@oxy.so/contracts 5.7.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 (227) 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/client/consoleOnboarding.js +24 -0
  12. package/dist/cjs/client/index.js +7 -3
  13. package/dist/cjs/client/safety.js +9 -1
  14. package/dist/cjs/consoleOnboarding.js +56 -0
  15. package/dist/cjs/contentClaims.js +23 -14
  16. package/dist/cjs/deviceDirectory.js +11 -9
  17. package/dist/cjs/deviceSession.js +27 -25
  18. package/dist/cjs/email/messages.js +20 -18
  19. package/dist/cjs/emailAgentContext.js +11 -9
  20. package/dist/cjs/externalIdentity.js +15 -11
  21. package/dist/cjs/federationInstanceFetch.js +12 -7
  22. package/dist/cjs/identity.js +19 -17
  23. package/dist/cjs/identityLink.js +6 -4
  24. package/dist/cjs/identityProof.js +6 -4
  25. package/dist/cjs/inboxPush.js +5 -4
  26. package/dist/cjs/index.js +16 -6
  27. package/dist/cjs/inference/accountBilling.js +35 -33
  28. package/dist/cjs/inference/aliaModelRelease.js +9 -7
  29. package/dist/cjs/inference/attribution.js +14 -12
  30. package/dist/cjs/inference/catalogue.js +35 -29
  31. package/dist/cjs/inference/economics.js +24 -19
  32. package/dist/cjs/inference/embeddings.js +9 -7
  33. package/dist/cjs/inference/entitlement.js +17 -15
  34. package/dist/cjs/inference/errors.js +15 -8
  35. package/dist/cjs/inference/identifiers.js +33 -21
  36. package/dist/cjs/inference/inbox.js +37 -35
  37. package/dist/cjs/inference/modelDocumentation.js +16 -14
  38. package/dist/cjs/inference/money.js +5 -4
  39. package/dist/cjs/inference/priceVersion.js +10 -5
  40. package/dist/cjs/inference/providerConnection.js +21 -14
  41. package/dist/cjs/inference/realtime.js +88 -47
  42. package/dist/cjs/inference/request.js +27 -25
  43. package/dist/cjs/inference/routingPolicy.js +12 -10
  44. package/dist/cjs/inference/streamEvents.js +22 -16
  45. package/dist/cjs/inference/usage.js +32 -15
  46. package/dist/cjs/keyRecovery.js +8 -6
  47. package/dist/cjs/keyRotation.js +5 -4
  48. package/dist/cjs/linkedAccounts.js +22 -18
  49. package/dist/cjs/moderationReputation.js +29 -27
  50. package/dist/cjs/notifications.js +25 -9
  51. package/dist/cjs/numberChecks.js +45 -0
  52. package/dist/cjs/oauth.js +14 -12
  53. package/dist/cjs/organizations.js +23 -21
  54. package/dist/cjs/products/access.js +10 -8
  55. package/dist/cjs/products/billing.js +10 -8
  56. package/dist/cjs/products/checkout.js +22 -10
  57. package/dist/cjs/products/plans.js +15 -10
  58. package/dist/cjs/protocol.js +6 -5
  59. package/dist/cjs/recommendations.js +27 -19
  60. package/dist/cjs/reputation.js +15 -13
  61. package/dist/cjs/safety.js +46 -29
  62. package/dist/cjs/serviceToken.js +81 -2
  63. package/dist/cjs/sessionRevocation.js +8 -6
  64. package/dist/cjs/signIn.js +42 -24
  65. package/dist/cjs/stickers.js +19 -15
  66. package/dist/cjs/stringChecks.js +70 -0
  67. package/dist/cjs/transparency.js +14 -12
  68. package/dist/cjs/updates.js +24 -22
  69. package/dist/cjs/userInvalidation.js +7 -5
  70. package/dist/cjs/userResponse.js +8 -7
  71. package/dist/cjs/username.js +7 -6
  72. package/dist/esm/accountAccess.js +4 -3
  73. package/dist/esm/accountEmail.js +13 -5
  74. package/dist/esm/accountGraph.js +8 -7
  75. package/dist/esm/accountName.js +3 -2
  76. package/dist/esm/agency.js +90 -33
  77. package/dist/esm/agentKeys.js +21 -17
  78. package/dist/esm/appAssertions.js +11 -10
  79. package/dist/esm/applicationRoles.js +16 -9
  80. package/dist/esm/civic.js +8 -7
  81. package/dist/esm/client/check.js +61 -53
  82. package/dist/esm/client/consoleOnboarding.js +21 -0
  83. package/dist/esm/client/index.js +2 -1
  84. package/dist/esm/client/safety.js +8 -0
  85. package/dist/esm/consoleOnboarding.js +51 -0
  86. package/dist/esm/contentClaims.js +23 -14
  87. package/dist/esm/deviceDirectory.js +11 -9
  88. package/dist/esm/deviceSession.js +27 -25
  89. package/dist/esm/email/messages.js +18 -16
  90. package/dist/esm/emailAgentContext.js +11 -9
  91. package/dist/esm/externalIdentity.js +15 -11
  92. package/dist/esm/federationInstanceFetch.js +10 -5
  93. package/dist/esm/identity.js +17 -15
  94. package/dist/esm/identityLink.js +6 -4
  95. package/dist/esm/identityProof.js +6 -4
  96. package/dist/esm/inboxPush.js +3 -2
  97. package/dist/esm/index.js +5 -2
  98. package/dist/esm/inference/accountBilling.js +33 -31
  99. package/dist/esm/inference/aliaModelRelease.js +7 -5
  100. package/dist/esm/inference/attribution.js +14 -12
  101. package/dist/esm/inference/catalogue.js +33 -27
  102. package/dist/esm/inference/economics.js +22 -17
  103. package/dist/esm/inference/embeddings.js +9 -7
  104. package/dist/esm/inference/entitlement.js +15 -13
  105. package/dist/esm/inference/errors.js +13 -6
  106. package/dist/esm/inference/identifiers.js +31 -19
  107. package/dist/esm/inference/inbox.js +37 -35
  108. package/dist/esm/inference/modelDocumentation.js +14 -12
  109. package/dist/esm/inference/money.js +3 -2
  110. package/dist/esm/inference/priceVersion.js +8 -3
  111. package/dist/esm/inference/providerConnection.js +19 -12
  112. package/dist/esm/inference/realtime.js +85 -44
  113. package/dist/esm/inference/request.js +25 -23
  114. package/dist/esm/inference/routingPolicy.js +9 -7
  115. package/dist/esm/inference/streamEvents.js +20 -14
  116. package/dist/esm/inference/usage.js +30 -13
  117. package/dist/esm/keyRecovery.js +8 -6
  118. package/dist/esm/keyRotation.js +5 -4
  119. package/dist/esm/linkedAccounts.js +20 -16
  120. package/dist/esm/moderationReputation.js +27 -25
  121. package/dist/esm/notifications.js +23 -7
  122. package/dist/esm/numberChecks.js +41 -0
  123. package/dist/esm/oauth.js +14 -12
  124. package/dist/esm/organizations.js +23 -21
  125. package/dist/esm/products/access.js +10 -8
  126. package/dist/esm/products/billing.js +10 -8
  127. package/dist/esm/products/checkout.js +22 -10
  128. package/dist/esm/products/plans.js +15 -10
  129. package/dist/esm/protocol.js +4 -3
  130. package/dist/esm/recommendations.js +25 -17
  131. package/dist/esm/reputation.js +13 -11
  132. package/dist/esm/safety.js +45 -29
  133. package/dist/esm/serviceToken.js +80 -1
  134. package/dist/esm/sessionRevocation.js +6 -4
  135. package/dist/esm/signIn.js +42 -24
  136. package/dist/esm/stickers.js +17 -13
  137. package/dist/esm/stringChecks.js +63 -0
  138. package/dist/esm/transparency.js +14 -12
  139. package/dist/esm/updates.js +22 -20
  140. package/dist/esm/userInvalidation.js +4 -2
  141. package/dist/esm/userResponse.js +4 -3
  142. package/dist/esm/username.js +3 -2
  143. package/dist/types/accountAccess.d.ts +29 -70
  144. package/dist/types/accountEmail.d.ts +2 -14
  145. package/dist/types/accountGraph.d.ts +179 -171
  146. package/dist/types/accountName.d.ts +1 -1
  147. package/dist/types/accountSubject.d.ts +20 -93
  148. package/dist/types/agency.d.ts +528 -2924
  149. package/dist/types/agentKeys.d.ts +48 -421
  150. package/dist/types/appAssertions.d.ts +56 -210
  151. package/dist/types/applicationRoles.d.ts +30 -276
  152. package/dist/types/avatarCharacter.d.ts +1 -1
  153. package/dist/types/civic.d.ts +1 -13
  154. package/dist/types/client/agentKeys.d.ts +18 -18
  155. package/dist/types/client/appAssertions.d.ts +3 -3
  156. package/dist/types/client/check.d.ts +13 -13
  157. package/dist/types/client/consoleOnboarding.d.ts +16 -0
  158. package/dist/types/client/deviceDirectory.d.ts +51 -51
  159. package/dist/types/client/deviceSession.d.ts +14 -14
  160. package/dist/types/client/index.d.ts +2 -1
  161. package/dist/types/client/organizations.d.ts +25 -25
  162. package/dist/types/client/products.d.ts +33 -33
  163. package/dist/types/client/recommendations.d.ts +2 -2
  164. package/dist/types/client/safety.d.ts +53 -45
  165. package/dist/types/client/sessionStatus.d.ts +4 -4
  166. package/dist/types/client/signIn.d.ts +1 -1
  167. package/dist/types/commonsSignIn.d.ts +4 -1
  168. package/dist/types/consoleOnboarding.d.ts +57 -0
  169. package/dist/types/contentClaims.d.ts +24 -180
  170. package/dist/types/deviceDirectory.d.ts +109 -1040
  171. package/dist/types/deviceSession.d.ts +36 -298
  172. package/dist/types/email/messages.d.ts +212 -1793
  173. package/dist/types/emailAgentContext.d.ts +10 -194
  174. package/dist/types/externalIdentity.d.ts +121 -615
  175. package/dist/types/federationInstanceFetch.d.ts +3 -32
  176. package/dist/types/identity.d.ts +15 -92
  177. package/dist/types/identityLink.d.ts +6 -84
  178. package/dist/types/identityProof.d.ts +5 -17
  179. package/dist/types/inboxPush.d.ts +1 -9
  180. package/dist/types/index.d.ts +6 -3
  181. package/dist/types/inference/accountBilling.d.ts +151 -488
  182. package/dist/types/inference/aliaModelRelease.d.ts +42 -439
  183. package/dist/types/inference/attribution.d.ts +75 -104
  184. package/dist/types/inference/catalogue.d.ts +417 -1599
  185. package/dist/types/inference/economics.d.ts +69 -276
  186. package/dist/types/inference/embeddings.d.ts +110 -406
  187. package/dist/types/inference/entitlement.d.ts +80 -335
  188. package/dist/types/inference/errors.d.ts +90 -102
  189. package/dist/types/inference/identifiers.d.ts +12 -4
  190. package/dist/types/inference/inbox.d.ts +105 -420
  191. package/dist/types/inference/modelDocumentation.d.ts +201 -1390
  192. package/dist/types/inference/money.d.ts +65 -32
  193. package/dist/types/inference/priceVersion.d.ts +53 -120
  194. package/dist/types/inference/providerConnection.d.ts +253 -710
  195. package/dist/types/inference/realtime.d.ts +954 -6825
  196. package/dist/types/inference/request.d.ts +300 -2572
  197. package/dist/types/inference/routingPolicy.d.ts +95 -503
  198. package/dist/types/inference/streamEvents.d.ts +253 -721
  199. package/dist/types/inference/usage.d.ts +317 -950
  200. package/dist/types/keyRecovery.d.ts +3 -51
  201. package/dist/types/keyRotation.d.ts +3 -38
  202. package/dist/types/linkedAccounts.d.ts +50 -236
  203. package/dist/types/moderationReputation.d.ts +81 -14
  204. package/dist/types/notifications.d.ts +19 -51
  205. package/dist/types/numberChecks.d.ts +9 -0
  206. package/dist/types/oauth.d.ts +101 -809
  207. package/dist/types/organizations.d.ts +268 -921
  208. package/dist/types/oxyRecordTypes.d.ts +11 -1
  209. package/dist/types/products/access.d.ts +125 -775
  210. package/dist/types/products/billing.d.ts +67 -503
  211. package/dist/types/products/checkout.d.ts +16 -69
  212. package/dist/types/products/plans.d.ts +33 -366
  213. package/dist/types/recommendations.d.ts +76 -389
  214. package/dist/types/reputation.d.ts +37 -5
  215. package/dist/types/safety.d.ts +410 -2050
  216. package/dist/types/serviceToken.d.ts +247 -7
  217. package/dist/types/sessionRevocation.d.ts +2 -17
  218. package/dist/types/sessionStatus.d.ts +27 -115
  219. package/dist/types/signIn.d.ts +53 -553
  220. package/dist/types/stickers.d.ts +67 -819
  221. package/dist/types/stringChecks.d.ts +16 -0
  222. package/dist/types/transparency.d.ts +14 -302
  223. package/dist/types/updates.d.ts +60 -316
  224. package/dist/types/userInvalidation.d.ts +4 -13
  225. package/dist/types/userResponse.d.ts +302 -2400
  226. package/dist/types/username.d.ts +3 -3
  227. package/package.json +3 -4
