feat: map codex thread collaboration progress
This commit is contained in:
47
tests/fixtures/codex-app-server-runtime.mjs
vendored
47
tests/fixtures/codex-app-server-runtime.mjs
vendored
@@ -642,6 +642,53 @@ rl.on("line", (line) => {
|
||||
},
|
||||
});
|
||||
}
|
||||
if (process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_COLLAB_EVENTS === "1") {
|
||||
send({
|
||||
method: "item/started",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
item: {
|
||||
type: "collabToolCall",
|
||||
id: "collab-call-1",
|
||||
tool: "send_input",
|
||||
status: "running",
|
||||
senderThreadId: "thread-source-secret-should-not-leak",
|
||||
receiverThreadId: "thread-target-secret-should-not-leak",
|
||||
prompt: "internal prompt token=sk-secret-should-not-leak",
|
||||
agentStatus: "running",
|
||||
},
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/completed",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
item: {
|
||||
type: "collabToolCall",
|
||||
id: "collab-call-1",
|
||||
tool: "send_input",
|
||||
status: "completed",
|
||||
senderThreadId: "thread-source-secret-should-not-leak",
|
||||
receiverThreadId: "thread-target-secret-should-not-leak",
|
||||
prompt: "internal prompt token=sk-secret-should-not-leak",
|
||||
agentStatus: "completed",
|
||||
},
|
||||
},
|
||||
});
|
||||
send({
|
||||
method: "item/completed",
|
||||
params: {
|
||||
threadId: message.params?.threadId,
|
||||
turnId: "turn-fixture",
|
||||
item: {
|
||||
type: "contextCompaction",
|
||||
id: "context-compaction-secret-should-not-leak",
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
send({
|
||||
method: "item/agentMessage/delta",
|
||||
params: {
|
||||
|
||||
@@ -595,6 +595,53 @@ test("codex app-server runner maps account, quota, verification, and notices wit
|
||||
}
|
||||
});
|
||||
|
||||
test("codex app-server runner maps collab tool calls and context compaction without leaking thread internals", async () => {
|
||||
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_COLLAB_EVENTS;
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_COLLAB_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-collab-events",
|
||||
taskType: "conversation_reply",
|
||||
targetCodexThreadRef: "019d-app-server-thread",
|
||||
targetCodexFolderRef: repoRoot,
|
||||
executionPrompt: "让目标线程协作推进",
|
||||
});
|
||||
|
||||
assert.equal(result.status, "completed");
|
||||
assert.deepEqual(result.executionProgress.threadCollaboration, {
|
||||
tool: "send_input",
|
||||
status: "completed",
|
||||
target: "已有线程",
|
||||
agentStatus: "completed",
|
||||
});
|
||||
assert.deepEqual(result.executionProgress.compaction, {
|
||||
status: "completed",
|
||||
message: "上下文已压缩",
|
||||
});
|
||||
const serialized = JSON.stringify(result.executionProgress);
|
||||
assert.equal(serialized.includes("thread-source-secret-should-not-leak"), false);
|
||||
assert.equal(serialized.includes("thread-target-secret-should-not-leak"), false);
|
||||
assert.equal(serialized.includes("internal prompt"), false);
|
||||
assert.equal(serialized.includes("sk-secret-should-not-leak"), false);
|
||||
assert.equal(serialized.includes("context-compaction-secret-should-not-leak"), false);
|
||||
} finally {
|
||||
if (previous === undefined) {
|
||||
delete process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_COLLAB_EVENTS;
|
||||
} else {
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_COLLAB_EVENTS = previous;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("codex app-server runner bridges source thread context into target thread through inject_items", async () => {
|
||||
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_INTER_THREAD;
|
||||
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_INTER_THREAD = "1";
|
||||
|
||||
@@ -447,3 +447,73 @@ test("POST task progress preserves Codex account, quota, verification, and notic
|
||||
assert.equal(serialized.includes("sk-secret-should-not-persist"), false);
|
||||
assert.equal(serialized.includes("turn-secret-should-not-persist"), false);
|
||||
});
|
||||
|
||||
test("POST task progress preserves Codex thread collaboration summaries without leaking thread internals", async () => {
|
||||
const task = await data.queueMasterAgentTask({
|
||||
taskId: "route-progress-thread-collab-task",
|
||||
projectId: "group-progress-test",
|
||||
taskType: "dispatch_execution",
|
||||
requestMessageId: "msg-route-progress-thread-collab",
|
||||
requestText: "让目标线程协作推进",
|
||||
executionPrompt: "让目标线程协作推进",
|
||||
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" }],
|
||||
threadCollaboration: {
|
||||
tool: "send_input",
|
||||
status: "completed",
|
||||
target: "已有线程",
|
||||
agentStatus: "completed",
|
||||
senderThreadId: "thread-source-secret-should-not-persist",
|
||||
receiverThreadId: "thread-target-secret-should-not-persist",
|
||||
prompt: "internal prompt token=sk-secret-should-not-persist",
|
||||
},
|
||||
compaction: {
|
||||
status: "completed",
|
||||
message: "上下文已压缩",
|
||||
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?.threadCollaboration, {
|
||||
tool: "send_input",
|
||||
status: "completed",
|
||||
target: "已有线程",
|
||||
agentStatus: "completed",
|
||||
});
|
||||
assert.equal(progress?.compaction?.status, "completed");
|
||||
const serialized = JSON.stringify(progress);
|
||||
assert.equal(serialized.includes("thread-source-secret-should-not-persist"), false);
|
||||
assert.equal(serialized.includes("thread-target-secret-should-not-persist"), false);
|
||||
assert.equal(serialized.includes("internal prompt"), false);
|
||||
assert.equal(serialized.includes("sk-secret-should-not-persist"), false);
|
||||
assert.equal(serialized.includes("turn-secret-should-not-persist"), false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user