@keyban/cli 0.1.2 → 0.2.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 CHANGED
@@ -115,6 +115,9 @@ Read-only:
115
115
  | `wait_for_intent` | Wait for approval decisions |
116
116
  | `x402_info` | Inspect the x402 price of a URL |
117
117
  | `discover_x402_services` | Search the x402 service directory |
118
+ | `list_missions`, `get_mission` | Read the missions and their statistics |
119
+ | `list_mission_runs`, `get_mission_run` | Read this wallet's mission runs |
120
+ | `publish_mission` | Check a draft can be published and show the page to publish it |
118
121
 
119
122
  Writing:
120
123
 
@@ -124,6 +127,9 @@ Writing:
124
127
  | `cancel_intent` | Cancel a pending payment intent |
125
128
  | `transfer_usdc` | Transfer USDC — moves funds |
126
129
  | `x402_pay` | Pay for an x402 resource — moves funds |
130
+ | `create_mission`, `update_mission`, `discard_mission_draft` | Draft a mission on this wallet |
131
+ | `request_mission_trial` | Ask a trial of the draft, validated by a human |
132
+ | `start_mission_run`, `log_mission_progress`, `complete_mission_run`, `abandon_mission_run` | Run a mission |
127
133
 
128
134
  Every tool carries a `title` and the applicable `readOnlyHint` or
129
135
  `destructiveHint`, so a client can tell the two groups apart before calling
@@ -134,10 +140,34 @@ anything.
134
140
  Transfers and x402 payments are checked against the wallet's policy on the
135
141
  Keyban side. A call the policy will not clear on its own does not fail
136
142
  silently: it comes back naming a payment intent that needs a human decision.
137
- `wait_for_intent` blocks until the owner approves or declines, and the agent
143
+ The answer carries the link to approve it and the next steps;
144
+ `wait_for_intent` blocks until a wallet operator approves or declines, and the agent
138
145
  retries once it is approved. The policy lives with the wallet, not with this
139
146
  process, so editing this server's configuration cannot widen it.
140
147
 
