@oxy.so/contracts 5.8.0 → 6.0.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 (219) 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/civic.js +10 -9
  10. package/dist/cjs/client/check.js +61 -53
  11. package/dist/cjs/consoleOnboarding.js +9 -4
  12. package/dist/cjs/contentClaims.js +23 -14
  13. package/dist/cjs/deviceDirectory.js +11 -9
  14. package/dist/cjs/deviceSession.js +27 -25
  15. package/dist/cjs/email/messages.js +20 -18
  16. package/dist/cjs/emailAgentContext.js +11 -9
  17. package/dist/cjs/externalIdentity.js +15 -11
  18. package/dist/cjs/federationInstanceFetch.js +12 -7
  19. package/dist/cjs/identity.js +19 -17
  20. package/dist/cjs/identityLink.js +6 -4
  21. package/dist/cjs/identityProof.js +6 -4
  22. package/dist/cjs/inboxPush.js +5 -4
  23. package/dist/cjs/index.js +15 -6
  24. package/dist/cjs/inference/accountBilling.js +35 -33
  25. package/dist/cjs/inference/aliaModelRelease.js +9 -7
  26. package/dist/cjs/inference/attribution.js +14 -12
  27. package/dist/cjs/inference/catalogue.js +35 -29
  28. package/dist/cjs/inference/economics.js +24 -19
  29. package/dist/cjs/inference/embeddings.js +9 -7
  30. package/dist/cjs/inference/entitlement.js +17 -15
  31. package/dist/cjs/inference/errors.js +15 -8
  32. package/dist/cjs/inference/identifiers.js +33 -21
  33. package/dist/cjs/inference/inbox.js +37 -35
  34. package/dist/cjs/inference/modelDocumentation.js +16 -14
  35. package/dist/cjs/inference/money.js +5 -4
  36. package/dist/cjs/inference/priceVersion.js +10 -5
  37. package/dist/cjs/inference/providerConnection.js +21 -14
  38. package/dist/cjs/inference/realtime.js +88 -47
  39. package/dist/cjs/inference/request.js +27 -25
  40. package/dist/cjs/inference/routingPolicy.js +12 -10
  41. package/dist/cjs/inference/streamEvents.js +22 -16
  42. package/dist/cjs/inference/usage.js +32 -15
  43. package/dist/cjs/keyRecovery.js +8 -6
  44. package/dist/cjs/keyRotation.js +5 -4
  45. package/dist/cjs/linkedAccounts.js +22 -18
  46. package/dist/cjs/moderationReputation.js +29 -27
  47. package/dist/cjs/notifications.js +25 -9
  48. package/dist/cjs/numberChecks.js +45 -0
  49. package/dist/cjs/oauth.js +14 -12
  50. package/dist/cjs/organizations.js +23 -21
  51. package/dist/cjs/products/access.js +10 -8
  52. package/dist/cjs/products/billing.js +10 -8
  53. package/dist/cjs/products/checkout.js +22 -10
  54. package/dist/cjs/products/plans.js +15 -10
  55. package/dist/cjs/protocol.js +6 -5
  56. package/dist/cjs/recommendations.js +27 -19
  57. package/dist/cjs/reputation.js +15 -13
  58. package/dist/cjs/safety.js +43 -27
  59. package/dist/cjs/serviceToken.js +81 -2
  60. package/dist/cjs/sessionRevocation.js +8 -6
  61. package/dist/cjs/signIn.js +42 -24
  62. package/dist/cjs/stickers.js +19 -15
  63. package/dist/cjs/stringChecks.js +70 -0
  64. package/dist/cjs/transparency.js +14 -12
  65. package/dist/cjs/updates.js +24 -22
  66. package/dist/cjs/userInvalidation.js +7 -5
  67. package/dist/cjs/userResponse.js +8 -7
  68. package/dist/cjs/username.js +7 -6
  69. package/dist/esm/accountAccess.js +4 -3
  70. package/dist/esm/accountEmail.js +13 -5
  71. package/dist/esm/accountGraph.js +8 -7
  72. package/dist/esm/accountName.js +3 -2
  73. package/dist/esm/agency.js +90 -33
  74. package/dist/esm/agentKeys.js +21 -17
  75. package/dist/esm/appAssertions.js +11 -10
  76. package/dist/esm/applicationRoles.js +16 -9
  77. package/dist/esm/civic.js +8 -7
  78. package/dist/esm/client/check.js +61 -53
  79. package/dist/esm/consoleOnboarding.js +7 -2
  80. package/dist/esm/contentClaims.js +23 -14
  81. package/dist/esm/deviceDirectory.js +11 -9
  82. package/dist/esm/deviceSession.js +27 -25
  83. package/dist/esm/email/messages.js +18 -16
  84. package/dist/esm/emailAgentContext.js +11 -9
  85. package/dist/esm/externalIdentity.js +15 -11
  86. package/dist/esm/federationInstanceFetch.js +10 -5
  87. package/dist/esm/identity.js +17 -15
  88. package/dist/esm/identityLink.js +6 -4
  89. package/dist/esm/identityProof.js +6 -4
  90. package/dist/esm/inboxPush.js +3 -2
  91. package/dist/esm/index.js +4 -2
  92. package/dist/esm/inference/accountBilling.js +33 -31
  93. package/dist/esm/inference/aliaModelRelease.js +7 -5
  94. package/dist/esm/inference/attribution.js +14 -12
  95. package/dist/esm/inference/catalogue.js +33 -27
  96. package/dist/esm/inference/economics.js +22 -17
  97. package/dist/esm/inference/embeddings.js +9 -7
  98. package/dist/esm/inference/entitlement.js +15 -13
  99. package/dist/esm/inference/errors.js +13 -6
  100. package/dist/esm/inference/identifiers.js +31 -19
  101. package/dist/esm/inference/inbox.js +37 -35
  102. package/dist/esm/inference/modelDocumentation.js +14 -12
  103. package/dist/esm/inference/money.js +3 -2
  104. package/dist/esm/inference/priceVersion.js +8 -3
  105. package/dist/esm/inference/providerConnection.js +19 -12
  106. package/dist/esm/inference/realtime.js +85 -44
  107. package/dist/esm/inference/request.js +25 -23
  108. package/dist/esm/inference/routingPolicy.js +9 -7
  109. package/dist/esm/inference/streamEvents.js +20 -14
  110. package/dist/esm/inference/usage.js +30 -13
  111. package/dist/esm/keyRecovery.js +8 -6
  112. package/dist/esm/keyRotation.js +5 -4
  113. package/dist/esm/linkedAccounts.js +20 -16
  114. package/dist/esm/moderationReputation.js +27 -25
  115. package/dist/esm/notifications.js +23 -7
  116. package/dist/esm/numberChecks.js +41 -0
  117. package/dist/esm/oauth.js +14 -12
  118. package/dist/esm/organizations.js +23 -21
  119. package/dist/esm/products/access.js +10 -8
  120. package/dist/esm/products/billing.js +10 -8
  121. package/dist/esm/products/checkout.js +22 -10
  122. package/dist/esm/products/plans.js +15 -10
  123. package/dist/esm/protocol.js +4 -3
  124. package/dist/esm/recommendations.js +25 -17
  125. package/dist/esm/reputation.js +13 -11
  126. package/dist/esm/safety.js +43 -27
  127. package/dist/esm/serviceToken.js +80 -1
  128. package/dist/esm/sessionRevocation.js +6 -4
  129. package/dist/esm/signIn.js +42 -24
  130. package/dist/esm/stickers.js +17 -13
  131. package/dist/esm/stringChecks.js +63 -0
  132. package/dist/esm/transparency.js +14 -12
  133. package/dist/esm/updates.js +22 -20
  134. package/dist/esm/userInvalidation.js +4 -2
  135. package/dist/esm/userResponse.js +4 -3
  136. package/dist/esm/username.js +3 -2
  137. package/dist/types/accountAccess.d.ts +29 -70
  138. package/dist/types/accountEmail.d.ts +2 -14
  139. package/dist/types/accountGraph.d.ts +179 -171
  140. package/dist/types/accountName.d.ts +1 -1
  141. package/dist/types/accountSubject.d.ts +20 -93
  142. package/dist/types/agency.d.ts +528 -2924
  143. package/dist/types/agentKeys.d.ts +48 -421
  144. package/dist/types/appAssertions.d.ts +56 -210
  145. package/dist/types/applicationRoles.d.ts +30 -276
  146. package/dist/types/avatarCharacter.d.ts +1 -1
  147. package/dist/types/civic.d.ts +1 -13
  148. package/dist/types/client/agentKeys.d.ts +18 -18
  149. package/dist/types/client/appAssertions.d.ts +3 -3
  150. package/dist/types/client/check.d.ts +13 -13
  151. package/dist/types/client/deviceDirectory.d.ts +51 -51
  152. package/dist/types/client/deviceSession.d.ts +14 -14
  153. package/dist/types/client/organizations.d.ts +25 -25
  154. package/dist/types/client/products.d.ts +33 -33
  155. package/dist/types/client/recommendations.d.ts +2 -2
  156. package/dist/types/client/safety.d.ts +45 -45
  157. package/dist/types/client/sessionStatus.d.ts +4 -4
  158. package/dist/types/client/signIn.d.ts +1 -1
  159. package/dist/types/commonsSignIn.d.ts +4 -1
  160. package/dist/types/consoleOnboarding.d.ts +24 -44
  161. package/dist/types/contentClaims.d.ts +24 -180
  162. package/dist/types/deviceDirectory.d.ts +109 -1040
  163. package/dist/types/deviceSession.d.ts +36 -298
  164. package/dist/types/email/messages.d.ts +212 -1793
  165. package/dist/types/emailAgentContext.d.ts +10 -194
  166. package/dist/types/externalIdentity.d.ts +121 -615
  167. package/dist/types/federationInstanceFetch.d.ts +3 -32
  168. package/dist/types/identity.d.ts +15 -92
  169. package/dist/types/identityLink.d.ts +6 -84
  170. package/dist/types/identityProof.d.ts +5 -17
  171. package/dist/types/inboxPush.d.ts +1 -9
  172. package/dist/types/index.d.ts +5 -3
  173. package/dist/types/inference/accountBilling.d.ts +151 -488
  174. package/dist/types/inference/aliaModelRelease.d.ts +42 -439
  175. package/dist/types/inference/attribution.d.ts +75 -104
  176. package/dist/types/inference/catalogue.d.ts +417 -1599
  177. package/dist/types/inference/economics.d.ts +69 -276
  178. package/dist/types/inference/embeddings.d.ts +110 -406
  179. package/dist/types/inference/entitlement.d.ts +80 -335
  180. package/dist/types/inference/errors.d.ts +90 -102
  181. package/dist/types/inference/identifiers.d.ts +12 -4
  182. package/dist/types/inference/inbox.d.ts +105 -420
  183. package/dist/types/inference/modelDocumentation.d.ts +201 -1390
  184. package/dist/types/inference/money.d.ts +65 -32
  185. package/dist/types/inference/priceVersion.d.ts +53 -120
  186. package/dist/types/inference/providerConnection.d.ts +253 -710
  187. package/dist/types/inference/realtime.d.ts +954 -6825
  188. package/dist/types/inference/request.d.ts +300 -2572
  189. package/dist/types/inference/routingPolicy.d.ts +95 -503
  190. package/dist/types/inference/streamEvents.d.ts +253 -721
  191. package/dist/types/inference/usage.d.ts +317 -950
  192. package/dist/types/keyRecovery.d.ts +3 -51
  193. package/dist/types/keyRotation.d.ts +3 -38
  194. package/dist/types/linkedAccounts.d.ts +50 -236
  195. package/dist/types/moderationReputation.d.ts +81 -14
  196. package/dist/types/notifications.d.ts +19 -51
  197. package/dist/types/numberChecks.d.ts +9 -0
  198. package/dist/types/oauth.d.ts +101 -809
  199. package/dist/types/organizations.d.ts +268 -921
  200. package/dist/types/oxyRecordTypes.d.ts +11 -1
  201. package/dist/types/products/access.d.ts +125 -775
  202. package/dist/types/products/billing.d.ts +67 -503
  203. package/dist/types/products/checkout.d.ts +16 -69
  204. package/dist/types/products/plans.d.ts +33 -366
  205. package/dist/types/recommendations.d.ts +76 -389
  206. package/dist/types/reputation.d.ts +37 -5
  207. package/dist/types/safety.d.ts +408 -2048
  208. package/dist/types/serviceToken.d.ts +247 -7
  209. package/dist/types/sessionRevocation.d.ts +2 -17
  210. package/dist/types/sessionStatus.d.ts +27 -115
  211. package/dist/types/signIn.d.ts +53 -553
  212. package/dist/types/stickers.d.ts +67 -819
  213. package/dist/types/stringChecks.d.ts +16 -0
  214. package/dist/types/transparency.d.ts +14 -302
  215. package/dist/types/updates.d.ts +60 -316
  216. package/dist/types/userInvalidation.d.ts +4 -13
  217. package/dist/types/userResponse.d.ts +302 -2400
  218. package/dist/types/username.d.ts +3 -3
  219. package/package.json +2 -2
