Files
AgentLab/frontend/src/types.ts
T
ThearchyHelios 0895a01b41 变量表抽屉;顺便治了一个每敲一键发一次全图请求的老毛病
先说顺带修的那个,因为它是前提:validate() **零防抖**,从七个 mutation 点
直接调,其中包括 updateNode——也就是 Inspector 里每敲一个字都发一次带全图
的 POST。实测敲 15 个字 = 15 次请求。再挂一个变量分析就是翻倍,所以必须先
治:一次防抖(300ms)、两个请求并发、epoch 丢弃过期响应(图在飞行期间又改
了的话,旧答案不能覆盖新答案——校验结果闪回是最难查的那种 UI bug)。
现在敲 15 个字 = 1 次请求。

变量表另有一层跳过:**"有哪些变量"只取决于结构,不取决于文案**。节点 id、
类型、assign_to、入口字段名组成签名,改 prompt 里一个字不会触发变量分析。

抽屉本身做成挤压式而不是浮层——React Flow 的 Controls 和 MiniMap 是绝对
定位在画布容器里的,浮层会把它俩埋掉,挤压会把它俩顶上去。限高并给画布
留底(React Flow 容器高度归零会直接报 error 004),可拖拽改高,两端都夹住。

表里四列:变量 / 来自哪个节点 / 被引用几处 / 最近一次运行的值。点开右侧
详情能看到谁产出、每一处引用在哪个节点的哪个字段,点一下定位到画布。
实跑验证:

  {{ input.question }}  输入   —     变量表要显示这个值
  {{ vars.question }}   输入   —     变量表要显示这个值
  {{ nodes.start }}     输入   —     { "question": "变量表要显示这个值" }
  {{ last_message }}    内置   1 处  —

另外让用户看得见**真正跑的那份代码**:代码节点送进沙箱的是 {{ }} 渲染后的
字符串,和编辑器里那份可能差很远(一个带引号或换行的值插进字符串字面量里
就把程序写坏了),而报错指的是渲染后的行号,对着自己那份怎么也数不对。
sandbox.start 现在带上渲染结果,只在真插过值时才显示(没插值的两份一模一样,
显示等于噪音)。沙箱步骤的 detail/result 也分开了:detail 是跑的什么,
result 是跑出了什么——塞一个字段里的话,报错时最需要的两样东西只能看见一样。
2026-09-18 10:48:22 +08:00

186 lines
3.9 KiB
TypeScript

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<string, any> }
}
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<string, any>
defaults?: Record<string, any>
}
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<string, any>
output: Record<string, any>
error: string | null
usage: Record<string, any>
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<string, any>
replay?: boolean
}
export interface Approval {
id: string
run_id: string
node_id: string
mode: 'approve' | 'input' | 'edit'
title: string
payload: Record<string, any>
status: string
response: Record<string, any>
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<string, any>
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<string, any>
}
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<string, any>
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
}