引入上下文片段、固定槽与投影排序,并完善机遇裁定与游玩期 UI。

把创作产物收敛为可挂载片段与 play_slots/context_order,同步修订世界模拟器模块与运行时拼装。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 01:36:32 +08:00
co-authored by Cursor
parent 00dfcb6615
commit 94f67fa744
69 changed files with 7786 additions and 1283 deletions
+21 -3
View File
@@ -32,7 +32,7 @@ function buildMainAgentSystemPrompt(
4. 当信息不足时,使用 ask_user:assessment 是主内容(完备度评价);questions 挂在其下且用户可跳过;一次 1~2 题。
5. 当需要执行任务时,使用 run_worker,只指定 workerId。不要指定 inputTags 或 outputTags——Runtime 从 Worker Skill 读取。
6. requiresApproval 表示运行 worker 前是否需要用户确认。代笔模式通常为 true。
7. run_worker 可选 workerContext:{ "roleId": "A" },用于 role-decide 等指定当前决策角色(Runtime 写入 世界.当前角色.id)。
7. run_worker 可选 workerContext:{ "roleId": "A" } 或 { "chance": { "op":"roll", "expression":"2d6" } }(机遇裁定走程序,勿让模型编随机)。
8. 你不能把未验收内容当作事实。
9. 向用户提问是 worker 的技能(ask_user tool),不是独立 worker。编排器只在调度层提问。
10. blackboardIndex 只有 tag 索引,不含正文 content。
@@ -175,9 +175,27 @@ export function parseMainAgentDecision(raw: string): MainAgentDecision {
let workerContext: MainAgentDecision["workerContext"];
const ctxRaw = obj.workerContext;
if (ctxRaw && typeof ctxRaw === "object" && !Array.isArray(ctxRaw)) {
const roleIdRaw = (ctxRaw as Record<string, unknown>).roleId;
const ctx = ctxRaw as Record<string, unknown>;
const roleIdRaw = ctx.roleId;
const roleId = typeof roleIdRaw === "string" ? roleIdRaw.trim() : undefined;
if (roleId) workerContext = { roleId };
const chanceRaw = ctx.chance;
const chance =
chanceRaw && typeof chanceRaw === "object" && !Array.isArray(chanceRaw)
? (chanceRaw as Record<string, unknown>)
: undefined;
if (roleId || chance) {
workerContext = {
...(roleId ? { roleId } : {}),
...(chance ? { chance } : {}),
};
}
}
// 兼容 tool 扁平参数 chance(与 workerContext.chance 等价)
if (!workerContext?.chance && obj.chance && typeof obj.chance === "object") {
workerContext = {
...(workerContext ?? {}),
chance: obj.chance as Record<string, unknown>,
};
}
const assessmentRaw =
+6 -1
View File
@@ -133,7 +133,7 @@ export const MAIN_AGENT_TOOL_DEFINITIONS: ToolDefinition[] = [
function: {
name: "run_worker",
description:
"调度 worker 执行任务。只传 workerId,inputTags/outputTags 由 Runtime 从 Worker Skill 读取。",
"调度 worker。常规只传 workerId。调度 chance(机遇裁定)时传 chance 请求对象(程序掷骰/比点/抽签,禁止让模型编随机)。",
parameters: {
type: "object",
properties: {
@@ -147,6 +147,11 @@ export const MAIN_AGENT_TOOL_DEFINITIONS: ToolDefinition[] = [
type: "string",
description: "role-decide 等 worker 的当前角色 id",
},
chance: {
type: "object",
description:
"仅 workerId=chance:{ op:'roll'|'compare'|'draw'|'pick', ... }。例 roll:{expression:'2d6+1'};draw:{pool:['a','b'],count:1}",
},
},
required: ["workerId", "reason", "requiresApproval"],
additionalProperties: false,