fix(status): surface provider usage errors

This commit is contained in:
Peter Steinberger
2026-01-09 14:52:07 +00:00
parent f436808735
commit 922ca2ee1c
2 changed files with 24 additions and 1 deletions

View File

@@ -153,6 +153,15 @@ export async function buildStatusReply(params: {
agentDir: statusAgentDir,
});
usageLine = formatUsageSummaryLine(usageSummary, { now: Date.now() });
if (
!usageLine &&
(resolvedVerboseLevel === "on" || resolvedElevatedLevel === "on")
) {
const entry = usageSummary.providers[0];
if (entry?.error) {
usageLine = `📊 Usage: ${entry.displayName} (${entry.error})`;
}
}
}
} catch {
usageLine = null;

View File

@@ -296,6 +296,9 @@ async function fetchClaudeUsage(
{
headers: {
Authorization: `Bearer ${token}`,
"User-Agent": "clawdbot",
Accept: "application/json",
"anthropic-version": "2023-06-01",
"anthropic-beta": "oauth-2025-04-20",
},
},
@@ -304,11 +307,22 @@ async function fetchClaudeUsage(
);
if (!res.ok) {
let message: string | undefined;
try {
const data = (await res.json()) as {
error?: { message?: unknown } | null;
};
const raw = data?.error?.message;
if (typeof raw === "string" && raw.trim()) message = raw.trim();
} catch {
// ignore parse errors
}
const suffix = message ? `: ${message}` : "";
return {
provider: "anthropic",
displayName: PROVIDER_LABELS.anthropic,
windows: [],
error: `HTTP ${res.status}`,
error: `HTTP ${res.status}${suffix}`,
};
}