148
+ In clients that render MCP apps (Claude, Claude Desktop, ChatGPT…),
149
+ `x402_pay` and `transfer_usdc` show a card and wait for the decision in the
150
+ same call: the amount, who it pays, a countdown to the deadline, a button that
151
+ opens the payment in the Keyban dashboard and one that withdraws the request.
152
+ Once approved, the call signs and settles, and the card turns into a receipt.
153
+ The card follows the payment through `await_payment_approval` and
154
+ `watch_payment_approval`, tools only it can call. It approves nothing:
155
+ approval needs the user's own Keyban session.
156
+
157
+ The mission tools come from the Keyban API description (`/openapi.json`, kept
158
+ in the user's cache), called with the wallet's key on its own wallet.
159
+ `request_mission_trial`, an on-demand `start_mission_run` and
160
+ `publish_mission` show a mission card: what is asked, a button that opens the
161
+ trial, the run or the mission page in the dashboard, and its status until a
162
+ human decides, through `watch_mission_approval`. Validating and publishing
163
+ stay the user's, in the dashboard.
164
+
165
+ In clients that declare URL elicitation but render no MCP apps (Claude Code),
166
+ the held payment asks the client to open the approval page instead: the client
167
+ shows the user the URL, opens it in the browser once they agree, and the call
168
+ waits for the decision just as with the card. A client that does neither gets
169
+ the link and the steps in the answer.
170
+
141
171
  ## Trust boundary
142
172
 
143
173
  The share and the API key are protected by your user account, nothing finer.
package/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: keyban-agent-wallet
3
- description: Operate a Keyban Agent Wallet, an AI agent's own USDC wallet whose spending policy is enforced server-side, through the local agent wallet MCP. Use when the user wants an agent to pay x402 APIs, transfer USDC, check its balance or spending, or when a payment waits for a human or is refused by the policy. Creating and configuring the wallet is the keyban-admin skill.
3
+ description: Operate a Keyban Agent Wallet, an AI agent's own USDC wallet whose spending policy is enforced server-side, through the local agent wallet MCP. Use when the user wants an agent to pay x402 APIs, transfer USDC, check its balance or spending, or when a payment waits for a human or is refused by the policy, or to draft and run a mission. Creating and configuring the wallet is the keyban-admin skill.
4
4
  ---
5
5
 
6
6
  # Keyban Agent Wallet
@@ -19,7 +19,7 @@ Keyban, and neither side can sign alone.
19
19
  | Acts as | the signed-in user (OAuth) | the agent, through one wallet |
20
20
  | Runs | remote, `https://mcp.keyban.io/mcp` | local, `npx -y @keyban/cli@latest mcp` |
21
21
  | Default server name | `keyban` | `agent-wallet` |
22
- | Does | organization, applications, agent wallets, destination rules, x402 catalogue, quotas, billing | balance, spending, USDC transfers, x402 payments, approval waits |
22
+ | Does | organization, applications, agent wallets, destination rules, x402 catalogue, quotas, billing | balance, spending, USDC transfers, x402 payments, approval waits, missions |
23
23
  | Does not | spend, install the wallet's signer, approve payments, edit an existing wallet's spending caps | create or configure wallets, approve its own payments |
24
24
  | Guide | `keyban:get_instructions`, the `keyban-admin` skill | `agent-wallet:get_instructions`, this skill |
25
25
 
@@ -48,19 +48,40 @@ API key and a one-shot invite key.
48
48
 
49
49
  ## Fund the wallet — human
50
50
 
51
- Not needed for a payment the Keyban welcome offer covers (see below).
51
+ Not needed for a payment the Keyban welcome offer covers (see below), nor on a
52
+ prepaid account (see below).
52
53
 
53
54
  USDC on the wallet's network, sent to the address from
54
55
  `agent-wallet:get_account_info`. The wallet page in the dashboard also offers a
55
56
  card top-up (Base mainnet only, 5 to 999 EUR per purchase) and a top-up request
56
57
  to a teammate. Test USDC: https://faucet.circle.com/
57
58
 
59
+ ## Prepaid account
60
+
61
+ Only when `agent-wallet:get_account_info` starts with `Account: prepaid`;
62
+ otherwise skip this section. A prepaid account has no wallet of its own: no
63
+ address and no key share on this machine for you to handle. It does have a
64
+ network, the one Keyban pays on, shown by `agent-wallet:get_account_info`.
65
+ Keyban pays the seller of each x402 payment and debits the prepaid credit of the
66
+ organization, shared by all its prepaid accounts.
67
+
68
+ - The balance is that credit, in euros: `agent-wallet:balance` reports it. A
69
+ welcome credit offered by Keyban to a new organization is part of it, and
70
+ `agent-wallet:balance` shows what is left of it.
71
+ - Pay with `agent-wallet:x402_pay`. `agent-wallet:transfer_usdc` and
72
+ `agent-wallet:sign_message` are not offered: there is nothing to sign or send
73
+ from an address.
74
+ - The mission tools are not offered either: missions do not run on a prepaid
75
+ account yet.
76
+ - "Fund the wallet" does not apply. When the credit runs out, the payment is
77
+ refused with `policy/prepaid-balance-insufficient` (see the table below).
78
+
58
79
  ## Operate the wallet
59
80
 
60
81
  - Read: `agent-wallet:balance` (report the fiat value first),
61
82
  `agent-wallet:expense_stats`, `agent-wallet:list_expense_transactions`.
62
- - A new organization's first payments may be covered by the Keyban welcome
63
- offer, shown by `agent-wallet:balance` and `agent-wallet:get_account_info`.
83
+ - On a wallet, a new organization's first payments may be covered by the Keyban
84
+ welcome offer, shown by `agent-wallet:balance` and `agent-wallet:get_account_info`.
64
85
  On first use, report it with the balance, and do not say the wallet needs
65
86
  funding while the offer has an amount left that covers the payment. The
66
87
  offer pays a payment only when its whole price fits in what is left, so a
@@ -83,25 +104,168 @@ to a teammate. Test USDC: https://faucet.circle.com/
83
104
 
84
105
  A service listed "via" a gateway (e.g. Orthogonal) is paid the same way: the
85
106
  gateway collects the payment and calls the provider for you.
86
- - Send USDC: `agent-wallet:transfer_usdc`, amount in USDC (`"1.5"`), not in
87
- base units.
107
+ - Send USDC (a wallet only, not a prepaid account): `agent-wallet:transfer_usdc`,
108
+ amount in USDC (`"1.5"`), not in base units.
88
109
 
89
110
  The policy is the user's authorization: do not ask the user to confirm a payment
90
111
  the policy allows.
91
112
 
92
113
  ## When a human must approve
93
114
 
94
- A payment above the approval threshold is held, and the tool fails with an
95
- `intentId`.
115
+ A payment above the approval threshold is held for the wallet's operators.
116
+ The answer is not an error: it gives the `intentId`, the link to approve it
117
+ and what to do next. Follow it.
118
+
119
+ - In clients that show MCP apps, or that can open the approval page for the
120
+ user (URL elicitation), `x402_pay` and `transfer_usdc` wait for the decision
121
+ themselves while an operator approves, then go on. If one comes back still
122
+ waiting, call it again as the answer says.
123
+ - Elsewhere, in one message, tell the user the amount, the recipient, the
124
+ deadline and the link, and call `agent-wallet:wait_for_intent`; call it
125
+ again each time it comes back still waiting. A decision taken before the
126
+ call shows in `recentlyDecided`. Once approved, retry the same call with
127
+ that `intentId` (a transfer: the same recipient and amount).
128
+
129
+ The wallet's operators are notified and decide from the dashboard; approval
130
+ needs their own session: no tool can approve. Never start a new payment for
131
+ the same purchase: it creates a second intent. To withdraw a pending request,
132
+ call `agent-wallet:cancel_intent`.
133
+
134
+ ## Missions
135
+
136
+ A mission is the budget and the brief an agent gets for one task: what to do,
137
+ how much per run, where the money may go, for how long, who may run it and how.
138
+ You write it as a draft and try it; a human validates the trial and an operator
139
+ publishes it; then it runs as many times as needed, by one wallet or by many.
140
+ Every mission tool acts on this server's own wallet: never pass a wallet id.
141
+ On a prepaid account there are no mission tools: skip this section.
142
+
143
+ Missions are open to pilot organizations only. Elsewhere every mission tool
144
+ answers `AGENT_WALLET_MISSIONS_DISABLED` (403): it is not a bug and the request
145
+ is valid, so do not retry it. Tell the user missions are not enabled for their
146
+ organization yet, and that Keyban can enable them.
147
+
148
+ ### When to propose one
149
+
150
+ When the user asks an agent to do something repeatable that costs money (enrich
151
+ leads, fetch pages, run a nightly job), or when a wallet already pays the same
152
+ services over and over. Do not invent a task: read what the wallet really paid
153
+ (`agent-wallet:list_expense_transactions`, the x402 services it called) and the
154
+ missions that already exist (`agent-wallet:list_missions`,
155
+ `agent-wallet:get_mission`) first. If one fits, run it; if one nearly fits,
156
+ `agent-wallet:update_mission` opens a draft of the next version. Otherwise
157
+ create one that names, budgets and scopes what the agent already does.
158
+
159
+ ### Write the brief
160
+
161
+ `brief` is what the agent reads at the start of every run, so write it for an
162
+ agent: the goal in one sentence, the inputs it gets, the steps, what a finished
163
+ unit looks like, what to do when a service fails, when to stop. Say which
164
+ services to use and which never to use. Markdown, at most 8000 characters. A
165
+ good brief can be followed by an agent that has no other context. `title` is the
166
+ short name; `key` is the stable kebab-case identifier (`lead-enrichment`).
96
167
 
97
- 1. Tell the user the amount, the recipient and the deadline, with the link
98
- `https://admin.keyban.io/app/<applicationId>/inbox?intent=<intentId>`.
99
- Approval needs the user's own session: no tool can approve.
100
- 2. In the same turn, call `agent-wallet:wait_for_intent`, and call it again
101
- each time it comes back still waiting, until the intent is decided or expires.
102
- 3. Once approved, retry the same call with that `intentId`. Never start a new
103
- payment for the same purchase: it creates a second intent.
104
- 4. To withdraw a pending request, call `agent-wallet:cancel_intent`.
168
+ ### Fields
169
+
170
+ `agent-wallet:create_mission` describes its own fields. What it cannot say:
171
+
172
+ - Ask the user for every amount: never pick one yourself. Amounts are integer
173
+ strings in the smallest unit of the organization's currency (`"3000"` is
174
+ 30.00 EUR).
175
+ - The target price per unit is a hint, not a guarantee: say « envelope 30 EUR
176
+ (100 leads at a 0.30 EUR target) », never « at most 0.30 EUR per lead ».
177
+ - Propose a total budget whenever the mission will run on many wallets or many
178
+ times: each run reserves its whole envelope while it lasts, so the total
179
+ budget also bounds how many runs can overlap.
180
+ - `maxPaymentRef`, `exemptFromWalletBudgets` and `maxActiveRunsPerWallet` only
181
+ when the task needs them. Say plainly what each one lifts: the user will see
182
+ it flagged.
183
+ - Write each endpoint `METHOD host/path`, for example `POST api.exa.ai/search`,
184
+ with a plain path: no query string, no percent-encoding, no `.` or `..`
185
+ segment. The server refuses with `MISSION_ENDPOINT_INVALID` what it cannot
186
+ read unambiguously.
187
+
188
+ ### Try, then publish
189
+
190
+ 1. `agent-wallet:create_mission` (or `agent-wallet:update_mission` to change the
191
+ open draft, or to open a draft of the next version from a published one).
192
+ Any change voids the trials already done.
193
+ 2. `agent-wallet:request_mission_trial`: asks a trial of the draft on this
194
+ wallet. A card shows it to the user; tell them to validate it in the Inbox
195
+ of the dashboard (an operator of the wallet; the organization's finance
196
+ owner too when the draft loosens application or organization rules). It
197
+ returns a run id. If the finance owner declines what the draft loosens, the
198
+ trial is declined with it: change the draft and ask a new trial.
199
+ 3. Once validated (`agent-wallet:get_mission_run` says `active`), play the
200
+ trial like a run: pay passing the run id as `missionRunId`, record
201
+ progress, then `agent-wallet:complete_mission_run`. The trial uses real
202
+ money, inside the draft envelope, and does not count in the mission's total
203
+ budget.
204
+ 4. `agent-wallet:publish_mission` checks the draft can be published and shows
205
+ the user a card with the page where they publish it. It does not publish:
206
+ the user does, in the dashboard, as an operator of the wallet. You cannot
207
+ publish, approve or decline: no tool does it. A refusal says what is
208
+ missing (a completed trial of the current content, the finance owner's
209
+ approval of what the draft loosens). To drop a draft,
210
+ `agent-wallet:discard_mission_draft`.
211
+
212
+ While a draft v2 is being tuned, the published v1 keeps running.
213
+
214
+ ### Run it
215
+
216
+ 1. `agent-wallet:start_mission_run` with the mission; optionally `units` (unit
217
+ tokens such as ids) or `unitCount`, within the mission's count. It returns
218
+ a run id: `active` at once, or `pending_approval` in `on_demand` mode, then
219
+ a card shows it to the user: tell them to approve it in the Inbox, and
220
+ check with `agent-wallet:get_mission_run` that it is `active` before
221
+ paying.
222
+ 2. Pay passing the run id as `missionRunId` on `agent-wallet:x402_pay` and
223
+ `agent-wallet:transfer_usdc` (`--mission-run-id <id>` on the command line).
224
+ The run is the budget a human validated for the task: each payment counts
225
+ against the run's envelope and, when the mission has one, its total budget.
226
+ Inside a trial and an on-demand run the approval threshold is lifted;
227
+ inside an automatic or frequency run it still applies, and a payment above
228
+ it waits for an operator. Do not attach a payment to a run it does not
229
+ serve: the server cannot tell, so the user relies on you for the right run.
230
+ Without a run id a payment is evaluated under the wallet policy alone,
231
+ unless the policy requires a mission (`policy/mission-required`).
232
+ 3. Record progress with `agent-wallet:log_mission_progress` (`unitsDone`,
233
+ idempotent, or `unitsDoneCount`, and a `note`).
234
+ `agent-wallet:get_mission_run` returns what is spent and left and the units
235
+ remaining: after an interruption, read it and continue from the remaining
236
+ units.
237
+ 4. `agent-wallet:complete_mission_run` when done.
238
+ `agent-wallet:abandon_mission_run` withdraws a run still waiting for
239
+ approval.
240
+
241
+ Refusals of `agent-wallet:start_mission_run`:
242
+
243
+ - `MISSION_RUN_FREQUENCY_REACHED` (409): the wallet already started as many
244
+ runs as the mission allows in the current period. `params.retryAt` (ISO 8601,
245
+ UTC) is when it may start again. Do not retry before; tell the user when.
246
+ - `MISSION_RUN_LIMIT_REACHED` (409): the wallet already has the maximum of
247
+ active runs of this mission; finish or abandon one.
248
+ - `MISSION_TOTAL_BUDGET_EXHAUSTED` (409): the mission's total budget cannot
249
+ cover this run; tell the user, do not split the work to get around it.
250
+ - `MISSION_NOT_PUBLISHED` (409): nothing is published yet (ask a trial) or the
251
+ mission is archived.
252
+ - `MISSION_RUN_WALLET_OUT_OF_SCOPE` (403): this wallet is outside the mission's
253
+ sharing.
254
+ - `MISSION_RUN_OUT_OF_MISSION` (422): units, unit price or count fall outside
255
+ the mission, or the wallet's currency differs.
256
+
257
+ A run that no longer fits cannot be edited: start another one. A run that goes
258
+ over its envelope, the mission's total budget, its destinations or its deadline
259
+ is refused with a `policy/…` reason (below). A payment above the wallet's
260
+ approval threshold in an `auto` or `frequency` run waits for an operator in the
261
+ Inbox, who may allow it for the next runs of the mission. Stopping an active
262
+ run is a human decision, in the dashboard.
263
+
264
+ `agent-wallet:list_missions` and `agent-wallet:get_mission` return the
265
+ statistics (runs by status, total spent, what is left of the total budget,
266
+ observed price per unit next to the target) and the limits currently blocking a
267
+ start, with their `retryAt`. `agent-wallet:list_mission_runs` and
268
+ `agent-wallet:get_mission_run` read the runs of this wallet.
105
269
 