@@ -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.
@@ -1,12 +1,14 @@
1
+ import { integerCheck } from '../numberChecks.js';
2
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  import { z } from 'zod';
2
4
  import { inferenceErrorSchema } from './errors.js';
3
- const inboxTextSchema = z.string().trim().min(1).max(20000);
4
- const inboxMessageIdSchema = z.string().min(1).max(128);
5
+ const inboxTextSchema = z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(20000));
6
+ const inboxMessageIdSchema = z.string().check(utf16MinLength(1)).check(utf16MaxLength(128));
5
7
  const DAILY_BRIEF_MIN_WINDOW_MS = 23 * 60 * 60 * 1000;
6
8
  const DAILY_BRIEF_MAX_WINDOW_MS = 25 * 60 * 60 * 1000;
7
9
  const inboxUtcTimestampSchema = z
8
10
  .string()
9
- .datetime({ offset: false })
11
+ .check(isoDateTime({ offset: false }))
10
12
  .refine((value) => value.endsWith('Z'), 'Timestamp must use the UTC Z suffix');
11
13
  export const inboxComposeRequestSchema = z.discriminatedUnion('operation', [
12
14
  z.object({
@@ -38,7 +40,7 @@ export const inboxDailyBriefRequestSchema = z.object({
38
40
  startAt: inboxUtcTimestampSchema,
39
41
  endAt: inboxUtcTimestampSchema,
40
42
  /** BCP 47 tag of the language the brief is written in; English when absent. */
41
- locale: z.string().regex(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/).max(35).optional(),
43
+ locale: z.string().regex(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/).check(utf16MaxLength(35)).optional(),
42
44
  }).strict().superRefine((value, context) => {
43
45
  const durationMs = Date.parse(value.endAt) - Date.parse(value.startAt);
44
46
  if (!Number.isFinite(durationMs) || durationMs <= 0) {
@@ -57,20 +59,20 @@ export const inboxDailyBriefRequestSchema = z.object({
57
59
  });
58
60
  }
59
61
  });
60
- export const inboxNaturalSearchRequestSchema = z.object({ query: z.string().trim().min(1).max(512) }).strict();
62
+ export const inboxNaturalSearchRequestSchema = z.object({ query: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(512)) }).strict();
61
63
  export const inboxMessageInferenceParamsSchema = z.object({ messageId: inboxMessageIdSchema }).strict();
62
64
  export const inboxInferenceTextResponseSchema = z.object({
63
65
  schemaVersion: z.literal(1),
64
- requestId: z.string().min(1).max(128),
65
- generationId: z.string().min(1).max(128).optional(),
66
- text: z.string().max(40000),
66
+ requestId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
67
+ generationId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)).optional(),
68
+ text: z.string().check(utf16MaxLength(40000)),
67
69
  }).strict();
68
70
  export const inboxNaturalSearchResponseSchema = z.object({
69
71
  query: z.object({
70
- q: z.string().max(512).optional(),
71
- from: z.string().max(320).optional(),
72
- to: z.string().max(320).optional(),
73
- subject: z.string().max(512).optional(),
72
+ q: z.string().check(utf16MaxLength(512)).optional(),
73
+ from: z.string().check(utf16MaxLength(320)).optional(),
74
+ to: z.string().check(utf16MaxLength(320)).optional(),
75
+ subject: z.string().check(utf16MaxLength(512)).optional(),
74
76
  hasAttachment: z.boolean().optional(),
75
77
  starred: z.boolean().optional(),
76
78
  unread: z.boolean().optional(),
@@ -78,7 +80,7 @@ export const inboxNaturalSearchResponseSchema = z.object({
78
80
  before: z.string().date().optional(),
79
81
  mailbox: z.enum(['inbox', 'sent', 'drafts', 'trash', 'spam', 'archive']).optional(),
80
82
  }).strict(),
81
- interpretation: z.string().max(1000),
83
+ interpretation: z.string().check(utf16MaxLength(1000)),
82
84
  }).strict();
83
85
  /** Where the brief puts a message: it asks something of the owner, it is today's news, or it is still unread from before. */
84
86
  export const INBOX_DAILY_BRIEF_SECTIONS = ['needs_you', 'today', 'earlier'];
@@ -90,50 +92,50 @@ export const INBOX_DAILY_BRIEF_SECTIONS = ['needs_you', 'today', 'earlier'];
90
92
  */
91
93
  export const inboxDailyBriefResponseSchema = z.object({
92
94
  schemaVersion: z.literal(1),
93
- requestId: z.string().min(1).max(128),
94
- generationId: z.string().min(1).max(128).optional(),
95
- summary: z.string().max(400),
95
+ requestId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
96
+ generationId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)).optional(),
97
+ summary: z.string().check(utf16MaxLength(400)),
96
98
  /** Returned only when the caller opts in with `?includeActions=true`. */
97
99
  actions: z.array(z.object({
98
- label: z.string().trim().min(1).max(40),
99
- prompt: z.string().trim().min(1).max(600),
100
+ label: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(40)),
101
+ prompt: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(600)),
100
102
  messageIds: z.array(inboxMessageIdSchema).min(1).max(10),
101
103
  }).strict()).min(2).max(5).optional(),
102
104
  counts: z.object({
103
- received: z.number().int().nonnegative(),
104
- unread: z.number().int().nonnegative(),
105
- starred: z.number().int().nonnegative(),
106
- earlierUnread: z.number().int().nonnegative(),
105
+ received: z.number().check(integerCheck()).nonnegative(),
106
+ unread: z.number().check(integerCheck()).nonnegative(),
107
+ starred: z.number().check(integerCheck()).nonnegative(),
108
+ earlierUnread: z.number().check(integerCheck()).nonnegative(),
107
109
  }).strict(),
108
110
  items: z.array(z.object({
109
111
  messageId: inboxMessageIdSchema,
110
112
  section: z.enum(INBOX_DAILY_BRIEF_SECTIONS),
111
- note: z.string().max(200),
112
- from: z.object({ name: z.string().max(998).nullable(), address: z.string().max(320) }).strict(),
113
- subject: z.string().max(998),
114
- receivedAt: z.string().datetime(),
113
+ note: z.string().check(utf16MaxLength(200)),
114
+ from: z.object({ name: z.string().check(utf16MaxLength(998)).nullable(), address: z.string().check(utf16MaxLength(320)) }).strict(),
115
+ subject: z.string().check(utf16MaxLength(998)),
116
+ receivedAt: z.string().check(isoDateTime()),
115
117
  unread: z.boolean(),
116
118
  hasAttachments: z.boolean(),
117
119
  }).strict()).max(20),
118
120
  }).strict();
119
121
  export const inboxSmartRepliesResponseSchema = z.object({
120
- replies: z.array(z.string().trim().min(1).max(500)).max(3),
122
+ replies: z.array(z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(500))).max(3),
121
123
  }).strict();
122
124
  export const inboxThreadSummaryResponseSchema = z.object({
123
- summary: z.string().max(4000),
124
- keyPoints: z.array(z.string().max(1000)).max(12),
125
+ summary: z.string().check(utf16MaxLength(4000)),
126
+ keyPoints: z.array(z.string().check(utf16MaxLength(1000))).max(12),
125
127
  actionItems: z.array(z.object({
126
- text: z.string().max(1000),
127
- owner: z.string().max(320).nullable(),
128
- deadline: z.string().max(128).nullable(),
128
+ text: z.string().check(utf16MaxLength(1000)),
129
+ owner: z.string().check(utf16MaxLength(320)).nullable(),
130
+ deadline: z.string().check(utf16MaxLength(128)).nullable(),
129
131
  }).strict()).max(12),
130
132
  }).strict();
131
133
  export const inboxInferenceStreamEventSchema = z.discriminatedUnion('type', [
132
- z.object({ type: z.literal('delta'), text: z.string().min(1).max(16384) }).strict(),
134
+ z.object({ type: z.literal('delta'), text: z.string().check(utf16MinLength(1)).check(utf16MaxLength(16384)) }).strict(),
133
135
  z.object({
134
136
  type: z.literal('done'),
135
- requestId: z.string().min(1).max(128),
136
- generationId: z.string().min(1).max(128).optional(),
137
+ requestId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
138
+ generationId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)).optional(),
137
139
  }).strict(),
