@multiagency/sdk 0.3.1

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 (78) hide show
  1. package/CHANGES.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +142 -0
  4. package/THIRD-PARTY-NOTICES +127 -0
  5. package/bin/release-server.d.mts +29 -0
  6. package/bin/release-server.mjs +143 -0
  7. package/dist/compensation-contract.d.ts +370 -0
  8. package/dist/compensation-contract.js +51 -0
  9. package/dist/contract/agent-connection.d.ts +86 -0
  10. package/dist/contract/agent-connection.js +36 -0
  11. package/dist/contract/app-access.d.ts +141 -0
  12. package/dist/contract/app-access.js +57 -0
  13. package/dist/contract/app-client.d.ts +140 -0
  14. package/dist/contract/app-client.js +61 -0
  15. package/dist/contract/app-consent.d.ts +68 -0
  16. package/dist/contract/app-consent.js +91 -0
  17. package/dist/contract/assets.d.ts +6 -0
  18. package/dist/contract/assets.js +6 -0
  19. package/dist/contract/client.d.ts +347 -0
  20. package/dist/contract/client.js +81 -0
  21. package/dist/contract/gateway.d.ts +74 -0
  22. package/dist/contract/gateway.js +47 -0
  23. package/dist/contract/index.d.ts +26 -0
  24. package/dist/contract/index.js +25 -0
  25. package/dist/contract/inputs.d.ts +230 -0
  26. package/dist/contract/inputs.js +99 -0
  27. package/dist/contract/intents-account.d.ts +5 -0
  28. package/dist/contract/intents-account.js +8 -0
  29. package/dist/contract/orpc-client.js +2037 -0
  30. package/dist/contract/owner-capabilities.d.ts +81 -0
  31. package/dist/contract/owner-capabilities.js +33 -0
  32. package/dist/contract/owner-client.d.ts +99 -0
  33. package/dist/contract/owner-client.js +146 -0
  34. package/dist/contract/owner-contract.d.ts +1156 -0
  35. package/dist/contract/owner-contract.js +37 -0
  36. package/dist/contract/owner-inputs.d.ts +166 -0
  37. package/dist/contract/owner-inputs.js +1 -0
  38. package/dist/contract/owner-outputs.d.ts +5749 -0
  39. package/dist/contract/owner-outputs.js +751 -0
  40. package/dist/contract/package-version.d.ts +5 -0
  41. package/dist/contract/package-version.js +2 -0
  42. package/dist/contract/payee-entry.d.ts +10 -0
  43. package/dist/contract/payee-entry.js +10 -0
  44. package/dist/contract/payee.d.ts +326 -0
  45. package/dist/contract/payee.js +32 -0
  46. package/dist/contract/permissions.d.ts +20 -0
  47. package/dist/contract/permissions.js +64 -0
  48. package/dist/contract/proposals.d.ts +178 -0
  49. package/dist/contract/proposals.js +27 -0
  50. package/dist/contract/run-log-schema.d.ts +888 -0
  51. package/dist/contract/run-log-schema.js +150 -0
  52. package/dist/contract/run-progress-schema.d.ts +104 -0
  53. package/dist/contract/run-progress-schema.js +20 -0
  54. package/dist/payee-contract.d.ts +9 -0
  55. package/dist/payee-contract.js +15 -0
  56. package/package.json +58 -0
  57. package/provenance.json +61 -0
  58. package/schemas/agentConnection.json +76 -0
  59. package/schemas/agentConnectionIssue.json +22 -0
  60. package/schemas/agentConnectionList.json +88 -0
  61. package/schemas/agentConnectionStarted.json +90 -0
  62. package/schemas/compensationSend.json +40 -0
  63. package/schemas/errorBody.json +16 -0
  64. package/schemas/fileResult.json +67 -0
  65. package/schemas/invoicesView.json +130 -0
  66. package/schemas/ownerCompensationView.json +556 -0
  67. package/schemas/payeeCompensationView.json +546 -0
  68. package/schemas/payeeWorkOrderRequest.json +31 -0
  69. package/schemas/publicWorkOrder.json +94 -0
  70. package/schemas/reportCommand.json +82 -0
  71. package/schemas/requestRecord.json +149 -0
  72. package/schemas/session.json +20 -0
  73. package/schemas/workOrderList.json +43 -0
  74. package/schemas/workOrderRequestResult.json +20 -0
  75. package/skills/app-server/SKILL.md +190 -0
  76. package/skills/getting-started/SKILL.md +90 -0
  77. package/skills/owner-workflows/SKILL.md +157 -0
  78. package/skills/payee-workflows/SKILL.md +200 -0