106
270
  ## When the policy refuses
107
271
 
@@ -113,12 +277,24 @@ that payment.
113
277
  | `policy/amount-exceeded` | above the per-payment cap | raise the cap on the wallet page |
114
278
  | `policy/budget-day-exceeded`, `-week-`, `-month-` | the period's budget is used | wait, or raise the budget on the wallet page |
115
279
  | `policy/recipient-…`, `policy/domain-…` | destination not allowed at some scope | change a destination rule, through the admin MCP only if the user asks |
280
+ | `policy/mission-required` | this wallet only pays inside a mission run, and the payment named none | pay inside a run of the mission this task belongs to: start one with `agent-wallet:start_mission_run` if none is active, or ask the user which mission it is; never start a run of an unrelated mission to get the payment through; do not retry without a run |
281
+ | `policy/mission-run-not-found` | the run id is unknown, belongs to another wallet, or missions are not available | check the id with `agent-wallet:list_mission_runs`; do not guess another |
282
+ | `policy/mission-run-not-active: <status>` | the run is not active: `pending_approval` (an operator has not approved it yet), `declined`, `abandoned`, `cancelled` or `completed` | tell the user the status; wait for approval or start a new run (Missions, above); never reuse an ended run |
283
+ | `policy/mission-run-not-active: expired` | the run passed its deadline | start a new run if the task continues |
284
+ | `policy/mission-run-not-active: currency_mismatch` | the wallet's policy currency changed after the run started, so the envelope no longer matches | do not retry; the user must recreate the mission in the new currency and start a new run |
285
+ | `policy/envelope-exceeded: … (<key>)` | the payment would take the spent total above a cap: the key is the run's id when it is the run's envelope, the mission's id when it is the mission's total budget (shared by every run and wallet of the mission) | report which one; finish or abandon the run, or ask the user for a mission with a larger envelope (run) or total budget (mission); never split the payment |
286
+ | `policy/domain-mission-not-allowed: <METHOD host/path>` (x402), `policy/recipient-mission-not-allowed` (transfer) | the destination is not in the mission's own list; for x402 the whole `METHOD host/path` is compared | pick a service the mission names, with the method and path it names; to add one, update the mission with `agent-wallet:update_mission`, play a trial, and the user publishes the new version |
116
287
  | `policy/intent-in-flight` | an earlier transfer is still pending | wait for it, or cancel it with `agent-wallet:cancel_intent` |
117
288
  | `policy/emergency-stop` | the wallet is paused | resume it on the wallet page |
118
289
  | `policy/transaction-quota-reached` | the organization's monthly transaction quota (its plan) is used up — for every wallet of the organization, until the 1st of next month (UTC) | do not retry; ask an organization admin to upgrade the plan or allow billed overage in Billing → Usage |
119
290
  | `policy/missing` | the wallet has no policy (403 at signing) | ask the user to open the wallet page; do not retry |
120
291
  | `policy/x402-no-exact-accept` | the seller only offers an x402 payment scheme the wallet cannot settle yet (e.g. `upto`) — a current limit of the wallet, not a budget problem | do not retry; pick another provider and tell the user |
121
- | `policy/x402-…` | the seller's x402 offer cannot be paid (unreachable, malformed, wrong asset or chain, above `maxAmount`) | pick another provider |
292
+ | `policy/x402-…` | the seller's x402 offer cannot be paid (unreachable, malformed, invalid recipient, wrong asset or chain, above `maxAmount`) | pick another provider |
293
+ | `policy/prepaid-balance-insufficient` | the prepaid credit of the organization does not cover the payment | tell the user an admin must buy a pack in Billing → Prepaid credit; never retry or split the payment |
294
+ | `policy/prepaid-payer-unavailable`, `policy/prepaid-suspended` | Keyban cannot pay prepaid payments for now | report it; do not retry |
295
+
296
+ A destination refused with `mission` as scope is the mission's list; with
297
+ `wallet`, `application` or `organization`, it is that rule.
122
298
 
