引入游玩回合与开场收口,抽出可替换 agent 司机并支持运行中止;完善预设洞位、世界书拼装与试跑,并打磨会话运行时与 Web 交互。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-24 01:13:48 +08:00
co-authored by Cursor
parent ec474cb946
commit b82da4c5a5
95 changed files with 6781 additions and 1344 deletions
+44 -5
View File
@@ -1,3 +1,5 @@
import type { GenerationParameters } from "./preset.js";
/** 一次 LLM 调用实际发送的上下文(全量,供右键观察) */
export type LlmContextMessage = {
role: string;
@@ -12,17 +14,51 @@ export type LlmContextTrace = {
/** 便于列表展示 */
charCount: number;
model?: string;
/** 与请求一并送出的生成参数(无则未带) */
generation?: GenerationParameters;
};
/** 把即将写入请求 body.messages 的条目冻成痕迹(含 tool_calls 等附加字段) */
export function snapshotRequestMessages(
messages: Array<{
role: string;
content?: string | null;
tool_calls?: unknown;
tool_call_id?: string;
}>,
): LlmContextMessage[] {
return messages.map((m) => {
const hasExtras = Boolean(m.tool_calls) || Boolean(m.tool_call_id);
if (!hasExtras) {
return {
role: m.role,
content: typeof m.content === "string" ? m.content : String(m.content ?? ""),
};
}
return {
role: m.role,
content: JSON.stringify({
role: m.role,
content: m.content ?? "",
...(m.tool_calls ? { tool_calls: m.tool_calls } : {}),
...(m.tool_call_id ? { tool_call_id: m.tool_call_id } : {}),
}),
};
});
}
export function buildContextTrace(params: {
caller: string;
messages: Array<{ role: string; content: string }>;
messages: Array<{
role: string;
content?: string | null;
tool_calls?: unknown;
tool_call_id?: string;
}>;
model?: string;
generation?: GenerationParameters;
}): LlmContextTrace {
const messages = params.messages.map((m) => ({
role: m.role,
content: typeof m.content === "string" ? m.content : String(m.content ?? ""),
}));
const messages = snapshotRequestMessages(params.messages);
const charCount = messages.reduce((n, m) => n + m.content.length, 0);
return {
caller: params.caller,
@@ -30,6 +66,9 @@ export function buildContextTrace(params: {
messages,
charCount,
model: params.model,
...(params.generation && Object.keys(params.generation).length
? { generation: params.generation }
: {}),
};
}
+11 -2
View File
@@ -53,7 +53,10 @@ export type WaitingReason =
} // worker 无产物时的阻塞提问
| { kind: "revision"; instruction?: string } // 无意见打回时等补交;有意见则直接重跑
| {
/** 上一步已验收:先问「下一步想写什么」(可留空),再提案并确认开干 */
/**
* 旧路径:上一步验收后先问「下一步想写什么」。
* 现已改为验收后直接提案;保留此 kind 以兼容未完成的旧会话。
*/
kind: "next_intent";
afterWorkerId?: string;
afterUnitId?: string;
@@ -329,7 +332,13 @@ export type PhaseEffect =
| { type: "run_programmatic_review"; artifactId: string }
| { type: "emit_message"; message: string }
/** 根据流程与用户下一步意向,提案下一节点并进入确认 */
| { type: "propose_next_creation_step" };
| { type: "propose_next_creation_step" }
/** 选定开场白:落库、关 DAG、标记创作收口 */
| { type: "seal_creation_opening" }
/** 游玩:按运行规格开一轮(旁观 → 主世界层 → 转述) */
| { type: "run_play_turn" }
/** 游玩:跑管线里的下一个执行单元;队空则等下一条用户输入 */
| { type: "continue_play_turn" };
/** applyEvent 的返回值:新会话快照 + 待处理副作用 + 可选错误 */
export type ApplyEventResult = {