export type NodeType = | 'input' | 'output' | 'llm' | 'agent' | 'supervisor' | 'tool' | 'code' | 'branch' | 'loop' | 'subgraph' | 'memory' | 'retrieve' | 'transform' | 'human' | 'validate' | 'metrics' export interface GraphNode { id: string type: NodeType position: { x: number; y: number } data: { label?: string; description?: string; config: Record } } export interface GraphEdge { id?: string source: string target: string sourceHandle?: string | null targetHandle?: string | null label?: string } export interface GraphSpec { nodes: GraphNode[] edges: GraphEdge[] viewport?: Record defaults?: Record } export interface Workflow { id: string name: string description: string graph: GraphSpec tags: string[] version: number is_template: boolean status?: 'draft' | 'published' | 'governed' published_version?: number | null run_count?: number created_at?: string updated_at?: string } export type RunStatus = | 'queued' | 'running' | 'interrupted' | 'succeeded' | 'failed' | 'cancelled' export interface Run { id: string workflow_id: string | null workflow_name: string status: RunStatus input: Record output: Record error: string | null usage: Record run_class?: 'formal' | 'exploratory' version?: number | null version_hash?: string | null manifest_hash?: string | null started_by?: string | null created_at?: string started_at?: string finished_at?: string } export interface RunEvent { seq: number type: string node_id: string | null ts: number data: Record replay?: boolean } export interface Approval { id: string run_id: string node_id: string mode: 'approve' | 'input' | 'edit' title: string payload: Record status: string response: Record created_at?: string } export interface Provider { id: string name: string kind: string base_url: string | null default_model: string | null models: { id: string; label?: string; context?: number; pricing?: any }[] enabled: boolean extra: Record api_key_masked: string has_key: boolean } export interface ToolInfo { id: string name: string description: string category: string source: 'builtin' | 'custom' | 'mcp' dangerous: boolean schema: Record } export interface Skill { id: string name: string description: string instructions: string examples: { input?: string; output?: string }[] suggested_tools: string[] tags: string[] enabled: boolean } export interface MemoryItem { id: string scope: string kind: string content: string importance: number use_count: number meta: Record created_at?: string } export interface KbDocument { id: string collection: string title: string source: string mime: string chunk_count: number created_at?: string } export interface ValidationIssue { level: 'error' | 'warning' node_id?: string | null edge_id?: string | null message: string } /** 单个节点在一次运行中的实时状态,驱动画布上的高亮。 */ export interface NodeRuntime { status: 'idle' | 'running' | 'done' | 'failed' | 'waiting' | 'skipped' durationMs?: number preview?: any error?: string tokens?: string thinking?: string toolCalls?: { tool: string; args?: any; result?: string; ok?: boolean }[] } /** 一处 {{ }} 引用 */ export interface VarRef { node_id: string node_label: string field: string expr: string } /** 一个可以被 {{ }} 引用的东西。由后端静态分析整张图得出 */ export interface Variable { path: string kind: 'input' | 'var' | 'node' | 'builtin' | 'loop' label: string produced_by?: string | null produced_by_label?: string | null order: number refs: VarRef[] description: string } export interface VarIssue { level: 'error' | 'warning' | 'info' message: string node_id?: string | null path: string }