fix(status): surface provider usage errors
This commit is contained in:
@@ -153,6 +153,15 @@ export async function buildStatusReply(params: {
|
|||||||
agentDir: statusAgentDir,
|
agentDir: statusAgentDir,
|
||||||
});
|
});
|
||||||
usageLine = formatUsageSummaryLine(usageSummary, { now: Date.now() });
|
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 {
|
} catch {
|
||||||
usageLine = null;
|
usageLine = null;
|
||||||
|
|||||||
@@ -296,6 +296,9 @@ async function fetchClaudeUsage(
|
|||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
|
"User-Agent": "clawdbot",
|
||||||
|
Accept: "application/json",
|
||||||
|
"anthropic-version": "2023-06-01",
|
||||||
"anthropic-beta": "oauth-2025-04-20",
|
"anthropic-beta": "oauth-2025-04-20",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -304,11 +307,22 @@ async function fetchClaudeUsage(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!res.ok) {
|
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 {
|
return {
|
||||||
provider: "anthropic",
|
provider: "anthropic",
|
||||||
displayName: PROVIDER_LABELS.anthropic,
|
displayName: PROVIDER_LABELS.anthropic,
|
||||||
windows: [],
|
windows: [],
|
||||||
error: `HTTP ${res.status}`,
|
error: `HTTP ${res.status}${suffix}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user