@haven_ai/cli 0.10.0-alpha.0 → 0.11.0-alpha.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 +19 -9
- package/dist/cli.cjs +40 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +40 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +40 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +40 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,7 +53,9 @@ The CLI talks to the hosted Haven backend by default. Point it elsewhere with
|
|
|
53
53
|
|
|
54
54
|
The path an agent walks, and where it stops. Four of the six steps in
|
|
55
55
|
[`/for-agents.md`](https://github.com/d-hinders/Haven-AI/blob/dev/packages/frontend/public/for-agents.md)
|
|
56
|
-
are your user's
|
|
56
|
+
are your user's. With a CLI session you can take step 3 — creating the agent
|
|
57
|
+
and setting its budget — off their hands, and `--run` also does step 4, which
|
|
58
|
+
is yours.
|
|
57
59
|
|
|
58
60
|
```bash
|
|
59
61
|
# 1. Get a scoped session. Prints a code and a link for your user to approve in
|
|
@@ -109,7 +111,7 @@ haven logout
|
|
|
109
111
|
|
|
110
112
|
# read
|
|
111
113
|
haven wallets list
|
|
112
|
-
haven wallets balances --safe <id|address>
|
|
114
|
+
haven wallets balances [--safe <id|address>]
|
|
113
115
|
haven wallets funding [--safe <id|address>] [--wait] # the paste-ready funding instruction (#2534)
|
|
114
116
|
haven agents list
|
|
115
117
|
haven agents show <id>
|
|
@@ -164,7 +166,13 @@ never calls `activate` — that is the whole design.
|
|
|
164
166
|
route). `--amount` is in
|
|
165
167
|
whole tokens, read from your wallet's balances exactly like
|
|
166
168
|
`agents connect`; `--recipient` pins the budget to one address (omit for an
|
|
167
|
-
open budget); `--expires` takes unix seconds (default: 90 days).
|
|
169
|
+
open budget); `--expires` takes unix seconds (default: 90 days). A grant
|
|
170
|
+
adds a budget to an EMPTY (token, recipient) slot only: when the agent
|
|
171
|
+
already has a live budget there, the build is refused (exit 4,
|
|
172
|
+
`error_code: BUDGET_SLOT_OCCUPIED` with `existing_delegation_hash` under
|
|
173
|
+
`--json`, #3933) and the hint says to edit that budget on the agent's page,
|
|
174
|
+
which replaces it and stops the old one on-chain. A grant cannot replace it
|
|
175
|
+
— that would leave the old delegation enabled.
|
|
168
176
|
- `budget revoke <agentId> <delegationHash>` prepares the sponsored
|
|
169
177
|
revocation (no gas, one signature). The hash comes from
|
|
170
178
|
`haven budget show <agentId> --hashes` or the dashboard. (`agents show` does
|
|
@@ -177,7 +185,8 @@ never calls `activate` — that is the whole design.
|
|
|
177
185
|
returns the same hash, so `--wait` converges instead of chasing a version
|
|
178
186
|
that never activates.
|
|
179
187
|
- Under `--json`, grant returns the backend's build object —
|
|
180
|
-
`{
|
|
188
|
+
`{ delegation_hash, version, delegate_account_address, signing_payload,
|
|
189
|
+
build_id, typed_data_hash, signing_url }`
|
|
181
190
|
(`build_id` and `typed_data_hash` are the delegation hash, named for API
|
|
182
191
|
clarity) — plus `agent_id` and `status`. The link first, the settled status
|
|
183
192
|
after: the same two-emission shape as device login.
|
|
@@ -194,7 +203,7 @@ rather than rounding it away.
|
|
|
194
203
|
The connector command is **printed, never composed** — it is the same string
|
|
195
204
|
the dashboard shows for the same setup, because both render what the backend
|
|
196
205
|
built. `--run` executes it for you as a child process with exactly `--json`
|
|
197
|
-
appended and nothing else changed, streams the connector's
|
|
206
|
+
appended and nothing else changed, streams the connector's stderr, and puts the
|
|
198
207
|
thing you have to act on first.
|
|
199
208
|
|
|
200
209
|
If the connector refuses — it cannot tell which runtime to wire, or the machine
|
|
@@ -217,7 +226,7 @@ Approving the budget stays with the human, in the browser, every time.
|
|
|
217
226
|
|
|
218
227
|
### `haven wallets funding`
|
|
219
228
|
|
|
220
|
-
Prints the funding instruction a human acts on: what to send (
|
|
229
|
+
Prints the funding instruction a human acts on: what to send (the token's
|
|
221
230
|
documented minimum-useful amount), to which address, on which chain, plus the
|
|
222
231
|
explorer link and a faucet link on testnets. It reads
|
|
223
232
|
`GET /user/accounts/:accountId/funding` — the same facts the dashboard's funding
|
|
@@ -225,7 +234,8 @@ card shows — and composes nothing locally, so the printed sentence and the
|
|
|
225
234
|
dashboard can never disagree about the amount.
|
|
226
235
|
|
|
227
236
|
`--wait` polls the same read until the account counts as funded, printing the
|
|
228
|
-
elapsed time on stderr
|
|
237
|
+
elapsed time while it waits (on stderr under `--json`), and exits 0 the moment
|
|
238
|
+
`funded` flips.
|
|
229
239
|
On timeout it exits 1 with the elapsed time in the message. It is read-only in
|
|
230
240
|
every mode: it never sends anything and never touches a faucet — the transfer
|
|
231
241
|
itself stays with the human.
|
|
@@ -325,7 +335,7 @@ sentence, now emit an object as well.
|
|
|
325
335
|
| `1` | Failed | Something broke that none of the below describes (a 5xx, an unexpected error). Retrying may help. |
|
|
326
336
|
| `2` | Usage | The command line was wrong — unknown command, missing argument, bad flag, or a `--safe` that matches nothing. Fix the argv; retrying it unchanged will not help. |
|
|
327
337
|
| `3` | Not authenticated | No stored session, or the backend rejected the one we have. Run `haven login`. |
|
|
328
|
-
| `4` | Refused | The
|
|
338
|
+
| `4` | Refused | The answer is no: a 403, 410 or other 4xx from the backend (its own `error` text is echoed when it sends one), or a refusal the CLI makes itself — for example a live budget on `agents revoke`, credential-shaped `feedback submit` text, the connector's refusal under `agents connect --run`, or a device login the human denied. |
|
|
329
339
|
| `5` | Network | The backend could not be reached at all. Check connectivity and `--api`. |
|
|
330
340
|
|
|
331
341
|
**Why a 401 is `3` and not `4`.** The two overlap by definition — a 401 *is* the
|
|
@@ -362,5 +372,5 @@ test; the copy exists so this package keeps **zero runtime dependencies** and
|
|
|
362
372
|
The CLI authenticates as the user and talks to the same JWT API as the
|
|
363
373
|
dashboard. It can read everything and perform backend-only management; anything
|
|
364
374
|
that moves funds or changes on-chain authority is signed by your wallet/passkey
|
|
365
|
-
in the dashboard. Haven never holds your
|
|
375
|
+
in the dashboard. Haven never holds your account's owner key or any delegate key
|
|
366
376
|
through this tool.
|
package/dist/cli.cjs
CHANGED
|
@@ -174,9 +174,9 @@ function helpText() {
|
|
|
174
174
|
"Budgets (construct-and-hand-off \u2014 the CLI never signs, #2539):",
|
|
175
175
|
" budget grant <agentId> --amount <n> --token USDC --period <minutes>",
|
|
176
176
|
" [--recipient <address>] [--expires <unix-s>] [--wait]",
|
|
177
|
-
" Prints
|
|
177
|
+
" Prints an approval link; the human approves in the dashboard.",
|
|
178
178
|
" budget revoke <agentId> <delegationHash> [--wait]",
|
|
179
|
-
" Prints a revocation link; the human
|
|
179
|
+
" Prints a revocation link; the human approves in the dashboard.",
|
|
180
180
|
"",
|
|
181
181
|
"Options:",
|
|
182
182
|
" --json One JSON value on stdout, prose on stderr, on every",
|
|
@@ -471,7 +471,7 @@ ${failure.hint}` : failure.message);
|
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
// src/agent-guidance-text.ts
|
|
474
|
-
var HAVEN_AGENT_RUNBOOK_MD = "# Haven for agents \u2014 set your user up to let you pay\n\nYou are an AI agent whose user has no Haven account yet, or has one but has not connected you.\n\n> Links below are paths on this same host: resolve them against the URL you fetched this file from.\n\n## What Haven is, in three sentences\n\nYour user gives you a **budget on their own account** \u2014 not their wallet, and not a key to their funds. The budget is a delegation they sign, enforced on-chain: a payment over it, to the wrong recipient, or past its expiry is refused at execution time, not by a dashboard promise. Haven constructs and relays the payments; you get an agent credential and a signing key made on your machine, and your user can revoke the budget without you and without Haven.\n\n## The sequence\n\nFour of the six steps are your user's \u2014 each needs a human signature or a human decision. The rest is yours. If they already have a funded account, start at step 3.\n\n1. **HUMAN \u2014 create the account.** Name, email, password, then a passkey (Face ID / Touch ID) or a wallet. Never offer to enter any of it: you must not have their password, and the passkey is bound to their device. With a terminal, `<packages.cli.one_liner> login --api <api-url>` afterwards gets you a scoped session for steps 3-4 (that flag or `HAVEN_API_URL`, on the first command \u2014 the session then remembers the backend; **the CLI's built-in default is Haven's hosted production backend**, so on any other deployment an omitted flag connects you somewhere real and wrong rather than failing) \u2014 they approve a code in the browser, you never hold their password. That command is the manifest's `packages.cli.one_liner` (`/.well-known/haven.json`) \u2014 run it as given: `packages.cli.channel` serves the full spec. Do not hold the process open while you wait: under `--json`, pass `--no-wait` to get the link object back at once, then poll it with `haven login --poll <device_code>` \u2014 one round per invocation, exit 3 while it is still pending, 0 once approved. It can set up agents and read the account; it cannot sign, approve a budget, move funds, or rotate any agent's keys.\n2. **HUMAN \u2014 fund it.** USDC only, no ETH: Haven sponsors the gas. `/.well-known/haven.json` names `chains.default` as the deployment's expected chain, but after login `haven wallets funding` prints the address, the amount and which chain in one place; confirm that chain before you message your user. Without a CLI session, the dashboard's funding card shows the address and amount and its Receive-funds screen names the chain; never assume one: a testnet deployment and production both call themselves Haven. Before you write that message, read the manifest: `environment` says whether this deployment is `production`, and each `chains.supported` entry says whether that chain is a `testnet`. Real money is at stake only on a non-testnet chain of a `production` deployment \u2014 tell your user which case theirs is.\n3. **HUMAN \u2014 create the agent, set its budget**, and paste you the **setup prompt** it hands back. With a CLI session (step 1) you can do this step yourself: `haven agents connect --name <n> --budget <amount> --token USDC --period <minutes>` prints the same connector command and approval link; add `--run` to do step 4 too.\n4. **YOU \u2014 run the connector command** in that prompt (see What you run). It makes your signing key locally, registering only the public address.\n5. **HUMAN \u2014 approve the budget** with their passkey, in the Haven tab they created the agent in: it advances to the approval step by itself once your run registers.\n6. **YOU \u2014 verify, then pay.**\n\n## Budget changes later (second token, raise, revoke)\n\nThe first budget rides the setup in The sequence. After the agent exists, a CLI session can construct the LATER changes \u2014 a second token, a bigger amount, a recipient pin, a stop \u2014 and hand your user a link; the human still signs, every time:\n\n```\nhaven budget grant <agentId> --amount <n> --token USDC --period <minutes> [--recipient <address>] [--wait]\nhaven budget revoke <agentId> <delegationHash> [--wait]\n```\n\nThe CLI never signs: it prints a dashboard link, your user opens it and signs with their passkey or wallet. `--wait` polls until the human's signature lands. The hash for `revoke` is in `haven budget show <agentId> --hashes`.\n\n## Hand-off scripts\n\nSend these as your own message, `<host>` replaced by the host you fetched this file from. Say what you cannot do, not only what they must.\n\n**Before signup** (step 1):\n\n> I can do everything except the parts that need your signature. Please open `<host>/signup?next=/agents&via=agent` \u2014 name, email, password, then a passkey (Face ID / Touch ID) or a wallet. That is your account's key: I should not have it, and I will never ask for your password. Already have one? `<host>/login?next=/agents`.\n\n**At the passkey step:**\n\n> The passkey must be made on your own device \u2014 it is what keeps the account yours, so nobody, Haven included, can move your funds without you. If this browser cannot, open `<host>/onboarding?next=/agents` on your phone and finish there.\n\n**At funding** (step 2):\n\n> Your Haven account needs USDC before I can pay for anything \u2014 USDC only, no ETH: Haven sponsors the gas. Before you send anything, let me get you the exact address **and network** \u2014 `haven wallets funding` prints both, and the funding card on `<host>/dashboard` shows the same. Please do not send to an address or a chain I have not confirmed with you; a small amount first is fine.\n\n**At the budget** (step 3):\n\n> On `<host>/agents`, create an agent for me and set a budget \u2014 say 25 USDC per day. That is the limit I cannot exceed. It hands back a setup prompt: paste it to me and I run it here.\n\n**At budget approval** (step 5) \u2014 the moment your run reports that approval is required, before anything else. Send the first if your run carried `approval.url`, the second if it did not.\n\n> Setup is done on my side. Approve the budget here: <approval.url>. Approve it with your passkey; nothing can be spent until you do.\n\n> Setup is done on my side. Go back to the Haven tab where you created the agent \u2014 it should now be asking you to approve the budget. Approve it with your passkey; nothing can be spent until you do.\n\n## What you run\n\nThe setup prompt carries a **connector command** shaped like this:\n\n```\nnpx -y @haven_ai/connect@<channel> --setup EXAMPLE-SETUP-TOKEN-NOT-REAL --api <api-url> --ack-local-tools\n```\n\nRun the prompt's version, not this one: the token is one-time, the API URL is the backend's own, and `<channel>` is the npm tag your prompt names \u2014 never a tag you pick. The rules below come from that prompt, so \"me\" in them is your user, not Haven.\n\n- If you are an AI agent running this command yourself rather than a human pasting it, you should append --json: the connector then emits one machine-readable, secret-free result object on stdout with progress on stderr, and returns promptly instead of blocking while it waits for the budget approval.\n- When a --json outcome reports approval.required: true, your first action must be to relay the approval instruction to me in your own reply \u2014 if the outcome carries approval.url, give me that link; otherwise tell me to return to Haven and approve this agent's budget \u2014 before verifying the connection, restarting anything, or any other step. Never build that link yourself: relay the one the outcome gave you or none at all. Any restart the outcome asks for is a separate instruction to give me afterwards, once the approval is done.\n- If you ran the command without --json, the connector waits for the approval itself and prints its next steps when it finishes: relay the budget-approval instruction to me \u2014 the approval link if those steps printed one, otherwise that you need to return to Haven and approve this agent's budget \u2014 only if those printed next steps still ask for it. If they report the budget as already approved, there is nothing for me to approve.\n- Only three changes to the command above are permitted, and no others: appending --json; re-running it once with --runtime <name> added, only if the connector refuses because it could not determine the agent runtime, naming the harness you are running in and using one of the values that refusal lists; and re-running it once with the one flag I chose added, only after I have answered a wiring_collision relay \u2014 --name <the suggested_name or a name I gave> to add alongside, or --replace to replace \u2014 keeping any change already made. If that re-run is refused too, relay the refusal to me and stop. Never invent a runtime name and never change anything else.\n- Do not print private keys, API keys, credential file contents, or config secrets in chat or logs.\n\nIf the approval wait times out, nothing is lost \u2014 your agent is registered and the budget is still waiting to be approved. Send your user the `approval.url` your run reported, or, if it carried none, ask them to finish it in that same Haven tab. The outcome carries no setup id, so never assemble an approval link out of parts \u2014 relay the whole one it gave you or none at all.\n\n## How to verify\n\nCall `haven_get_agent`, one of the Haven MCP tools the connector wires into your runtime in step 4. It returns identity plus `spend_authority_readiness`:\n\n- `ready` \u2014 a budget is live: you have the authority to pay. It does not say the account holds funds \u2014 the `allowances[]` rows carry `funds_cover_remaining`, and `false` there is a heads-up to mention to your user, not a refusal.\n- `needs_approval` \u2014 the connector finished, nobody approved yet. Ask your user again, in their Haven tab; there is no queue to wait in.\n- `revoked` \u2014 the credential is not active; ask your user to create a new agent.\n\n`ready` covers hosted identity and the budget only, not your local signer. Check that with `npx -y @haven_ai/connect@<channel> --doctor`, the same tag your prompt named \u2014 a separate command, so the command-modification rule does not bind it.\n\n## If you cannot open a browser\n\nNothing here needs you to. Steps 1-3 \u2014 account, funding, budget \u2014 are links: hand your user the full `<host>/\u2026` URL and ask them to say when it is done. Step 5 is a link only when your run reported one in `approval.url` \u2014 otherwise it is the tab they already have open. Then poll `haven_get_agent` until it reads `ready`. Do not route around the sign-in wall \u2014 it makes the account theirs, not yours.\n\n## If something breaks\n\nIf a Haven result carries `client_update`, that client is out of date: run its `upgrade_command` exactly as given \u2014 a connector command may name your pair with `--name <slug>` \u2014 then any repair line it prints, then retry. `required: true` means payments are refused until you do. What changed: [/releases](/releases).\n\nSomething else wrong? `haven feedback submit \"<text>\"` sends it to Haven \u2014 it needs `haven login` first. Never put a credential in that text: no API key, no delegate key, no session token, no recovery phrase.\n\n## Vocabulary\n\n| Term | What it is |\n|---|---|\n| **setup prompt** | The text the dashboard hands your user to paste to you. Carries the command and its rules. |\n| **connector command** | The `npx -y @haven_ai/connect@\u2026` line you run. One-time token, one use. |\n| **agent credential** | Your API key (`sk_agent_\u2026`), written to `~/.haven`. It identifies you; alone it cannot move money. |\n| **delegate key** | Your signing key, made on this machine and never sent anywhere. |\n| **budget** | The on-chain delegation your user signed. It authorises the payment; Haven constructs and relays it. |\n\nNext: [your agent hit a 402](/402.md) \xB7 [everything agent-readable](/llms.txt)\n";
|
|
474
|
+
var HAVEN_AGENT_RUNBOOK_MD = "# Haven for agents \u2014 set your user up to let you pay\n\nYou are an AI agent whose user has no Haven account yet, or has one but has not connected you.\n\n> Links below are paths on this same host: resolve them against the URL you fetched this file from.\n\n## What Haven is, in three sentences\n\nYour user gives you a **budget on their own account** \u2014 not their wallet, and not a key to their funds. The budget is a delegation they sign, enforced on-chain: a payment over it, to the wrong recipient, or past its expiry is refused at execution time, not by a dashboard promise. Haven constructs and relays the payments; you get an agent credential and a signing key made on your machine, and your user can revoke the budget without you and without Haven.\n\n## The sequence\n\nFour of the six steps are your user's \u2014 each needs a human signature or a human decision. The rest is yours. If they already have a funded account, start at step 3.\n\n1. **HUMAN \u2014 create the account.** Name, email, password, then a passkey or a wallet. Never offer to enter any of it: you must not have their password, and the passkey is bound to their device. With a terminal, `<packages.cli.one_liner> login --api <api-url>` afterwards gets you a scoped session for steps 3-4 (that flag or `HAVEN_API_URL`, on the first command \u2014 the session then remembers the backend; **the CLI's built-in default is Haven's hosted production backend**, so on any other deployment an omitted flag connects you somewhere real and wrong rather than failing) \u2014 they approve a code in the browser, you never hold their password. That command is the manifest's `packages.cli.one_liner` (`/.well-known/haven.json`) \u2014 run it as given: `packages.cli.channel` serves the full spec. Do not hold the process open while you wait: under `--json`, pass `--no-wait` to get the link object back at once, then poll it with `haven login --poll <device_code>` \u2014 one round per invocation, exit 3 while it is still pending, 0 once approved. It can set up agents and read the account; it cannot sign, approve a budget, move funds, or rotate any agent's keys.\n2. **HUMAN \u2014 fund it.** USDC only, no ETH: Haven sponsors the gas. `/.well-known/haven.json` names `chains.default` as the deployment's expected chain, but after login `haven wallets funding` prints the address, the amount and which chain in one place; confirm that chain before you message your user. Without a CLI session, the dashboard's funding card shows the address and amount and its Receive-funds screen names the chain; never assume one: a testnet deployment and production both call themselves Haven. Before you write that message, read the manifest: `environment` says whether this deployment is `production`, and each `chains.supported` entry says whether that chain is a `testnet`. Real money is at stake only on a non-testnet chain of a `production` deployment \u2014 tell your user which case theirs is.\n3. **HUMAN \u2014 create the agent, set its budget**, and paste you the **setup prompt** it hands back. With a CLI session (step 1) you can do this step yourself: `haven agents connect --name <n> --budget <amount> --token USDC --period <minutes>` prints the same connector command and approval link; add `--run` to do step 4 too.\n4. **YOU \u2014 run the connector command** in that prompt (see What you run). It makes your signing key locally, registering only the public address.\n5. **HUMAN \u2014 approve the budget** with their passkey, in the Haven tab they created the agent in: it advances to the approval step by itself once your run registers.\n6. **YOU \u2014 verify, then pay.**\n\n## Budget changes later (second token, raise, revoke)\n\nThe first budget rides the setup in The sequence. After the agent exists, a CLI session can construct the LATER changes \u2014 a second token, a bigger amount, a recipient pin, a stop \u2014 and hand your user a link; the human still signs, every time:\n\n```\nhaven budget grant <agentId> --amount <n> --token USDC --period <minutes> [--recipient <address>] [--wait]\nhaven budget revoke <agentId> <delegationHash> [--wait]\n```\n\nThe CLI never signs: it prints a dashboard link, your user opens it and signs with their passkey or wallet. `--wait` polls until the human's signature lands. The hash for `revoke` is in `haven budget show <agentId> --hashes`.\n\n## Hand-off scripts\n\nSend these as your own message, `<host>` replaced by the host you fetched this file from. Say what you cannot do, not only what they must.\n\n**Before signup** (step 1):\n\n> I can do everything except the parts that need your signature. Please open `<host>/signup?next=/agents&via=agent` \u2014 name, email, password, then a passkey or a wallet. That is your account's key: I should not have it, and I will never ask for your password. Already have one? `<host>/login?next=/agents`.\n\n**At the passkey step:**\n\n> The passkey must be made on your own device \u2014 it is what keeps the account yours, so nobody, Haven included, can move your funds without you. If this browser cannot, open `<host>/onboarding?next=/agents` on your phone and finish there.\n\n**At funding** (step 2):\n\n> Your Haven account needs USDC before I can pay for anything \u2014 USDC only, no ETH: Haven sponsors the gas. Before you send anything, let me get you the exact address **and network** \u2014 `haven wallets funding` prints both, and the funding card on `<host>/dashboard` shows the same. Please do not send to an address or a chain I have not confirmed with you; a small amount first is fine.\n\n**At the budget** (step 3):\n\n> On `<host>/agents`, create an agent for me and set a budget \u2014 say 25 USDC per day. That is the limit I cannot exceed. It hands back a setup prompt: paste it to me and I run it here.\n\n**At budget approval** (step 5) \u2014 the moment your run reports that approval is required, before anything else. Send the first if your run carried `approval.url`, the second if it did not.\n\n> Setup is done on my side. Approve the budget here: <approval.url>. Approve it with your passkey; nothing can be spent until you do.\n\n> Setup is done on my side. Go back to the Haven tab where you created the agent \u2014 it should now be asking you to approve the budget. Approve it with your passkey; nothing can be spent until you do.\n\n## What you run\n\nThe setup prompt carries a **connector command** shaped like this:\n\n```\nnpx -y @haven_ai/connect@<channel> --setup EXAMPLE-SETUP-TOKEN-NOT-REAL --api <api-url> --ack-local-tools\n```\n\nRun the prompt's version, not this one: the token is one-time, the API URL is the backend's own, and `<channel>` is the npm tag your prompt names \u2014 never a tag you pick. The rules below come from that prompt, so \"me\" in them is your user, not Haven.\n\n- If you are an AI agent running this command yourself rather than a human pasting it, you should append --json: the connector then emits one machine-readable, secret-free result object on stdout with progress on stderr, and returns promptly instead of blocking while it waits for the budget approval.\n- When a --json outcome reports approval.required: true, your first action must be to relay the approval instruction to me in your own reply \u2014 if the outcome carries approval.url, give me that link; otherwise tell me to return to Haven and approve this agent's budget \u2014 before verifying the connection, restarting anything, or any other step. Never build that link yourself: relay the one the outcome gave you or none at all. Any restart the outcome asks for is a separate instruction to give me afterwards, once the approval is done.\n- If you ran the command without --json, the connector waits for the approval itself and prints its next steps when it finishes: relay the budget-approval instruction to me \u2014 the approval link if those steps printed one, otherwise that you need to return to Haven and approve this agent's budget \u2014 only if those printed next steps still ask for it. If they report the budget as already approved, there is nothing for me to approve.\n- Only three changes to the command above are permitted, and no others: appending --json; re-running it once with --runtime <name> added, only if the connector refuses because it could not determine the agent runtime, naming the harness you are running in and using one of the values that refusal lists; and re-running it once with the one flag I chose added, only after I have answered a wiring_collision relay \u2014 --name <the suggested_name or a name I gave> to add alongside, or --replace to replace \u2014 keeping any change already made. If that re-run is refused too, relay the refusal to me and stop. Never invent a runtime name and never change anything else.\n- Do not print private keys, API keys, credential file contents, or config secrets in chat or logs.\n\nIf the approval wait times out, nothing is lost \u2014 your agent is registered and the budget is still waiting to be approved. Send your user the `approval.url` your run reported, or, if it carried none, ask them to finish it in that same Haven tab. The outcome carries no setup id, so never assemble an approval link out of parts \u2014 relay the whole one it gave you or none at all.\n\n## How to verify\n\nCall `haven_get_agent`, one of the Haven MCP tools the connector wires into your runtime in step 4. It returns identity plus `spend_authority_readiness`:\n\n- `ready` \u2014 a budget is live: you have the authority to pay. It does not say the account holds funds \u2014 the `allowances[]` rows carry `funds_cover_remaining`, and `false` there is a heads-up to mention to your user, not a refusal.\n- `needs_approval` \u2014 the connector finished, nobody approved yet. Ask your user again, in their Haven tab; there is no queue to wait in.\n- `revoked` \u2014 the credential is not active; ask your user to create a new agent.\n\n`ready` covers hosted identity and the budget only, not your local signer. Check that with `npx -y @haven_ai/connect@<channel> --doctor`, the same tag your prompt named \u2014 a separate command, so the command-modification rule does not bind it.\n\n## If you cannot open a browser\n\nNothing here needs you to. Steps 1-3 \u2014 account, funding, budget \u2014 are links: hand your user the full `<host>/\u2026` URL and ask them to say when it is done. Step 5 is a link only when your run reported one in `approval.url` \u2014 otherwise it is the tab they already have open. Then poll `haven_get_agent` until it reads `ready`. Do not route around the sign-in wall \u2014 it makes the account theirs, not yours.\n\n## If something breaks\n\nIf a Haven result carries `client_update`, that client is out of date: run its `upgrade_command` exactly as given \u2014 a connector command may name your pair with `--name <slug>` \u2014 then any repair line it prints, then retry. `required: true` means payments are refused until you do. What changed: [/releases](/releases).\n\nSomething else wrong? `haven feedback submit \"<text>\"` sends it to Haven \u2014 it needs `haven login` first. Never put a credential in that text: no API key, no delegate key, no session token, no recovery phrase.\n\n## Vocabulary\n\n| Term | What it is |\n|---|---|\n| **setup prompt** | The text the dashboard hands your user to paste to you. Carries the command and its rules. |\n| **connector command** | The `npx -y @haven_ai/connect@\u2026` line you run. One-time token, one use. |\n| **agent credential** | Your API key (`sk_agent_\u2026`), written to `~/.haven`. It identifies you; alone it cannot move money. |\n| **delegate key** | Your signing key, made on this machine and never sent anywhere. |\n| **budget** | The on-chain delegation your user signed. It authorises the payment; Haven constructs and relays it. |\n\nNext: [your agent hit a 402](/402.md) \xB7 [everything agent-readable](/llms.txt)\n";
|
|
475
475
|
|
|
476
476
|
// src/token.ts
|
|
477
477
|
function sessionExpiry(token) {
|
|
@@ -3152,7 +3152,7 @@ async function checkTextForSecrets(text, deps) {
|
|
|
3152
3152
|
|
|
3153
3153
|
// src/commands.ts
|
|
3154
3154
|
var DEFAULT_API = "https://havenbackend-production-8a00.up.railway.app";
|
|
3155
|
-
var CLI_VERSION = "0.
|
|
3155
|
+
var CLI_VERSION = "0.11.0-alpha.0";
|
|
3156
3156
|
var CLI_CLIENT_IDENTITY = `@haven_ai/cli/${CLI_VERSION}`;
|
|
3157
3157
|
function accountAddressOf(s) {
|
|
3158
3158
|
return s.account_address ?? "";
|
|
@@ -3611,6 +3611,11 @@ function budgetSummary(allowances) {
|
|
|
3611
3611
|
if (!allowances || allowances.length === 0) return "\u2014";
|
|
3612
3612
|
return allowances.map((a) => `${a.allowance_amount} ${a.token_symbol}`).join(", ");
|
|
3613
3613
|
}
|
|
3614
|
+
var STILL_ENABLED_STATUSES = /* @__PURE__ */ new Set([
|
|
3615
|
+
"pending",
|
|
3616
|
+
"active",
|
|
3617
|
+
"replaced"
|
|
3618
|
+
]);
|
|
3614
3619
|
var BUDGET_WAIT_TIMEOUT_S = 15 * 60;
|
|
3615
3620
|
var BUDGET_WAIT_INTERVAL_MS = 5e3;
|
|
3616
3621
|
async function cmdBudgetGrant(args, d) {
|
|
@@ -3648,13 +3653,27 @@ async function cmdBudgetGrant(args, d) {
|
|
|
3648
3653
|
}
|
|
3649
3654
|
const amount = parseTokenAmount(args.flags.amount, token.decimals, token.symbol);
|
|
3650
3655
|
if (!amount.ok) throw new UsageError(amount.message);
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3656
|
+
let built;
|
|
3657
|
+
try {
|
|
3658
|
+
built = await api.post(`/agents/${id}/delegations/build`, {
|
|
3659
|
+
token_address: token.address,
|
|
3660
|
+
recipient_address: args.flags.recipient ?? null,
|
|
3661
|
+
budget_atomic: amount.atomic,
|
|
3662
|
+
period_seconds: args.flags.period * 60,
|
|
3663
|
+
...args.flags.expires !== void 0 ? { expires_at: args.flags.expires } : {}
|
|
3664
|
+
});
|
|
3665
|
+
} catch (err) {
|
|
3666
|
+
const body = err instanceof CliApiError ? err.body : void 0;
|
|
3667
|
+
if (body?.error_code === "BUDGET_SLOT_OCCUPIED") {
|
|
3668
|
+
throw new HavenCliError(
|
|
3669
|
+
err instanceof Error ? err.message : "This agent already has a live budget for this token and recipient.",
|
|
3670
|
+
EXIT.refused,
|
|
3671
|
+
"Edit that budget on the agent's page in the Haven dashboard instead: editing replaces it and stops the old one on-chain. Open task and sub-budgets carved from the old budget end when it is stopped.",
|
|
3672
|
+
{ error_code: "BUDGET_SLOT_OCCUPIED", existing_delegation_hash: body.existing_delegation_hash ?? null }
|
|
3673
|
+
);
|
|
3674
|
+
}
|
|
3675
|
+
throw err;
|
|
3676
|
+
}
|
|
3658
3677
|
const emitGrant = (status) => emit(
|
|
3659
3678
|
d,
|
|
3660
3679
|
args.flags.json,
|
|
@@ -3662,10 +3681,10 @@ async function cmdBudgetGrant(args, d) {
|
|
|
3662
3681
|
() => [
|
|
3663
3682
|
`Budget of ${args.flags.amount} ${token.symbol} per ${args.flags.period} minutes built for agent ${id}.`,
|
|
3664
3683
|
args.flags.recipient ? `Recipient pin: ${args.flags.recipient}` : null,
|
|
3665
|
-
"Open this link and
|
|
3684
|
+
"Open this link and approve \u2014 the budget goes live the moment you do:",
|
|
3666
3685
|
built.signing_url,
|
|
3667
3686
|
`Delegation: ${built.delegation_hash} (version ${built.version})`,
|
|
3668
|
-
status === "active" ? "
|
|
3687
|
+
status === "active" ? "Approved and active." : "Waiting for your approval. Run the same command with --wait to poll until it is active."
|
|
3669
3688
|
].filter((line) => line !== null).join("\n")
|
|
3670
3689
|
);
|
|
3671
3690
|
emitGrant();
|
|
@@ -3675,19 +3694,19 @@ async function cmdBudgetGrant(args, d) {
|
|
|
3675
3694
|
await d.sleep(BUDGET_WAIT_INTERVAL_MS);
|
|
3676
3695
|
const { delegations } = await api.get(`/agents/${id}/delegations`);
|
|
3677
3696
|
const mine = delegations.find((row) => row.delegation_hash === built.delegation_hash);
|
|
3678
|
-
if (mine
|
|
3697
|
+
if (mine && (mine.is_live ?? mine.status === "active")) {
|
|
3679
3698
|
emitGrant("active");
|
|
3680
3699
|
return EXIT.ok;
|
|
3681
3700
|
}
|
|
3682
3701
|
if (mine?.status === "revoked" || mine?.status === "replaced") {
|
|
3683
3702
|
throw new HavenCliError(
|
|
3684
|
-
`Delegation ${built.delegation_hash} is now ${mine.status} without being
|
|
3703
|
+
`Delegation ${built.delegation_hash} is now ${mine.status} without being approved.`,
|
|
3685
3704
|
EXIT.refused
|
|
3686
3705
|
);
|
|
3687
3706
|
}
|
|
3688
3707
|
}
|
|
3689
3708
|
throw new HavenCliError(
|
|
3690
|
-
`Timed out waiting for delegation ${built.delegation_hash} to go active (${BUDGET_WAIT_TIMEOUT_S / 60} minutes). The
|
|
3709
|
+
`Timed out waiting for delegation ${built.delegation_hash} to go active (${BUDGET_WAIT_TIMEOUT_S / 60} minutes). The approval link stays valid until it expires \u2014 approve it, or rerun with --wait.`,
|
|
3691
3710
|
EXIT.failed
|
|
3692
3711
|
);
|
|
3693
3712
|
}
|
|
@@ -3719,11 +3738,11 @@ async function cmdBudgetRevoke(args, d) {
|
|
|
3719
3738
|
args.flags.json,
|
|
3720
3739
|
{ agent_id: id, delegation_hash: hash, status, ...prepared },
|
|
3721
3740
|
() => [
|
|
3722
|
-
"Revocation prepared \u2014 one
|
|
3723
|
-
"Open this link and
|
|
3741
|
+
"Revocation prepared \u2014 one approval, sponsored (no gas).",
|
|
3742
|
+
"Open this link and approve to stop this budget:",
|
|
3724
3743
|
revokeUrl,
|
|
3725
3744
|
`Delegation: ${hash}`,
|
|
3726
|
-
status === "revoked" ? "Revoked." : "The budget keeps working until you
|
|
3745
|
+
status === "revoked" ? "Revoked." : "The budget keeps working until you approve. Run the same command with --wait to poll until it is revoked."
|
|
3727
3746
|
].filter((line) => line !== null).join("\n")
|
|
3728
3747
|
);
|
|
3729
3748
|
emitRevoke("pending_revoke");
|
|
@@ -3739,7 +3758,7 @@ async function cmdBudgetRevoke(args, d) {
|
|
|
3739
3758
|
}
|
|
3740
3759
|
}
|
|
3741
3760
|
throw new HavenCliError(
|
|
3742
|
-
`Timed out waiting for delegation ${hash} to be revoked (${BUDGET_WAIT_TIMEOUT_S / 60} minutes). The link stays valid \u2014
|
|
3761
|
+
`Timed out waiting for delegation ${hash} to be revoked (${BUDGET_WAIT_TIMEOUT_S / 60} minutes). The link stays valid \u2014 approve it, or rerun with --wait.`,
|
|
3743
3762
|
EXIT.failed
|
|
3744
3763
|
);
|
|
3745
3764
|
}
|
|
@@ -3779,7 +3798,7 @@ async function cmdAgentRevoke(args, d) {
|
|
|
3779
3798
|
const agent = await api.get(`/agents/${id}`);
|
|
3780
3799
|
if ((agent.live_delegation_count ?? 0) > 0) {
|
|
3781
3800
|
const { delegations } = await api.get(`/agents/${id}/delegations`);
|
|
3782
|
-
live = delegations.filter((r) =>
|
|
3801
|
+
live = delegations.filter((r) => STILL_ENABLED_STATUSES.has(r.status));
|
|
3783
3802
|
}
|
|
3784
3803
|
} catch (err) {
|
|
3785
3804
|
d.o.note(`Couldn't check budgets for agent ${id}, so the revocation was not attempted.`);
|