138
140
  z.object({ type: z.literal('error'), error: inferenceErrorSchema }).strict(),
139
141
  ]);
@@ -1,3 +1,5 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  /**
2
4
  * Model documentation: what a first-party release must DECLARE, what a
3
5
  * downstream developer may READ, and the request that ingests both.
@@ -134,7 +136,7 @@ export const modelSystemicRiskTierSchema = z.enum([
134
136
  */
135
137
  export const trainingComputeFlopsSchema = z
136
138
  .string()
137
- .max(40)
139
+ .check(utf16MaxLength(40))
138
140
  .regex(/^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:e\+?(?:0|[1-9][0-9]?))?$/, 'training compute must be a decimal or scientific figure, e.g. 4.2e25');
139
141
  /**
140
142
  * Article 51(2)'s presumption threshold, as a number.
@@ -165,13 +167,13 @@ export const SYSTEMIC_RISK_COMPUTE_THRESHOLD_FLOPS = 1e25;
165
167
  export const modelDownstreamDocumentationSchema = z
166
168
  .object({
167
169
  /** Annex XI §1(2), Annex XII §1(a): the tasks the model is intended for. */
168
- intendedTasks: z.string().min(1).max(2000).optional(),
170
+ intendedTasks: z.string().check(utf16MinLength(1)).check(utf16MaxLength(2000)).optional(),
169
171
  /** Annex XI §1(4), Annex XII §1(a). */
