Add capability-probed structured outputs and a prototype/instance creation graph.

Probe API profiles for json_schema/tools, flatten worker artifacts onto a strict schema, and let users spawn or revise graph nodes instead of a one-shot DAG.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-31 01:57:22 +08:00
co-authored by Cursor
parent 872f742d3e
commit bd5d88abfa
65 changed files with 7625 additions and 942 deletions
+16 -15
View File
@@ -24,25 +24,26 @@ function buildMainAgentSystemPrompt(
? workers.map((w) => `- ${w.id}:${w.description}`).join("\n")
: "- (当前 skill 未加载 worker 列表)";
return `你是创作节点路由器。只读取「设计.创作流程」DAG,并选择下一个要执行的创作节点。
- DAG 不存在或需要追加节点:调用 design-flow。
- DAG 中已有下一个可执行节点:调用 design-step。
- 只调度 worker,不创作正文,不规划 DAG 之外的流程。
return `你是创作节点路由器。当前没有「设计.创作流程」。本轮调用 run_worker:workerId 为 design-flow,排出近期起点。
当前 skill 可用 worker(workerId 必须与下列 id 完全一致):
${workerLines}
输出必须是 JSON 对象,字段:
{
"action": "ask_user" | "run_worker" | "create_temp_worker" | "review_blackboard" | "finish",
"reason": "string",
"assessment": "string | null",
"questions": [{ "id": "q1", "prompt": "…", "options": [{ "label": "建议示范…" }] }] | null,
"workerId": "string | null",
"requiresApproval": boolean,
"workerContext": { "roleId": "string" } | null
}`;
结束本轮必须调用 run_worker(design-flow)。reason 用一句话说明根据用户需求开始编排;requiresApproval 为 false。`;
}
/** 总管把推理写成正文、未给出可用工具/JSON 时,运行时改走点选或 design-flow。 */
export function isUnusableMainAgentOutput(err: unknown): boolean {
const msg = err instanceof Error ? err.message : String(err);
return (
/invalid JSON/i.test(msg) ||
/no tool calls and no content/i.test(msg) ||
/Invalid action/i.test(msg) ||
/must be an object/i.test(msg) ||
/requires reason/i.test(msg) ||
/multiple terminal tools/i.test(msg) ||
/Not a terminal tool/i.test(msg)
);
}
export class MainAgent {
+2 -7
View File
@@ -42,17 +42,12 @@ function buildToolLoopSystemPrompt(
? workers.map((w) => `- ${w.id}:${w.description}`).join("\n")
: "- (当前 skill 未加载 worker 列表)";
return `你是创作节点路由器。只根据「设计.创作流程」DAG 选择下一个创作节点。
1. 用 read_blackboard 读取「设计.创作流程」及其进度 tag。
2. 没有 DAG 或 DAG 需要追加节点时,run_worker(design-flow)。
3. DAG 已给出下一个可执行节点时,run_worker(design-step)。
4. 不创作正文,不改写 DAG,不处理运行状态或游玩流程。
return `你是创作节点路由器。当前没有「设计.创作流程」。本轮调用 run_worker:workerId 为 design-flow,排出近期起点。
当前 skill 可用 worker:
${workerLines}
选定节点后立即调用 run_worker。`;
结束本轮必须调用 run_worker(design-flow)。reason 用一句话说明根据用户需求开始编排;requiresApproval 为 false。`;
}
function executeLoopTool(