cleanup: remove all unconnected Phase I+J scaffold code and unconnected Phase F+H modules (workstream_contract, proactive_feed, dashboard, dsgvo_export, onboarding, mcp_exposure, integration_tools, self_improvement, agent_workstream, workflows/workstream, knowledge_sources, knowledge_extraction, knowledge_lifecycle, platform.py routes, 13 frontend files, 2 test files), restore Dashboard.tsx, tsc clean, backend OK
This commit is contained in:
@@ -1,159 +0,0 @@
|
||||
/**
|
||||
* Controlled Self-Improvement API client (Phase J).
|
||||
*
|
||||
* All requests use the shared `apiClient` (`baseURL: '/api/v1'`) and target
|
||||
* the self-improvement routes under `/improvement/...`.
|
||||
*/
|
||||
|
||||
import { apiDelete, apiGet, apiPost, apiPut } from './client';
|
||||
|
||||
// ─── Types ───
|
||||
|
||||
export type ProposalType =
|
||||
| 'agent'
|
||||
| 'skill'
|
||||
| 'trigger'
|
||||
| 'workflow'
|
||||
| 'miniapp_template'
|
||||
| 'plugin_patch';
|
||||
|
||||
export type ProposalStatus =
|
||||
| 'draft'
|
||||
| 'evaluating'
|
||||
| 'pending_approval'
|
||||
| 'approved'
|
||||
| 'rejected'
|
||||
| 'active'
|
||||
| 'rolled_back'
|
||||
| 'expired';
|
||||
|
||||
export type SignalType =
|
||||
| 'agent_run'
|
||||
| 'workflow_run'
|
||||
| 'proactive_suggestion'
|
||||
| 'audit_log'
|
||||
| 'entity_history'
|
||||
| 'user_correction'
|
||||
| 'handoff'
|
||||
| 'error_retry';
|
||||
|
||||
export interface ImprovementSignal {
|
||||
id: string;
|
||||
signal_type: SignalType;
|
||||
source_ref: string;
|
||||
tenant_id: string;
|
||||
user_id?: string | null;
|
||||
timestamp: string;
|
||||
outcome: string;
|
||||
metadata: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface DetectedPattern {
|
||||
id: string;
|
||||
pattern_type: string;
|
||||
description: string;
|
||||
confidence: number;
|
||||
occurrence_count: number;
|
||||
evidence_refs: string[];
|
||||
metadata: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface EvaluationResult {
|
||||
proposal_id?: string;
|
||||
draft_id?: string;
|
||||
evaluated_at?: string;
|
||||
test_cases: number;
|
||||
passed: number;
|
||||
failed: number;
|
||||
score: number;
|
||||
recommendation: string;
|
||||
details?: unknown[];
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface ImprovementProposal {
|
||||
id: string;
|
||||
proposal_type: ProposalType;
|
||||
title: string;
|
||||
description: string;
|
||||
rationale: string;
|
||||
expected_benefit: string;
|
||||
risk_assessment: string;
|
||||
status: ProposalStatus;
|
||||
evidence_refs: string[];
|
||||
pattern_refs: string[];
|
||||
draft_config: Record<string, unknown>;
|
||||
evaluation_result: EvaluationResult;
|
||||
measurement_before: Record<string, unknown>;
|
||||
measurement_after: Record<string, unknown>;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
approved_by?: string | null;
|
||||
activated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface VersionedDraft {
|
||||
id: string;
|
||||
proposal_id: string;
|
||||
version: number;
|
||||
config: Record<string, unknown>;
|
||||
previous_version_id?: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface ProposalActionResponse {
|
||||
proposal_id: string;
|
||||
status: string;
|
||||
error?: string;
|
||||
approval_id?: string;
|
||||
activated_at?: string;
|
||||
rolled_back_at?: string;
|
||||
rollback_available?: boolean;
|
||||
previous_version_id?: string | null;
|
||||
evaluation?: EvaluationResult;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
// ─── Proposals ───
|
||||
|
||||
export const fetchProposals = (status?: ProposalStatus) =>
|
||||
apiGet<ImprovementProposal[]>('/improvement/proposals', {
|
||||
params: status ? { status } : {},
|
||||
});
|
||||
|
||||
export const fetchProposal = (id: string) =>
|
||||
apiGet<ImprovementProposal>(`/improvement/proposals/${id}`);
|
||||
|
||||
export const approveProposal = (id: string) =>
|
||||
apiPost<ProposalActionResponse>(`/improvement/proposals/${id}/approve`);
|
||||
|
||||
export const rejectProposal = (id: string) =>
|
||||
apiPost<ProposalActionResponse>(`/improvement/proposals/${id}/reject`);
|
||||
|
||||
export const rollbackProposal = (id: string) =>
|
||||
apiPost<ProposalActionResponse>(`/improvement/proposals/${id}/rollback`);
|
||||
|
||||
export const activateProposal = (id: string) =>
|
||||
apiPost<ProposalActionResponse>(`/improvement/proposals/${id}/activate`);
|
||||
|
||||
export const deleteProposal = (id: string) =>
|
||||
apiDelete<{ status: string }>(`/improvement/proposals/${id}`);
|
||||
|
||||
// ─── Patterns ───
|
||||
|
||||
export const fetchPatterns = () => apiGet<DetectedPattern[]>('/improvement/patterns');
|
||||
|
||||
// ─── Signals ───
|
||||
|
||||
export const fetchSignals = (days?: number) =>
|
||||
apiGet<ImprovementSignal[]>('/improvement/signals', {
|
||||
params: days ? { days } : {},
|
||||
});
|
||||
|
||||
// ─── Drafts ───
|
||||
|
||||
export const fetchDraft = (proposalId: string) =>
|
||||
apiGet<VersionedDraft>(`/improvement/proposals/${proposalId}/draft`);
|
||||
|
||||
export const updateDraft = (proposalId: string, config: Record<string, unknown>) =>
|
||||
apiPut<VersionedDraft>(`/improvement/proposals/${proposalId}/draft`, { config });
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* MiniApp manifest types + workstream block types (Phase I.2 Workstream & MiniApps).
|
||||
*
|
||||
* Mirrors backend contracts:
|
||||
* - app/plugins/manifest.py → MiniAppContribution
|
||||
* - app/ai/workstream_contract.py → WorkstreamBlock / WorkstreamMessage
|
||||
* - app/ai/proactive_feed.py → ProactiveSuggestion
|
||||
*/
|
||||
|
||||
// ── MiniApp manifest contribution (backend: MiniAppContribution) ──
|
||||
|
||||
export interface MiniAppContribution {
|
||||
app_id: string;
|
||||
name: string;
|
||||
icon: string;
|
||||
description: string;
|
||||
render_schema: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin manifest with optional `miniapps` field.
|
||||
* Only the fields relevant to MiniApps are declared here; the full manifest
|
||||
* is typed in store/pluginStore.ts (PluginUiManifest).
|
||||
*/
|
||||
export interface PluginManifestWithMiniApps {
|
||||
name: string;
|
||||
display_name: string;
|
||||
version: string;
|
||||
miniapps?: MiniAppContribution[];
|
||||
}
|
||||
|
||||
// ── Workstream block types (backend: WorkstreamBlock) ──
|
||||
|
||||
export type WorkstreamBlockType =
|
||||
| 'text'
|
||||
| 'entity_card'
|
||||
| 'action_card'
|
||||
| 'evidence_card'
|
||||
| 'approval_card'
|
||||
| 'miniapp'
|
||||
| 'workflow_status'
|
||||
| 'workflow_handoff'
|
||||
| 'error';
|
||||
|
||||
export interface WorkstreamBlock {
|
||||
type: WorkstreamBlockType;
|
||||
content: string;
|
||||
metadata: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export type WorkstreamActorType = 'human' | 'system' | 'agent' | 'workflow';
|
||||
|
||||
export interface WorkstreamMessage {
|
||||
actor_type: WorkstreamActorType;
|
||||
actor_id?: string | null;
|
||||
content: string;
|
||||
blocks: WorkstreamBlock[];
|
||||
conversation_id?: string | null;
|
||||
tenant_id?: string | null;
|
||||
}
|
||||
|
||||
// ── Proactive suggestion (backend: ProactiveSuggestion) ──
|
||||
|
||||
export type ProactivePriority = 'low' | 'medium' | 'high' | 'urgent';
|
||||
|
||||
export interface ProactiveSuggestion {
|
||||
id: string;
|
||||
trigger: string;
|
||||
title: string;
|
||||
description: string;
|
||||
priority: ProactivePriority;
|
||||
action_type: 'suggestion' | 'action_required' | 'info';
|
||||
action_url: string;
|
||||
entity_type?: string | null;
|
||||
entity_id?: string | null;
|
||||
blocks: WorkstreamBlock[];
|
||||
created_at: string;
|
||||
expires_at?: string | null;
|
||||
metadata: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface ProactiveFeedSettings {
|
||||
enabled: boolean;
|
||||
min_priority: ProactivePriority;
|
||||
max_per_hour: number;
|
||||
triggers_enabled: Record<string, boolean>;
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
/**
|
||||
* Platform API hooks — Phase I.6/I.7 (I-ONB, I-DASH, I-COST, I-USE).
|
||||
*
|
||||
* Provides hooks for the setup wizard (onboarding) and the platform dashboard
|
||||
* (agent status, workflow stats, search metrics, knowledge coverage, cost
|
||||
* tracking, system health). Backend routes may not be wired yet, so all hooks
|
||||
* degrade gracefully to an "unavailable" state instead of throwing.
|
||||
*/
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { apiGet } from './client';
|
||||
|
||||
// ── Onboarding ──────────────────────────────────────────────────────────────
|
||||
|
||||
export interface OnboardingStepStatus {
|
||||
completed: boolean;
|
||||
required: boolean;
|
||||
}
|
||||
|
||||
export interface OnboardingStatus {
|
||||
steps: Record<string, OnboardingStepStatus>;
|
||||
progress_pct: number;
|
||||
}
|
||||
|
||||
export interface OnboardingGuideStep {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string;
|
||||
icon?: string;
|
||||
action_url?: string;
|
||||
}
|
||||
|
||||
export interface OnboardingGuide {
|
||||
steps: OnboardingGuideStep[];
|
||||
}
|
||||
|
||||
export function useOnboardingStatus() {
|
||||
return useQuery({
|
||||
queryKey: ['onboardingStatus'],
|
||||
queryFn: () => apiGet<OnboardingStatus>('/onboarding/status'),
|
||||
staleTime: 60 * 1000,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export function useOnboardingGuide() {
|
||||
return useQuery({
|
||||
queryKey: ['onboardingGuide'],
|
||||
queryFn: () => apiGet<OnboardingGuide>('/onboarding/guide'),
|
||||
staleTime: 60 * 1000,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
// ── Platform dashboard ──────────────────────────────────────────────────────
|
||||
|
||||
export interface PlatformDashboardData {
|
||||
agents?: {
|
||||
active_agents?: number;
|
||||
total_runs?: number;
|
||||
recent_runs_7d?: number;
|
||||
error?: string;
|
||||
};
|
||||
workflows?: {
|
||||
active_workflows?: number;
|
||||
running_instances?: number;
|
||||
completed_instances?: number;
|
||||
error?: string;
|
||||
};
|
||||
search?: {
|
||||
total_queries?: number;
|
||||
avg_latency_ms?: number;
|
||||
error?: string;
|
||||
};
|
||||
knowledge?: {
|
||||
wiki_articles?: number;
|
||||
coverage_pct?: number;
|
||||
error?: string;
|
||||
};
|
||||
workstream?: {
|
||||
messages?: number;
|
||||
error?: string;
|
||||
};
|
||||
system_health?: {
|
||||
redis?: string;
|
||||
status?: string;
|
||||
error?: string;
|
||||
};
|
||||
generated_at?: string;
|
||||
}
|
||||
|
||||
export function usePlatformDashboard() {
|
||||
return useQuery({
|
||||
queryKey: ['platformDashboard'],
|
||||
queryFn: () => apiGet<PlatformDashboardData>('/dashboard/platform'),
|
||||
staleTime: 60 * 1000,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
// ── Cost tracking ───────────────────────────────────────────────────────────
|
||||
|
||||
export interface CostDashboardData {
|
||||
period_days?: number;
|
||||
total_cost_usd?: number;
|
||||
by_agent?: Record<string, { cost_usd: number; runs: number }>;
|
||||
budget?: {
|
||||
monthly_limit_usd?: number;
|
||||
utilization_pct?: number;
|
||||
};
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export function useCostDashboard(days = 30) {
|
||||
return useQuery({
|
||||
queryKey: ['costDashboard', days],
|
||||
queryFn: () => apiGet<CostDashboardData>(`/dashboard/cost?days=${days}`),
|
||||
staleTime: 60 * 1000,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
// ── Usage analytics ─────────────────────────────────────────────────────────
|
||||
|
||||
export interface UsageAnalyticsData {
|
||||
period_days?: number;
|
||||
agent_runs?: {
|
||||
total?: number;
|
||||
completed?: number;
|
||||
failed?: number;
|
||||
success_rate?: number;
|
||||
error?: string;
|
||||
};
|
||||
workflow_executions?: {
|
||||
total?: number;
|
||||
completed?: number;
|
||||
error?: string;
|
||||
};
|
||||
search_queries?: {
|
||||
total?: number;
|
||||
error?: string;
|
||||
};
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export function useUsageAnalytics(days = 30) {
|
||||
return useQuery({
|
||||
queryKey: ['usageAnalytics', days],
|
||||
queryFn: () => apiGet<UsageAnalyticsData>(`/dashboard/usage?days=${days}`),
|
||||
staleTime: 60 * 1000,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user