@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 } from '../numberChecks.js';
2
+ import { isoDateTime } from '../stringChecks.js';
1
3
  /**
2
4
  * Wire contract for the Inbox read API (`/email/*` on oxy-api).
3
5
  *
@@ -21,7 +23,7 @@
21
23
  */
22
24
  import { z } from 'zod';
23
25
  /** An ISO-8601 instant as `Date.prototype.toJSON` writes it. */
24
- const isoInstant = z.string().datetime();
26
+ const isoInstant = z.string().check(isoDateTime());
25
27
  // ─── Vocabularies ───────────────────────────────────────────────────
26
28
  /** Structured data cards the AI extractor can emit. */
27
29
  export const MESSAGE_CARD_TYPES = ['trip', 'purchase', 'event', 'bill', 'package'];
@@ -138,8 +140,8 @@ export const emailMessageHighlightSchema = z.object({
138
140
  */
139
141
  export const emailMessageDeliverySchema = z.object({
140
142
  state: z.enum(EMAIL_DELIVERY_STATES),
141
- attempts: z.number().int(),
142
- maxAttempts: z.number().int(),
143
+ attempts: z.number().check(integerCheck()),
144
+ maxAttempts: z.number().check(integerCheck()),
143
145
  nextAttemptAt: isoInstant.nullable(),
144
146
  error: z.string().nullable(),
145
147
  errorCode: z.enum(EMAIL_DELIVERY_ERROR_CODES).nullable().catch(null),
@@ -186,14 +188,14 @@ export const emailMessageSchema = z.object({
186
188
  receivedAt: isoInstant,
187
189
  createdAt: isoInstant,
188
190
  updatedAt: isoInstant,
189
- draftRevision: z.number().int().min(1),
191
+ draftRevision: z.number().check(integerCheck()).min(1),
190
192
  /** Present only on the reads that return bodies (single message, thread). */
191
193
  text: z.string().nullable().optional(),
192
194
  html: z.string().nullable().optional(),
193
195
  headers: z.record(z.string(), z.string()).optional(),
194
196
  senderAvatarPath: z.string().nullable().optional(),
195
197
  /** Present only on list reads that walked the thread. */
196
- threadCount: z.number().int().optional(),
198
+ threadCount: z.number().check(integerCheck()).optional(),
197
199
  threadParticipants: z.array(z.string()).optional(),
198
200
  /**
199
201
  * Present only on a message the user sent through Oxy since delivery was
@@ -210,9 +212,9 @@ export const emailMailboxSchema = z.object({
210
212
  name: z.string(),
211
213
  path: z.string(),
212
214
  specialUse: z.string().nullable(),
213
- retentionDays: z.number().int().nullable(),
214
- totalMessages: z.number().int(),
215
- unseenMessages: z.number().int(),
215
+ retentionDays: z.number().check(integerCheck()).nullable(),
216
+ totalMessages: z.number().check(integerCheck()),
217
+ unseenMessages: z.number().check(integerCheck()),
216
218
  size: z.number(),
217
219
  createdAt: isoInstant,
218
220
  updatedAt: isoInstant,
@@ -224,7 +226,7 @@ export const emailUserLabelSchema = z.object({
224
226
  userId: z.string(),
225
227
  name: z.string(),
226
228
  color: z.string(),
227
- order: z.number().int(),
229
+ order: z.number().check(integerCheck()),
228
230
  system: z.literal(false),
229
231
  createdAt: isoInstant,
230
232
  updatedAt: isoInstant,
@@ -234,7 +236,7 @@ export const emailSystemLabelSchema = z.object({
234
236
  _id: z.string(),
235
237
  name: z.string(),
236
238
  color: z.string(),
237
- order: z.number().int(),
239
+ order: z.number().check(integerCheck()),
238
240
  system: z.literal(true),
239
241
  });
240
242
  export const emailLabelSchema = z.discriminatedUnion('system', [
@@ -259,7 +261,7 @@ export const emailFilterSchema = z.object({
259
261
  name: z.string(),
260
262
  enabled: z.boolean(),
261
263
  matchAll: z.boolean(),
262
- order: z.number().int(),
264
+ order: z.number().check(integerCheck()),
263
265
  conditions: z.array(emailFilterConditionSchema),
264
266
  actions: z.array(emailFilterActionSchema),
265
267
  createdAt: isoInstant,
@@ -275,7 +277,7 @@ export const emailBundleSchema = z.object({
275
277
  matchLabels: z.array(z.string()),
276
278
  enabled: z.boolean(),
277
279
  collapsed: z.boolean(),
278
- order: z.number().int(),
280
+ order: z.number().check(integerCheck()),
279
281
  createdAt: isoInstant,
280
282
  updatedAt: isoInstant,
281
283
  });
@@ -285,9 +287,9 @@ export const emailBundledInboxSchema = z.object({
285
287
  bundles: z.array(z.object({
286
288
  bundle: emailBundleSchema,
287
289
  messages: z.array(emailMessageSchema),
288
- unreadCount: z.number().int(),
290
+ unreadCount: z.number().check(integerCheck()),
289
291
  })),
290
- total: z.number().int(),
292
+ total: z.number().check(integerCheck()),
291
293
  });
292
294
  /** An address-book entry. `company` and `notes` are `null` when unset. */
293
295
  export const emailContactSchema = z.object({
@@ -312,8 +314,8 @@ export const emailOutboxSchema = z.object({
312
314
  id: z.string(),
313
315
  messageId: z.string(),
314
316
  status: z.enum(EMAIL_OUTBOX_STATUSES),
315
- attempts: z.number().int(),
316
- maxAttempts: z.number().int(),
317
+ attempts: z.number().check(integerCheck()),
318
+ maxAttempts: z.number().check(integerCheck()),
317
319
  terminal: z.boolean(),
318
320
  nextAttemptAt: isoInstant,
319
321
  lastError: z.string().nullable(),
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { isoDateTime, utf16MinLength } from './stringChecks.js';
1
3
  import { z } from 'zod';
2
4
  export const emailContextAddressSchema = z
3
5
  .object({
@@ -7,29 +9,29 @@ export const emailContextAddressSchema = z
7
9
  .strict();
8
10
  export const emailContextMailboxSchema = z
9
11
  .object({
10
- mailboxId: z.string().min(1),
12
+ mailboxId: z.string().check(utf16MinLength(1)),
11
13
  name: z.string(),
12
14
  path: z.string(),
13
- totalMessages: z.number().int().nonnegative(),
14
- unseenMessages: z.number().int().nonnegative(),
15
+ totalMessages: z.number().check(integerCheck()).nonnegative(),
16
+ unseenMessages: z.number().check(integerCheck()).nonnegative(),
15
17
  })
16
18
  .strict();
17
19
  export const emailContextMessageSchema = z
18
20
  .object({
19
- messageId: z.string().min(1),
20
- mailboxId: z.string().min(1),
21
+ messageId: z.string().check(utf16MinLength(1)),
22
+ mailboxId: z.string().check(utf16MinLength(1)),
21
23
  from: emailContextAddressSchema,
22
24
  subject: z.string(),
23
- receivedAt: z.string().datetime(),
25
+ receivedAt: z.string().check(isoDateTime()),
24
26
  seen: z.boolean(),
25
27
  answered: z.boolean(),
26
28
  })
27
29
  .strict();
28
30
  export const emailAgentContextSchema = z
29
31
  .object({
30
- accountId: z.string().min(1),
31
- resourceMailboxId: z.string().min(1).nullable(),
32
- generatedAt: z.string().datetime(),
32
+ accountId: z.string().check(utf16MinLength(1)),
33
+ resourceMailboxId: z.string().check(utf16MinLength(1)).nullable(),
34
+ generatedAt: z.string().check(isoDateTime()),
33
35
  mailboxes: z.array(emailContextMailboxSchema),
34
36
  recentUnread: z.array(emailContextMessageSchema),
35
37
  needsResponse: z.array(emailContextMessageSchema),
@@ -1,3 +1,4 @@
1
+ import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
2
  import { z } from 'zod';
2
3
  import { userResponseSchema } from './userResponse.js';
3
4
  /**
@@ -7,26 +8,26 @@ import { userResponseSchema } from './userResponse.js';
7
8
  */
8
9
  export const externalIdentityProtocolSchema = z.enum(['activitypub', 'atproto', 'instagram-graph']);
9
10
  export const externalIdentityReferenceSchema = z.object({
10
- canonicalAcct: z.string().min(1),
11
- network: z.string().min(1),
11
+ canonicalAcct: z.string().check(utf16MinLength(1)),
12
+ network: z.string().check(utf16MinLength(1)),
12
13
  protocol: externalIdentityProtocolSchema,
13
- actorUri: z.string().min(1),
14
- transportAcct: z.string().min(1),
15
- sourceUserId: z.string().min(1),
14
+ actorUri: z.string().check(utf16MinLength(1)),
15
+ transportAcct: z.string().check(utf16MinLength(1)),
16
+ sourceUserId: z.string().check(utf16MinLength(1)),
16
17
  });
17
18
  export const resolveExternalIdentityRequestSchema = z
18
19
  .object({
19
- actorUri: z.string().min(1).max(2048).optional(),
20
- handle: z.string().min(1).max(2048).optional(),
21
- transportAcct: z.string().max(320).optional(),
20
+ actorUri: z.string().check(utf16MinLength(1)).check(utf16MaxLength(2048)).optional(),
21
+ handle: z.string().check(utf16MinLength(1)).check(utf16MaxLength(2048)).optional(),
22
+ transportAcct: z.string().check(utf16MaxLength(320)).optional(),
22
23
  protocol: externalIdentityProtocolSchema.optional(),
23
24
  })
24
25
  .refine((value) => Boolean(value.actorUri) !== Boolean(value.handle), 'Exactly one actorUri or handle is required');
25
26
  export const resolveExternalIdentityResponseSchema = z
26
27
  .object({
27
28
  user: userResponseSchema.extend({
28
- id: z.string().min(1),
29
- username: z.string().min(1),
29
+ id: z.string().check(utf16MinLength(1)),
30
+ username: z.string().check(utf16MinLength(1)),
30
31
  bio: z.string().optional(),
31
32
  externalIdentities: z.array(externalIdentityReferenceSchema),
32
33
  redirectedUserIds: z.array(z.string()),
@@ -61,7 +62,10 @@ export const resolveExternalIdentityResponseSchema = z
61
62
  }
62
63
  });
63
64
  export const lookupExternalIdentitiesRequestSchema = z.object({
64
- identifiers: z.array(z.string().min(1).max(2048)).min(1).max(100),
65
+ identifiers: z
66
+ .array(z.string().check(utf16MinLength(1)).check(utf16MaxLength(2048)))
67
+ .min(1)
68
+ .max(100),
65
69
  });
66
70
  export const lookupExternalIdentitiesResponseSchema = z.object({
67
71
  identities: z.array(z.object({
@@ -1,3 +1,4 @@
1
+ import { urlCheck, utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
2
  /**
2
3
  * Wire contract for `POST /federation/instance-fetch/sign`: Oxy's INSTANCE
3
4
  * actor signs one ActivityPub GET for a first-party service, so the service can
@@ -22,19 +23,23 @@ export const INSTANCE_FETCH_MAX_URL_LENGTH = 2048;
22
23
  export const instanceFetchSignRequestSchema = z
23
24
  .object({
24
25
  /** The absolute public `https://` URL the caller is about to GET. */
25
- url: z.string().trim().min(1).max(INSTANCE_FETCH_MAX_URL_LENGTH),
26
+ url: z
27
+ .string()
28
+ .trim()
29
+ .check(utf16MinLength(1))
30
+ .check(utf16MaxLength(INSTANCE_FETCH_MAX_URL_LENGTH)),
26
31
  })
27
32
  .strict();
28
33
  export const instanceFetchSignResponseSchema = z
29
34
  .object({
30
35
  /** The instance actor's key, e.g. `https://oxy.so/ap/users/instance#main-key`. */
31
- keyId: z.string().url(),
36
+ keyId: z.string().check(urlCheck()),
32
37
  /** Send all three on the GET, as they are. */
33
38
  headers: z
34
39
  .object({
35
- Host: z.string().min(1),
36
- Date: z.string().min(1),
37
- Signature: z.string().min(1),
40
+ Host: z.string().check(utf16MinLength(1)),
41
+ Date: z.string().check(utf16MinLength(1)),
42
+ Signature: z.string().check(utf16MinLength(1)),
38
43
  })
39
44
  .strict(),
40
45
  })
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { isoDateTime, utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
3
  /**
2
4
  * Self-sovereign identity API contracts.
3
5
  *
@@ -80,15 +82,15 @@ export const signedRecordEnvelopeSchema = z
80
82
  version: z.union([z.literal(1), z.literal(2)]),
81
83
  // Open, app-defined category (see the `type` doc above). The Oxy STORE
82
84
  // re-narrows to `oxySignedRecordTypeSchema`; an app to its own constant.
83
- type: z.string().min(1),
85
+ type: z.string().check(utf16MinLength(1)),
84
86
  subject: z.string(),
85
87
  issuer: z.string(),
86
- record: z.record(z.unknown()),
88
+ record: z.record(z.string(), z.unknown()),
87
89
  issuedAt: z.number(),
88
- seq: z.number().int().nonnegative().optional(),
90
+ seq: z.number().check(integerCheck()).nonnegative().optional(),
89
91
  prev: z.string().nullable().optional(),
90
- collection: z.string().min(1).optional(),
91
- rkey: z.string().min(1).optional(),
92
+ collection: z.string().check(utf16MinLength(1)).optional(),
93
+ rkey: z.string().check(utf16MinLength(1)).optional(),
92
94
  publicKey: z.string(),
93
95
  alg: z.literal('ES256K-DER-SHA256'),
94
96
  signature: z.string(),
@@ -167,7 +169,7 @@ export const verifiedDomainSchema = z.object({
167
169
  });
168
170
  /** Request body for `POST /identity/domains` — the domain to start verifying. */
169
171
  export const domainVerificationRequestSchema = z.object({
170
- domain: z.string().trim().min(1),
172
+ domain: z.string().trim().check(utf16MinLength(1)),
171
173
  });
172
174
  const resourceOriginHostSchema = z
173
175
  .string()
@@ -175,24 +177,24 @@ const resourceOriginHostSchema = z
175
177
  .toLowerCase()
176
178
  .pipe(z
177
179
  .string()
178
- .min(1)
179
- .max(253)
180
+ .check(utf16MinLength(1))
181
+ .check(utf16MaxLength(253))
180
182
  .regex(/^(?!-)[a-z0-9-]{1,63}(?<!-)(?:\.(?!-)[a-z0-9-]{1,63}(?<!-))+$/, 'originHost must be a public DNS hostname without scheme, port or path'));
181
183
  /** Clarity resource-server request to bind a site to Oxy domain authority. */
182
184
  export const resourceDomainOwnershipRequestSchema = z
183
185
  .object({
184
- accountId: z.string().min(1).max(128),
185
- verifiedDomainId: z.string().min(1).max(128),
186
+ accountId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
187
+ verifiedDomainId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
186
188
  originHost: resourceOriginHostSchema,
187
189
  })
188
190
  .strict();
189
191
  export const resourceDomainOwnershipResponseSchema = z
190
192
  .object({
191
193
  verified: z.boolean(),
192
- accountId: z.string().min(1).max(128),
193
- verifiedDomainId: z.string().min(1).max(128),
194
+ accountId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
195
+ verifiedDomainId: z.string().check(utf16MinLength(1)).check(utf16MaxLength(128)),
194
196
  originHost: resourceOriginHostSchema,
195
- verifiedAt: z.string().datetime().optional(),
197
+ verifiedAt: z.string().check(isoDateTime()).optional(),
196
198
  method: z.enum(['dns-txt', 'well-known']).optional(),
197
199
  })
198
200
  .strict();
@@ -266,11 +268,11 @@ export const exportBundleSchema = z.object({
266
268
  exportedAt: z.string(),
267
269
  did: z.string(),
268
270
  didDocument: didDocumentSchema,
269
- profile: z.record(z.unknown()),
271
+ profile: z.record(z.string(), z.unknown()),
270
272
  verifiedDomains: z.array(verifiedDomainSchema),
271
273
  authMethods: z.array(authMethodEntrySchema),
272
274
  signedRecords: z.array(signedRecordEnvelopeSchema),
273
- appData: z.array(z.record(z.unknown())),
275
+ appData: z.array(z.record(z.string(), z.unknown())),
274
276
  social: z.object({
275
277
  following: z.array(z.string()),
276
278
  followers: z.array(z.string()),
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { utf16MinLength } from './stringChecks.js';
1
3
  /**
2
4
  * Linking Commons to an account without a key (ADR 0029 D3) — the two-device
3
5
  * relay.
@@ -37,16 +39,16 @@ export const identityLinkIdSchema = z
37
39
  export const identityLinkCreateResponseSchema = z.object({
38
40
  linkId: identityLinkIdSchema,
39
41
  challenge: z.string().regex(CHALLENGE),
40
- expiresAt: z.number().int().positive(),
42
+ expiresAt: z.number().check(integerCheck()).positive(),
41
43
  qrPayload: z.string().startsWith(IDENTITY_LINK_QR_PREFIX),
42
44
  });
43
45
  export const identityLinkStateSchema = z.object({
44
46
  status: z.enum(IDENTITY_LINK_STATUSES),
45
- userId: z.string().min(1),
47
+ userId: z.string().check(utf16MinLength(1)),
46
48
  username: z.string().nullable(),
47
49
  publicKey: z.string().nullable(),
48
- audience: z.string().min(1),
49
- expiresAt: z.number().int().positive(),
50
+ audience: z.string().check(utf16MinLength(1)),
51
+ expiresAt: z.number().check(integerCheck()).positive(),
50
52
  });
51
53
  /** `POST /identity/link/:linkId/proof` — from Commons, no bearer. */
52
54
  export const identityLinkProofRequestSchema = z
@@ -1,3 +1,5 @@
1
+ import { integerCheck } from './numberChecks.js';
2
+ import { utf16MaxLength, utf16MinLength } from './stringChecks.js';
1
3
  /**
2
4
  * Identity proof contract — the ONE signed format for operations on a personal root.
3
5
  *
@@ -24,8 +26,8 @@ export { IDENTITY_PROOF_VERSION, IDENTITY_PROOF_DOMAIN, IDENTITY_PROOF_AUDIENCE,
24
26
  export const identityProofSchema = z.object({
25
27
  v: z.literal(IDENTITY_PROOF_VERSION),
26
28
  challenge: z.string().trim().regex(CHALLENGE, 'challenge must be 64 lowercase hex characters'),
27
- expiresAt: z.number().int().positive(),
28
- signature: z.string().trim().min(1).max(512),
29
+ expiresAt: z.number().check(integerCheck()).positive(),
30
+ signature: z.string().trim().check(utf16MinLength(1)).check(utf16MaxLength(512)),
29
31
  });
30
32
  /** `POST /identity/proof-challenge` */
31
33
  export const identityProofChallengeRequestSchema = z.object({
@@ -33,8 +35,8 @@ export const identityProofChallengeRequestSchema = z.object({
33
35
  });
34
36
  export const identityProofChallengeResponseSchema = z.object({
35
37
  challenge: z.string().regex(CHALLENGE),
36
- expiresAt: z.number().int().positive(),
37
- audience: z.string().min(1),
38
+ expiresAt: z.number().check(integerCheck()).positive(),
39
+ audience: z.string().check(utf16MinLength(1)),
38
40
  });
39
41
  export const identityRootStatusSchema = z.object({
40
42
  rootLinked: z.boolean(),
@@ -1,3 +1,4 @@
1
+ import { utf16MinLength } from './stringChecks.js';
1
2
  /**
2
3
  * Canonical contract for Inbox new-mail push notifications.
3
4
  *
@@ -16,6 +17,6 @@ export const INBOX_EMAIL_PUSH_CHANNEL = 'email';
16
17
  export const INBOX_EMAIL_PUSH_TYPE = 'oxy_inbox_new_message';
17
18
  export const inboxEmailPushDataSchema = z.object({
18
19
  type: z.literal(INBOX_EMAIL_PUSH_TYPE),
19
- messageId: z.string().min(1),
20
- mailboxId: z.string().min(1),
20
+ messageId: z.string().check(utf16MinLength(1)),
21
+ mailboxId: z.string().check(utf16MinLength(1)),
21
22
  });
package/dist/esm/index.js CHANGED
@@ -182,7 +182,7 @@ PRODUCT_PLAN_STATUSES, productPlanStatusSchema, LIVE_PRODUCT_PLAN_STATUSES, plan
182
182
  export {
183
183
  // Economic treatment (I09): derived by the server, never sent by a caller.
184
184
  INFERENCE_ECONOMIC_TREATMENTS, inferenceEconomicTreatmentSchema, PROVIDER_COST_SOURCES, providerCostSourceSchema, costCenterUsageSchema, } from './inference/economics.js';
185
- export { AUTONOMY_LEVELS, CAPABILITY_PACKAGES, autonomyLevelSchema, capabilityPackageSchema, actorRefSchema, executionActorRefSchema, foregroundExecutionAuthorizationInputSchema, resourceRefSchema, toolGrantOverrideSchema, grantLimitSchema, capabilityCatalogBindingSchema, executionAuthorizationRefSchema, capabilityCoordinatorSchema, capabilityTicketRequestSchema, delegationGrantSchema, AGENT_REQUESTER_CEILING_AUTONOMY, agentRequesterCeilingWriteSchema, agentRequesterCeilingSchema, APPLICATION_AGENT_AVAILABILITIES, applicationAgentAvailabilitySchema, applicationAgentWriteSchema, applicationAgentSchema, agentAvailabilitySchema, automationTriggerSchema, automationActorSelectionSchema, automationDataFlowSchema, automationDefinitionSchema, capabilityTicketClaimsSchema, invocationPrincipalSchema, policyDecisionSchema, auditResultSchema, auditEventSchema, CATALOG_TOOL_ACTOR_TYPES, CATALOG_TOOL_DEFAULT_ACTORS, catalogToolActorTypeSchema, catalogToolActors, catalogToolAllowsActor, catalogToolSchema, catalogEventSchema, catalogFeatureSchema, CATALOG_INTERNAL_TRANSPORTS, appCapabilityCatalogSchema, catalogRegistrationSchema, normalizedAppEventSchema, } from './agency.js';
185
+ export { AUTONOMY_LEVELS, CAPABILITY_PACKAGES, autonomyLevelSchema, capabilityPackageSchema, actorRefSchema, executionActorRefSchema, foregroundExecutionAuthorizationInputSchema, firstPartyExecutionAuthorizationInputSchema, firstPartyTaskInputSchema, resourceRefSchema, toolGrantOverrideSchema, grantLimitSchema, capabilityCatalogBindingSchema, executionAuthorizationRefSchema, capabilityCoordinatorSchema, capabilityTicketRequestSchema, delegationGrantSchema, AGENT_REQUESTER_CEILING_AUTONOMY, agentRequesterCeilingWriteSchema, agentRequesterCeilingSchema, APPLICATION_AGENT_AVAILABILITIES, applicationAgentAvailabilitySchema, applicationAgentWriteSchema, applicationAgentSchema, agentAvailabilitySchema, automationTriggerSchema, automationActorSelectionSchema, automationDataFlowSchema, automationDefinitionSchema, capabilityTicketClaimsSchema, invocationPrincipalSchema, policyDecisionSchema, auditResultSchema, auditEventSchema, CATALOG_TOOL_ACTOR_TYPES, CATALOG_TOOL_DEFAULT_ACTORS, catalogToolActorTypeSchema, catalogToolActors, catalogToolAllowsActor, catalogToolSchema, catalogEventSchema, catalogFeatureSchema, CATALOG_INTERNAL_TRANSPORTS, appCapabilityCatalogSchema, catalogRegistrationSchema, normalizedAppEventSchema, } from './agency.js';
186
186
  export { catalogInvocationPathParameters, catalogInvocationsOverlap, catalogInvocationTemplatesEquivalent, findOverlappingCatalogInvocations, matchCatalogInvocation, resolveCatalogInvocation, } from './capabilityInvocation.js';
187
187
  export { emailContextAddressSchema, emailContextMailboxSchema, emailContextMessageSchema, emailAgentContextSchema, } from './emailAgentContext.js';
188
188
  export { inboxComposeRequestSchema, inboxDailyBriefRequestSchema, inboxDailyBriefResponseSchema, INBOX_DAILY_BRIEF_SECTIONS, inboxNaturalSearchRequestSchema, inboxMessageInferenceParamsSchema, inboxInferenceTextResponseSchema, inboxNaturalSearchResponseSchema, inboxSmartRepliesResponseSchema, inboxThreadSummaryResponseSchema, inboxInferenceStreamEventSchema, } from './inference/inbox.js';
@@ -203,9 +203,12 @@ export { personalPlanDisplayPriceSchema, personalPlanCatalogueSchema, productPla
203
203
  export * from './products/checkout.js';
204
204
  export * from './organizations.js';
205
205
  export * from './safety.js';
206
- export { serviceTokenScopesSchema, serviceTokenOptionsSchema, } from './serviceToken.js';
206
+ export * from './serviceToken.js';
207
207
  export * from './applicationRoles.js';
208
208
  export * from './contentClaims.js';
209
209
  export * from './appAssertions.js';
210
210
  export * from './products/one.js';
211
211
  export { USER_PROFILE_COLORS, USER_PROFILE_COLOR_PRESETS, FREE_USER_PROFILE_COLOR_PRESETS, } from './profileColors.generated.js';
212
+ export { utf16MinLength, utf16MaxLength, utf16Length, isoDateTime, urlCheck, } from './stringChecks.js';
213
+ export { integerCheck, safeNumberCheck } from './numberChecks.js';
214
+ export { campaignAttributionSchema } from './campaignAttribution.js';
@@ -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
  *