@claudexor/schema 3.3.10 → 3.3.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"credential-profile-snapshot.d.ts","sourceRoot":"","sources":["../src/credential-profile-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAM3B;+EAC+E;AAC/E,eAAO,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEqC,CAAC;AACzF,MAAM,MAAM,sCAAsC,GAAG,CAAC,CAAC,KAAK,CAC1D,OAAO,sCAAsC,CAC9C,CAAC"}
package/dist/quota.d.ts CHANGED
@@ -199,6 +199,218 @@ export declare const QuotaAbsence: z.ZodObject<{
199
199
  observed_at: string;
200
200
  }>;
201
201
  export type QuotaAbsence = z.infer<typeof QuotaAbsence>;
202
+ export declare const QuotaAvailabilityState: z.ZodEnum<["available", "exhausted", "cooldown"]>;
203
+ export type QuotaAvailabilityState = z.infer<typeof QuotaAvailabilityState>;
204
+ export declare const QuotaModelScopedExhaustion: z.ZodObject<{
205
+ constraint_id: z.ZodString;
206
+ applies_to_models: z.ZodArray<z.ZodString, "many">;
207
+ resets_at: z.ZodNullable<z.ZodString>;
208
+ }, "strict", z.ZodTypeAny, {
209
+ constraint_id: string;
210
+ applies_to_models: string[];
211
+ resets_at: string | null;
212
+ }, {
213
+ constraint_id: string;
214
+ applies_to_models: string[];
215
+ resets_at: string | null;
216
+ }>;
217
+ export type QuotaModelScopedExhaustion = z.infer<typeof QuotaModelScopedExhaustion>;
218
+ export declare const QuotaAvailability: z.ZodObject<{
219
+ state: z.ZodEnum<["available", "exhausted", "cooldown"]>;
220
+ blocking_constraints: z.ZodArray<z.ZodString, "many">;
221
+ resets_at: z.ZodNullable<z.ZodString>;
222
+ model_scoped_exhaustions: z.ZodArray<z.ZodObject<{
223
+ constraint_id: z.ZodString;
224
+ applies_to_models: z.ZodArray<z.ZodString, "many">;
225
+ resets_at: z.ZodNullable<z.ZodString>;
226
+ }, "strict", z.ZodTypeAny, {
227
+ constraint_id: string;
228
+ applies_to_models: string[];
229
+ resets_at: string | null;
230
+ }, {
231
+ constraint_id: string;
232
+ applies_to_models: string[];
233
+ resets_at: string | null;
234
+ }>, "many">;
235
+ }, "strict", z.ZodTypeAny, {
236
+ state: "available" | "cooldown" | "exhausted";
237
+ blocking_constraints: string[];
238
+ resets_at: string | null;
239
+ model_scoped_exhaustions: {
240
+ constraint_id: string;
241
+ applies_to_models: string[];
242
+ resets_at: string | null;
243
+ }[];
244
+ }, {
245
+ state: "available" | "cooldown" | "exhausted";
246
+ blocking_constraints: string[];
247
+ resets_at: string | null;
248
+ model_scoped_exhaustions: {
249
+ constraint_id: string;
250
+ applies_to_models: string[];
251
+ resets_at: string | null;
252
+ }[];
253
+ }>;
254
+ export type QuotaAvailability = z.infer<typeof QuotaAvailability>;
255
+ export declare const ControlQuotaSnapshot: z.ZodObject<{
256
+ subject: z.ZodObject<{
257
+ harness: z.ZodString;
258
+ credential_route: z.ZodEnum<["vendor_native", "managed_api_key", "local"]>;
259
+ plan_label: z.ZodDefault<z.ZodNullable<z.ZodString>>;
260
+ /** The CREDENTIAL SUBJECT the windows belong to (release wave round-16
261
+ * #2): a Claudexor credential-profile id, or null for the harness's
262
+ * engine-default credential. Every producer (oauth-usage refresher,
263
+ * typed-event registry, adapter quota events) uses exactly this
264
+ * vocabulary; budget routing filters snapshots by exact subject so one
265
+ * account's exhaustion never cools another. */
266
+ subject_id: z.ZodDefault<z.ZodNullable<z.ZodString>>;
267
+ }, "strict", z.ZodTypeAny, {
268
+ harness: string;
269
+ credential_route: "local" | "managed_api_key" | "vendor_native";
270
+ plan_label: string | null;
271
+ subject_id: string | null;
272
+ }, {
273
+ harness: string;
274
+ credential_route: "local" | "managed_api_key" | "vendor_native";
275
+ plan_label?: string | null | undefined;
276
+ subject_id?: string | null | undefined;
277
+ }>;
278
+ constraints: z.ZodArray<z.ZodObject<{
279
+ id: z.ZodString;
280
+ label: z.ZodString;
281
+ /** omitted/null = this vendor window applies to every model. A non-null
282
+ * list is the producer's canonical model-id/alias scope, so a
283
+ * model-specific cap never cools a different model on the same subject. */
284
+ applies_to_models: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
285
+ used_ratio: z.ZodNullable<z.ZodNumber>;
286
+ window_seconds: z.ZodNullable<z.ZodNumber>;
287
+ resets_at: z.ZodNullable<z.ZodString>;
288
+ cooldown_until: z.ZodDefault<z.ZodNullable<z.ZodString>>;
289
+ }, "strict", z.ZodTypeAny, {
290
+ id: string;
291
+ label: string;
292
+ applies_to_models?: string[] | null | undefined;
293
+ used_ratio: number | null;
294
+ window_seconds: number | null;
295
+ resets_at: string | null;
296
+ cooldown_until: string | null;
297
+ }, {
298
+ id: string;
299
+ label: string;
300
+ applies_to_models?: string[] | null | undefined;
301
+ used_ratio: number | null;
302
+ window_seconds: number | null;
303
+ resets_at: string | null;
304
+ cooldown_until?: string | null | undefined;
305
+ }>, "many">;
306
+ source: z.ZodEnum<["codex_app_server", "codex_rollout", "claude_statusline", "claude_api_retry", "claude_oauth_usage"]>;
307
+ observed_at: z.ZodString;
308
+ freshness: z.ZodEnum<["fresh", "stale", "unknown"]>;
309
+ } & {
310
+ availability: z.ZodOptional<z.ZodObject<{
311
+ state: z.ZodEnum<["available", "exhausted", "cooldown"]>;
312
+ blocking_constraints: z.ZodArray<z.ZodString, "many">;
313
+ resets_at: z.ZodNullable<z.ZodString>;
314
+ model_scoped_exhaustions: z.ZodArray<z.ZodObject<{
315
+ constraint_id: z.ZodString;
316
+ applies_to_models: z.ZodArray<z.ZodString, "many">;
317
+ resets_at: z.ZodNullable<z.ZodString>;
318
+ }, "strict", z.ZodTypeAny, {
319
+ constraint_id: string;
320
+ applies_to_models: string[];
321
+ resets_at: string | null;
322
+ }, {
323
+ constraint_id: string;
324
+ applies_to_models: string[];
325
+ resets_at: string | null;
326
+ }>, "many">;
327
+ }, "strict", z.ZodTypeAny, {
328
+ state: "available" | "cooldown" | "exhausted";
329
+ blocking_constraints: string[];
330
+ resets_at: string | null;
331
+ model_scoped_exhaustions: {
332
+ constraint_id: string;
333
+ applies_to_models: string[];
334
+ resets_at: string | null;
335
+ }[];
336
+ }, {
337
+ state: "available" | "cooldown" | "exhausted";
338
+ blocking_constraints: string[];
339
+ resets_at: string | null;
340
+ model_scoped_exhaustions: {
341
+ constraint_id: string;
342
+ applies_to_models: string[];
343
+ resets_at: string | null;
344
+ }[];
345
+ }>>;
346
+ }, "strict", z.ZodTypeAny, {
347
+ subject: {
348
+ harness: string;
349
+ credential_route: "local" | "managed_api_key" | "vendor_native";
350
+ plan_label: string | null;
351
+ subject_id: string | null;
352
+ };
353
+ constraints: {
354
+ id: string;
355
+ label: string;
356
+ applies_to_models?: string[] | null | undefined;
357
+ used_ratio: number | null;
358
+ window_seconds: number | null;
359
+ resets_at: string | null;
360
+ cooldown_until: string | null;
361
+ }[];
362
+ source: "claude_api_retry" | "claude_oauth_usage" | "claude_statusline" | "codex_app_server" | "codex_rollout";
363
+ observed_at: string;
364
+ freshness: "fresh" | "stale" | "unknown";
365
+ availability?: {
366
+ state: "available" | "cooldown" | "exhausted";
367
+ blocking_constraints: string[];
368
+ resets_at: string | null;
369
+ model_scoped_exhaustions: {
370
+ constraint_id: string;
371
+ applies_to_models: string[];
372
+ resets_at: string | null;
373
+ }[];
374
+ } | undefined;
375
+ }, {
376
+ subject: {
377
+ harness: string;
378
+ credential_route: "local" | "managed_api_key" | "vendor_native";
379
+ plan_label?: string | null | undefined;
380
+ subject_id?: string | null | undefined;
381
+ };
382
+ constraints: {
383
+ id: string;
384
+ label: string;
385
+ applies_to_models?: string[] | null | undefined;
386
+ used_ratio: number | null;
387
+ window_seconds: number | null;
388
+ resets_at: string | null;
389
+ cooldown_until?: string | null | undefined;
390
+ }[];
391
+ source: "claude_api_retry" | "claude_oauth_usage" | "claude_statusline" | "codex_app_server" | "codex_rollout";
392
+ observed_at: string;
393
+ freshness: "fresh" | "stale" | "unknown";
394
+ availability?: {
395
+ state: "available" | "cooldown" | "exhausted";
396
+ blocking_constraints: string[];
397
+ resets_at: string | null;
398
+ model_scoped_exhaustions: {
399
+ constraint_id: string;
400
+ applies_to_models: string[];
401
+ resets_at: string | null;
402
+ }[];
403
+ } | undefined;
404
+ }>;
405
+ export type ControlQuotaSnapshot = z.infer<typeof ControlQuotaSnapshot>;
406
+ export declare const ControlQuotaRefreshRequest: z.ZodObject<{
407
+ model: z.ZodOptional<z.ZodString>;
408
+ }, "strict", z.ZodTypeAny, {
409
+ model?: string | undefined;
410
+ }, {
411
+ model?: string | undefined;
412
+ }>;
413
+ export type ControlQuotaRefreshRequest = z.infer<typeof ControlQuotaRefreshRequest>;
202
414
  export declare const ControlQuotaResponse: z.ZodObject<{
203
415
  snapshots: z.ZodArray<z.ZodObject<{
204
416
  subject: z.ZodObject<{
@@ -254,6 +466,43 @@ export declare const ControlQuotaResponse: z.ZodObject<{
254
466
  source: z.ZodEnum<["codex_app_server", "codex_rollout", "claude_statusline", "claude_api_retry", "claude_oauth_usage"]>;
255
467
  observed_at: z.ZodString;
256
468
  freshness: z.ZodEnum<["fresh", "stale", "unknown"]>;
469
+ } & {
470
+ availability: z.ZodOptional<z.ZodObject<{
471
+ state: z.ZodEnum<["available", "exhausted", "cooldown"]>;
472
+ blocking_constraints: z.ZodArray<z.ZodString, "many">;
473
+ resets_at: z.ZodNullable<z.ZodString>;
474
+ model_scoped_exhaustions: z.ZodArray<z.ZodObject<{
475
+ constraint_id: z.ZodString;
476
+ applies_to_models: z.ZodArray<z.ZodString, "many">;
477
+ resets_at: z.ZodNullable<z.ZodString>;
478
+ }, "strict", z.ZodTypeAny, {
479
+ constraint_id: string;
480
+ applies_to_models: string[];
481
+ resets_at: string | null;
482
+ }, {
483
+ constraint_id: string;
484
+ applies_to_models: string[];
485
+ resets_at: string | null;
486
+ }>, "many">;
487
+ }, "strict", z.ZodTypeAny, {
488
+ state: "available" | "cooldown" | "exhausted";
489
+ blocking_constraints: string[];
490
+ resets_at: string | null;
491
+ model_scoped_exhaustions: {
492
+ constraint_id: string;
493
+ applies_to_models: string[];
494
+ resets_at: string | null;
495
+ }[];
496
+ }, {
497
+ state: "available" | "cooldown" | "exhausted";
498
+ blocking_constraints: string[];
499
+ resets_at: string | null;
500
+ model_scoped_exhaustions: {
501
+ constraint_id: string;
502
+ applies_to_models: string[];
503
+ resets_at: string | null;
504
+ }[];
505
+ }>>;
257
506
  }, "strict", z.ZodTypeAny, {
258
507
  subject: {
259
508
  harness: string;
@@ -273,6 +522,16 @@ export declare const ControlQuotaResponse: z.ZodObject<{
273
522
  source: "claude_api_retry" | "claude_oauth_usage" | "claude_statusline" | "codex_app_server" | "codex_rollout";
274
523
  observed_at: string;
275
524
  freshness: "fresh" | "stale" | "unknown";
525
+ availability?: {
526
+ state: "available" | "cooldown" | "exhausted";
527
+ blocking_constraints: string[];
528
+ resets_at: string | null;
529
+ model_scoped_exhaustions: {
530
+ constraint_id: string;
531
+ applies_to_models: string[];
532
+ resets_at: string | null;
533
+ }[];
534
+ } | undefined;
276
535
  }, {
277
536
  subject: {
278
537
  harness: string;
@@ -292,6 +551,16 @@ export declare const ControlQuotaResponse: z.ZodObject<{
292
551
  source: "claude_api_retry" | "claude_oauth_usage" | "claude_statusline" | "codex_app_server" | "codex_rollout";
293
552
  observed_at: string;
294
553
  freshness: "fresh" | "stale" | "unknown";
554
+ availability?: {
555
+ state: "available" | "cooldown" | "exhausted";
556
+ blocking_constraints: string[];
557
+ resets_at: string | null;
558
+ model_scoped_exhaustions: {
559
+ constraint_id: string;
560
+ applies_to_models: string[];
561
+ resets_at: string | null;
562
+ }[];
563
+ } | undefined;
295
564
  }>, "many">;
296
565
  absences: z.ZodDefault<z.ZodArray<z.ZodObject<{
297
566
  subject: z.ZodObject<{
@@ -361,6 +630,16 @@ export declare const ControlQuotaResponse: z.ZodObject<{
361
630
  source: "claude_api_retry" | "claude_oauth_usage" | "claude_statusline" | "codex_app_server" | "codex_rollout";
362
631
  observed_at: string;
363
632
  freshness: "fresh" | "stale" | "unknown";
633
+ availability?: {
634
+ state: "available" | "cooldown" | "exhausted";
635
+ blocking_constraints: string[];
636
+ resets_at: string | null;
637
+ model_scoped_exhaustions: {
638
+ constraint_id: string;
639
+ applies_to_models: string[];
640
+ resets_at: string | null;
641
+ }[];
642
+ } | undefined;
364
643
  }[];
365
644
  absences: {
366
645
  subject: {
@@ -394,6 +673,16 @@ export declare const ControlQuotaResponse: z.ZodObject<{
394
673
  source: "claude_api_retry" | "claude_oauth_usage" | "claude_statusline" | "codex_app_server" | "codex_rollout";
395
674
  observed_at: string;
396
675
  freshness: "fresh" | "stale" | "unknown";
676
+ availability?: {
677
+ state: "available" | "cooldown" | "exhausted";
678
+ blocking_constraints: string[];
679
+ resets_at: string | null;
680
+ model_scoped_exhaustions: {
681
+ constraint_id: string;
682
+ applies_to_models: string[];
683
+ resets_at: string | null;
684
+ }[];
685
+ } | undefined;
397
686
  }[];
398
687
  absences?: {
399
688
  subject: {
@@ -409,4 +698,29 @@ export declare const ControlQuotaResponse: z.ZodObject<{
409
698
  refreshed_at: string | null;
410
699
  }>;
411
700
  export type ControlQuotaResponse = z.infer<typeof ControlQuotaResponse>;
701
+ /** Derive one snapshot's typed model-aware availability — a pure projection
702
+ * over the snapshot's own constraints, never an aggregate across subjects.
703
+ * Blocking semantics mirror the router's `BudgetLedger`: a window
704
+ * blocks while its cooldown_until is in the future, or while used_ratio >= 1
705
+ * with a still-future resets_at (a spent ratio whose reset elapsed or is
706
+ * unknown is stale data, not a live block). Without `model`, only windows that
707
+ * apply to EVERY model can block; model-scoped spent windows are disclosed in
708
+ * model_scoped_exhaustions and leave state available — including a spent
709
+ * scoped window whose reset is UNKNOWN (disclosed with resets_at null, never
710
+ * blocking); one whose reset ELAPSED is provably released and not disclosed.
711
+ * With `model`, scoped windows matching it block too.
712
+ * Full-coverage inference ("every model is
713
+ * covered by some spent scoped window") is deliberately not attempted: the
714
+ * model universe is unknowable here, so that case stays available + disclosed. */
715
+ export declare function quotaSnapshotAvailability(snapshot: Pick<QuotaSnapshot, "constraints">, opts?: {
716
+ now?: Date;
717
+ model?: string | null;
718
+ }): QuotaAvailability;
719
+ /** Decorate a quota response with per-snapshot availability projections —
720
+ * applied at the /v2/quota boundary so journals, projection signatures, and
721
+ * embedded raw snapshots stay byte-identical. */
722
+ export declare function withQuotaAvailability(response: ControlQuotaResponse, opts?: {
723
+ now?: Date;
724
+ model?: string | null;
725
+ }): ControlQuotaResponse;
412
726
  //# sourceMappingURL=quota.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"quota.d.ts","sourceRoot":"","sources":["../src/quota.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG3B,eAAO,MAAM,WAAW,iHAQgD,CAAC;AACzE,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,cAAc,0CAE+B,CAAC;AAC3D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,YAAY;;;;IAKrB;;;;;mDAK+C;;;;;;;;;;;;EAMhD,CAAC;AACJ,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,eAAO,MAAM,eAAe;;;IAIxB;;+EAE2E;;;;;;;;;;;;;;;;;;;;;;EAU5E,CAAC;AACJ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,eAAO,MAAM,aAAa;;;;;QAjCtB;;;;;uDAK+C;;;;;;;;;;;;;;;;QAa/C;;mFAE2E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBM,CAAC;AACtF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D,eAAO,MAAM,kBAAkB,8HAa+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C,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,GAC/C,oBAAoB,CAQtB"}
package/dist/quota.js CHANGED
@@ -75,9 +75,50 @@ export const QuotaAbsence = z
75
75
  })
76
76
  .strict()
77
77
  .describe("A registered subject's typed missing-snapshot — absence is stated, never inferred.");
78
+ export const QuotaAvailabilityState = z
79
+ .enum(["available", "exhausted", "cooldown"])
80
+ .describe("Spendability verdict for one snapshot: exhausted = a spent window blocks every applicable request; cooldown = an applicable window is only rate-limit-cooling; available = nothing applicable blocks.");
81
+ export const QuotaModelScopedExhaustion = z
82
+ .object({
83
+ constraint_id: Id,
84
+ applies_to_models: z.array(Id).min(1),
85
+ resets_at: z.string().datetime({ offset: true }).nullable(),
86
+ })
87
+ .strict()
88
+ .describe("A spent or cooling window that applies only to the named models. Without a requested model it never sets the whole subject exhausted; when the request names a model it covers, it blocks that request too (and is then also listed in blocking_constraints). resets_at is its earliest known release instant (null = unknown).");
89
+ export const QuotaAvailability = z
90
+ .object({
91
+ state: QuotaAvailabilityState,
92
+ blocking_constraints: z
93
+ .array(Id)
94
+ .describe("Ids of the constraints that produced a non-available state."),
95
+ resets_at: z
96
+ .string()
97
+ .datetime({ offset: true })
98
+ .nullable()
99
+ .describe("Earliest known instant at which any blocking constraint may release; null when nothing blocks or no reset is known."),
100
+ model_scoped_exhaustions: z
101
+ .array(QuotaModelScopedExhaustion)
102
+ .describe("Every spent/cooling model-scoped window, listed regardless of state so consumers see partial exhaustion without re-deriving constraint scope."),
103
+ })
104
+ .strict()
105
+ .describe("Derived model-aware availability projection for one quota snapshot. Without a requested model, only windows applying to EVERY model can set exhausted/cooldown — a model-scoped spent window keeps state available and is disclosed in model_scoped_exhaustions.");
106
+ export const ControlQuotaSnapshot = QuotaSnapshot.extend({
107
+ availability: QuotaAvailability.optional().describe("Typed availability projection derived by the /v2/quota route; absent on surfaces that embed raw snapshots."),
108
+ }).describe("One vendor-owned quota snapshot plus its derived availability projection.");
109
+ export const ControlQuotaRefreshRequest = z
110
+ .object({
111
+ model: z
112
+ .string()
113
+ .min(1)
114
+ .optional()
115
+ .describe("Optional model id/alias the caller intends to spend against. When present, each snapshot's availability.state is computed against this model (case-insensitive alias containment in either direction), so windows scoped to OTHER models never report the subject exhausted."),
116
+ })
117
+ .strict()
118
+ .describe("Optional POST /v2/quota body; an empty or absent body keeps the model-agnostic projection.");
78
119
  export const ControlQuotaResponse = z
79
120
  .object({
80
- snapshots: z.array(QuotaSnapshot),
121
+ snapshots: z.array(ControlQuotaSnapshot),
81
122
  absences: z
82
123
  .array(QuotaAbsence)
83
124
  .default([])
@@ -86,4 +127,113 @@ export const ControlQuotaResponse = z
86
127
  })
87
128
  .strict()
88
129
  .describe("Current quota snapshots without a fabricated aggregate.");
130
+ /** Millisecond instant of a still-future ISO timestamp, else null. */
131
+ function futureMs(iso, now) {
132
+ if (!iso)
133
+ return null;
134
+ const at = Date.parse(iso);
135
+ return Number.isFinite(at) && at > now ? at : null;
136
+ }
137
+ /** API-parameter model matching, deliberately looser than the router's exact
138
+ * `quotaConstraintAppliesToModel` (@claudexor/budget): consumers pass whatever
139
+ * model string they route with ("claude-fable-5", "fable", a bracketed
140
+ * variant), while producers publish vendor alias lists — so match by
141
+ * case-insensitive alias containment in either direction. A null/empty scope
142
+ * list is a vendor-wide window and matches every model. */
143
+ function modelScopeMatches(scope, model) {
144
+ if (scope == null || scope.length === 0)
145
+ return true;
146
+ const target = model.trim().toLowerCase();
147
+ return scope.some((alias) => {
148
+ const candidate = alias.trim().toLowerCase();
149
+ return (candidate !== "" &&
150
+ target !== "" &&
151
+ (candidate.includes(target) || target.includes(candidate)));
152
+ });
153
+ }
154
+ /** Derive one snapshot's typed model-aware availability — a pure projection
155
+ * over the snapshot's own constraints, never an aggregate across subjects.
156
+ * Blocking semantics mirror the router's `BudgetLedger`: a window
157
+ * blocks while its cooldown_until is in the future, or while used_ratio >= 1
158
+ * with a still-future resets_at (a spent ratio whose reset elapsed or is
159
+ * unknown is stale data, not a live block). Without `model`, only windows that
160
+ * apply to EVERY model can block; model-scoped spent windows are disclosed in
161
+ * model_scoped_exhaustions and leave state available — including a spent
162
+ * scoped window whose reset is UNKNOWN (disclosed with resets_at null, never
163
+ * blocking); one whose reset ELAPSED is provably released and not disclosed.
164
+ * With `model`, scoped windows matching it block too.
165
+ * Full-coverage inference ("every model is
166
+ * covered by some spent scoped window") is deliberately not attempted: the
167
+ * model universe is unknowable here, so that case stays available + disclosed. */
168
+ export function quotaSnapshotAvailability(snapshot, opts = {}) {
169
+ const now = (opts.now ?? new Date()).getTime();
170
+ const model = opts.model ?? null;
171
+ const blocking = [];
172
+ const scopedExhaustions = [];
173
+ let sawExhausted = false;
174
+ let earliestRelease = null;
175
+ for (const constraint of snapshot.constraints) {
176
+ const resetAt = futureMs(constraint.resets_at, now);
177
+ const cooldownAt = futureMs(constraint.cooldown_until, now);
178
+ const exhausted = constraint.used_ratio !== null && constraint.used_ratio >= 1 && resetAt !== null;
179
+ const cooling = cooldownAt !== null;
180
+ // A spent ratio with an UNKNOWN reset never blocks (BudgetLedger mirror:
181
+ // stale data, not a live block), but a scoped one is still DISCLOSED below
182
+ // with resets_at null; an elapsed reset is provably released and stays
183
+ // undisclosed.
184
+ const spentUnknownReset = constraint.used_ratio !== null && constraint.used_ratio >= 1 && constraint.resets_at === null;
185
+ if (!exhausted && !cooling && !spentUnknownReset)
186
+ continue;
187
+ // A constraint stays blocked until EVERY active condition lifts, so its
188
+ // own release is the LATER of the two; the snapshot-level resets_at below
189
+ // is the EARLIEST such release across blocking constraints. A
190
+ // disclosure-only window (spent, unknown reset) has no release instant.
191
+ const release = !exhausted && !cooling
192
+ ? null
193
+ : exhausted && cooling
194
+ ? resetAt >= cooldownAt
195
+ ? { iso: constraint.resets_at, at: resetAt }
196
+ : { iso: constraint.cooldown_until, at: cooldownAt }
197
+ : exhausted
198
+ ? { iso: constraint.resets_at, at: resetAt }
199
+ : { iso: constraint.cooldown_until, at: cooldownAt };
200
+ const scope = constraint.applies_to_models ?? null;
201
+ const scoped = scope !== null && scope.length > 0;
202
+ if (scoped) {
203
+ scopedExhaustions.push({
204
+ constraint_id: constraint.id,
205
+ applies_to_models: [...scope],
206
+ resets_at: release?.iso ?? null,
207
+ });
208
+ }
209
+ if (release === null)
210
+ continue;
211
+ if (scoped && (model === null || !modelScopeMatches(scope, model)))
212
+ continue;
213
+ blocking.push(constraint.id);
214
+ if (exhausted)
215
+ sawExhausted = true;
216
+ if (earliestRelease === null || release.at < earliestRelease.at) {
217
+ earliestRelease = release;
218
+ }
219
+ }
220
+ return QuotaAvailability.parse({
221
+ state: blocking.length === 0 ? "available" : sawExhausted ? "exhausted" : "cooldown",
222
+ blocking_constraints: blocking,
223
+ resets_at: earliestRelease?.iso ?? null,
224
+ model_scoped_exhaustions: scopedExhaustions,
225
+ });
226
+ }
227
+ /** Decorate a quota response with per-snapshot availability projections —
228
+ * applied at the /v2/quota boundary so journals, projection signatures, and
229
+ * embedded raw snapshots stay byte-identical. */
230
+ export function withQuotaAvailability(response, opts = {}) {
231
+ return {
232
+ ...response,
233
+ snapshots: response.snapshots.map((snapshot) => ({
234
+ ...snapshot,
235
+ availability: quotaSnapshotAvailability(snapshot, opts),
236
+ })),
237
+ };
238
+ }
89
239
  //# sourceMappingURL=quota.js.map
package/dist/quota.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"quota.js","sourceRoot":"","sources":["../src/quota.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC;KACzB,IAAI,CAAC;IACJ,kBAAkB;IAClB,eAAe;IACf,mBAAmB;IACnB,kBAAkB;IAClB,oBAAoB;CACrB,CAAC;KACD,QAAQ,CAAC,2DAA2D,CAAC,CAAC;AAGzE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC;KAC5B,IAAI,CAAC,CAA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