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 <noreply@anthropic.com>
This commit is contained in:
parent
32c76e0012
commit
a9dcea023b
1 changed files with 17 additions and 6 deletions
|
|
@ -15,6 +15,7 @@ import {
|
||||||
} from "@paperclipai/adapter-utils/server-utils";
|
} from "@paperclipai/adapter-utils/server-utils";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { parseCodexJsonl } from "./parse.js";
|
import { parseCodexJsonl } from "./parse.js";
|
||||||
|
import { readCodexAuthInfo } from "./quota.js";
|
||||||
|
|
||||||
function summarizeStatus(checks: AdapterEnvironmentCheck[]): AdapterEnvironmentTestResult["status"] {
|
function summarizeStatus(checks: AdapterEnvironmentCheck[]): AdapterEnvironmentTestResult["status"] {
|
||||||
if (checks.some((check) => check.level === "error")) return "fail";
|
if (checks.some((check) => check.level === "error")) return "fail";
|
||||||
|
|
@ -108,12 +109,22 @@ export async function testEnvironment(
|
||||||
detail: `Detected in ${source}.`,
|
detail: `Detected in ${source}.`,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
checks.push({
|
const codexAuth = await readCodexAuthInfo().catch(() => null);
|
||||||
code: "codex_openai_api_key_missing",
|
if (codexAuth) {
|
||||||
level: "warn",
|
checks.push({
|
||||||
message: "OPENAI_API_KEY is not set. Codex runs may fail until authentication is configured.",
|
code: "codex_native_auth_present",
|
||||||
hint: "Set OPENAI_API_KEY in adapter env, shell environment, or Codex auth configuration.",
|
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 =
|
const canRunProbe =
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue