@oxy.so/contracts 5.8.0 → 6.1.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 (231) hide show
  1. package/dist/cjs/accountAccess.js +6 -5
  2. package/dist/cjs/accountEmail.js +13 -5
  3. package/dist/cjs/accountGraph.js +10 -9
  4. package/dist/cjs/accountName.js +3 -2
  5. package/dist/cjs/agency.js +91 -34
  6. package/dist/cjs/agentKeys.js +21 -17
  7. package/dist/cjs/appAssertions.js +14 -13
  8. package/dist/cjs/applicationRoles.js +19 -12
  9. package/dist/cjs/campaignAttribution.js +28 -0
  10. package/dist/cjs/civic.js +10 -9
  11. package/dist/cjs/client/campaignAttribution.js +14 -0
  12. package/dist/cjs/client/check.js +61 -53
  13. package/dist/cjs/client/index.js +7 -1
  14. package/dist/cjs/client/language.js +7 -0
  15. package/dist/cjs/consoleOnboarding.js +9 -4
  16. package/dist/cjs/contentClaims.js +23 -14
  17. package/dist/cjs/deviceDirectory.js +11 -9
  18. package/dist/cjs/deviceSession.js +27 -25
  19. package/dist/cjs/email/messages.js +20 -18
  20. package/dist/cjs/emailAgentContext.js +11 -9
  21. package/dist/cjs/externalIdentity.js +15 -11
  22. package/dist/cjs/federationInstanceFetch.js +12 -7
  23. package/dist/cjs/identity.js +19 -17
  24. package/dist/cjs/identityLink.js +6 -4
  25. package/dist/cjs/identityProof.js +6 -4
  26. package/dist/cjs/inboxPush.js +5 -4
  27. package/dist/cjs/index.js +17 -6
  28. package/dist/cjs/inference/accountBilling.js +35 -33
  29. package/dist/cjs/inference/aliaModelRelease.js +9 -7
  30. package/dist/cjs/inference/attribution.js +14 -12
  31. package/dist/cjs/inference/catalogue.js +35 -29
  32. package/dist/cjs/inference/economics.js +24 -19
  33. package/dist/cjs/inference/embeddings.js +9 -7
  34. package/dist/cjs/inference/entitlement.js +17 -15
  35. package/dist/cjs/inference/errors.js +15 -8
  36. package/dist/cjs/inference/identifiers.js +33 -21
  37. package/dist/cjs/inference/inbox.js +37 -35
  38. package/dist/cjs/inference/modelDocumentation.js +16 -14
  39. package/dist/cjs/inference/money.js +5 -4
  40. package/dist/cjs/inference/priceVersion.js +10 -5
  41. package/dist/cjs/inference/providerConnection.js +21 -14
  42. package/dist/cjs/inference/realtime.js +88 -47
  43. package/dist/cjs/inference/request.js +27 -25
  44. package/dist/cjs/inference/routingPolicy.js +12 -10
  45. package/dist/cjs/inference/streamEvents.js +22 -16
  46. package/dist/cjs/inference/usage.js +32 -15
  47. package/dist/cjs/keyRecovery.js +8 -6
  48. package/dist/cjs/keyRotation.js +5 -4
  49. package/dist/cjs/linkedAccounts.js +22 -18
  50. package/dist/cjs/moderationReputation.js +29 -27
  51. package/dist/cjs/notifications.js +25 -9
  52. package/dist/cjs/numberChecks.js +45 -0
  53. package/dist/cjs/oauth.js +14 -12
  54. package/dist/cjs/organizations.js +23 -21
  55. package/dist/cjs/products/access.js +10 -8
  56. package/dist/cjs/products/billing.js +10 -8
  57. package/dist/cjs/products/checkout.js +22 -10
  58. package/dist/cjs/products/plans.js +15 -10
  59. package/dist/cjs/protocol.js +6 -5
  60. package/dist/cjs/recommendations.js +27 -19
  61. package/dist/cjs/reputation.js +15 -13
  62. package/dist/cjs/safety.js +43 -27
  63. package/dist/cjs/serviceToken.js +81 -2
  64. package/dist/cjs/sessionRevocation.js +8 -6
  65. package/dist/cjs/signIn.js +50 -24
  66. package/dist/cjs/stickers.js +19 -15
  67. package/dist/cjs/stringChecks.js +70 -0
  68. package/dist/cjs/transparency.js +14 -12
  69. package/dist/cjs/updates.js +24 -22
  70. package/dist/cjs/userInvalidation.js +7 -5
  71. package/dist/cjs/userResponse.js +8 -7
  72. package/dist/cjs/username.js +7 -6
  73. package/dist/esm/accountAccess.js +4 -3
  74. package/dist/esm/accountEmail.js +13 -5
  75. package/dist/esm/accountGraph.js +8 -7
  76. package/dist/esm/accountName.js +3 -2
  77. package/dist/esm/agency.js +90 -33
  78. package/dist/esm/agentKeys.js +21 -17
  79. package/dist/esm/appAssertions.js +11 -10
  80. package/dist/esm/applicationRoles.js +16 -9
  81. package/dist/esm/campaignAttribution.js +25 -0
  82. package/dist/esm/civic.js +8 -7
  83. package/dist/esm/client/campaignAttribution.js +10 -0
  84. package/dist/esm/client/check.js +61 -53
  85. package/dist/esm/client/index.js +2 -0
  86. package/dist/esm/client/language.js +4 -0
  87. package/dist/esm/consoleOnboarding.js +7 -2
  88. package/dist/esm/contentClaims.js +23 -14
  89. package/dist/esm/deviceDirectory.js +11 -9
  90. package/dist/esm/deviceSession.js +27 -25
  91. package/dist/esm/email/messages.js +18 -16
  92. package/dist/esm/emailAgentContext.js +11 -9
  93. package/dist/esm/externalIdentity.js +15 -11
  94. package/dist/esm/federationInstanceFetch.js +10 -5
  95. package/dist/esm/identity.js +17 -15
  96. package/dist/esm/identityLink.js +6 -4
  97. package/dist/esm/identityProof.js +6 -4
  98. package/dist/esm/inboxPush.js +3 -2
  99. package/dist/esm/index.js +5 -2
  100. package/dist/esm/inference/accountBilling.js +33 -31
  101. package/dist/esm/inference/aliaModelRelease.js +7 -5
  102. package/dist/esm/inference/attribution.js +14 -12
  103. package/dist/esm/inference/catalogue.js +33 -27
  104. package/dist/esm/inference/economics.js +22 -17
  105. package/dist/esm/inference/embeddings.js +9 -7
  106. package/dist/esm/inference/entitlement.js +15 -13
  107. package/dist/esm/inference/errors.js +13 -6
  108. package/dist/esm/inference/identifiers.js +31 -19
  109. package/dist/esm/inference/inbox.js +37 -35
  110. package/dist/esm/inference/modelDocumentation.js +14 -12
  111. package/dist/esm/inference/money.js +3 -2
  112. package/dist/esm/inference/priceVersion.js +8 -3
  113. package/dist/esm/inference/providerConnection.js +19 -12
  114. package/dist/esm/inference/realtime.js +85 -44
  115. package/dist/esm/inference/request.js +25 -23
  116. package/dist/esm/inference/routingPolicy.js +9 -7
  117. package/dist/esm/inference/streamEvents.js +20 -14
  118. package/dist/esm/inference/usage.js +30 -13
  119. package/dist/esm/keyRecovery.js +8 -6
  120. package/dist/esm/keyRotation.js +5 -4
  121. package/dist/esm/linkedAccounts.js +20 -16
  122. package/dist/esm/moderationReputation.js +27 -25
  123. package/dist/esm/notifications.js +23 -7
  124. package/dist/esm/numberChecks.js +41 -0
  125. package/dist/esm/oauth.js +14 -12
  126. package/dist/esm/organizations.js +23 -21
  127. package/dist/esm/products/access.js +10 -8
  128. package/dist/esm/products/billing.js +10 -8
  129. package/dist/esm/products/checkout.js +22 -10
  130. package/dist/esm/products/plans.js +15 -10
  131. package/dist/esm/protocol.js +4 -3
  132. package/dist/esm/recommendations.js +25 -17
  133. package/dist/esm/reputation.js +13 -11
  134. package/dist/esm/safety.js +43 -27
  135. package/dist/esm/serviceToken.js +80 -1
  136. package/dist/esm/sessionRevocation.js +6 -4
  137. package/dist/esm/signIn.js +50 -24
  138. package/dist/esm/stickers.js +17 -13
  139. package/dist/esm/stringChecks.js +63 -0
  140. package/dist/esm/transparency.js +14 -12
  141. package/dist/esm/updates.js +22 -20
  142. package/dist/esm/userInvalidation.js +4 -2
  143. package/dist/esm/userResponse.js +4 -3
  144. package/dist/esm/username.js +3 -2
  145. package/dist/types/accountAccess.d.ts +29 -70
  146. package/dist/types/accountEmail.d.ts +2 -14
  147. package/dist/types/accountGraph.d.ts +179 -171
  148. package/dist/types/accountName.d.ts +1 -1
  149. package/dist/types/accountSubject.d.ts +20 -93
  150. package/dist/types/agency.d.ts +528 -2924
  151. package/dist/types/agentKeys.d.ts +48 -421
  152. package/dist/types/appAssertions.d.ts +56 -210
  153. package/dist/types/applicationRoles.d.ts +30 -276
  154. package/dist/types/avatarCharacter.d.ts +1 -1
  155. package/dist/types/campaignAttribution.d.ts +10 -0
  156. package/dist/types/civic.d.ts +1 -13
  157. package/dist/types/client/agentKeys.d.ts +18 -18
  158. package/dist/types/client/appAssertions.d.ts +3 -3
  159. package/dist/types/client/campaignAttribution.d.ts +12 -0
  160. package/dist/types/client/check.d.ts +13 -13
  161. package/dist/types/client/deviceDirectory.d.ts +51 -51
  162. package/dist/types/client/deviceSession.d.ts +14 -14
  163. package/dist/types/client/index.d.ts +3 -0
  164. package/dist/types/client/language.d.ts +2 -0
  165. package/dist/types/client/organizations.d.ts +25 -25
  166. package/dist/types/client/products.d.ts +33 -33
  167. package/dist/types/client/recommendations.d.ts +2 -2
  168. package/dist/types/client/safety.d.ts +45 -45
  169. package/dist/types/client/sessionStatus.d.ts +4 -4
  170. package/dist/types/client/signIn.d.ts +1 -1
  171. package/dist/types/commonsSignIn.d.ts +4 -1
  172. package/dist/types/consoleOnboarding.d.ts +24 -44
  173. package/dist/types/contentClaims.d.ts +24 -180
  174. package/dist/types/deviceDirectory.d.ts +109 -1040
  175. package/dist/types/deviceSession.d.ts +36 -298
  176. package/dist/types/email/messages.d.ts +212 -1793
  177. package/dist/types/emailAgentContext.d.ts +10 -194
  178. package/dist/types/externalIdentity.d.ts +121 -615
  179. package/dist/types/federationInstanceFetch.d.ts +3 -32
  180. package/dist/types/identity.d.ts +15 -92
  181. package/dist/types/identityLink.d.ts +6 -84
  182. package/dist/types/identityProof.d.ts +5 -17
  183. package/dist/types/inboxPush.d.ts +1 -9
  184. package/dist/types/index.d.ts +7 -3
  185. package/dist/types/inference/accountBilling.d.ts +151 -488
  186. package/dist/types/inference/aliaModelRelease.d.ts +42 -439
  187. package/dist/types/inference/attribution.d.ts +75 -104
  188. package/dist/types/inference/catalogue.d.ts +417 -1599
  189. package/dist/types/inference/economics.d.ts +69 -276
  190. package/dist/types/inference/embeddings.d.ts +110 -406
  191. package/dist/types/inference/entitlement.d.ts +80 -335
  192. package/dist/types/inference/errors.d.ts +90 -102
  193. package/dist/types/inference/identifiers.d.ts +12 -4
  194. package/dist/types/inference/inbox.d.ts +105 -420
  195. package/dist/types/inference/modelDocumentation.d.ts +201 -1390
  196. package/dist/types/inference/money.d.ts +65 -32
  197. package/dist/types/inference/priceVersion.d.ts +53 -120
  198. package/dist/types/inference/providerConnection.d.ts +253 -710
  199. package/dist/types/inference/realtime.d.ts +954 -6825
  200. package/dist/types/inference/request.d.ts +300 -2572
  201. package/dist/types/inference/routingPolicy.d.ts +95 -503
  202. package/dist/types/inference/streamEvents.d.ts +253 -721
  203. package/dist/types/inference/usage.d.ts +317 -950
  204. package/dist/types/keyRecovery.d.ts +3 -51
  205. package/dist/types/keyRotation.d.ts +3 -38
  206. package/dist/types/linkedAccounts.d.ts +50 -236
  207. package/dist/types/moderationReputation.d.ts +81 -14
  208. package/dist/types/notifications.d.ts +19 -51
  209. package/dist/types/numberChecks.d.ts +9 -0
  210. package/dist/types/oauth.d.ts +101 -809
  211. package/dist/types/organizations.d.ts +268 -921
  212. package/dist/types/oxyRecordTypes.d.ts +11 -1
  213. package/dist/types/products/access.d.ts +125 -775
  214. package/dist/types/products/billing.d.ts +67 -503
  215. package/dist/types/products/checkout.d.ts +16 -69
  216. package/dist/types/products/plans.d.ts +33 -366
  217. package/dist/types/recommendations.d.ts +76 -389
  218. package/dist/types/reputation.d.ts +37 -5
  219. package/dist/types/safety.d.ts +408 -2048
  220. package/dist/types/serviceToken.d.ts +247 -7
  221. package/dist/types/sessionRevocation.d.ts +2 -17
  222. package/dist/types/sessionStatus.d.ts +27 -115
  223. package/dist/types/signIn.d.ts +62 -553
  224. package/dist/types/stickers.d.ts +67 -819
  225. package/dist/types/stringChecks.d.ts +16 -0
  226. package/dist/types/transparency.d.ts +14 -302
  227. package/dist/types/updates.d.ts +60 -316
  228. package/dist/types/userInvalidation.d.ts +4 -13
  229. package/dist/types/userResponse.d.ts +302 -2400
  230. package/dist/types/username.d.ts +3 -3
  231. package/package.json +6 -4
@@ -1,3 +1,5 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  /**
2
4
  * The canonical model catalogue.
3
5
  *
@@ -152,8 +154,8 @@ export const modelCapabilitiesSchema = z
152
154
  reasoningEfforts: z.array(reasoningEffortSchema).default([]),
153
155
  streaming: z.boolean(),
154
156
  promptCaching: z.boolean(),
155
- maxContextTokens: z.number().int().positive().safe(),
156
- maxOutputTokens: z.number().int().positive().safe(),
157
+ maxContextTokens: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
158
+ maxOutputTokens: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
157
159
  /**
158
160
  * The request dialects a route to this model can EXECUTE. Modalities say
159
161
  * what a model consumes and produces; they do not say which request shape a
@@ -216,8 +218,8 @@ export const modelCapabilitiesSchema = z
216
218
  export const modelLicenseSchema = z
217
219
  .object({
218
220
  /** SPDX identifier where one exists, otherwise the publisher's own name. */
219
- licenseId: z.string().min(1).max(128),
220
- displayName: z.string().min(1).max(200),
221
+ licenseId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
222
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
221
223
  url: inferenceHttpsUrlSchema.optional(),
222
224
  commercialUseAllowed: z.boolean(),
223
225
  requiresAttribution: z.boolean(),
@@ -241,7 +243,7 @@ export const modelProvenanceSchema = z
241
243
  ]),
242
244
  /** The model this one was derived/fine-tuned from, where there is one. */
243
245
  baseModelId: modelIdSchema.optional(),
244
- trainingOrganization: z.string().min(1).max(200).optional(),
246
+ trainingOrganization: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)).optional(),
245
247
  })
246
248
  .strict();
247
249
  /**
@@ -254,11 +256,13 @@ export const inferenceDataPolicySchema = z
254
256
  .object({
255
257
  retainsPayloads: z.boolean(),
256
258
  /** Zero when nothing is retained. */
257
- retentionDays: z.number().int().nonnegative().max(3650),
259
+ retentionDays: z.number().check(integerCheck()).nonnegative().max(3650),
258
260
  trainsOnCustomerData: z.boolean(),
259
261
  zeroDataRetentionAvailable: z.boolean(),
260
262
  /** Named subprocessors a payload may pass through, for compliance review. */
261
- subprocessors: z.array(z.string().min(1).max(200)).default([]),
263
+ subprocessors: z
264
+ .array(z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)))
265
+ .default([]),
262
266
  policyUrl: inferenceHttpsUrlSchema.optional(),
263
267
  })
264
268
  .strict()
@@ -323,10 +327,10 @@ export const modelDeprecationSchema = z
323
327
  /** One published evaluation result for a revision. */
324
328
  export const modelEvaluationResultSchema = z
325
329
  .object({
326
- suite: z.string().min(1).max(128),
327
- metric: z.string().min(1).max(128),
330
+ suite: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
331
+ metric: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
328
332
  /** Kept as a string: an eval score is published text, not arithmetic. */
329
- score: z.string().min(1).max(64),
333
+ score: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
330
334
  evaluatedAt: inferenceTimestampSchema.optional(),
331
335
  reportUrl: inferenceHttpsUrlSchema.optional(),
332
336
  })
@@ -339,7 +343,9 @@ export const modelSafetyMetadataSchema = z
339
343
  .object({
340
344
  safetyCardUrl: inferenceHttpsUrlSchema.optional(),
341
345
  contentFilteringDefault: z.enum(['none', 'provider_default', 'strict']),
342
- knownLimitations: z.array(z.string().min(1).max(500)).default([]),
346
+ knownLimitations: z
347
+ .array(z.string().check(utf16MinLength(1)).check(utf16MaxLength(500)))
348
+ .default([]),
343
349
  /** Content-provenance marking the modality requires, where it requires one. */
344
350
  provenanceMarking: z.enum(['none', 'visible_watermark', 'invisible_watermark', 'c2pa']),
345
351
  })
@@ -351,10 +357,10 @@ export const modelSafetyMetadataSchema = z
351
357
  export const modelPublisherSchema = z.object({
352
358
  /** See `version.ts`: served on its own by the catalogue, so it is versioned. */
353
359
  schemaVersion: z.literal(1),
354
- publisherId: z.string().min(1).max(128),
360
+ publisherId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
355
361
  slug: publisherSlugSchema,
356
- displayName: z.string().min(1).max(200),
357
- description: z.string().max(2000).optional(),
362
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
363
+ description: z.string().check(utf16MaxLength(2000)).optional(),
358
364
  websiteUrl: inferenceHttpsUrlSchema.optional(),
359
365
  });
360
366
  /* -------------------------------------------------------------------------- */
@@ -374,8 +380,8 @@ export const catalogueModelSchema = z
374
380
  modelId: modelIdSchema,
375
381
  publisher: publisherSlugSchema,
376
382
  slug: modelSlugSchema,
377
- displayName: z.string().min(1).max(200),
378
- description: z.string().max(4000).optional(),
383
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
384
+ description: z.string().check(utf16MaxLength(4000)).optional(),
379
385
  capabilities: modelCapabilitiesSchema,
380
386
  license: modelLicenseSchema,
381
387
  provenance: modelProvenanceSchema,
@@ -421,7 +427,7 @@ export const modelRevisionSchema = z
421
427
  .object({
422
428
  /** See `version.ts`: served on its own by the catalogue, so it is versioned. */
423
429
  schemaVersion: z.literal(1),
424
- revisionId: z.string().min(1).max(128),
430
+ revisionId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
425
431
  modelId: modelIdSchema,
426
432
  revision: modelRevisionLabelSchema,
427
433
  reference: modelReferenceSchema,
@@ -449,9 +455,9 @@ export const modelRevisionSchema = z
449
455
  export const inferenceProviderSchema = z.object({
450
456
  /** See `version.ts`: served on its own by the catalogue, so it is versioned. */
451
457
  schemaVersion: z.literal(1),
452
- providerId: z.string().min(1).max(128),
458
+ providerId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
453
459
  slug: inferenceProviderSlugSchema,
454
- displayName: z.string().min(1).max(200),
460
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
455
461
  /**
456
462
  * `customer_byok` means the customer's own upstream account is billed
457
463
  * directly by the provider and Oxy charges only its platform fee.
@@ -494,7 +500,7 @@ export const modelDeploymentSchema = z
494
500
  /** Reserved capacity for one enterprise account rather than shared. */
495
501
  dedicatedCapacity: z.boolean(),
496
502
  /** The price version customers are charged under on this route. */
497
- priceVersionId: z.string().min(1).max(128).optional(),
503
+ priceVersionId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)).optional(),
498
504
  })
499
505
  .superRefine((deployment, ctx) => {
500
506
  if (!deployment.modelReference.includes('@')) {
@@ -545,7 +551,7 @@ export const routingProfileCandidateSchema = z
545
551
  .object({
546
552
  modelReference: modelReferenceSchema,
547
553
  /** Lower sorts first. Ties are broken by the profile's optimisation target. */
548
- priority: z.number().int().nonnegative().max(1000),
554
+ priority: z.number().check(integerCheck()).nonnegative().max(1000),
549
555
  })
550
556
  .strict();
551
557
  /**
@@ -561,8 +567,8 @@ export const routingProfileSchema = z.object({
561
567
  schemaVersion: z.literal(1),
562
568
  routingProfileId: routingProfileIdSchema,
563
569
  slug: routingProfileSlugSchema,
564
- displayName: z.string().min(1).max(200),
565
- description: z.string().max(2000).optional(),
570
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
571
+ description: z.string().check(utf16MaxLength(2000)).optional(),
566
572
  /** What the profile optimises for when several candidates qualify. */
567
573
  optimiseFor: z.enum(['price', 'latency', 'throughput', 'quality', 'balanced']),
568
574
  candidates: z.array(routingProfileCandidateSchema).min(1),
@@ -590,7 +596,7 @@ export const routingProfileSchema = z.object({
590
596
  export const cataloguePublisherSummarySchema = z
591
597
  .object({
592
598
  slug: publisherSlugSchema,
593
- displayName: z.string().min(1).max(200),
599
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
594
600
  websiteUrl: inferenceHttpsUrlSchema.optional(),
595
601
  })
596
602
  .strict();
@@ -604,7 +610,7 @@ export const cataloguePublisherSummarySchema = z
604
610
  export const catalogueServingProviderSummarySchema = z
605
611
  .object({
606
612
  slug: inferenceProviderSlugSchema,
607
- displayName: z.string().min(1).max(200),
613
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
608
614
  regions: z.array(inferenceRegionSchema).default([]),
609
615
  dataPolicy: inferenceDataPolicySchema,
610
616
  })
@@ -621,8 +627,8 @@ export const modelCatalogueEntrySchema = z.object({
621
627
  schemaVersion: z.literal(3),
622
628
  modelId: modelIdSchema,
623
629
  publisher: cataloguePublisherSummarySchema,
624
- displayName: z.string().min(1).max(200),
625
- description: z.string().max(4000).optional(),
630
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
631
+ description: z.string().check(utf16MaxLength(4000)).optional(),
626
632
  currentRevision: modelRevisionLabelSchema,
627
633
  /** Revisions a customer may pin today, newest first. */
628
634
  availableRevisions: z.array(modelRevisionLabelSchema).min(1),
@@ -1,3 +1,5 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
2
+ import { isoDateTime, utf16MinLength } from '../stringChecks.js';
1
3
  /**
2
4
  * Economic treatment and durable usage/cost reporting for inference
3
5
  * (issue #1526, plan item I09).
@@ -41,7 +43,7 @@ export const inferenceEconomicTreatmentSchema = z.enum(INFERENCE_ECONOMIC_TREATM
41
43
  */
42
44
  export const PROVIDER_COST_SOURCES = ['provider_reported', 'rate_card', 'unknown'];
43
45
  export const providerCostSourceSchema = z.enum(PROVIDER_COST_SOURCES);
44
- const nonNegativeCount = z.number().int().nonnegative().safe();
46
+ const nonNegativeCount = z.number().check(integerCheck()).nonnegative().check(safeNumberCheck());
45
47
  /** One amount family, with the rows it could not include counted beside it. */
46
48
  const knownAmountSchema = z
47
49
  .object({
@@ -66,8 +68,8 @@ export const costCenterUsageSchema = z
66
68
  costCenter: costCenterSchema.nullable(),
67
69
  treatment: inferenceEconomicTreatmentSchema,
68
70
  currency: currencyCodeSchema,
69
- periodStart: z.string().datetime(),
70
- periodEnd: z.string().datetime(),
71
+ periodStart: z.string().check(isoDateTime()),
72
+ periodEnd: z.string().check(isoDateTime()),
71
73
  /** Requests settled in the window (completed, failed, cancelled or partial). */
72
74
  requestCount: nonNegativeCount,
73
75
  /** Requests admitted and not yet settled when the report was read. */
@@ -87,10 +89,10 @@ export const costCenterUsageSchema = z
87
89
  /** Attempts priced in a different currency, excluded without currency conversion. */
88
90
  otherCurrencyCount: nonNegativeCount.default(0),
89
91
  /** Amount stated by the provider; this is not a copy of its invoice. */
90
- providerReportedAmount: exactDecimalSchema.default('0'),
92
+ providerReportedAmount: exactDecimalSchema.prefault('0'),
91
93
  providerReportedCount: nonNegativeCount.default(0),
92
94
  /** Amount estimated from Kaana's immutable rate card, never described as invoiced. */
93
- estimatedAmount: exactDecimalSchema.default('0'),
95
+ estimatedAmount: exactDecimalSchema.prefault('0'),
94
96
  estimatedCount: nonNegativeCount.default(0),
95
97
  }),
96
98
  /**
@@ -108,35 +110,38 @@ export const meteredGenerationSchema = z
108
110
  .object({
109
111
  schemaVersion: z.literal(2),
110
112
  kind: z.literal('metered_usage'),
111
- meteredUsageId: z.string().min(1),
112
- requestId: z.string().min(1),
113
- generationId: z.string().min(1).optional(),
114
- parentRequestId: z.string().min(1).optional(),
115
- applicationId: z.string().min(1),
116
- credentialId: z.string().min(1),
117
- delegatedUserId: z.string().min(1).optional(),
113
+ meteredUsageId: z.string().check(utf16MinLength(1)),
114
+ requestId: z.string().check(utf16MinLength(1)),
115
+ generationId: z.string().check(utf16MinLength(1)).optional(),
116
+ parentRequestId: z.string().check(utf16MinLength(1)).optional(),
117
+ applicationId: z.string().check(utf16MinLength(1)),
118
+ credentialId: z.string().check(utf16MinLength(1)),
119
+ delegatedUserId: z.string().check(utf16MinLength(1)).optional(),
118
120
  environment: inferenceEnvironmentSchema,
119
121
  economicTreatment: z.literal('internal_metered'),
120
- economicPolicyVersion: z.string().min(1),
122
+ economicPolicyVersion: z.string().check(utf16MinLength(1)),
121
123
  outcome: inferenceRequestOutcomeSchema,
122
124
  usageSource: usageSourceSchema,
123
125
  units: z.array(usageQuantitySchema),
124
126
  resolvedModelReference: modelReferenceSchema,
125
- servingProvider: z.string().min(1),
127
+ servingProvider: z.string().check(utf16MinLength(1)),
126
128
  tariff: z.discriminatedUnion('status', [
127
129
  z
128
130
  .object({
129
131
  status: z.literal('quoted'),
130
132
  amount: exactDecimalSchema,
131
133
  currency: currencyCodeSchema,
132
- priceVersionId: z.string().min(1),
134
+ priceVersionId: z.string().check(utf16MinLength(1)),
133
135
  })
134
136
  .strict(),
135
137
  z
136
- .object({ status: z.literal('unpriced'), priceVersionId: z.string().min(1).nullable() })
138
+ .object({
139
+ status: z.literal('unpriced'),
140
+ priceVersionId: z.string().check(utf16MinLength(1)).nullable(),
141
+ })
137
142
  .strict(),
138
143
  ]),
139
144
  customerCharge: z.object({ status: z.literal('not_charged') }).strict(),
140
- settledAt: z.string().datetime(),
145
+ settledAt: z.string().check(isoDateTime()),
141
146
  })
142
147
  .strict();
@@ -1,15 +1,17 @@
1
+ import { integerCheck } from '../numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  import { z } from 'zod';
2
4
  import { inferenceErrorSchema } from './errors.js';
3
5
  export const embeddingVectorSchema = z
4
6
  .object({
5
- index: z.number().int().nonnegative(),
7
+ index: z.number().check(integerCheck()).nonnegative(),
6
8
  embedding: z.array(z.number().finite()).min(1).max(1024),
7
9
  })
8
10
  .strict();
9
11
  export const embeddingUsageSchema = z
10
12
  .object({
11
- inputTokens: z.number().int().nonnegative(),
12
- totalTokens: z.number().int().nonnegative(),
13
+ inputTokens: z.number().check(integerCheck()).nonnegative(),
14
+ totalTokens: z.number().check(integerCheck()).nonnegative(),
13
15
  })
14
16
  .strict()
15
17
  .refine((usage) => usage.totalTokens >= usage.inputTokens, {
@@ -19,9 +21,9 @@ export const embeddingUsageSchema = z
19
21
  export const embeddingSuccessSchema = z
20
22
  .object({
21
23
  schemaVersion: z.literal(1),
22
- requestId: z.string().min(1).max(128),
23
- model: z.string().min(1).max(255),
24
- dimension: z.number().int().positive().max(1024),
24
+ requestId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
25
+ model: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)),
26
+ dimension: z.number().check(integerCheck()).positive().max(1024),
25
27
  data: z.array(embeddingVectorSchema).min(1).max(2048),
26
28
  usage: embeddingUsageSchema,
27
29
  })
@@ -47,7 +49,7 @@ export const embeddingSuccessSchema = z
47
49
  export const embeddingFailureSchema = z
48
50
  .object({
49
51
  schemaVersion: z.literal(1),
50
- requestId: z.string().min(1).max(128),
52
+ requestId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
51
53
  error: inferenceErrorSchema,
52
54
  })
53
55
  .strict();
@@ -1,3 +1,5 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
2
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  /**
2
4
  * Product entitlements — the interface a first-party product (Alia) queries to
3
5
  * learn what an account is entitled to, WITHOUT learning anything it could
@@ -87,8 +89,8 @@ export const planAllowanceSchema = z
87
89
  /** A stable machine name, e.g. `api_credits_per_month`. */
88
90
  key: z.string().regex(/^[a-z][a-z0-9_]{0,62}$/),
89
91
  /** Whole units included per period. Never money. */
90
- included: z.number().int().nonnegative().safe(),
91
- remaining: z.number().int().nonnegative().safe().optional(),
92
+ included: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
93
+ remaining: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()).optional(),
92
94
  })
93
95
  .strict();
94
96
  /**
@@ -101,12 +103,12 @@ export const planAllowanceSchema = z
101
103
  */
102
104
  export const productPlanSchema = z
103
105
  .object({
104
- id: z.string().min(1).max(64),
105
- name: z.string().min(1).max(120),
106
+ id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
107
+ name: z.string().check(utf16MinLength(1)).check(utf16MaxLength(120)),
106
108
  status: productPlanStatusSchema,
107
109
  live: z.boolean(),
108
- currentPeriodStart: z.string().datetime(),
109
- currentPeriodEnd: z.string().datetime(),
110
+ currentPeriodStart: z.string().check(isoDateTime()),
111
+ currentPeriodEnd: z.string().check(isoDateTime()),
110
112
  cancelAtPeriodEnd: z.boolean(),
111
113
  allowances: z.array(planAllowanceSchema),
112
114
  })
@@ -156,10 +158,10 @@ export const costCenterSchema = z
156
158
  schemaVersion: z.literal(1),
157
159
  accountId: oxyAccountIdSchema,
158
160
  slug: z.string().regex(/^[a-z0-9][a-z0-9-]{0,62}$/),
159
- label: z.string().min(1).max(120),
161
+ label: z.string().check(utf16MinLength(1)).check(utf16MaxLength(120)),
160
162
  status: costCenterStatusSchema,
161
- createdAt: z.string().datetime(),
162
- updatedAt: z.string().datetime(),
163
+ createdAt: z.string().check(isoDateTime()),
164
+ updatedAt: z.string().check(isoDateTime()),
163
165
  })
164
166
  .strict();
165
167
  /**
@@ -175,10 +177,10 @@ export const costCenterSpendSchema = z
175
177
  schemaVersion: z.literal(1),
176
178
  costCenter: costCenterSchema,
177
179
  currency: currencyCodeSchema,
178
- periodStart: z.string().datetime(),
179
- periodEnd: z.string().datetime(),
180
+ periodStart: z.string().check(isoDateTime()),
181
+ periodEnd: z.string().check(isoDateTime()),
180
182
  billedAmount: exactDecimalSchema,
181
- requestCount: z.number().int().nonnegative().safe(),
183
+ requestCount: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
182
184
  })
183
185
  .strict();
184
186
  /* -------------------------------------------------------------------------- */
@@ -209,6 +211,6 @@ export const productEntitlementSchema = z
209
211
  payAsYouGo: payAsYouGoEntitlementSchema.nullable(),
210
212
  costCenter: costCenterSchema.nullable(),
211
213
  /** When this view was computed. Entitlements are eventually consistent. */
212
- resolvedAt: z.string().datetime(),
214
+ resolvedAt: z.string().check(isoDateTime()),
213
215
  })
