claude-use 5.1.1 → 5.3.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.
@@ -0,0 +1,259 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The usage store's one schema definition: every record the front door appends to the usage log, the per-identity snapshot other tools read, and the account metadata both carry. Each is a strict object, so a field not named here can never be written (the store validates every record and snapshot before it touches disk) and the published JSON Schemas (`schema/UsageRecord.schema.json`, `schema/UsageSnapshot.schema.json`) describe exactly what a reader can find.
4
+ *
5
+ * Metadata only, by construction: nothing here can hold a prompt, a response, tool content, or a credential. Rate-limit headers are kept by name from an allow-list of quota headers (`isRateLimitHeader`), never wholesale.
6
+ */
7
+ /** The version of the record and snapshot shapes below. A reader checks it before trusting a document; a change that is not purely additive bumps it. */
8
+ export declare const USAGE_SCHEMA_VERSION = 1;
9
+ /** Token counts from a response body's `usage` object, renamed to this project's casing. Each field is present only when the response reported it. */
10
+ export declare const TokenUsageSchema: z.ZodObject<{
11
+ inputTokens: z.ZodOptional<z.ZodNumber>;
12
+ outputTokens: z.ZodOptional<z.ZodNumber>;
13
+ cacheCreationInputTokens: z.ZodOptional<z.ZodNumber>;
14
+ cacheReadInputTokens: z.ZodOptional<z.ZodNumber>;
15
+ }, z.core.$strict>;
16
+ export type TokenUsage = z.infer<typeof TokenUsageSchema>;
17
+ /** The two kinds of refusal a consumer acts on differently: a short rate limit is worth retrying on the same credential once its wait has passed, an exhausted quota means moving to the next credential until the reset. */
18
+ declare const LIMIT_KINDS: readonly ["rate-limited", "quota-exhausted"];
19
+ export type LimitKind = (typeof LIMIT_KINDS)[number];
20
+ /** A 429 (or 402) classified, with the wait or reset the upstream announced and the signals the classification rests on. */
21
+ export declare const LimitClassificationSchema: z.ZodObject<{
22
+ kind: z.ZodEnum<{
23
+ "rate-limited": "rate-limited";
24
+ "quota-exhausted": "quota-exhausted";
25
+ }>;
26
+ retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
27
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
28
+ window: z.ZodOptional<z.ZodString>;
29
+ evidence: z.ZodArray<z.ZodString>;
30
+ }, z.core.$strict>;
31
+ export type LimitClassification = z.infer<typeof LimitClassificationSchema>;
32
+ /** One routed request, appended to the usage log when its response has finished. */
33
+ export declare const UsageRecordSchema: z.ZodObject<{
34
+ schemaVersion: z.ZodLiteral<1>;
35
+ at: z.ZodISODateTime;
36
+ identity: z.ZodOptional<z.ZodString>;
37
+ provider: z.ZodString;
38
+ sessionId: z.ZodOptional<z.ZodString>;
39
+ project: z.ZodOptional<z.ZodString>;
40
+ route: z.ZodString;
41
+ method: z.ZodString;
42
+ endpoint: z.ZodString;
43
+ model: z.ZodOptional<z.ZodString>;
44
+ status: z.ZodNumber;
45
+ latencyMs: z.ZodNumber;
46
+ durationMs: z.ZodNumber;
47
+ outcome: z.ZodEnum<{
48
+ completed: "completed";
49
+ aborted: "aborted";
50
+ }>;
51
+ usage: z.ZodOptional<z.ZodObject<{
52
+ inputTokens: z.ZodOptional<z.ZodNumber>;
53
+ outputTokens: z.ZodOptional<z.ZodNumber>;
54
+ cacheCreationInputTokens: z.ZodOptional<z.ZodNumber>;
55
+ cacheReadInputTokens: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strict>>;
57
+ rateLimitHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
58
+ limit: z.ZodOptional<z.ZodObject<{
59
+ kind: z.ZodEnum<{
60
+ "rate-limited": "rate-limited";
61
+ "quota-exhausted": "quota-exhausted";
62
+ }>;
63
+ retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
64
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
65
+ window: z.ZodOptional<z.ZodString>;
66
+ evidence: z.ZodArray<z.ZodString>;
67
+ }, z.core.$strict>>;
68
+ requestId: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strict>;
70
+ export type UsageRecord = z.infer<typeof UsageRecordSchema>;
71
+ /** One quota window from Anthropic's unified rate-limit headers. */
72
+ declare const QuotaWindowSchema: z.ZodObject<{
73
+ utilization: z.ZodOptional<z.ZodNumber>;
74
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
75
+ status: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strict>;
77
+ export type QuotaWindow = z.infer<typeof QuotaWindowSchema>;
78
+ /** Anthropic's unified subscription rate-limit state, parsed from the `anthropic-ratelimit-unified-*` headers (which the in-process Codex route also derives from the Codex backend's own quota headers). */
79
+ export declare const UnifiedRateLimitSchema: z.ZodObject<{
80
+ status: z.ZodOptional<z.ZodString>;
81
+ fiveHour: z.ZodOptional<z.ZodObject<{
82
+ utilization: z.ZodOptional<z.ZodNumber>;
83
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
84
+ status: z.ZodOptional<z.ZodString>;
85
+ }, z.core.$strict>>;
86
+ sevenDay: z.ZodOptional<z.ZodObject<{
87
+ utilization: z.ZodOptional<z.ZodNumber>;
88
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
89
+ status: z.ZodOptional<z.ZodString>;
90
+ }, z.core.$strict>>;
91
+ representativeClaim: z.ZodOptional<z.ZodString>;
92
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
93
+ overageStatus: z.ZodOptional<z.ZodString>;
94
+ }, z.core.$strict>;
95
+ export type UnifiedRateLimit = z.infer<typeof UnifiedRateLimitSchema>;
96
+ /** The latest rate-limit state an upstream reported on any response. */
97
+ declare const RateLimitStateSchema: z.ZodObject<{
98
+ observedAt: z.ZodISODateTime;
99
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
100
+ unified: z.ZodOptional<z.ZodObject<{
101
+ status: z.ZodOptional<z.ZodString>;
102
+ fiveHour: z.ZodOptional<z.ZodObject<{
103
+ utilization: z.ZodOptional<z.ZodNumber>;
104
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
105
+ status: z.ZodOptional<z.ZodString>;
106
+ }, z.core.$strict>>;
107
+ sevenDay: z.ZodOptional<z.ZodObject<{
108
+ utilization: z.ZodOptional<z.ZodNumber>;
109
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
110
+ status: z.ZodOptional<z.ZodString>;
111
+ }, z.core.$strict>>;
112
+ representativeClaim: z.ZodOptional<z.ZodString>;
113
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
114
+ overageStatus: z.ZodOptional<z.ZodString>;
115
+ }, z.core.$strict>>;
116
+ }, z.core.$strict>;
117
+ export type RateLimitState = z.infer<typeof RateLimitStateSchema>;
118
+ /** A classified refusal, with when it was seen and its status. */
119
+ declare const LimitEventSchema: z.ZodObject<{
120
+ kind: z.ZodEnum<{
121
+ "rate-limited": "rate-limited";
122
+ "quota-exhausted": "quota-exhausted";
123
+ }>;
124
+ retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
125
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
126
+ window: z.ZodOptional<z.ZodString>;
127
+ evidence: z.ZodArray<z.ZodString>;
128
+ observedAt: z.ZodISODateTime;
129
+ status: z.ZodNumber;
130
+ }, z.core.$strict>;
131
+ export type LimitEvent = z.infer<typeof LimitEventSchema>;
132
+ /** One provider's latest state under one identity. */
133
+ declare const ProviderUsageStateSchema: z.ZodObject<{
134
+ lastRequestAt: z.ZodISODateTime;
135
+ lastStatus: z.ZodNumber;
136
+ lastModel: z.ZodOptional<z.ZodString>;
137
+ rateLimit: z.ZodOptional<z.ZodObject<{
138
+ observedAt: z.ZodISODateTime;
139
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
140
+ unified: z.ZodOptional<z.ZodObject<{
141
+ status: z.ZodOptional<z.ZodString>;
142
+ fiveHour: z.ZodOptional<z.ZodObject<{
143
+ utilization: z.ZodOptional<z.ZodNumber>;
144
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
145
+ status: z.ZodOptional<z.ZodString>;
146
+ }, z.core.$strict>>;
147
+ sevenDay: z.ZodOptional<z.ZodObject<{
148
+ utilization: z.ZodOptional<z.ZodNumber>;
149
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
150
+ status: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strict>>;
152
+ representativeClaim: z.ZodOptional<z.ZodString>;
153
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
154
+ overageStatus: z.ZodOptional<z.ZodString>;
155
+ }, z.core.$strict>>;
156
+ }, z.core.$strict>>;
157
+ lastLimit: z.ZodOptional<z.ZodObject<{
158
+ kind: z.ZodEnum<{
159
+ "rate-limited": "rate-limited";
160
+ "quota-exhausted": "quota-exhausted";
161
+ }>;
162
+ retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
163
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
164
+ window: z.ZodOptional<z.ZodString>;
165
+ evidence: z.ZodArray<z.ZodString>;
166
+ observedAt: z.ZodISODateTime;
167
+ status: z.ZodNumber;
168
+ }, z.core.$strict>>;
169
+ }, z.core.$strict>;
170
+ export type ProviderUsageState = z.infer<typeof ProviderUsageStateSchema>;
171
+ /**
172
+ * The account fields copied from an identity's stored Claude login (`oauthAccount` in the identity's `.claude.json`): who the account is and which plan and tier it is on. Never the token, which Claude Code keeps elsewhere. Each field is present only when the stored login has it; a setup-token identity has no profile scope and so none of them (see issue #44).
173
+ */
174
+ export declare const AccountMetadataSchema: z.ZodObject<{
175
+ accountUuid: z.ZodOptional<z.ZodString>;
176
+ emailAddress: z.ZodOptional<z.ZodString>;
177
+ displayName: z.ZodOptional<z.ZodString>;
178
+ organizationUuid: z.ZodOptional<z.ZodString>;
179
+ organizationName: z.ZodOptional<z.ZodString>;
180
+ organizationType: z.ZodOptional<z.ZodString>;
181
+ organizationRole: z.ZodOptional<z.ZodString>;
182
+ workspaceRole: z.ZodOptional<z.ZodString>;
183
+ billingType: z.ZodOptional<z.ZodString>;
184
+ seatTier: z.ZodOptional<z.ZodString>;
185
+ organizationRateLimitTier: z.ZodOptional<z.ZodString>;
186
+ userRateLimitTier: z.ZodOptional<z.ZodString>;
187
+ hasExtraUsageEnabled: z.ZodOptional<z.ZodBoolean>;
188
+ subscriptionCreatedAt: z.ZodOptional<z.ZodString>;
189
+ accountCreatedAt: z.ZodOptional<z.ZodString>;
190
+ }, z.core.$strict>;
191
+ export type AccountMetadata = z.infer<typeof AccountMetadataSchema>;
192
+ /**
193
+ * The latest state for one identity, rewritten atomically after each recorded response: the snapshot file other tools read (`~/.claude-use/usage/snapshots/<identity>.json`) without shelling out to `claude-use`.
194
+ */
195
+ export declare const UsageSnapshotSchema: z.ZodObject<{
196
+ schemaVersion: z.ZodLiteral<1>;
197
+ identity: z.ZodString;
198
+ updatedAt: z.ZodISODateTime;
199
+ account: z.ZodOptional<z.ZodObject<{
200
+ accountUuid: z.ZodOptional<z.ZodString>;
201
+ emailAddress: z.ZodOptional<z.ZodString>;
202
+ displayName: z.ZodOptional<z.ZodString>;
203
+ organizationUuid: z.ZodOptional<z.ZodString>;
204
+ organizationName: z.ZodOptional<z.ZodString>;
205
+ organizationType: z.ZodOptional<z.ZodString>;
206
+ organizationRole: z.ZodOptional<z.ZodString>;
207
+ workspaceRole: z.ZodOptional<z.ZodString>;
208
+ billingType: z.ZodOptional<z.ZodString>;
209
+ seatTier: z.ZodOptional<z.ZodString>;
210
+ organizationRateLimitTier: z.ZodOptional<z.ZodString>;
211
+ userRateLimitTier: z.ZodOptional<z.ZodString>;
212
+ hasExtraUsageEnabled: z.ZodOptional<z.ZodBoolean>;
213
+ subscriptionCreatedAt: z.ZodOptional<z.ZodString>;
214
+ accountCreatedAt: z.ZodOptional<z.ZodString>;
215
+ }, z.core.$strict>>;
216
+ providers: z.ZodRecord<z.ZodString, z.ZodObject<{
217
+ lastRequestAt: z.ZodISODateTime;
218
+ lastStatus: z.ZodNumber;
219
+ lastModel: z.ZodOptional<z.ZodString>;
220
+ rateLimit: z.ZodOptional<z.ZodObject<{
221
+ observedAt: z.ZodISODateTime;
222
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
223
+ unified: z.ZodOptional<z.ZodObject<{
224
+ status: z.ZodOptional<z.ZodString>;
225
+ fiveHour: z.ZodOptional<z.ZodObject<{
226
+ utilization: z.ZodOptional<z.ZodNumber>;
227
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
228
+ status: z.ZodOptional<z.ZodString>;
229
+ }, z.core.$strict>>;
230
+ sevenDay: z.ZodOptional<z.ZodObject<{
231
+ utilization: z.ZodOptional<z.ZodNumber>;
232
+ resetsAt: z.ZodOptional<z.ZodISODateTime>;
233
+ status: z.ZodOptional<z.ZodString>;
234
+ }, z.core.$strict>>;
235
+ representativeClaim: z.ZodOptional<z.ZodString>;
236
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
237
+ overageStatus: z.ZodOptional<z.ZodString>;
238
+ }, z.core.$strict>>;
239
+ }, z.core.$strict>>;
240
+ lastLimit: z.ZodOptional<z.ZodObject<{
241
+ kind: z.ZodEnum<{
242
+ "rate-limited": "rate-limited";
243
+ "quota-exhausted": "quota-exhausted";
244
+ }>;
245
+ retryAfterSeconds: z.ZodOptional<z.ZodNumber>;
246
+ resetAt: z.ZodOptional<z.ZodISODateTime>;
247
+ window: z.ZodOptional<z.ZodString>;
248
+ evidence: z.ZodArray<z.ZodString>;
249
+ observedAt: z.ZodISODateTime;
250
+ status: z.ZodNumber;
251
+ }, z.core.$strict>>;
252
+ }, z.core.$strict>>;
253
+ }, z.core.$strict>;
254
+ export type UsageSnapshot = z.infer<typeof UsageSnapshotSchema>;
255
+ /**
256
+ * Whether a response header is one the store keeps: the quota and rate-limit families the upstreams claude-use routes to send (Anthropic's `anthropic-ratelimit-*`, the IETF draft's `ratelimit*`, the common `x-ratelimit-*`, the Codex backend's `x-codex-*` quota headers, which the Codex route forwards) and `retry-after`. Every one of these carries a number, a time or a status word; none carries a credential or content.
257
+ */
258
+ export declare function isRateLimitHeader(name: string): boolean;
259
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-use",
3
- "version": "5.1.1",
3
+ "version": "5.3.0",
4
4
  "description": "A profile manager and launcher for Claude Code that lets one person run multiple logins from one machine while controlling what gets shared between them.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Joseph Mearman <joseph@mearman.co.uk>",