feat: surface codex account runtime notices

This commit is contained in:
AI Bot
2026-06-01 17:40:03 +08:00
parent 26b5e97614
commit defa3da185
11 changed files with 505 additions and 5 deletions

View File

@@ -529,6 +529,72 @@ test("codex app-server runner maps thread goal, settings, and compaction events
}
});
test("codex app-server runner maps account, quota, verification, and notices without leaking config paths", async () => {
const previous = process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_ACCOUNT_NOTICE_EVENTS;
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_ACCOUNT_NOTICE_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-account-notices",
taskType: "conversation_reply",
targetCodexThreadRef: "019d-app-server-thread",
targetCodexFolderRef: repoRoot,
executionPrompt: "同步账号与告警状态",
});
assert.equal(result.status, "completed");
assert.deepEqual(result.executionProgress.accountStatus, {
authMode: "chatgpt",
planType: "team",
limitId: "codex",
limitName: "Codex",
usedPercent: 88,
windowDurationMins: 180,
resetsAt: 1770003600,
creditsBalance: "120.5",
hasCredits: true,
unlimitedCredits: false,
});
assert.deepEqual(result.executionProgress.modelVerification, {
verifications: ["trustedAccessForCyber"],
});
assert.deepEqual(result.executionProgress.warnings, [
{
id: "codex-warning-1",
message: "模型切换提醒 token=[redacted]",
severity: "warning",
},
{
id: "config-warning-2",
message: "项目配置已忽略openai_base_url 不能放在项目配置里",
severity: "warning",
},
{
id: "deprecation-notice-3",
message: "on-failure 已废弃:请改用 on-request",
severity: "info",
},
]);
const serialized = JSON.stringify(result.executionProgress);
assert.equal(serialized.includes("/Users/kris"), false);
assert.equal(serialized.includes("sk-secret-should-not-leak"), false);
} finally {
if (previous === undefined) {
delete process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_ACCOUNT_NOTICE_EVENTS;
} else {
process.env.BOSS_CODEX_APP_SERVER_FIXTURE_EMIT_ACCOUNT_NOTICE_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";