170
172
  distributionMethods: z.array(modelDistributionMethodSchema).min(1),
171
173
  /** Annex XI §1(5), reachable through Annex XII §1(a) ("points 1 to 5"). */
172
- architecture: z.string().min(1).max(500).optional(),
174
+ architecture: z.string().check(utf16MinLength(1)).check(utf16MaxLength(500)).optional(),
173
175
  /** Annex XI §1(5): the number of parameters. */
174
- parameterCount: z.number().int().positive().safe().optional(),
176
+ parameterCount: z.number().check(integerCheck()).positive().check(safeNumberCheck()).optional(),
175
177
  /** Article 53(1)(d): the publicly available summary of training content. */
176
178
  trainingDataSummaryUrl: inferenceHttpsUrlSchema,
177
179
  /**
@@ -210,13 +212,13 @@ export const modelGpaiDocumentationSchema = modelDownstreamDocumentationSchema
210
212
  /** Annex XI §2(b): the computational resources used for training. */
211
213
  trainingComputeFlops: trainingComputeFlopsSchema.optional(),
212
214
  /** Annex XI §2(b): the training time. */
213
- trainingTimeHours: z.number().positive().safe().optional(),
215
+ trainingTimeHours: z.number().positive().check(safeNumberCheck()).optional(),
214
216
  /**
215
217
  * Annex XI §2(c): the known or ESTIMATED energy consumption. The Act asks
216
218
  * for an estimate where the figure is not known, so absence here means the
217
219
  * Annex XI set is exempt rather than that the number was hard to obtain.
218
220
  */
