From 7d796ee5070c0729d2a96ba03183799c9bb04b60 Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 1 Oct 2026 16:22:12 +0000 Subject: [PATCH] Sync workflow definition types from Core Why: The frontend contract mirror has to include script steps and critic fields before a workflow can be described to the client. Evidence: make contracts copied modules/core/ts/types.ts. No screen or event changed. Impact: contracts.ts only. The existing plan, inbox, and HITL cards stay the UI. Refs: feature/agent-harness-p4 Co-authored-by: Cursor --- src/contracts.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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;