diff --git a/src/contracts.ts b/src/contracts.ts index f914030..46572ba 100644 --- a/src/contracts.ts +++ b/src/contracts.ts @@ -262,6 +262,36 @@ export interface PluginPanel { id: string; title: string; icon?: string; body: UINode[]; refreshTool?: string; } +/** 模板占位符:{{input}}、{{slots.}}、{{steps..output}}。 */ +export interface WorkflowDef { + id: string; title: string; description?: string; intentId?: string; + /** 整条工作流的 critic 重试上限。 */ + maxRetries?: number; + steps: WorkflowStep[]; +} + +export interface StepCritic { + criteria: string; + /** 本步重试上限;缺省 1 次。 */ + maxRetries?: number; +} + +export interface WorkflowStep { + id: string; title: string; + kind: 'prompt' | 'tool' | 'hitl' | 'artifact' | 'card' | 'script'; + prompt?: string; + /** prompt 步骤的子代理 profile,缺省 general。 */ + agent?: string; + tool?: string; + args?: unknown; + hitl?: { question: string; kind: HITLKind; choices?: HITLChoice[]; allowFreeInput: boolean; freeInputHint?: string }; + artifact?: string; + card?: { kind: CardKind; title: string; tone?: string; body?: UINode[]; actions?: { id: string; label: string; style?: 'primary' | 'default' | 'danger'; command?: string }[] }; + /** script 步骤在插件目录内的相对路径。 */ + script?: string; + critic?: StepCritic; +} + export interface PluginWorkspace { id: string; title: string; icon?: string; shortcut?: string; badgeTool?: string; body: UINode[]; refreshTool?: string;