@oxy.so/contracts 4.11.0-oxy-one.0 → 4.11.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 (98) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/accountGraph.js +5 -3
  3. package/dist/cjs/agency.js +178 -96
  4. package/dist/cjs/agentKeys.js +80 -26
  5. package/dist/cjs/capabilityBindings.js +2 -2
  6. package/dist/cjs/capabilityInvocation.js +3 -1
  7. package/dist/cjs/commonsSignIn.js +2 -2
  8. package/dist/cjs/deviceSession.js +5 -1
  9. package/dist/cjs/email/messages.js +70 -4
  10. package/dist/cjs/emailAgentContext.js +16 -8
  11. package/dist/cjs/externalIdentity.js +30 -12
  12. package/dist/cjs/identity.js +14 -6
  13. package/dist/cjs/identityLink.js +7 -2
  14. package/dist/cjs/identityProof.js +2 -1
  15. package/dist/cjs/index.js +5 -3
  16. package/dist/cjs/inference/catalogue.js +2 -12
  17. package/dist/cjs/inference/decisions.js +102 -83
  18. package/dist/cjs/inference/economics.js +15 -5
  19. package/dist/cjs/inference/embeddings.js +44 -6
  20. package/dist/cjs/inference/inbox.js +33 -2
  21. package/dist/cjs/inference/providerConnection.js +21 -6
  22. package/dist/cjs/inference/realtime.js +114 -107
  23. package/dist/cjs/inference/scopedExecution.js +12 -12
  24. package/dist/cjs/inference/usage.js +2 -9
  25. package/dist/cjs/notifications.js +25 -5
  26. package/dist/cjs/oauth.js +30 -14
  27. package/dist/cjs/oxyRecordTypes.js +2 -2
  28. package/dist/cjs/products/access.js +146 -57
  29. package/dist/cjs/products/billing.js +71 -17
  30. package/dist/cjs/products/checkout.js +24 -6
  31. package/dist/cjs/products/plans.js +22 -7
  32. package/dist/cjs/recommendations.js +4 -6
  33. package/dist/cjs/reputation.js +3 -6
  34. package/dist/cjs/sessionStatus.js +1 -6
  35. package/dist/cjs/signIn.js +17 -4
  36. package/dist/cjs/transparency.js +3 -1
  37. package/dist/cjs/updates.js +2 -4
  38. package/dist/cjs/userResponse.js +27 -7
  39. package/dist/cjs/username.js +3 -1
  40. package/dist/esm/.tsbuildinfo +1 -1
  41. package/dist/esm/accountGraph.js +5 -3
  42. package/dist/esm/agency.js +178 -96
  43. package/dist/esm/agentKeys.js +80 -26
  44. package/dist/esm/capabilityBindings.js +2 -2
  45. package/dist/esm/capabilityInvocation.js +3 -1
  46. package/dist/esm/commonsSignIn.js +2 -2
  47. package/dist/esm/deviceSession.js +5 -1
  48. package/dist/esm/email/messages.js +69 -3
  49. package/dist/esm/emailAgentContext.js +16 -8
  50. package/dist/esm/externalIdentity.js +30 -12
  51. package/dist/esm/identity.js +14 -6
  52. package/dist/esm/identityLink.js +7 -2
  53. package/dist/esm/identityProof.js +2 -1
  54. package/dist/esm/index.js +7 -7
  55. package/dist/esm/inference/aliaModelRelease.js +1 -1
  56. package/dist/esm/inference/catalogue.js +3 -13
  57. package/dist/esm/inference/decisions.js +108 -89
  58. package/dist/esm/inference/economics.js +16 -6
  59. package/dist/esm/inference/embeddings.js +44 -6
  60. package/dist/esm/inference/inbox.js +32 -1
  61. package/dist/esm/inference/providerConnection.js +21 -6
  62. package/dist/esm/inference/realtime.js +123 -116
  63. package/dist/esm/inference/scopedExecution.js +15 -15
  64. package/dist/esm/inference/usage.js +2 -9
  65. package/dist/esm/notifications.js +25 -5
  66. package/dist/esm/oauth.js +30 -14
  67. package/dist/esm/oxyRecordTypes.js +2 -2
  68. package/dist/esm/products/access.js +146 -57
  69. package/dist/esm/products/billing.js +71 -17
  70. package/dist/esm/products/checkout.js +24 -6
  71. package/dist/esm/products/plans.js +22 -7
  72. package/dist/esm/recommendations.js +4 -6
  73. package/dist/esm/reputation.js +3 -6
  74. package/dist/esm/sessionStatus.js +1 -6
  75. package/dist/esm/signIn.js +17 -4
  76. package/dist/esm/transparency.js +3 -1
  77. package/dist/esm/updates.js +2 -4
  78. package/dist/esm/userResponse.js +27 -7
  79. package/dist/esm/username.js +3 -1
  80. package/dist/types/.tsbuildinfo +1 -1
  81. package/dist/types/accountGraph.d.ts +1 -1
  82. package/dist/types/commonsSignIn.d.ts +2 -2
  83. package/dist/types/email/messages.d.ts +208 -2
  84. package/dist/types/identity.d.ts +1 -1
  85. package/dist/types/index.d.ts +8 -8
  86. package/dist/types/inference/decisions.d.ts +1 -1
  87. package/dist/types/inference/inbox.d.ts +129 -5
  88. package/dist/types/inference/realtime.d.ts +1 -1
  89. package/dist/types/inference/scopedExecution.d.ts +1 -1
  90. package/dist/types/moderationReputation.d.ts +1 -1
  91. package/dist/types/oxyRecordTypes.d.ts +2 -2
  92. package/dist/types/products/access.d.ts +102 -102
  93. package/dist/types/products/checkout.d.ts +3 -3
  94. package/dist/types/products/plans.d.ts +40 -40
  95. package/dist/types/reputation.d.ts +4 -4
  96. package/dist/types/updates.d.ts +1 -1
  97. package/dist/types/userResponse.d.ts +22 -23
  98. package/package.json +1 -2
