
























@@ -389,13 +389,15 @@ describe("bridgeCodexAppServerStartOptions", () => {
389389await applyCodexAppServerAuthProfile({
390390client: { request } as never,
391391 agentDir,
392-startOptions: createStartOptions(),
392+startOptions: createStartOptions({
393+env: { CODEX_API_KEY: "configured-codex-api-key" },
394+}),
393395});
394396395397expect(request).toHaveBeenNthCalledWith(1, "account/read", { refreshToken: false });
396398expect(request).toHaveBeenNthCalledWith(2, "account/login/start", {
397399type: "apiKey",
398-apiKey: "codex-env-api-key",
400+apiKey: "configured-codex-api-key",
399401});
400402} finally {
401403await fs.rm(agentDir, { recursive: true, force: true });
@@ -478,6 +480,31 @@ describe("bridgeCodexAppServerStartOptions", () => {
478480}
479481});
480482483+it("honors clearEnv before env API-key fallback", async () => {
484+const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-codex-app-server-"));
485+const request = vi.fn(async (method: string) => {
486+if (method === "account/read") {
487+return { account: null, requiresOpenaiAuth: true };
488+}
489+return { type: "apiKey" };
490+});
491+vi.stubEnv("CODEX_API_KEY", "codex-env-api-key");
492+vi.stubEnv("OPENAI_API_KEY", "openai-env-api-key");
493+try {
494+await applyCodexAppServerAuthProfile({
495+client: { request } as never,
496+ agentDir,
497+startOptions: createStartOptions({
498+clearEnv: ["CODEX_API_KEY", "OPENAI_API_KEY"],
499+}),
500+});
501+502+expect(request).not.toHaveBeenCalled();
503+} finally {
504+await fs.rm(agentDir, { recursive: true, force: true });
505+}
506+});
507+481508it("does not send env API-key fallback to websocket app-server connections", async () => {
482509const agentDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-codex-app-server-"));
483510const request = vi.fn(async (method: string) => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。