@keyban/cli 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +137 -65
- package/dist/index.mjs +891 -377
- package/dist/index.mjs.map +4 -4
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -121,8 +121,8 @@ and what to do next. Follow it.
|
|
|
121
121
|
themselves while an operator approves, then go on. If one comes back still
|
|
122
122
|
waiting, call it again as the answer says.
|
|
123
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
|
|
125
|
-
again each time it comes back still waiting. A decision taken before the
|
|
124
|
+
deadline and the link, and call `agent-wallet:wait_for_intent` (it waits at
|
|
125
|
+
most 45 s); call it again each time it comes back still waiting. A decision taken before the
|
|
126
126
|
call shows in `recentlyDecided`. Once approved, retry the same call with
|
|
127
127
|
that `intentId` (a transfer: the same recipient and amount).
|
|
128
128
|
|
|
@@ -134,7 +134,7 @@ call `agent-wallet:cancel_intent`.
|
|
|
134
134
|
## Missions
|
|
135
135
|
|
|
136
136
|
A mission is the budget and the brief an agent gets for one task: what to do,
|
|
137
|
-
|
|
137
|
+
which services may be paid and how often, how much per run, who may run it and how.
|
|
138
138
|
You write it as a draft and try it; a human validates the trial and an operator
|
|
139
139
|
publishes it; then it runs as many times as needed, by one wallet or by many.
|
|
140
140
|
Every mission tool acts on this server's own wallet: never pass a wallet id.
|
|
@@ -167,74 +167,148 @@ short name; `key` is the stable kebab-case identifier (`lead-enrichment`).
|
|
|
167
167
|
|
|
168
168
|
### Fields
|
|
169
169
|
|
|
170
|
-
`agent-wallet:create_mission` describes its own fields.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
`agent-wallet:create_mission` describes its own fields. Go in this order:
|
|
171
|
+
|
|
172
|
+
1. Understand the task, and check the wallet balance
|
|
173
|
+
(`agent-wallet:balance`) first: a mission the wallet cannot fund is
|
|
174
|
+
useless.
|
|
175
|
+
2. Create the draft right away with the `sources` you propose: for each, the
|
|
176
|
+
endpoint, what you expect from it, the calls planned per unit (per run when
|
|
177
|
+
the task has no unit) and the price of one call, read in the x402
|
|
178
|
+
catalogue. That plan is an estimate, never a limit: the sources are the
|
|
179
|
+
services the mission allows. The draft shows no card: the user corrects it
|
|
180
|
+
in chat, and you apply the corrections with `agent-wallet:update_mission`.
|
|
181
|
+
Do not ask for the list beforehand. For a change to an existing mission,
|
|
182
|
+
the same rule: `agent-wallet:update_mission` opens the next version right
|
|
183
|
+
away; do not ask before, do not propose in text.
|
|
184
|
+
3. Propose the price per unit yourself, in the draft: the cost of one unit
|
|
185
|
+
(the sum of the sources' calls × price) plus a margin. The envelope of a
|
|
186
|
+
run is that price × the units of the mission, and it is the only limit on
|
|
187
|
+
spend. There is no cap over all the runs of a mission. Do not ask the user
|
|
188
|
+
for amounts: they correct the ones on the trial card.
|
|
189
|
+
4. Leave the rest at its defaults (duration 1 day, no limit on simultaneous
|
|
190
|
+
runs): do not ask.
|
|
191
|
+
5. On a task with units, `unitCount` is an estimate used for the envelope, not
|
|
192
|
+
a limit: a run may handle more or fewer units. A trial plays a small sample
|
|
193
|
+
of units, not a whole run: when you ask it, pass `unitCount`, the sample, a
|
|
194
|
+
few units; you may propose its size to the user.
|
|
195
|
+
|
|
196
|
+
Amounts are integer strings in cents of the organization's currency, never
|
|
197
|
+
decimals: 0.05 EUR is `"5"`, 30.00 EUR is `"3000"`. A decimal is refused with a
|
|
198
|
+
400. One exception: the price of one call of a source (`callPriceRef`) takes up
|
|
199
|
+
to 3 decimals of a cent, as an x402 call often costs less than one: 0.003 EUR is
|
|
200
|
+
`"0.3"`. Prices of the sources are in the mission's currency.
|
|
201
|
+
|
|
202
|
+
- Each source is `METHOD host/path`, for example `POST api.exa.ai/search`, with
|
|
203
|
+
a plain path: no query string, no percent-encoding, no `.` or `..` segment;
|
|
204
|
+
one source per endpoint. The server refuses with `MISSION_ENDPOINT_INVALID`
|
|
205
|
+
what it cannot read unambiguously.
|
|
206
|
+
- The plan is your honest estimate: the calls one unit needs and the price of
|
|
207
|
+
one call read in the catalogue. Put the margin in the unit price, not in the
|
|
208
|
+
plan.
|
|
175
209
|
- 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.
|
|
210
|
+
`"3000"` (100 leads at a 0.30 EUR target) », never « at most 0.30 EUR per lead ».
|
|
180
211
|
- `maxPaymentRef`, `exemptFromWalletBudgets` and `maxActiveRunsPerWallet` only
|
|
181
212
|
when the task needs them. Say plainly what each one lifts: the user will see
|
|
182
213
|
it flagged.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
214
|
+
|
|
215
|
+
### Around a card
|
|
216
|
+
|
|
217
|
+
Several tools show a card to the user. Write at most one sentence before it,
|
|
218
|
+
which does not repeat what it shows, and nothing after it: the card is the call
|
|
219
|
+
to action and ends the message. In French, say « essai », never « trial ».
|
|
187
220
|
|
|
188
221
|
### Try, then publish
|
|
189
222
|
|
|
190
223
|
1. `agent-wallet:create_mission` (or `agent-wallet:update_mission` to change the
|
|
191
224
|
open draft, or to open a draft of the next version from a published one).
|
|
192
225
|
Any change voids the trials already done.
|
|
193
|
-
2. `agent-wallet:request_mission_trial
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
226
|
+
2. `agent-wallet:request_mission_trial`, right after the draft call, without
|
|
227
|
+
asking the user in the chat first: the only approval is the user's
|
|
228
|
+
« Validate in Keyban ». It asks a trial of the draft on this wallet; on a
|
|
229
|
+
task with units, pass `unitCount`, the sample (a few units). It returns at
|
|
230
|
+
once with a card, which the user validates in the Inbox of the dashboard
|
|
231
|
+
(an operator of the wallet; the organization's finance owner too when the
|
|
232
|
+
draft loosens application or organization rules). Then call
|
|
233
|
+
`agent-wallet:wait_for_mission_run` with the `runId`, again and again while
|
|
234
|
+
it says the decision is pending: do not ask the user to tell you. If the
|
|
235
|
+
finance owner declines what the draft loosens, the trial is declined with
|
|
236
|
+
it: change the draft and ask a new trial. The card then follows the run:
|
|
237
|
+
the user sees the payments as they happen, so write nothing in between.
|
|
238
|
+
3. Once the trial is active, play it like a run without asking again (the
|
|
239
|
+
validation is the go-ahead): pay with the `*_in_mission` tools (below),
|
|
240
|
+
record progress, deliver the work result, then
|
|
241
|
+
`agent-wallet:complete_mission_run`. The trial uses real money, inside the
|
|
242
|
+
trial's envelope (sample size × unit price). It must make at least one
|
|
243
|
+
payment, or the draft cannot be published: ask a new trial that pays.
|
|
244
|
+
4. After a successful trial the end-of-run card carries « Publish mission in
|
|
245
|
+
Keyban »: do not call `agent-wallet:publish_mission` then. The user
|
|
246
|
+
publishes in the dashboard, as an operator of the wallet; you cannot
|
|
247
|
+
publish, approve or decline. `agent-wallet:publish_mission` stays for
|
|
248
|
+
publishing later: it checks the draft can be published and shows a card
|
|
249
|
+
with the page. A refusal says what is missing (a completed trial of the
|
|
250
|
+
current content, a trial that paid, the finance owner's approval of what
|
|
251
|
+
the draft loosens). Publication may lower the unit price and the envelope
|
|
252
|
+
to the cost the trial observed: do not adjust them yourself.
|
|
253
|
+
To drop a draft, `agent-wallet:discard_mission_draft`.
|
|
211
254
|
|
|
212
255
|
While a draft v2 is being tuned, the published v1 keeps running.
|
|
213
256
|
|
|
257
|
+
### Optimize an existing mission
|
|
258
|
+
|
|
259
|
+
When the user wants a mission to cost less, or to use other sources:
|
|
260
|
+
|
|
261
|
+
1. Read the mission (`agent-wallet:get_mission`) and the `versionStats` entry
|
|
262
|
+
of its published version: `bySource` says which source costs what, in amount
|
|
263
|
+
and in share (`shareBps`). Tell the user which source weighs what; a
|
|
264
|
+
`basis` of `trial` means the version only ran as trials.
|
|
265
|
+
2. Look for an alternative (`agent-wallet:discover_x402_services`,
|
|
266
|
+
`agent-wallet:x402_info`): the price of one call, read in the catalogue or
|
|
267
|
+
from the seller.
|
|
268
|
+
3. Open the draft right away with `agent-wallet:update_mission`, without asking
|
|
269
|
+
for agreement and without asking about amounts: the draft is the proposal,
|
|
270
|
+
the user corrects it in chat. The « create right away » rule holds for a
|
|
271
|
+
change as for a creation.
|
|
272
|
+
4. Ask the trial right away, wait for the decision, execute, deliver the result,
|
|
273
|
+
then `agent-wallet:complete_mission_run` last: its card compares the unit
|
|
274
|
+
cost of the run with the published version. Write nothing after it.
|
|
275
|
+
5. A trial that paid nothing proves nothing: say so in one sentence before the
|
|
276
|
+
end-of-run card.
|
|
277
|
+
|
|
214
278
|
### Run it
|
|
215
279
|
|
|
280
|
+
A mission may have several runs active at once, started by other
|
|
281
|
+
conversations or other agents. Only touch the runs you started in this
|
|
282
|
+
conversation: never log progress on, complete or abandon another one (its work
|
|
283
|
+
and its results are elsewhere). Start your own run and leave the others alone.
|
|
284
|
+
|
|
216
285
|
1. `agent-wallet:start_mission_run` with the mission; optionally `units` (unit
|
|
217
|
-
tokens such as ids) or `unitCount
|
|
218
|
-
a run id: `active
|
|
219
|
-
a card shows it to the user
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
286
|
+
tokens such as ids) or `unitCount`; it may exceed the mission's estimate.
|
|
287
|
+
It returns at once with a run id: `active`, or `pending_approval` in
|
|
288
|
+
`on_demand` mode, then a card shows it to the user, who approves it in the
|
|
289
|
+
Inbox. Call `agent-wallet:wait_for_mission_run` with the `runId` until the
|
|
290
|
+
decision: do not ask the user to tell you. Once active, execute without
|
|
291
|
+
asking again.
|
|
292
|
+
2. Pay with `agent-wallet:x402_pay_in_mission` and
|
|
293
|
+
`agent-wallet:transfer_usdc_in_mission`, passing the run id as `missionRunId`
|
|
294
|
+
(required). `agent-wallet:x402_pay` and `agent-wallet:transfer_usdc` refuse a
|
|
295
|
+
`missionRunId`. The run is the budget a human validated for the task: each
|
|
296
|
+
payment counts against the run's envelope. Inside a trial and an on-demand
|
|
297
|
+
run the approval threshold is lifted; inside an automatic or frequency run it
|
|
298
|
+
still applies, and a payment above it waits for an operator: the tool then
|
|
299
|
+
returns the approval link in text. Do not attach a payment to a run it does
|
|
300
|
+
not serve: the server cannot tell, so the user relies on you for the right
|
|
301
|
+
run. These tools show no card. From the command line the same calls are
|
|
302
|
+
`keyban wallet x402-pay-in-mission` and `keyban wallet transfer-usdc-in-mission`,
|
|
303
|
+
with `--mission-run-id <runId>`. Without a run id a payment is evaluated
|
|
304
|
+
under the wallet policy alone, unless the policy requires a mission
|
|
305
|
+
(`policy/mission-required`).
|
|
232
306
|
3. Record progress with `agent-wallet:log_mission_progress` (`unitsDone`,
|
|
233
|
-
idempotent, or `unitsDoneCount`, and a `note`).
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
307
|
+
idempotent, or `unitsDoneCount`, and a `note`). `agent-wallet:get_mission_run`
|
|
308
|
+
returns what is spent and left and the units remaining: after an
|
|
309
|
+
interruption, read it and continue from the remaining units.
|
|
310
|
+
4. When done, deliver the work result first, then call
|
|
311
|
+
`agent-wallet:complete_mission_run`: its card ends the message.
|
|
238
312
|
`agent-wallet:abandon_mission_run` withdraws a run still waiting for
|
|
239
313
|
approval.
|
|
240
314
|
|
|
@@ -243,26 +317,24 @@ Refusals of `agent-wallet:start_mission_run`:
|
|
|
243
317
|
- `MISSION_RUN_FREQUENCY_REACHED` (409): the wallet already started as many
|
|
244
318
|
runs as the mission allows in the current period. `params.retryAt` (ISO 8601,
|
|
245
319
|
UTC) is when it may start again. Do not retry before; tell the user when.
|
|
246
|
-
- `MISSION_RUN_LIMIT_REACHED` (409): the
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
cover this run; tell the user, do not split the work to get around it.
|
|
320
|
+
- `MISSION_RUN_LIMIT_REACHED` (409): the mission limits the simultaneous runs
|
|
321
|
+
per wallet and this wallet reached it. Finish one of your own runs first; if
|
|
322
|
+
the others are not yours, tell the user and stop.
|
|
250
323
|
- `MISSION_NOT_PUBLISHED` (409): nothing is published yet (ask a trial) or the
|
|
251
324
|
mission is archived.
|
|
252
325
|
- `MISSION_RUN_WALLET_OUT_OF_SCOPE` (403): this wallet is outside the mission's
|
|
253
326
|
sharing.
|
|
254
|
-
- `MISSION_RUN_OUT_OF_MISSION` (422):
|
|
255
|
-
the
|
|
327
|
+
- `MISSION_RUN_OUT_OF_MISSION` (422): the run does not fit the mission; read
|
|
328
|
+
the error, then start a run that fits or tell the user.
|
|
256
329
|
|
|
257
330
|
A run that no longer fits cannot be edited: start another one. A run that goes
|
|
258
|
-
over its envelope,
|
|
259
|
-
is refused with a `policy/…` reason (below). A payment above the wallet's
|
|
331
|
+
over its envelope, its destinations or its deadline is refused with a `policy/…` reason (below). A payment above the wallet's
|
|
260
332
|
approval threshold in an `auto` or `frequency` run waits for an operator in the
|
|
261
333
|
Inbox, who may allow it for the next runs of the mission. Stopping an active
|
|
262
334
|
run is a human decision, in the dashboard.
|
|
263
335
|
|
|
264
336
|
`agent-wallet:list_missions` and `agent-wallet:get_mission` return the
|
|
265
|
-
statistics (runs by status, total spent,
|
|
337
|
+
statistics (runs by status, total spent,
|
|
266
338
|
observed price per unit next to the target) and the limits currently blocking a
|
|
267
339
|
start, with their `retryAt`. `agent-wallet:list_mission_runs` and
|
|
268
340
|
`agent-wallet:get_mission_run` read the runs of this wallet.
|
|
@@ -282,8 +354,8 @@ that payment.
|
|
|
282
354
|
| `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
355
|
| `policy/mission-run-not-active: expired` | the run passed its deadline | start a new run if the task continues |
|
|
284
356
|
| `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
|
|
286
|
-
| `policy/domain-mission-not-allowed: <METHOD host/path>` (x402), `policy/recipient-mission-not-allowed` (transfer) | the destination is not
|
|
357
|
+
| `policy/envelope-exceeded: … (<key>)` | the payment would take the spent total above a cap: the key is the run's id | report which one; finish or abandon the run, or ask the user for a mission with a larger envelope; never split the payment |
|
|
358
|
+
| `policy/domain-mission-not-allowed: <METHOD host/path>` (x402), `policy/recipient-mission-not-allowed` (transfer) | the destination is not among the mission's sources (or recipients); 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 |
|
|
287
359
|
| `policy/intent-in-flight` | an earlier transfer is still pending | wait for it, or cancel it with `agent-wallet:cancel_intent` |
|
|
288
360
|
| `policy/emergency-stop` | the wallet is paused | resume it on the wallet page |
|
|
289
361
|
| `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 |
|