123
299
  Never split a payment into smaller ones to stay under a cap or the approval
124
300
  threshold, and never route a payment around a destination rule.
@@ -133,8 +309,21 @@ threshold, and never route a payment around a destination rule.
133
309
  - Running the agent wallet MCP on Amazon Bedrock AgentCore: see the package
134
310
  README.
135
311
  - The signer's share or API key may have leaked: any program running as the
136
- user can read them. Rotate with the admin MCP: add a new signer, set it up,
137
- then delete the old one; that revokes both, and the address stays.
312
+ user can read them. On a wallet, rotate with the admin MCP: add a new signer,
313
+ set it up, then delete the old one; that revokes both, and the address stays.
314
+ A prepaid account has no signer to rotate: ask the user to have an admin
315
+ pause the account at once, then delete it and create a new one, with a new
316
+ MCP configuration.
317
+ - A payment fails with `FUNDING_SIGNED_BY_SERVER`: this agent wallet MCP is too
318
+ old to pay it. Ask the user to update it.
319
+ - A payment fails with `FUNDING_UNAVAILABLE`: `agent-wallet:x402_pay` already
320
+ evaluated it again once. Tell the user Keyban cannot pay this payment for
321
+ now; do not retry.
322
+ - A call fails with `FUNDING_NO_CLIENT_SIGNER`: the account is prepaid, so
323
+ Keyban signs its payments and no key share lives on this machine: no DKG, no
324
+ `agent-wallet:transfer_usdc`, no `agent-wallet:sign_message`. Pay with
325
+ `agent-wallet:x402_pay`; if it fails with this code too, this agent wallet
326
+ MCP is too old: ask the user to update it.
138
327
 
139
328
  ## Links
140
329