219
- energyConsumptionMwh: z.number().nonnegative().safe().optional(),
221
+ energyConsumptionMwh: z.number().nonnegative().check(safeNumberCheck()).optional(),
220
222
  /**
221
223
  * Article 55(1)(a): the model evaluation, including adversarial testing,
222
224
  * performed for a model with systemic risk. A pointer, like every other
@@ -309,8 +311,8 @@ export const modelGpaiDocumentationSchema = modelDownstreamDocumentationSchema
309
311
  */
310
312
  export const modelLineDeclarationSchema = z
311
313
  .object({
312
- displayName: z.string().min(1).max(200),
313
- description: z.string().max(4000).optional(),
314
+ displayName: z.string().check(utf16MinLength(1)).check(utf16MaxLength(200)),
315
+ description: z.string().check(utf16MaxLength(4000)).optional(),
314
316
  capabilities: modelCapabilitiesSchema,
315
317
  knowledgeCutoff: inferenceDateSchema.optional(),
316
318
  releasedOn: inferenceDateSchema.optional(),
@@ -353,15 +355,15 @@ export const modelReleaseIngestionResultSchema = z
353
355
  .object({
354
356
  /** See `version.ts`: served on its own, so it is versioned. */
355
357
  schemaVersion: z.literal(1),
356
- releaseId: z.string().min(1).max(128),
358
+ releaseId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
357
359
  modelId: modelIdSchema,
358
360
  revision: modelRevisionLabelSchema,
359
361
  reference: modelReferenceSchema,
360
362
  /** Whether this request created the release, or found it already ingested. */
361
363
  outcome: z.enum(['ingested', 'already_ingested']),
362
- artifactCount: z.number().int().positive().safe(),
363
- signatureCount: z.number().int().positive().safe(),
364
- evaluationCount: z.number().int().nonnegative().safe(),
364
+ artifactCount: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
365
+ signatureCount: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
366
+ evaluationCount: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
365
367
  ingestedAt: inferenceTimestampSchema,
366
368
  })
367
369
  .strict();
@@ -1,3 +1,4 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
1
2
  /**
2
3
  * Money and usage units for the inference contracts.
3
4
  *
@@ -200,7 +201,7 @@ export const usageUnitSchema = z.enum(USAGE_UNITS);
200
201
  export const usageQuantitySchema = z
201
202
  .object({
202
203
  unit: usageUnitSchema,
203
- quantity: z.number().int().nonnegative().safe(),
204
+ quantity: z.number().check(integerCheck()).nonnegative().check(safeNumberCheck()),
204
205
  })
205
206
  .strict();
206
207
  /**
@@ -225,7 +226,7 @@ export const unitPriceSchema = z
225
226
  .object({
226
227
  unit: usageUnitSchema,
227
228
  amount: exactDecimalSchema,
228
- per: z.number().int().positive().safe(),
229
+ per: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
229
230
  currency: currencyCodeSchema,
230
231
  })
231
232
  .strict();
@@ -1,3 +1,4 @@
1
+ import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
2
  /**
2
3
  * Price versions — the immutable snapshots customer pricing is quoted and
3
4
  * settled against.
@@ -38,7 +39,7 @@ export const priceVersionSchema = z
38
39
  .object({
39
40
  /** See `version.ts`: served on its own by the catalogue, so it is versioned. */
40
41
  schemaVersion: z.literal(1),
41
- priceVersionId: z.string().min(1).max(128),
42
+ priceVersionId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
42
43
  status: priceVersionStatusSchema,
43
44
  modelReference: modelReferenceSchema,
44
45
  provider: inferenceProviderSlugSchema,
@@ -48,7 +49,11 @@ export const priceVersionSchema = z
48
49
  /** Absent while this version is the current one. */
49
50
  effectiveUntil: inferenceTimestampSchema.optional(),
50
51
  /** The version this one replaced, absent for the first version of a route. */
51
- supersedesPriceVersionId: z.string().min(1).max(128).optional(),
52
+ supersedesPriceVersionId: z
53
+ .string()
54
+ .check(utf16MinLength(1))
55
+ .check(utf16MaxLength(128))
56
+ .optional(),
52
57
  createdAt: inferenceTimestampSchema,
53
58
  })
