From a9dcea023bc5e6f30956d761675fde24e13def0f Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Tue, 24 Mar 2026 09:47:48 -0700 Subject: [PATCH] fix(codex): check native auth before warning about missing API key The environment test warned about OPENAI_API_KEY being unset even when Codex was authenticated via `codex auth`. Now checks ~/.codex/auth.json before emitting the warning. Co-Authored-By: Claude Opus 4.6 --- .../adapters/codex-local/src/server/test.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/adapters/codex-local/src/server/test.ts b/packages/adapters/codex-local/src/server/test.ts index 292e53ee..fbf95e62 100644 --- a/packages/adapters/codex-local/src/server/test.ts +++ b/packages/adapters/codex-local/src/server/test.ts @@ -15,6 +15,7 @@ import { } from "@paperclipai/adapter-utils/server-utils"; import path from "node:path"; import { parseCodexJsonl } from "./parse.js"; +import { readCodexAuthInfo } from "./quota.js"; function summarizeStatus(checks: AdapterEnvironmentCheck[]): AdapterEnvironmentTestResult["status"] { if (checks.some((check) => check.level === "error")) return "fail"; @@ -108,12 +109,22 @@ export async function testEnvironment( detail: `Detected in ${source}.`, }); } else { - checks.push({ - code: "codex_openai_api_key_missing", - level: "warn", - message: "OPENAI_API_KEY is not set. Codex runs may fail until authentication is configured.", - hint: "Set OPENAI_API_KEY in adapter env, shell environment, or Codex auth configuration.", - }); + const codexAuth = await readCodexAuthInfo().catch(() => null); + if (codexAuth) { + checks.push({ + code: "codex_native_auth_present", + level: "info", + message: "Codex is authenticated via its own auth configuration.", + detail: codexAuth.email ? `Logged in as ${codexAuth.email}.` : "Credentials found in ~/.codex/auth.json.", + }); + } else { + checks.push({ + code: "codex_openai_api_key_missing", + level: "warn", + message: "OPENAI_API_KEY is not set. Codex runs may fail until authentication is configured.", + hint: "Set OPENAI_API_KEY in adapter env, shell environment, or run `codex auth` to log in.", + }); + } } const canRunProbe =