@oxyhq/contracts 0.28.0 → 0.30.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.
Files changed (43) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/identity.js +33 -1
  3. package/dist/cjs/index.js +20 -7
  4. package/dist/cjs/inference/aliaModelRelease.js +250 -0
  5. package/dist/cjs/inference/catalogue.js +1 -4
  6. package/dist/cjs/inference/errors.js +108 -9
  7. package/dist/cjs/inference/identifiers.js +23 -3
  8. package/dist/cjs/inference/request.js +188 -5
  9. package/dist/cjs/inference/routingPolicy.js +81 -2
  10. package/dist/cjs/inference/streamEvents.js +38 -1
  11. package/dist/cjs/inference/usage.js +32 -1
  12. package/dist/cjs/inference/version.js +24 -4
  13. package/dist/esm/.tsbuildinfo +1 -1
  14. package/dist/esm/identity.js +32 -0
  15. package/dist/esm/index.js +8 -3
  16. package/dist/esm/inference/aliaModelRelease.js +247 -0
  17. package/dist/esm/inference/catalogue.js +2 -5
  18. package/dist/esm/inference/errors.js +108 -9
  19. package/dist/esm/inference/identifiers.js +22 -2
  20. package/dist/esm/inference/request.js +189 -6
  21. package/dist/esm/inference/routingPolicy.js +81 -2
  22. package/dist/esm/inference/streamEvents.js +38 -1
  23. package/dist/esm/inference/usage.js +32 -1
  24. package/dist/esm/inference/version.js +24 -4
  25. package/dist/types/.tsbuildinfo +1 -1
  26. package/dist/types/identity.d.ts +59 -1
  27. package/dist/types/index.d.ts +7 -5
  28. package/dist/types/inference/accountBilling.d.ts +26 -26
  29. package/dist/types/inference/aliaModelRelease.d.ts +597 -0
  30. package/dist/types/inference/catalogue.d.ts +6 -6
  31. package/dist/types/inference/entitlement.d.ts +4 -4
  32. package/dist/types/inference/errors.d.ts +46 -10
  33. package/dist/types/inference/identifiers.d.ts +20 -2
  34. package/dist/types/inference/money.d.ts +4 -4
  35. package/dist/types/inference/priceVersion.d.ts +14 -14
  36. package/dist/types/inference/providerConnection.d.ts +4 -4
  37. package/dist/types/inference/request.d.ts +291 -5
  38. package/dist/types/inference/routingPolicy.d.ts +109 -13
  39. package/dist/types/inference/streamEvents.d.ts +84 -48
  40. package/dist/types/inference/usage.d.ts +103 -79
  41. package/dist/types/inference/version.d.ts +24 -4
  42. package/dist/types/keyRecovery.d.ts +4 -4
  43. package/package.json +1 -1
@@ -22,7 +22,14 @@
22
22
  * REJECTED, rather than being quietly resolved by whichever field the executor
23
23
  * happens to read first. That rejection is `routingPolicySchema`'s refinement.
24
24
  *
25
- * Decided in: docs/adr/0008-catalogue-concept-separation.md, issue #972 workstream 6.
25
+ * **The policy itself never crosses to the data plane.** What crosses is
26
+ * {@link authorizedRouteSchema} — the candidate routes that SURVIVED these
27
+ * controls, in preference order — plus {@link routingPolicyReferenceSchema} as
28
+ * provenance for the receipt. The data plane holds no control value and needs
29
+ * none: it fails over by taking the next entry. See ADR 0017.
30
+ *
31
+ * Decided in: docs/adr/0008-catalogue-concept-separation.md,
32
+ * docs/adr/0017-authorized-routes-in-the-envelope.md, issue #972 workstream 6.
26
33
  */
27
34
  import { z } from 'zod';