214
216
  .strict();
@@ -1,3 +1,5 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  /**
2
4
  * Inference errors and retryability.
3
5
  *
@@ -223,8 +225,8 @@ const CREDENTIAL_PATTERNS = [
223
225
  */
224
226
  export const safeErrorTextSchema = z
225
227
  .string()
226
- .min(1)
227
- .max(2000)
228
+ .check(utf16MinLength(1))
229
+ .check(utf16MaxLength(2000))
228
230
  .refine((value) => !CREDENTIAL_PATTERNS.some((pattern) => pattern.test(value)), 'error text must not contain credential-shaped material');
229
231
  /**
230
232
  * A coarse classification of an upstream failure (ADR 0010's `upstreamCategory`).
@@ -258,9 +260,9 @@ export const providerErrorPassthroughSchema = z
258
260
  .object({
259
261
  provider: inferenceProviderSlugSchema,
260
262
  /** The upstream HTTP status, when the upstream spoke HTTP. */
261
- status: z.number().int().min(100).max(599).optional(),
263
+ status: z.number().check(integerCheck()).min(100).max(599).optional(),
262
264
  /** The upstream's own error code, verbatim and uninterpreted. */
263
- code: z.string().max(128).optional(),
265
+ code: z.string().check(utf16MaxLength(128)).optional(),
264
266
  /** The upstream's message, subject to the same credential refusal. */
