@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,5 @@
1
+ /** The package name and version, independent of the wire manifest version (`payeeContract.version`). */
2
+ export declare const contractPackage: {
3
+ readonly name: "@multiagency/sdk";
4
+ readonly version: "0.3.1";
5
+ };
@@ -0,0 +1,2 @@
1
+ /** The package name and version, independent of the wire manifest version (`payeeContract.version`). */
2
+ export const contractPackage = { name: "@multiagency/sdk", version: "0.3.1" };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `@multiagency/sdk/payee`: the payee side of the contract. It imports zod alone; the owner entry's oRPC and AG-UI
3
+ * dependencies are installed but never loaded by this entry.
4
+ */
5
+ export { contractPackage } from "./package-version.js";
6
+ export { payeeContract, compatiblePayeeFrontend, compatibleRelease } from "../payee-contract.js";
7
+ export * from "../compensation-contract.js";
8
+ export * from "./payee.js";
9
+ export * from "./client.js";
10
+ export * from "./agent-connection.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `@multiagency/sdk/payee`: the payee side of the contract. It imports zod alone; the owner entry's oRPC and AG-UI
3
+ * dependencies are installed but never loaded by this entry.
4
+ */
5
+ export { contractPackage } from "./package-version.js";
6
+ export { payeeContract, compatiblePayeeFrontend, compatibleRelease } from "../payee-contract.js";
7
+ export * from "../compensation-contract.js";
8
+ export * from "./payee.js";
9
+ export * from "./client.js";
10
+ export * from "./agent-connection.js";
@@ -0,0 +1,326 @@
1
+ import { z } from "zod";
2
+ /** Payee HTTP responses under the instance base. The platform's handlers are tested against these schemas. */
3
+ export declare const invoiceStatus: z.ZodEnum<{
4
+ busy: "busy";
5
+ failed: "failed";
6
+ needs_agreement: "needs_agreement";
7
+ needs_review: "needs_review";
8
+ paid: "paid";
9
+ paying: "paying";
10
+ prepared: "prepared";
11
+ refused: "refused";
12
+ unknown: "unknown";
13
+ waiting: "waiting";
14
+ }>;
15
+ export declare const agreementStatus: z.ZodEnum<{
16
+ agreed: "agreed";
17
+ declined: "declined";
18
+ filed: "filed";
19
+ proposed: "proposed";
20
+ requested: "requested";
21
+ }>;
22
+ export declare const errorBody: z.ZodObject<{
23
+ error: z.ZodString;
24
+ code: z.ZodOptional<z.ZodString>;
25
+ }, z.core.$strip>;
26
+ export declare const session: z.ZodObject<{
27
+ account: z.ZodNullable<z.ZodString>;
28
+ agreed: z.ZodBoolean;
29
+ }, z.core.$strip>;
30
+ export declare const compensationSession: z.ZodObject<{
31
+ account: z.ZodNullable<z.ZodString>;
32
+ }, z.core.$strip>;
33
+ export declare const signInResult: z.ZodObject<{
34
+ account: z.ZodString;
35
+ agreed: z.ZodOptional<z.ZodBoolean>;
36
+ }, z.core.$strip>;
37
+ export declare const signOutResult: z.ZodObject<{
38
+ account: z.ZodNull;
39
+ }, z.core.$strip>;
40
+ export declare const invoice: z.ZodObject<{
41
+ id: z.ZodString;
42
+ amount: z.ZodNullable<z.ZodString>;
43
+ note: z.ZodString;
44
+ filedAt: z.ZodString;
45
+ status: z.ZodEnum<{
46
+ busy: "busy";
47
+ failed: "failed";
48
+ needs_agreement: "needs_agreement";
49
+ needs_review: "needs_review";
50
+ paid: "paid";
51
+ paying: "paying";
52
+ prepared: "prepared";
53
+ refused: "refused";
54
+ unknown: "unknown";
55
+ waiting: "waiting";
56
+ }>;
57
+ revisionConflict: z.ZodBoolean;
58
+ }, z.core.$strip>;
59
+ export declare const agreement: z.ZodObject<{
60
+ id: z.ZodString;
61
+ origin: z.ZodEnum<{
62
+ owner: "owner";
63
+ payee: "payee";
64
+ }>;
65
+ amount: z.ZodString;
66
+ note: z.ZodString;
67
+ submission: z.ZodOptional<z.ZodString>;
68
+ terms: z.ZodOptional<z.ZodObject<{
69
+ maxAmount: z.ZodString;
70
+ until: z.ZodString;
71
+ }, z.core.$strip>>;
72
+ status: z.ZodEnum<{
73
+ agreed: "agreed";
74
+ declined: "declined";
75
+ filed: "filed";
76
+ proposed: "proposed";
77
+ requested: "requested";
78
+ }>;
79
+ at: z.ZodString;
80
+ }, z.core.$strip>;
81
+ export declare const invoicesView: z.ZodObject<{
82
+ invoices: z.ZodArray<z.ZodObject<{
83
+ id: z.ZodString;
84
+ amount: z.ZodNullable<z.ZodString>;
85
+ note: z.ZodString;
86
+ filedAt: z.ZodString;
87
+ status: z.ZodEnum<{
88
+ busy: "busy";
89
+ failed: "failed";
90
+ needs_agreement: "needs_agreement";
91
+ needs_review: "needs_review";
92
+ paid: "paid";
93
+ paying: "paying";
94
+ prepared: "prepared";
95
+ refused: "refused";
96
+ unknown: "unknown";
97
+ waiting: "waiting";
98
+ }>;
99
+ revisionConflict: z.ZodBoolean;
100
+ }, z.core.$strip>>;
101
+ agreements: z.ZodArray<z.ZodObject<{
102
+ id: z.ZodString;
103
+ origin: z.ZodEnum<{
104
+ owner: "owner";
105
+ payee: "payee";
106
+ }>;
107
+ amount: z.ZodString;
108
+ note: z.ZodString;
109
+ submission: z.ZodOptional<z.ZodString>;
110
+ terms: z.ZodOptional<z.ZodObject<{
111
+ maxAmount: z.ZodString;
112
+ until: z.ZodString;
113
+ }, z.core.$strip>>;
114
+ status: z.ZodEnum<{
115
+ agreed: "agreed";
116
+ declined: "declined";
117
+ filed: "filed";
118
+ proposed: "proposed";
119
+ requested: "requested";
120
+ }>;
121
+ at: z.ZodString;
122
+ }, z.core.$strip>>;
123
+ agreed: z.ZodBoolean;
124
+ }, z.core.$strip>;
125
+ /** POST /api/invoices and /api/invoices/:id/continue. An account not yet agreed receives an agreement request instead. */
126
+ export declare const fileResult: z.ZodUnion<readonly [z.ZodObject<{
127
+ id: z.ZodString;
128
+ status: z.ZodEnum<{
129
+ busy: "busy";
130
+ failed: "failed";
131
+ needs_agreement: "needs_agreement";
132
+ needs_review: "needs_review";
133
+ paid: "paid";
134
+ paying: "paying";
135
+ prepared: "prepared";
136
+ refused: "refused";
137
+ unknown: "unknown";
138
+ waiting: "waiting";
139
+ }>;
140
+ revisionConflict: z.ZodOptional<z.ZodBoolean>;
141
+ }, z.core.$strip>, z.ZodObject<{
142
+ id: z.ZodString;
143
+ status: z.ZodUnion<readonly [z.ZodEnum<{
144
+ agreed: "agreed";
145
+ declined: "declined";
146
+ filed: "filed";
147
+ proposed: "proposed";
148
+ requested: "requested";
149
+ }>, z.ZodLiteral<"busy">]>;
150
+ }, z.core.$strip>]>;
151
+ export declare const workOrderSummary: z.ZodObject<{
152
+ id: z.ZodUUID;
153
+ amount: z.ZodString;
154
+ note: z.ZodString;
155
+ until: z.ZodString;
156
+ createdAt: z.ZodString;
157
+ }, z.core.$strip>;
158
+ export declare const workOrderList: z.ZodObject<{
159
+ orders: z.ZodArray<z.ZodObject<{
160
+ id: z.ZodUUID;
161
+ amount: z.ZodString;
162
+ note: z.ZodString;
163
+ until: z.ZodString;
164
+ createdAt: z.ZodString;
165
+ }, z.core.$strip>>;
166
+ }, z.core.$strip>;
167
+ export declare const publicWorkOrder: z.ZodObject<{
168
+ id: z.ZodUUID;
169
+ amount: z.ZodString;
170
+ note: z.ZodString;
171
+ until: z.ZodString;
172
+ createdAt: z.ZodString;
173
+ invoice: z.ZodNullable<z.ZodObject<{
174
+ id: z.ZodString;
175
+ amount: z.ZodNullable<z.ZodString>;
176
+ note: z.ZodString;
177
+ filedAt: z.ZodString;
178
+ status: z.ZodEnum<{
179
+ busy: "busy";
180
+ failed: "failed";
181
+ needs_agreement: "needs_agreement";
182
+ needs_review: "needs_review";
183
+ paid: "paid";
184
+ paying: "paying";
185
+ prepared: "prepared";
186
+ refused: "refused";
187
+ unknown: "unknown";
188
+ waiting: "waiting";
189
+ }>;
190
+ revisionConflict: z.ZodBoolean;
191
+ }, z.core.$strip>>;
192
+ ready: z.ZodBoolean;
193
+ unavailable: z.ZodBoolean;
194
+ }, z.core.$strip>;
195
+ export declare const payeeWorkOrderRequest: z.ZodObject<{
196
+ submission: z.ZodUUID;
197
+ amount: z.ZodString;
198
+ note: z.ZodString;
199
+ until: z.ZodISODateTime;
200
+ }, z.core.$strict>;
201
+ export declare const workOrderRequestResult: z.ZodObject<{
202
+ id: z.ZodUUID;
203
+ status: z.ZodLiteral<"requested">;
204
+ }, z.core.$strip>;
205
+ /** Member identities are redacted to "owner" before they reach the payee. */
206
+ export declare const payeeCompensationView: z.ZodObject<{
207
+ account: z.ZodString;
208
+ agreements: z.ZodArray<z.ZodObject<{
209
+ id: z.ZodUUID;
210
+ version: z.ZodNumber;
211
+ terms: z.ZodObject<{
212
+ payee: z.ZodString;
213
+ title: z.ZodString;
214
+ document: z.ZodURL;
215
+ signedOn: z.ZodString;
216
+ start: z.ZodString;
217
+ end: z.ZodString;
218
+ ceiling: z.ZodString;
219
+ openingApproved: z.ZodString;
220
+ scope: z.ZodString;
221
+ }, z.core.$strict>;
222
+ recordedBy: z.ZodString;
223
+ at: z.ZodString;
224
+ approved: z.ZodString;
225
+ remaining: z.ZodString;
226
+ }, z.core.$strip>>;
227
+ requests: z.ZodArray<z.ZodObject<{
228
+ id: z.ZodUUID;
229
+ version: z.ZodNumber;
230
+ payee: z.ZodString;
231
+ agreementVersion: z.ZodNumber;
232
+ report: z.ZodObject<{
233
+ agreementId: z.ZodUUID;
234
+ amount: z.ZodOptional<z.ZodString>;
235
+ start: z.ZodString;
236
+ end: z.ZodString;
237
+ contributions: z.ZodString;
238
+ assessment: z.ZodString;
239
+ evidence: z.ZodArray<z.ZodURL>;
240
+ }, z.core.$strict>;
241
+ state: z.ZodEnum<{
242
+ approved: "approved";
243
+ changes_requested: "changes_requested";
244
+ declined: "declined";
245
+ draft: "draft";
246
+ submitted: "submitted";
247
+ }>;
248
+ approvedAmount: z.ZodOptional<z.ZodString>;
249
+ feedback: z.ZodString;
250
+ reviewedBy: z.ZodNullable<z.ZodString>;
251
+ at: z.ZodString;
252
+ payment: z.ZodDefault<z.ZodNullable<z.ZodObject<{
253
+ mode: z.ZodEnum<{
254
+ isolated: "isolated";
255
+ shared: "shared";
256
+ }>;
257
+ id: z.ZodUUID;
258
+ until: z.ZodOptional<z.ZodISODateTime>;
259
+ }, z.core.$strip>>>;
260
+ }, z.core.$strip>>;
261
+ history: z.ZodArray<z.ZodObject<{
262
+ sequence: z.ZodNumber;
263
+ actor: z.ZodString;
264
+ record: z.ZodUnion<readonly [z.ZodObject<{
265
+ id: z.ZodUUID;
266
+ version: z.ZodNumber;
267
+ payee: z.ZodString;
268
+ agreementVersion: z.ZodNumber;
269
+ report: z.ZodObject<{
270
+ agreementId: z.ZodUUID;
271
+ amount: z.ZodOptional<z.ZodString>;
272
+ start: z.ZodString;
273
+ end: z.ZodString;
274
+ contributions: z.ZodString;
275
+ assessment: z.ZodString;
276
+ evidence: z.ZodArray<z.ZodURL>;
277
+ }, z.core.$strict>;
278
+ state: z.ZodEnum<{
279
+ approved: "approved";
280
+ changes_requested: "changes_requested";
281
+ declined: "declined";
282
+ draft: "draft";
283
+ submitted: "submitted";
284
+ }>;
285
+ approvedAmount: z.ZodOptional<z.ZodString>;
286
+ feedback: z.ZodString;
287
+ reviewedBy: z.ZodNullable<z.ZodString>;
288
+ at: z.ZodString;
289
+ payment: z.ZodDefault<z.ZodNullable<z.ZodObject<{
290
+ mode: z.ZodEnum<{
291
+ isolated: "isolated";
292
+ shared: "shared";
293
+ }>;
294
+ id: z.ZodUUID;
295
+ until: z.ZodOptional<z.ZodISODateTime>;
296
+ }, z.core.$strip>>>;
297
+ }, z.core.$strip>, z.ZodObject<{
298
+ id: z.ZodUUID;
299
+ version: z.ZodNumber;
300
+ terms: z.ZodObject<{
301
+ payee: z.ZodString;
302
+ title: z.ZodString;
303
+ document: z.ZodURL;
304
+ signedOn: z.ZodString;
305
+ start: z.ZodString;
306
+ end: z.ZodString;
307
+ ceiling: z.ZodString;
308
+ openingApproved: z.ZodString;
309
+ scope: z.ZodString;
310
+ }, z.core.$strict>;
311
+ recordedBy: z.ZodString;
312
+ at: z.ZodString;
313
+ }, z.core.$strip>]>;
314
+ }, z.core.$strip>>;
315
+ payments: z.ZodArray<z.ZodObject<{
316
+ requestId: z.ZodUUID;
317
+ id: z.ZodString;
318
+ status: z.ZodString;
319
+ }, z.core.$strip>>;
320
+ }, z.core.$strip>;
321
+ export type InvoiceStatus = z.infer<typeof invoiceStatus>;
322
+ export type Invoice = z.infer<typeof invoice>;
323
+ export type Agreement = z.infer<typeof agreement>;
324
+ export type PublicWorkOrder = z.infer<typeof publicWorkOrder>;
325
+ export type PayeeWorkOrderRequest = z.infer<typeof payeeWorkOrderRequest>;
326
+ export type PayeeCompensationView = z.infer<typeof payeeCompensationView>;
@@ -0,0 +1,32 @@
1
+ import { z } from "zod";
2
+ import { agreementRecord, compensationView, requestRecord } from "../compensation-contract.js";
3
+ /** Payee HTTP responses under the instance base. The platform's handlers are tested against these schemas. */
4
+ export const invoiceStatus = z.enum(["needs_agreement", "refused", "busy", "prepared", "waiting", "paying", "paid", "failed", "unknown", "needs_review"]);
5
+ export const agreementStatus = z.enum(["requested", "proposed", "agreed", "filed", "declined"]);
6
+ export const errorBody = z.object({ error: z.string(), code: z.string().optional() });
7
+ export const session = z.object({ account: z.string().nullable(), agreed: z.boolean() });
8
+ export const compensationSession = z.object({ account: z.string().nullable() });
9
+ export const signInResult = z.object({ account: z.string(), agreed: z.boolean().optional() });
10
+ export const signOutResult = z.object({ account: z.null() });
11
+ export const invoice = z.object({ id: z.string(), amount: z.string().nullable(), note: z.string(), filedAt: z.string(), status: invoiceStatus, revisionConflict: z.boolean() });
12
+ export const agreement = z.object({ id: z.string(), origin: z.enum(["owner", "payee"]), amount: z.string(), note: z.string(), submission: z.string().optional(),
13
+ terms: z.object({ maxAmount: z.string(), until: z.string() }).optional(), status: agreementStatus, at: z.string() });
14
+ export const invoicesView = z.object({ invoices: z.array(invoice), agreements: z.array(agreement), agreed: z.boolean() });
15
+ /** POST /api/invoices and /api/invoices/:id/continue. An account not yet agreed receives an agreement request instead. */
16
+ export const fileResult = z.union([
17
+ z.object({ id: z.string(), status: invoiceStatus, revisionConflict: z.boolean().optional() }),
18
+ z.object({ id: z.string(), status: z.union([agreementStatus, z.literal("busy")]) }),
19
+ ]);
20
+ export const workOrderSummary = z.object({ id: z.uuid(), amount: z.string(), note: z.string(), until: z.string(), createdAt: z.string() });
21
+ export const workOrderList = z.object({ orders: z.array(workOrderSummary) });
22
+ export const publicWorkOrder = workOrderSummary.extend({ invoice: invoice.nullable(), ready: z.boolean(), unavailable: z.boolean() });
23
+ export const payeeWorkOrderRequest = z.object({ submission: z.uuid(), amount: z.string(), note: z.string().trim().min(1).max(200), until: z.iso.datetime() }).strict();
24
+ export const workOrderRequestResult = z.object({ id: z.uuid(), status: z.literal("requested") });
25
+ /** Member identities are redacted to "owner" before they reach the payee. */
26
+ export const payeeCompensationView = z.object({
27
+ account: z.string(),
28
+ agreements: compensationView.shape.agreements,
29
+ requests: z.array(requestRecord),
30
+ history: z.array(z.object({ sequence: z.number(), actor: z.string(), record: z.union([requestRecord, agreementRecord]) })),
31
+ payments: z.array(z.object({ requestId: z.uuid(), id: z.string(), status: z.string() })),
32
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The procedure→permission map, as data. Single source: the gateway enforces with this same module
3
+ * (src/gateway/allowlist.ts); apps may mirror it to present controls, but presenting never authorizes.
4
+ */
5
+ /** What an admitted account may do with an agent (resolved by the gateway from ownership and DAO roles). */
6
+ export type Access = {
7
+ canSign: boolean;
8
+ canPropose: boolean;
9
+ canVote: boolean;
10
+ canExecute: boolean;
11
+ canManage: boolean;
12
+ };
13
+ /**
14
+ * Agent-server procedures by capability, shared with the dashboard. Unknown paths are denied even
15
+ * to wallet owners. These controls do not replace the provider's policy, grant or owner signature.
16
+ */
17
+ export declare const READS: Set<string>;
18
+ export declare const OWNER_PROPOSALS: Set<string>;
19
+ /** Whether this admitted account may call `path` (`owner/prepare`, without the `/rpc/` prefix). */
20
+ export declare function mayCall(access: Access, path: string): boolean;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Agent-server procedures by capability, shared with the dashboard. Unknown paths are denied even
3
+ * to wallet owners. These controls do not replace the provider's policy, grant or owner signature.
4
+ */
5
+ export const READS = new Set([
6
+ "setup",
7
+ "instance",
8
+ "overview",
9
+ "policyHistory",
10
+ "treasury/get",
11
+ "activity",
12
+ "unresolved",
13
+ "held",
14
+ "autopilot/get",
15
+ "strategy/get",
16
+ "autopilot/evidence",
17
+ "autopilot/log",
18
+ "inbox/list",
19
+ "ledger",
20
+ "ledgerCsv",
21
+ "reconcileBooks",
22
+ "owner/status",
23
+ "owner/pending",
24
+ "owner/actions",
25
+ "paymentHistory",
26
+ "paymentStatus",
27
+ "payouts/status",
28
+ "agreements/list",
29
+ "invoices",
30
+ "compensation/list",
31
+ "workOrders/list",
32
+ "workOrders/get",
33
+ "workOrders/status",
34
+ "demoGuide/compose",
35
+ ]);
36
+ export const OWNER_PROPOSALS = new Set([
37
+ "owner/prepare",
38
+ "agreements/propose",
39
+ "agreements/offer",
40
+ "workOrders/create",
41
+ "workOrders/prepare",
42
+ ]);
43
+ const PREPARE = new Set([...OWNER_PROPOSALS, "rebalance", "externalPlan", "steward/propose", "deposit", "treasury/fund", "workOrders/deposit"]);
44
+ const EXECUTE = new Set(["workOrders/file", "compensation/prepare", "compensation/send", "compensation/review", "pay", "payouts/request", "sweep", "executePlan", "autopilot/tick", "autopilot/enable"]);
45
+ const MANAGE = new Set(["compensation/agreement", "strategy/save", "treasury/link", "treasury/unlink", "treasury/setConfidential", "agreements/decline"]);
46
+ const MAINTAIN = new Set(["autopilot/stop", "recover", "inbox/dismiss", "cancelPreparedInvoice"]);
47
+ /** Whether this admitted account may call `path` (`owner/prepare`, without the `/rpc/` prefix). */
48
+ export function mayCall(access, path) {
49
+ if (READS.has(path))
50
+ return true;
51
+ if (PREPARE.has(path))
52
+ return access.canSign || access.canPropose;
53
+ if (path === "owner/submit" || path === "workOrders/submit")
54
+ return access.canSign;
55
+ if (EXECUTE.has(path))
56
+ return access.canExecute;
57
+ if (MANAGE.has(path))
58
+ return access.canManage;
59
+ if (path === "autopilot/set")
60
+ return access.canManage && access.canExecute;
61
+ if (MAINTAIN.has(path))
62
+ return access.canManage || access.canExecute;
63
+ return false;
64
+ }
@@ -0,0 +1,178 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * `GET /gw/proposals?dao=<account>`: the DAO's recent agent-owner signing proposals, each matched against what the
4
+ * agents wait for. Single source: the gateway's `decodeProposals` (src/gateway/proposals.ts) returns these types.
5
+ */
6
+ export declare const proposalCheck: z.ZodUnion<readonly [z.ZodObject<{
7
+ kind: z.ZodLiteral<"verified">;
8
+ standard: z.ZodLiteral<"nep413">;
9
+ message: z.ZodUnknown;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ kind: z.ZodLiteral<"verified">;
12
+ standard: z.ZodLiteral<"nep366">;
13
+ receiver: z.ZodString;
14
+ methods: z.ZodArray<z.ZodString>;
15
+ }, z.core.$strip>, z.ZodObject<{
16
+ kind: z.ZodLiteral<"mismatch">;
17
+ reason: z.ZodString;
18
+ }, z.core.$strip>]>;
19
+ export declare const decodedProposal: z.ZodUnion<readonly [z.ZodObject<{
20
+ id: z.ZodNumber;
21
+ proposer: z.ZodString;
22
+ description: z.ZodString;
23
+ status: z.ZodString;
24
+ submittedAt: z.ZodString;
25
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
26
+ hash: z.ZodString;
27
+ what: z.ZodLiteral<"agent">;
28
+ agent: z.ZodString;
29
+ type: z.ZodString;
30
+ correlationId: z.ZodString;
31
+ expiresAt: z.ZodString;
32
+ state: z.ZodEnum<{
33
+ done: "done";
34
+ expired: "expired";
35
+ waiting: "waiting";
36
+ }>;
37
+ check: z.ZodUnion<readonly [z.ZodObject<{
38
+ kind: z.ZodLiteral<"verified">;
39
+ standard: z.ZodLiteral<"nep413">;
40
+ message: z.ZodUnknown;
41
+ }, z.core.$strip>, z.ZodObject<{
42
+ kind: z.ZodLiteral<"verified">;
43
+ standard: z.ZodLiteral<"nep366">;
44
+ receiver: z.ZodString;
45
+ methods: z.ZodArray<z.ZodString>;
46
+ }, z.core.$strip>, z.ZodObject<{
47
+ kind: z.ZodLiteral<"mismatch">;
48
+ reason: z.ZodString;
49
+ }, z.core.$strip>]>;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ id: z.ZodNumber;
52
+ proposer: z.ZodString;
53
+ description: z.ZodString;
54
+ status: z.ZodString;
55
+ submittedAt: z.ZodString;
56
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
57
+ hash: z.ZodString;
58
+ what: z.ZodLiteral<"unknown">;
59
+ }, z.core.$strip>, z.ZodObject<{
60
+ id: z.ZodNumber;
61
+ proposer: z.ZodString;
62
+ description: z.ZodString;
63
+ status: z.ZodString;
64
+ submittedAt: z.ZodString;
65
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
66
+ hash: z.ZodString;
67
+ what: z.ZodLiteral<"unchecked">;
68
+ unanswered: z.ZodArray<z.ZodString>;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ id: z.ZodNumber;
71
+ proposer: z.ZodString;
72
+ description: z.ZodString;
73
+ status: z.ZodString;
74
+ submittedAt: z.ZodString;
75
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
76
+ hash: z.ZodString;
77
+ what: z.ZodLiteral<"past">;
78
+ }, z.core.$strip>, z.ZodObject<{
79
+ id: z.ZodNumber;
80
+ proposer: z.ZodString;
81
+ description: z.ZodString;
82
+ status: z.ZodString;
83
+ submittedAt: z.ZodString;
84
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
85
+ hash: z.ZodString;
86
+ what: z.ZodLiteral<"trezu">;
87
+ }, z.core.$strip>, z.ZodObject<{
88
+ id: z.ZodNumber;
89
+ proposer: z.ZodString;
90
+ description: z.ZodString;
91
+ status: z.ZodString;
92
+ submittedAt: z.ZodString;
93
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
94
+ hash: z.ZodString;
95
+ what: z.ZodLiteral<"other">;
96
+ path: z.ZodString;
97
+ }, z.core.$strip>]>;
98
+ export declare const proposalsResponse: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
99
+ id: z.ZodNumber;
100
+ proposer: z.ZodString;
101
+ description: z.ZodString;
102
+ status: z.ZodString;
103
+ submittedAt: z.ZodString;
104
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
105
+ hash: z.ZodString;
106
+ what: z.ZodLiteral<"agent">;
107
+ agent: z.ZodString;
108
+ type: z.ZodString;
109
+ correlationId: z.ZodString;
110
+ expiresAt: z.ZodString;
111
+ state: z.ZodEnum<{
112
+ done: "done";
113
+ expired: "expired";
114
+ waiting: "waiting";
115
+ }>;
116
+ check: z.ZodUnion<readonly [z.ZodObject<{
117
+ kind: z.ZodLiteral<"verified">;
118
+ standard: z.ZodLiteral<"nep413">;
119
+ message: z.ZodUnknown;
120
+ }, z.core.$strip>, z.ZodObject<{
121
+ kind: z.ZodLiteral<"verified">;
122
+ standard: z.ZodLiteral<"nep366">;
123
+ receiver: z.ZodString;
124
+ methods: z.ZodArray<z.ZodString>;
125
+ }, z.core.$strip>, z.ZodObject<{
126
+ kind: z.ZodLiteral<"mismatch">;
127
+ reason: z.ZodString;
128
+ }, z.core.$strip>]>;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ id: z.ZodNumber;
131
+ proposer: z.ZodString;
132
+ description: z.ZodString;
133
+ status: z.ZodString;
134
+ submittedAt: z.ZodString;
135
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
136
+ hash: z.ZodString;
137
+ what: z.ZodLiteral<"unknown">;
138
+ }, z.core.$strip>, z.ZodObject<{
139
+ id: z.ZodNumber;
140
+ proposer: z.ZodString;
141
+ description: z.ZodString;
142
+ status: z.ZodString;
143
+ submittedAt: z.ZodString;
144
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
145
+ hash: z.ZodString;
146
+ what: z.ZodLiteral<"unchecked">;
147
+ unanswered: z.ZodArray<z.ZodString>;
148
+ }, z.core.$strip>, z.ZodObject<{
149
+ id: z.ZodNumber;
150
+ proposer: z.ZodString;
151
+ description: z.ZodString;
152
+ status: z.ZodString;
153
+ submittedAt: z.ZodString;
154
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
155
+ hash: z.ZodString;
156
+ what: z.ZodLiteral<"past">;
157
+ }, z.core.$strip>, z.ZodObject<{
158
+ id: z.ZodNumber;
159
+ proposer: z.ZodString;
160
+ description: z.ZodString;
161
+ status: z.ZodString;
162
+ submittedAt: z.ZodString;
163
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
164
+ hash: z.ZodString;
165
+ what: z.ZodLiteral<"trezu">;
166
+ }, z.core.$strip>, z.ZodObject<{
167
+ id: z.ZodNumber;
168
+ proposer: z.ZodString;
169
+ description: z.ZodString;
170
+ status: z.ZodString;
171
+ submittedAt: z.ZodString;
172
+ votes: z.ZodRecord<z.ZodString, z.ZodString>;
173
+ hash: z.ZodString;
174
+ what: z.ZodLiteral<"other">;
175
+ path: z.ZodString;
176
+ }, z.core.$strip>]>>;
177
+ export type ProposalCheck = z.infer<typeof proposalCheck>;
178
+ export type Decoded = z.infer<typeof decodedProposal>;
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * `GET /gw/proposals?dao=<account>`: the DAO's recent agent-owner signing proposals, each matched against what the
4
+ * agents wait for. Single source: the gateway's `decodeProposals` (src/gateway/proposals.ts) returns these types.
5
+ */
6
+ export const proposalCheck = z.union([
7
+ /** The hash is recomputed from the readable payload: this is exactly what the vote signs. */
8
+ z.object({ kind: z.literal("verified"), standard: z.literal("nep413"), message: z.unknown() }),
9
+ /** The hash is recomputed from the delegate bytes; receiver and methods are read, the policy blob is encrypted. */
10
+ z.object({ kind: z.literal("verified"), standard: z.literal("nep366"), receiver: z.string(), methods: z.array(z.string()) }),
11
+ z.object({ kind: z.literal("mismatch"), reason: z.string() }),
12
+ ]);
13
+ const base = { id: z.number(), proposer: z.string(), description: z.string(), status: z.string(), submittedAt: z.string(), votes: z.record(z.string(), z.string()), hash: z.string() };
14
+ export const decodedProposal = z.union([
15
+ z.object({ ...base, what: z.literal("agent"), agent: z.string(), type: z.string(), correlationId: z.string(), expiresAt: z.string(),
16
+ state: z.enum(["waiting", "done", "expired"]), check: proposalCheck }),
17
+ /** An agent-owner signature nothing here prepared, every agent having answered: don't approve it without knowing where it's from. */
18
+ z.object({ ...base, what: z.literal("unknown") }),
19
+ /** An agent-owner signature no answering agent prepared, while `unanswered` agents couldn't be asked: not yet checkable. */
20
+ z.object({ ...base, what: z.literal("unchecked"), unanswered: z.array(z.string()) }),
21
+ /** A finished agent-owner proposal: what it signed was submitted and is no longer waited for. */
22
+ z.object({ ...base, what: z.literal("past") }),
23
+ /** Trezu's own confidential payment, signed on the DAO's path rather than the agents'. */
24
+ z.object({ ...base, what: z.literal("trezu") }),
25
+ z.object({ ...base, what: z.literal("other"), path: z.string() }),
26
+ ]);
27
+ export const proposalsResponse = z.array(decodedProposal);