@@ -117,7 +117,7 @@ function isOperatorSwitchTargetKind(kind) {
117
117
  * Narrow an unknown value to an {@link AccountKind}.
118
118
  *
119
119
  * The user-DTO serializers read from structurally-permissive `unknown` sources
120
- * (a Drizzle row, a Mongo document, an already-formatted object), so each one
120
+ * (a Drizzle row, a raw document, an already-formatted object), so each one
121
121
  * would otherwise hand-roll this check and they would drift on what counts.
122
122
  */
123
123
  function isAccountKind(value) {
@@ -395,7 +395,8 @@ const accountNameSchema = zod_1.z
395
395
  * accept categories would break that reasoning silently, so
396
396
  * `__tests__/accountGraph.test.ts` asserts the two lists agree.
397
397
  */
398
- exports.createAccountRequestSchema = zod_1.z.object({
398
+ exports.createAccountRequestSchema = zod_1.z
399
+ .object({
399
400
  parentAccountId: zod_1.z.string().trim().min(1).optional(),
400
401
  kind: exports.childAccountKindSchema,
401
402
  /**
@@ -474,7 +475,8 @@ exports.createAccountRequestSchema = zod_1.z.object({
474
475
  * remedy must not either.
475
476
  */
476
477
  isPrivateAccount: zod_1.z.boolean().optional(),
477
- }).superRefine((request, ctx) => {
478
+ })
479
+ .superRefine((request, ctx) => {
478
480
  // The ONE place `kind` and `username` arrive in the same object, so it is the
479
481
  // only place a wire schema CAN apply the per-kind half of the policy: a bot's
480
482
  // handle must end in `bot`. Not a second rule — it asks
@@ -5,17 +5,17 @@ const zod_1 = require("zod");
5
5
  const capabilityInvocation_1 = require("./capabilityInvocation");
6
6
  const nonEmptyStringSchema = zod_1.z.string().trim().min(1);
7
7
  const identifierSchema = zod_1.z.string().trim().min(1).max(255);
8
- const limitKeySchema = zod_1.z.string().regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/, 'limit keys must be dot-separated input property names').max(255);
8
+ const limitKeySchema = zod_1.z
9
+ .string()
10
+ .regex(/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/, 'limit keys must be dot-separated input property names')
11
+ .max(255);
9
12
  const auditCodeSchema = zod_1.z.string().regex(/^[A-Za-z0-9_.:-]{1,128}$/);
10
13
  const sha256HexSchema = zod_1.z.string().regex(/^[a-f0-9]{64}$/);
11
- const invocationPathSchema = zod_1.z.string().regex(/^\/(?!\/)[^\\?#]*$/, 'invocation paths must be absolute app-local paths without backslashes, query or fragment');
14
+ const invocationPathSchema = zod_1.z
15
+ .string()
16
+ .regex(/^\/(?!\/)[^\\?#]*$/, 'invocation paths must be absolute app-local paths without backslashes, query or fragment');
12
17
  /** Autonomy is ordered from least to most permissive. */
13
- exports.AUTONOMY_LEVELS = [
14
- 'read_only',
15
- 'draft',
16
- 'execute_on_request',
17
- 'autonomous',
18
- ];
18
+ exports.AUTONOMY_LEVELS = ['read_only', 'draft', 'execute_on_request', 'autonomous'];
19
19
  exports.autonomyLevelSchema = zod_1.z.enum(exports.AUTONOMY_LEVELS);
20
20
  exports.CAPABILITY_PACKAGES = [
21
21
  'read',
@@ -29,14 +29,18 @@ exports.CAPABILITY_PACKAGES = [
29
29
  ];
30
30
  exports.capabilityPackageSchema = zod_1.z.enum(exports.CAPABILITY_PACKAGES);
31
31
  exports.actorRefSchema = zod_1.z.discriminatedUnion('type', [
32
- zod_1.z.object({
32
+ zod_1.z
33
+ .object({
33
34
  type: zod_1.z.literal('alia'),
34
35
  ownerAccountId: identifierSchema,
35
- }).strict(),
36
- zod_1.z.object({
36
+ })
37
+ .strict(),
38
+ zod_1.z
39
+ .object({
37
40
  type: zod_1.z.literal('agent'),
38
41
  accountId: identifierSchema,
39
- }).strict(),
42
+ })
43
+ .strict(),
40
44
  ]);
41
45
  /** Present requester only; standing grants/automation retain actorRefSchema. */
42
46
  exports.executionActorRefSchema = zod_1.z.discriminatedUnion('type', [
@@ -44,63 +48,84 @@ exports.executionActorRefSchema = zod_1.z.discriminatedUnion('type', [
44
48
  zod_1.z.object({ type: zod_1.z.literal('requester'), accountId: identifierSchema }).strict(),
45
49
  ]);
46
50
  /** Separate bearer lives only in the SDK option / authority request body. */
47
- exports.foregroundExecutionAuthorizationInputSchema = zod_1.z.object({
51
+ exports.foregroundExecutionAuthorizationInputSchema = zod_1.z
52
+ .object({
48
53
  tool: zod_1.z.enum(['recommendProfiles', 'readViewerGraph']),
49
- expectedCatalog: zod_1.z.object({
54
+ expectedCatalog: zod_1.z
55
+ .object({
50
56
  registrationId: identifierSchema,
51
57
  version: identifierSchema,
52
58
  digest: sha256HexSchema,
53
- }).strict(),
59
+ })
60
+ .strict(),
54
61
  runId: identifierSchema,
55
62
  stepId: identifierSchema.optional(),
56
63
  expiresAt: zod_1.z.string().datetime(),
57
- }).strict();
58
- exports.resourceRefSchema = zod_1.z.object({
64
+ })
65
+ .strict();
66
+ exports.resourceRefSchema = zod_1.z
67
+ .object({
59
68
  appId: identifierSchema,
60
69
  effectiveAccountId: identifierSchema,
61
70
  resourceType: identifierSchema,
62
71
  resourceId: identifierSchema,
63
- }).strict();
64
- exports.toolGrantOverrideSchema = zod_1.z.object({
72
+ })
73
+ .strict();
74
+ exports.toolGrantOverrideSchema = zod_1.z
75
+ .object({
65
76
  tool: identifierSchema,
66
77
  decision: zod_1.z.enum(['allow', 'deny']),
67
- }).strict();
68
- exports.grantLimitSchema = zod_1.z.object({
78
+ })
79
+ .strict();
80
+ exports.grantLimitSchema = zod_1.z
81
+ .object({
69
82
  tool: identifierSchema,
70
83
  key: limitKeySchema,
71
84
  // Persisted limits are deliberately closed scalar bounds. Strings and
72
85
  // arrays are tool arguments in disguise (recipient lists, prompts, search
73
86
  // queries) and ADR 0016 forbids persisting those in Oxy.
74
87
  value: zod_1.z.union([zod_1.z.number().finite(), zod_1.z.boolean()]),
75
- }).strict();
76
- exports.capabilityCatalogBindingSchema = zod_1.z.object({
88
+ })
89
+ .strict();
90
+ exports.capabilityCatalogBindingSchema = zod_1.z
91
+ .object({
77
92
  registrationId: identifierSchema,
78
93
  version: identifierSchema,
79
94
  digest: sha256HexSchema,
80
- }).strict();
95
+ })
96
+ .strict();
81
97
  exports.executionAuthorizationRefSchema = zod_1.z.discriminatedUnion('kind', [
82
- zod_1.z.object({
98
+ zod_1.z
99
+ .object({
83
100
  kind: zod_1.z.literal('direct_request'),
84
101
  id: identifierSchema,
85
- }).strict(),
86
- zod_1.z.object({
102
+ })
103
+ .strict(),
104
+ zod_1.z
105
+ .object({
87
106
  kind: zod_1.z.literal('automation'),
88
107
  id: identifierSchema,
89
108
  automationId: identifierSchema,
90
- }).strict(),
109
+ })
110
+ .strict(),
91
111
  ]);
92
- exports.capabilityCoordinatorSchema = zod_1.z.object({
112
+ exports.capabilityCoordinatorSchema = zod_1.z
113
+ .object({
93
114
  applicationId: identifierSchema,
94
115
  credentialId: identifierSchema,
95
- }).strict();
116
+ })
117
+ .strict();
96
118
  /** Opt-in catalogue pin; legacy issuance omits expectedCatalog and its claim. */
97
- exports.capabilityTicketRequestSchema = zod_1.z.object({
119
+ exports.capabilityTicketRequestSchema = zod_1.z
120
+ .object({
98
121
  executionAuthorizationId: zod_1.z.string().min(1),
99
122
  runId: zod_1.z.string().min(1).optional(),
100
123
  stepId: zod_1.z.string().min(1).optional(),
101
124
  expectedCatalog: exports.capabilityCatalogBindingSchema.optional(),
102
- }).strict();
103
- exports.delegationGrantSchema = zod_1.z.object({
125
+ })
126
+ .strict();
127
+ exports.delegationGrantSchema = zod_1.z
128
+ .object({
104
129
  id: identifierSchema,
105
130
  ownerAccountId: identifierSchema,
106
131
  actor: exports.actorRefSchema,
@@ -116,30 +141,38 @@ exports.delegationGrantSchema = zod_1.z.object({
116
141
  revokedAt: zod_1.z.string().datetime().nullable().default(null),
117
142
  createdAt: zod_1.z.string().datetime(),
118
143
  updatedAt: zod_1.z.string().datetime(),
119
- }).strict();
144
+ })
145
+ .strict();
120
146
  exports.automationTriggerSchema = zod_1.z.discriminatedUnion('type', [
121
147
  zod_1.z.object({ type: zod_1.z.literal('manual') }).strict(),
122
- zod_1.z.object({
148
+ zod_1.z
149
+ .object({
123
150
  type: zod_1.z.literal('event'),
124
151
  appId: identifierSchema,
125
152
  eventType: identifierSchema,
126
153
  resource: exports.resourceRefSchema.optional(),
127
- }).strict(),
128
- zod_1.z.object({
154
+ })
155
+ .strict(),
156
+ zod_1.z
157
+ .object({
129
158
  type: zod_1.z.literal('schedule'),
130
159
  cron: nonEmptyStringSchema,
131
160
  timezone: nonEmptyStringSchema,
132
- }).strict(),
161
+ })
162
+ .strict(),
133
163
  ]);
134
164
  exports.automationActorSelectionSchema = zod_1.z.discriminatedUnion('mode', [
135
165
  zod_1.z.object({ mode: zod_1.z.literal('fixed'), actor: exports.actorRefSchema }).strict(),
136
166
  zod_1.z.object({ mode: zod_1.z.literal('automatic') }).strict(),
137
167
  ]);
138
- exports.automationDataFlowSchema = zod_1.z.object({
168
+ exports.automationDataFlowSchema = zod_1.z
169
+ .object({
139
170
  sources: zod_1.z.array(exports.resourceRefSchema),
140
171
  destinations: zod_1.z.array(exports.resourceRefSchema),
141
- }).strict();
142
- exports.automationDefinitionSchema = zod_1.z.object({
172
+ })
173
+ .strict();
174
+ exports.automationDefinitionSchema = zod_1.z
175
+ .object({
143
176
  id: identifierSchema,
144
177
  ownerAccountId: identifierSchema,
145
178
  objective: nonEmptyStringSchema,
@@ -153,8 +186,10 @@ exports.automationDefinitionSchema = zod_1.z.object({
153
186
  enabled: zod_1.z.boolean(),
154
187
  createdAt: zod_1.z.string().datetime(),
155
188
  updatedAt: zod_1.z.string().datetime(),
156
- }).strict();
157
- exports.capabilityTicketClaimsSchema = zod_1.z.object({
189
+ })
190
+ .strict();
191
+ exports.capabilityTicketClaimsSchema = zod_1.z
192
+ .object({
158
193
  iss: nonEmptyStringSchema,
159
194
  aud: identifierSchema,
160
195
  sub: identifierSchema,
@@ -177,10 +212,10 @@ exports.capabilityTicketClaimsSchema = zod_1.z.object({
177
212
  capabilities: zod_1.z.array(identifierSchema).min(1),
178
213
  limits: zod_1.z.array(exports.grantLimitSchema).default([]),
179
214
  autonomy: exports.autonomyLevelSchema,
180
- }).strict().superRefine((claims, context) => {
181
- const expectedSubject = claims.actor.type !== 'alia'
182
- ? claims.actor.accountId
183
- : `alia:${claims.actor.ownerAccountId}`;
215
+ })
216
+ .strict()
217
+ .superRefine((claims, context) => {
218
+ const expectedSubject = claims.actor.type !== 'alia' ? claims.actor.accountId : `alia:${claims.actor.ownerAccountId}`;
184
219
  if (claims.sub !== expectedSubject) {
185
220
  context.addIssue({
186
221
  code: zod_1.z.ZodIssueCode.custom,
@@ -195,13 +230,17 @@ exports.capabilityTicketClaimsSchema = zod_1.z.object({
195
230
  path: ['actor', 'ownerAccountId'],
196
231
  });
197
232
  }
198
- if (claims.actor.type === 'requester' && (claims.actor.accountId !== claims.requesterAccountId
199
- || claims.executionAuthorization.kind !== 'direct_request'
200
- || claims.autonomy !== 'read_only'
201
- || claims.grantId !== undefined
202
- || claims.automationId !== undefined)) {
203
- context.addIssue({ code: zod_1.z.ZodIssueCode.custom, path: ['actor'],
204
- message: 'requester actors require their exact principal and direct read-only authority without standing grants' });
233
+ if (claims.actor.type === 'requester' &&
234
+ (claims.actor.accountId !== claims.requesterAccountId ||
235
+ claims.executionAuthorization.kind !== 'direct_request' ||
236
+ claims.autonomy !== 'read_only' ||
237
+ claims.grantId !== undefined ||
238
+ claims.automationId !== undefined)) {
239
+ context.addIssue({
240
+ code: zod_1.z.ZodIssueCode.custom,
241
+ path: ['actor'],
242
+ message: 'requester actors require their exact principal and direct read-only authority without standing grants',
243
+ });
205
244
  }
206
245
  if (claims.exp <= claims.iat) {
207
246
  context.addIssue({
@@ -238,7 +277,8 @@ exports.capabilityTicketClaimsSchema = zod_1.z.object({
238
277
  });
239
278
  /** Structural projections only: an authenticated transport must produce these. */
240
279
  exports.invocationPrincipalSchema = zod_1.z.discriminatedUnion('kind', [
241
- zod_1.z.object({
280
+ zod_1.z
281
+ .object({
242
282
  kind: zod_1.z.literal('oauth'),
243
283
  subject: identifierSchema,
244
284
  clientId: identifierSchema,
@@ -246,25 +286,33 @@ exports.invocationPrincipalSchema = zod_1.z.discriminatedUnion('kind', [
246
286
  activeAccountId: identifierSchema,
247
287
  scopes: zod_1.z.array(identifierSchema),
248
288
  resource: zod_1.z.string().url(),
249
- }).strict(),
250
- zod_1.z.object({
289
+ })
290
+ .strict(),
291
+ zod_1.z
292
+ .object({
251
293
  kind: zod_1.z.literal('capability'),
252
294
  claims: exports.capabilityTicketClaimsSchema.refine((claims) => claims.catalog !== undefined, {
253
295
  message: 'internal MCP requires a signed catalogue binding',
254
296
  }),
255
- }).strict(),
297
+ })
298
+ .strict(),
256
299
  ]);
257
- exports.policyDecisionSchema = zod_1.z.object({
300
+ exports.policyDecisionSchema = zod_1.z
301
+ .object({
258
302
  allowed: zod_1.z.boolean(),
259
303
  reason: identifierSchema,
260
304
  effectiveAutonomy: exports.autonomyLevelSchema.optional(),
261
305
  grantId: identifierSchema.optional(),
262
- }).strict();
263
- exports.auditResultSchema = zod_1.z.object({
306
+ })
307
+ .strict();
308
+ exports.auditResultSchema = zod_1.z
309
+ .object({
264
310
  status: zod_1.z.enum(['planned', 'allowed', 'denied', 'succeeded', 'failed', 'rolled_back']),
265
311
  code: auditCodeSchema.optional(),
266
- }).strict();
267
- exports.auditEventSchema = zod_1.z.object({
312
+ })
313
+ .strict();
314
+ exports.auditEventSchema = zod_1.z
315
+ .object({
268
316
  eventId: identifierSchema,
269
317
  occurredAt: zod_1.z.string().datetime(),
270
318
  requesterAccountId: identifierSchema,
@@ -277,20 +325,26 @@ exports.auditEventSchema = zod_1.z.object({
277
325
  capabilities: zod_1.z.array(identifierSchema),
278
326
  policyDecision: exports.policyDecisionSchema,
279
327
  result: exports.auditResultSchema,
280
- rollback: zod_1.z.object({
328
+ rollback: zod_1.z
329
+ .object({
281
330
  supported: zod_1.z.boolean(),
282
331
  attempted: zod_1.z.boolean(),
283
332
  succeeded: zod_1.z.boolean().optional(),
284
- }).strict(),
285
- correlation: zod_1.z.object({
333
+ })
334
+ .strict(),
335
+ correlation: zod_1.z
336
+ .object({
286
337
  runId: identifierSchema,
287
338
  stepId: identifierSchema.optional(),
288
339
  automationId: identifierSchema.optional(),
289
340
  idempotencyKeyHash: sha256HexSchema.optional(),
290
341
  capabilityTicketId: identifierSchema.optional(),
291
- }).strict(),
292
- }).strict();
293
- exports.catalogToolSchema = zod_1.z.object({
342
+ })
343
+ .strict(),
344
+ })
345
+ .strict();
346
+ exports.catalogToolSchema = zod_1.z
347
+ .object({
294
348
  name: identifierSchema,
295
349
  version: identifierSchema,
296
350
  description: nonEmptyStringSchema,
@@ -303,15 +357,23 @@ exports.catalogToolSchema = zod_1.z.object({
303
357
  idempotency: zod_1.z.enum(['none', 'supported', 'required']),
304
358
  rollback: zod_1.z.enum(['none', 'manual', 'supported']),
305
359
  exposure: zod_1.z.array(zod_1.z.enum(['internal', 'mcp'])).min(1),
306
- limitKeys: zod_1.z.array(zod_1.z.object({
360
+ limitKeys: zod_1.z
361
+ .array(zod_1.z
362
+ .object({
307
363
  key: limitKeySchema,
308
364
  kind: zod_1.z.enum(['maximum_number', 'exact_boolean']),
309
- }).strict()).default([]),
310
- invocation: zod_1.z.object({
365
+ })
366
+ .strict())
367
+ .default([]),
368
+ invocation: zod_1.z
369
+ .object({
311
370
  method: zod_1.z.enum(['GET', 'POST', 'PATCH', 'PUT', 'DELETE']),
312
371
  path: invocationPathSchema,
313
- }).strict(),
314
- }).strict().superRefine((tool, context) => {
372
+ })
373
+ .strict(),
374
+ })
375
+ .strict()
376
+ .superRefine((tool, context) => {
315
377
  const requireUnique = (values, path) => {
316
378
  if (new Set(values).size !== values.length) {
317
379
  context.addIssue({
@@ -388,7 +450,8 @@ exports.catalogToolSchema = zod_1.z.object({
388
450
  path: ['capabilityPackage'],
389
451
  });
390
452
  }
391
- if ((tool.effect === 'financial' || tool.effect === 'security') && tool.idempotency !== 'required') {
453
+ if ((tool.effect === 'financial' || tool.effect === 'security') &&
454
+ tool.idempotency !== 'required') {
392
455
  context.addIssue({
393
456
  code: zod_1.z.ZodIssueCode.custom,
394
457
  message: 'Financial and security effects require idempotency keys',
@@ -407,16 +470,17 @@ exports.catalogToolSchema = zod_1.z.object({
407
470
  // not declare as a REQUIRED property can never be filled, and a GET input
408
471
  // that is not a scalar has no query-string form — both are refused here so
409
472
  // the builder never has to guess.
410
- const declared = typeof tool.inputSchema.properties === 'object'
411
- && tool.inputSchema.properties !== null
412
- && !Array.isArray(tool.inputSchema.properties)
473
+ const declared = typeof tool.inputSchema.properties === 'object' &&
474
+ tool.inputSchema.properties !== null &&
475
+ !Array.isArray(tool.inputSchema.properties)
413
476
  ? tool.inputSchema.properties
414
477
  : {};
415
478
  const required = Array.isArray(tool.inputSchema.required) ? tool.inputSchema.required : [];
416
479
  const parameters = (0, capabilityInvocation_1.catalogInvocationPathParameters)(tool.invocation.path);
417
480
  requireUnique(parameters, 'invocation.path parameters');
418
481
  for (const parameter of parameters) {
419
- if (!Object.prototype.hasOwnProperty.call(declared, parameter) || !required.includes(parameter)) {
482
+ if (!Object.prototype.hasOwnProperty.call(declared, parameter) ||
483
+ !required.includes(parameter)) {
420
484
  context.addIssue({
421
485
  code: zod_1.z.ZodIssueCode.custom,
422
486
  message: `Path parameter {${parameter}} must be a required input property`,
@@ -439,20 +503,26 @@ exports.catalogToolSchema = zod_1.z.object({
439
503
  }
440
504
  }
441
505
  });
442
- exports.catalogEventSchema = zod_1.z.object({
506
+ exports.catalogEventSchema = zod_1.z
507
+ .object({
443
508
  type: identifierSchema,
444
509
  version: identifierSchema,
445
510
  description: nonEmptyStringSchema,
446
511
  dataSchema: zod_1.z.record(zod_1.z.unknown()),
447
512
  resourceTypes: zod_1.z.array(identifierSchema).min(1),
448
- }).strict();
449
- exports.appCapabilityCatalogSchema = zod_1.z.object({
513
+ })
514
+ .strict();
515
+ exports.appCapabilityCatalogSchema = zod_1.z
516
+ .object({
450
517
  schemaVersion: zod_1.z.literal('1'),
451
518
  appId: identifierSchema,
452
519
  version: identifierSchema,
453
520
  audience: identifierSchema,
454
521
  /** HTTPS origin that serves the catalog's internal invocation paths. */
455
- internalBaseUrl: zod_1.z.string().url().superRefine((value, context) => {
522
+ internalBaseUrl: zod_1.z
523
+ .string()
524
+ .url()
525
+ .superRefine((value, context) => {
456
526
  const url = new URL(value);
457
527
  const localDevelopment = url.hostname === 'localhost' || url.hostname === '127.0.0.1';
458
528
  if (url.protocol !== 'https:' && !(localDevelopment && url.protocol === 'http:')) {
@@ -471,12 +541,16 @@ exports.appCapabilityCatalogSchema = zod_1.z.object({
471
541
  /** Account-scoped resource used for native Alia bindings without app-specific code. */
472
542
  accountResourceType: identifierSchema,
473
543
  /** Canonical protected-resource URI when this catalog is also exposed as an external MCP server. */
474
- externalMcp: zod_1.z.object({
475
- resource: zod_1.z.string().url().superRefine((value, context) => {
544
+ externalMcp: zod_1.z
545
+ .object({
546
+ resource: zod_1.z
547
+ .string()
548
+ .url()
549
+ .superRefine((value, context) => {
476
550
  const url = new URL(value);
477
- const localDevelopment = url.hostname === 'localhost'
478
- || url.hostname === '127.0.0.1'
479
- || url.hostname === '[::1]';
551
+ const localDevelopment = url.hostname === 'localhost' ||
552
+ url.hostname === '127.0.0.1' ||
553
+ url.hostname === '[::1]';
480
554
  if (url.protocol !== 'https:' && !(localDevelopment && url.protocol === 'http:')) {
481
555
  context.addIssue({
482
556
  code: zod_1.z.ZodIssueCode.custom,
@@ -490,10 +564,14 @@ exports.appCapabilityCatalogSchema = zod_1.z.object({
490
564
  });
491
565
  }
492
566
  }),
493
- }).strict().optional(),
567
+ })
568
+ .strict()
569
+ .optional(),
494
570
  tools: zod_1.z.array(exports.catalogToolSchema),
495
571
  events: zod_1.z.array(exports.catalogEventSchema),
496
- }).strict().superRefine((catalog, context) => {
572
+ })
573
+ .strict()
574
+ .superRefine((catalog, context) => {
497
575
  const names = new Set();
498
576
  for (const [index, tool] of catalog.tools.entries()) {
499
577
  if (names.has(tool.name)) {
@@ -512,8 +590,8 @@ exports.appCapabilityCatalogSchema = zod_1.z.object({
512
590
  for (const [left, right] of (0, capabilityInvocation_1.findOverlappingCatalogInvocations)(catalog.tools)) {
513
591
  context.addIssue({
514
592
  code: zod_1.z.ZodIssueCode.custom,
515
- message: `Tools ${left.name} and ${right.name} have overlapping invocations `
516
- + `(${left.invocation.method} ${left.invocation.path} / ${right.invocation.method} ${right.invocation.path})`,
593
+ message: `Tools ${left.name} and ${right.name} have overlapping invocations ` +
594
+ `(${left.invocation.method} ${left.invocation.path} / ${right.invocation.method} ${right.invocation.path})`,
517
595
  path: ['tools'],
518
596
  });
519
597
  }
@@ -529,13 +607,16 @@ exports.appCapabilityCatalogSchema = zod_1.z.object({
529
607
  eventTypes.add(event.type);
530
608
  }
531
609
  });
532
- exports.catalogRegistrationSchema = zod_1.z.object({
610
+ exports.catalogRegistrationSchema = zod_1.z
611
+ .object({
533
612
  catalog: exports.appCapabilityCatalogSchema,
534
613
  digest: zod_1.z.string().regex(/^[a-f0-9]{64}$/),
535
614
  signature: nonEmptyStringSchema,
536
615
  deployedAt: zod_1.z.string().datetime(),
537
- }).strict();
538
- exports.normalizedAppEventSchema = zod_1.z.object({
616
+ })
617
+ .strict();
618
+ exports.normalizedAppEventSchema = zod_1.z
619
+ .object({
539
620
  eventId: identifierSchema,
540
621
  appId: identifierSchema,
541
622
  accountId: identifierSchema,
@@ -543,4 +624,5 @@ exports.normalizedAppEventSchema = zod_1.z.object({
543
624
  type: identifierSchema,
544
625
  occurredAt: zod_1.z.string().datetime(),
545
626
  data: zod_1.z.record(zod_1.z.unknown()),
546
- }).strict();
627
+ })
628
+ .strict();
@@ -8,8 +8,15 @@ const signIn_1 = require("./signIn");
8
8
  const identityProof_1 = require("./identityProof");
9
9
  exports.AGENT_PROOF_AUDIENCE = 'oxy-api/agent';
10
10
  exports.AGENT_PROOF_TTL_MS = 60000;
11
- exports.AGENT_PROOF_ACTIONS = ['agent_signin', 'agent_enroll', 'agent_rotate', 'agent_recover', 'agent_governance'];
12
- exports.agentProofClaimsSchema = zod_1.z.object({
11
+ exports.AGENT_PROOF_ACTIONS = [
12
+ 'agent_signin',
13
+ 'agent_enroll',
14
+ 'agent_rotate',
15
+ 'agent_recover',
16
+ 'agent_governance',
17
+ ];
18
+ exports.agentProofClaimsSchema = zod_1.z
19
+ .object({
13
20
  version: zod_1.z.literal(1),
14
21
  audience: zod_1.z.literal(exports.AGENT_PROOF_AUDIENCE),
15
22
  action: zod_1.z.enum(exports.AGENT_PROOF_ACTIONS),
@@ -20,48 +27,95 @@ exports.agentProofClaimsSchema = zod_1.z.object({
20
27
  payloadDigest: zod_1.z.string().regex(/^[0-9a-f]{64}$/),
21
28
  challenge: zod_1.z.string().regex(/^[0-9a-f]{64}$/),
22
29
  expiresAt: zod_1.z.number().int().positive(),
23
- }).strict();
30
+ })
31
+ .strict();
24
32
  /** Different proof roles cannot substitute for one another on the same operation. */
25
33
  function buildAgentProofMessage(claims, timestamp, role = 'credential') {
26
- return (0, identityProof_1.canonicalJson)({ domain: 'oxy-agent-proof', ...exports.agentProofClaimsSchema.parse(claims), timestamp, role });
34
+ return (0, identityProof_1.canonicalJson)({
35
+ domain: 'oxy-agent-proof',
36
+ ...exports.agentProofClaimsSchema.parse(claims),
37
+ timestamp,
38
+ role,
39
+ });
27
40
  }
28
- exports.agentSignatureSchema = zod_1.z.object({
41
+ exports.agentSignatureSchema = zod_1.z
42
+ .object({
29
43
  challenge: zod_1.z.string().regex(/^[0-9a-f]{64}$/),
30
- signature: zod_1.z.string().regex(/^[0-9a-f]+$/i).max(160),
44
+ signature: zod_1.z
45
+ .string()
46
+ .regex(/^[0-9a-f]+$/i)
47
+ .max(160),
31
48
  timestamp: zod_1.z.number().int().positive(),
32
- }).strict();
33
- exports.agentChallengeRequestSchema = zod_1.z.object({ publicKey: zod_1.z.string().trim().min(1).max(130) }).strict();
34
- exports.agentVerifyRequestSchema = exports.agentSignatureSchema.extend({ publicKey: zod_1.z.string().trim().min(1).max(130) }).strict();
35
- const newKey = { publicKey: zod_1.z.string().trim().min(1).max(130), label: zod_1.z.string().trim().min(1).max(120) };
49
+ })
50
+ .strict();
51
+ exports.agentChallengeRequestSchema = zod_1.z
52
+ .object({ publicKey: zod_1.z.string().trim().min(1).max(130) })
53
+ .strict();
54
+ exports.agentVerifyRequestSchema = exports.agentSignatureSchema
55
+ .extend({ publicKey: zod_1.z.string().trim().min(1).max(130) })
56
+ .strict();
57
+ const newKey = {
58
+ publicKey: zod_1.z.string().trim().min(1).max(130),
59
+ label: zod_1.z.string().trim().min(1).max(120),
60
+ };
36
61
  exports.agentKeyOperationSchema = zod_1.z.discriminatedUnion('operation', [
37
62
  zod_1.z.object({ operation: zod_1.z.literal('enroll'), ...newKey }).strict(),
38
63
  zod_1.z.object({ operation: zod_1.z.literal('recover'), ...newKey }).strict(),
39
- zod_1.z.object({ operation: zod_1.z.literal('rotate'), ...newKey, retireCurrent: zod_1.z.boolean().optional() }).strict(),
64
+ zod_1.z
65
+ .object({ operation: zod_1.z.literal('rotate'), ...newKey, retireCurrent: zod_1.z.boolean().optional() })
66
+ .strict(),
40
67
  zod_1.z.object({ operation: zod_1.z.literal('revoke'), methodId: zod_1.z.string().min(1) }).strict(),
41
68
  ]);
42
- exports.agentKeyOperationProofSchema = zod_1.z.object({
69
+ exports.agentKeyOperationProofSchema = zod_1.z
70
+ .object({
43
71
  challenge: zod_1.z.string().regex(/^[0-9a-f]{64}$/),
44
72
  timestamp: zod_1.z.number().int().positive(),
45
- keySignature: zod_1.z.string().regex(/^[0-9a-f]+$/i).max(160).optional(),
46
- governorSignature: zod_1.z.string().regex(/^[0-9a-f]+$/i).max(160).optional(),
73
+ keySignature: zod_1.z
74
+ .string()
75
+ .regex(/^[0-9a-f]+$/i)
76
+ .max(160)
77
+ .optional(),
78
+ governorSignature: zod_1.z
79
+ .string()
80
+ .regex(/^[0-9a-f]+$/i)
81
+ .max(160)
82
+ .optional(),
47
83
  reauth: signIn_1.reauthProofSchema.optional(),
48
- }).strict();
49
- exports.executeAgentKeyOperationSchema = zod_1.z.object({
84
+ })
85
+ .strict();
86
+ exports.executeAgentKeyOperationSchema = zod_1.z
87
+ .object({
50
88
  operation: exports.agentKeyOperationSchema,
51
89
  proof: exports.agentKeyOperationProofSchema,
52
- }).strict();
53
- exports.agentKeyOperationChallengeSchema = zod_1.z.object({
90
+ })
91
+ .strict();
92
+ exports.agentKeyOperationChallengeSchema = zod_1.z
93
+ .object({
54
94
  claims: exports.agentProofClaimsSchema,
55
95
  governorPublicKey: zod_1.z.string().nullable(),
56
- }).strict();
57
- exports.agentKeyOperationResultSchema = zod_1.z.object({
96
+ })
97
+ .strict();
98
+ exports.agentKeyOperationResultSchema = zod_1.z
99
+ .object({
58
100
  methodId: zod_1.z.string().nullable(),
59
101
  revokedMethodIds: zod_1.z.array(zod_1.z.string()),
60
- }).strict();
102
+ })
103
+ .strict();
61
104
  exports.ACCOUNT_AUTH_METHODS = ['identity', 'agent_key'];
62
105
  /** Public credential inventory. Never includes a proof, bearer or private key. */
63
- exports.agentKeyListResponseSchema = zod_1.z.object({ keys: zod_1.z.array(zod_1.z.object({
64
- id: zod_1.z.string(), publicKey: zod_1.z.string(), label: zod_1.z.string(),
65
- enrolledByUserId: zod_1.z.string().nullable(), enrollmentMethod: zod_1.z.enum(['governor', 'rotation', 'recovery']),
66
- linkedAt: zod_1.z.string().datetime(), lastUsedAt: zod_1.z.string().datetime().nullable(), revokedAt: zod_1.z.string().datetime().nullable(),
67
- }).strict()) }).strict();
106
+ exports.agentKeyListResponseSchema = zod_1.z
107
+ .object({
108
+ keys: zod_1.z.array(zod_1.z
109
+ .object({
110
+ id: zod_1.z.string(),
111
+ publicKey: zod_1.z.string(),
112
+ label: zod_1.z.string(),
113
+ enrolledByUserId: zod_1.z.string().nullable(),
114
+ enrollmentMethod: zod_1.z.enum(['governor', 'rotation', 'recovery']),
115
+ linkedAt: zod_1.z.string().datetime(),
116
+ lastUsedAt: zod_1.z.string().datetime().nullable(),
117
+ revokedAt: zod_1.z.string().datetime().nullable(),
118
+ })
119
+ .strict()),
120
+ })
121
+ .strict();