265
267
  message: safeErrorTextSchema.optional(),
266
268
  })
@@ -281,9 +283,14 @@ export const inferenceErrorSchema = z
281
283
  retryable: z.boolean(),
282
284
  requestId: requestIdSchema,
283
285
  /** How long to wait before retrying. Only meaningful when `retryable`. */
284
- retryAfterMs: z.number().int().nonnegative().safe().optional(),
286
+ retryAfterMs: z
287
+ .number()
288
+ .check(integerCheck())
289
+ .nonnegative()
290
+ .check(safeNumberCheck())
291
+ .optional(),
285
292
  /** The request field at fault, for `invalid_request`. */
286
- param: z.string().max(128).optional(),
293
+ param: z.string().check(utf16MaxLength(128)).optional(),
287
294
  /** Present only when an upstream provider was reached and failed. */
288
295
  upstreamCategory: upstreamErrorCategorySchema.optional(),
289
296
  providerError: providerErrorPassthroughSchema.optional(),
@@ -1,3 +1,4 @@
1
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
2
  /**
2
3
  * Identifiers, references and wire primitives shared by every Oxy↔data-plane
3
4
  * inference contract.
@@ -32,7 +33,11 @@ import { z } from 'zod';
32
33
  * of a header, a JWT claim or a request body — is not assignable to it; the
33
34
  * only way to obtain one is to parse a value through this schema.
34
35
  */
35
- export const oxyAccountIdSchema = z.string().min(1).max(64).brand();
36
+ export const oxyAccountIdSchema = z
37
+ .string()
38
+ .check(utf16MinLength(1))
39
+ .check(utf16MaxLength(64))
40
+ .brand();
36
41
  /**
37
42
  * A delegated end-user identity (Alia's `X-Oxy-User-Id`), branded with a
38
43
  * DIFFERENT brand from {@link oxyAccountIdSchema} so the two cannot be
@@ -43,16 +48,20 @@ export const oxyAccountIdSchema = z.string().min(1).max(64).brand();
43
48
  * a billing principal, never an access-control principal, and its presence
44
49
  * never changes which account is charged.
45
50
  */
46
- export const delegatedUserIdSchema = z.string().min(1).max(64).brand();
51
+ export const delegatedUserIdSchema = z
52
+ .string()
53
+ .check(utf16MinLength(1))
54
+ .check(utf16MaxLength(64))
55
+ .brand();
47
56
  /**
48
57
  * An Oxy `Application._id`. Not branded: no invariant in this contract turns on
49
58
  * confusing it with another id, and brand inflation costs every producer a
50
59
  * parse call for no safety. The two ids above are branded because ADR 0007's
51
60
  * rule is exactly that they must not be interchangeable.
52
61
  */
53
- export const oxyApplicationIdSchema = z.string().min(1).max(64);
62
+ export const oxyApplicationIdSchema = z.string().check(utf16MinLength(1)).check(utf16MaxLength(64));
54
63
  /** An Oxy `ApplicationCredential._id` — the credential used for this request. */
55
- export const oxyCredentialIdSchema = z.string().min(1).max(64);
64
+ export const oxyCredentialIdSchema = z.string().check(utf16MinLength(1)).check(utf16MaxLength(64));
56
65
  /**
57
66
  * A request id allocated by the Oxy EDGE, at admission and BEFORE
58
67
  * authentication, so that a request rejected for a bad credential is as
@@ -74,18 +83,18 @@ export const oxyCredentialIdSchema = z.string().min(1).max(64);
74
83
  * customer-visible receipt, so it appears on every stream event and every
75
84
  * ledger record.
76
85
  */
77
- export const requestIdSchema = z.string().min(1).max(128);
86
+ export const requestIdSchema = z.string().check(utf16MinLength(1)).check(utf16MaxLength(128));
78
87
  /**
79
88
  * A generation id generated by the data plane, present when a request produced
80
89
  * a generation that can be looked up later (`GET /v1/generations/:id`).
81
90
  */
82
- export const generationIdSchema = z.string().min(1).max(128);
91
+ export const generationIdSchema = z.string().check(utf16MinLength(1)).check(utf16MaxLength(128));
83
92
  /**
84
93
  * A caller-supplied idempotency key. Every reserve/settle/refund call is keyed
85
94
  * on one so a retry, a redelivered event or a duplicated webhook can never
86
95
  * charge twice.
87
96
  */
88
- export const idempotencyKeySchema = z.string().min(1).max(255);
97
+ export const idempotencyKeySchema = z.string().check(utf16MinLength(1)).check(utf16MaxLength(255));
89
98
  /** Credential environments. A credential is issued into exactly one of them. */
90
99
  export const inferenceEnvironmentSchema = z.enum(['development', 'staging', 'production']);
91
100
  /* -------------------------------------------------------------------------- */