@@ -0,0 +1,370 @@
1
+ import { z } from "zod";
2
+ export declare const requestId: z.ZodUUID;
3
+ export declare const atomicUsdc: z.ZodString;
4
+ export declare const compensationTerms: z.ZodObject<{
5
+ payee: z.ZodString;
6
+ title: z.ZodString;
7
+ document: z.ZodURL;
8
+ signedOn: z.ZodString;
9
+ start: z.ZodString;
10
+ end: z.ZodString;
11
+ ceiling: z.ZodString;
12
+ openingApproved: z.ZodString;
13
+ scope: z.ZodString;
14
+ }, z.core.$strict>;
15
+ export declare const compensationReport: z.ZodObject<{
16
+ agreementId: z.ZodUUID;
17
+ amount: z.ZodOptional<z.ZodString>;
18
+ start: z.ZodString;
19
+ end: z.ZodString;
20
+ contributions: z.ZodString;
21
+ assessment: z.ZodString;
22
+ evidence: z.ZodArray<z.ZodURL>;
23
+ }, z.core.$strict>;
24
+ export declare const paymentPreparation: z.ZodObject<{
25
+ type: z.ZodLiteral<"prepare">;
26
+ command: z.ZodObject<{
27
+ commandId: z.ZodUUID;
28
+ id: z.ZodUUID;
29
+ expectedVersion: z.ZodNumber;
30
+ mode: z.ZodEnum<{
31
+ isolated: "isolated";
32
+ shared: "shared";
33
+ }>;
34
+ until: z.ZodOptional<z.ZodISODateTime>;
35
+ }, z.core.$strict>;
36
+ }, z.core.$strict>;
37
+ export declare const agreementCommand: z.ZodObject<{
38
+ commandId: z.ZodUUID;
39
+ id: z.ZodUUID;
40
+ expectedVersion: z.ZodNumber;
41
+ terms: z.ZodObject<{
42
+ payee: z.ZodString;
43
+ title: z.ZodString;
44
+ document: z.ZodURL;
45
+ signedOn: z.ZodString;
46
+ start: z.ZodString;
47
+ end: z.ZodString;
48
+ ceiling: z.ZodString;
49
+ openingApproved: z.ZodString;
50
+ scope: z.ZodString;
51
+ }, z.core.$strict>;
52
+ }, z.core.$strict>;
53
+ export declare const reportCommand: z.ZodObject<{
54
+ commandId: z.ZodUUID;
55
+ id: z.ZodUUID;
56
+ expectedVersion: z.ZodNumber;
57
+ report: z.ZodObject<{
58
+ agreementId: z.ZodUUID;
59
+ amount: z.ZodOptional<z.ZodString>;
60
+ start: z.ZodString;
61
+ end: z.ZodString;
62
+ contributions: z.ZodString;
63
+ assessment: z.ZodString;
64
+ evidence: z.ZodArray<z.ZodURL>;
65
+ }, z.core.$strict>;
66
+ submit: z.ZodBoolean;
67
+ }, z.core.$strict>;
68
+ export declare const reviewCommand: z.ZodObject<{
69
+ commandId: z.ZodUUID;
70
+ id: z.ZodUUID;
71
+ expectedVersion: z.ZodNumber;
72
+ decision: z.ZodEnum<{
73
+ approved: "approved";
74
+ changes_requested: "changes_requested";
75
+ declined: "declined";
76
+ }>;
77
+ feedback: z.ZodString;
78
+ approvedAmount: z.ZodOptional<z.ZodString>;
79
+ }, z.core.$strict>;
80
+ export type CompensationTerms = z.infer<typeof compensationTerms>;
81
+ export type CompensationReport = z.infer<typeof compensationReport>;
82
+ export declare const agreementRecord: z.ZodObject<{
83
+ id: z.ZodUUID;
84
+ version: z.ZodNumber;
85
+ terms: z.ZodObject<{
86
+ payee: z.ZodString;
87
+ title: z.ZodString;
88
+ document: z.ZodURL;
89
+ signedOn: z.ZodString;
90
+ start: z.ZodString;
91
+ end: z.ZodString;
92
+ ceiling: z.ZodString;
93
+ openingApproved: z.ZodString;
94
+ scope: z.ZodString;
95
+ }, z.core.$strict>;
96
+ recordedBy: z.ZodString;
97
+ at: z.ZodString;
98
+ }, z.core.$strip>;
99
+ export declare const requestRecord: z.ZodObject<{
100
+ id: z.ZodUUID;
101
+ version: z.ZodNumber;
102
+ payee: z.ZodString;
103
+ agreementVersion: z.ZodNumber;
104
+ report: z.ZodObject<{
105
+ agreementId: z.ZodUUID;
106
+ amount: z.ZodOptional<z.ZodString>;
107
+ start: z.ZodString;
108
+ end: z.ZodString;
109
+ contributions: z.ZodString;
110
+ assessment: z.ZodString;
111
+ evidence: z.ZodArray<z.ZodURL>;
112
+ }, z.core.$strict>;
113
+ state: z.ZodEnum<{
114
+ approved: "approved";
115
+ changes_requested: "changes_requested";
116
+ declined: "declined";
117
+ draft: "draft";
118
+ submitted: "submitted";
119
+ }>;
120
+ approvedAmount: z.ZodOptional<z.ZodString>;
121
+ feedback: z.ZodString;
122
+ reviewedBy: z.ZodNullable<z.ZodString>;
123
+ at: z.ZodString;
124
+ payment: z.ZodDefault<z.ZodNullable<z.ZodObject<{
125
+ mode: z.ZodEnum<{
126
+ isolated: "isolated";
127
+ shared: "shared";
128
+ }>;
129
+ id: z.ZodUUID;
130
+ until: z.ZodOptional<z.ZodISODateTime>;
131
+ }, z.core.$strip>>>;
132
+ }, z.core.$strip>;
133
+ /** The owner's explicitly approved amount: the only amount a payment of this request may carry. */
134
+ export declare function approvedCompensation(request: CompensationRequest): string;
135
+ export type CompensationAgreement = z.infer<typeof agreementRecord>;
136
+ export type CompensationRequest = z.infer<typeof requestRecord>;
137
+ export type CompensationView = {
138
+ agreements: (CompensationAgreement & {
139
+ approved: string;
140
+ remaining: string;
141
+ })[];
142
+ requests: CompensationRequest[];
143
+ };
144
+ export declare const compensationView: z.ZodObject<{
145
+ agreements: z.ZodArray<z.ZodObject<{
146
+ id: z.ZodUUID;
147
+ version: z.ZodNumber;
148
+ terms: z.ZodObject<{
149
+ payee: z.ZodString;
150
+ title: z.ZodString;
151
+ document: z.ZodURL;
152
+ signedOn: z.ZodString;
153
+ start: z.ZodString;
154
+ end: z.ZodString;
155
+ ceiling: z.ZodString;
156
+ openingApproved: z.ZodString;
157
+ scope: z.ZodString;
158
+ }, z.core.$strict>;
159
+ recordedBy: z.ZodString;
160
+ at: z.ZodString;
161
+ approved: z.ZodString;
162
+ remaining: z.ZodString;
163
+ }, z.core.$strip>>;
164
+ requests: z.ZodArray<z.ZodObject<{
165
+ id: z.ZodUUID;
166
+ version: z.ZodNumber;
167
+ payee: z.ZodString;
168
+ agreementVersion: z.ZodNumber;
169
+ report: z.ZodObject<{
170
+ agreementId: z.ZodUUID;
171
+ amount: z.ZodOptional<z.ZodString>;
172
+ start: z.ZodString;
173
+ end: z.ZodString;
174
+ contributions: z.ZodString;
175
+ assessment: z.ZodString;
176
+ evidence: z.ZodArray<z.ZodURL>;
177
+ }, z.core.$strict>;
178
+ state: z.ZodEnum<{
179
+ approved: "approved";
180
+ changes_requested: "changes_requested";
181
+ declined: "declined";
182
+ draft: "draft";
183
+ submitted: "submitted";
184
+ }>;
185
+ approvedAmount: z.ZodOptional<z.ZodString>;
186
+ feedback: z.ZodString;
187
+ reviewedBy: z.ZodNullable<z.ZodString>;
188
+ at: z.ZodString;
189
+ payment: z.ZodDefault<z.ZodNullable<z.ZodObject<{
190
+ mode: z.ZodEnum<{
191
+ isolated: "isolated";
192
+ shared: "shared";
193
+ }>;
194
+ id: z.ZodUUID;
195
+ until: z.ZodOptional<z.ZodISODateTime>;
196
+ }, z.core.$strip>>>;
197
+ }, z.core.$strip>>;
198
+ }, z.core.$strip>;
199
+ export declare const ownerCompensationView: z.ZodObject<{
200
+ agreements: z.ZodArray<z.ZodObject<{
201
+ id: z.ZodUUID;
202
+ version: z.ZodNumber;
203
+ terms: z.ZodObject<{
204
+ payee: z.ZodString;
205
+ title: z.ZodString;
206
+ document: z.ZodURL;
207
+ signedOn: z.ZodString;
208
+ start: z.ZodString;
209
+ end: z.ZodString;
210
+ ceiling: z.ZodString;
211
+ openingApproved: z.ZodString;
212
+ scope: z.ZodString;
213
+ }, z.core.$strict>;
214
+ recordedBy: z.ZodString;
215
+ at: z.ZodString;
216
+ approved: z.ZodString;
217
+ remaining: z.ZodString;
218
+ }, z.core.$strip>>;
219
+ requests: z.ZodArray<z.ZodObject<{
220
+ id: z.ZodUUID;
221
+ version: z.ZodNumber;
222
+ payee: z.ZodString;
223
+ agreementVersion: z.ZodNumber;
224
+ report: z.ZodObject<{
225
+ agreementId: z.ZodUUID;
226
+ amount: z.ZodOptional<z.ZodString>;
227
+ start: z.ZodString;
228
+ end: z.ZodString;
229
+ contributions: z.ZodString;
230
+ assessment: z.ZodString;
231
+ evidence: z.ZodArray<z.ZodURL>;
232
+ }, z.core.$strict>;
233
+ state: z.ZodEnum<{
234
+ approved: "approved";
235
+ changes_requested: "changes_requested";
236
+ declined: "declined";
237
+ draft: "draft";
238
+ submitted: "submitted";
239
+ }>;
240
+ approvedAmount: z.ZodOptional<z.ZodString>;
241
+ feedback: z.ZodString;
242
+ reviewedBy: z.ZodNullable<z.ZodString>;
243
+ at: z.ZodString;
244
+ payment: z.ZodDefault<z.ZodNullable<z.ZodObject<{
245
+ mode: z.ZodEnum<{
246
+ isolated: "isolated";
247
+ shared: "shared";
248
+ }>;
249
+ id: z.ZodUUID;
250
+ until: z.ZodOptional<z.ZodISODateTime>;
251
+ }, z.core.$strip>>>;
252
+ }, z.core.$strip>>;
253
+ history: z.ZodArray<z.ZodObject<{
254
+ sequence: z.ZodNumber;
255
+ actor: z.ZodString;
256
+ record: z.ZodUnion<readonly [z.ZodObject<{
257
+ id: z.ZodUUID;
258
+ version: z.ZodNumber;
259
+ payee: z.ZodString;
260
+ agreementVersion: z.ZodNumber;
261
+ report: z.ZodObject<{
262
+ agreementId: z.ZodUUID;
263
+ amount: z.ZodOptional<z.ZodString>;
264
+ start: z.ZodString;
265
+ end: z.ZodString;
266
+ contributions: z.ZodString;
267
+ assessment: z.ZodString;
268
+ evidence: z.ZodArray<z.ZodURL>;
269
+ }, z.core.$strict>;
270
+ state: z.ZodEnum<{
271
+ approved: "approved";
272
+ changes_requested: "changes_requested";
273
+ declined: "declined";
274
+ draft: "draft";
275
+ submitted: "submitted";
276
+ }>;
277
+ approvedAmount: z.ZodOptional<z.ZodString>;
278
+ feedback: z.ZodString;
279
+ reviewedBy: z.ZodNullable<z.ZodString>;
280
+ at: z.ZodString;
281
+ payment: z.ZodDefault<z.ZodNullable<z.ZodObject<{
282
+ mode: z.ZodEnum<{
283
+ isolated: "isolated";
284
+ shared: "shared";
285
+ }>;
286
+ id: z.ZodUUID;
287
+ until: z.ZodOptional<z.ZodISODateTime>;
288
+ }, z.core.$strip>>>;
289
+ }, z.core.$strip>, z.ZodObject<{
290
+ id: z.ZodUUID;
291
+ version: z.ZodNumber;
292
+ terms: z.ZodObject<{
293
+ payee: z.ZodString;
294
+ title: z.ZodString;
295
+ document: z.ZodURL;
296
+ signedOn: z.ZodString;
297
+ start: z.ZodString;
298
+ end: z.ZodString;
299
+ ceiling: z.ZodString;
300
+ openingApproved: z.ZodString;
301
+ scope: z.ZodString;
302
+ }, z.core.$strict>;
303
+ recordedBy: z.ZodString;
304
+ at: z.ZodString;
305
+ }, z.core.$strip>]>;
306
+ }, z.core.$strip>>;
307
+ payments: z.ZodArray<z.ZodObject<{
308
+ requestId: z.ZodUUID;
309
+ invoiceId: z.ZodString;
310
+ status: z.ZodString;
311
+ correlationId: z.ZodNullable<z.ZodString>;
312
+ refused: z.ZodNullable<z.ZodString>;
313
+ }, z.core.$strip>>;
314
+ }, z.core.$strip>;
315
+ export declare const compensationCommand: z.ZodDiscriminatedUnion<[z.ZodObject<{
316
+ type: z.ZodLiteral<"list">;
317
+ }, z.core.$strict>, z.ZodObject<{
318
+ type: z.ZodLiteral<"agreement">;
319
+ command: z.ZodObject<{
320
+ commandId: z.ZodUUID;
321
+ id: z.ZodUUID;
322
+ expectedVersion: z.ZodNumber;
323
+ terms: z.ZodObject<{
324
+ payee: z.ZodString;
325
+ title: z.ZodString;
326
+ document: z.ZodURL;
327
+ signedOn: z.ZodString;
328
+ start: z.ZodString;
329
+ end: z.ZodString;
330
+ ceiling: z.ZodString;
331
+ openingApproved: z.ZodString;
332
+ scope: z.ZodString;
333
+ }, z.core.$strict>;
334
+ }, z.core.$strict>;
335
+ }, z.core.$strict>, z.ZodObject<{
336
+ type: z.ZodLiteral<"review">;
337
+ command: z.ZodObject<{
338
+ commandId: z.ZodUUID;
339
+ id: z.ZodUUID;
340
+ expectedVersion: z.ZodNumber;
341
+ decision: z.ZodEnum<{
342
+ approved: "approved";
343
+ changes_requested: "changes_requested";
344
+ declined: "declined";
345
+ }>;
346
+ feedback: z.ZodString;
347
+ approvedAmount: z.ZodOptional<z.ZodString>;
348
+ }, z.core.$strict>;
349
+ }, z.core.$strict>, z.ZodObject<{
350
+ type: z.ZodLiteral<"prepare">;
351
+ command: z.ZodObject<{
352
+ commandId: z.ZodUUID;
353
+ id: z.ZodUUID;
354
+ expectedVersion: z.ZodNumber;
355
+ mode: z.ZodEnum<{
356
+ isolated: "isolated";
357
+ shared: "shared";
358
+ }>;
359
+ until: z.ZodOptional<z.ZodISODateTime>;
360
+ }, z.core.$strict>;
361
+ }, z.core.$strict>], "type">;
362
+ /** Owner send of a prepared shared payment, bound to the reviewed policy revision and digest. */
363
+ export declare const compensationSend: z.ZodObject<{
364
+ type: z.ZodLiteral<"send">;
365
+ id: z.ZodUUID;
366
+ expectedPolicy: z.ZodObject<{
367
+ revision: z.ZodNumber;
368
+ digest: z.ZodString;
369
+ }, z.core.$strip>;
370
+ }, z.core.$strict>;
@@ -0,0 +1,51 @@
1
+ import { z } from "zod";
2
+ export const requestId = z.uuid();
3
+ const account = z.string().regex(/^(?=.{2,64}$)([a-z\d]+[-_])*[a-z\d]+(\.([a-z\d]+[-_])*[a-z\d]+)*$/);
4
+ export const atomicUsdc = z.string().regex(/^[1-9][0-9]{0,17}$/);
5
+ const day = z.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine(s => {
6
+ const date = new Date(`${s}T00:00:00Z`);
7
+ return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === s;
8
+ }, "Enter a real calendar date");
9
+ const https = z.url().max(1000).refine(s => { const u = new URL(s); return u.protocol === "https:" && !u.username && !u.password; }, "Use an HTTPS link without credentials");
10
+ export const compensationTerms = z.object({
11
+ payee: account, title: z.string().trim().min(1).max(160), document: https,
12
+ signedOn: day, start: day, end: day, ceiling: atomicUsdc,
13
+ openingApproved: z.string().regex(/^(0|[1-9][0-9]{0,17})$/), scope: z.string().trim().max(2000),
14
+ }).strict().refine(t => t.start <= t.end, "The period end must follow its start")
15
+ .refine(t => BigInt(t.openingApproved) <= BigInt(t.ceiling), "Previously approved compensation exceeds the ceiling");
16
+ export const compensationReport = z.object({
17
+ agreementId: requestId, amount: atomicUsdc.optional(), start: day, end: day,
18
+ contributions: z.string().trim().min(1).max(4000), assessment: z.string().trim().min(1).max(2000),
19
+ evidence: z.array(https).max(12),
20
+ }).strict().refine(t => t.start <= t.end, "The period end must follow its start")
21
+ .refine(t => new TextEncoder().encode(JSON.stringify(t)).length <= 12_000, "Keep the report and links within 12 KB");
22
+ const mutation = { commandId: requestId, id: requestId, expectedVersion: z.number().int().nonnegative() };
23
+ export const paymentPreparation = z.object({ type: z.literal("prepare"), command: z.object({ ...mutation, mode: z.enum(["shared", "isolated"]), until: z.iso.datetime().optional() }).strict().refine(c => c.mode !== "isolated" || !!c.until, "Choose the isolated order's payment deadline") }).strict();
24
+ export const agreementCommand = z.object({ ...mutation, terms: compensationTerms }).strict();
25
+ export const reportCommand = z.object({ ...mutation, report: compensationReport, submit: z.boolean() }).strict();
26
+ export const reviewCommand = z.object({ ...mutation, decision: z.enum(["approved", "changes_requested", "declined"]), feedback: z.string().trim().max(2000), approvedAmount: atomicUsdc.optional() }).strict()
27
+ .refine(c => c.decision === "approved" || c.feedback.length > 0, "Explain the feedback or decline");
28
+ export const agreementRecord = z.object({ id: requestId, version: z.number().int().positive(), terms: compensationTerms, recordedBy: z.string(), at: z.string() });
29
+ export const requestRecord = z.object({
30
+ id: requestId, version: z.number().int().positive(), payee: account, agreementVersion: z.number().int().positive(),
31
+ report: compensationReport, state: z.enum(["draft", "submitted", "changes_requested", "approved", "declined"]),
32
+ approvedAmount: atomicUsdc.optional(),
33
+ feedback: z.string(), reviewedBy: z.string().nullable(), at: z.string(),
34
+ payment: z.object({ mode: z.enum(["shared", "isolated"]), id: requestId, until: z.iso.datetime().optional() }).nullable().default(null),
35
+ });
36
+ /** The owner's explicitly approved amount: the only amount a payment of this request may carry. */
37
+ export function approvedCompensation(request) {
38
+ if (request.state !== "approved" || !request.approvedAmount)
39
+ throw new Error("Approved compensation evidence is missing; restore and review the original record.");
40
+ return request.approvedAmount;
41
+ }
42
+ export const compensationView = z.object({ agreements: z.array(agreementRecord.extend({ approved: z.string().regex(/^\d+$/), remaining: z.string().regex(/^\d+$/) })), requests: z.array(requestRecord) });
43
+ export const ownerCompensationView = compensationView.extend({ history: z.array(z.object({ sequence: z.number(), actor: z.string(), record: z.union([requestRecord, agreementRecord]) })), payments: z.array(z.object({ requestId: z.uuid(), invoiceId: z.string(), status: z.string(), correlationId: z.string().nullable(), refused: z.string().nullable() })) });
44
+ export const compensationCommand = z.discriminatedUnion("type", [
45
+ z.object({ type: z.literal("list") }).strict(),
46
+ z.object({ type: z.literal("agreement"), command: agreementCommand }).strict(),
47
+ z.object({ type: z.literal("review"), command: reviewCommand }).strict(),
48
+ paymentPreparation,
49
+ ]);
50
+ /** Owner send of a prepared shared payment, bound to the reviewed policy revision and digest. */
51
+ export const compensationSend = z.object({ type: z.literal("send"), id: z.uuid(), expectedPolicy: z.object({ revision: z.number().int().nonnegative(), digest: z.string().regex(/^sha256:[0-9a-f]{64}$/) }) }).strict();
@@ -0,0 +1,86 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Agent connections: a user connects an external agent to their MultiAgency workspace with an explicit, fixed set of
4
+ * permitted actions, and can list or revoke it. One mechanism for every role; each role has its own principal and
5
+ * permission sets. The first set is a contractor's own compensation reports and their payment-status reads.
6
+ * A connection never carries every permission its user has.
7
+ */
8
+ /** The payee role, as sent on the wire. Released 1.5.0 clients expect "supplier" and do not read it (no compatibility, by decision). */
9
+ export declare const PAYEE_ROLE: "payee";
10
+ export declare const AGENT_CONNECTION_ROLES: readonly ["payee"];
11
+ /** The contractor-report set: read the account's own compensation records, submit its own reports. */
12
+ export declare const PAYEE_REPORT_PERMISSIONS: readonly ["compensation.read", "compensation.submit"];
13
+ export declare const agentConnectionPermission: z.ZodEnum<{
14
+ "compensation.read": "compensation.read";
15
+ "compensation.submit": "compensation.submit";
16
+ }>;
17
+ export type AgentConnectionPermission = z.infer<typeof agentConnectionPermission>;
18
+ /** A connection as its user sees it. Never the secret or its hash. */
19
+ export declare const agentConnection: z.ZodObject<{
20
+ id: z.ZodUUID;
21
+ label: z.ZodString;
22
+ role: z.ZodEnum<{
23
+ payee: "payee";
24
+ }>;
25
+ permissions: z.ZodArray<z.ZodEnum<{
26
+ "compensation.read": "compensation.read";
27
+ "compensation.submit": "compensation.submit";
28
+ }>>;
29
+ host: z.ZodString;
30
+ instance: z.ZodString;
31
+ account: z.ZodString;
32
+ agentId: z.ZodString;
33
+ createdAt: z.ZodISODateTime;
34
+ expiresAt: z.ZodISODateTime;
35
+ revoked: z.ZodBoolean;
36
+ }, z.core.$strip>;
37
+ export type AgentConnection = z.infer<typeof agentConnection>;
38
+ export declare const agentConnectionIssue: z.ZodObject<{
39
+ label: z.ZodString;
40
+ ttlSeconds: z.ZodDefault<z.ZodNumber>;
41
+ }, z.core.$strict>;
42
+ /** The token is shown once, at issue; only its hash is stored. */
43
+ export declare const agentConnectionStarted: z.ZodObject<{
44
+ connection: z.ZodObject<{
45
+ id: z.ZodUUID;
46
+ label: z.ZodString;
47
+ role: z.ZodEnum<{
48
+ payee: "payee";
49
+ }>;
50
+ permissions: z.ZodArray<z.ZodEnum<{
51
+ "compensation.read": "compensation.read";
52
+ "compensation.submit": "compensation.submit";
53
+ }>>;
54
+ host: z.ZodString;
55
+ instance: z.ZodString;
56
+ account: z.ZodString;
57
+ agentId: z.ZodString;
58
+ createdAt: z.ZodISODateTime;
59
+ expiresAt: z.ZodISODateTime;
60
+ revoked: z.ZodBoolean;
61
+ }, z.core.$strip>;
62
+ token: z.ZodString;
63
+ }, z.core.$strip>;
64
+ export declare const agentConnectionList: z.ZodObject<{
65
+ connections: z.ZodArray<z.ZodObject<{
66
+ id: z.ZodUUID;
67
+ label: z.ZodString;
68
+ role: z.ZodEnum<{
69
+ payee: "payee";
70
+ }>;
71
+ permissions: z.ZodArray<z.ZodEnum<{
72
+ "compensation.read": "compensation.read";
73
+ "compensation.submit": "compensation.submit";
74
+ }>>;
75
+ host: z.ZodString;
76
+ instance: z.ZodString;
77
+ account: z.ZodString;
78
+ agentId: z.ZodString;
79
+ createdAt: z.ZodISODateTime;
80
+ expiresAt: z.ZodISODateTime;
81
+ revoked: z.ZodBoolean;
82
+ }, z.core.$strip>>;
83
+ }, z.core.$strip>;
84
+ export declare const agentConnectionRevoked: z.ZodObject<{
85
+ revoked: z.ZodLiteral<true>;
86
+ }, z.core.$strip>;
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Agent connections: a user connects an external agent to their MultiAgency workspace with an explicit, fixed set of
4
+ * permitted actions, and can list or revoke it. One mechanism for every role; each role has its own principal and
5
+ * permission sets. The first set is a contractor's own compensation reports and their payment-status reads.
6
+ * A connection never carries every permission its user has.
7
+ */
8
+ /** The payee role, as sent on the wire. Released 1.5.0 clients expect "supplier" and do not read it (no compatibility, by decision). */
9
+ export const PAYEE_ROLE = "payee";
10
+ export const AGENT_CONNECTION_ROLES = [PAYEE_ROLE];
11
+ /** The contractor-report set: read the account's own compensation records, submit its own reports. */
12
+ export const PAYEE_REPORT_PERMISSIONS = ["compensation.read", "compensation.submit"];
13
+ export const agentConnectionPermission = z.enum(PAYEE_REPORT_PERMISSIONS);
14
+ /** A connection as its user sees it. Never the secret or its hash. */
15
+ export const agentConnection = z.object({
16
+ id: z.uuid(),
17
+ label: z.string().min(1).max(80),
18
+ role: z.enum(AGENT_CONNECTION_ROLES),
19
+ permissions: z.array(agentConnectionPermission).min(1),
20
+ /** What the connection is bound to: it is refused anywhere else. */
21
+ host: z.string().min(1),
22
+ instance: z.string().min(1),
23
+ account: z.string().min(2),
24
+ agentId: z.string().min(1),
25
+ createdAt: z.iso.datetime(),
26
+ expiresAt: z.iso.datetime(),
27
+ revoked: z.boolean(),
28
+ });
29
+ export const agentConnectionIssue = z.strictObject({
30
+ label: z.string().trim().min(1).max(80),
31
+ ttlSeconds: z.number().int().min(60).max(86_400).default(3_600),
32
+ });
33
+ /** The token is shown once, at issue; only its hash is stored. */
34
+ export const agentConnectionStarted = z.object({ connection: agentConnection, token: z.string().regex(/^tac_[0-9a-f-]{36}\.[A-Za-z0-9_-]{43}$/) });
35
+ export const agentConnectionList = z.object({ connections: z.array(agentConnection) });
36
+ export const agentConnectionRevoked = z.object({ revoked: z.literal(true) });
@@ -0,0 +1,141 @@
1
+ import { z } from "zod";
2
+ import { AppScope } from "./app-consent.js";
3
+ import type { OwnerAction } from "./owner-inputs.js";
4
+ /**
5
+ * What an app deployment may do through `/apps/v1`: the gateway enforces with these same definitions, and
6
+ * the app client is typed by them. Presenting never authorizes.
7
+ */
8
+ /** Reads the app may make with `read` consent. Workflow records (agreements, invoices, work orders) stay out. */
9
+ export declare const APP_READS: readonly ["instance", "overview", "policyHistory", "activity", "unresolved", "held", "ledger", "ledgerCsv", "owner/actions", "owner/pending", "owner/status", "paymentHistory", "paymentStatus"];
10
+ /** Owner actions with `owner` consent: prepared here, completed only by the owner's own wallet signature at submit. */
11
+ export declare const APP_OWNER: readonly ["owner/prepare", "owner/submit", "owner/status", "owner/pending", "owner/actions"];
12
+ /**
13
+ * Payout requests with `payout` consent: each sent at most once under the app's `requestId`, within the owner-signed
14
+ * policy, and held for the owner's vote when the policy says so. `held` shows what waits for that vote. `deposit` gives a
15
+ * one-time address that credits USDC, or wNEAR, to the agent's confidential balance, so the app can fund it; it moves
16
+ * nothing out.
17
+ */
18
+ export declare const APP_PAYOUT: readonly ["payouts/request", "payouts/status", "held", "deposit"];
19
+ export type AppProcedure = (typeof APP_READS)[number] | (typeof APP_OWNER)[number] | (typeof APP_PAYOUT)[number];
20
+ /** Whether consent scopes cover a procedure (the gateway also requires the owner's own access to it). */
21
+ export declare const appScopesCover: (scopes: readonly AppScope[], path: string) => boolean;
22
+ /** Whether a parsed owner action is one the app may prepare (signer `wallet` is checked separately). */
23
+ export declare function appMayAsk(action: {
24
+ type: string;
25
+ payees?: readonly unknown[];
26
+ }): boolean;
27
+ type Of<T extends OwnerAction["type"]> = Extract<OwnerAction, {
28
+ type: T;
29
+ }>;
30
+ /** The owner actions an app may prepare, as types. The gateway's check (`appMayAsk`) is the authority. */
31
+ export type AppOwnerAction = (Omit<Of<"agent_create">, "payees"> & {
32
+ owner: NonNullable<Of<"agent_create">["owner"]>;
33
+ }) | Of<"agent_freeze"> | Of<"agent_unfreeze"> | Of<"grant_issue"> | Of<"grant_revoke"> | Of<"approval_vote"> | Of<"policy_update">;
34
+ /**
35
+ * A NEP-366 owner action the platform holds for the owner to sign on its confirm page (`/confirm/<token>`). The link
36
+ * shows the action's terms to whoever holds it; the bytes to sign go only to whoever presents the owner's signature over
37
+ * the link's text, which the page asks the owner's wallet for. Open it for the owner right away: the intent expires in minutes. Follow the outcome with
38
+ * `owner/status`; the app can't submit it.
39
+ */
40
+ export declare const appConfirm: z.ZodObject<{
41
+ url: z.ZodString;
42
+ expiresAt: z.ZodString;
43
+ }, z.core.$loose>;
44
+ /** `GET /apps/v1/agents/<agent>`: what the owner's consent must name. */
45
+ export declare const appAgent: z.ZodObject<{
46
+ agent: z.ZodString;
47
+ owner: z.ZodString;
48
+ agentId: z.ZodNullable<z.ZodString>;
49
+ created: z.ZodBoolean;
50
+ host: z.ZodString;
51
+ deployment: z.ZodString;
52
+ }, z.core.$loose>;
53
+ /** A stored consent as the platform shows it: never its message, nonce or signature. Times are epoch milliseconds. */
54
+ export declare const appConsentView: z.ZodObject<{
55
+ id: z.ZodString;
56
+ deployment: z.ZodString;
57
+ host: z.ZodString;
58
+ organization: z.ZodString;
59
+ owner: z.ZodString;
60
+ agent: z.ZodString;
61
+ agentId: z.ZodString;
62
+ scopes: z.ZodArray<z.ZodEnum<{
63
+ owner: "owner";
64
+ payout: "payout";
65
+ read: "read";
66
+ }>>;
67
+ expiresAt: z.ZodNumber;
68
+ createdAt: z.ZodNumber;
69
+ publicKey: z.ZodString;
70
+ revoked: z.ZodBoolean;
71
+ revokedAt: z.ZodNullable<z.ZodNumber>;
72
+ }, z.core.$loose>;
73
+ export declare const appConsentList: z.ZodObject<{
74
+ consents: z.ZodArray<z.ZodObject<{
75
+ id: z.ZodString;
76
+ deployment: z.ZodString;
77
+ host: z.ZodString;
78
+ organization: z.ZodString;
79
+ owner: z.ZodString;
80
+ agent: z.ZodString;
81
+ agentId: z.ZodString;
82
+ scopes: z.ZodArray<z.ZodEnum<{
83
+ owner: "owner";
84
+ payout: "payout";
85
+ read: "read";
86
+ }>>;
87
+ expiresAt: z.ZodNumber;
88
+ createdAt: z.ZodNumber;
89
+ publicKey: z.ZodString;
90
+ revoked: z.ZodBoolean;
91
+ revokedAt: z.ZodNullable<z.ZodNumber>;
92
+ }, z.core.$loose>>;
93
+ }, z.core.$loose>;
94
+ export declare const appConsentStored: z.ZodObject<{
95
+ consent: z.ZodObject<{
96
+ id: z.ZodString;
97
+ deployment: z.ZodString;
98
+ host: z.ZodString;
99
+ organization: z.ZodString;
100
+ owner: z.ZodString;
101
+ agent: z.ZodString;
102
+ agentId: z.ZodString;
103
+ scopes: z.ZodArray<z.ZodEnum<{
104
+ owner: "owner";
105
+ payout: "payout";
106
+ read: "read";
107
+ }>>;
108
+ expiresAt: z.ZodNumber;
109
+ createdAt: z.ZodNumber;
110
+ publicKey: z.ZodString;
111
+ revoked: z.ZodBoolean;
112
+ revokedAt: z.ZodNullable<z.ZodNumber>;
113
+ }, z.core.$loose>;
114
+ }, z.core.$loose>;
115
+ /** `POST /apps/v1/setup`: the hosted agent's name and its setup consent (agent ID `unborn`). */
116
+ export declare const appSetupStored: z.ZodObject<{
117
+ agent: z.ZodString;
118
+ consent: z.ZodObject<{
119
+ id: z.ZodString;
120
+ deployment: z.ZodString;
121
+ host: z.ZodString;
122
+ organization: z.ZodString;
123
+ owner: z.ZodString;
124
+ agent: z.ZodString;
125
+ agentId: z.ZodString;
126
+ scopes: z.ZodArray<z.ZodEnum<{
127
+ owner: "owner";
128
+ payout: "payout";
129
+ read: "read";
130
+ }>>;
131
+ expiresAt: z.ZodNumber;
132
+ createdAt: z.ZodNumber;
133
+ publicKey: z.ZodString;
134
+ revoked: z.ZodBoolean;
135
+ revokedAt: z.ZodNullable<z.ZodNumber>;
136
+ }, z.core.$loose>;
137
+ }, z.core.$loose>;
138
+ export declare const appRevoked: z.ZodObject<{
139
+ revoked: z.ZodLiteral<true>;
140
+ }, z.core.$loose>;
141
+ export {};