@@ -1,3 +1,5 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
2
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  /**
2
4
  * The account-scoped billing surface: who pays, what they hold, what bounds
3
5
  * them, and how it reconciles against the payment processor.
@@ -100,8 +102,8 @@ export const billingProfileSchema = z
100
102
  */
101
103
  creditLimit: exactDecimalSchema,
102
104
  autoRecharge: autoRechargeSchema,
103
- createdAt: z.string().datetime(),
104
- updatedAt: z.string().datetime(),
105
+ createdAt: z.string().check(isoDateTime()),
106
+ updatedAt: z.string().check(isoDateTime()),
105
107
  })
106
108
  .strict();
107
109
  /* -------------------------------------------------------------------------- */
@@ -166,20 +168,20 @@ export const billingInvoiceSchema = z
166
168
  .object({
167
169
  /** See `version.ts`: this shape is served to Console and to Alia. */
168
170
  schemaVersion: z.literal(1),
169
- id: z.string().min(1).max(64),
171
+ id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
170
172
  accountId: oxyAccountIdSchema,
171
173
  currency: currencyCodeSchema,
172
- periodStart: z.string().datetime(),
173
- periodEnd: z.string().datetime(),
174
+ periodStart: z.string().check(isoDateTime()),
175
+ periodEnd: z.string().check(isoDateTime()),
174
176
  status: billingInvoiceStatusSchema,
175
177
  subtotalAmount: exactDecimalSchema,
176
178
  totalAmount: exactDecimalSchema,
177
- minorUnitExponent: z.number().int().min(0).max(4),
179
+ minorUnitExponent: z.number().check(integerCheck()).min(0).max(4),
178
180
  /** The processor's own invoice id, for reconciliation. Never an authority. */
179
- externalInvoiceRef: z.string().min(1).max(255).optional(),
180
- issuedAt: z.string().datetime().optional(),
181
- paidAt: z.string().datetime().optional(),
182
- receiptCount: z.number().int().nonnegative().safe(),
181
+ externalInvoiceRef: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)).optional(),
182
+ issuedAt: z.string().check(isoDateTime()).optional(),
183
+ paidAt: z.string().check(isoDateTime()).optional(),
184
+ receiptCount: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
183
185
  })
184
186
  .strict();
185
187
  /* -------------------------------------------------------------------------- */
@@ -207,16 +209,16 @@ export const externalPaymentKindSchema = z.enum(EXTERNAL_PAYMENT_KINDS);
207
209
  */
208
210
  export const externalPaymentSchema = z
209
211
  .object({
210
- id: z.string().min(1).max(64),
212
+ id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
211
213
  accountId: oxyAccountIdSchema,
212
214
  provider: externalPaymentProviderSchema,
213
215
  externalKind: externalPaymentKindSchema,
214
- externalRef: z.string().min(1).max(255),
216
+ externalRef: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)),
215
217
  amount: exactDecimalSchema,
216
218
  currency: currencyCodeSchema,
217
- ledgerEntryId: z.string().min(1).max(64),
218
- occurredAt: z.string().datetime(),
219
- createdAt: z.string().datetime(),
219
+ ledgerEntryId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
220
+ occurredAt: z.string().check(isoDateTime()),
221
+ createdAt: z.string().check(isoDateTime()),
220
222
  })
221
223
  .strict();
222
224
  /** Lifecycle of one automatic top-up. */
@@ -234,18 +236,18 @@ export const autoRechargeAttemptSchema = z
234
236
  .object({
235
237
  /** See `version.ts`: this shape is served to Console and to Alia. */
236
238
  schemaVersion: z.literal(1),
237
- id: z.string().min(1).max(64),
239
+ id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
238
240
  accountId: oxyAccountIdSchema,
239
241
  currency: currencyCodeSchema,
240
242
  requestedAmount: exactDecimalSchema,
241
243
  /** The spendable balance that triggered it — why this attempt exists. */
242
244
  balanceAtTrigger: exactDecimalSchema,
243
245
  status: autoRechargeStatusSchema,
244
- externalRef: z.string().min(1).max(255).optional(),
246
+ externalRef: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)).optional(),
245
247
  /** The processor's own decline code. Never a free-form message. */
246
- failureCode: z.string().min(1).max(64).optional(),
247
- createdAt: z.string().datetime(),
248
- updatedAt: z.string().datetime(),
248
+ failureCode: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)).optional(),
249
+ createdAt: z.string().check(isoDateTime()),
250
+ updatedAt: z.string().check(isoDateTime()),
249
251
  })
250
252
  .strict();
251
253
  /* -------------------------------------------------------------------------- */
@@ -280,18 +282,18 @@ export const reconciliationDiscrepancySchema = z
280
282
  .object({
281
283
  /** See `version.ts`: this shape is served to Console and to Alia. */
282
284
  schemaVersion: z.literal(1),
283
- id: z.string().min(1).max(64),
284
- runId: z.string().min(1).max(64),
285
+ id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
286
+ runId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
285
287
  kind: reconciliationDiscrepancyKindSchema,
286
288
  accountId: oxyAccountIdSchema.optional(),
287
- externalRef: z.string().min(1).max(255).optional(),
288
- ledgerEntryId: z.string().min(1).max(64).optional(),
289
+ externalRef: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)).optional(),
290
+ ledgerEntryId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)).optional(),
289
291
  /** What Oxy recorded. Absent for `missing_in_ledger`. */
290
292
  ledgerAmount: exactDecimalSchema.optional(),