28
35
  /**
@@ -170,13 +177,13 @@ export declare const routingPolicySchema: z.ZodEffects<z.ZodObject<{
170
177
  per: z.ZodNumber;
171
178
  currency: z.ZodString;
172
179
  }, "strict", z.ZodTypeAny, {
173
- amount: string & z.BRAND<"ExactDecimal">;
174
180
  currency: string;
181
+ amount: string & z.BRAND<"ExactDecimal">;
175
182
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
176
183
  per: number;
177
184
  }, {
178
- amount: string;
179
185
  currency: string;
186
+ amount: string;
180
187
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
181
188
  per: number;
182
189
  }>, "many">>;
@@ -184,11 +191,11 @@ export declare const routingPolicySchema: z.ZodEffects<z.ZodObject<{
184
191
  amount: z.ZodBranded<z.ZodString, "ExactDecimal">;
185
192
  currency: z.ZodString;
186
193
  }, "strict", z.ZodTypeAny, {
187
- amount: string & z.BRAND<"ExactDecimal">;
188
194
  currency: string;
195
+ amount: string & z.BRAND<"ExactDecimal">;
189
196
  }, {
190
- amount: string;
191
197
  currency: string;
198
+ amount: string;
192
199
  }>>;
193
200
  /** What to optimise for among the routes that qualify. */
194
201
  optimiseFor: z.ZodEnum<["price", "latency", "throughput", "balanced"]>;
