feat(server): show Claude auth status in provider diagnostic
Runs `claude auth status` and surfaces the parsed result (auth method, subscription, email/org) in the Claude Code provider diagnostic panel.
This commit is contained in:
@@ -1144,6 +1144,7 @@ export class ClaudeAgentClient implements AgentClient {
|
|||||||
const resolvedBinary = (await findExecutable("claude")) ?? "not found";
|
const resolvedBinary = (await findExecutable("claude")) ?? "not found";
|
||||||
const available = await this.isAvailable();
|
const available = await this.isAvailable();
|
||||||
const version = await resolveClaudeVersion(this.runtimeSettings);
|
const version = await resolveClaudeVersion(this.runtimeSettings);
|
||||||
|
const auth = available ? await resolveClaudeAuth(this.runtimeSettings) : null;
|
||||||
let modelsValue = "Not checked";
|
let modelsValue = "Not checked";
|
||||||
let status = formatDiagnosticStatus(available);
|
let status = formatDiagnosticStatus(available);
|
||||||
|
|
||||||
@@ -1164,6 +1165,7 @@ export class ClaudeAgentClient implements AgentClient {
|
|||||||
diagnostic: formatProviderDiagnostic("Claude Code", [
|
diagnostic: formatProviderDiagnostic("Claude Code", [
|
||||||
{ label: "Binary", value: resolvedBinary },
|
{ label: "Binary", value: resolvedBinary },
|
||||||
...(version ? [{ label: "Version", value: version }] : []),
|
...(version ? [{ label: "Version", value: version }] : []),
|
||||||
|
...(auth ? [{ label: "Auth", value: auth }] : []),
|
||||||
{ label: "Models", value: modelsValue },
|
{ label: "Models", value: modelsValue },
|
||||||
{ label: "Status", value: status },
|
{ label: "Status", value: status },
|
||||||
]),
|
]),
|
||||||
@@ -1210,6 +1212,57 @@ async function resolveClaudeVersion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function resolveClaudeAuth(
|
||||||
|
runtimeSettings?: ProviderRuntimeSettings,
|
||||||
|
): Promise<string | null> {
|
||||||
|
const command = runtimeSettings?.command;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let stdout: string;
|
||||||
|
if (command?.mode === "replace") {
|
||||||
|
const result = await execCommand(
|
||||||
|
command.argv[0]!,
|
||||||
|
[...command.argv.slice(1), "auth", "status"],
|
||||||
|
{ timeout: 5_000 },
|
||||||
|
);
|
||||||
|
stdout = result.stdout;
|
||||||
|
} else {
|
||||||
|
const executable = await findExecutable("claude");
|
||||||
|
if (!executable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const result = await execCommand(executable, ["auth", "status"], { timeout: 5_000 });
|
||||||
|
stdout = result.stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed: unknown = JSON.parse(stdout);
|
||||||
|
if (!parsed || typeof parsed !== "object") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const record = parsed as Record<string, unknown>;
|
||||||
|
if (record.loggedIn !== true) {
|
||||||
|
return "Not logged in";
|
||||||
|
}
|
||||||
|
|
||||||
|
const parts: string[] = [];
|
||||||
|
if (typeof record.authMethod === "string" && record.authMethod) {
|
||||||
|
parts.push(record.authMethod);
|
||||||
|
}
|
||||||
|
if (typeof record.subscriptionType === "string" && record.subscriptionType) {
|
||||||
|
parts.push(record.subscriptionType);
|
||||||
|
}
|
||||||
|
if (typeof record.email === "string" && record.email) {
|
||||||
|
parts.push(record.email);
|
||||||
|
} else if (typeof record.orgName === "string" && record.orgName) {
|
||||||
|
parts.push(record.orgName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parts.length > 0 ? parts.join(" · ") : "Logged in";
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function extractContextWindowSize(modelUsage: unknown): number | undefined {
|
function extractContextWindowSize(modelUsage: unknown): number | undefined {
|
||||||
if (!modelUsage || typeof modelUsage !== "object") {
|
if (!modelUsage || typeof modelUsage !== "object") {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user