@haven_ai/cli 0.0.0-dev.202609051933.cc65a9d → 0.0.0-dev.202609060850.63aab73
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 +16 -0
- package/dist/cli.cjs +66 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +66 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +66 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +66 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ haven logout
|
|
|
44
44
|
# read
|
|
45
45
|
haven wallets list
|
|
46
46
|
haven wallets balances --safe <id|address>
|
|
47
|
+
haven wallets funding [--safe <id|address>] [--wait] # the paste-ready funding instruction (#2534)
|
|
47
48
|
haven agents list
|
|
48
49
|
haven agents show <id>
|
|
49
50
|
haven budget show <agentId>
|
|
@@ -99,6 +100,21 @@ delegate address, and a CLI an agent drives must never hold a signing key —
|
|
|
99
100
|
|
|
100
101
|
Approving the budget stays with the human, in the browser, every time.
|
|
101
102
|
|
|
103
|
+
### `haven wallets funding`
|
|
104
|
+
|
|
105
|
+
Prints the funding instruction a human acts on: what to send (each token's
|
|
106
|
+
documented minimum-useful amount), to which address, on which chain, plus the
|
|
107
|
+
explorer link and a faucet link on testnets. It reads
|
|
108
|
+
`GET /user/safes/:safeId/funding` — the same facts the dashboard's funding
|
|
109
|
+
card shows — and composes nothing locally, so the printed sentence and the
|
|
110
|
+
dashboard can never disagree about the amount.
|
|
111
|
+
|
|
112
|
+
`--wait` polls the same read until the account counts as funded, printing the
|
|
113
|
+
elapsed time on stderr while it waits, and exits 0 the moment `funded` flips.
|
|
114
|
+
On timeout it exits 1 with the elapsed time in the message. It is read-only in
|
|
115
|
+
every mode: it never sends anything and never touches a faucet — the transfer
|
|
116
|
+
itself stays with the human.
|
|
117
|
+
|
|
102
118
|
Add `--json` to any read command for machine-readable output:
|
|
103
119
|
|
|
104
120
|
```bash
|
package/dist/cli.cjs
CHANGED
|
@@ -106,6 +106,9 @@ function helpText() {
|
|
|
106
106
|
"Read:",
|
|
107
107
|
" wallets list List your Haven wallets",
|
|
108
108
|
" wallets balances [--safe <id|address>] Token balances for a wallet",
|
|
109
|
+
" wallets funding [--safe <id|address>] [--wait] The paste-ready funding",
|
|
110
|
+
" instruction: what to send, where, on which chain.",
|
|
111
|
+
" --wait polls until the account counts as funded.",
|
|
109
112
|
" agents list List your agents",
|
|
110
113
|
" agents show <id> Show one agent + its budget",
|
|
111
114
|
" budget show <agentId> Show an agent's configured budget",
|
|
@@ -381,7 +384,7 @@ ${failure.hint}` : failure.message);
|
|
|
381
384
|
}
|
|
382
385
|
|
|
383
386
|
// src/agent-guidance-text.ts
|
|
384
|
-
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, `npx @haven_ai/cli login` afterwards gets you a scoped session for steps 3-4 \u2014 they approve a code in the browser, you never hold their password. 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 on Base, to the address the dashboard shows.\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 (below). 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## 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 on Base before I can pay for anything \u2014 USDC only, no ETH: Haven sponsors the gas. The dashboard shows the address to send it to; 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 two changes to the command above are permitted, and no others: appending --json, and \u2014 only if the connector refuses because it could not determine the agent runtime \u2014 re-running it once with --runtime <name> added, naming the harness you are running in, using one of the values that refusal lists. 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 can pay.\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 two-changes rule does not bind it.\n\n## If you cannot open a browser\n\nNothing here needs you to. Steps 1-3 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, as above. 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## 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";
|
|
387
|
+
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, `npx @haven_ai/cli login` afterwards gets you a scoped session for steps 3-4 \u2014 they approve a code in the browser, you never hold their password. 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 on Base, to the address the dashboard shows. With a CLI session, `haven wallets funding` prints the address and the amount to send.\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 (below). 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## 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 on Base before I can pay for anything \u2014 USDC only, no ETH: Haven sponsors the gas. The dashboard shows the address to send it to; a small amount first is fine. If I have a terminal session, `haven wallets funding` prints the address, the amount and an explorer link \u2014 say the word and I will paste them here.\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 two changes to the command above are permitted, and no others: appending --json, and \u2014 only if the connector refuses because it could not determine the agent runtime \u2014 re-running it once with --runtime <name> added, naming the harness you are running in, using one of the values that refusal lists. 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 can pay.\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 two-changes rule does not bind it.\n\n## If you cannot open a browser\n\nNothing here needs you to. Steps 1-3 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, as above. 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## 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";
|
|
385
388
|
|
|
386
389
|
// src/token.ts
|
|
387
390
|
function sessionExpiry(token) {
|
|
@@ -556,7 +559,7 @@ async function runConnector(connectorCommand, spawner, onStderr) {
|
|
|
556
559
|
|
|
557
560
|
// src/commands.ts
|
|
558
561
|
var DEFAULT_API = "https://havenbackend-production-8a00.up.railway.app";
|
|
559
|
-
var CLI_VERSION = "0.0.0-dev.
|
|
562
|
+
var CLI_VERSION = "0.0.0-dev.202609060850.63aab73";
|
|
560
563
|
async function run(argv, deps = {}) {
|
|
561
564
|
const out = deps.out ?? ((l) => process.stdout.write(`${l}
|
|
562
565
|
`));
|
|
@@ -615,6 +618,8 @@ async function dispatch(args, d) {
|
|
|
615
618
|
return cmdWalletsList(args, d);
|
|
616
619
|
case "wallets balances":
|
|
617
620
|
return cmdWalletsBalances(args, d);
|
|
621
|
+
case "wallets funding":
|
|
622
|
+
return cmdWalletsFunding(args, d);
|
|
618
623
|
case "agents list":
|
|
619
624
|
return cmdAgentsList(args, d);
|
|
620
625
|
case "agents show":
|
|
@@ -801,6 +806,65 @@ function pickSafe(safes, ref) {
|
|
|
801
806
|
const lower = ref.toLowerCase();
|
|
802
807
|
return safes.find((s) => s.id === ref || s.safe_address.toLowerCase() === lower);
|
|
803
808
|
}
|
|
809
|
+
async function cmdWalletsFunding(args, d) {
|
|
810
|
+
const { api } = await authed(args, d);
|
|
811
|
+
const { safes } = await api.get("/user/safes");
|
|
812
|
+
const safe = pickSafe(safes, args.flags.safe);
|
|
813
|
+
if (!safe) {
|
|
814
|
+
if (args.flags.safe) throw new UsageError(`No wallet matches "${args.flags.safe}".`);
|
|
815
|
+
throw new CliApiError("No Haven wallet found.", 404);
|
|
816
|
+
}
|
|
817
|
+
const funding = await api.get(`/user/safes/${safe.id}/funding`);
|
|
818
|
+
if (!args.flags.wait) {
|
|
819
|
+
emitFunding(d, funding);
|
|
820
|
+
return EXIT.ok;
|
|
821
|
+
}
|
|
822
|
+
const started = Date.now();
|
|
823
|
+
const pollMs = Number(d.env.HAVEN_FUNDING_POLL_MS ?? "5000");
|
|
824
|
+
const waitMs = Number(d.env.HAVEN_FUNDING_WAIT_MS ?? String(2 * 60 * 60 * 1e3));
|
|
825
|
+
if (!Number.isFinite(pollMs) || pollMs <= 0 || !Number.isFinite(waitMs) || waitMs <= 0) {
|
|
826
|
+
throw new UsageError("HAVEN_FUNDING_POLL_MS / HAVEN_FUNDING_WAIT_MS must be positive numbers of milliseconds");
|
|
827
|
+
}
|
|
828
|
+
let current = funding;
|
|
829
|
+
for (; ; ) {
|
|
830
|
+
const spent = Date.now() - started;
|
|
831
|
+
if (spent >= waitMs) {
|
|
832
|
+
throw new HavenCliError(
|
|
833
|
+
`Still not funded after ${elapsedLabel(spent)} \u2014 the transfer may not have landed yet. Check the explorer link, then re-run.`,
|
|
834
|
+
EXIT.failed
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
await d.sleep(pollMs);
|
|
838
|
+
current = await api.get(`/user/safes/${safe.id}/funding`);
|
|
839
|
+
if (current.funded) break;
|
|
840
|
+
d.o.note(`Still waiting after ${elapsedLabel(Date.now() - started)} \u2014 funded: no.`);
|
|
841
|
+
}
|
|
842
|
+
d.o.note(`Account shows funded after ${elapsedLabel(Date.now() - started)}.`);
|
|
843
|
+
emitFunding(d, current);
|
|
844
|
+
return EXIT.ok;
|
|
845
|
+
}
|
|
846
|
+
function emitFunding(d, funding) {
|
|
847
|
+
emit(d, d.o.json, funding, () => {
|
|
848
|
+
const token = funding.tokens.find((t) => t.minimum_useful_human !== null);
|
|
849
|
+
const asset = token ? `at least ${token.minimum_useful_human} ${token.symbol}` : funding.native.needed ? funding.native.symbol : "USDC";
|
|
850
|
+
const gas = funding.native.needed ? ` plus ${funding.native.symbol} for gas` : " \u2014 no gas token needed; Haven sponsors it";
|
|
851
|
+
const faucet = funding.faucet_url !== void 0 ? ` faucet: ${funding.faucet_url},` : "";
|
|
852
|
+
return [
|
|
853
|
+
`Send ${asset} on ${funding.chain.name} to ${funding.account_address}${gas}.`,
|
|
854
|
+
`Explorer: ${funding.chain.explorer_url}.${faucet ? faucet.slice(0, -1) : ""}`,
|
|
855
|
+
funding.funded ? "The account already counts as funded." : "Nothing has arrived yet."
|
|
856
|
+
].join("\n");
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
function elapsedLabel(ms) {
|
|
860
|
+
const total = Math.floor(ms / 1e3);
|
|
861
|
+
const h = Math.floor(total / 3600);
|
|
862
|
+
const m = Math.floor(total % 3600 / 60);
|
|
863
|
+
const s = total % 60;
|
|
864
|
+
if (h > 0) return `${h}h${String(m).padStart(2, "0")}m`;
|
|
865
|
+
if (m > 0) return `${m}m${String(s).padStart(2, "0")}s`;
|
|
866
|
+
return `${s}s`;
|
|
867
|
+
}
|
|
804
868
|
async function cmdAgentsList(args, d) {
|
|
805
869
|
const { api } = await authed(args, d);
|
|
806
870
|
const { agents } = await api.get("/agents");
|