291
293
  /** What the processor recorded. Absent for `missing_in_external`. */
292
294
  externalAmount: exactDecimalSchema.optional(),
293
295
  currency: currencyCodeSchema,
294
- createdAt: z.string().datetime(),
296
+ createdAt: z.string().check(isoDateTime()),
295
297
  })
296
298
  .strict();
297
299
  /**
@@ -306,19 +308,19 @@ export const reconciliationRunSchema = z
306
308
  .object({
307
309
  /** See `version.ts`: this shape is served to Console and to Alia. */
308
310
  schemaVersion: z.literal(1),
309
- id: z.string().min(1).max(64),
311
+ id: z.string().check(utf16MinLength(1)).check(utf16MaxLength(64)),
310
312
  provider: externalPaymentProviderSchema,
311
313
  /** Absent for a platform-wide pass. */
312
314
  accountId: oxyAccountIdSchema.optional(),
313
315
  currency: currencyCodeSchema,
314
- periodStart: z.string().datetime(),
315
- periodEnd: z.string().datetime(),
316
+ periodStart: z.string().check(isoDateTime()),
317
+ periodEnd: z.string().check(isoDateTime()),
316
318
  status: reconciliationRunStatusSchema,
317
319
  ledgerTotal: exactDecimalSchema,
318
320
  externalTotal: exactDecimalSchema,
319
- discrepancyCount: z.number().int().nonnegative().safe(),
320
- startedAt: z.string().datetime(),
321
- completedAt: z.string().datetime().optional(),
321
+ discrepancyCount: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
322
+ startedAt: z.string().check(isoDateTime()),
323
+ completedAt: z.string().check(isoDateTime()).optional(),
322
324
  })
323
325
  .strict();
324
326
  export const reconciliationReportSchema = z
