feat: add usage to providers list
This commit is contained in:
@@ -51,6 +51,7 @@ export function registerProvidersCli(program: Command) {
|
||||
providers
|
||||
.command("list")
|
||||
.description("List configured providers + auth profiles")
|
||||
.option("--usage", "Show provider usage/quota snapshots", false)
|
||||
.option("--json", "Output JSON", false)
|
||||
.action(async (opts) => {
|
||||
try {
|
||||
|
||||
@@ -12,6 +12,10 @@ import {
|
||||
resolveDiscordAccount,
|
||||
} from "../discord/accounts.js";
|
||||
import { callGateway } from "../gateway/call.js";
|
||||
import {
|
||||
formatUsageReportLines,
|
||||
loadProviderUsageSummary,
|
||||
} from "../infra/provider-usage.js";
|
||||
import {
|
||||
listIMessageAccountIds,
|
||||
resolveIMessageAccount,
|
||||
@@ -56,6 +60,7 @@ type ChatProvider = (typeof CHAT_PROVIDERS)[number];
|
||||
|
||||
type ProvidersListOptions = {
|
||||
json?: boolean;
|
||||
usage?: boolean;
|
||||
};
|
||||
|
||||
type ProvidersStatusOptions = {
|
||||
@@ -461,6 +466,7 @@ export async function providersListCommand(
|
||||
profileId === CODEX_CLI_PROFILE_ID,
|
||||
}),
|
||||
);
|
||||
const usage = opts.usage ? await loadProviderUsageSummary() : undefined;
|
||||
|
||||
if (opts.json) {
|
||||
const payload = {
|
||||
@@ -473,6 +479,7 @@ export async function providersListCommand(
|
||||
imessage: imessageAccounts,
|
||||
},
|
||||
auth: authProfiles,
|
||||
...(usage ? { usage } : {}),
|
||||
};
|
||||
runtime.log(JSON.stringify(payload, null, 2));
|
||||
return;
|
||||
@@ -567,6 +574,11 @@ export async function providersListCommand(
|
||||
}
|
||||
}
|
||||
|
||||
if (usage) {
|
||||
lines.push("");
|
||||
lines.push(...formatUsageReportLines(usage));
|
||||
}
|
||||
|
||||
lines.push("");
|
||||
lines.push(
|
||||
`Docs: ${docsLink("/gateway/configuration", "gateway/configuration")}`,
|
||||
|
||||
Reference in New Issue
Block a user