@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.
- package/CHANGES.md +21 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/THIRD-PARTY-NOTICES +127 -0
- package/bin/release-server.d.mts +29 -0
- package/bin/release-server.mjs +143 -0
- package/dist/compensation-contract.d.ts +370 -0
- package/dist/compensation-contract.js +51 -0
- package/dist/contract/agent-connection.d.ts +86 -0
- package/dist/contract/agent-connection.js +36 -0
- package/dist/contract/app-access.d.ts +141 -0
- package/dist/contract/app-access.js +57 -0
- package/dist/contract/app-client.d.ts +140 -0
- package/dist/contract/app-client.js +61 -0
- package/dist/contract/app-consent.d.ts +68 -0
- package/dist/contract/app-consent.js +91 -0
- package/dist/contract/assets.d.ts +6 -0
- package/dist/contract/assets.js +6 -0
- package/dist/contract/client.d.ts +347 -0
- package/dist/contract/client.js +81 -0
- package/dist/contract/gateway.d.ts +74 -0
- package/dist/contract/gateway.js +47 -0
- package/dist/contract/index.d.ts +26 -0
- package/dist/contract/index.js +25 -0
- package/dist/contract/inputs.d.ts +230 -0
- package/dist/contract/inputs.js +99 -0
- package/dist/contract/intents-account.d.ts +5 -0
- package/dist/contract/intents-account.js +8 -0
- package/dist/contract/orpc-client.js +2037 -0
- package/dist/contract/owner-capabilities.d.ts +81 -0
- package/dist/contract/owner-capabilities.js +33 -0
- package/dist/contract/owner-client.d.ts +99 -0
- package/dist/contract/owner-client.js +146 -0
- package/dist/contract/owner-contract.d.ts +1156 -0
- package/dist/contract/owner-contract.js +37 -0
- package/dist/contract/owner-inputs.d.ts +166 -0
- package/dist/contract/owner-inputs.js +1 -0
- package/dist/contract/owner-outputs.d.ts +5749 -0
- package/dist/contract/owner-outputs.js +751 -0
- package/dist/contract/package-version.d.ts +5 -0
- package/dist/contract/package-version.js +2 -0
- package/dist/contract/payee-entry.d.ts +10 -0
- package/dist/contract/payee-entry.js +10 -0
- package/dist/contract/payee.d.ts +326 -0
- package/dist/contract/payee.js +32 -0
- package/dist/contract/permissions.d.ts +20 -0
- package/dist/contract/permissions.js +64 -0
- package/dist/contract/proposals.d.ts +178 -0
- package/dist/contract/proposals.js +27 -0
- package/dist/contract/run-log-schema.d.ts +888 -0
- package/dist/contract/run-log-schema.js +150 -0
- package/dist/contract/run-progress-schema.d.ts +104 -0
- package/dist/contract/run-progress-schema.js +20 -0
- package/dist/payee-contract.d.ts +9 -0
- package/dist/payee-contract.js +15 -0
- package/package.json +58 -0
- package/provenance.json +61 -0
- package/schemas/agentConnection.json +76 -0
- package/schemas/agentConnectionIssue.json +22 -0
- package/schemas/agentConnectionList.json +88 -0
- package/schemas/agentConnectionStarted.json +90 -0
- package/schemas/compensationSend.json +40 -0
- package/schemas/errorBody.json +16 -0
- package/schemas/fileResult.json +67 -0
- package/schemas/invoicesView.json +130 -0
- package/schemas/ownerCompensationView.json +556 -0
- package/schemas/payeeCompensationView.json +546 -0
- package/schemas/payeeWorkOrderRequest.json +31 -0
- package/schemas/publicWorkOrder.json +94 -0
- package/schemas/reportCommand.json +82 -0
- package/schemas/requestRecord.json +149 -0
- package/schemas/session.json +20 -0
- package/schemas/workOrderList.json +43 -0
- package/schemas/workOrderRequestResult.json +20 -0
- package/skills/app-server/SKILL.md +190 -0
- package/skills/getting-started/SKILL.md +90 -0
- package/skills/owner-workflows/SKILL.md +157 -0
- package/skills/payee-workflows/SKILL.md +200 -0
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output (return value) schemas of the owner-facing oRPC procedures served by `src/router.ts`.
|
|
3
|
+
* Every object is a `z.looseObject`, so validating an output never strips a field the server added:
|
|
4
|
+
* the fields declared are the ones whose type was read from the handler. Provider (Agent API SDK)
|
|
5
|
+
* objects declare only their top-level fields.
|
|
6
|
+
*
|
|
7
|
+
* Wire note: values are described as the handlers return them. Some carry `bigint` (dashboard and
|
|
8
|
+
* plan holdings) or `undefined` inside arrays (`rebalance`'s `steps`); those survive only through the
|
|
9
|
+
* oRPC RPC serializer, not plain JSON. Each such place is marked "serializer:" below.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { appConfirm } from "./app-access.js";
|
|
13
|
+
import { ownerCompensationView } from "../compensation-contract.js";
|
|
14
|
+
import { RecordingSchema } from "./run-log-schema.js";
|
|
15
|
+
// Server modules with filesystem, crypto or AG-UI dependencies stay out of this browser-safe package: their shapes are
|
|
16
|
+
// restated here, and test/contract-owner.test.ts proves every handler output is accepted by these schemas.
|
|
17
|
+
// ---------------------------------------------------------------------------------------------
|
|
18
|
+
// Shared pieces
|
|
19
|
+
const record = z.record(z.string(), z.unknown());
|
|
20
|
+
/** A provider status (StatusResponse["status"]); kept open: local records also hold "PREPARED", "UNKNOWN", "EXPIRED". */
|
|
21
|
+
const status = z.string();
|
|
22
|
+
/** SDK OwnerWallet (near | evm | passkey): only the discriminant and key are declared. */
|
|
23
|
+
/** SDK OwnerWallet: discriminated by `type`, so a near owner's `account_id` is typed. */
|
|
24
|
+
const ownerWallet = z.discriminatedUnion("type", [
|
|
25
|
+
z.looseObject({ type: z.literal("near"), account_id: z.string(), public_key: z.string() }),
|
|
26
|
+
z.looseObject({ type: z.literal("evm"), address: z.string(), chain_id: z.number(), public_key: z.string() }),
|
|
27
|
+
z.looseObject({ type: z.literal("passkey"), credential_id: z.string(), public_key: z.string(), rp_id: z.string(), origin: z.string() }),
|
|
28
|
+
]);
|
|
29
|
+
/** dao-owner.ts NearOwner: the DAO's MPC-derived owner account. */
|
|
30
|
+
const nearOwner = z.looseObject({ type: z.literal("near"), account_id: z.string(), public_key: z.string() });
|
|
31
|
+
/** SDK Policy: top-level fields; nested destinations and limits kept open. */
|
|
32
|
+
const policy = z.looseObject({
|
|
33
|
+
frozen: z.boolean(),
|
|
34
|
+
actions: z.array(z.enum(["swap", "transfer", "withdraw"])),
|
|
35
|
+
confidential: z.boolean(),
|
|
36
|
+
owner_approval: z.boolean(),
|
|
37
|
+
assets: z.union([z.literal("any"), z.array(z.string())]),
|
|
38
|
+
limits: z.looseObject({
|
|
39
|
+
per_transaction: z.record(z.string(), z.string()).optional(),
|
|
40
|
+
hourly: z.record(z.string(), z.string()).optional(),
|
|
41
|
+
daily: z.record(z.string(), z.string()).optional(),
|
|
42
|
+
monthly: z.record(z.string(), z.string()).optional(),
|
|
43
|
+
}),
|
|
44
|
+
max_actions_per_hour: z.number().nullable(),
|
|
45
|
+
destinations: z.looseObject({
|
|
46
|
+
mode: z.enum(["any", "only", "except"]),
|
|
47
|
+
// SDK destination entries: a transfer carries `confidential`; a withdrawal its chain and memo.
|
|
48
|
+
list: z.array(z.discriminatedUnion("action", [
|
|
49
|
+
z.looseObject({ action: z.literal("transfer"), address: z.string(), confidential: z.boolean() }),
|
|
50
|
+
z.looseObject({ action: z.literal("withdraw"), chain: z.string(), address: z.string(), memo: z.string().nullable() }),
|
|
51
|
+
])),
|
|
52
|
+
}),
|
|
53
|
+
budget: z.looseObject({ daily_usd: z.string().nullable(), weekly_usd: z.string().nullable(), monthly_usd: z.string().nullable() }),
|
|
54
|
+
timelock_ms: z.number(),
|
|
55
|
+
// SDK `Schedule`: when the policy allows actions, in the owner's time zone.
|
|
56
|
+
schedule: z.looseObject({
|
|
57
|
+
mode: z.enum(["only", "except"]),
|
|
58
|
+
time_zone: z.string(),
|
|
59
|
+
windows: z.array(z.looseObject({ days: z.array(z.enum(["mon", "tue", "wed", "thu", "fri", "sat", "sun"])), start: z.string(), end: z.string() })),
|
|
60
|
+
}).optional(),
|
|
61
|
+
sign: z.looseObject({ recipients: z.array(z.string()) }).optional(),
|
|
62
|
+
});
|
|
63
|
+
const cooldowns = z.looseObject({ policy_change_available_at: z.string().nullable(), unfreeze_available_at: z.string().nullable() });
|
|
64
|
+
/** One USD budget window. An uncapped window's spend is "0.000000": nothing counted (`countedSpend`, src/budget-window.ts). */
|
|
65
|
+
const budgetWindow = z.looseObject({ limit_usd: z.string().nullable(), spent_usd: z.string(), remaining_usd: z.string().nullable(), resets_at: z.string().nullable() });
|
|
66
|
+
/** SDK PolicyView, as `api.getPolicy` returns it. */
|
|
67
|
+
const policyView = z.looseObject({
|
|
68
|
+
wallet_id: z.string(),
|
|
69
|
+
revision: z.number().nullable(),
|
|
70
|
+
// Provider evidence neither the platform nor the apps use: tolerated when absent, so its omission cannot fail every read.
|
|
71
|
+
policy_hash: z.string().nullable().optional(),
|
|
72
|
+
status: z.enum(["NONE", "SIGNED", "APPLIED", "FAILED"]),
|
|
73
|
+
applied_at: z.string().nullable().optional(),
|
|
74
|
+
transaction_hash: z.string().nullable().optional(),
|
|
75
|
+
provider_policy_synced: z.boolean(),
|
|
76
|
+
cooldowns,
|
|
77
|
+
policy: policy.nullable(),
|
|
78
|
+
usage: z.looseObject({
|
|
79
|
+
budget: z.looseObject({ daily: budgetWindow, weekly: budgetWindow, monthly: budgetWindow }),
|
|
80
|
+
timelock: z.looseObject({ delay_ms: z.number(), scheduled_count: z.number() }),
|
|
81
|
+
}),
|
|
82
|
+
});
|
|
83
|
+
/** SDK GrantView, as `api.listGrants` returns it; `owner_message` is the signed grant message (opaque here). */
|
|
84
|
+
const grantView = z.looseObject({
|
|
85
|
+
grant_id: z.string(),
|
|
86
|
+
agent_id: z.string(),
|
|
87
|
+
wallet_id: z.string(),
|
|
88
|
+
label: z.string(),
|
|
89
|
+
issued_at: z.string(),
|
|
90
|
+
expires_at: z.string(),
|
|
91
|
+
revoked_at: z.string().nullable(),
|
|
92
|
+
revoked_reason: z.string().nullable().optional(), // unused provider evidence; tolerated when absent
|
|
93
|
+
owner_epoch: z.number(),
|
|
94
|
+
owner_message: z.unknown(),
|
|
95
|
+
});
|
|
96
|
+
/** The grant summary several reads project from a GrantView. */
|
|
97
|
+
const grantSummary = z.looseObject({ id: z.string(), label: z.string(), expiresAt: z.string() });
|
|
98
|
+
/** SDK Intent (nep413 | nep366 | eip712 | webauthn): the payload is what the owner signs, kept opaque. */
|
|
99
|
+
/** SDK Intent: each signing standard with its payload, so a signer narrows on `standard` without casting. */
|
|
100
|
+
const intent = z.discriminatedUnion("standard", [
|
|
101
|
+
z.looseObject({ standard: z.literal("nep413"), payload: z.looseObject({ message: z.string(), recipient: z.string(), nonce: z.string() }) }),
|
|
102
|
+
z.looseObject({ standard: z.literal("nep366"), payload: z.looseObject({ receiverId: z.string(), actions: z.array(z.looseObject({
|
|
103
|
+
type: z.literal("FunctionCall"), params: z.looseObject({ methodName: z.string(), args: z.record(z.string(), z.unknown()), gas: z.string(), deposit: z.string() })
|
|
104
|
+
})) }) }),
|
|
105
|
+
z.looseObject({ standard: z.literal("eip712"), payload: z.looseObject({ domain: z.record(z.string(), z.unknown()),
|
|
106
|
+
types: z.record(z.string(), z.array(z.looseObject({ name: z.string(), type: z.string() }))), primaryType: z.string(), message: z.record(z.string(), z.unknown()) }) }),
|
|
107
|
+
z.looseObject({ standard: z.literal("webauthn"), payload: z.looseObject({ challenge: z.string(), rpId: z.string(),
|
|
108
|
+
allowCredentials: z.array(z.looseObject({ id: z.string(), type: z.literal("public-key") })), userVerification: z.literal("required"), timeout: z.number() }) }),
|
|
109
|
+
]);
|
|
110
|
+
/** SDK IntentPreview. */
|
|
111
|
+
const intentPreview = z.looseObject({
|
|
112
|
+
summary: z.string(),
|
|
113
|
+
revision: z.number().optional(),
|
|
114
|
+
previous_revision: z.number().optional(),
|
|
115
|
+
policy_hash: z.string().optional(),
|
|
116
|
+
policy: policy.optional(),
|
|
117
|
+
deletion: z.unknown().optional(),
|
|
118
|
+
approval: z.looseObject({ approval_id: z.string(), request_type: z.string(), request_hash: z.string(), verdict: z.enum(["approve", "reject"]) }).optional(),
|
|
119
|
+
});
|
|
120
|
+
/** A NEAR transaction for a wallet to sign: dao-owner.ts signTransaction/proposalTransaction/proposalAndVote, chain.ts fundingTransaction. */
|
|
121
|
+
const callArgs = z.custom(value => typeof value === "object" && value !== null && !Array.isArray(value), "Expected call arguments as an object");
|
|
122
|
+
const nearTransaction = z.looseObject({
|
|
123
|
+
receiverId: z.string(),
|
|
124
|
+
actions: z.array(z.looseObject({
|
|
125
|
+
type: z.literal("FunctionCall"),
|
|
126
|
+
// Typed `object`, as wallets' signAndSendTransaction expects.
|
|
127
|
+
params: z.looseObject({ methodName: z.string(), args: callArgs, gas: z.string(), deposit: z.string() }),
|
|
128
|
+
})),
|
|
129
|
+
});
|
|
130
|
+
/** Which held payment an approval vote releases or rejects (owner-intents.ts paymentOf). */
|
|
131
|
+
const votedPayment = z.looseObject({ correlationId: z.string(), verdict: z.enum(["approve", "reject"]) }).nullable();
|
|
132
|
+
/** ops.ts Op: one journal operation folded with its outcome. Optional fields are absent from older lines. */
|
|
133
|
+
const op = z.looseObject({
|
|
134
|
+
at: z.string(),
|
|
135
|
+
idempotencyKey: z.string(),
|
|
136
|
+
kind: z.string(),
|
|
137
|
+
method: z.enum(["swap", "transfer", "shield", "unshield", "withdraw"]).optional(),
|
|
138
|
+
request: record,
|
|
139
|
+
journalVersion: z.literal(2).optional(),
|
|
140
|
+
invoiceId: z.string().optional(),
|
|
141
|
+
submissionState: z.enum(["PREPARED", "SUBMISSION_ATTEMPTED", "OBSERVED", "UNKNOWN", "RESOLVED"]).optional(),
|
|
142
|
+
correlationId: z.string().optional(),
|
|
143
|
+
status: z.string().optional(),
|
|
144
|
+
refused: z.string().optional(),
|
|
145
|
+
policyRevision: z.number().nullable().optional(),
|
|
146
|
+
policyDigest: z.string().nullable().optional(),
|
|
147
|
+
planId: z.string().optional(),
|
|
148
|
+
usdIn: z.number().nullable().optional(),
|
|
149
|
+
});
|
|
150
|
+
/** planning/model.ts PlannedAction. */
|
|
151
|
+
const plannedAction = z.discriminatedUnion("type", [
|
|
152
|
+
z.looseObject({ type: z.literal("swap"), from: z.string(), to: z.string(), amount: z.string(), amountOut: z.string(), minAmountOut: z.string(), costBps: z.number() }),
|
|
153
|
+
z.looseObject({ type: z.literal("shield"), asset: z.string(), amount: z.string() }),
|
|
154
|
+
]);
|
|
155
|
+
/** planning/model.ts Plan. */
|
|
156
|
+
const plan = z.looseObject({
|
|
157
|
+
id: z.string(),
|
|
158
|
+
source: z.enum(["steward", "rebalance", "external"]),
|
|
159
|
+
createdAt: z.string(),
|
|
160
|
+
expiresAt: z.string(),
|
|
161
|
+
instruction: z.string(),
|
|
162
|
+
actions: z.array(plannedAction),
|
|
163
|
+
agentId: z.string(),
|
|
164
|
+
policyRevision: z.number().nullable(),
|
|
165
|
+
policyDigest: z.string().nullable(),
|
|
166
|
+
strategyDigest: z.string(),
|
|
167
|
+
balances: z.record(z.string(), z.looseObject({ public: z.string(), confidential: z.string() })),
|
|
168
|
+
});
|
|
169
|
+
/** holdings.ts Holding. serializer: `public` and `confidential` are bigint. */
|
|
170
|
+
const holding = z.looseObject({
|
|
171
|
+
asset: z.string(), symbol: z.string(), decimals: z.number(), price: z.number(),
|
|
172
|
+
public: z.bigint(), confidential: z.bigint(), usd: z.number(),
|
|
173
|
+
});
|
|
174
|
+
/** A loose copy of the strategy: Strategy itself is a stripping z.object. */
|
|
175
|
+
const strategy = z.looseObject({ targetBps: z.record(z.string(), z.number()), minLegUsd: z.number(), maxCostBps: z.number(),
|
|
176
|
+
autopilot: z.looseObject({ everyMin: z.number(), maxUsd: z.number() }) });
|
|
177
|
+
/** strategy-controls.ts snapshot. */
|
|
178
|
+
const strategySnapshot = z.looseObject({ strategy, digest: z.string(), on: z.boolean() });
|
|
179
|
+
/** autopilot.ts status. */
|
|
180
|
+
const autopilotStatus = z.looseObject({
|
|
181
|
+
on: z.boolean(), everyMin: z.number(), maxUsd: z.number(),
|
|
182
|
+
lastRun: z.string().nullable(), nextRun: z.string().nullable(),
|
|
183
|
+
});
|
|
184
|
+
/** invoices.ts Status. */
|
|
185
|
+
const invoiceStatus = z.enum(["needs_agreement", "refused", "busy", "prepared", "waiting", "paying", "paid", "failed", "unknown", "needs_review"]);
|
|
186
|
+
/** invoice-store.ts StoredInvoice. */
|
|
187
|
+
const storedInvoice = z.looseObject({
|
|
188
|
+
id: z.string(),
|
|
189
|
+
payee: z.string(),
|
|
190
|
+
submission: z.string(),
|
|
191
|
+
amount: z.string(),
|
|
192
|
+
note: z.string(),
|
|
193
|
+
at: z.string(),
|
|
194
|
+
revision: z.number(),
|
|
195
|
+
operation: op,
|
|
196
|
+
reservation: z.string(),
|
|
197
|
+
review: z.boolean(),
|
|
198
|
+
revisions: z.array(z.looseObject({ revision: z.number(), amount: z.string(), note: z.string(), review: z.number() })),
|
|
199
|
+
});
|
|
200
|
+
// ---------------------------------------------------------------------------------------------
|
|
201
|
+
// Reads
|
|
202
|
+
/** rpc/observations.ts setup (with linkedDao). Without an agent, every field but `dao` and `executor` is null. */
|
|
203
|
+
export const setupOutput = z.looseObject({
|
|
204
|
+
agentId: z.string().nullable(),
|
|
205
|
+
executor: z.boolean(),
|
|
206
|
+
wallet: z.string().nullable(),
|
|
207
|
+
owner: ownerWallet.nullable(),
|
|
208
|
+
grant: grantSummary.nullable(),
|
|
209
|
+
dao: z.looseObject({ id: z.string(), owner: nearOwner, funded: z.boolean() }).nullable(),
|
|
210
|
+
});
|
|
211
|
+
/** rpc/observations.ts instance. */
|
|
212
|
+
export const instanceOutput = z.looseObject({ agentId: z.string().nullable(), executor: z.boolean() });
|
|
213
|
+
/** dashboard-holdings.ts dashboardHoldings `managed` row. serializer: `public` and `confidential` are bigint. */
|
|
214
|
+
const managedHolding = z.looseObject({
|
|
215
|
+
asset: z.string(), symbol: z.string(), decimals: z.number(),
|
|
216
|
+
public: z.bigint(), confidential: z.bigint(),
|
|
217
|
+
price: z.number().nullable(), priceUpdatedAt: z.string().nullable(), priceExpiresAt: z.string().nullable(),
|
|
218
|
+
usd: z.number().nullable(),
|
|
219
|
+
});
|
|
220
|
+
/** dashboard-holdings.ts dashboardHoldings `unmanaged` row. serializer: `amount` is bigint. */
|
|
221
|
+
const unmanagedHolding = z.looseObject({
|
|
222
|
+
asset: z.string(), symbol: z.string(), decimals: z.number().nullable(), amount: z.bigint(),
|
|
223
|
+
price: z.number().nullable(), priceUpdatedAt: z.string().nullable(), priceExpiresAt: z.string().nullable(),
|
|
224
|
+
usd: z.number().nullable(),
|
|
225
|
+
});
|
|
226
|
+
/** rpc/observations.ts overview. `area` is absent unless DASHBOARD_AREA is configured. */
|
|
227
|
+
export const overviewOutput = z.looseObject({
|
|
228
|
+
agentId: z.string(),
|
|
229
|
+
area: z.enum(["payables", "treasury"]).optional(),
|
|
230
|
+
book: z.array(managedHolding),
|
|
231
|
+
unmanaged: z.array(unmanagedHolding),
|
|
232
|
+
target: z.record(z.string(), z.number()),
|
|
233
|
+
rebalance: z.looseObject({ minLegUsd: z.number(), maxCostBps: z.number() }),
|
|
234
|
+
policy: policyView,
|
|
235
|
+
digest: z.string().nullable(),
|
|
236
|
+
notInForce: z.string().nullable(),
|
|
237
|
+
agreed: z.array(z.string()),
|
|
238
|
+
grants: z.array(grantView),
|
|
239
|
+
});
|
|
240
|
+
/** rpc/observations.ts policyHistory. */
|
|
241
|
+
export const policyHistoryOutput = z.array(z.looseObject({
|
|
242
|
+
revision: z.number().nullable(),
|
|
243
|
+
status: z.enum(["NONE", "SIGNED", "APPLIED", "FAILED"]),
|
|
244
|
+
appliedAt: z.string().nullable(),
|
|
245
|
+
transactionHash: z.string().nullable(),
|
|
246
|
+
digest: z.string().nullable(),
|
|
247
|
+
}));
|
|
248
|
+
/** rpc/observations.ts activity (ops.ts readOps projection). Absent fields are omitted, not null. */
|
|
249
|
+
export const activityOutput = z.array(z.looseObject({
|
|
250
|
+
at: z.string(),
|
|
251
|
+
kind: z.string(),
|
|
252
|
+
request: record,
|
|
253
|
+
correlationId: z.string().optional(),
|
|
254
|
+
status: z.string().optional(),
|
|
255
|
+
refused: z.string().optional(),
|
|
256
|
+
policyRevision: z.number().nullable().optional(),
|
|
257
|
+
policyDigest: z.string().nullable().optional(),
|
|
258
|
+
planId: z.string().optional(),
|
|
259
|
+
}));
|
|
260
|
+
/**
|
|
261
|
+
* What the provider answered when a claimed submission failed without a proven outcome (submission-evidence.ts). Diagnostic
|
|
262
|
+
* only: it never resolves, links or clears the operation, and nothing may treat it as an outcome.
|
|
263
|
+
*/
|
|
264
|
+
export const unresolvedEvidence = z.looseObject({
|
|
265
|
+
at: z.string(),
|
|
266
|
+
httpStatus: z.number(),
|
|
267
|
+
code: z.string(),
|
|
268
|
+
/** The provider's id for the failed request, to quote to the provider. Not an operation or correlation id. */
|
|
269
|
+
requestId: z.string().nullable(),
|
|
270
|
+
/** Ids the provider's error happened to include. Unverified: never a correlation for `paymentStatus` or recovery. */
|
|
271
|
+
providerIds: z.record(z.string(), z.string()),
|
|
272
|
+
message: z.string(),
|
|
273
|
+
/** States that the evidence establishes no correlation, execution or permission to clear the operation. */
|
|
274
|
+
note: z.string(),
|
|
275
|
+
});
|
|
276
|
+
/**
|
|
277
|
+
* rpc/observations.ts unresolved. The operation fields are authoritative and strict. `evidence` is absent from servers
|
|
278
|
+
* before Recovery B, null without a recorded answer, and null when malformed: a bad diagnostic never hides the operation.
|
|
279
|
+
*/
|
|
280
|
+
export const unresolvedOutput = z.array(z.looseObject({
|
|
281
|
+
key: z.string(), at: z.string(), kind: z.string(), request: record, status: z.string().nullable(), sent: z.boolean(),
|
|
282
|
+
evidence: unresolvedEvidence.nullable().optional().catch(null),
|
|
283
|
+
}));
|
|
284
|
+
/** payouts.ts held: local held operations, and the API's (kind "remote") not recorded here. */
|
|
285
|
+
export const heldOutput = z.array(z.looseObject({
|
|
286
|
+
at: z.string(), kind: z.string(), request: record, correlationId: z.string(), approvalId: z.string(),
|
|
287
|
+
}));
|
|
288
|
+
/** inbox.ts readInbox Entry. */
|
|
289
|
+
export const inboxListOutput = z.array(z.looseObject({
|
|
290
|
+
id: z.string(), at: z.string(), level: z.enum(["run", "warn", "action"]), text: z.string(), dismissed: z.boolean().optional(),
|
|
291
|
+
}));
|
|
292
|
+
/** autopilot.ts status. */
|
|
293
|
+
export const autopilotGetOutput = autopilotStatus;
|
|
294
|
+
/** evidence.ts Observation | { error } (Seen). */
|
|
295
|
+
const seen = z.union([
|
|
296
|
+
z.looseObject({
|
|
297
|
+
at: z.string(),
|
|
298
|
+
book: z.array(z.looseObject({ asset: z.string(), public: z.string(), confidential: z.string(), usd: z.number() })),
|
|
299
|
+
weightsBps: z.record(z.string(), z.number()),
|
|
300
|
+
targetBps: z.record(z.string(), z.number()),
|
|
301
|
+
driftBps: z.number(),
|
|
302
|
+
budget: z.unknown(),
|
|
303
|
+
unresolved: z.number(),
|
|
304
|
+
}),
|
|
305
|
+
z.looseObject({ error: z.string() }),
|
|
306
|
+
]);
|
|
307
|
+
/**
|
|
308
|
+
* evidence.ts ticks: `Tick` as read back. Lines are JSON.parse'd without validation, so historical
|
|
309
|
+
* records may differ from the current TickStart/TickEnd types.
|
|
310
|
+
*/
|
|
311
|
+
export const autopilotEvidenceOutput = z.looseObject({
|
|
312
|
+
ticks: z.array(z.looseObject({
|
|
313
|
+
progressVersion: z.literal(1).optional(),
|
|
314
|
+
id: z.string(),
|
|
315
|
+
at: z.string(),
|
|
316
|
+
trigger: z.enum(["schedule", "operator"]),
|
|
317
|
+
schedule: z.looseObject({ on: z.boolean(), everyMin: z.number(), maxUsd: z.number(), lastRun: z.string().nullable() }),
|
|
318
|
+
build: z.looseObject({ deployment: z.string().nullable(), source: z.string(), lockfile: z.string().nullable(), packageJson: z.string().nullable() }),
|
|
319
|
+
agentId: z.string(),
|
|
320
|
+
policy: z.looseObject({ revision: z.number().nullable(), digest: z.string().nullable(), status: z.string() }),
|
|
321
|
+
strategy: z.string(),
|
|
322
|
+
grant: grantSummary.nullable(),
|
|
323
|
+
end: z.looseObject({
|
|
324
|
+
progressIncomplete: z.boolean().optional(),
|
|
325
|
+
endedAt: z.string(),
|
|
326
|
+
before: seen,
|
|
327
|
+
after: seen,
|
|
328
|
+
plan: z.looseObject({
|
|
329
|
+
id: z.string(), usd: z.number(),
|
|
330
|
+
legs: z.array(z.looseObject({ from: z.string(), to: z.string(), amount: z.string(), amountOut: z.string(), minAmountOut: z.string(), costBps: z.number() })),
|
|
331
|
+
}).nullable(),
|
|
332
|
+
steps: z.array(z.looseObject({ index: z.number(), status: z.string(), correlationId: z.string(), failureCode: z.string().nullable() })),
|
|
333
|
+
shields: z.array(z.looseObject({ asset: z.string(), status: z.string(), correlationId: z.string() })),
|
|
334
|
+
rejected: z.array(z.string()),
|
|
335
|
+
refusal: z.string().nullable(),
|
|
336
|
+
outcome: z.string(),
|
|
337
|
+
}).nullable(),
|
|
338
|
+
})),
|
|
339
|
+
corrupt: z.array(z.number()),
|
|
340
|
+
});
|
|
341
|
+
/** run-log-export.ts exportRunLog → agui.ts tickLog: the strict recording format, which the handler already parses its output with. */
|
|
342
|
+
export const autopilotLogOutput = RecordingSchema;
|
|
343
|
+
/** strategy-status.ts readStrategyStatus. */
|
|
344
|
+
export const strategyGetOutput = z.looseObject({
|
|
345
|
+
strategy,
|
|
346
|
+
digest: z.string(),
|
|
347
|
+
grantSuffix: z.string(),
|
|
348
|
+
executor: z.boolean(),
|
|
349
|
+
on: z.boolean(),
|
|
350
|
+
/** null on an approve-only host. */
|
|
351
|
+
grantMatches: z.boolean().nullable(),
|
|
352
|
+
unresolved: z.number(),
|
|
353
|
+
grant: grantSummary.nullable(),
|
|
354
|
+
readiness: z.looseObject({
|
|
355
|
+
state: z.enum(["approve-only", "blocked", "authorization-required", "ready", "off"]),
|
|
356
|
+
reasons: z.array(z.string()),
|
|
357
|
+
canEnable: z.boolean(),
|
|
358
|
+
}),
|
|
359
|
+
observedAt: z.string(),
|
|
360
|
+
});
|
|
361
|
+
/** rpc/treasury.ts treasury.get (chain.ts describeTreasury + daoPayees); null when no treasury is linked. */
|
|
362
|
+
export const treasuryGetOutput = z.looseObject({
|
|
363
|
+
accountId: z.string(),
|
|
364
|
+
/** chain.ts council, or null when the account is not a DAO. */
|
|
365
|
+
dao: z.looseObject({
|
|
366
|
+
members: z.array(z.string()),
|
|
367
|
+
approvers: z.array(z.looseObject({ role: z.string(), threshold: z.string() })),
|
|
368
|
+
}).nullable(),
|
|
369
|
+
balances: z.looseObject({ near: z.string(), usdc: z.string() }),
|
|
370
|
+
confidential: z.boolean(),
|
|
371
|
+
payees: z.array(z.looseObject({ address: z.string(), proposalId: z.number(), description: z.string() })),
|
|
372
|
+
}).nullable();
|
|
373
|
+
/** ledger.ts ledger Row. */
|
|
374
|
+
const ledgerRow = z.looseObject({
|
|
375
|
+
at: z.string(),
|
|
376
|
+
settledAt: z.string(),
|
|
377
|
+
type: z.string(),
|
|
378
|
+
status: z.string(),
|
|
379
|
+
failureCode: z.string().nullable(),
|
|
380
|
+
confidential: z.boolean(),
|
|
381
|
+
assetIn: z.string().nullable(),
|
|
382
|
+
amountIn: z.string().nullable(),
|
|
383
|
+
assetOut: z.string().nullable(),
|
|
384
|
+
amountOut: z.string().nullable(),
|
|
385
|
+
recipient: z.string().nullable(),
|
|
386
|
+
correlationId: z.string(),
|
|
387
|
+
intentHash: z.string().nullable(),
|
|
388
|
+
approvalId: z.string().nullable(),
|
|
389
|
+
kind: z.string().nullable(),
|
|
390
|
+
planId: z.string().nullable(),
|
|
391
|
+
policyRevision: z.number().nullable(),
|
|
392
|
+
policyDigest: z.string().nullable(),
|
|
393
|
+
usdIn: z.number().nullable(),
|
|
394
|
+
});
|
|
395
|
+
/** ledger.ts ledger. */
|
|
396
|
+
export const ledgerOutput = z.array(ledgerRow);
|
|
397
|
+
/** ledger.ts ledgerCsv: the CSV text. */
|
|
398
|
+
export const ledgerCsvOutput = z.string();
|
|
399
|
+
/** ledger.ts reconcileBooks Reconciliation. Amounts are raw-unit decimal strings. */
|
|
400
|
+
export const reconcileBooksOutput = z.array(z.looseObject({
|
|
401
|
+
asset: z.string(),
|
|
402
|
+
symbol: z.string(),
|
|
403
|
+
public: z.looseObject({ api: z.string(), chain: z.string(), drift: z.string() }),
|
|
404
|
+
confidential: z.looseObject({ api: z.string(), recorded: z.string(), unattributed: z.string() }),
|
|
405
|
+
}));
|
|
406
|
+
/** payouts.ts paymentHistory. */
|
|
407
|
+
export const paymentHistoryOutput = z.looseObject({
|
|
408
|
+
items: z.array(z.looseObject({ correlationId: z.string(), at: z.string() })),
|
|
409
|
+
complete: z.boolean(),
|
|
410
|
+
});
|
|
411
|
+
/** payouts.ts paymentStatus (evidence: provider-display.ts paymentEvidence). */
|
|
412
|
+
/**
|
|
413
|
+
* payout-requests.ts: a payout request as recorded. `succeeded` settled with SUCCESS; `failed` ended FAILED or REFUNDED,
|
|
414
|
+
* which doesn't prove nothing moved, so a person checks before asking again; `held` waits for the owner's approval;
|
|
415
|
+
* `processing` was accepted and is still moving; `refused` was proven not sent (`code`); `unknown` has no proven
|
|
416
|
+
* outcome. `processing` and `unknown` block the agent's sends and are never sent again; `not_found` was never recorded
|
|
417
|
+
* by this executor.
|
|
418
|
+
*/
|
|
419
|
+
export const payoutRequestOutput = z.looseObject({
|
|
420
|
+
requestId: z.string(),
|
|
421
|
+
state: z.enum(["succeeded", "failed", "held", "processing", "refused", "unknown", "not_found"]),
|
|
422
|
+
status: z.string().nullable(),
|
|
423
|
+
correlationId: z.string().nullable(),
|
|
424
|
+
code: z.string().nullable(),
|
|
425
|
+
});
|
|
426
|
+
export const paymentStatusOutput = z.looseObject({
|
|
427
|
+
status,
|
|
428
|
+
failureCode: z.string().nullable(),
|
|
429
|
+
createdAt: z.string().nullable(),
|
|
430
|
+
updatedAt: z.string().nullable(),
|
|
431
|
+
request: record.nullable(),
|
|
432
|
+
approvalId: z.string().nullable(),
|
|
433
|
+
expiresAt: z.string().nullable(),
|
|
434
|
+
detailError: z.string().nullable(),
|
|
435
|
+
evidence: z.looseObject({
|
|
436
|
+
txHash: z.string().nullable(),
|
|
437
|
+
destinationTxHash: z.string().nullable(),
|
|
438
|
+
refundTxHash: z.string().nullable(),
|
|
439
|
+
refundTo: z.string().nullable(),
|
|
440
|
+
refundedAmount: z.string().nullable(),
|
|
441
|
+
}),
|
|
442
|
+
});
|
|
443
|
+
/** invoice-store.ts listInvoices. */
|
|
444
|
+
export const invoicesOutput = z.array(storedInvoice);
|
|
445
|
+
/** agreements.ts Agreement, from localStore.list or remoteStore.list (the latter already parsed by agreementList). */
|
|
446
|
+
const agreement = z.looseObject({
|
|
447
|
+
id: z.string(),
|
|
448
|
+
at: z.string(),
|
|
449
|
+
origin: z.enum(["payee", "owner"]),
|
|
450
|
+
payee: z.string(),
|
|
451
|
+
amount: z.string(),
|
|
452
|
+
note: z.string(),
|
|
453
|
+
submission: z.string().optional(),
|
|
454
|
+
terms: z.looseObject({ maxAmount: z.string(), until: z.string() }).optional(),
|
|
455
|
+
status: z.enum(["requested", "proposed", "agreed", "filed", "declined"]),
|
|
456
|
+
});
|
|
457
|
+
/** agreements.ts AgreementStore.list. */
|
|
458
|
+
export const agreementsListOutput = z.array(agreement);
|
|
459
|
+
/** owner-intents.ts status (the `outcomes` map's entries included). */
|
|
460
|
+
export const ownerStatusOutput = z.looseObject({
|
|
461
|
+
stage: z.enum(["submitted", "submitting", "expired", "failed", "voting", "unknown"]),
|
|
462
|
+
status: status.optional(),
|
|
463
|
+
failureCode: z.string().nullable().optional(),
|
|
464
|
+
error: z.string().optional(),
|
|
465
|
+
/** Only for `voting`. */
|
|
466
|
+
expiresAt: z.string().optional(),
|
|
467
|
+
});
|
|
468
|
+
/** owner-intents.ts daoRequests: kept requests and the archived expired ones (`.expired.jsonl`, unvalidated JSON). */
|
|
469
|
+
export const ownerPendingOutput = z.array(z.looseObject({
|
|
470
|
+
correlationId: z.string(),
|
|
471
|
+
type: z.string(),
|
|
472
|
+
expiresAt: z.string(),
|
|
473
|
+
hash: z.string(),
|
|
474
|
+
intent,
|
|
475
|
+
delegate: z.string().nullable(),
|
|
476
|
+
/** "done" | "waiting" | "expired" at runtime; the handler's type widens it to string, so it is declared as one. */
|
|
477
|
+
state: z.string(),
|
|
478
|
+
payment: votedPayment,
|
|
479
|
+
}));
|
|
480
|
+
/** owner-intents.ts ownerActions. */
|
|
481
|
+
export const ownerActionsOutput = z.array(z.looseObject({
|
|
482
|
+
correlationId: z.string(),
|
|
483
|
+
type: z.string(),
|
|
484
|
+
expiresAt: z.string(),
|
|
485
|
+
signer: z.enum(["dao", "wallet"]),
|
|
486
|
+
stage: z.enum(["settled", "submitted", "expired", "prepared"]),
|
|
487
|
+
ownerSucceeded: z.boolean(),
|
|
488
|
+
status: z.string().nullable(),
|
|
489
|
+
failureCode: z.string().nullable(),
|
|
490
|
+
payment: votedPayment,
|
|
491
|
+
}));
|
|
492
|
+
/** compensation.ts ownerCompensation (CompensationOwnerView); reused from compensation-contract.ts, top level kept loose. */
|
|
493
|
+
const compensationOwnerView = ownerCompensationView.loose();
|
|
494
|
+
export const compensationListOutput = compensationOwnerView;
|
|
495
|
+
/** work-order-store.ts WorkOrder (strict record schema, reused; top level kept loose). */
|
|
496
|
+
const workOrder = z.looseObject({ id: z.string(), payee: z.string(), amount: z.string(), note: z.string(), until: z.string(), asset: z.string(),
|
|
497
|
+
owner: z.looseObject({ type: z.literal("near"), account_id: z.string(), public_key: z.string() }), dao: z.string().optional(),
|
|
498
|
+
version: z.literal(1), parentAgentId: z.string(), createdAt: z.string() });
|
|
499
|
+
/** work-orders.ts workOrders.list → work-order-store.ts listWorkOrders. Remote results are not re-parsed. */
|
|
500
|
+
export const workOrdersListOutput = z.array(workOrder);
|
|
501
|
+
/** invoices.ts mine: the payee read model a work order snapshot carries. */
|
|
502
|
+
const payeeInvoice = z.looseObject({
|
|
503
|
+
id: z.string(),
|
|
504
|
+
amount: z.string().nullable(),
|
|
505
|
+
note: z.string(),
|
|
506
|
+
filedAt: z.string(),
|
|
507
|
+
status: invoiceStatus,
|
|
508
|
+
revisionConflict: z.boolean(),
|
|
509
|
+
});
|
|
510
|
+
/** work-order-protocol.ts WorkOrderSnapshot (WorkOrderReply["snapshot"]). */
|
|
511
|
+
export const workOrdersGetOutput = z.looseObject({
|
|
512
|
+
order: workOrder,
|
|
513
|
+
agentId: z.string().nullable(),
|
|
514
|
+
wallet: z.string().nullable(),
|
|
515
|
+
balance: z.string().nullable(),
|
|
516
|
+
policyReady: z.boolean(),
|
|
517
|
+
grant: z.looseObject({ id: z.string(), expiresAt: z.string() }).nullable(),
|
|
518
|
+
invoice: payeeInvoice.nullable(),
|
|
519
|
+
ownerActions: ownerActionsOutput,
|
|
520
|
+
approval: z.looseObject({ correlationId: z.string(), approvalId: z.string() }).nullable(),
|
|
521
|
+
error: z.string().nullable(),
|
|
522
|
+
/**
|
|
523
|
+
* Server-computed readiness (work-order-protocol.ts workOrderProgress): apps read it instead of copying the rules.
|
|
524
|
+
* `unavailable` when observations failed or the balance is unknown; it never fails the read.
|
|
525
|
+
*/
|
|
526
|
+
progress: z.looseObject({ stage: z.string(), expired: z.boolean(), residual: z.string().nullable(), excess: z.string().nullable() }),
|
|
527
|
+
});
|
|
528
|
+
/** work-order-protocol.ts WorkOrderReply["status"] = owner-intents.ts status. */
|
|
529
|
+
export const workOrdersStatusOutput = ownerStatusOutput;
|
|
530
|
+
// ---------------------------------------------------------------------------------------------
|
|
531
|
+
// Mutations
|
|
532
|
+
/** agent.ts pay: settled by the provider, or a proven refusal (details: provider-display.ts refusalDetails). */
|
|
533
|
+
export const payOutput = z.discriminatedUnion("outcome", [
|
|
534
|
+
z.looseObject({ outcome: z.literal("settled"), status, correlationId: z.string(), failureCode: z.string().nullable() }),
|
|
535
|
+
z.looseObject({
|
|
536
|
+
outcome: z.literal("refused"),
|
|
537
|
+
code: z.string(),
|
|
538
|
+
details: z.looseObject({ availableAt: z.string().optional(), budgetRemainingUsd: z.string().optional() }).optional(),
|
|
539
|
+
}),
|
|
540
|
+
]);
|
|
541
|
+
/** agent.ts depositAddress. */
|
|
542
|
+
export const depositOutput = z.looseObject({
|
|
543
|
+
correlationId: z.string(),
|
|
544
|
+
address: z.string(),
|
|
545
|
+
memo: z.string().nullable(),
|
|
546
|
+
minAmount: z.string().nullable(),
|
|
547
|
+
expiresAt: z.string().nullable(),
|
|
548
|
+
});
|
|
549
|
+
/** rpc/observations.ts recover (recover.ts recover projection). */
|
|
550
|
+
export const recoverOutput = z.array(z.looseObject({
|
|
551
|
+
key: z.string(),
|
|
552
|
+
outcome: z.enum(["settled", "refused", "open", "unknown"]),
|
|
553
|
+
status: z.string().nullable(),
|
|
554
|
+
detail: z.string().nullable(),
|
|
555
|
+
}));
|
|
556
|
+
/** invoice-store.ts cancelPreparedInvoice: the invoice after cancellation. */
|
|
557
|
+
export const cancelPreparedInvoiceOutput = storedInvoice;
|
|
558
|
+
/** inbox.ts dismiss: returns nothing. */
|
|
559
|
+
export const inboxDismissOutput = z.void();
|
|
560
|
+
/** owner-intents.ts prepare: a wallet's intent and signer, or (signer "dao") the transactions DAO members file. */
|
|
561
|
+
export const ownerPrepareOutput = z.looseObject({
|
|
562
|
+
correlationId: z.string(),
|
|
563
|
+
preview: intentPreview,
|
|
564
|
+
expiresAt: z.string(),
|
|
565
|
+
/** mandate.ts mandateDigest of a policy_update's requested policy; null otherwise. */
|
|
566
|
+
digest: z.string().nullable(),
|
|
567
|
+
/** Creation and policy edits: the policy this server asked the provider to sign, and the one in force it replaces
|
|
568
|
+
* (null for a creation). */
|
|
569
|
+
policy: z.looseObject({ current: policy.nullable(), requested: policy }).optional(),
|
|
570
|
+
/** Wallet signer only; absent through an app when the intent is NEP-366 (see `confirm`). */
|
|
571
|
+
intent: intent.optional(),
|
|
572
|
+
/** App routes only: a NEP-366 intent held on the platform for the owner to sign on its confirm page (`appConfirm`). */
|
|
573
|
+
confirm: appConfirm.optional(),
|
|
574
|
+
/** Wallet signer only. */
|
|
575
|
+
signer: ownerWallet.optional(),
|
|
576
|
+
/** Approval votes only: the held payout it releases or rejects; for approve, the transfer's terms as proven against
|
|
577
|
+
* the provider's request hash (payment-approval.ts), null for a reject. */
|
|
578
|
+
payment: z.looseObject({ correlationId: z.string(), verdict: z.enum(["approve", "reject"]),
|
|
579
|
+
terms: z.looseObject({ recipient: z.string(), asset: z.string(), amount: z.string() }).nullable() }).optional(),
|
|
580
|
+
/** DAO signer only. */
|
|
581
|
+
dao: z.looseObject({
|
|
582
|
+
owner: z.string(),
|
|
583
|
+
transaction: nearTransaction,
|
|
584
|
+
proposal: nearTransaction.nullable(),
|
|
585
|
+
proposalAndVote: nearTransaction.nullable(),
|
|
586
|
+
}).optional(),
|
|
587
|
+
});
|
|
588
|
+
/** owner-intents.ts submit: the recorded or reconciled owner outcome. */
|
|
589
|
+
export const ownerSubmitOutput = z.looseObject({ status, failureCode: z.string().nullable().optional() });
|
|
590
|
+
/** agreements.ts AgreementStore.propose: returns nothing. */
|
|
591
|
+
export const agreementsProposeOutput = z.void();
|
|
592
|
+
/** rpc/payables.ts agreements.offer. */
|
|
593
|
+
export const agreementsOfferOutput = z.looseObject({ id: z.string() });
|
|
594
|
+
/** agreements.ts AgreementStore.decline: returns nothing. */
|
|
595
|
+
export const agreementsDeclineOutput = z.void();
|
|
596
|
+
/** compensation.ts ownerCompensation. */
|
|
597
|
+
export const compensationAgreementOutput = compensationOwnerView;
|
|
598
|
+
/** compensation.ts ownerCompensation. */
|
|
599
|
+
export const compensationReviewOutput = compensationOwnerView;
|
|
600
|
+
/** compensation.ts ownerCompensation. */
|
|
601
|
+
export const compensationPrepareOutput = compensationOwnerView;
|
|
602
|
+
/** compensation.ts ownerCompensation. */
|
|
603
|
+
export const compensationSendOutput = compensationOwnerView;
|
|
604
|
+
/** work-order-store.ts createWorkOrder. */
|
|
605
|
+
export const workOrdersCreateOutput = workOrder;
|
|
606
|
+
/** work-order-protocol.ts WorkOrderReply["prepare"] = owner-intents.ts prepare. */
|
|
607
|
+
export const workOrdersPrepareOutput = ownerPrepareOutput;
|
|
608
|
+
/** work-order-protocol.ts WorkOrderReply["submit"] = owner-intents.ts submit. */
|
|
609
|
+
export const workOrdersSubmitOutput = ownerSubmitOutput;
|
|
610
|
+
/** work-order-protocol.ts WorkOrderReply["deposit"] = agent.ts depositAddress. */
|
|
611
|
+
export const workOrdersDepositOutput = depositOutput;
|
|
612
|
+
/** invoices.ts file (Filing). */
|
|
613
|
+
export const workOrdersFileOutput = z.looseObject({ id: z.string(), status: invoiceStatus, revisionConflict: z.boolean().optional() });
|
|
614
|
+
/** strategy-controls.ts saveReviewedStrategy (snapshot). */
|
|
615
|
+
export const strategySaveOutput = strategySnapshot;
|
|
616
|
+
/** rpc/treasury.ts autopilot.set: autopilot.ts status after setLegacySchedule. */
|
|
617
|
+
export const autopilotSetOutput = autopilotStatus;
|
|
618
|
+
/** strategy-controls.ts enableSchedule (snapshot). */
|
|
619
|
+
export const autopilotEnableOutput = strategySnapshot;
|
|
620
|
+
/** strategy-controls.ts stopSchedule. */
|
|
621
|
+
export const autopilotStopOutput = z.looseObject({ on: z.literal(false) });
|
|
622
|
+
/** autopilot.ts tick: the tick's summary (as the inbox shows it). */
|
|
623
|
+
export const autopilotTickOutput = z.string();
|
|
624
|
+
/** rpc/treasury.ts treasury.link: returns nothing. */
|
|
625
|
+
export const treasuryLinkOutput = z.void();
|
|
626
|
+
/** rpc/treasury.ts treasury.unlink: returns nothing. */
|
|
627
|
+
export const treasuryUnlinkOutput = z.void();
|
|
628
|
+
/** rpc/treasury.ts treasury.setConfidential (env.ts saveEnv): returns nothing. */
|
|
629
|
+
export const treasurySetConfidentialOutput = z.void();
|
|
630
|
+
/** rpc/treasury.ts treasury.fund: a deposit address and chain.ts fundingTransaction. */
|
|
631
|
+
export const treasuryFundOutput = z.looseObject({ deposit: depositOutput, transaction: nearTransaction });
|
|
632
|
+
/** planning/external.ts prepareExternalPlan. */
|
|
633
|
+
export const externalPlanOutput = plan;
|
|
634
|
+
// ---------------------------------------------------------------------------------------------
|
|
635
|
+
// Streams: one yielded event each. Every generator below returns nothing (void) when done.
|
|
636
|
+
/** treasury.ts rebalance RebalanceEvent. serializer: holdings and leg amounts are bigint; `steps` may hold undefined. */
|
|
637
|
+
export const rebalanceEvent = z.discriminatedUnion("type", [
|
|
638
|
+
z.looseObject({
|
|
639
|
+
type: z.literal("plan"),
|
|
640
|
+
total: z.number(),
|
|
641
|
+
book: z.array(holding),
|
|
642
|
+
legs: z.array(z.looseObject({ from: holding, to: holding, usd: z.number(), amount: z.bigint() })),
|
|
643
|
+
/** treasury.ts budgetRemaining. */
|
|
644
|
+
budget: z.string().nullable().optional(),
|
|
645
|
+
strategy,
|
|
646
|
+
}),
|
|
647
|
+
z.looseObject({
|
|
648
|
+
type: z.literal("quote"),
|
|
649
|
+
leg: z.number(),
|
|
650
|
+
skipped: z.boolean(),
|
|
651
|
+
amountOut: z.string(),
|
|
652
|
+
minAmountOut: z.string(),
|
|
653
|
+
costBps: z.number(),
|
|
654
|
+
worstCostBps: z.number(),
|
|
655
|
+
}),
|
|
656
|
+
/** `steps[i]` is leg i's step in the plan, undefined when the leg was skipped. */
|
|
657
|
+
z.looseObject({ type: z.literal("saved"), plan, steps: z.array(z.number().optional()) }),
|
|
658
|
+
]);
|
|
659
|
+
/** planning/execution.ts executePlan PlanEvent. */
|
|
660
|
+
export const executePlanEvent = z.discriminatedUnion("type", [
|
|
661
|
+
z.looseObject({ type: z.literal("rejected"), problems: z.array(z.string()) }),
|
|
662
|
+
z.looseObject({
|
|
663
|
+
type: z.literal("action"),
|
|
664
|
+
index: z.number(),
|
|
665
|
+
action: plannedAction,
|
|
666
|
+
shield: z.looseObject({ amount: z.string(), status: z.string() }).optional(),
|
|
667
|
+
/** `NOT_SENT` when the shield before it did not succeed. */
|
|
668
|
+
status,
|
|
669
|
+
correlationId: z.string(),
|
|
670
|
+
failureCode: z.string().nullable().optional(),
|
|
671
|
+
}),
|
|
672
|
+
]);
|
|
673
|
+
/** treasury.ts sweep SweepEvent. serializer: `exposed` holdings carry bigint. */
|
|
674
|
+
export const sweepEvent = z.discriminatedUnion("type", [
|
|
675
|
+
z.looseObject({ type: z.literal("plan"), exposed: z.array(holding) }),
|
|
676
|
+
z.looseObject({ type: z.literal("shield"), asset: z.string(), status, correlationId: z.string(), failureCode: z.string().nullable().optional() }),
|
|
677
|
+
]);
|
|
678
|
+
/** llm.ts steward StewardEvent. */
|
|
679
|
+
export const stewardProposeEvent = z.discriminatedUnion("type", [
|
|
680
|
+
z.looseObject({ type: z.literal("say"), text: z.string() }),
|
|
681
|
+
z.looseObject({ type: z.literal("call"), name: z.string(), input: z.unknown() }),
|
|
682
|
+
z.looseObject({ type: z.literal("result"), name: z.string(), result: z.string() }),
|
|
683
|
+
z.looseObject({ type: z.literal("verified"), completionId: z.string(), signatureKind: z.string() }),
|
|
684
|
+
z.looseObject({ type: z.literal("plan"), plan }),
|
|
685
|
+
]);
|
|
686
|
+
export const ownerOutputs = {
|
|
687
|
+
"setup": setupOutput,
|
|
688
|
+
"instance": instanceOutput,
|
|
689
|
+
"overview": overviewOutput,
|
|
690
|
+
"policyHistory": policyHistoryOutput,
|
|
691
|
+
"activity": activityOutput,
|
|
692
|
+
"unresolved": unresolvedOutput,
|
|
693
|
+
"held": heldOutput,
|
|
694
|
+
"inbox/list": inboxListOutput,
|
|
695
|
+
"autopilot/get": autopilotGetOutput,
|
|
696
|
+
"autopilot/evidence": autopilotEvidenceOutput,
|
|
697
|
+
"autopilot/log": autopilotLogOutput,
|
|
698
|
+
"strategy/get": strategyGetOutput,
|
|
699
|
+
"treasury/get": treasuryGetOutput,
|
|
700
|
+
"ledger": ledgerOutput,
|
|
701
|
+
"ledgerCsv": ledgerCsvOutput,
|
|
702
|
+
"reconcileBooks": reconcileBooksOutput,
|
|
703
|
+
"paymentHistory": paymentHistoryOutput,
|
|
704
|
+
"paymentStatus": paymentStatusOutput,
|
|
705
|
+
"payouts/request": payoutRequestOutput,
|
|
706
|
+
"payouts/status": payoutRequestOutput,
|
|
707
|
+
"invoices": invoicesOutput,
|
|
708
|
+
"agreements/list": agreementsListOutput,
|
|
709
|
+
"owner/status": ownerStatusOutput,
|
|
710
|
+
"owner/pending": ownerPendingOutput,
|
|
711
|
+
"owner/actions": ownerActionsOutput,
|
|
712
|
+
"compensation/list": compensationListOutput,
|
|
713
|
+
"workOrders/list": workOrdersListOutput,
|
|
714
|
+
"workOrders/get": workOrdersGetOutput,
|
|
715
|
+
"workOrders/status": workOrdersStatusOutput,
|
|
716
|
+
"pay": payOutput,
|
|
717
|
+
"deposit": depositOutput,
|
|
718
|
+
"recover": recoverOutput,
|
|
719
|
+
"cancelPreparedInvoice": cancelPreparedInvoiceOutput,
|
|
720
|
+
"inbox/dismiss": inboxDismissOutput,
|
|
721
|
+
"owner/prepare": ownerPrepareOutput,
|
|
722
|
+
"owner/submit": ownerSubmitOutput,
|
|
723
|
+
"agreements/propose": agreementsProposeOutput,
|
|
724
|
+
"agreements/offer": agreementsOfferOutput,
|
|
725
|
+
"agreements/decline": agreementsDeclineOutput,
|
|
726
|
+
"compensation/agreement": compensationAgreementOutput,
|
|
727
|
+
"compensation/review": compensationReviewOutput,
|
|
728
|
+
"compensation/prepare": compensationPrepareOutput,
|
|
729
|
+
"compensation/send": compensationSendOutput,
|
|
730
|
+
"workOrders/create": workOrdersCreateOutput,
|
|
731
|
+
"workOrders/prepare": workOrdersPrepareOutput,
|
|
732
|
+
"workOrders/submit": workOrdersSubmitOutput,
|
|
733
|
+
"workOrders/deposit": workOrdersDepositOutput,
|
|
734
|
+
"workOrders/file": workOrdersFileOutput,
|
|
735
|
+
"strategy/save": strategySaveOutput,
|
|
736
|
+
"autopilot/set": autopilotSetOutput,
|
|
737
|
+
"autopilot/enable": autopilotEnableOutput,
|
|
738
|
+
"autopilot/stop": autopilotStopOutput,
|
|
739
|
+
"autopilot/tick": autopilotTickOutput,
|
|
740
|
+
"treasury/link": treasuryLinkOutput,
|
|
741
|
+
"treasury/unlink": treasuryUnlinkOutput,
|
|
742
|
+
"treasury/setConfidential": treasurySetConfidentialOutput,
|
|
743
|
+
"treasury/fund": treasuryFundOutput,
|
|
744
|
+
"externalPlan": externalPlanOutput,
|
|
745
|
+
"rebalance": rebalanceEvent,
|
|
746
|
+
"executePlan": executePlanEvent,
|
|
747
|
+
"sweep": sweepEvent,
|
|
748
|
+
"steward/propose": stewardProposeEvent,
|
|
749
|
+
};
|
|
750
|
+
/** Procedures whose output is an event stream: `ownerOutputs` holds the schema of one yielded event. */
|
|
751
|
+
export const ownerStreams = ["rebalance", "executePlan", "sweep", "steward/propose"];
|