Files
openclaw/extensions/anthropic/cli-auth-seam.ts
Peter Steinberger fee4e77d91 fix(anthropic): native Claude models show incorrect availability (#129346)
* fix(anthropic): verify native Claude login before publishing runtime auth

* fix(status): preserve native Claude CLI authentication labels

* refactor(gateway): remove retired native Claude auth projection

* fix(plugin-sdk): retain Claude compatibility types

Keep the released Claude CLI credential reader source-compatible through its documented v2026.10 retirement window and explicitly account for both retained type exports in the public SDK budget.

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>

* fix(plugin-sdk): preserve only shipped Claude compatibility exports

* fix(ci): align Claude native-auth contracts

Retire Doctor fixtures for credentials now owned by Claude CLI and remove the two never-shipped compatibility type exports while retaining the shipped reader through its documented v2026.10 window.

Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>

* test(onboard): remove retired Claude credential file fixture

* fix(auth): skip incompatible profiles before plugin discovery

* fix(auth): avoid cold plugin activation for retired profiles

* test: repair upstream doctor and learning regressions

* fix(onboard): validate authored aliases without plugin discovery

* fix(agents): resolve compaction aliases without plugin discovery

* test(ui): register pairing sidebar before lifecycle teardown

* fix(anthropic): keep provider policy imports runtime-free

* test(vitest): cover codex startup retry test family

* fix(agents): avoid plugin discovery for internal sessions

---------

Co-authored-by: roboclaw-bot <309084314+roboclaw-bot@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
2026-08-25 14:42:08 -07:00

39 lines
1.2 KiB
TypeScript

import { spawnSync } from "node:child_process";
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
import { CLAUDE_CLI_CLEAR_ENV } from "./cli-constants.js";
type ClaudeCliAuthStatus = { status: "available" } | { status: "missing" | "unreadable" };
/** Ask Claude CLI whether its own login is usable without reading token material. */
export function probeClaudeCliAuthStatus(params?: {
command?: string;
env?: NodeJS.ProcessEnv;
}): ClaudeCliAuthStatus {
const env = { ...(params?.env ?? process.env) };
for (const name of CLAUDE_CLI_CLEAR_ENV) {
delete env[name];
}
const result = spawnSync(params?.command ?? "claude", ["auth", "status", "--json"], {
encoding: "utf8",
env,
maxBuffer: 64 * 1024,
timeout: 3_000,
windowsHide: true,
});
if (result.error || result.status === null) {
return { status: "unreadable" };
}
if (result.status !== 0) {
return { status: "missing" };
}
try {
const parsed: unknown = JSON.parse(result.stdout);
if (!isRecord(parsed) || parsed.loggedIn !== true) {
return { status: "missing" };
}
return { status: "available" };
} catch {
return { status: "unreadable" };
}
}