feat: add controlled codex thread archive

This commit is contained in:
AI Bot
2026-06-03 13:47:50 +08:00
parent 0fb588e339
commit 0bcdcbfb9d
11 changed files with 493 additions and 0 deletions

View File

@@ -1573,6 +1573,51 @@ test("codex app-server runner starts thread compaction without starting a normal
assert.equal(result.turnId, undefined);
});
test("codex app-server runner archives and unarchives a thread without starting a normal turn", async () => {
const runnerConfig = getCodexAppServerRunnerConfig(process.env, {
codexAppServerEnabled: true,
codexAppServerCommand: process.execPath,
codexAppServerArgs: ["tests/fixtures/codex-app-server-runtime.mjs"],
codexAppServerWorkdir: repoRoot,
codexAppServerTimeoutMs: 5000,
});
const archiveResult = await executeCodexAppServerTask(runnerConfig, {
taskId: "task-thread-archive",
taskType: "conversation_reply",
intentCategory: "thread_archive",
targetCodexThreadRef: "019d-app-server-thread",
targetCodexFolderRef: repoRoot,
threadLifecycleAction: "archive",
executionPrompt: "归档当前 Codex 线程。",
});
const unarchiveResult = await executeCodexAppServerTask(runnerConfig, {
taskId: "task-thread-unarchive",
taskType: "conversation_reply",
intentCategory: "thread_unarchive",
targetCodexThreadRef: "019d-app-server-thread",
targetCodexFolderRef: repoRoot,
threadLifecycleAction: "unarchive",
executionPrompt: "恢复当前 Codex 线程。",
});
assert.equal(archiveResult.status, "completed");
assert.equal(archiveResult.threadId, "019d-app-server-thread");
assert.equal(archiveResult.turnControl, "archive");
assert.match(archiveResult.replyBody, /已归档 Codex 线程/);
assert.equal(archiveResult.turnId, undefined);
assert.equal(unarchiveResult.status, "completed");
assert.equal(unarchiveResult.threadId, "019d-app-server-thread");
assert.equal(unarchiveResult.turnControl, "unarchive");
assert.match(unarchiveResult.replyBody, /已恢复 Codex 线程/);
assert.equal(unarchiveResult.turnId, undefined);
const serialized = JSON.stringify({ archiveResult, unarchiveResult });
assert.doesNotMatch(serialized, /thread-archive-secret-should-not-leak/);
assert.doesNotMatch(serialized, /thread-unarchive-secret-should-not-leak/);
assert.doesNotMatch(serialized, /private unarchived thread name should not leak/);
});
test("codex app-server runner stays disabled unless feature flag is explicit", () => {
const runnerConfig = getCodexAppServerRunnerConfig(process.env, {
codexAppServerCommand: process.execPath,