54
59
  .superRefine((priceVersion, ctx) => {
@@ -100,7 +105,7 @@ export const priceVersionSchema = z
100
105
  */
101
106
  export const priceSnapshotSchema = z
102
107
  .object({
103
- priceVersionId: z.string().min(1).max(128),
108
+ priceVersionId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
104
109
  currency: currencyCodeSchema,
105
110
  unitPrices: z.array(unitPriceSchema).min(1),
106
111
  })
@@ -1,3 +1,5 @@
1
+ import { integerCheck, safeNumberCheck } from '../numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from '../stringChecks.js';
1
3
  /**
2
4
  * BYOK provider connections — the metadata Oxy holds about a customer's own
3
5
  * upstream provider credential.
@@ -66,7 +68,7 @@ export const kaanaCredentialIdentitySchema = z
66
68
  .strict();
67
69
  const kaanaCredentialOperationActorSchema = z
68
70
  .string()
69
- .min(1)
71
+ .check(utf16MinLength(1))
70
72
  .refine((value) => new TextEncoder().encode(value).byteLength <= 256 &&
71
73
  value === value.trim() &&
72
74
  !/[\r\n]/.test(value), {
@@ -108,8 +110,8 @@ function isVisibleASCIIProviderCredential(value) {
108
110
  }
109
111
  const kaanaCredentialSecretBase64Schema = z
110
112
  .string()
111
- .min(1)
112
- .max(8192)
113
+ .check(utf16MinLength(1))
114
+ .check(utf16MaxLength(8192))
113
115
  .regex(PADDED_BASE64_PATTERN)
114
116
  .refine(isVisibleASCIIProviderCredential, {
115
117
  message: 'a decoded provider credential is 1-4096 visible ASCII bytes',
@@ -132,7 +134,7 @@ export const kaanaCredentialRotateMutationSchema = kaanaCredentialIdentitySchema
132
134
  credentialHandle: kaanaCredentialHandleSchema,
133
135
  expectedRevision: z
134
136
  .number()
135
- .int()
137
+ .check(integerCheck())
136
138
  .positive()
137
139
  .max(Number.MAX_SAFE_INTEGER - 1),
138
140
  secretBase64: kaanaCredentialSecretBase64Schema,
@@ -147,7 +149,7 @@ export const kaanaCredentialRevokeMutationSchema = kaanaCredentialIdentitySchema
147
149
  credentialHandle: kaanaCredentialHandleSchema,
148
150
  expectedRevision: z
149
151
  .number()
150
- .int()
152
+ .check(integerCheck())
151
153
  .positive()
152
154
  .max(Number.MAX_SAFE_INTEGER - 1),
153
155
  })
@@ -172,7 +174,7 @@ export const kaanaCredentialRotateOutcomeRequestSchema = kaanaCredentialIdentity
172
174
  credentialHandle: kaanaCredentialHandleSchema,
173
175
  expectedRevision: z
174
176
  .number()
175
- .int()
177
+ .check(integerCheck())
176
178
  .positive()
177
179
  .max(Number.MAX_SAFE_INTEGER - 1),
178
180
  })
@@ -185,7 +187,7 @@ export const kaanaCredentialRevokeOutcomeRequestSchema = kaanaCredentialIdentity
185
187
  credentialHandle: kaanaCredentialHandleSchema,
186
188
  expectedRevision: z
187
189
  .number()
188
- .int()
190
+ .check(integerCheck())
189
191
  .positive()
190
192
  .max(Number.MAX_SAFE_INTEGER - 1),
191
193
  })
@@ -202,7 +204,7 @@ export const kaanaCredentialAppliedOutcomeSchema = z
202
204
  action: kaanaCredentialOperationActionSchema,
203
205
  status: z.literal('applied'),
204
206
  credentialHandle: kaanaCredentialHandleSchema,
205
- revision: z.number().int().positive().safe(),
207
+ revision: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
206
208
  })
207
209
  .strict();
208
210
  export const kaanaCredentialConflictOutcomeSchema = z
@@ -230,7 +232,7 @@ export const kaanaCredentialValidationTaskSchema = kaanaCredentialIdentitySchema
230
232
  operationId: kaanaCredentialOperationIdSchema,
231
233
  applicationId: oxyApplicationIdSchema,
232
234
  credentialHandle: kaanaCredentialHandleSchema,
233
- credentialRevision: z.number().int().positive().safe(),
235
+ credentialRevision: z.number().check(integerCheck()).positive().check(safeNumberCheck()),
234
236
  deploymentId: deploymentIdSchema,
235
237
  })
236
238
  .strict();
@@ -303,7 +305,7 @@ export const providerCredentialValidationOperationSchema = z
303
305
  .object({
304
306
  schemaVersion: z.literal(1),
305
307
  operationId: kaanaCredentialOperationIdSchema,
306
- connectionId: z.string().min(1).max(128),
308
+ connectionId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
307
309
  applicationId: oxyApplicationIdSchema,
308
310
  deploymentId: deploymentIdSchema,
309
311
  state: kaanaCredentialValidationOutcomeStateSchema,
@@ -398,7 +400,7 @@ export const providerConnectionSchema = z
398
400
  .object({
399
401
  /** See `version.ts`: exchanged with the data plane and rendered by Console. */
400
402
  schemaVersion: z.literal(2),
401
- connectionId: z.string().min(1).max(128),
403
+ connectionId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
402
404
  provider: inferenceProviderSlugSchema,
403
405
  /** The Oxy account that owns the connection and answers for its use. */
404
406
  ownerAccountId: oxyAccountIdSchema,
@@ -407,7 +409,12 @@ export const providerConnectionSchema = z
407
409
  status: providerConnectionStatusSchema,
408
410
  custodyState: providerCredentialCustodyStateSchema,
409
411
  credentialHandle: kaanaCredentialHandleSchema.optional(),
410
- credentialRevision: z.number().int().positive().safe().optional(),
412
+ credentialRevision: z
413
+ .number()
414
+ .check(integerCheck())
415
+ .positive()
416
+ .check(safeNumberCheck())
417
+ .optional(),
411
418
  validation: providerConnectionValidationSchema,
412
419
  /**
413
420
  * Always `true` for a BYOK connection: the provider bills the customer's own