@ai-devkit/agent-manager 0.34.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentManager.d.ts +2 -0
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +25 -0
- package/dist/AgentManager.js.map +1 -1
- package/dist/__tests__/AgentManager.test.js +74 -0
- package/dist/__tests__/AgentManager.test.js.map +1 -1
- package/dist/__tests__/adapters/AntigravityCliAdapter.test.js +381 -0
- package/dist/__tests__/adapters/AntigravityCliAdapter.test.js.map +1 -0
- package/dist/__tests__/adapters/ClaudeCodeAdapter.test.js +28 -0
- package/dist/__tests__/adapters/ClaudeCodeAdapter.test.js.map +1 -1
- package/dist/__tests__/adapters/CodexAdapter.test.js +7 -0
- package/dist/__tests__/adapters/CodexAdapter.test.js.map +1 -1
- package/dist/__tests__/adapters/KiroAdapter.test.js +607 -0
- package/dist/__tests__/adapters/KiroAdapter.test.js.map +1 -0
- package/dist/__tests__/capacity/claude.test.js +485 -0
- package/dist/__tests__/capacity/claude.test.js.map +1 -0
- package/dist/__tests__/capacity/openai.test.js +672 -0
- package/dist/__tests__/capacity/openai.test.js.map +1 -0
- package/dist/__tests__/capacity/wham.test.js +144 -0
- package/dist/__tests__/capacity/wham.test.js.map +1 -0
- package/dist/__tests__/providers/copilot/CopilotAdapter.test.js +18 -0
- package/dist/__tests__/providers/copilot/CopilotAdapter.test.js.map +1 -1
- package/dist/__tests__/providers/gemini/GeminiCliAdapter.test.js +36 -0
- package/dist/__tests__/providers/gemini/GeminiCliAdapter.test.js.map +1 -1
- package/dist/__tests__/providers/grok/GrokAgentMapper.test.js +56 -0
- package/dist/__tests__/providers/grok/GrokAgentMapper.test.js.map +1 -0
- package/dist/__tests__/{adapters → providers/grok}/GrokCliAdapter.test.js +19 -6
- package/dist/__tests__/providers/grok/GrokCliAdapter.test.js.map +1 -0
- package/dist/__tests__/providers/grok/GrokSessionLocator.test.js +133 -0
- package/dist/__tests__/providers/grok/GrokSessionLocator.test.js.map +1 -0
- package/dist/__tests__/providers/opencode/OpenCodeAdapter.test.js +24 -0
- package/dist/__tests__/providers/opencode/OpenCodeAdapter.test.js.map +1 -1
- package/dist/__tests__/providers/pi/PiAdapter.test.js +30 -0
- package/dist/__tests__/providers/pi/PiAdapter.test.js.map +1 -1
- package/dist/__tests__/utils/agents.test.js +6 -0
- package/dist/__tests__/utils/agents.test.js.map +1 -1
- package/dist/__tests__/utils/session.test.js +18 -1
- package/dist/__tests__/utils/session.test.js.map +1 -1
- package/dist/adapters/AgentAdapter.d.ts +9 -1
- package/dist/adapters/AgentAdapter.d.ts.map +1 -1
- package/dist/adapters/AgentAdapter.js.map +1 -1
- package/dist/adapters/AntigravityCliAdapter.d.ts +57 -0
- package/dist/adapters/AntigravityCliAdapter.d.ts.map +1 -0
- package/dist/adapters/AntigravityCliAdapter.js +273 -0
- package/dist/adapters/AntigravityCliAdapter.js.map +1 -0
- package/dist/adapters/KiroAdapter.d.ts +46 -0
- package/dist/adapters/KiroAdapter.d.ts.map +1 -0
- package/dist/adapters/KiroAdapter.js +344 -0
- package/dist/adapters/KiroAdapter.js.map +1 -0
- package/dist/adapters/index.d.ts +3 -1
- package/dist/adapters/index.d.ts.map +1 -1
- package/dist/adapters/index.js +3 -1
- package/dist/adapters/index.js.map +1 -1
- package/dist/capacity/claude.d.ts +17 -0
- package/dist/capacity/claude.d.ts.map +1 -0
- package/dist/capacity/claude.js +271 -0
- package/dist/capacity/claude.js.map +1 -0
- package/dist/capacity/codex.d.ts +1 -2
- package/dist/capacity/codex.d.ts.map +1 -1
- package/dist/capacity/codex.js +5 -47
- package/dist/capacity/codex.js.map +1 -1
- package/dist/capacity/index.d.ts +11 -0
- package/dist/capacity/index.d.ts.map +1 -1
- package/dist/capacity/index.js +17 -0
- package/dist/capacity/index.js.map +1 -1
- package/dist/capacity/openai.d.ts +48 -0
- package/dist/capacity/openai.d.ts.map +1 -0
- package/dist/capacity/openai.js +312 -0
- package/dist/capacity/openai.js.map +1 -0
- package/dist/capacity/wham.d.ts +16 -0
- package/dist/capacity/wham.d.ts.map +1 -0
- package/dist/capacity/wham.js +66 -0
- package/dist/capacity/wham.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/providers/claude/ClaudeCodeAdapter.d.ts +2 -0
- package/dist/providers/claude/ClaudeCodeAdapter.d.ts.map +1 -1
- package/dist/providers/claude/ClaudeCodeAdapter.js +22 -19
- package/dist/providers/claude/ClaudeCodeAdapter.js.map +1 -1
- package/dist/providers/claude/ClaudeSessionLocator.d.ts +4 -0
- package/dist/providers/claude/ClaudeSessionLocator.d.ts.map +1 -1
- package/dist/providers/claude/ClaudeSessionLocator.js +18 -1
- package/dist/providers/claude/ClaudeSessionLocator.js.map +1 -1
- package/dist/providers/codex/CodexAdapter.d.ts +1 -0
- package/dist/providers/codex/CodexAdapter.d.ts.map +1 -1
- package/dist/providers/codex/CodexAdapter.js +8 -0
- package/dist/providers/codex/CodexAdapter.js.map +1 -1
- package/dist/providers/copilot/CopilotAdapter.d.ts +2 -0
- package/dist/providers/copilot/CopilotAdapter.d.ts.map +1 -1
- package/dist/providers/copilot/CopilotAdapter.js +24 -9
- package/dist/providers/copilot/CopilotAdapter.js.map +1 -1
- package/dist/providers/copilot/CopilotSessionLocator.d.ts +1 -0
- package/dist/providers/copilot/CopilotSessionLocator.d.ts.map +1 -1
- package/dist/providers/copilot/CopilotSessionLocator.js +9 -1
- package/dist/providers/copilot/CopilotSessionLocator.js.map +1 -1
- package/dist/providers/gemini/GeminiCliAdapter.d.ts +1 -0
- package/dist/providers/gemini/GeminiCliAdapter.d.ts.map +1 -1
- package/dist/providers/gemini/GeminiCliAdapter.js +9 -0
- package/dist/providers/gemini/GeminiCliAdapter.js.map +1 -1
- package/dist/providers/grok/GrokAgentMapper.d.ts +14 -0
- package/dist/providers/grok/GrokAgentMapper.d.ts.map +1 -0
- package/dist/providers/grok/GrokAgentMapper.js +36 -0
- package/dist/providers/grok/GrokAgentMapper.js.map +1 -0
- package/dist/providers/grok/GrokCliAdapter.d.ts +36 -0
- package/dist/providers/grok/GrokCliAdapter.d.ts.map +1 -0
- package/dist/providers/grok/GrokCliAdapter.js +98 -0
- package/dist/providers/grok/GrokCliAdapter.js.map +1 -0
- package/dist/providers/grok/GrokSessionLocator.d.ts +62 -0
- package/dist/providers/grok/GrokSessionLocator.d.ts.map +1 -0
- package/dist/providers/grok/GrokSessionLocator.js +140 -0
- package/dist/providers/grok/GrokSessionLocator.js.map +1 -0
- package/dist/providers/grok/GrokSessionParser.d.ts +54 -0
- package/dist/providers/grok/GrokSessionParser.d.ts.map +1 -0
- package/dist/providers/grok/GrokSessionParser.js +122 -0
- package/dist/providers/grok/GrokSessionParser.js.map +1 -0
- package/dist/providers/opencode/OpenCodeAdapter.d.ts +1 -0
- package/dist/providers/opencode/OpenCodeAdapter.d.ts.map +1 -1
- package/dist/providers/opencode/OpenCodeAdapter.js +3 -0
- package/dist/providers/opencode/OpenCodeAdapter.js.map +1 -1
- package/dist/providers/opencode/OpenCodeSessionLocator.d.ts +2 -0
- package/dist/providers/opencode/OpenCodeSessionLocator.d.ts.map +1 -1
- package/dist/providers/opencode/OpenCodeSessionLocator.js +31 -12
- package/dist/providers/opencode/OpenCodeSessionLocator.js.map +1 -1
- package/dist/providers/pi/PiAdapter.d.ts +1 -0
- package/dist/providers/pi/PiAdapter.d.ts.map +1 -1
- package/dist/providers/pi/PiAdapter.js +10 -0
- package/dist/providers/pi/PiAdapter.js.map +1 -1
- package/dist/providers/pi/PiSessionLocator.d.ts +1 -0
- package/dist/providers/pi/PiSessionLocator.d.ts.map +1 -1
- package/dist/providers/pi/PiSessionLocator.js +8 -1
- package/dist/providers/pi/PiSessionLocator.js.map +1 -1
- package/dist/readiness/AgentReadiness.d.ts +1 -1
- package/dist/readiness/AgentReadiness.d.ts.map +1 -1
- package/dist/readiness/AgentReadiness.js.map +1 -1
- package/dist/runtime/ManagedAgentRuntime.js +3 -1
- package/dist/runtime/ManagedAgentRuntime.js.map +1 -1
- package/dist/runtime/herdr/HerdrAgentDiscovery.js +10 -0
- package/dist/runtime/herdr/HerdrAgentDiscovery.js.map +1 -1
- package/dist/utils/agents.d.ts +1 -1
- package/dist/utils/agents.d.ts.map +1 -1
- package/dist/utils/agents.js +11 -0
- package/dist/utils/agents.js.map +1 -1
- package/dist/utils/session.d.ts +2 -0
- package/dist/utils/session.d.ts.map +1 -1
- package/dist/utils/session.js +3 -0
- package/dist/utils/session.js.map +1 -1
- package/package.json +1 -1
- package/src/AgentManager.ts +34 -0
- package/src/__tests__/AgentManager.test.ts +60 -0
- package/src/__tests__/adapters/AntigravityCliAdapter.test.ts +324 -0
- package/src/__tests__/adapters/ClaudeCodeAdapter.test.ts +23 -0
- package/src/__tests__/adapters/CodexAdapter.test.ts +7 -0
- package/src/__tests__/adapters/KiroAdapter.test.ts +534 -0
- package/src/__tests__/capacity/claude.test.ts +467 -0
- package/src/__tests__/capacity/fixtures/claude-credentials.json +7 -0
- package/src/__tests__/capacity/fixtures/claude-usage-malformed.json +1 -0
- package/src/__tests__/capacity/fixtures/claude-usage-partial.json +15 -0
- package/src/__tests__/capacity/fixtures/claude-usage.json +63 -0
- package/src/__tests__/capacity/fixtures/openai-auth.json +6 -0
- package/src/__tests__/capacity/fixtures/openai-codex-auth.json +9 -0
- package/src/__tests__/capacity/fixtures/openai-usage-completions.json +67 -0
- package/src/__tests__/capacity/fixtures/openai-usage-responses.json +20 -0
- package/src/__tests__/capacity/fixtures/wham-usage.json +32 -0
- package/src/__tests__/capacity/openai.test.ts +570 -0
- package/src/__tests__/capacity/wham.test.ts +104 -0
- package/src/__tests__/providers/copilot/CopilotAdapter.test.ts +12 -0
- package/src/__tests__/providers/gemini/GeminiCliAdapter.test.ts +21 -0
- package/src/__tests__/providers/grok/GrokAgentMapper.test.ts +57 -0
- package/src/__tests__/{adapters → providers/grok}/GrokCliAdapter.test.ts +18 -9
- package/src/__tests__/providers/grok/GrokSessionLocator.test.ts +106 -0
- package/src/__tests__/providers/opencode/OpenCodeAdapter.test.ts +18 -0
- package/src/__tests__/providers/pi/PiAdapter.test.ts +15 -0
- package/src/__tests__/utils/agents.test.ts +7 -0
- package/src/__tests__/utils/session.test.ts +11 -1
- package/src/adapters/AgentAdapter.ts +11 -0
- package/src/adapters/AntigravityCliAdapter.ts +356 -0
- package/src/adapters/KiroAdapter.ts +456 -0
- package/src/adapters/index.ts +3 -1
- package/src/capacity/claude.ts +313 -0
- package/src/capacity/codex.ts +25 -134
- package/src/capacity/index.ts +33 -4
- package/src/capacity/openai.ts +361 -0
- package/src/capacity/wham.ts +84 -0
- package/src/index.ts +11 -2
- package/src/providers/claude/ClaudeCodeAdapter.ts +28 -23
- package/src/providers/claude/ClaudeSessionLocator.ts +20 -0
- package/src/providers/codex/CodexAdapter.ts +8 -0
- package/src/providers/copilot/CopilotAdapter.ts +26 -10
- package/src/providers/copilot/CopilotSessionLocator.ts +7 -1
- package/src/providers/gemini/GeminiCliAdapter.ts +8 -0
- package/src/providers/grok/GrokAgentMapper.ts +41 -0
- package/src/providers/grok/GrokCliAdapter.ts +125 -0
- package/src/providers/grok/GrokSessionLocator.ts +179 -0
- package/src/providers/grok/GrokSessionParser.ts +166 -0
- package/src/providers/opencode/OpenCodeAdapter.ts +4 -0
- package/src/providers/opencode/OpenCodeSessionLocator.ts +43 -15
- package/src/providers/pi/PiAdapter.ts +12 -0
- package/src/providers/pi/PiSessionLocator.ts +16 -1
- package/src/readiness/AgentReadiness.ts +4 -1
- package/src/runtime/ManagedAgentRuntime.ts +2 -0
- package/src/runtime/herdr/HerdrAgentDiscovery.ts +5 -1
- package/src/utils/agents.ts +11 -1
- package/src/utils/session.ts +11 -0
- package/dist/__tests__/adapters/GrokCliAdapter.test.js.map +0 -1
- package/dist/adapters/GrokCliAdapter.d.ts +0 -80
- package/dist/adapters/GrokCliAdapter.d.ts.map +0 -1
- package/dist/adapters/GrokCliAdapter.js +0 -310
- package/dist/adapters/GrokCliAdapter.js.map +0 -1
- package/src/adapters/GrokCliAdapter.ts +0 -408
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import * as capacity from "../../capacity/index.js";
|
|
5
|
+
import { parseClaudeUsage } from "../../capacity/claude.js";
|
|
6
|
+
import * as agentManager from "../../index.js";
|
|
7
|
+
|
|
8
|
+
const fixture = (name: string) =>
|
|
9
|
+
readFile(fileURLToPath(new URL(`./fixtures/${name}`, import.meta.url)), "utf8");
|
|
10
|
+
|
|
11
|
+
describe("Claude capacity", () => {
|
|
12
|
+
it("exposes a Claude capacity report reader", () => {
|
|
13
|
+
expect(capacity).toHaveProperty("getClaudeCapacityReport");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("exports the Claude report reader from agent-manager", () => {
|
|
17
|
+
expect(agentManager).toHaveProperty("getClaudeCapacityReport");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("uses an environment OAuth token for the exact usage request", async () => {
|
|
21
|
+
const fetch = vi.fn(
|
|
22
|
+
async () =>
|
|
23
|
+
new Response(JSON.stringify({ five_hour: { utilization: 20 } }), {
|
|
24
|
+
status: 200,
|
|
25
|
+
headers: { "Content-Type": "application/json" },
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const report = await capacity.getClaudeCapacityReport({
|
|
30
|
+
now: () => new Date("2026-09-25T18:00:00.000Z"),
|
|
31
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-environment-token" },
|
|
32
|
+
readFile: vi.fn(),
|
|
33
|
+
fetch,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expect(fetch).toHaveBeenCalledOnce();
|
|
37
|
+
expect(fetch).toHaveBeenCalledWith(
|
|
38
|
+
"https://api.anthropic.com/api/oauth/usage",
|
|
39
|
+
expect.objectContaining({
|
|
40
|
+
method: "GET",
|
|
41
|
+
headers: {
|
|
42
|
+
Accept: "application/json",
|
|
43
|
+
Authorization: "Bearer fake-environment-token",
|
|
44
|
+
"Content-Type": "application/json",
|
|
45
|
+
"User-Agent": "claude-code/2.1.0",
|
|
46
|
+
"anthropic-beta": "oauth-2025-04-20",
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
expect(report).toMatchObject({
|
|
51
|
+
harness: "claude",
|
|
52
|
+
provider: "anthropic",
|
|
53
|
+
authenticated: true,
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("reads the OAuth token from the active Claude profile", async () => {
|
|
58
|
+
const readFile = vi.fn(async () => fixture("claude-credentials.json"));
|
|
59
|
+
const fetch = vi.fn(async () => new Response(JSON.stringify({}), { status: 200 }));
|
|
60
|
+
|
|
61
|
+
await capacity.getClaudeCapacityReport({
|
|
62
|
+
now: () => new Date("2026-09-25T18:00:00.000Z"),
|
|
63
|
+
env: { HOME: "/users/test", CLAUDE_CONFIG_DIR: "profiles/work" },
|
|
64
|
+
cwd: "/workspace/project",
|
|
65
|
+
readFile,
|
|
66
|
+
fetch,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
expect(readFile).toHaveBeenCalledWith(
|
|
70
|
+
"/workspace/project/profiles/work/.credentials.json",
|
|
71
|
+
"utf8",
|
|
72
|
+
);
|
|
73
|
+
expect(fetch.mock.calls[0][1]?.headers).toMatchObject({
|
|
74
|
+
Authorization: "Bearer fake-claude-oauth-token-for-tests",
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("rejects an expired profile credential before fetching usage", async () => {
|
|
79
|
+
const fetch = vi.fn();
|
|
80
|
+
await expect(
|
|
81
|
+
capacity.getClaudeCapacityReport({
|
|
82
|
+
now: () => new Date("2026-09-25T18:00:00.000Z"),
|
|
83
|
+
env: { HOME: "/users/test" },
|
|
84
|
+
platform: "linux",
|
|
85
|
+
readFile: async () =>
|
|
86
|
+
JSON.stringify({
|
|
87
|
+
claudeAiOauth: {
|
|
88
|
+
accessToken: "fake-expired-token",
|
|
89
|
+
expiresAt: 1,
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
fetch,
|
|
93
|
+
}),
|
|
94
|
+
).rejects.toThrow("Claude OAuth credentials expired");
|
|
95
|
+
expect(fetch).not.toHaveBeenCalled();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("maps subscription, model, scoped, and extra-usage windows", async () => {
|
|
99
|
+
const report = await capacity.getClaudeCapacityReport({
|
|
100
|
+
now: () => new Date("2026-09-25T18:00:00.000Z"),
|
|
101
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-mapping-token" },
|
|
102
|
+
fetch: vi.fn(async () => new Response(await fixture("claude-usage.json"), { status: 200 })),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(report).toMatchObject({
|
|
106
|
+
harness: "claude",
|
|
107
|
+
provider: "anthropic",
|
|
108
|
+
generatedAt: "2026-09-25T18:00:00.000Z",
|
|
109
|
+
authenticated: true,
|
|
110
|
+
available: "yes",
|
|
111
|
+
creditsRemaining: null,
|
|
112
|
+
});
|
|
113
|
+
expect(report.windows).toEqual([
|
|
114
|
+
{
|
|
115
|
+
id: "session",
|
|
116
|
+
label: "Session",
|
|
117
|
+
durationMinutes: 300,
|
|
118
|
+
usedPercent: 25,
|
|
119
|
+
resetsAt: "2026-09-25T20:00:00.000Z",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "weekly",
|
|
123
|
+
label: "Weekly",
|
|
124
|
+
durationMinutes: 10080,
|
|
125
|
+
usedPercent: 55.5,
|
|
126
|
+
resetsAt: "2026-09-30T12:00:00.000Z",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: "claude:sonnet:weekly",
|
|
130
|
+
label: "Sonnet weekly",
|
|
131
|
+
durationMinutes: 10080,
|
|
132
|
+
usedPercent: 61,
|
|
133
|
+
resetsAt: "2026-09-30T12:00:00.000Z",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: "claude:opus:weekly",
|
|
137
|
+
label: "Opus weekly",
|
|
138
|
+
durationMinutes: 10080,
|
|
139
|
+
usedPercent: 72,
|
|
140
|
+
resetsAt: "2026-09-30T12:00:00.000Z",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "claude:weekly:claude-fable",
|
|
144
|
+
label: "Fable weekly",
|
|
145
|
+
durationMinutes: 10080,
|
|
146
|
+
usedPercent: 33,
|
|
147
|
+
resetsAt: "2026-09-29T08:00:00.000Z",
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
id: "claude:extra-usage",
|
|
151
|
+
label: "Extra usage · USD",
|
|
152
|
+
limitType: "CREDIT_LIMIT",
|
|
153
|
+
durationMinutes: null,
|
|
154
|
+
usedPercent: 25,
|
|
155
|
+
resetsAt: null,
|
|
156
|
+
total: 50,
|
|
157
|
+
current: 12.5,
|
|
158
|
+
remaining: 37.5,
|
|
159
|
+
},
|
|
160
|
+
]);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("reports a rejected OAuth token as unauthorized without leaking it", async () => {
|
|
164
|
+
const token = "fake-rejected-token-never-expose";
|
|
165
|
+
let error: unknown;
|
|
166
|
+
try {
|
|
167
|
+
await capacity.getClaudeCapacityReport({
|
|
168
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: token },
|
|
169
|
+
fetch: vi.fn(async () => new Response('{"private":"response-body"}', { status: 401 })),
|
|
170
|
+
});
|
|
171
|
+
} catch (caught) {
|
|
172
|
+
error = caught;
|
|
173
|
+
}
|
|
174
|
+
expect(error).toBeInstanceOf(Error);
|
|
175
|
+
expect((error as Error).message).toBe("Claude OAuth request unauthorized (HTTP 401)");
|
|
176
|
+
expect((error as Error).message).not.toContain(token);
|
|
177
|
+
expect((error as Error).message).not.toContain("response-body");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("reports forbidden subscription usage without returning the response body", async () => {
|
|
181
|
+
await expect(
|
|
182
|
+
capacity.getClaudeCapacityReport({
|
|
183
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-forbidden-token" },
|
|
184
|
+
fetch: vi.fn(async () => new Response("private forbidden details", { status: 403 })),
|
|
185
|
+
}),
|
|
186
|
+
).rejects.toThrow("Claude OAuth request forbidden (HTTP 403)");
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it.each([
|
|
190
|
+
["120", "2026-09-25T18:02:00.000Z"],
|
|
191
|
+
["Fri, 25 Sep 2026 19:00:00 GMT", "2026-09-25T19:00:00.000Z"],
|
|
192
|
+
])("honors Retry-After %s", async (retryAfter, expected) => {
|
|
193
|
+
await expect(
|
|
194
|
+
capacity.getClaudeCapacityReport({
|
|
195
|
+
now: () => new Date("2026-09-25T18:00:00.000Z"),
|
|
196
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-rate-limited-token" },
|
|
197
|
+
fetch: vi.fn(
|
|
198
|
+
async () =>
|
|
199
|
+
new Response("private rate-limit body", {
|
|
200
|
+
status: 429,
|
|
201
|
+
headers: { "Retry-After": retryAfter },
|
|
202
|
+
}),
|
|
203
|
+
),
|
|
204
|
+
}),
|
|
205
|
+
).rejects.toThrow(`Claude OAuth usage rate limited until ${expected}`);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it("sanitizes malformed usage JSON", async () => {
|
|
209
|
+
await expect(
|
|
210
|
+
capacity.getClaudeCapacityReport({
|
|
211
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-malformed-token" },
|
|
212
|
+
fetch: vi.fn(async () => new Response("private non-json response", { status: 200 })),
|
|
213
|
+
}),
|
|
214
|
+
).rejects.toThrow("Claude usage response is malformed");
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("sanitizes network failures", async () => {
|
|
218
|
+
await expect(
|
|
219
|
+
capacity.getClaudeCapacityReport({
|
|
220
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-network-token" },
|
|
221
|
+
fetch: vi.fn(async () => {
|
|
222
|
+
throw new Error("private network details fake-network-token");
|
|
223
|
+
}),
|
|
224
|
+
}),
|
|
225
|
+
).rejects.toThrow("Claude OAuth usage request failed");
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it("preserves valid windows in a partial payload", async () => {
|
|
229
|
+
const report = parseClaudeUsage(
|
|
230
|
+
JSON.parse(await fixture("claude-usage-partial.json")),
|
|
231
|
+
"2026-09-25T18:00:00.000Z",
|
|
232
|
+
);
|
|
233
|
+
expect(report.available).toBe("yes");
|
|
234
|
+
expect(report.windows).toEqual([
|
|
235
|
+
{
|
|
236
|
+
id: "session",
|
|
237
|
+
label: "Session",
|
|
238
|
+
durationMinutes: 300,
|
|
239
|
+
usedPercent: 10,
|
|
240
|
+
resetsAt: null,
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
id: "weekly",
|
|
244
|
+
label: "Weekly",
|
|
245
|
+
durationMinutes: 10080,
|
|
246
|
+
usedPercent: null,
|
|
247
|
+
resetsAt: null,
|
|
248
|
+
},
|
|
249
|
+
]);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("rejects a non-object usage payload", async () => {
|
|
253
|
+
const raw = JSON.parse(await fixture("claude-usage-malformed.json"));
|
|
254
|
+
expect(() => parseClaudeUsage(raw, "2026-09-25T18:00:00.000Z")).toThrow(
|
|
255
|
+
"Claude usage response is malformed",
|
|
256
|
+
);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it.each([
|
|
260
|
+
["missing file", async () => Promise.reject(new Error("missing"))],
|
|
261
|
+
["malformed file", async () => "{"],
|
|
262
|
+
["missing token", async () => JSON.stringify({ claudeAiOauth: {} })],
|
|
263
|
+
])("rejects %s credentials without fetching", async (_name, readFile) => {
|
|
264
|
+
const fetch = vi.fn();
|
|
265
|
+
await expect(
|
|
266
|
+
capacity.getClaudeCapacityReport({
|
|
267
|
+
env: { HOME: "/users/test" },
|
|
268
|
+
platform: "linux",
|
|
269
|
+
readFile,
|
|
270
|
+
fetch,
|
|
271
|
+
}),
|
|
272
|
+
).rejects.toThrow("Claude OAuth credentials not found or malformed");
|
|
273
|
+
expect(fetch).not.toHaveBeenCalled();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it("uses the default Claude profile under HOME", async () => {
|
|
277
|
+
const readFile = vi.fn(async () =>
|
|
278
|
+
JSON.stringify({ claudeAiOauth: { accessToken: "fake-home-token" } }),
|
|
279
|
+
);
|
|
280
|
+
await capacity.getClaudeCapacityReport({
|
|
281
|
+
env: { HOME: "/users/test" },
|
|
282
|
+
readFile,
|
|
283
|
+
fetch: vi.fn(async () => new Response("{}", { status: 200 })),
|
|
284
|
+
});
|
|
285
|
+
expect(readFile).toHaveBeenCalledWith("/users/test/.claude/.credentials.json", "utf8");
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it("falls back to the Claude Code Keychain credential on macOS", async () => {
|
|
289
|
+
const keychainRead = vi.fn(async () =>
|
|
290
|
+
JSON.stringify({
|
|
291
|
+
claudeAiOauth: {
|
|
292
|
+
accessToken: "fake-keychain-token",
|
|
293
|
+
expiresAt: 1_900_000_000_000,
|
|
294
|
+
},
|
|
295
|
+
}),
|
|
296
|
+
);
|
|
297
|
+
const fetch = vi.fn(async () => new Response("{}", { status: 200 }));
|
|
298
|
+
|
|
299
|
+
await capacity.getClaudeCapacityReport({
|
|
300
|
+
now: () => new Date("2026-09-25T18:00:00.000Z"),
|
|
301
|
+
env: { HOME: "/users/test" },
|
|
302
|
+
platform: "darwin",
|
|
303
|
+
readFile: async () => Promise.reject(new Error("missing")),
|
|
304
|
+
keychainRead,
|
|
305
|
+
fetch,
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
expect(keychainRead).toHaveBeenCalledWith("Claude Code-credentials");
|
|
309
|
+
expect(fetch.mock.calls[0][1]?.headers).toMatchObject({
|
|
310
|
+
Authorization: "Bearer fake-keychain-token",
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
it("falls back to Keychain when the default profile file has no OAuth token", async () => {
|
|
315
|
+
const keychainRead = vi.fn(async () =>
|
|
316
|
+
JSON.stringify({ claudeAiOauth: { accessToken: "fake-keychain-fallback-token" } }),
|
|
317
|
+
);
|
|
318
|
+
const fetch = vi.fn(async () => new Response("{}", { status: 200 }));
|
|
319
|
+
|
|
320
|
+
await capacity.getClaudeCapacityReport({
|
|
321
|
+
env: { HOME: "/users/test" },
|
|
322
|
+
platform: "darwin",
|
|
323
|
+
readFile: async () => JSON.stringify({}),
|
|
324
|
+
keychainRead,
|
|
325
|
+
fetch,
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
expect(keychainRead).toHaveBeenCalledOnce();
|
|
329
|
+
expect(fetch.mock.calls[0][1]?.headers).toMatchObject({
|
|
330
|
+
Authorization: "Bearer fake-keychain-fallback-token",
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
it("keeps environment and profile-file credentials ahead of Keychain", async () => {
|
|
335
|
+
const keychainRead = vi.fn();
|
|
336
|
+
const fetch = vi.fn(async () => new Response("{}", { status: 200 }));
|
|
337
|
+
|
|
338
|
+
await capacity.getClaudeCapacityReport({
|
|
339
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-preferred-environment-token" },
|
|
340
|
+
platform: "darwin",
|
|
341
|
+
keychainRead,
|
|
342
|
+
fetch,
|
|
343
|
+
});
|
|
344
|
+
await capacity.getClaudeCapacityReport({
|
|
345
|
+
env: { HOME: "/users/test" },
|
|
346
|
+
platform: "darwin",
|
|
347
|
+
readFile: async () =>
|
|
348
|
+
JSON.stringify({ claudeAiOauth: { accessToken: "fake-preferred-file-token" } }),
|
|
349
|
+
keychainRead,
|
|
350
|
+
fetch,
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
expect(keychainRead).not.toHaveBeenCalled();
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it("rejects expired Keychain credentials before fetching usage", async () => {
|
|
357
|
+
const fetch = vi.fn();
|
|
358
|
+
|
|
359
|
+
await expect(
|
|
360
|
+
capacity.getClaudeCapacityReport({
|
|
361
|
+
now: () => new Date("2026-09-25T18:00:00.000Z"),
|
|
362
|
+
env: { HOME: "/users/test" },
|
|
363
|
+
platform: "darwin",
|
|
364
|
+
readFile: async () => Promise.reject(new Error("missing")),
|
|
365
|
+
keychainRead: async () =>
|
|
366
|
+
JSON.stringify({
|
|
367
|
+
claudeAiOauth: { accessToken: "fake-expired-keychain-token", expiresAt: 1 },
|
|
368
|
+
}),
|
|
369
|
+
fetch,
|
|
370
|
+
}),
|
|
371
|
+
).rejects.toThrow("Claude OAuth credentials expired");
|
|
372
|
+
|
|
373
|
+
expect(fetch).not.toHaveBeenCalled();
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it("uses a fresh Keychain credential when the default profile file is expired", async () => {
|
|
377
|
+
const keychainRead = vi.fn(async () =>
|
|
378
|
+
JSON.stringify({ claudeAiOauth: { accessToken: "fake-fresh-keychain-token" } }),
|
|
379
|
+
);
|
|
380
|
+
const fetch = vi.fn(async () => new Response("{}", { status: 200 }));
|
|
381
|
+
|
|
382
|
+
await capacity.getClaudeCapacityReport({
|
|
383
|
+
now: () => new Date("2026-09-25T18:00:00.000Z"),
|
|
384
|
+
env: { HOME: "/users/test" },
|
|
385
|
+
platform: "darwin",
|
|
386
|
+
readFile: async () =>
|
|
387
|
+
JSON.stringify({
|
|
388
|
+
claudeAiOauth: { accessToken: "fake-expired-file-token", expiresAt: 1 },
|
|
389
|
+
}),
|
|
390
|
+
keychainRead,
|
|
391
|
+
fetch,
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
expect(keychainRead).toHaveBeenCalledOnce();
|
|
395
|
+
expect(fetch.mock.calls[0][1]?.headers).toMatchObject({
|
|
396
|
+
Authorization: "Bearer fake-fresh-keychain-token",
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
it("sanitizes unavailable or malformed Keychain credentials", async () => {
|
|
401
|
+
const fetch = vi.fn();
|
|
402
|
+
|
|
403
|
+
await expect(
|
|
404
|
+
capacity.getClaudeCapacityReport({
|
|
405
|
+
env: { HOME: "/users/test" },
|
|
406
|
+
platform: "darwin",
|
|
407
|
+
readFile: async () => Promise.reject(new Error("private file error")),
|
|
408
|
+
keychainRead: async () => "private malformed keychain payload",
|
|
409
|
+
fetch,
|
|
410
|
+
}),
|
|
411
|
+
).rejects.toThrow("Claude OAuth credentials not found or malformed");
|
|
412
|
+
|
|
413
|
+
expect(fetch).not.toHaveBeenCalled();
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it("does not mix the default Keychain credential into a custom Claude profile", async () => {
|
|
417
|
+
const keychainRead = vi.fn(async () =>
|
|
418
|
+
JSON.stringify({ claudeAiOauth: { accessToken: "fake-wrong-profile-token" } }),
|
|
419
|
+
);
|
|
420
|
+
const fetch = vi.fn();
|
|
421
|
+
|
|
422
|
+
await expect(
|
|
423
|
+
capacity.getClaudeCapacityReport({
|
|
424
|
+
env: { HOME: "/users/test", CLAUDE_CONFIG_DIR: "/profiles/work" },
|
|
425
|
+
platform: "darwin",
|
|
426
|
+
readFile: async () => Promise.reject(new Error("missing")),
|
|
427
|
+
keychainRead,
|
|
428
|
+
fetch,
|
|
429
|
+
}),
|
|
430
|
+
).rejects.toThrow("Claude OAuth credentials not found or malformed");
|
|
431
|
+
|
|
432
|
+
expect(keychainRead).not.toHaveBeenCalled();
|
|
433
|
+
expect(fetch).not.toHaveBeenCalled();
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
it("reports other HTTP failures by status only", async () => {
|
|
437
|
+
await expect(
|
|
438
|
+
capacity.getClaudeCapacityReport({
|
|
439
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-status-token" },
|
|
440
|
+
fetch: vi.fn(async () => new Response("private service details", { status: 503 })),
|
|
441
|
+
}),
|
|
442
|
+
).rejects.toThrow("Claude OAuth usage request failed (HTTP 503)");
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
it("aborts a usage request at the configured timeout", async () => {
|
|
446
|
+
vi.useFakeTimers();
|
|
447
|
+
try {
|
|
448
|
+
const request = capacity.getClaudeCapacityReport({
|
|
449
|
+
env: { CLAUDE_CODE_OAUTH_TOKEN: "fake-timeout-token" },
|
|
450
|
+
timeoutMs: 10,
|
|
451
|
+
fetch: vi.fn(
|
|
452
|
+
async (_url, init) =>
|
|
453
|
+
new Promise<Response>((_resolve, reject) => {
|
|
454
|
+
init?.signal?.addEventListener("abort", () =>
|
|
455
|
+
reject(new Error("private abort details")),
|
|
456
|
+
);
|
|
457
|
+
}),
|
|
458
|
+
),
|
|
459
|
+
});
|
|
460
|
+
const rejection = expect(request).rejects.toThrow("Claude OAuth usage request failed");
|
|
461
|
+
await vi.advanceTimersByTimeAsync(10);
|
|
462
|
+
await rejection;
|
|
463
|
+
} finally {
|
|
464
|
+
vi.useRealTimers();
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["not-an-object"]
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"five_hour": {
|
|
3
|
+
"utilization": 10
|
|
4
|
+
},
|
|
5
|
+
"seven_day": {
|
|
6
|
+
"resets_at": "not-a-date"
|
|
7
|
+
},
|
|
8
|
+
"seven_day_sonnet": "invalid",
|
|
9
|
+
"limits": [null, { "kind": "daily", "group": "daily", "percent": 4 }],
|
|
10
|
+
"extra_usage": {
|
|
11
|
+
"is_enabled": true,
|
|
12
|
+
"monthly_limit": "unknown",
|
|
13
|
+
"used_credits": 100
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"five_hour": {
|
|
3
|
+
"utilization": 25,
|
|
4
|
+
"resets_at": "2026-09-25T20:00:00.000Z"
|
|
5
|
+
},
|
|
6
|
+
"seven_day": {
|
|
7
|
+
"utilization": 55.5,
|
|
8
|
+
"resets_at": "2026-09-30T12:00:00Z"
|
|
9
|
+
},
|
|
10
|
+
"seven_day_sonnet": {
|
|
11
|
+
"utilization": 61,
|
|
12
|
+
"resets_at": "2026-09-30T12:00:00Z"
|
|
13
|
+
},
|
|
14
|
+
"seven_day_opus": {
|
|
15
|
+
"utilization": 72,
|
|
16
|
+
"resets_at": "2026-09-30T12:00:00Z"
|
|
17
|
+
},
|
|
18
|
+
"limits": [
|
|
19
|
+
{
|
|
20
|
+
"kind": "weekly_scoped",
|
|
21
|
+
"group": "weekly",
|
|
22
|
+
"percent": 33,
|
|
23
|
+
"resets_at": "2026-09-29T08:00:00Z",
|
|
24
|
+
"is_active": false,
|
|
25
|
+
"scope": {
|
|
26
|
+
"model": {
|
|
27
|
+
"id": "claude-fable",
|
|
28
|
+
"display_name": "Fable"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"kind": "weekly_scoped",
|
|
34
|
+
"group": "weekly",
|
|
35
|
+
"percent": 99,
|
|
36
|
+
"scope": {
|
|
37
|
+
"model": {
|
|
38
|
+
"id": "all-models",
|
|
39
|
+
"display_name": "All Models"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"kind": "weekly_scoped",
|
|
45
|
+
"group": "weekly",
|
|
46
|
+
"percent": 88,
|
|
47
|
+
"scope": {
|
|
48
|
+
"model": {
|
|
49
|
+
"id": "claude-fable",
|
|
50
|
+
"display_name": "Duplicate Fable"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
null
|
|
55
|
+
],
|
|
56
|
+
"extra_usage": {
|
|
57
|
+
"is_enabled": true,
|
|
58
|
+
"monthly_limit": 5000,
|
|
59
|
+
"used_credits": 1250,
|
|
60
|
+
"utilization": 25,
|
|
61
|
+
"currency": "USD"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "list",
|
|
3
|
+
"data": [
|
|
4
|
+
{
|
|
5
|
+
"object": "item",
|
|
6
|
+
"id": "usage_day_1790380800",
|
|
7
|
+
"aggregation_timestamp": 1790380800,
|
|
8
|
+
"results": [
|
|
9
|
+
{
|
|
10
|
+
"object": "item.result",
|
|
11
|
+
"model": "gpt-4o-mini",
|
|
12
|
+
"input_tokens": 1000,
|
|
13
|
+
"input_cached_tokens": 400,
|
|
14
|
+
"output_tokens": 500,
|
|
15
|
+
"reasoning_tokens": 0
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"object": "item.result",
|
|
19
|
+
"model": "gpt-4.1",
|
|
20
|
+
"input_tokens": 200,
|
|
21
|
+
"output_tokens": 300
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"object": "item",
|
|
27
|
+
"id": "usage_day_1790294400",
|
|
28
|
+
"aggregation_timestamp": 1790294400,
|
|
29
|
+
"results": [
|
|
30
|
+
{
|
|
31
|
+
"object": "item.result",
|
|
32
|
+
"model": "gpt-4o-mini",
|
|
33
|
+
"input_tokens": 4000,
|
|
34
|
+
"output_tokens": 1000
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"object": "item",
|
|
40
|
+
"id": "usage_day_1789862400",
|
|
41
|
+
"aggregation_timestamp": 1789862400,
|
|
42
|
+
"results": [
|
|
43
|
+
{
|
|
44
|
+
"object": "item.result",
|
|
45
|
+
"model": "gpt-4o-mini",
|
|
46
|
+
"input_tokens": 800,
|
|
47
|
+
"output_tokens": 200
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"object": "item",
|
|
53
|
+
"id": "usage_day_1789689600",
|
|
54
|
+
"aggregation_timestamp": 1789689600,
|
|
55
|
+
"results": [
|
|
56
|
+
{
|
|
57
|
+
"object": "item.result",
|
|
58
|
+
"model": "gpt-4o-mini",
|
|
59
|
+
"input_tokens": 9999,
|
|
60
|
+
"output_tokens": 9999
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"has_more": false,
|
|
66
|
+
"next_page": null
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "list",
|
|
3
|
+
"data": [
|
|
4
|
+
{
|
|
5
|
+
"object": "item",
|
|
6
|
+
"id": "usage_day_1790294400",
|
|
7
|
+
"aggregation_timestamp": 1790294400,
|
|
8
|
+
"results": [
|
|
9
|
+
{
|
|
10
|
+
"object": "item.result",
|
|
11
|
+
"model": "gpt-5",
|
|
12
|
+
"input_tokens": 3000,
|
|
13
|
+
"output_tokens": 2000
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"has_more": false,
|
|
19
|
+
"next_page": null
|
|
20
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"user_id": "user-fixture-abc123",
|
|
3
|
+
"account_id": "account-fixture-uuid",
|
|
4
|
+
"email": "user@example.test",
|
|
5
|
+
"plan_type": "pro",
|
|
6
|
+
"rate_limit": {
|
|
7
|
+
"primary_window": {
|
|
8
|
+
"used_percent": 12.5,
|
|
9
|
+
"limit_window_seconds": 18000,
|
|
10
|
+
"reset_at": 1790517127
|
|
11
|
+
},
|
|
12
|
+
"secondary_window": {
|
|
13
|
+
"used_percent": 43.2,
|
|
14
|
+
"limit_window_seconds": 604800,
|
|
15
|
+
"reset_at": "2026-10-04T08:52:07Z"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"code_review_rate_limit": {
|
|
19
|
+
"primary_window": {
|
|
20
|
+
"used_percent": 0,
|
|
21
|
+
"limit_window_seconds": 3600,
|
|
22
|
+
"reset_at": 1790510000
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"additional_rate_limits": null,
|
|
26
|
+
"model_usage": [],
|
|
27
|
+
"credits": { "balance": 4.5 },
|
|
28
|
+
"spend_control": {},
|
|
29
|
+
"rate_limit_reached_type": "none",
|
|
30
|
+
"promo": null,
|
|
31
|
+
"rate_limit_reset_credits": { "availableCount": 0 }
|
|
32
|
+
}
|