@@ -237,8 +244,8 @@ export declare const routingPolicySchema: z.ZodEffects<z.ZodObject<{
237
244
  requireZeroDataRetention: boolean;
238
245
  prohibitTrainingOnCustomerData: boolean;
239
246
  maxPricePerUnit: {
240
- amount: string & z.BRAND<"ExactDecimal">;
241
247
  currency: string;
248
+ amount: string & z.BRAND<"ExactDecimal">;
242
249
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
243
250
  per: number;
244
251
  }[];
@@ -259,8 +266,8 @@ export declare const routingPolicySchema: z.ZodEffects<z.ZodObject<{
259
266
  routingProfile: string;
260
267
  } | undefined;
261
268
  maxPricePerRequest?: {
262
- amount: string & z.BRAND<"ExactDecimal">;
263
269
  currency: string;
270
+ amount: string & z.BRAND<"ExactDecimal">;
264
271
  } | undefined;
265
272
  }, {
266
273
  updatedAt: string;
@@ -299,14 +306,14 @@ export declare const routingPolicySchema: z.ZodEffects<z.ZodObject<{
299
306
  allowedRegions?: string[] | undefined;
300
307
  deniedRegions?: string[] | undefined;
301
308
  maxPricePerUnit?: {
302
- amount: string;
303
309
  currency: string;
310
+ amount: string;
304
311
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
305
312
  per: number;
306
313
  }[] | undefined;
307
314
  maxPricePerRequest?: {
308
- amount: string;
309
315
  currency: string;
316
+ amount: string;
310
317
  } | undefined;
311
318
  allowedLicenseIds?: string[] | undefined;
312
319
  }>, {
@@ -331,8 +338,8 @@ export declare const routingPolicySchema: z.ZodEffects<z.ZodObject<{
331
338
  requireZeroDataRetention: boolean;
332
339
  prohibitTrainingOnCustomerData: boolean;
333
340
  maxPricePerUnit: {
334
- amount: string & z.BRAND<"ExactDecimal">;
335
341
  currency: string;
342
+ amount: string & z.BRAND<"ExactDecimal">;
336
343
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
337
344
  per: number;
338
345
  }[];
@@ -353,8 +360,8 @@ export declare const routingPolicySchema: z.ZodEffects<z.ZodObject<{
353
360
  routingProfile: string;
354
361
  } | undefined;
355
362
  maxPricePerRequest?: {
356
- amount: string & z.BRAND<"ExactDecimal">;
357
363
  currency: string;
364
+ amount: string & z.BRAND<"ExactDecimal">;
358
365
  } | undefined;
359
366
  }, {
360
367
  updatedAt: string;
@@ -393,14 +400,14 @@ export declare const routingPolicySchema: z.ZodEffects<z.ZodObject<{
393
400
  allowedRegions?: string[] | undefined;
394
401
  deniedRegions?: string[] | undefined;
395
402
  maxPricePerUnit?: {
396
- amount: string;
397
403
  currency: string;
404
+ amount: string;
398
405
  unit: "input_tokens" | "cached_input_tokens" | "output_tokens" | "reasoning_tokens" | "requests" | "images" | "audio_input_milliseconds" | "audio_output_milliseconds" | "video_milliseconds" | "characters" | "embeddings";
399
406
  per: number;
400
407
  }[] | undefined;
401
408
  maxPricePerRequest?: {
402
- amount: string;
403
409
  currency: string;
410
+ amount: string;
404
411
  } | undefined;
405
412
  allowedLicenseIds?: string[] | undefined;
406
413
  }>;
@@ -419,8 +426,97 @@ export declare const routingPolicyReferenceSchema: z.ZodObject<{
419
426
  routingPolicyId: string;
420
427
  policyVersion: number;
421
428
  }>;
429
+ /**
430
+ * One route the control plane has already authorized for one request.
431
+ *
432
+ * **Authorization is an ENTRY, never a boolean.** The same stance
433
+ * `inference_routing_policy_fallbacks` takes in storage: being allowed to serve
434
+ * a route IS appearing here, and every entry names its destination. A flag
435
+ * saying "substitution allowed" without naming the destination is exactly the
436
+ * silent substitution the platform forbids, and it invents a "flag set, list
437
+ * empty" state somebody then has to decide what to do with.
438
+ *
439
+ * Discriminated on `substitution`, relative to the FIRST entry — the primary
440
+ * route Oxy resolved:
441
+ *
442
+ * - `same_model` serves the same model line as the primary. This is
443
+ * availability failover between deployments of one model.
444
+ * - `cross_model` serves a DIFFERENT model line, and is expressible only with
445
+ * `authorizedByPolicy: true` as a literal. So "a model was substituted
446
+ * without the customer authorizing it" is not a sentence this contract can
447
+ * say — the same construction `inferenceRouteSwitchDetailSchema` uses to make
448
+ * the resulting route-switch event unreportable.
449
+ */
450
+ export declare const authorizedRouteSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"substitution", [z.ZodObject<{
451
+ deploymentId: z.ZodString;
452
+ modelReference: z.ZodString;
453
+ provider: z.ZodString;
454
+ regions: z.ZodArray<z.ZodString, "many">;
455
+ substitution: z.ZodLiteral<"same_model">;
456
+ }, "strict", z.ZodTypeAny, {
457
+ provider: string;
458
+ modelReference: string;
459
+ regions: string[];
460
+ deploymentId: string;
461
+ substitution: "same_model";
462
+ }, {
463
+ provider: string;
464
+ modelReference: string;
465
+ regions: string[];
466
+ deploymentId: string;
467
+ substitution: "same_model";
468
+ }>, z.ZodObject<{
469
+ /** Literal `true`: an unauthorized substitution cannot be expressed. */
470
+ authorizedByPolicy: z.ZodLiteral<true>;
471
+ deploymentId: z.ZodString;
472
+ modelReference: z.ZodString;
473
+ provider: z.ZodString;
474
+ regions: z.ZodArray<z.ZodString, "many">;
475
+ substitution: z.ZodLiteral<"cross_model">;
476
+ }, "strict", z.ZodTypeAny, {
477
+ provider: string;
478
+ modelReference: string;
479
+ regions: string[];
480
+ deploymentId: string;
481
+ substitution: "cross_model";
482
+ authorizedByPolicy: true;
483
+ }, {
484
+ provider: string;
485
+ modelReference: string;
486
+ regions: string[];
487
+ deploymentId: string;
488
+ substitution: "cross_model";
489
+ authorizedByPolicy: true;
490
+ }>]>, {
491
+ provider: string;
492
+ modelReference: string;
493
+ regions: string[];
494
+ deploymentId: string;
495
+ substitution: "same_model";
496
+ } | {
497
+ provider: string;
498
+ modelReference: string;
499
+ regions: string[];
500
+ deploymentId: string;
501
+ substitution: "cross_model";
502
+ authorizedByPolicy: true;
503
+ }, {
504
+ provider: string;
505
+ modelReference: string;
506
+ regions: string[];
507
+ deploymentId: string;
508
+ substitution: "same_model";
509
+ } | {
510
+ provider: string;
511
+ modelReference: string;
512
+ regions: string[];
513
+ deploymentId: string;
514
+ substitution: "cross_model";
515
+ authorizedByPolicy: true;
516
+ }>;
422
517
  export type RoutingTarget = z.infer<typeof routingTargetSchema>;
423
518
  export type RoutingPolicyScope = z.infer<typeof routingPolicyScopeSchema>;
424
519
  export type RoutingFallbackPolicy = z.infer<typeof routingFallbackPolicySchema>;
425
520
  export type RoutingPolicy = z.infer<typeof routingPolicySchema>;
426
521
  export type RoutingPolicyReference = z.infer<typeof routingPolicyReferenceSchema>;
522
+ export type AuthorizedRoute = z.infer<typeof authorizedRouteSchema>;