feat: summarize codex stream progress events
This commit is contained in:
77
tests/fixtures/codex-app-server-runtime.mjs
vendored
77
tests/fixtures/codex-app-server-runtime.mjs
vendored
@@ -1401,6 +1401,83 @@ rl.on("line", (line) => {
|
||||
},
|
||||
});
|
||||
}
|
||||
if (process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_STREAM_DELTA_EVENTS === "1") {
|
||||
send({
|
||||
method: "item/plan/delta",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
itemId: "plan-delta-secret-should-not-leak",
|
||||
delta: "secret plan delta should not leak",
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/reasoning/summaryPartAdded",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
itemId: "reasoning-delta-secret-should-not-leak",
|
||||
summaryIndex: 0,
|
||||
part: "secret reasoning summary part should not leak",
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/reasoning/summaryTextDelta",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
itemId: "reasoning-delta-secret-should-not-leak",
|
||||
summaryIndex: 0,
|
||||
delta: "secret reasoning summary delta should not leak",
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/reasoning/textDelta",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
itemId: "reasoning-delta-secret-should-not-leak",
|
||||
delta: "secret raw reasoning delta should not leak",
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/mcpToolCall/progress",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
itemId: "mcp-progress-secret-should-not-leak",
|
||||
message: "secret mcp progress should not leak",
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/commandExecution/outputDelta",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
itemId: "command-output-secret-should-not-leak",
|
||||
stream: "stdout",
|
||||
delta: "secret command output should not leak",
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/commandExecution/terminalInteraction",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
itemId: "terminal-interaction-secret-should-not-leak",
|
||||
input: "secret terminal input should not leak",
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/fileChange/outputDelta",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
itemId: "file-output-secret-should-not-leak",
|
||||
delta: "secret file output should not leak",
|
||||
},
|
||||
});
|
||||
}
|
||||
send({
|
||||
method: "item/agentMessage/delta",
|
||||
params: {
|
||||
|
||||
@@ -933,6 +933,56 @@ test("codex app-server runner maps collab tool calls and context compaction with
|
||||
}
|
||||
});
|
||||
|
||||
test("codex app-server runner summarizes stream deltas without leaking raw delta content", async () => {
|
||||
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_STREAM_DELTA_EVENTS;
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_STREAM_DELTA_EVENTS = "1";
|
||||
try {
|
||||
const runnerConfig = getCodexAppServerRunnerConfig(process.env, {
|
||||
codexAppServerEnabled: true,
|
||||
codexAppServerCommand: process.execPath,
|
||||
codexAppServerArgs: ["tests/fixtures/codex-app-server-runtime.mjs"],
|
||||
codexAppServerWorkdir: repoRoot,
|
||||
codexAppServerTimeoutMs: 5000,
|
||||
masterAgentModel: "gpt-5.4",
|
||||
});
|
||||
|
||||
const result = await executeCodexAppServerTask(runnerConfig, {
|
||||
taskId: "task-app-server-stream-deltas",
|
||||
taskType: "conversation_reply",
|
||||
targetCodexThreadRef: "019d-app-server-thread",
|
||||
targetCodexFolderRef: repoRoot,
|
||||
executionPrompt: "检查 Codex 流式增量进度",
|
||||
});
|
||||
|
||||
assert.equal(result.status, "completed");
|
||||
assert.deepEqual(result.executionProgress.streamEvents, {
|
||||
status: "completed",
|
||||
agentDeltaCount: 1,
|
||||
planDeltaCount: 1,
|
||||
reasoningDeltaCount: 3,
|
||||
toolProgressCount: 1,
|
||||
commandOutputChunkCount: 1,
|
||||
terminalInteractionCount: 1,
|
||||
fileOutputChunkCount: 1,
|
||||
});
|
||||
const serialized = JSON.stringify(result.executionProgress);
|
||||
assert.equal(serialized.includes("secret plan delta should not leak"), false);
|
||||
assert.equal(serialized.includes("secret reasoning summary part should not leak"), false);
|
||||
assert.equal(serialized.includes("secret reasoning summary delta should not leak"), false);
|
||||
assert.equal(serialized.includes("secret raw reasoning delta should not leak"), false);
|
||||
assert.equal(serialized.includes("secret mcp progress should not leak"), false);
|
||||
assert.equal(serialized.includes("secret command output should not leak"), false);
|
||||
assert.equal(serialized.includes("secret terminal input should not leak"), false);
|
||||
assert.equal(serialized.includes("secret file output should not leak"), false);
|
||||
} finally {
|
||||
if (previous === undefined) {
|
||||
delete process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_STREAM_DELTA_EVENTS;
|
||||
} else {
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_STREAM_DELTA_EVENTS = previous;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("codex app-server runner maps tool, search, image, review, and command activities without leaking payloads", async () => {
|
||||
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_TOOL_ACTIVITY_EVENTS;
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_TOOL_ACTIVITY_EVENTS = "1";
|
||||
|
||||
@@ -528,6 +528,78 @@ test("POST task progress preserves Codex thread collaboration summaries without
|
||||
assert.equal(serialized.includes("turn-secret-should-not-persist"), false);
|
||||
});
|
||||
|
||||
test("POST task progress preserves Codex stream event counters without leaking raw deltas", async () => {
|
||||
const task = await data.queueMasterAgentTask({
|
||||
taskId: "route-progress-stream-events-task",
|
||||
projectId: "group-progress-test",
|
||||
taskType: "dispatch_execution",
|
||||
requestMessageId: "msg-route-progress-stream-events",
|
||||
requestText: "检查 Codex 流式增量",
|
||||
executionPrompt: "检查 Codex 流式增量",
|
||||
requestedBy: "krisolo",
|
||||
requestedByAccount: "krisolo",
|
||||
deviceId: "mac-studio",
|
||||
targetProjectId: "master-agent",
|
||||
targetThreadId: "master-agent-thread",
|
||||
});
|
||||
await data.claimNextMasterAgentTask("mac-studio");
|
||||
|
||||
const response = await postProgress(
|
||||
new NextRequest(`http://127.0.0.1:3000/api/v1/master-agent/tasks/${task.taskId}/progress`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
"x-boss-device-token": "boss-mac-studio-token",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
deviceId: "mac-studio",
|
||||
status: "running",
|
||||
executionProgress: {
|
||||
steps: [{ text: "接收 Codex 流式事件", status: "running" }],
|
||||
streamEvents: {
|
||||
status: "streaming",
|
||||
agentDeltaCount: 2,
|
||||
planDeltaCount: 1,
|
||||
reasoningDeltaCount: 3,
|
||||
toolProgressCount: 1,
|
||||
commandOutputChunkCount: 4,
|
||||
terminalInteractionCount: 1,
|
||||
fileOutputChunkCount: 1,
|
||||
delta: "secret delta should-not-persist",
|
||||
text: "secret text should-not-persist",
|
||||
output: "secret output should-not-persist",
|
||||
content: "secret content should-not-persist",
|
||||
command: "cat secret should-not-persist",
|
||||
turnId: "turn-secret-should-not-persist",
|
||||
},
|
||||
},
|
||||
}),
|
||||
}),
|
||||
{ params: Promise.resolve({ taskId: task.taskId }) },
|
||||
);
|
||||
|
||||
assert.equal(response.status, 200);
|
||||
|
||||
const state = await data.readState();
|
||||
const progress = state.projects
|
||||
.find((project) => project.id === "master-agent")
|
||||
?.messages.find((message) => message.executionProgress?.taskId === task.taskId)
|
||||
?.executionProgress;
|
||||
assert.deepEqual(progress?.streamEvents, {
|
||||
status: "streaming",
|
||||
agentDeltaCount: 2,
|
||||
planDeltaCount: 1,
|
||||
reasoningDeltaCount: 3,
|
||||
toolProgressCount: 1,
|
||||
commandOutputChunkCount: 4,
|
||||
terminalInteractionCount: 1,
|
||||
fileOutputChunkCount: 1,
|
||||
});
|
||||
const serialized = JSON.stringify(progress);
|
||||
assert.equal(serialized.includes("should-not-persist"), false);
|
||||
assert.equal(serialized.includes("turn-secret"), false);
|
||||
});
|
||||
|
||||
test("POST task progress preserves Codex tool activity summaries without leaking raw payloads", async () => {
|
||||
const task = await data.queueMasterAgentTask({
|
||||
taskId: "route-progress-tool-activity-task",
|
||||
|
||||
Reference in New Issue
Block a user