feat: add usage to providers list
This commit is contained in:
@@ -220,6 +220,10 @@ Common options:
|
|||||||
- `--account <id>`: provider account id (default `default`)
|
- `--account <id>`: provider account id (default `default`)
|
||||||
- `--name <label>`: display name for the account
|
- `--name <label>`: display name for the account
|
||||||
|
|
||||||
|
`providers list` options:
|
||||||
|
- `--usage`: include provider usage/quota snapshots (OAuth/API-backed only).
|
||||||
|
- `--json`: output JSON (includes usage when `--usage` is set).
|
||||||
|
|
||||||
### `pairing`
|
### `pairing`
|
||||||
Approve DM pairing requests across providers.
|
Approve DM pairing requests across providers.
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ read_when:
|
|||||||
## Where it shows up
|
## Where it shows up
|
||||||
- `/status` in chats: adds a short “Usage” line (only if available).
|
- `/status` in chats: adds a short “Usage” line (only if available).
|
||||||
- CLI: `clawdbot status --usage` prints a full per-provider breakdown.
|
- CLI: `clawdbot status --usage` prints a full per-provider breakdown.
|
||||||
|
- CLI: `clawdbot providers list --usage` prints the same usage snapshot alongside provider config.
|
||||||
- macOS menu bar: “Usage” section under Context (only if available).
|
- macOS menu bar: “Usage” section under Context (only if available).
|
||||||
|
|
||||||
## Providers + credentials
|
## Providers + credentials
|
||||||
@@ -24,4 +25,3 @@ read_when:
|
|||||||
- **z.ai**: API key via env/config/auth store.
|
- **z.ai**: API key via env/config/auth store.
|
||||||
|
|
||||||
Usage is hidden if no matching OAuth/API credentials exist.
|
Usage is hidden if no matching OAuth/API credentials exist.
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ export function registerProvidersCli(program: Command) {
|
|||||||
providers
|
providers
|
||||||
.command("list")
|
.command("list")
|
||||||
.description("List configured providers + auth profiles")
|
.description("List configured providers + auth profiles")
|
||||||
|
.option("--usage", "Show provider usage/quota snapshots", false)
|
||||||
.option("--json", "Output JSON", false)
|
.option("--json", "Output JSON", false)
|
||||||
.action(async (opts) => {
|
.action(async (opts) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ import {
|
|||||||
resolveDiscordAccount,
|
resolveDiscordAccount,
|
||||||
} from "../discord/accounts.js";
|
} from "../discord/accounts.js";
|
||||||
import { callGateway } from "../gateway/call.js";
|
import { callGateway } from "../gateway/call.js";
|
||||||
|
import {
|
||||||
|
formatUsageReportLines,
|
||||||
|
loadProviderUsageSummary,
|
||||||
|
} from "../infra/provider-usage.js";
|
||||||
import {
|
import {
|
||||||
listIMessageAccountIds,
|
listIMessageAccountIds,
|
||||||
resolveIMessageAccount,
|
resolveIMessageAccount,
|
||||||
@@ -56,6 +60,7 @@ type ChatProvider = (typeof CHAT_PROVIDERS)[number];
|
|||||||
|
|
||||||
type ProvidersListOptions = {
|
type ProvidersListOptions = {
|
||||||
json?: boolean;
|
json?: boolean;
|
||||||
|
usage?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ProvidersStatusOptions = {
|
type ProvidersStatusOptions = {
|
||||||
@@ -461,6 +466,7 @@ export async function providersListCommand(
|
|||||||
profileId === CODEX_CLI_PROFILE_ID,
|
profileId === CODEX_CLI_PROFILE_ID,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
const usage = opts.usage ? await loadProviderUsageSummary() : undefined;
|
||||||
|
|
||||||
if (opts.json) {
|
if (opts.json) {
|
||||||
const payload = {
|
const payload = {
|
||||||
@@ -473,6 +479,7 @@ export async function providersListCommand(
|
|||||||
imessage: imessageAccounts,
|
imessage: imessageAccounts,
|
||||||
},
|
},
|
||||||
auth: authProfiles,
|
auth: authProfiles,
|
||||||
|
...(usage ? { usage } : {}),
|
||||||
};
|
};
|
||||||
runtime.log(JSON.stringify(payload, null, 2));
|
runtime.log(JSON.stringify(payload, null, 2));
|
||||||
return;
|
return;
|
||||||
@@ -567,6 +574,11 @@ export async function providersListCommand(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (usage) {
|
||||||
|
lines.push("");
|
||||||
|
lines.push(...formatUsageReportLines(usage));
|
||||||
|
}
|
||||||
|
|
||||||
lines.push("");
|
lines.push("");
|
||||||
lines.push(
|
lines.push(
|
||||||
`Docs: ${docsLink("/gateway/configuration", "gateway/configuration")}`,
|
`Docs: ${docsLink("/gateway/configuration", "gateway/configuration")}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user