@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,37 @@
1
+ import { eventIterator, oc } from "@orpc/contract";
2
+ import { z } from "zod";
3
+ import { executePlanInput, ownerPrepareInput, ownerStatusInput, ownerSubmitInput } from "./inputs.js";
4
+ import { ownerOutputs } from "./owner-outputs.js";
5
+ /**
6
+ * Typed owner errors: recovery is decided by `data.kind`, never by message text. Every schema is loose, so an
7
+ * error's data reaches the client exactly as raised (oRPC sends the validated value; nothing may be stripped).
8
+ * Data that does not match (for example input validation's `{ issues }`) is sent unchanged as an undefined error.
9
+ */
10
+ const refused = z.looseObject({ kind: z.literal("refused"), code: z.string().optional() });
11
+ export const ownerErrors = {
12
+ /** Refused before anything was sent: an earlier operation has no proven outcome, or another action holds the lock. */
13
+ CONFLICT: { data: z.discriminatedUnion("kind", [z.looseObject({ kind: z.literal("unresolved") }), z.looseObject({ kind: z.literal("busy") }), refused]) },
14
+ /** Refused by the platform, or by the provider (with its code and supplementary details). */
15
+ BAD_REQUEST: { data: z.discriminatedUnion("kind", [refused, z.looseObject({
16
+ kind: z.literal("provider"), code: z.string().optional(), availableAt: z.string().nullable(), budgetRemainingUsd: z.string().optional(),
17
+ })]) },
18
+ };
19
+ const procedure = oc.errors(ownerErrors);
20
+ /**
21
+ * The owner contract, contract-first: inputs, outputs and typed errors in one place. The server implements it
22
+ * (src/rpc/*, `implement` with output validation off: reads validate only, mutations and streams are not validated
23
+ * server-side) and `ownerClient` is typed from it.
24
+ */
25
+ export const ownerContract = {
26
+ overview: procedure.output(ownerOutputs.overview),
27
+ activity: procedure.output(ownerOutputs.activity),
28
+ unresolved: procedure.output(ownerOutputs.unresolved),
29
+ strategy: { get: procedure.output(ownerOutputs["strategy/get"]) },
30
+ owner: {
31
+ prepare: procedure.input(ownerPrepareInput).output(ownerOutputs["owner/prepare"]),
32
+ submit: procedure.input(ownerSubmitInput).output(ownerOutputs["owner/submit"]),
33
+ status: procedure.input(ownerStatusInput).output(ownerOutputs["owner/status"]),
34
+ },
35
+ rebalance: procedure.output(eventIterator(ownerOutputs.rebalance)),
36
+ executePlan: procedure.input(executePlanInput).output(eventIterator(ownerOutputs.executePlan)),
37
+ };
@@ -0,0 +1,166 @@
1
+ import type { z } from "zod";
2
+ import type { agreementCommand, compensationSend, paymentPreparation, reviewCommand } from "../compensation-contract.js";
3
+ import type { depositInput, executePlanInput, ownerAction, ownerPrepareInput, ownerStatusInput, ownerSubmitInput, payoutRequestInput, payoutStatusInput } from "./inputs.js";
4
+ /**
5
+ * Owner procedure inputs as the router accepts them (before server-side parsing). Procedures in the owner contract
6
+ * (owner-contract.ts) take their types from its schemas; test/contract-owner.test.ts proves each type equals the router's.
7
+ */
8
+ type ReviewedPolicy = {
9
+ revision: number;
10
+ digest: string;
11
+ };
12
+ type Strategy = {
13
+ targetBps: Record<string, number>;
14
+ minLegUsd: number;
15
+ maxCostBps: number;
16
+ autopilot: {
17
+ everyMin: number;
18
+ maxUsd: number;
19
+ };
20
+ };
21
+ /** An owner action to prepare for signature, as the contract accepts it. */
22
+ export type OwnerAction = z.input<typeof ownerAction>;
23
+ type In<T extends z.ZodType> = z.input<T>;
24
+ export type OwnerInputs = {
25
+ setup: undefined;
26
+ instance: undefined;
27
+ overview: undefined;
28
+ policyHistory: undefined;
29
+ activity: undefined;
30
+ unresolved: undefined;
31
+ held: undefined;
32
+ "inbox/list": undefined;
33
+ "autopilot/get": undefined;
34
+ "autopilot/evidence": {
35
+ since?: string;
36
+ };
37
+ "autopilot/log": {
38
+ tickId?: string;
39
+ };
40
+ "strategy/get": undefined;
41
+ "treasury/get": undefined;
42
+ ledger: undefined;
43
+ ledgerCsv: undefined;
44
+ reconcileBooks: undefined;
45
+ paymentHistory: undefined;
46
+ paymentStatus: {
47
+ correlationId: string;
48
+ waitMs?: number;
49
+ };
50
+ invoices: undefined;
51
+ "agreements/list": undefined;
52
+ "owner/status": In<typeof ownerStatusInput>;
53
+ "owner/pending": undefined;
54
+ "owner/actions": undefined;
55
+ "compensation/list": undefined;
56
+ "workOrders/list": undefined;
57
+ "workOrders/get": {
58
+ id: string;
59
+ };
60
+ "workOrders/status": {
61
+ id: string;
62
+ correlationId: string;
63
+ };
64
+ pay: {
65
+ recipient: string;
66
+ asset: string;
67
+ amount: string;
68
+ confidential: boolean;
69
+ expectedPolicy: ReviewedPolicy;
70
+ };
71
+ deposit: In<typeof depositInput>;
72
+ recover: undefined;
73
+ cancelPreparedInvoice: {
74
+ id: string;
75
+ };
76
+ "inbox/dismiss": {
77
+ id: string;
78
+ };
79
+ "owner/prepare": In<typeof ownerPrepareInput>;
80
+ "owner/submit": In<typeof ownerSubmitInput>;
81
+ "payouts/request": In<typeof payoutRequestInput>;
82
+ "payouts/status": In<typeof payoutStatusInput>;
83
+ "agreements/propose": {
84
+ id: string;
85
+ until: string;
86
+ };
87
+ "agreements/offer": {
88
+ payee: string;
89
+ amount: string;
90
+ note: string;
91
+ until: string;
92
+ };
93
+ "agreements/decline": {
94
+ id: string;
95
+ };
96
+ "compensation/agreement": z.input<typeof agreementCommand>;
97
+ "compensation/review": z.input<typeof reviewCommand>;
98
+ "compensation/prepare": z.input<typeof paymentPreparation>;
99
+ "compensation/send": z.input<typeof compensationSend>;
100
+ "workOrders/create": {
101
+ id: string;
102
+ payee: string;
103
+ amount: string;
104
+ note: string;
105
+ until: string;
106
+ };
107
+ "workOrders/prepare": {
108
+ id: string;
109
+ action: "create" | "grant" | "approve" | "reject" | "revoke";
110
+ signer: "wallet" | "dao";
111
+ };
112
+ "workOrders/submit": {
113
+ id: string;
114
+ correlationId: string;
115
+ signedData: Record<string, unknown>;
116
+ };
117
+ "workOrders/deposit": {
118
+ id: string;
119
+ };
120
+ "workOrders/file": {
121
+ id: string;
122
+ };
123
+ "strategy/save": {
124
+ strategy: Strategy;
125
+ expectedDigest: string;
126
+ };
127
+ "autopilot/set": {
128
+ on: boolean;
129
+ everyMin: number;
130
+ maxUsd: number;
131
+ expectedDigest?: string;
132
+ };
133
+ "autopilot/enable": {
134
+ expectedDigest: string;
135
+ };
136
+ "autopilot/stop": undefined;
137
+ "autopilot/tick": undefined;
138
+ "treasury/link": {
139
+ accountId: string;
140
+ };
141
+ "treasury/unlink": undefined;
142
+ "treasury/setConfidential": {
143
+ confidential: boolean;
144
+ };
145
+ "treasury/fund": {
146
+ asset: "USDC" | "NEAR";
147
+ amount: string;
148
+ };
149
+ externalPlan: {
150
+ swaps: {
151
+ from: string;
152
+ to: string;
153
+ amount: string;
154
+ minAmountOut?: string;
155
+ }[];
156
+ };
157
+ rebalance: undefined;
158
+ executePlan: In<typeof executePlanInput>;
159
+ sweep: {
160
+ execute: boolean;
161
+ };
162
+ "steward/propose": {
163
+ instruction?: string;
164
+ };
165
+ };
166
+ export {};
@@ -0,0 +1 @@
1
+ export {};