Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(cli): add `lh quota` to read subscription quota of agent runtimes (#23331)

Arvin Xud3118e13395d
diff --git a/apps/cli/src/commands/quota.test.ts b/apps/cli/src/commands/quota.test.ts
new file mode 100644
index 00000000000..66939d9a8f5
--- /dev/null
+++ b/apps/cli/src/commands/quota.test.ts
@@ -0,0 +1,214 @@
+import { Command } from 'commander';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { buildAccountView, registerQuotaCommand } from './quota';
+
+const { mockTrpcClient } = vi.hoisted(() => ({
+ mockTrpcClient: {
+ agentQuota: {
+ getLatestReadings: { query: vi.fn() },
+ listAccounts: { query: vi.fn() },
+ listActiveRuns: { query: vi.fn() },
+ listBindings: { query: vi.fn() },
+ refreshCodexQuota: { mutate: vi.fn() },
+ refreshKimiCodeQuota: { mutate: vi.fn() },
+ selectAccountForAgent: { query: vi.fn() },
+ },
+ },
+}));
+
+const { getTrpcClient: mockGetTrpcClient } = vi.hoisted(() => ({
+ getTrpcClient: vi.fn(),
+}));
+
+vi.mock('../api/client', () => ({ getTrpcClient: mockGetTrpcClient }));
+
+const NOW = Date.UTC(2026, 10, 18, 4, 0);
+const HOUR = 60 * 60 * 1000;
+
+const accounts = [
+ { email: '[email protected]', id: 'acc-a', provider: 'claude-code' },
+ { email: '[email protected]', id: 'acc-b', provider: 'codex' },
+];
+
+const readingsById: Record<string, any[]> = {
+ 'acc-a': [
+ {
+ capturedAt: NOW - HOUR,
+ limitType: 'session',
+ resetsAt: NOW + 30 * 60 * 1000,
+ scopeKey: '',
+ utilization: 100,
+ },
+ {
+ capturedAt: NOW - HOUR,
+ limitType: 'weekly_all',
+ resetsAt: NOW + 72 * HOUR,
+ scopeKey: '',
+ utilization: 40,
+ },
+ ],
+ 'acc-b': [
+ {
+ capturedAt: NOW - HOUR,
+ limitType: 'session',
+ resetsAt: NOW + 2 * HOUR,
+ scopeKey: '',
+ utilization: 12,
+ },
+ ],
+};
+
+describe('quota command', () => {
+ let consoleSpy: ReturnType<typeof vi.spyOn>;
+ let exitSpy: ReturnType<typeof vi.spyOn>;
+
+ beforeEach(() => {
+ vi.useFakeTimers({ now: NOW, toFake: ['Date'] });
+ consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
+ exitSpy = vi.spyOn(process, 'exit').mockImplementation((() => {}) as any);
+ mockGetTrpcClient.mockResolvedValue(mockTrpcClient);
+ for (const method of Object.values(mockTrpcClient.agentQuota))
+ for (const fn of Object.values(method)) (fn as ReturnType<typeof vi.fn>).mockReset();
+ mockTrpcClient.agentQuota.listAccounts.query.mockResolvedValue(accounts);
+ mockTrpcClient.agentQuota.getLatestReadings.query.mockImplementation(
+ async ({ accountId }: { accountId: string }) => readingsById[accountId] ?? [],
+ );
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ consoleSpy.mockRestore();
+ exitSpy.mockRestore();
+ });
+
+ const run = (...args: string[]) => {
+ const program = new Command();
+ program.exitOverride();
+ registerQuotaCommand(program);
+ return program.parseAsync(['node', 'test', 'quota', ...args]);
+ };
+
+ const lastJson = () => JSON.parse(consoleSpy.mock.calls.at(-1)![0]);
+
+ it('lists accounts with folded status', async () => {
+ await run('list', '--json');
+
+ const views = lastJson();
+ expect(views.map((v: any) => [v.accountId, v.status])).toEqual([
+ ['acc-a', 'exhausted'],
+ ['acc-b', 'ok'],
+ ]);
+ expect(views[0].unavailableUntil).toBe(new Date(NOW + 30 * 60 * 1000).toISOString());
+ expect(views[0].windows.map((w: any) => w.kind)).toEqual(['session', 'weekly']);
+ });
+
+ it('filters list by provider', async () => {
+ await run('list', '--provider', 'codex', '--json');
+
+ expect(lastJson().map((v: any) => v.accountId)).toEqual(['acc-b']);
+ });
+
+ it('resolves the current account of an agent', async () => {
+ mockTrpcClient.agentQuota.selectAccountForAgent.query.mockResolvedValue({
+ accountId: 'acc-a',
+ reason: 'pinned',
+ });
+ mockTrpcClient.agentQuota.listBindings.query.mockResolvedValue([
+ { accountId: 'acc-a', role: 'pinned' },
+ { accountId: 'acc-b', role: 'disabled' },
+ ]);
+
+ await run('agent', 'agt_1', '--device', 'dev-1', '--json');
+
+ expect(mockTrpcClient.agentQuota.selectAccountForAgent.query).toHaveBeenCalledWith({
+ agentId: 'agt_1',
+ deviceId: 'dev-1',
+ provider: undefined,
+ });
+ const result = lastJson();
+ expect(result.current).toMatchObject({
+ accountId: 'acc-a',
+ reason: 'pinned',
+ status: 'exhausted',
+ });
+ expect(result.accounts.map((v: any) => v.accountId)).toEqual(['acc-a']);
+ });
+
+ it('refuses to refresh claude-code on demand', async () => {
+ await run('refresh', '--device', 'dev-1', '--provider', 'claude-code');
+
+ expect(exitSpy).toHaveBeenCalledWith(1);
+ expect(mockTrpcClient.agentQuota.refreshCodexQuota.mutate).not.toHaveBeenCalled();
+ });
+
+ it('refreshes codex through the device', async () => {
+ mockTrpcClient.agentQuota.refreshCodexQuota.mutate.mockResolvedValue({ status: 'ok' });
+
+ await run('refresh', '--device', 'dev-1', '--provider', 'codex', '--json');
+
+ expect(mockTrpcClient.agentQuota.refreshCodexQuota.mutate).toHaveBeenCalledWith({
+ deviceId: 'dev-1',
+ force: true,
+ });
+ });
+});
+
+describe('buildAccountView', () => {
+ const account = { id: 'acc', provider: 'claude-code' };
+
+ it('treats a window that already reset as empty', () => {
+ const view = buildAccountView(
+ account,
+ [
+ {
+ capturedAt: NOW - 6 * HOUR,
+ limitType: 'session',
+ resetsAt: NOW - HOUR,
+ scopeKey: '',
+ utilization: 100,
+ },
+ ],
+ NOW,
+ );
+ expect(view.status).toBe('ok');
+ expect(view.windows[0].utilization).toBe(0);
+ });
+
+ it('benches on a full weekly and warns near the limit', () => {
+ expect(
+ buildAccountView(
+ account,
+ [
+ {
+ capturedAt: NOW,
+ limitType: 'weekly_all',
+ resetsAt: NOW + HOUR,
+ scopeKey: '',
+ utilization: 100,
+ },
+ ],
+ NOW,
+ ).status,
+ ).toBe('exhausted');
+ expect(
+ buildAccountView(
+ account,
+ [
+ {
+ capturedAt: NOW,
+ limitType: 'session',
+ resetsAt: NOW + HOUR,
+ scopeKey: '',
+ utilization: 85,
+ },
+ ],
+ NOW,
+ ).status,
+ ).toBe('warning');
+ });
+
+ it('reports unknown without readings', () => {
+ expect(buildAccountView(account, [], NOW).status).toBe('unknown');
+ });
+});
diff --git a/apps/cli/src/commands/quota.ts b/apps/cli/src/commands/quota.ts
new file mode 100644
index 00000000000..e9d4bab9b7d
--- /dev/null
+++ b/apps/cli/src/commands/quota.ts
@@ -0,0 +1,378 @@
+import {
+ currentUtilization,
+ isScopedWeeklyLimit,
+ isSessionLimit,
+ isWeeklyAllLimit,
+ type QuotaLimitReading,
+} from '@lobechat/heterogeneous-agents/quota';
+import type { Command } from 'commander';
+import pc from 'picocolors';
+
+import type { TrpcClient } from '../api/client';
+import { getTrpcClient } from '../api/client';
+import { resolveWorkspaceRef } from '../api/workspaceRef';
+import { outputJson, printTable, timeAgo, timeUntil } from '../utils/format';
+import { log } from '../utils/logger';
+
+/** At or above this utilization an account is close to being benched. */
+const WARNING_UTILIZATION = 80;
+
+export type QuotaStatus = 'exhausted' | 'ok' | 'unknown' | 'warning';
+
+export interface QuotaWindowView {
+ /** `session` (5-hour), `weekly`, or `weekly:<model>` for a model-scoped weekly. */
+ kind: string;
+ limitType: string;
+ resetsAt: string | null;
+ scopeKey: string;
+ /** Percent 0..100, already 0 when the window has rolled over since the reading. */
+ utilization: number;
+}
+
+export interface QuotaAccountView {
+ accountId: string;
+ displayName: string | null;
+ email: string | null;
+ enabled: boolean;
+ label: string | null;
+ planTier: string | null;
+ provider: string;
+ status: QuotaStatus;
+ /** When an exhausted account gets quota back; null otherwise. */
+ unavailableUntil: string | null;
+ /** When the newest reading was captured; null when the account has none yet. */
+ updatedAt: string | null;
+ windows: QuotaWindowView[];
+}
+
+const windowKind = (reading: QuotaLimitReading): string => {
+ if (isSessionLimit(reading)) return 'session';
+ if (isScopedWeeklyLimit(reading)) return `weekly:${reading.scopeKey}`;
+ if (isWeeklyAllLimit(reading)) return 'weekly';
+ return reading.scopeKey ? `${reading.limitType}:${reading.scopeKey}` : reading.limitType;
+};
+
+const toIso = (ms: number | null | undefined) => (ms ? new Date(ms).toISOString() : null);
+
+/**
+ * Fold an account's latest readings into one status. Any window at 100% benches
+ * the account until the latest of those windows resets β€” a full weekly blocks
+ * runs just as a full session does.
+ */
+export const buildAccountView = (
+ account: any,
+ readings: QuotaLimitReading[],
+ now: number = Date.now(),
+): QuotaAccountView => {
+ let status: QuotaStatus = readings.length ? 'ok' : 'unknown';
+ let unavailableUntil: number | null = null;
+
+ const windows = readings.map((reading) => {
+ const utilization = currentUtilization(reading, now);
+ if (utilization >= 100 || (reading.rateLimited && utilization > 0)) {
+ status = 'exhausted';
+ if (reading.resetsAt) unavailableUntil = Math.max(unavailableUntil ?? 0, reading.resetsAt);
+ } else if (utilization >= WARNING_UTILIZATION && status !== 'exhausted') {
+ status = 'warning';
+ }
+ return {
+ kind: windowKind(reading),
+ limitType: reading.limitType,
+ resetsAt: toIso(reading.resetsAt),
+ scopeKey: reading.scopeKey,
+ utilization,
+ };
+ });
+
+ const newest = readings.reduce((max, r) => Math.max(max, r.capturedAt), 0);
+
+ return {
+ accountId: account.id,
+ displayName: account.displayName ?? null,
+ email: account.email ?? null,
+ enabled: account.enabled ?? true,
+ label: account.label ?? null,
+ planTier: account.planTier ?? null,
+ provider: account.provider,
+ status,
+ unavailableUntil: toIso(unavailableUntil),
+ updatedAt: toIso(newest),
+ windows,
+ };
+};
+
+const loadAccountViews = async (client: TrpcClient, accounts: any[]) =>
+ Promise.all(
+ accounts.map(async (account) =>
+ buildAccountView(
+ account,
+ (await client.agentQuota.getLatestReadings.query({ accountId: account.id })) as any,
+ ),
+ ),
+ );
+
+const accountName = (view: QuotaAccountView) =>
+ view.label || view.email || view.displayName || view.accountId;
+
+const formatStatus = (view: QuotaAccountView) => {
+ switch (view.status) {
+ case 'exhausted': {
+ return pc.red(
+ view.unavailableUntil
+ ? `exhausted (resets ${timeUntil(view.unavailableUntil)})`
+ : 'exhausted',
+ );
+ }
+ case 'warning': {
+ return pc.yellow('warning');
+ }
+ case 'ok': {
+ return pc.green('ok');
+ }
+ default: {
+ return pc.dim('no data');
+ }
+ }
+};
+
+const formatWindow = (view: QuotaAccountView, kind: string) => {
+ const window = view.windows.find((w) => w.kind === kind);
+ if (!window) return '-';
+ const reset = window.resetsAt ? pc.dim(` ${timeUntil(window.resetsAt)}`) : '';
+ return `${window.utilization}%${reset}`;
+};
+
+const formatScopedWeekly = (view: QuotaAccountView) =>
+ view.windows
+ .filter((w) => w.kind.startsWith('weekly:'))
+ .map((w) => `${w.scopeKey} ${w.utilization}%`)
+ .join(', ') || '-';
+
+const printAccountTable = (views: QuotaAccountView[]) => {
+ printTable(
+ views.map((view) => [
+ view.accountId,
+ view.provider,
+ accountName(view),
+ formatWindow(view, 'session'),
+ formatWindow(view, 'weekly'),
+ formatScopedWeekly(view),
+ formatStatus(view),
+ view.updatedAt ? timeAgo(view.updatedAt) : '-',
+ ]),
+ ['ACCOUNT ID', 'PROVIDER', 'NAME', '5H', 'WEEKLY', 'MODEL WEEKLY', 'STATUS', 'UPDATED'],
+ );
+};
+
+const emitJson = (data: unknown, json: string | boolean) =>
+ outputJson(data, typeof json === 'string' ? json : undefined);
+
+export function registerQuotaCommand(program: Command) {
+ const quota = program
+ .command('quota')
+ .description(
+ 'Read subscription quota of agent runtimes (Claude Code / Codex / Kimi Code accounts)',
+ );
+
+ // ── list ──────────────────────────────────────────────
+
+ quota
+ .command('list')
+ .description('List subscription accounts with their current quota windows')
+ .option('--provider <provider>', 'Only this provider: claude-code, codex or kimi-code')
+ .option('--json [fields]', 'Output JSON, optionally specify fields (comma-separated)')
+ .option('--workspace <id|slug>', "Read the workspace's shared accounts")
+ .action(async (options: { json?: string | boolean; provider?: string; workspace?: string }) => {
+ const client = await getTrpcClient(await resolveWorkspaceRef(options.workspace));
+ const accounts = ((await client.agentQuota.listAccounts.query()) as any[]).filter(
+ (account) => !options.provider || account.provider === options.provider,
+ );
+ const views = await loadAccountViews(client, accounts);
+
+ if (options.json !== undefined) return emitJson(views, options.json);
+
+ if (views.length === 0) {
+ console.log('No subscription accounts found.');
+ console.log(
+ pc.dim(
+ 'Accounts appear once a device running Claude Code / Codex / Kimi Code reports quota.',
+ ),
+ );
+ return;
+ }
+ printAccountTable(views);
+ });
+
+ // ── view ──────────────────────────────────────────────
+
+ quota
+ .command('view <accountId>')
+ .description('Show one account: every quota window and the agent runs spending it now')
+ .option('--json [fields]', 'Output JSON, optionally specify fields (comma-separated)')
+ .option('--workspace <id|slug>', 'Read the account in this workspace context')
+ .action(async (accountId: string, options: { json?: string | boolean; workspace?: string }) => {
+ const client = await getTrpcClient(await resolveWorkspaceRef(options.workspace));
+ const accounts = (await client.agentQuota.listAccounts.query()) as any[];
+ const account = accounts.find((a) => a.id === accountId);
+ if (!account) {
+ log.error(`Account "${accountId}" not found. Run 'lh quota list' to see accounts.`);
+ process.exit(1);
+ return;
+ }
+
+ const [view] = await loadAccountViews(client, [account]);
+ const activeRuns = (await client.agentQuota.listActiveRuns.query({ accountId })) as any[];
+ const result = { ...view, activeRuns };
+
+ if (options.json !== undefined) return emitJson(result, options.json);
+
+ console.log(`${pc.bold(accountName(view))} ${pc.dim(`(${view.provider})`)}`);
+ console.log(`Status: ${formatStatus(view)}`);
+ if (view.updatedAt) console.log(pc.dim(`Updated ${timeAgo(view.updatedAt)}`));
+ console.log();
+ if (view.windows.length) {
+ printTable(
+ view.windows.map((w) => [
+ w.kind,
+ `${w.utilization}%`,
+ w.resetsAt ? timeUntil(w.resetsAt) : '-',
+ ]),
+ ['WINDOW', 'USED', 'RESETS'],
+ );
+ } else {
+ console.log(pc.dim('No quota readings yet.'));
+ }
+ if (activeRuns.length) {
+ console.log();
+ console.log(pc.bold('Active runs'));
+ printTable(
+ activeRuns.map((run) => [
+ run.agentTitle ?? run.agentId ?? '-',
+ run.topicTitle ?? run.topicId ?? '-',
+ run.lastTurnAt ? timeAgo(new Date(run.lastTurnAt)) : '-',
+ ]),
+ ['AGENT', 'TOPIC', 'LAST TURN'],
+ );
+ }
+ });
+
+ // ── agent ─────────────────────────────────────────────
+
+ quota
+ .command('agent <agentId>')
+ .description(
+ 'Quota of the account(s) an agent runs on: the account it would use now, and every bound account',
+ )
+ .option('--device <deviceId>', 'Resolve the account the agent uses on this device')
+ .option('--provider <provider>', 'Runtime provider: claude-code, codex or kimi-code')
+ .option('--json [fields]', 'Output JSON, optionally specify fields (comma-separated)')
+ .option('--workspace <id|slug>', 'Read the agent in this workspace context')
+ .action(
+ async (
+ agentId: string,
+ options: {
+ device?: string;
+ json?: string | boolean;
+ provider?: string;
+ workspace?: string;
+ },
+ ) => {
+ const client = await getTrpcClient(await resolveWorkspaceRef(options.workspace));
+ const [selected, bindings, accounts] = await Promise.all([
+ client.agentQuota.selectAccountForAgent.query({
+ agentId,
+ deviceId: options.device,
+ provider: options.provider,
+ }),
+ client.agentQuota.listBindings.query({ agentId }),
+ client.agentQuota.listAccounts.query(),
+ ]);
+
+ const byId = new Map((accounts as any[]).map((a) => [a.id, a]));
+ const boundIds = new Set<string>(
+ (bindings as any[]).filter((b) => b.role !== 'disabled').map((b) => b.accountId),
+ );
+ if (selected?.accountId) boundIds.add(selected.accountId);
+ const views = await loadAccountViews(
+ client,
+ [...boundIds].map((id) => byId.get(id)).filter(Boolean),
+ );
+ const current = views.find((v) => v.accountId === selected?.accountId) ?? null;
+ const result = {
+ agentId,
+ current: current && { ...current, reason: selected?.reason ?? null },
+ accounts: views,
+ };
+
+ if (options.json !== undefined) return emitJson(result, options.json);
+
+ if (!views.length) {
+ console.log(`No subscription account is bound to agent ${agentId}.`);
+ return;
+ }
+ if (current) {
+ console.log(
+ `Current account: ${pc.bold(accountName(current))} ${pc.dim(`(${selected?.reason})`)} β€” ${formatStatus(current)}`,
+ );
+ console.log();
+ }
+ printAccountTable(views);
+ },
+ );
+
+ // ── refresh ───────────────────────────────────────────
+
+ quota
+ .command('refresh')
+ .description(
+ 'Sample quota on a device now (codex / kimi-code; Claude Code is reported by the desktop app)',
+ )
+ .requiredOption('--device <deviceId>', 'Device to sample on (see `lh device list`)')
+ .requiredOption('--provider <provider>', 'codex or kimi-code')
+ .option('--json [fields]', 'Output JSON, optionally specify fields (comma-separated)')
+ .option('--workspace <id|slug>', 'Reach the device through this workspace context')
+ .action(
+ async (options: {
+ device: string;
+ json?: string | boolean;
+ provider: string;
+ workspace?: string;
+ }) => {
+ if (options.provider !== 'codex' && options.provider !== 'kimi-code') {
+ log.error(
+ `Cannot refresh "${options.provider}" on demand; only codex and kimi-code are sampled through the device.`,
+ );
+ process.exit(1);
+ return;
+ }
+
+ const client = await getTrpcClient(await resolveWorkspaceRef(options.workspace));
+ const input = { deviceId: options.device, force: true };
+ const snapshot: any =
+ options.provider === 'codex'
+ ? await client.agentQuota.refreshCodexQuota.mutate(input)
+ : await client.agentQuota.refreshKimiCodeQuota.mutate(input);
+
+ if (options.json !== undefined) return emitJson(snapshot, options.json);
+
+ if (!snapshot) {
+ log.error(`Device "${options.device}" is not reachable.`);
+ process.exit(1);
+ return;
+ }
+ if (snapshot.status !== 'ok') {
+ log.error(`Refresh failed: ${snapshot.error ?? snapshot.status}`);
+ process.exit(1);
+ return;
+ }
+ const who = snapshot.identity?.email ?? snapshot.identity?.externalAccountId ?? 'account';
+ console.log(`${pc.green('βœ“')} Refreshed ${options.provider} quota for ${who}`);
+ for (const reading of snapshot.readings ?? []) {
+ const reset = reading.resetsAt
+ ? pc.dim(` (resets ${timeUntil(new Date(reading.resetsAt))})`)
+ : '';
+ console.log(` ${windowKind(reading)}: ${reading.utilization}%${reset}`);
+ }
+ },
+ );
+}
diff --git a/apps/cli/src/program.ts b/apps/cli/src/program.ts
index 1189a273ee8..9556d39a5b5 100644
--- a/apps/cli/src/program.ts
+++ b/apps/cli/src/program.ts
@@ -36,6 +36,7 @@ import { registerNotifyCommand } from './commands/notify';
import { registerLegacyPluginCommand } from './commands/plugin';
import { registerProjectCommand } from './commands/project';
import { registerProviderCommand } from './commands/provider';
+import { registerQuotaCommand } from './commands/quota';
import { registerReadCommand } from './commands/read';
import { registerRecallCommand } from './commands/recall';
import { registerSearchCommand } from './commands/search';
@@ -91,6 +92,7 @@ export function createProgram() {
registerManCommand(program);
registerConnectCommand(program);
registerDeviceCommand(program);
+ registerQuotaCommand(program);
registerStatusCommand(program);
registerDoctorCommand(program);
registerDocCommand(program);
diff --git a/packages/builtin-skills/src/lobehub/content.ts b/packages/builtin-skills/src/lobehub/content.ts
index 7bb5791084b..85f4c35daac 100644
--- a/packages/builtin-skills/src/lobehub/content.ts
+++ b/packages/builtin-skills/src/lobehub/content.ts
@@ -69,6 +69,7 @@ run commands.
| \`lh automation\` | Automations: MCP Events subscriptions an agent made in a conversation (list, view, rename, check, delete) | \`references/automation\` |
| \`lh legacy-plugin\` | Legacy 1.0 plugin management | \`references/plugin\` |
| \`lh bot\` | Bot integration management (Discord, Slack, Telegram, etc.) | \`references/bot\` |
+| \`lh quota\` | Subscription quota (5h / weekly windows) of the Claude Code / Codex / Kimi Code accounts agents run on | \`references/quota\` |
| \`lh widget\` / \`lh dashboard\` | Monitoring widgets (sandboxed scripts) and the dashboards they sit on | \`references/dashboard\` |
| \`lh eval\` | Evaluation workflow management | \`references/eval\` |
| \`lh whoami\` / \`lh usage\` / \`lh user\` / \`lh notification\` / \`lh migrate\` | Account, usage, settings, notification settings and imports (top-level commands, not a \`config\` module) | \`references/config\` |
diff --git a/packages/builtin-skills/src/lobehub/index.ts b/packages/builtin-skills/src/lobehub/index.ts
index 68feed410d4..e6f7bf6a201 100644
--- a/packages/builtin-skills/src/lobehub/index.ts
+++ b/packages/builtin-skills/src/lobehub/index.ts
@@ -30,6 +30,7 @@ import model from './references/model';
import plugin from './references/plugin';
import project from './references/project';
import provider from './references/provider';
+import quota from './references/quota';
import search from './references/search';
import skill from './references/skill';
import topic from './references/topic';
@@ -70,6 +71,7 @@ export const LobeHubSkill: BuiltinSkill = {
'references/plugin': plugin,
'references/project': project,
'references/provider': provider,
+ 'references/quota': quota,
'references/search': search,
'references/skill': skill,
'references/topic': topic,
diff --git a/packages/builtin-skills/src/lobehub/references/quota.ts b/packages/builtin-skills/src/lobehub/references/quota.ts
new file mode 100644
index 00000000000..a26b58b510e
--- /dev/null
+++ b/packages/builtin-skills/src/lobehub/references/quota.ts
@@ -0,0 +1,42 @@
+const content = `# lh quota - Subscription Quota of Agent Runtimes
+
+Agents that run on Claude Code, Codex or Kimi Code spend the subscription account signed in on
+their device, not LobeHub credits. \`lh quota\` reads those accounts' quota windows (5-hour session,
+weekly, model-scoped weekly) as last reported by the devices. Use it to tell whether an agent can
+take more work right now, or when its account gets quota back.
+
+\`lh usage\` is a different thing: LobeHub's own credits and spend.
+
+## Subcommands
+
+- \`lh quota list [--provider <claude-code|codex|kimi-code>]\` - Every visible account with its 5h / weekly / model-weekly usage and status
+- \`lh quota view <accountId>\` - One account: every window with its reset time, and the agent runs spending it now
+- \`lh quota agent <agentId> [--device <deviceId>] [--provider <provider>]\` - The account the agent would run on now (\`current\`, with \`reason\` pinned / balanced) and every account bound to it
+- \`lh quota refresh --device <deviceId> --provider <codex|kimi-code>\` - Sample quota on the device now and store it; Claude Code is reported by the desktop app on its own
+
+All of them accept \`--json\`.
+
+## Status
+
+Each account folds its windows into one \`status\`:
+
+- \`ok\` - every window below 80%
+- \`warning\` - a window at 80% or more
+- \`exhausted\` - a window is full; \`unavailableUntil\` is when the account gets quota back
+- \`unknown\` - no device has reported this account yet
+
+Utilization is the provider's own number at \`updatedAt\`. A window whose reset time has passed counts
+as 0%. When \`updatedAt\` is old and the account is Codex or Kimi Code, run \`lh quota refresh\` first.
+
+## Examples
+
+\`\`\`bash
+# Which accounts are out of quota right now
+lh quota list --json accountId,provider,email,status,unavailableUntil
+
+# Can this agent take a task now?
+lh quota agent <agentId> --json
+\`\`\`
+`;
+
+export default content;