botanary-mcp 0.6.5 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -2
- package/dist/src/agent-actions.d.ts +12 -3
- package/dist/src/agent-actions.d.ts.map +1 -1
- package/dist/src/agent-actions.js +43 -23
- package/dist/src/agent-actions.js.map +1 -1
- package/dist/src/agent-grant-helpers.d.ts +7 -18
- package/dist/src/agent-grant-helpers.d.ts.map +1 -1
- package/dist/src/agent-grant-helpers.js +7 -21
- package/dist/src/agent-grant-helpers.js.map +1 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +36 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/diagnose.d.ts.map +1 -1
- package/dist/src/diagnose.js +9 -3
- package/dist/src/diagnose.js.map +1 -1
- package/dist/src/hitl/context.d.ts +60 -0
- package/dist/src/hitl/context.d.ts.map +1 -0
- package/dist/src/hitl/context.js +59 -0
- package/dist/src/hitl/context.js.map +1 -0
- package/dist/src/hitl/handles.d.ts +45 -0
- package/dist/src/hitl/handles.d.ts.map +1 -0
- package/dist/src/hitl/handles.js +120 -0
- package/dist/src/hitl/handles.js.map +1 -0
- package/dist/src/hitl/resume.d.ts +22 -0
- package/dist/src/hitl/resume.d.ts.map +1 -0
- package/dist/src/hitl/resume.js +153 -0
- package/dist/src/hitl/resume.js.map +1 -0
- package/dist/src/hitl/wait.d.ts +59 -0
- package/dist/src/hitl/wait.d.ts.map +1 -0
- package/dist/src/hitl/wait.js +142 -0
- package/dist/src/hitl/wait.js.map +1 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/paths.d.ts +3 -0
- package/dist/src/paths.d.ts.map +1 -1
- package/dist/src/paths.js +5 -0
- package/dist/src/paths.js.map +1 -1
- package/dist/src/runtime.d.ts +16 -5
- package/dist/src/runtime.d.ts.map +1 -1
- package/dist/src/runtime.js +39 -5
- package/dist/src/runtime.js.map +1 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +13 -3
- package/dist/src/server.js.map +1 -1
- package/dist/src/tools.d.ts +11 -1
- package/dist/src/tools.d.ts.map +1 -1
- package/dist/src/tools.js +276 -39
- package/dist/src/tools.js.map +1 -1
- package/dist/src/wallet/composites.d.ts +1 -1
- package/dist/src/wallet/login.d.ts +28 -0
- package/dist/src/wallet/login.d.ts.map +1 -1
- package/dist/src/wallet/login.js +86 -36
- package/dist/src/wallet/login.js.map +1 -1
- package/dist/src/wallet/send-orchestration.d.ts +11 -9
- package/dist/src/wallet/send-orchestration.d.ts.map +1 -1
- package/dist/src/wallet/send-orchestration.js +64 -21
- package/dist/src/wallet/send-orchestration.js.map +1 -1
- package/dist/src/wallet/send.d.ts +15 -0
- package/dist/src/wallet/send.d.ts.map +1 -1
- package/dist/src/wallet/send.js +66 -3
- package/dist/src/wallet/send.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,9 @@ picked at login. Nothing forces them to agree - `wallet_status` prints both bind
|
|
|
18
18
|
flags a mismatch as a first-class finding, and `wallet_send`'s own lane arbitration (below) refuses to
|
|
19
19
|
let a mandate on one account authorize a spend on the other, no matter how "helpful" that would be.
|
|
20
20
|
|
|
21
|
+
> **Full documentation: https://docs.botanary.xyz/mcp** - install recipes per client, the two lanes,
|
|
22
|
+
> the trust model, and a tool reference generated from this package.
|
|
23
|
+
|
|
21
24
|
## Tools
|
|
22
25
|
|
|
23
26
|
`botanary-mcp` advertises a **subset** of its tools at any moment - a small starter set when nothing is
|
|
@@ -67,6 +70,12 @@ advertised tool list changes" further down.
|
|
|
67
70
|
| `wallet_mandates` | Reads `GET /delegations` + `GET /mandates`: what the agent lane may spend unattended - active delegations with budget info, and any outstanding mandates. |
|
|
68
71
|
| `wallet_agents` | Reads `GET /agents` + `GET /agents/requests`: connected agents and any pending approval requests they've filed. |
|
|
69
72
|
| `wallet_api_get` | Read ANY `GET` endpoint in Botanary's frozen OpenAPI contract, authenticated as the owner. **GET-only, deliberately** - see below. |
|
|
73
|
+
| `resolve_token` | Resolve a token address or CAIP-19 asset ref to its full identity - symbol, name, decimals, and which source vouches for it. Refuses bare symbols: a symbol is a label a contract picked for itself, and two contracts on one chain can share one, so the product will not guess. Call `list_tokens` when you only have a symbol. |
|
|
74
|
+
| `list_tokens` | Every token this account holds on a chain, with the contract address and CAIP-19 asset ref you need to spend it. This is the discovery command for `wallet_send`, which takes an address and refuses a symbol. When two rows share a symbol, show both and let the user choose; never guess. |
|
|
75
|
+
|
|
76
|
+
## Why `wallet_send` requires a token address, not a symbol
|
|
77
|
+
|
|
78
|
+
The `wallet_send` tool requires a contract address or CAIP-19 asset ref for the `token` parameter, never a symbol. This is by design: a symbol is a label a contract picks for itself, and two contracts on one chain can legally share the same symbol. The product will not guess which one you meant. Use `resolve_token` to turn a symbol into a full identity, or call `list_tokens` to discover every token this account holds on a chain, each with the address you need.
|
|
70
79
|
|
|
71
80
|
## Lane arbitration: how `wallet_send` decides who signs
|
|
72
81
|
|
|
@@ -95,6 +104,50 @@ the browser page itself does against the live backend, and beneath that, on-chai
|
|
|
95
104
|
result from this preflight proves nothing by itself, the same discipline `propose_payment`'s own
|
|
96
105
|
client-side bounds check documents on the agent lane.
|
|
97
106
|
|
|
107
|
+
## Waiting for results: handles, streams, and why elicitation is not approval
|
|
108
|
+
|
|
109
|
+
Several tools (`wallet_login`, `wallet_send`, `pair`, `request_approval`, `propose_payment`, `propose_swap`)
|
|
110
|
+
do not return immediately - they need human action, on-chain confirmation, or both. These tools now WAIT
|
|
111
|
+
for completion instead of handing back a reference and walking away.
|
|
112
|
+
|
|
113
|
+
When a tool waits, it:
|
|
114
|
+
|
|
115
|
+
1. **Reports progress** - periodically sends heartbeats so the client knows it is still alive and waiting,
|
|
116
|
+
never going silent for minutes at a time.
|
|
117
|
+
2. **Watches the backend's declared deadline** - the server tells the tool how long it is willing to hold the
|
|
118
|
+
operation open. The tool will wait until that deadline, then stop, and the client can join the same wait
|
|
119
|
+
at any time by calling `botanary_wait` with the returned handle.
|
|
120
|
+
3. **Respects an abort signal** - if the client has to stop (interrupt, timeout, preemption by a newer task),
|
|
121
|
+
it can abort the wait without breaking the backend operation. The handle stays live, and the wait can be
|
|
122
|
+
rejoined from where it left off.
|
|
123
|
+
4. **Runs a stream when the server supports it** - most operations have a Server-Sent Events stream endpoint
|
|
124
|
+
that delivers updates in real time. When a stream is not available (old backend, network lost), the tool
|
|
125
|
+
automatically falls back to polling, asking the backend "is this operation done?" at regular intervals.
|
|
126
|
+
|
|
127
|
+
## Handles, and why a handle is not a secret
|
|
128
|
+
|
|
129
|
+
A handle is an opaque reference to an ongoing operation at the backend - a place to rejoin a wait that was
|
|
130
|
+
interrupted. The handle file itself carries **no secret**. Any credential the operation needs (a session
|
|
131
|
+
token, a signer's key, an approval credential) lives in the same keychain chain `wallet_login` uses, and is
|
|
132
|
+
deleted the moment the operation terminates - the handle cannot be replayed from an old transcript.
|
|
133
|
+
|
|
134
|
+
To rejoin a wait: **call `botanary_wait` with the handle** - never re-call the original tool (`wallet_login`,
|
|
135
|
+
`wallet_send`, etc.). Re-calling starts a brand-new operation; the wait will not pick up where it left off.
|
|
136
|
+
|
|
137
|
+
## Why elicitation is never an approval
|
|
138
|
+
|
|
139
|
+
When a tool waits through the `wallet_send` browser handoff, it may elicit - show the caller where a
|
|
140
|
+
signature is being requested, with a cancel affordance. **Elicitation is strictly presentational.** It never
|
|
141
|
+
asks for an approval and never authorizes anything. It only tells the caller: "The signature is needed in
|
|
142
|
+
your browser, here is a link or a code to review it."
|
|
143
|
+
|
|
144
|
+
- If the caller cancels the elicitation, the wait stops locally, but the browser tab stays live and the
|
|
145
|
+
owner can still sign it there.
|
|
146
|
+
- If the owner signs in the browser, the elicitation on the model's side gets the result.
|
|
147
|
+
- If the owner rejects it in the browser, the wait gets the rejection and surfaces it as the final result.
|
|
148
|
+
|
|
149
|
+
The only boundary that counts is the one on-chain.
|
|
150
|
+
|
|
98
151
|
## `wallet_api_get` is GET-only, deliberately - and there is no `api_post`
|
|
99
152
|
|
|
100
153
|
Every path is validated against a manifest generated from the frozen OpenAPI contract
|
|
@@ -224,8 +277,11 @@ Neither piece is derived *from* the private key, and there's no computation that
|
|
|
224
277
|
an obfuscated secret - it was never built out of one.
|
|
225
278
|
|
|
226
279
|
That's what makes the rest of the claim hold: **the code identifies, the signature authenticates.**
|
|
227
|
-
Completing a connection
|
|
228
|
-
that never left this machine
|
|
280
|
+
Completing a connection requires the agent to sign the code together with a timestamp, using the key
|
|
281
|
+
that never left this machine, and submit that signature with its public key - proof of possession, not
|
|
282
|
+
proof of having seen a string. (The signed message is `code|timestamp`; the code is minted locally, so
|
|
283
|
+
this is not a server-issued challenge. `mintSession` is the separate flow that does fetch a server
|
|
284
|
+
nonce before signing.) Someone who only
|
|
229
285
|
intercepted the code cannot produce that signature, because they don't have the key. The worst they can
|
|
230
286
|
do is type the code into their *own* Botanary account's "Connected agents" box - which, per the product
|
|
231
287
|
rule above, gets *them* nothing: a connection with no grant can do nothing, and it takes nothing away
|
|
@@ -2,12 +2,21 @@ import type { AgentRuntime } from './runtime.js';
|
|
|
2
2
|
export interface ProposePaymentInput {
|
|
3
3
|
recipient: string;
|
|
4
4
|
amount: number;
|
|
5
|
-
|
|
5
|
+
/** A contract address or CAIP-19 asset ref - never a symbol. See `resolveAsset`'s own doc comment:
|
|
6
|
+
* this package never resolves a token itself, it asks the backend, whose `AssetResolverService` is
|
|
7
|
+
* the one resolution `DelegationService.buildAction` also uses. */
|
|
8
|
+
token: string;
|
|
6
9
|
chainId: number;
|
|
7
10
|
}
|
|
8
11
|
export interface ProposeSwapInput {
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
/** The token being SOLD - a contract address or CAIP-19 asset ref, never a symbol. Resolved before
|
|
13
|
+
* anything else so the venue match, the budget check and the build all name the same contract. */
|
|
14
|
+
assetIn: string;
|
|
15
|
+
/** The token being BOUGHT - a contract address or CAIP-19 asset ref, never a symbol. Unbounded by the
|
|
16
|
+
* grant (see `proposeSwap`'s own doc comment); resolved only so the backend's still-symbol-keyed
|
|
17
|
+
* build route (`DelegatedActionDto.tokenOut` - the swap shape was not part of Task A11's widening,
|
|
18
|
+
* see its own doc comment) gets a verified symbol rather than whatever the caller typed. */
|
|
19
|
+
assetOut: string;
|
|
11
20
|
amountIn: number;
|
|
12
21
|
chainId: number;
|
|
13
22
|
maxSlippageBps?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-actions.d.ts","sourceRoot":"","sources":["../../src/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-actions.d.ts","sourceRoot":"","sources":["../../src/agent-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMjD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf;;wEAEoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B;uGACmG;IACnG,OAAO,EAAE,MAAM,CAAC;IAChB;;;iGAG6F;IAC7F,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAuHxH;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAgJlH"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { describeGrant,
|
|
1
|
+
import { describeGrant, findBudgetMeter, missingModuleOf } from './agent-grant-helpers.js';
|
|
2
2
|
import { settleRelayedOp } from './wallet/send-orchestration.js';
|
|
3
3
|
import { setupUrl } from './app-link.js';
|
|
4
|
+
import { resolveAsset } from './wallet/asset.js';
|
|
4
5
|
/**
|
|
5
6
|
* Build and relay a payment under this agent's OWN grant. Reads the grant's bounds and permissionId from
|
|
6
7
|
* the backend (GET /agents/me) FIRST: when there is no grant, the grant is not active, it is on a
|
|
@@ -13,7 +14,7 @@ import { setupUrl } from './app-link.js';
|
|
|
13
14
|
* chain is what actually enforces the grant.
|
|
14
15
|
*/
|
|
15
16
|
export async function proposePayment(runtime, input) {
|
|
16
|
-
const { recipient, amount,
|
|
17
|
+
const { recipient, amount, token: tokenRef, chainId } = input;
|
|
17
18
|
const self = await runtime.me();
|
|
18
19
|
if (!self.grant) {
|
|
19
20
|
return { proposed: false, reason: 'no_grant', message: `${describeGrant(self)} Nothing was built or sent.` };
|
|
@@ -35,12 +36,17 @@ export async function proposePayment(runtime, input) {
|
|
|
35
36
|
'was built or sent. Use request_approval if this payment genuinely needs that chain.',
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
// RESOLVE FIRST - the same discipline `wallet_send`'s own doc comment names: every branch below
|
|
40
|
+
// (budget check, per-action cap, build, human-readable messages) has to name the same contract the
|
|
41
|
+
// op will bind, so nothing downstream re-derives or guesses the asset once this resolves. A backend
|
|
42
|
+
// refusal here (unknown ref, unresolvable address) propagates as a rejection, same as `wallet_send`.
|
|
43
|
+
const asset = await resolveAsset(runtime, chainId, tokenRef, await runtime.ensureSession());
|
|
44
|
+
const meter = findBudgetMeter(grant, asset.assetRef);
|
|
39
45
|
if (!meter) {
|
|
40
46
|
return {
|
|
41
47
|
proposed: false,
|
|
42
48
|
reason: 'token_not_budgeted',
|
|
43
|
-
message: `This grant has no budget for ${
|
|
49
|
+
message: `This grant has no budget for ${asset.symbol}. Budgeted tokens: ` +
|
|
44
50
|
`${grant.policySet.budgets.map((b) => b.token.symbol).join(', ') || 'none'}. Nothing was ` +
|
|
45
51
|
'built or sent. Use request_approval instead.',
|
|
46
52
|
};
|
|
@@ -49,17 +55,17 @@ export async function proposePayment(runtime, input) {
|
|
|
49
55
|
return {
|
|
50
56
|
proposed: false,
|
|
51
57
|
reason: 'over_budget',
|
|
52
|
-
message: `This grant has ${meter.remaining} ${
|
|
53
|
-
`${amount} ${
|
|
58
|
+
message: `This grant has ${meter.remaining} ${asset.symbol} remaining (of ${meter.limit} total); ` +
|
|
59
|
+
`${amount} ${asset.symbol} would exceed it. Nothing was built or sent. Use request_approval ` +
|
|
54
60
|
'to ask the owner for this specific payment.',
|
|
55
61
|
};
|
|
56
62
|
}
|
|
57
63
|
const perActionMax = grant.policySet.perActionMax;
|
|
58
|
-
if (perActionMax && perActionMax.token.
|
|
64
|
+
if (perActionMax && perActionMax.token.assetRef === asset.assetRef && amount > perActionMax.amount) {
|
|
59
65
|
return {
|
|
60
66
|
proposed: false,
|
|
61
67
|
reason: 'over_per_action_max',
|
|
62
|
-
message: `This grant caps a single action at ${perActionMax.amount} ${
|
|
68
|
+
message: `This grant caps a single action at ${perActionMax.amount} ${asset.symbol}; ${amount} ` +
|
|
63
69
|
'exceeds it. Nothing was built or sent. Use request_approval instead.',
|
|
64
70
|
};
|
|
65
71
|
}
|
|
@@ -70,7 +76,11 @@ export async function proposePayment(runtime, input) {
|
|
|
70
76
|
// itself refuses (403, named reason) a delegation id that does not name this agent.
|
|
71
77
|
let build;
|
|
72
78
|
try {
|
|
73
|
-
|
|
79
|
+
// `asset.assetRef` - the RESOLVED identity, not the raw `tokenRef` the caller passed in. Both are
|
|
80
|
+
// accepted by `DelegatedActionDto.token` (an address or a CAIP-19 ref), but the assetRef is what
|
|
81
|
+
// this function already checked the budget against, so sending anything else risks the build
|
|
82
|
+
// resolving a technically-equivalent-but-textually-different reference to a different conclusion.
|
|
83
|
+
build = await runtime.buildDelegatedAction({ delegationId: grant.id, recipient, amount, token: asset.assetRef });
|
|
74
84
|
}
|
|
75
85
|
catch (e) {
|
|
76
86
|
// The one refusal with a remedy the OWNER can act on in a browser and this agent cannot act on
|
|
@@ -105,7 +115,7 @@ export async function proposePayment(runtime, input) {
|
|
|
105
115
|
// instruction - and the agent's natural next move, resending, would move real money twice. That
|
|
106
116
|
// whole discipline lives in `settleRelayedOp`, shared with `proposeSwap` so the two can never
|
|
107
117
|
// drift into describing the same three outcomes differently.
|
|
108
|
-
return settleRelayedOp(runtime, opId, build.userOpHash, 'payment', { amount, token:
|
|
118
|
+
return settleRelayedOp(runtime, opId, build.userOpHash, 'payment', { amount, token: asset.symbol }, `NOTHING moved: no ${asset.symbol} left the account, the recipient received nothing, ` +
|
|
109
119
|
'and the grant budget was not spent.');
|
|
110
120
|
}
|
|
111
121
|
/**
|
|
@@ -125,7 +135,7 @@ export async function proposePayment(runtime, input) {
|
|
|
125
135
|
* the grant.
|
|
126
136
|
*/
|
|
127
137
|
export async function proposeSwap(runtime, input) {
|
|
128
|
-
const {
|
|
138
|
+
const { assetIn, assetOut, amountIn, chainId, maxSlippageBps } = input;
|
|
129
139
|
// BOUNDS FIRST, exactly as proposePayment does, and for the same reason: the refusals below are
|
|
130
140
|
// the ones this side can make honestly from backend-reported facts, and making them here means an
|
|
131
141
|
// out-of-grant swap costs no build, no signature and no relay.
|
|
@@ -168,12 +178,17 @@ export async function proposeSwap(runtime, input) {
|
|
|
168
178
|
'and token it may swap, or use request_approval for this one swap.',
|
|
169
179
|
};
|
|
170
180
|
}
|
|
171
|
-
|
|
181
|
+
// RESOLVE the SOLD leg before anything below - the venue match, the allowance ceiling and the budget
|
|
182
|
+
// check all have to name the same contract, exactly the discipline `proposePayment` follows. The
|
|
183
|
+
// BOUGHT leg (`assetOut`) is resolved further down, only once every refusal above it has passed: it
|
|
184
|
+
// costs a network call for no reason if this swap is going to be refused anyway.
|
|
185
|
+
const soldAsset = await resolveAsset(runtime, chainId, assetIn, await runtime.ensureSession());
|
|
186
|
+
if (venue.token.symbol.toUpperCase() !== soldAsset.symbol.toUpperCase()) {
|
|
172
187
|
return {
|
|
173
188
|
proposed: false,
|
|
174
189
|
reason: 'token_not_venue_token',
|
|
175
|
-
message: `This grant may only swap ${venue.token.symbol}, not ${
|
|
176
|
-
'sold token exactly, and any other would be refused in validation. Nothing was built or ' +
|
|
190
|
+
message: `This grant may only swap ${venue.token.symbol}, not ${soldAsset.symbol} - its session pins ` +
|
|
191
|
+
'the sold token exactly, and any other would be refused in validation. Nothing was built or ' +
|
|
177
192
|
'sent. Use request_approval instead.',
|
|
178
193
|
};
|
|
179
194
|
}
|
|
@@ -182,23 +197,28 @@ export async function proposeSwap(runtime, input) {
|
|
|
182
197
|
proposed: false,
|
|
183
198
|
reason: 'over_venue_allowance',
|
|
184
199
|
message: `This grant allows at most ${venue.maxAllowance} ${venue.token.symbol} per swap; ` +
|
|
185
|
-
`${amountIn} ${
|
|
186
|
-
'the owner for this specific swap.',
|
|
200
|
+
`${amountIn} ${soldAsset.symbol} exceeds it. Nothing was built or sent. Use ` +
|
|
201
|
+
'request_approval to ask the owner for this specific swap.',
|
|
187
202
|
};
|
|
188
203
|
}
|
|
189
204
|
// The grant's ordinary spend meter applies TOO - the venue ceiling caps one swap, the budget caps
|
|
190
205
|
// the lifetime - so a swap within the ceiling but over what is left is still refused here, with
|
|
191
206
|
// the backend's own remaining figure rather than a guess.
|
|
192
|
-
const meter =
|
|
207
|
+
const meter = findBudgetMeter(grant, soldAsset.assetRef);
|
|
193
208
|
if (meter && amountIn > meter.remaining) {
|
|
194
209
|
return {
|
|
195
210
|
proposed: false,
|
|
196
211
|
reason: 'over_budget',
|
|
197
|
-
message: `This grant has ${meter.remaining} ${
|
|
198
|
-
`${amountIn} ${
|
|
199
|
-
'to ask the owner for this specific swap.',
|
|
212
|
+
message: `This grant has ${meter.remaining} ${soldAsset.symbol} remaining (of ${meter.limit} total); ` +
|
|
213
|
+
`${amountIn} ${soldAsset.symbol} would exceed it. Nothing was built or sent. Use ` +
|
|
214
|
+
'request_approval to ask the owner for this specific swap.',
|
|
200
215
|
};
|
|
201
216
|
}
|
|
217
|
+
// Resolved only now, past every refusal that did not need it. `DelegatedActionDto`'s swap shape
|
|
218
|
+
// (`tokenIn`/`tokenOut`) was NOT part of Task A11's widening - see this function's own doc comment -
|
|
219
|
+
// so the backend still wants a SYMBOL for both legs; this resolves the caller's address/asset ref
|
|
220
|
+
// into the contract's own verified symbol rather than sending back whatever string the caller typed.
|
|
221
|
+
const boughtAsset = await resolveAsset(runtime, chainId, assetOut, await runtime.ensureSession());
|
|
202
222
|
// Within the client-read bounds - build AGAINST THIS AGENT'S OWN GRANT ID (grant.id, from
|
|
203
223
|
// GET /agents/me), then relay it signed with the grant's own session key. The router is the
|
|
204
224
|
// BACKEND's to resolve: it quotes the route, checks it against the one router the venue pins, and
|
|
@@ -207,8 +227,8 @@ export async function proposeSwap(runtime, input) {
|
|
|
207
227
|
try {
|
|
208
228
|
build = await runtime.buildDelegatedSwap({
|
|
209
229
|
delegationId: grant.id,
|
|
210
|
-
tokenIn,
|
|
211
|
-
tokenOut,
|
|
230
|
+
tokenIn: soldAsset.symbol,
|
|
231
|
+
tokenOut: boughtAsset.symbol,
|
|
212
232
|
amountIn,
|
|
213
233
|
...(maxSlippageBps != null ? { maxSlippageBps } : {}),
|
|
214
234
|
});
|
|
@@ -238,7 +258,7 @@ export async function proposeSwap(runtime, input) {
|
|
|
238
258
|
return { proposed: true, settled: false, userOpHash: build.userOpHash, relay };
|
|
239
259
|
// THE RELAY HAS ALREADY SUCCEEDED by this line - see `settleRelayedOp`, which owns the three
|
|
240
260
|
// outcomes from here and is the SAME code proposePayment settles through.
|
|
241
|
-
return settleRelayedOp(runtime, opId, build.userOpHash, 'swap', { amount: amountIn, token:
|
|
261
|
+
return settleRelayedOp(runtime, opId, build.userOpHash, 'swap', { amount: amountIn, token: soldAsset.symbol }, `NOTHING moved: no ${soldAsset.symbol} left the account, no ${boughtAsset.symbol} was received, ` +
|
|
242
262
|
'and the grant budget was not spent.');
|
|
243
263
|
}
|
|
244
264
|
//# sourceMappingURL=agent-actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-actions.js","sourceRoot":"","sources":["../../src/agent-actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"agent-actions.js","sourceRoot":"","sources":["../../src/agent-actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AA0BjD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAqB,EAAE,KAA0B;IACpF,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAE9D,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,EAAE,EAAE,CAAC;IAChC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,6BAA6B,EAAE,CAAC;IAC/G,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACzB,IAAI,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO;Y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AAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7D,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC;IAE1F,6FAA6F;IAC7F,0EAA0E;IAC1E,OAAO,eAAe,CACpB,OAAO,EACP,IAAI,EACJ,KAAK,CAAC,UAAU,EAChB,MAAM,EACN,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,EAC7C,qBAAqB,SAAS,CAAC,MAAM,yBAAyB,WAAW,CAAC,MAAM,iBAAiB;QAC/F,qCAAqC,CACxC,CAAC;AACJ,CAAC"}
|
|
@@ -16,24 +16,13 @@ export declare function describeGrant(self: AgentSelf): string;
|
|
|
16
16
|
*
|
|
17
17
|
* Callers must supply a REAL assetRef - one that came from `GET /agents/me`'s own grant (a budgeted
|
|
18
18
|
* token) or from `GET /assets/resolve` (a resolved send/swap target), never a guessed or hand-built
|
|
19
|
-
* string. `wallet_send`'s `checkSendBounds`
|
|
20
|
-
*
|
|
21
|
-
* than by label
|
|
19
|
+
* string. `wallet_send`'s `checkSendBounds` (the owner lane) and `propose_payment`/`propose_swap`
|
|
20
|
+
* (`agent-actions.ts`, the agent lane) are both callers, each resolving its caller-named token before
|
|
21
|
+
* ever reaching here - this is the ONLY place a budget is matched, by identity rather than by label,
|
|
22
|
+
* across either lane. `findBudgetMeterBySymbol` used to exist as a SECOND matcher for the agent lane's
|
|
23
|
+
* build route, which validated its token by symbol until Task A11 widened it to accept an address/asset
|
|
24
|
+
* ref too - a second enumeration of the same fact is exactly what `modules/agent/token-decimals.ts`
|
|
25
|
+
* blames for its 10^12 mis-encoding incident, so it was deleted rather than kept in sync by hand.
|
|
22
26
|
*/
|
|
23
27
|
export declare function findBudgetMeter(grant: AgentGrantView, assetRef: string): SpendMeterView | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* The spend meter for `tokenSymbol` on this grant, matched by SYMBOL - not `findBudgetMeter`'s assetRef
|
|
26
|
-
* match above. Exists ONLY for `propose_payment`/`propose_swap` (`agent-actions.ts`), whose build route
|
|
27
|
-
* (`POST /delegations/{delegationId}/actions`, `DelegatedActionDto`) still validates `token`/`tokenIn`/
|
|
28
|
-
* `tokenOut` BY SYMBOL - that DTO was not touched by the asset-identity migration, so those two tools
|
|
29
|
-
* still take a symbol from their caller and this is the honest match for it.
|
|
30
|
-
*
|
|
31
|
-
* Deliberately does NOT resolve a symbol to an assetRef and delegate to `findBudgetMeter`: a budgeted
|
|
32
|
-
* token whose address this build has no manifest entry for keeps `assetRef: null`
|
|
33
|
-
* (`grant-asset-refs.ts`'s own convention, "honestly undecodable, never guessed") - if this delegated
|
|
34
|
-
* instead, that null would collide with every other unresolvable token and the meter would go missing
|
|
35
|
-
* for a token that IS genuinely budgeted. Matching directly on the row's own `symbol` field, exactly as
|
|
36
|
-
* this package always has, has no such failure mode.
|
|
37
|
-
*/
|
|
38
|
-
export declare function findBudgetMeterBySymbol(grant: AgentGrantView, tokenSymbol: string): SpendMeterView | undefined;
|
|
39
28
|
//# sourceMappingURL=agent-grant-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-grant-helpers.d.ts","sourceRoot":"","sources":["../../src/agent-grant-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9E;4GAC4G;AAC5G,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAIzD;AAED;;gFAEgF;AAChF,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAqBrD;AAED
|
|
1
|
+
{"version":3,"file":"agent-grant-helpers.d.ts","sourceRoot":"","sources":["../../src/agent-grant-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9E;4GAC4G;AAC5G,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAIzD;AAED;;gFAEgF;AAChF,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAqBrD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAGnG"}
|
|
@@ -36,30 +36,16 @@ export function describeGrant(self) {
|
|
|
36
36
|
*
|
|
37
37
|
* Callers must supply a REAL assetRef - one that came from `GET /agents/me`'s own grant (a budgeted
|
|
38
38
|
* token) or from `GET /assets/resolve` (a resolved send/swap target), never a guessed or hand-built
|
|
39
|
-
* string. `wallet_send`'s `checkSendBounds`
|
|
40
|
-
*
|
|
41
|
-
* than by label
|
|
39
|
+
* string. `wallet_send`'s `checkSendBounds` (the owner lane) and `propose_payment`/`propose_swap`
|
|
40
|
+
* (`agent-actions.ts`, the agent lane) are both callers, each resolving its caller-named token before
|
|
41
|
+
* ever reaching here - this is the ONLY place a budget is matched, by identity rather than by label,
|
|
42
|
+
* across either lane. `findBudgetMeterBySymbol` used to exist as a SECOND matcher for the agent lane's
|
|
43
|
+
* build route, which validated its token by symbol until Task A11 widened it to accept an address/asset
|
|
44
|
+
* ref too - a second enumeration of the same fact is exactly what `modules/agent/token-decimals.ts`
|
|
45
|
+
* blames for its 10^12 mis-encoding incident, so it was deleted rather than kept in sync by hand.
|
|
42
46
|
*/
|
|
43
47
|
export function findBudgetMeter(grant, assetRef) {
|
|
44
48
|
const idx = grant.policySet.budgets.findIndex((b) => b.token.assetRef === assetRef);
|
|
45
49
|
return idx === -1 ? undefined : grant.spentToDate[idx];
|
|
46
50
|
}
|
|
47
|
-
/**
|
|
48
|
-
* The spend meter for `tokenSymbol` on this grant, matched by SYMBOL - not `findBudgetMeter`'s assetRef
|
|
49
|
-
* match above. Exists ONLY for `propose_payment`/`propose_swap` (`agent-actions.ts`), whose build route
|
|
50
|
-
* (`POST /delegations/{delegationId}/actions`, `DelegatedActionDto`) still validates `token`/`tokenIn`/
|
|
51
|
-
* `tokenOut` BY SYMBOL - that DTO was not touched by the asset-identity migration, so those two tools
|
|
52
|
-
* still take a symbol from their caller and this is the honest match for it.
|
|
53
|
-
*
|
|
54
|
-
* Deliberately does NOT resolve a symbol to an assetRef and delegate to `findBudgetMeter`: a budgeted
|
|
55
|
-
* token whose address this build has no manifest entry for keeps `assetRef: null`
|
|
56
|
-
* (`grant-asset-refs.ts`'s own convention, "honestly undecodable, never guessed") - if this delegated
|
|
57
|
-
* instead, that null would collide with every other unresolvable token and the meter would go missing
|
|
58
|
-
* for a token that IS genuinely budgeted. Matching directly on the row's own `symbol` field, exactly as
|
|
59
|
-
* this package always has, has no such failure mode.
|
|
60
|
-
*/
|
|
61
|
-
export function findBudgetMeterBySymbol(grant, tokenSymbol) {
|
|
62
|
-
const idx = grant.policySet.budgets.findIndex((b) => b.token.symbol.toUpperCase() === tokenSymbol.toUpperCase());
|
|
63
|
-
return idx === -1 ? undefined : grant.spentToDate[idx];
|
|
64
|
-
}
|
|
65
51
|
//# sourceMappingURL=agent-grant-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-grant-helpers.js","sourceRoot":"","sources":["../../src/agent-grant-helpers.ts"],"names":[],"mappings":"AAEA;4GAC4G;AAC5G,MAAM,UAAU,eAAe,CAAC,CAAU;IACxC,MAAM,OAAO,GAAI,CAAyD,EAAE,OAAO,CAAC;IACpF,MAAM,IAAI,GAAG,OAAO,EAAE,aAAa,CAAC;IACpC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,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eAAe,CAAC,KAAqB,EAAE,QAAgB;IACrE,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;IACpF,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AACzD,CAAC"}
|
package/dist/src/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAuBjD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,YAAY,CAAC;IACtB,YAAY,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,MAAM,CAAC;IAChD,eAAe,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED;;uGAEuG;AACvG,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CA4B3E"}
|
package/dist/src/cli.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createTools } from './tools.js';
|
|
2
|
+
import { PACKAGE_VERSION } from './package-version.js';
|
|
1
3
|
const HELP_TEXT = `botanary-mcp - Botanary's agent connector (local MCP server)
|
|
2
4
|
|
|
3
5
|
Usage:
|
|
@@ -10,6 +12,10 @@ Usage:
|
|
|
10
12
|
fallback). Any grant a Botanary account still has on file for this
|
|
11
13
|
agent's address is UNCHANGED - revoke that separately, in Botanary. See
|
|
12
14
|
the README ("what deleting the key does and doesn't do").
|
|
15
|
+
botanary-mcp tools List every tool this server can expose, with its lane. Add --json for
|
|
16
|
+
the machine-readable form (this is what generates the tool reference on
|
|
17
|
+
docs.botanary.xyz). Reads metadata only: creates no key, contacts
|
|
18
|
+
nothing.
|
|
13
19
|
botanary-mcp --help Show this message.
|
|
14
20
|
`;
|
|
15
21
|
/** Runs one CLI invocation and returns the process exit code. Kept free of `process.exit`/signal
|
|
@@ -27,6 +33,8 @@ export async function runCli(argv, deps) {
|
|
|
27
33
|
return await whoami(deps, stdout);
|
|
28
34
|
case 'forget':
|
|
29
35
|
return await forget(deps, stdout);
|
|
36
|
+
case 'tools':
|
|
37
|
+
return await tools(deps, argv.slice(1), stdout);
|
|
30
38
|
case '--help':
|
|
31
39
|
case '-h':
|
|
32
40
|
case 'help':
|
|
@@ -76,4 +84,32 @@ async function forget(deps, stdout) {
|
|
|
76
84
|
: 'No agent identity was stored on this machine - nothing to delete.');
|
|
77
85
|
return 0;
|
|
78
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Tool METADATA only. `createTools` uses its runtime solely inside each tool's `run` closure, so
|
|
89
|
+
* enumerating the list touches no key, no keychain and no network - which is what makes it safe to run
|
|
90
|
+
* from a docs build on a CI runner that has no Botanary credentials at all. `test/cli.spec.ts` pins
|
|
91
|
+
* that: it asserts no identity exists afterwards, against a runtime whose `fetch` is refused outright.
|
|
92
|
+
*
|
|
93
|
+
* Synchronous by nature, but declared async to match the other command handlers' shape.
|
|
94
|
+
*/
|
|
95
|
+
async function tools(deps, rest, stdout) {
|
|
96
|
+
const definitions = createTools(deps.runtime).map((tool) => ({
|
|
97
|
+
name: tool.name,
|
|
98
|
+
lane: tool.lane,
|
|
99
|
+
docSummary: tool.docSummary,
|
|
100
|
+
description: tool.description,
|
|
101
|
+
inputSchema: tool.inputSchema,
|
|
102
|
+
}));
|
|
103
|
+
if (rest.includes('--json')) {
|
|
104
|
+
// One compact line, the same contract `botanary prompt --json` offers: a generator reads stdout
|
|
105
|
+
// whole and parses it, so anything multi-line or pretty-printed is a needless parsing hazard.
|
|
106
|
+
stdout(JSON.stringify({ version: PACKAGE_VERSION, tools: definitions }));
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
const width = Math.max(...definitions.map((tool) => tool.name.length));
|
|
110
|
+
for (const tool of definitions) {
|
|
111
|
+
stdout(`${tool.name.padEnd(width)} ${tool.lane.padEnd(7)} ${tool.docSummary}`);
|
|
112
|
+
}
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
79
115
|
//# sourceMappingURL=cli.js.map
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;CAiBjB,CAAC;AAUF;;uGAEuG;AACvG,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAc,EAAE,IAAa;IACxD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC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d.ts","sourceRoot":"","sources":["../../src/diagnose.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../../src/diagnose.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,cAAc,CAAC;AAG5D,MAAM,MAAM,aAAa,GACrB,QAAQ,GACR,eAAe,GACf,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,GAChB,gBAAgB;AAClB;;;gDAGgD;GAC9C,gBAAgB;AAClB;qGACqG;GACnG,yBAAyB,GACzB,UAAU;AACZ,uGAAuG;GACrG,kBAAkB,GAClB,UAAU,GACV,OAAO,CAAC;AAEZ,MAAM,WAAW,OAAO;IACtB;;sBAEkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,UAAU,GAAG,SAAS,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAeD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAkQhF"}
|
package/dist/src/diagnose.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BotanaryApiError } from './api-client.js';
|
|
2
2
|
import { setupUrl } from './app-link.js';
|
|
3
|
+
import { getFallbackCount } from './hitl/wait.js';
|
|
3
4
|
const BALANCE_FRESHNESS = 'backend store-backed (GET /balance makes zero external calls) - may lag the chain by a refresh cycle';
|
|
4
5
|
function report(state, summary, blockers, facts = {}, freshness = {}) {
|
|
5
6
|
return { state, summary, blockers, facts, freshness };
|
|
@@ -12,6 +13,9 @@ function report(state, summary, blockers, facts = {}, freshness = {}) {
|
|
|
12
13
|
* Never mutates and never signs. Every number it reports is the backend's own.
|
|
13
14
|
*/
|
|
14
15
|
export async function runDiagnose(runtime) {
|
|
16
|
+
const pending = (await runtime.handles.list()).map((h) => ({ id: h.id, kind: h.kind, label: h.label, expiresAt: h.expiresAt }));
|
|
17
|
+
const fallbackCount = getFallbackCount();
|
|
18
|
+
const transport = fallbackCount > 0 ? 'polling (stream unavailable)' : 'stream (or polling as fallback)';
|
|
15
19
|
if (!(await runtime.store.hasIdentity())) {
|
|
16
20
|
return report('no_key', 'No agent key exists on this machine yet.', [
|
|
17
21
|
{
|
|
@@ -20,7 +24,7 @@ export async function runDiagnose(runtime) {
|
|
|
20
24
|
detail: 'Nothing is stored at this machine\'s identity path.',
|
|
21
25
|
nextAction: 'Call get_pairing_code to create an identity and get a code for the owner to claim.',
|
|
22
26
|
},
|
|
23
|
-
]);
|
|
27
|
+
], { pending, transport });
|
|
24
28
|
}
|
|
25
29
|
let self;
|
|
26
30
|
try {
|
|
@@ -35,7 +39,7 @@ export async function runDiagnose(runtime) {
|
|
|
35
39
|
detail: `The backend does not recognise this agent (HTTP ${e.status}).`,
|
|
36
40
|
nextAction: 'Call get_pairing_code and give the code to the owner to enter in Botanary.',
|
|
37
41
|
},
|
|
38
|
-
]);
|
|
42
|
+
], { pending, transport });
|
|
39
43
|
}
|
|
40
44
|
return report('backend_unavailable', 'Could not reach the Botanary backend to ask who this agent is.', [
|
|
41
45
|
{
|
|
@@ -44,12 +48,14 @@ export async function runDiagnose(runtime) {
|
|
|
44
48
|
detail: e instanceof Error ? e.message : String(e),
|
|
45
49
|
nextAction: 'Retry once the backend is reachable. Nothing local is wrong.',
|
|
46
50
|
},
|
|
47
|
-
]);
|
|
51
|
+
], { pending, transport });
|
|
48
52
|
}
|
|
49
53
|
const facts = {
|
|
50
54
|
agent: { id: self.id, name: self.name, address: self.address, fingerprint: self.fingerprint },
|
|
51
55
|
account: { accountId: self.accountId, address: self.accountAddress ?? null },
|
|
52
56
|
grant: self.grant,
|
|
57
|
+
pending,
|
|
58
|
+
transport,
|
|
53
59
|
};
|
|
54
60
|
/** Name the account by the address the OWNER would recognise, falling back to the opaque row id only
|
|
55
61
|
* when an older backend does not send one. This is the whole point of the diagnosis: "connected to an
|
package/dist/src/diagnose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../src/diagnose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../src/diagnose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAyClD,MAAM,iBAAiB,GACrB,sGAAsG,CAAC;AAEzG,SAAS,MAAM,CACb,KAAoB,EACpB,OAAe,EACf,QAAmB,EACnB,QAAiC,EAAE,EACnC,YAAoC,EAAE;IAEtC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AACxD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAqB;IACrD,MAAM,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EA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