@@ -1,3 +1,5 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  /**
2
4
  * The signed Alia model release manifest — the ingestion contract for a
3
5
  * first-party model release.
@@ -93,10 +95,10 @@ import { inferenceTimestampSchema, RESERVED_ALIA_PUBLISHER, sha256DigestSchema,
93
95
  export const aliaReleaseArtifactSchema = z
94
96
  .object({
95
97
  /** Path within the release, e.g. `model-00001-of-00004.safetensors`. */
96
- path: z.string().min(1).max(512),
98
+ path: z.string().check(utf16MinLength(1)).check(utf16MaxLength(512)),
97
99
  digest: sha256DigestSchema,
98
- sizeBytes: z.number().int().positive().safe(),
99
- mediaType: z.string().min(1).max(255).optional(),
100
+ sizeBytes: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
101
+ mediaType: z.string().check(utf16MinLength(1)).check(utf16MaxLength(255)).optional(),
100
102
  })
101
103
  .strict();
102
104
  /**
@@ -125,7 +127,7 @@ export const aliaReleaseSignatureSchema = z
125
127
  algorithm: z.enum(['ed25519']),
126
128
  canonicalization: z.enum(['jcs']),
127
129
  /** Opaque identifier of the public key. Resolving it is undecided. */
128
- keyId: z.string().min(1).max(256),
130
+ keyId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(256)),
129
131
  /**
130
132
  * Unpadded base64url. Exactly 86 characters, which is a 64-byte Ed25519
131
133
  * signature — the one algorithm above. A second algorithm moves this length
@@ -150,7 +152,7 @@ export const aliaModelReleaseManifestSchema = z
150
152
  /** See `version.ts`: an ingestion payload is a whole message on the wire. */
151
153
  schemaVersion: z.literal(1),
152
154
  /** The release's own identity, so ingestion is idempotent on it. */
153
- releaseId: z.string().min(1).max(128),
155
+ releaseId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
154
156
  issuedAt: inferenceTimestampSchema,
155
157
  /**
156
158
  * The revision being released. Carries its OWN `schemaVersion`, like
@@ -27,15 +27,7 @@
27
27
  */
28
28
  import { z } from 'zod';
29
29
  import { delegatedUserIdSchema, generationIdSchema, inferenceEnvironmentSchema, oxyAccountIdSchema, oxyApplicationIdSchema, oxyCredentialIdSchema, requestIdSchema, } from './identifiers.js';
30
- /**
31
- * The inference capability scopes the data plane needs to know about.
32
- *
33
- * A credential may carry many other Oxy scopes; only these cross the boundary,
34
- * because the data plane's authorization questions are exactly "may this caller
35
- * invoke", "may it read the catalogue", "may it read usage", "may it read or
36
- * write routing", "may it read or write provider connections". Everything else
37
- * is the control plane's business and is not the data plane's to hold.
38
- */
30
+ /** External caller limits recorded by Oxy. First-party instructions carry no scopes. */
39
31
  export const INFERENCE_SCOPES = [
40
32
  'inference:invoke',
41
33
  'inference:models:read',
@@ -70,13 +62,23 @@ export const billingPrincipalSchema = z
70
62
  * envelope; it does not re-derive access from its own database, because it has
71
63
  * no account graph to re-derive it from.
72
64
  */
73
- export const authenticatedPrincipalSchema = z.object({
65
+ const principalIdentity = {
74
66
  billing: billingPrincipalSchema,
75
67
  applicationId: oxyApplicationIdSchema,
76
68
  credentialId: oxyCredentialIdSchema,
77
69
  environment: inferenceEnvironmentSchema,
78
- inferenceScopes: z.array(inferenceScopeSchema),
79
- });
70
+ };
71
+ /** Oxy has authorized this instruction; the discriminator never grants customer access in Kaana. */
72
+ export const authenticatedPrincipalSchema = z.discriminatedUnion('authority', [
73
+ z.object({ ...principalIdentity, authority: z.literal('first_party') }).strict(),
74
+ z
75
+ .object({
76
+ ...principalIdentity,
77
+ authority: z.literal('external').optional(),
78
+ inferenceScopes: z.array(inferenceScopeSchema),
79
+ })
80
+ .strict(),
81
+ ]);
80
82
  /**
81
83
  * The attribution block carried by every request, receipt and ledger record.
82
84
  *
@@ -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(),