fix(server): surface raw claude auth status in diagnostic
Return stdout verbatim instead of parsing JSON fields. Parser was fragile to upstream schema changes and added no value — users can read the raw output directly.
This commit is contained in:
@@ -1218,46 +1218,22 @@ async function resolveClaudeAuth(
|
|||||||
const command = runtimeSettings?.command;
|
const command = runtimeSettings?.command;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let stdout: string;
|
|
||||||
if (command?.mode === "replace") {
|
if (command?.mode === "replace") {
|
||||||
const result = await execCommand(
|
const { stdout } = await execCommand(
|
||||||
command.argv[0]!,
|
command.argv[0]!,
|
||||||
[...command.argv.slice(1), "auth", "status"],
|
[...command.argv.slice(1), "auth", "status"],
|
||||||
{ timeout: 5_000 },
|
{ timeout: 5_000 },
|
||||||
);
|
);
|
||||||
stdout = result.stdout;
|
return stdout.trim() || null;
|
||||||
} 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);
|
const executable = await findExecutable("claude");
|
||||||
if (!parsed || typeof parsed !== "object") {
|
if (!executable) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const record = parsed as Record<string, unknown>;
|
|
||||||
if (record.loggedIn !== true) {
|
|
||||||
return "Not logged in";
|
|
||||||
}
|
|
||||||
|
|
||||||
const parts: string[] = [];
|
const { stdout } = await execCommand(executable, ["auth", "status"], { timeout: 5_000 });
|
||||||
if (typeof record.authMethod === "string" && record.authMethod) {
|
return stdout.trim() || null;
|
||||||
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 {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user