botanary-mcp 0.6.4 → 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.
Files changed (68) hide show
  1. package/README.md +50 -0
  2. package/dist/src/agent-actions.d.ts +12 -3
  3. package/dist/src/agent-actions.d.ts.map +1 -1
  4. package/dist/src/agent-actions.js +42 -22
  5. package/dist/src/agent-actions.js.map +1 -1
  6. package/dist/src/agent-grant-helpers.d.ts +19 -4
  7. package/dist/src/agent-grant-helpers.d.ts.map +1 -1
  8. package/dist/src/agent-grant-helpers.js +20 -5
  9. package/dist/src/agent-grant-helpers.js.map +1 -1
  10. package/dist/src/diagnose.d.ts.map +1 -1
  11. package/dist/src/diagnose.js +9 -3
  12. package/dist/src/diagnose.js.map +1 -1
  13. package/dist/src/hitl/context.d.ts +60 -0
  14. package/dist/src/hitl/context.d.ts.map +1 -0
  15. package/dist/src/hitl/context.js +59 -0
  16. package/dist/src/hitl/context.js.map +1 -0
  17. package/dist/src/hitl/handles.d.ts +45 -0
  18. package/dist/src/hitl/handles.d.ts.map +1 -0
  19. package/dist/src/hitl/handles.js +120 -0
  20. package/dist/src/hitl/handles.js.map +1 -0
  21. package/dist/src/hitl/resume.d.ts +22 -0
  22. package/dist/src/hitl/resume.d.ts.map +1 -0
  23. package/dist/src/hitl/resume.js +153 -0
  24. package/dist/src/hitl/resume.js.map +1 -0
  25. package/dist/src/hitl/wait.d.ts +59 -0
  26. package/dist/src/hitl/wait.d.ts.map +1 -0
  27. package/dist/src/hitl/wait.js +142 -0
  28. package/dist/src/hitl/wait.js.map +1 -0
  29. package/dist/src/index.d.ts +4 -0
  30. package/dist/src/index.d.ts.map +1 -1
  31. package/dist/src/index.js +2 -0
  32. package/dist/src/index.js.map +1 -1
  33. package/dist/src/paths.d.ts +3 -0
  34. package/dist/src/paths.d.ts.map +1 -1
  35. package/dist/src/paths.js +5 -0
  36. package/dist/src/paths.js.map +1 -1
  37. package/dist/src/runtime.d.ts +24 -5
  38. package/dist/src/runtime.d.ts.map +1 -1
  39. package/dist/src/runtime.js +39 -5
  40. package/dist/src/runtime.js.map +1 -1
  41. package/dist/src/server.d.ts.map +1 -1
  42. package/dist/src/server.js +13 -3
  43. package/dist/src/server.js.map +1 -1
  44. package/dist/src/tools.d.ts +2 -1
  45. package/dist/src/tools.d.ts.map +1 -1
  46. package/dist/src/tools.js +319 -41
  47. package/dist/src/tools.js.map +1 -1
  48. package/dist/src/wallet/asset.d.ts +28 -0
  49. package/dist/src/wallet/asset.d.ts.map +1 -0
  50. package/dist/src/wallet/asset.js +31 -0
  51. package/dist/src/wallet/asset.js.map +1 -0
  52. package/dist/src/wallet/login.d.ts +28 -0
  53. package/dist/src/wallet/login.d.ts.map +1 -1
  54. package/dist/src/wallet/login.js +86 -36
  55. package/dist/src/wallet/login.js.map +1 -1
  56. package/dist/src/wallet/payloads.d.ts +17 -4
  57. package/dist/src/wallet/payloads.d.ts.map +1 -1
  58. package/dist/src/wallet/payloads.js +2 -1
  59. package/dist/src/wallet/payloads.js.map +1 -1
  60. package/dist/src/wallet/send-orchestration.d.ts +25 -13
  61. package/dist/src/wallet/send-orchestration.d.ts.map +1 -1
  62. package/dist/src/wallet/send-orchestration.js +94 -29
  63. package/dist/src/wallet/send-orchestration.js.map +1 -1
  64. package/dist/src/wallet/send.d.ts +27 -1
  65. package/dist/src/wallet/send.d.ts.map +1 -1
  66. package/dist/src/wallet/send.js +66 -3
  67. package/dist/src/wallet/send.js.map +1 -1
  68. package/package.json +1 -1
