feat: mirror boss messages via app server

This commit is contained in:
AI Bot
2026-06-03 15:00:25 +08:00
parent 0c3437a36f
commit dbdaab8d0f
7 changed files with 121 additions and 1 deletions

View File

@@ -796,6 +796,12 @@ rl.on("line", (line) => {
return;
}
const text = message.params?.input?.find?.((item) => item?.type === "text")?.text ?? "";
const injectedUserMessageText =
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_ECHO_INJECTED_USER_MESSAGE === "1"
? injectedItems
.flatMap((item) => item?.content ?? [])
.find((content) => content?.type === "input_text")?.text
: "";
send({
id: message.id,
result: {
@@ -1654,7 +1660,9 @@ rl.on("line", (line) => {
threadId: message.params?.threadId,
turnId: "turn-fixture",
delta:
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_INTER_THREAD === "1"
injectedUserMessageText
? `INJECTED_USER_MESSAGE:${injectedUserMessageText}`
: process.env.BOSS_CODEX_APP_SERVER_FIXTURE_INTER_THREAD === "1"
? `INTER_THREAD_INJECTED:${JSON.stringify(injectedItems)}`
: `APP_SERVER_REPLY:${text}`,
},

View File

@@ -508,6 +508,50 @@ test("codex app-server runner resumes a thread and collects streamed agent text"
assert.equal(result.transport, "stdio");
});
test("codex app-server runner injects Boss user message into the target Codex thread before starting a turn", async () => {
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_ECHO_INJECTED_USER_MESSAGE;
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_ECHO_INJECTED_USER_MESSAGE = "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 task = {
taskId: "task-app-server-sync-user-message",
taskType: "conversation_reply",
targetCodexThreadRef: "019d-app-server-thread",
targetCodexFolderRef: repoRoot,
executionPrompt: "请修复登录页跳转问题",
mirrorBossUserMessageToCodexDesktop: true,
userMessageId: "boss-msg-1",
sourceMessageId: "boss-msg-1",
sourceMessageBody: "请修复登录页跳转问题",
userDisplayName: "你",
};
const result = await executeCodexAppServerTask(runnerConfig, task);
assert.equal(result.status, "completed");
assert.equal(result.threadId, "019d-app-server-thread");
assert.equal(result.turnControl, "start");
assert.equal(result.threadHistorySync?.threadId, "019d-app-server-thread");
assert.equal(result.threadHistorySync?.injectedItemCount, 1);
assert.equal(result.threadHistorySync?.source, "boss_user_message");
assert.match(result.replyBody, /INJECTED_USER_MESSAGE:请修复登录页跳转问题/);
assert.doesNotMatch(JSON.stringify(result), /boss-msg-1/);
} finally {
if (previous === undefined) {
delete process.env.BOSS_CODEX_APP_SERVER_FIXTURE_ECHO_INJECTED_USER_MESSAGE;
} else {
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_ECHO_INJECTED_USER_MESSAGE = previous;
}
}
});
test("codex app-server runner converts protocol progress events into Boss execution progress", async () => {
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_PROGRESS;
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_PROGRESS = "1";