@@ -100,7 +109,7 @@ export const inferenceEnvironmentSchema = z.enum(['development', 'staging', 'pro
100
109
  * settled. One canonical spelling (UTC, `Z`) so two records that describe the
101
110
  * same moment compare and sort as equal, which a mix of offsets would not.
102
111
  */
103
- export const inferenceTimestampSchema = z.string().datetime();
112
+ export const inferenceTimestampSchema = z.string().check(isoDateTime());
104
113
  /**
105
114
  * A calendar DATE with no instant attached (`2026-05-01`) — a knowledge cutoff
106
115
  * or a release date, which are published as days and become wrong when a
@@ -112,7 +121,7 @@ export const inferenceDateSchema = z
112
121
  /** An absolute https URL, for model cards, licenses and provider documentation. */
113
122
  export const inferenceHttpsUrlSchema = z
114
123
  .string()
115
- .max(2048)
124
+ .check(utf16MaxLength(2048))
116
125
  .regex(/^https:\/\/[^\s]+$/, 'must be an absolute https URL');
117
126
  /**
118
127
  * A content digest, `sha256:<64 lowercase hex>`.
@@ -138,12 +147,12 @@ const REVISION_PATTERN = '[a-zA-Z0-9](?:[a-zA-Z0-9._-]*[a-zA-Z0-9])?';
138
147
  /** A publisher slug, e.g. `openai`, `anthropic`, `meta`, `alia`. */
139
148
  export const publisherSlugSchema = z
140
149
  .string()
141
- .max(64)
150
+ .check(utf16MaxLength(64))
142
151
  .regex(new RegExp(`^${SLUG_PATTERN}$`), 'publisher must be a lowercase URL-safe slug');
143
152
  /** A model slug within its publisher's namespace, e.g. `gpt-5`, `llama-3.1-70b`. */
144
153
  export const modelSlugSchema = z
145
154
  .string()
146
- .max(64)
155
+ .check(utf16MaxLength(64))
147
156
  .regex(new RegExp(`^${SLUG_PATTERN}$`), 'model must be a lowercase URL-safe slug');
148
157
  /**
149
158
  * A canonical model id, `<publisher>/<model>`. This names a MODEL — a
@@ -152,12 +161,12 @@ export const modelSlugSchema = z
152
161
  */
153
162
  export const modelIdSchema = z
154
163
  .string()
155
- .max(129)
164
+ .check(utf16MaxLength(129))
156
165
  .regex(new RegExp(`^${SLUG_PATTERN}/${SLUG_PATTERN}$`), 'model id must be <publisher>/<model>');
157
166
  /** An immutable revision label, unique within its model, e.g. `2026-05-01`. */
158
167
  export const modelRevisionLabelSchema = z
159
168
  .string()
160
- .max(64)
169
+ .check(utf16MaxLength(64))
161
170
  .regex(new RegExp(`^${REVISION_PATTERN}$`), 'revision must be a URL-safe label');
162
171
  /**
163
172
  * A model reference as a customer writes it: `<publisher>/<model>` (the model's
@@ -171,7 +180,7 @@ export const modelRevisionLabelSchema = z
171
180
  */
172
181
  export const modelReferenceSchema = z
173
182
  .string()
174
- .max(194)
183
+ .check(utf16MaxLength(194))
175
184
  .regex(new RegExp(`^${SLUG_PATTERN}/${SLUG_PATTERN}(?:@${REVISION_PATTERN})?$`), 'model reference must be <publisher>/<model> or <publisher>/<model>@<revision>');
176
185
  /**
177
186
  * A routing-profile slug, e.g. `auto`, `fast`, `quality`.
@@ -183,7 +192,7 @@ export const modelReferenceSchema = z
183
192
  */
184
193
  export const routingProfileSlugSchema = z
185
194
  .string()
186
- .max(64)
195
+ .check(utf16MaxLength(64))
187
196
  .regex(new RegExp(`^${SLUG_PATTERN}$`), 'routing profile must be a lowercase URL-safe slug');
188
197
  /**
189
198
  * The opaque PostgreSQL identity of one routing profile.
@@ -191,11 +200,14 @@ export const routingProfileSlugSchema = z
191
200
  * No trim, case-folding or format heuristic: callers selecting by id must name
192
201
  * the exact stored bytes. The database lookup is the authority for existence.
193
202
  */
194
- export const routingProfileIdSchema = z.string().min(1).max(128);
203
+ export const routingProfileIdSchema = z
204
+ .string()
205
+ .check(utf16MinLength(1))
206
+ .check(utf16MaxLength(128));
195
207
  /** An inference provider slug, e.g. `openai`, `bedrock`, `oxy-hosted`. */
196
208
  export const inferenceProviderSlugSchema = z
197
209
  .string()
198
- .max(64)
210
+ .check(utf16MaxLength(64))
199
211
  .regex(new RegExp(`^${SLUG_PATTERN}$`), 'provider must be a lowercase URL-safe slug');
200
212
  /**
201
213
  * A deployment/endpoint id. Opaque to customers: which concrete endpoint served
@@ -203,7 +215,7 @@ export const inferenceProviderSlugSchema = z
203
215
  * subset of it is ever attributed back (see the catalogue's serving-boundary
204
216
  * rules).
205
217
  */
206
- export const deploymentIdSchema = z.string().min(1).max(128);
218
+ export const deploymentIdSchema = z.string().check(utf16MinLength(1)).check(utf16MaxLength(128));
207
219
  /**
208
220
  * A region identifier, e.g. `us-west-2`, `eu-central-1`. Free-form rather than
209
221
  * a closed enum because the set is provider-defined and grows without any
@@ -211,7 +223,7 @@ export const deploymentIdSchema = z.string().min(1).max(128);
211
223
  */
212
224
  export const inferenceRegionSchema = z
213
225
  .string()
214
- .max(64)
226
+ .check(utf16MaxLength(64))
215
227
  .regex(new RegExp(`^${SLUG_PATTERN}$`), 'region must be a lowercase URL-safe slug');
216
228
  /**
217
229
  * The publisher namespace reserved for models Alia actually owns or derives.