package/README.md CHANGED
@@ -70,6 +70,12 @@ advertised tool list changes" further down.
70
70
  | `wallet_mandates` | Reads `GET /delegations` + `GET /mandates`: what the agent lane may spend unattended - active delegations with budget info, and any outstanding mandates. |
71
71
  | `wallet_agents` | Reads `GET /agents` + `GET /agents/requests`: connected agents and any pending approval requests they've filed. |
72
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.
73
79
 
74
80
  ## Lane arbitration: how `wallet_send` decides who signs
75
81
 
@@ -98,6 +104,50 @@ the browser page itself does against the live backend, and beneath that, on-chai
98
104
  result from this preflight proves nothing by itself, the same discipline `propose_payment`'s own
99
105
  client-side bounds check documents on the agent lane.
100
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
+
101
151
  ## `wallet_api_get` is GET-only, deliberately - and there is no `api_post`
102
152
 
103
153
  Every path is validated against a manifest generated from the frozen OpenAPI contract
@@ -2,12 +2,21 @@ import type { AgentRuntime } from './runtime.js';
2
2
  export interface ProposePaymentInput {
3
3
  recipient: string;
4
4
  amount: number;
5
- tokenSymbol: string;
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
- tokenIn: string;
10
- tokenOut: string;
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;AAKjD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,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,CA8GxH;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqIlH"}
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
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, tokenSymbol, chainId } = input;
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
- const meter = findBudgetMeter(grant, tokenSymbol);
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 ${tokenSymbol}. Budgeted tokens: ` +
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} ${tokenSymbol} remaining (of ${meter.limit} total); ` +
53
- `${amount} ${tokenSymbol} would exceed it. Nothing was built or sent. Use request_approval ` +
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.symbol.toUpperCase() === tokenSymbol.toUpperCase() && amount > perActionMax.amount) {
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} ${tokenSymbol}; ${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
- build = await runtime.buildDelegatedAction({ delegationId: grant.id, recipient, amount, token: tokenSymbol });
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: tokenSymbol }, `NOTHING moved: no ${tokenSymbol} left the account, the recipient received nothing, ` +
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 { tokenIn, tokenOut, amountIn, chainId, maxSlippageBps } = input;
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
- if (venue.token.symbol.toUpperCase() !== tokenIn.toUpperCase()) {
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 ${tokenIn} - its session pins the ` +
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} ${tokenIn} exceeds it. Nothing was built or sent. Use request_approval to ask ` +
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 = findBudgetMeter(grant, tokenIn);
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} ${tokenIn} remaining (of ${meter.limit} total); ` +
198
- `${amountIn} ${tokenIn} would exceed it. Nothing was built or sent. Use request_approval ` +
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: tokenIn }, `NOTHING moved: no ${tokenIn} left the account, no ${tokenOut} was received, ` +
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,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAiBzC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAqB,EAAE,KAA0B;IACpF,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAE1D,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;YACL,QAAQ,EAAE,KAAK;YACf,M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ACrD,OAAO,EACL,2BAA2B,OAAO,aAAa,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,KAAK,UAAU;gBACtF,qFAAqF;gBACrF,yFAAyF;gBACzF,0FAA0F;gBAC1F,4CAA4C;SAC/C,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC;IAC5C,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAEzH,MAAM,IAAI,GAAG,OAAO,KAAK,EAAE,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,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"}
@@ -6,8 +6,23 @@ export declare function missingModuleOf(e: unknown): string | null;
6
6
  * data (never a fabricated number), shared by `what_may_i_do` and the `propose_payment`/`propose_swap`
7
7
  * refusal paths so no two tools describe the same grant two different ways. */
8
8
  export declare function describeGrant(self: AgentSelf): string;
9
- /** The spend meter for `tokenSymbol` on this grant, or undefined when the grant budgets no such token -
10
- * `spentToDate` is "one meter per budget, in the SAME order as policySet.budgets" (backend's own
11
- * invariant, `Delegation.spentToDate`'s doc comment), which is what makes this a plain index lookup. */
12
- export declare function findBudgetMeter(grant: AgentGrantView, tokenSymbol: string): SpendMeterView | undefined;
9
+ /**
10
+ * The spend meter for `assetRef` on this grant, or undefined when the grant budgets no such asset.
11
+ * Matches on the CAIP-19 identity, never on the symbol: `AgentGuard` and `MandateExecutor` enforce a
12
+ * budget against a token ADDRESS, so a client that can only see a symbol is asking a different question
13
+ * from the one the chain will answer - two contracts on one chain can share a symbol. `spentToDate` is
14
+ * "one meter per budget, in the SAME order as policySet.budgets" (backend's own invariant,
15
+ * `Delegation.spentToDate`'s doc comment), which is what makes this a plain index lookup.
16
+ *
17
+ * Callers must supply a REAL assetRef - one that came from `GET /agents/me`'s own grant (a budgeted
18
+ * token) or from `GET /assets/resolve` (a resolved send/swap target), never a guessed or hand-built
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.
26
+ */
27
+ export declare function findBudgetMeter(grant: AgentGrantView, assetRef: string): SpendMeterView | undefined;
13
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;;yGAEyG;AACzG,wBAAgB,eAAe,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAGtG"}
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"}
@@ -26,11 +26,26 @@ export function describeGrant(self) {
26
26
  .join('; ');
27
27
  return `Grant status: ${g.status}. ${g.humanSummary}${meters ? ` Remaining: ${meters}.` : ''}`;
28
28
  }
29
- /** The spend meter for `tokenSymbol` on this grant, or undefined when the grant budgets no such token -
30
- * `spentToDate` is "one meter per budget, in the SAME order as policySet.budgets" (backend's own
31
- * invariant, `Delegation.spentToDate`'s doc comment), which is what makes this a plain index lookup. */
32
- export function findBudgetMeter(grant, tokenSymbol) {
33
- const idx = grant.policySet.budgets.findIndex((b) => b.token.symbol.toUpperCase() === tokenSymbol.toUpperCase());
29
+ /**
30
+ * The spend meter for `assetRef` on this grant, or undefined when the grant budgets no such asset.
31
+ * Matches on the CAIP-19 identity, never on the symbol: `AgentGuard` and `MandateExecutor` enforce a
32
+ * budget against a token ADDRESS, so a client that can only see a symbol is asking a different question
33
+ * from the one the chain will answer - two contracts on one chain can share a symbol. `spentToDate` is
34
+ * "one meter per budget, in the SAME order as policySet.budgets" (backend's own invariant,
35
+ * `Delegation.spentToDate`'s doc comment), which is what makes this a plain index lookup.
36
+ *
37
+ * Callers must supply a REAL assetRef - one that came from `GET /agents/me`'s own grant (a budgeted
38
+ * token) or from `GET /assets/resolve` (a resolved send/swap target), never a guessed or hand-built
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.
46
+ */
47
+ export function findBudgetMeter(grant, assetRef) {
48
+ const idx = grant.policySet.budgets.findIndex((b) => b.token.assetRef === assetRef);
34
49
  return idx === -1 ? undefined : grant.spentToDate[idx];
35
50
  }
36
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,IAAI,CAAC;AACnE,CAAC;AAED;;gFAEgF;AAChF,MAAM,UAAU,aAAa,CAAC,IAAe;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,cAA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ChB,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,CA4PhF"}
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"}
@@ -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
@@ -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;AA0CzC,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,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QACzC,OAAO,MAAM,CAAC,QAAQ,EAAE,0CAA0C,EAAE;YAClE;gBACE,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,UAAU;gBACpB,MAAM,EAAE,qDAAqD;gBAC7D,UAAU,EAAE,oFAAoF;aACjG;SACF,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAe,CAAC;IACpB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,OAAO,CAAC,EAAE,EAAE,CAAC;IAC5B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,gBAAgB,IAAI,CAAC,CAAC,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,EAAE,CAAC;YAC5E,OAAO,MAAM,CAAC,eAAe,EAAE,iEAAiE,EAAE;gBAChG;oBACE,IAAI,EAAE,eAAe;oBACrB,QAAQ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ClF,UAAU,EAAE,iCAAiC;SAC9C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;IACpD,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QACpD,OAAO,MAAM,CACX,kBAAkB,EAClB,6CAA6C,EAC7C;YACE,GAAG,QAAQ;YACX;gBACE,IAAI,EAAE,kBAAkB;gBACxB,QAAQ,EAAE,UAAU;gBACpB,MAAM,EAAE,iCAAiC,SAAS,GAAG;gBACrD,UAAU,EAAE,yDAAyD;aACtE;SACF,EACD,KAAK,EACL,SAAS,CACV,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CACX,UAAU,EACV,yEAAyE,EACzE,QAAQ,EACR,KAAK,EACL,SAAS,CACV,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CACX,OAAO,EACP,gBAAgB,YAAY,4BAA4B,KAAK,CAAC,KAAK,IAAI,SAAS,KAAK,CAAC,OAAO,EAAE,8BAA8B,EAC7H,EAAE,EACF,KAAK,EACL,SAAS,CACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * What a tool can say while it waits, and how it learns it should stop.
3
+ *
4
+ * WHY THIS EXISTS. `wallet_login` and `wallet_send`'s browser lane already block for up to the ten
5
+ * minutes the backend declares, and emit NOTHING while they do - so the host is free to time the call
6
+ * out, and the person watching sees a tool that produces no output for minutes. `LoginDeps.onPrompt`
7
+ * and `WalletSendDeps.onHandoff` were added for exactly this problem on the CLI side, with the note
8
+ * that "the MCP lane cannot use this (a tool result does not exist until the call returns)". That is
9
+ * true of a RETURN VALUE. It is not true of a notification.
10
+ *
11
+ * DELIBERATELY FREE OF MCP TYPES. `tools.ts` must stay drivable by fakes with no transport - which is
12
+ * the whole reason this package's test suite runs without one - so the SDK's `RequestHandlerExtra`
13
+ * appears in exactly one file, `server.ts`, which adapts it into this. The CLI implements the same
14
+ * interface over its own `notify`/`step`, so one waiting primitive serves both front ends rather than
15
+ * two that drift.
16
+ */
17
+ /** What a tool reports while it waits. Free-form text a human reads, not a status code. */
18
+ export interface ProgressReport {
19
+ message: string;
20
+ progress?: number;
21
+ total?: number;
22
+ }
23
+ /** A structured ask, mirroring MCP's `elicitation/create` without importing its types. */
24
+ export interface ElicitAsk {
25
+ message: string;
26
+ requestedSchema?: Record<string, unknown>;
27
+ }
28
+ export interface ElicitAnswer {
29
+ action: 'accept' | 'decline' | 'cancel';
30
+ content?: Record<string, unknown>;
31
+ }
32
+ export interface HitlContext {
33
+ signal: AbortSignal;
34
+ /**
35
+ * Report progress. NEVER throws - a front end whose reporting fails must not be able to turn a
36
+ * succeeded action into a tool error, for the same reason `server.ts` swallows a failed
37
+ * `sendToolListChanged`: past the relay, money has already moved.
38
+ */
39
+ progress(p: ProgressReport): void;
40
+ /** Present only when the client declared the elicitation capability. Every call site is `ctx.elicit?.(…)`. */
41
+ elicit?(ask: ElicitAsk): Promise<ElicitAnswer | null>;
42
+ }
43
+ /** A context that reports to nobody. For callers with nothing to say and for tests. */
44
+ export declare function noopHitlContext(signal?: AbortSignal): HitlContext;
45
+ export interface HitlContextSources {
46
+ signal: AbortSignal;
47
+ progressToken: string | number | undefined;
48
+ sendNotification: (n: {
49
+ method: string;
50
+ params: Record<string, unknown>;
51
+ }) => Promise<void>;
52
+ elicitationSupported: boolean;
53
+ sendRequest: (req: {
54
+ method: string;
55
+ params: Record<string, unknown>;
56
+ }) => Promise<unknown>;
57
+ }
58
+ /** Adapt the MCP request's own capabilities into a `HitlContext`. Called only from `server.ts`. */
59
+ export declare function hitlContextFrom(sources: HitlContextSources): HitlContext;
60
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/hitl/context.ts"],"names":[],"m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AA;KAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7F;AAED,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAkCxE"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * What a tool can say while it waits, and how it learns it should stop.
3
+ *
4
+ * WHY THIS EXISTS. `wallet_login` and `wallet_send`'s browser lane already block for up to the ten
5
+ * minutes the backend declares, and emit NOTHING while they do - so the host is free to time the call
6
+ * out, and the person watching sees a tool that produces no output for minutes. `LoginDeps.onPrompt`
7
+ * and `WalletSendDeps.onHandoff` were added for exactly this problem on the CLI side, with the note
8
+ * that "the MCP lane cannot use this (a tool result does not exist until the call returns)". That is
9
+ * true of a RETURN VALUE. It is not true of a notification.
10
+ *
11
+ * DELIBERATELY FREE OF MCP TYPES. `tools.ts` must stay drivable by fakes with no transport - which is
12
+ * the whole reason this package's test suite runs without one - so the SDK's `RequestHandlerExtra`
13
+ * appears in exactly one file, `server.ts`, which adapts it into this. The CLI implements the same
14
+ * interface over its own `notify`/`step`, so one waiting primitive serves both front ends rather than
15
+ * two that drift.
16
+ */
17
+ /** A context that reports to nobody. For callers with nothing to say and for tests. */
18
+ export function noopHitlContext(signal = new AbortController().signal) {
19
+ return { signal, progress: () => { } };
20
+ }
21
+ /** Adapt the MCP request's own capabilities into a `HitlContext`. Called only from `server.ts`. */
22
+ export function hitlContextFrom(sources) {
23
+ const ctx = {
24
+ signal: sources.signal,
25
+ progress: (p) => {
26
+ if (sources.progressToken === undefined)
27
+ return;
28
+ // Fire and forget, and defensively swallowed - see HitlContext.progress's own comment.
29
+ void sources
30
+ .sendNotification({
31
+ method: 'notifications/progress',
32
+ params: {
33
+ progressToken: sources.progressToken,
34
+ message: p.message,
35
+ ...(p.progress === undefined ? {} : { progress: p.progress }),
36
+ ...(p.total === undefined ? {} : { total: p.total }),
37
+ },
38
+ })
39
+ .catch(() => { });
40
+ },
41
+ };
42
+ if (sources.elicitationSupported) {
43
+ ctx.elicit = async (ask) => {
44
+ try {
45
+ const res = (await sources.sendRequest({
46
+ method: 'elicitation/create',
47
+ params: { message: ask.message, ...(ask.requestedSchema ? { requestedSchema: ask.requestedSchema } : {}) },
48
+ }));
49
+ return res ?? null;
50
+ }
51
+ catch {
52
+ // An elicitation that fails is a client that could not ask - never a reason to fail the action.
53
+ return null;
54
+ }
55
+ };
56
+ }
57
+ return ctx;
58
+ }
59
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/hitl/context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAgCH,uFAAuF;AACvF,MAAM,UAAU,eAAe,CAAC,SAAsB,IAAI,eAAe,EAAE,CAAC,MAAM;IAChF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC;AACxC,CAAC;AAUD,mGAAmG;AACnG,MAAM,UAAU,eAAe,CAAC,OAA2B;IACzD,MAAM,GAAG,GAAgB;QACvB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;YACd,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS;gBAAE,OAAO;YAChD,uFAAuF;YACvF,KAAK,OAAO;iBACT,gBAAgB,CAAC;gBAChB,MAAM,EAAE,wBAAwB;gBAChC,MAAM,EAAE;oBACN,aAAa,EAAE,OAAO,CAAC,aAAa;oBACpC,OAAO,EAAE,CAAC,CAAC,OAAO;oBAClB,GAAG,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;oBAC7D,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,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