Procházet zdrojové kódy

feat(可视化前端): 定义真实执行与任务详情类型

前端类型与后端真实投影一一对应,覆盖运行摘要、动态 Task、Planner Turn、生命周期、Attempt、Agent Step 和 DataUsage。删除旧固定 PhaseFrame、Edge 与 Inspector 合同。
SamLee před 19 hodinami
rodič
revize
c02ec98640
1 změnil soubory, kde provedl 107 přidání a 60 odebrání
  1. 107 60
      visualization/frontend/lib/types.ts

+ 107 - 60
visualization/frontend/lib/types.ts

@@ -1,78 +1,125 @@
-export type NodeType =
-  | "input" | "contract" | "operation" | "worker" | "attempt" | "artifact"
-  | "validator" | "validation" | "decision" | "checkpoint" | "publication"
-  | "transaction" | "readback";
-
-export type Phase = "phase-1" | "phase-2" | "phase-3" | "delivery";
+export interface RunSummary {
+  script_build_id: number;
+  title: string;
+  status: string;
+  checkpoint: string;
+  root_trace_id: string;
+  revision: number;
+  task_count: number;
+  attempt_count: number;
+  planner_turn_count: number;
+  current_focus_task_id: string | null;
+  current_gap: string;
+  created_at: string;
+  updated_at: string;
+}
 
-export interface Metric { label: string; value: string }
+export interface TaskNode {
+  task_id: string;
+  display_path: string;
+  parent_task_id: string | null;
+  child_task_ids: string[];
+  task_kind: string;
+  phase: string;
+  objective: string;
+  status: string;
+  blocked_reason: string | null;
+  attempt_count: number;
+  validation_count: number;
+  decision_count: number;
+  current_spec_version: number;
+  acceptance_criteria: Array<Record<string, unknown>>;
+  context_refs: string[];
+  created_at: string;
+  updated_at: string;
+}
 
-export interface RecordEnvelope {
-  model_name: string;
-  schema_version: string | null;
-  payload: Record<string, unknown>;
+export interface PlannerTurn {
+  turn_id: string;
+  order: number;
+  message_sequence: number;
+  phase: string;
+  action: string;
+  action_label: string;
+  summary: string;
+  observable_reasoning: string;
+  result_summary: string;
+  status: "succeeded" | "failed" | "unknown";
+  focus_task_id: string | null;
+  affected_task_ids: string[];
+  visible_task_ids: string[];
+  tool_name: string;
+  tool_arguments: Record<string, unknown>;
+  tokens: number;
+  cost: number;
+  created_at: string;
 }
 
-export interface FlowNodeRecord {
-  id: string;
-  node_type: NodeType;
-  phase: Phase;
-  lane: string;
+export interface LifecycleEvent {
+  event_id: string;
+  kind: "task" | "attempt" | "validation" | "decision";
   title: string;
-  subtitle: string;
   status: string;
-  agent_role: string | null;
-  task_kind: string | null;
+  summary: string;
+  created_at: string;
+  attempt_id: string | null;
+}
+
+export interface AgentStep {
   sequence: number;
-  x: number;
-  y: number;
-  width: number;
-  tags: string[];
-  metrics: Metric[];
-  record: RecordEnvelope;
+  role: string;
+  step_kind: "instruction" | "explanation" | "tool_call" | "tool_result";
+  title: string;
+  text: string;
+  tool_name: string | null;
+  tool_arguments: Record<string, unknown> | null;
+  tokens: number;
+  cost: number;
+  duration_ms: number | null;
+  created_at: string;
 }
 
-export interface FlowEdgeRecord {
-  id: string;
-  source: string;
-  target: string;
-  label: string | null;
-  kind: "control" | "artifact" | "validation" | "publication";
-  animated: boolean;
+export interface AttemptDetail {
+  attempt_id: string;
+  task_id: string;
+  status: string;
+  worker_preset: string | null;
+  worker_trace_id: string | null;
+  execution_mode: string | null;
+  started_at: string | null;
+  completed_at: string | null;
+  total_tokens: number;
+  total_cost: number;
+  error: unknown;
+  submission: Record<string, unknown> | null;
+  validation: Record<string, unknown> | null;
+  decision: Record<string, unknown> | null;
+  prompt: string;
+  steps: AgentStep[];
 }
 
-export interface PhaseFrame {
-  id: string;
-  title: string;
-  subtitle: string;
-  x: number;
-  y: number;
-  width: number;
-  height: number;
-  tone: "coral" | "blue" | "purple" | "green";
+export interface DataUsage {
+  inherited_inputs: Array<Record<string, unknown>>;
+  confirmed_reads: Array<Record<string, unknown>>;
+  produced_outputs: Array<Record<string, unknown>>;
+  adoption: Array<Record<string, unknown>>;
 }
 
-export interface RunSummary {
-  script_build_id: number;
-  title: string;
-  status: string;
-  checkpoint: string;
-  root_trace_id: string;
-  publication_state: string;
-  node_count: number;
-  created_at: string;
-  updated_at: string;
+export interface TaskDetail {
+  task: TaskNode;
+  contract: Record<string, unknown> | null;
+  lifecycle: LifecycleEvent[];
+  attempts: AttemptDetail[];
+  data_usage: DataUsage;
 }
 
-export interface RunGraph {
-  schema_version: "script-build-visualization/v1";
-  data_mode: "fake";
+export interface ExecutionView {
+  schema_version: "script-build-execution-view/v1";
+  data_mode: "persisted-real-run";
   generated_at: string;
   run: RunSummary;
-  frames: PhaseFrame[];
-  nodes: FlowNodeRecord[];
-  edges: FlowEdgeRecord[];
-  schema_catalog: Record<string, string[]>;
-  enum_catalog: Record<string, string[]>;
-  declared_gaps: string[];
+  planner_turns: PlannerTurn[];
+  tasks: TaskNode[];
+  snapshot_basis: string;
+  warnings: string[];
 }