Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Handle Codex auth JSON arrays and flag missing auth markers
Julius Marminge9db54c9b19b1
diff --git a/apps/server/src/provider/Layers/ProviderHealth.test.ts b/apps/server/src/provider/Layers/ProviderHealth.test.tsindex 2530ae129..b75c358ba 100644--- a/apps/server/src/provider/Layers/ProviderHealth.test.ts+++ b/apps/server/src/provider/Layers/ProviderHealth.test.ts@@ -79,6 +79,56 @@ describe("checkProviderStatusesOnStartup", () => {]);});+ it("returns unauthenticated when auth probe JSON array includes authenticated=false", async () => {+ const status = await checkProviderStatusesOnStartup(async (_command, args) => {+ if (args.join(" ") === "--version") {+ return result({ stdout: "codex 1.0.0\n" });+ }+ if (args.join(" ") === "auth status --json") {+ return result({+ stdout: '[{"authenticated":false}]\n',+ });+ }+ throw new Error(`Unexpected command: ${args.join(" ")}`);+ });++ expect(status).toEqual([+ expect.objectContaining({+ provider: "codex",+ status: "error",+ available: true,+ authStatus: "unauthenticated",+ message: "Codex CLI is not authenticated. Run `codex login` and try again.",+ }),+ ]);+ });++ it("returns warning when auth probe JSON array has no auth marker", async () => {+ const status = await checkProviderStatusesOnStartup(async (_command, args) => {+ if (args.join(" ") === "--version") {+ return result({ stdout: "codex 1.0.0\n" });+ }+ if (args.join(" ") === "auth status --json") {+ return result({+ code: 0,+ stdout: '[{"ok":true}]\n',+ });+ }+ throw new Error(`Unexpected command: ${args.join(" ")}`);+ });++ expect(status).toEqual([+ expect.objectContaining({+ provider: "codex",+ status: "warning",+ available: true,+ authStatus: "unknown",+ message:+ "Could not verify Codex authentication status from JSON output (missing auth marker).",+ }),+ ]);+ });+it("returns warning when auth status command is unsupported", async () => {const status = await checkProviderStatusesOnStartup(async (_command, args) => {if (args.join(" ") === "--version") {diff --git a/apps/server/src/provider/Layers/ProviderHealth.ts b/apps/server/src/provider/Layers/ProviderHealth.tsindex 020554561..3bab83f19 100644--- a/apps/server/src/provider/Layers/ProviderHealth.ts+++ b/apps/server/src/provider/Layers/ProviderHealth.ts@@ -54,7 +54,17 @@ function detailFromResult(result: ProcessRunResult): string | undefined {}function extractAuthBoolean(value: unknown): boolean | undefined {- if (!value || typeof value !== "object" || Array.isArray(value)) {+ if (Array.isArray(value)) {+ for (const entry of value) {+ const nested = extractAuthBoolean(entry);+ if (nested !== undefined) {+ return nested;+ }+ }+ return undefined;+ }++ if (!value || typeof value !== "object") {return undefined;}@@ -122,19 +132,28 @@ function parseAuthStatusFromOutput((() => {const trimmed = result.stdout.trim();if (!trimmed || (!trimmed.startsWith("{") && !trimmed.startsWith("["))) {- return undefined;+ return {+ attemptedJsonParse: false as const,+ auth: undefined as boolean | undefined,+ };}try {- return extractAuthBoolean(JSON.parse(trimmed));+ return {+ attemptedJsonParse: true as const,+ auth: extractAuthBoolean(JSON.parse(trimmed)),+ };} catch {- return undefined;+ return {+ attemptedJsonParse: false as const,+ auth: undefined as boolean | undefined,+ };}- })() ?? undefined;+ })();- if (parsedAuth === true) {+ if (parsedAuth.auth === true) {return { status: "ready", authStatus: "authenticated" };}- if (parsedAuth === false) {+ if (parsedAuth.auth === false) {return {status: "error",authStatus: "unauthenticated",@@ -142,6 +161,15 @@ function parseAuthStatusFromOutput(};}+ if (parsedAuth.attemptedJsonParse) {+ return {+ status: "warning",+ authStatus: "unknown",+ message:+ "Could not verify Codex authentication status from JSON output (missing auth marker).",+ };+ }+if (result.code === 0) {// Successful command with no explicit auth marker is still a pass.return { status: "ready", authStatus: "authenticated" };@@ -240,7 +268,3 @@ const makeProviderHealth = (run: CommandRunner = runProcess) =>});export const ProviderHealthLive = Layer.effect(ProviderHealth, makeProviderHealth());--export function makeProviderHealthLive(run?: CommandRunner) {- return Layer.effect(ProviderHealth, makeProviderHealth(run));-}