@haven_ai/sdk 0.1.36-alpha.0 → 0.2.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/dist/index.cjs +72 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +158 -12
- package/dist/index.d.ts +158 -12
- package/dist/index.js +66 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,13 @@ interface PaymentReceipt {
|
|
|
23
23
|
amount: string;
|
|
24
24
|
amountSek: string | null;
|
|
25
25
|
recipient: string;
|
|
26
|
+
/** @deprecated since #2907 — read `account`; removed in #2914 (the release after the naming window). Same value as `account`. */
|
|
26
27
|
safe: string;
|
|
28
|
+
/**
|
|
29
|
+
* The payer's smart-account address (#2907 twin of `safe`). Optional for
|
|
30
|
+
* the window: a server from before the twin emits `safe` only.
|
|
31
|
+
*/
|
|
32
|
+
account?: string;
|
|
27
33
|
chainId: number;
|
|
28
34
|
settledAt: string | null;
|
|
29
35
|
resourceUrl: string | null;
|
|
@@ -118,9 +124,10 @@ interface SignData {
|
|
|
118
124
|
hash: string;
|
|
119
125
|
/**
|
|
120
126
|
* Delegation rail: 'eip712_userop' (funding redemption) or
|
|
121
|
-
* 'eip712_delegation' (erc7710 settlement child).
|
|
122
|
-
* AllowanceModule
|
|
123
|
-
*
|
|
127
|
+
* 'eip712_delegation' (erc7710 settlement child). The backend spec makes it
|
|
128
|
+
* required; the legacy AllowanceModule reading — absent = raw ECDSA over
|
|
129
|
+
* `hash` — is retired (#2850), and the SDK client refuses an absent scheme.
|
|
130
|
+
* The session rail's 'eip191_userop' is retired (#834).
|
|
124
131
|
*
|
|
125
132
|
* When present, `hash` is NOT what gets signed — `typed_data` is (#1138).
|
|
126
133
|
*/
|
|
@@ -137,7 +144,14 @@ interface SignData {
|
|
|
137
144
|
};
|
|
138
145
|
/** Breakdown of values that were hashed — useful for debugging */
|
|
139
146
|
components: {
|
|
147
|
+
/** @deprecated #2908 — same value as `payer_account`; the server drops it at #2914. */
|
|
140
148
|
safe: string;
|
|
149
|
+
/**
|
|
150
|
+
* #2907 — the account-vocabulary twin of `safe`: the PAYER account
|
|
151
|
+
* (the user's smart account). Not to be confused with `account`, which on
|
|
152
|
+
* the funding shapes holds the DELEGATE account address.
|
|
153
|
+
*/
|
|
154
|
+
payer_account?: string;
|
|
141
155
|
token: string;
|
|
142
156
|
to: string;
|
|
143
157
|
amount: string;
|
|
@@ -521,6 +535,15 @@ interface HavenAgent {
|
|
|
521
535
|
id: string;
|
|
522
536
|
name: string;
|
|
523
537
|
status: string;
|
|
538
|
+
/**
|
|
539
|
+
* The agent's Haven account (smart account) address — #2908, the
|
|
540
|
+
* account-vocabulary name. Same value as {@link HavenAgent.safeAddress}.
|
|
541
|
+
*/
|
|
542
|
+
accountAddress: string;
|
|
543
|
+
/**
|
|
544
|
+
* @deprecated #2908 — same value as {@link HavenAgent.accountAddress}.
|
|
545
|
+
* Removed in the release after the one carrying #2908 (#2914).
|
|
546
|
+
*/
|
|
524
547
|
safeAddress: string;
|
|
525
548
|
delegateAddress: string;
|
|
526
549
|
chainId: number;
|
|
@@ -562,6 +585,12 @@ interface HavenAllowance {
|
|
|
562
585
|
}
|
|
563
586
|
interface HavenAllowanceSummary {
|
|
564
587
|
agentId: string;
|
|
588
|
+
/** #2908 — the account-vocabulary name; same value as `safeAddress`. */
|
|
589
|
+
accountAddress: string;
|
|
590
|
+
/**
|
|
591
|
+
* @deprecated #2908 — same value as {@link HavenAllowanceSummary.accountAddress}.
|
|
592
|
+
* Removed in the release after the one carrying #2908 (#2914).
|
|
593
|
+
*/
|
|
565
594
|
safeAddress: string;
|
|
566
595
|
delegateAddress: string;
|
|
567
596
|
chainId: number;
|
|
@@ -842,9 +871,14 @@ declare const AgentPaymentNextAction: {
|
|
|
842
871
|
*/
|
|
843
872
|
readonly PaymentWindowExpired: "payment_window_expired";
|
|
844
873
|
/**
|
|
845
|
-
* Stop and tell the user that the originating
|
|
874
|
+
* Stop and tell the user that the originating account needs to be funded or
|
|
846
875
|
* the agent's per-token allowance needs to be raised before the payment
|
|
847
876
|
* can succeed. A user approval will not fix this state on its own.
|
|
877
|
+
*
|
|
878
|
+
* #2908: the wire twin `fund_account_or_raise_allowance`
|
|
879
|
+
* ({@link AgentPaymentNextActionAccountAlias}) means the same thing; the
|
|
880
|
+
* server keeps emitting THIS value until #2914. Compare via
|
|
881
|
+
* {@link canonicalAgentPaymentNextAction}.
|
|
848
882
|
*/
|
|
849
883
|
readonly FundSafeOrRaiseAllowance: "fund_safe_or_raise_allowance";
|
|
850
884
|
/**
|
|
@@ -855,6 +889,39 @@ declare const AgentPaymentNextAction: {
|
|
|
855
889
|
readonly SweepStrandedFunds: "sweep_stranded_funds";
|
|
856
890
|
};
|
|
857
891
|
type AgentPaymentNextAction = (typeof AgentPaymentNextAction)[keyof typeof AgentPaymentNextAction];
|
|
892
|
+
/**
|
|
893
|
+
* #2908 (naming epic #2906): the account-vocabulary twin of
|
|
894
|
+
* {@link AgentPaymentNextAction.FundSafeOrRaiseAllowance}. The server ACCEPTS
|
|
895
|
+
* and DOCUMENTS this value from #2907 but keeps EMITTING the old one through
|
|
896
|
+
* the compatibility window; the emitted value flips at #2914.
|
|
897
|
+
*
|
|
898
|
+
* Deliberately declared beside `AgentPaymentNextAction` rather than inside
|
|
899
|
+
* it: the backend keeps a hand-mirror of that const, parity-pinned key-for-key
|
|
900
|
+
* and value-for-value (`agent-payment-taxonomy.parity.test.ts`), and the
|
|
901
|
+
* served `x-enumDescriptions` are the SDK's strings verbatim. Both consts
|
|
902
|
+
* move together at #2914; until then this alias is how a client handles both
|
|
903
|
+
* wire values without forking the taxonomy.
|
|
904
|
+
*/
|
|
905
|
+
declare const AgentPaymentNextActionAccountAlias: {
|
|
906
|
+
/** Account-vocabulary twin of `fund_safe_or_raise_allowance`; same meaning. */
|
|
907
|
+
readonly FundAccountOrRaiseAllowance: "fund_account_or_raise_allowance";
|
|
908
|
+
};
|
|
909
|
+
type AgentPaymentNextActionAccountAlias = (typeof AgentPaymentNextActionAccountAlias)[keyof typeof AgentPaymentNextActionAccountAlias];
|
|
910
|
+
/** Every `next_action` value a server may put on the wire during the #2908 window. */
|
|
911
|
+
type AgentPaymentNextActionWire = AgentPaymentNextAction | AgentPaymentNextActionAccountAlias;
|
|
912
|
+
/**
|
|
913
|
+
* Collapse the #2908 account-vocabulary alias onto its canonical taxonomy
|
|
914
|
+
* value, and pass every other value through untouched.
|
|
915
|
+
*
|
|
916
|
+
* This is the one seam a `switch` over `AgentPaymentNextAction` needs: a
|
|
917
|
+
* case on `FundSafeOrRaiseAllowance` matches a server that emits either
|
|
918
|
+
* spelling, and no case falls through because the alias arrived. Unknown
|
|
919
|
+
* strings are returned as-is (the SDK never invents a value), so the return
|
|
920
|
+
* type is exactly the input type widened by the canonical value.
|
|
921
|
+
*/
|
|
922
|
+
declare function canonicalAgentPaymentNextAction<T extends string | null | undefined>(value: T): Exclude<T, AgentPaymentNextActionAccountAlias> | typeof AgentPaymentNextAction.FundSafeOrRaiseAllowance;
|
|
923
|
+
/** True for EITHER spelling of the fund-or-raise-allowance next action (#2908). */
|
|
924
|
+
declare function isFundAccountOrRaiseAllowance(value: string | null | undefined): boolean;
|
|
858
925
|
declare const AgentPaymentFailureCode: {
|
|
859
926
|
/** A merchant-authoritative x402 price exceeds the caller's pre-funding max_amount cap. */
|
|
860
927
|
readonly PriceExceedsMax: "PRICE_EXCEEDS_MAX";
|
|
@@ -991,7 +1058,15 @@ interface AgentPaymentWarning {
|
|
|
991
1058
|
* (payment_required) are named in `reason` and taken from the SAME response.
|
|
992
1059
|
*/
|
|
993
1060
|
interface AgentNextStep {
|
|
994
|
-
|
|
1061
|
+
/**
|
|
1062
|
+
* From `AgentPaymentNextAction`, widened by the #2908 account-vocabulary
|
|
1063
|
+
* alias for the compatibility window: the hosted server keeps emitting
|
|
1064
|
+
* `fund_safe_or_raise_allowance` until #2914, but a client compiled against
|
|
1065
|
+
* this type must not reject `fund_account_or_raise_allowance` when the flip
|
|
1066
|
+
* lands. Compare through {@link canonicalAgentPaymentNextAction} or
|
|
1067
|
+
* {@link isFundAccountOrRaiseAllowance}, never by one literal.
|
|
1068
|
+
*/
|
|
1069
|
+
next_action: AgentPaymentNextActionWire;
|
|
995
1070
|
/**
|
|
996
1071
|
* Claude-family namespaced tool name for the next call
|
|
997
1072
|
* (`mcp__<server>__<tool>`), when one exists.
|
|
@@ -1630,7 +1705,8 @@ declare class HavenClient {
|
|
|
1630
1705
|
* Sign a payment's `sign_data` with the correct scheme for its rail.
|
|
1631
1706
|
*
|
|
1632
1707
|
* Dispatching on the server-provided scheme means a caller never has to
|
|
1633
|
-
* know which rail an account is on; an unknown scheme
|
|
1708
|
+
* know which rail an account is on; an unknown scheme — or an absent one,
|
|
1709
|
+
* since the legacy AllowanceModule rail retired (#2850) — is a hard error,
|
|
1634
1710
|
* never a guessed signature. The session rail's 'eip191_userop' is retired
|
|
1635
1711
|
* (#834) — the backend refuses those intents with HTTP 410 before any
|
|
1636
1712
|
* sign_data reaches a client, so encountering it here is a hard error too.
|
|
@@ -1738,8 +1814,10 @@ declare class HavenClient {
|
|
|
1738
1814
|
* allowance/budget summary a settle response carries.
|
|
1739
1815
|
*
|
|
1740
1816
|
* #1310/#1311 parity: this is the ONE home for logic that was duplicated
|
|
1741
|
-
* verbatim in
|
|
1742
|
-
*
|
|
1817
|
+
* verbatim in the hosted and local `haven_get_payment_status` handlers —
|
|
1818
|
+
* `packages/mcp-server/src/tools/state-direct-recovery.ts` since #2809 (it
|
|
1819
|
+
* was `packages/mcp-server/src/tools.ts` when this was written) and
|
|
1820
|
+
* `packages/mcp/src/tools.ts` — extracted
|
|
1743
1821
|
* here because both packages already depend on `@haven_ai/sdk` and call
|
|
1744
1822
|
* methods on a `HavenClient` instance, so this needed no new dependency
|
|
1745
1823
|
* edge. `funded_but_unsettled` is deliberately excluded: that phase means
|
|
@@ -2230,7 +2308,7 @@ declare const toolDescriptions: {
|
|
|
2230
2308
|
readonly getAgent: {
|
|
2231
2309
|
readonly summary: "Return the authenticated agent identity AND its live spend authority in one call: Haven wallet, delegate, chain, raw status, spend_authority_readiness, and per-token remaining allowance (atomic + human-readable). The recommended first call in a new session to confirm who you are and whether Haven will let you spend right now.";
|
|
2232
2310
|
readonly selectionGuidance: "Use this as the one-shot orientation/bootstrap at the start of a session, or whenever you need to confirm identity together with whether the agent can spend right now. For a detailed per-token breakdown (configured vs spent vs reset window) use haven_get_allowances.";
|
|
2233
|
-
readonly behavior: "Reads identity plus the live spend-authority snapshot in one shot — the agent's active on-chain budget delegation. spend_authority_readiness (readiness is a deprecated alias, same value) is \"ready\" when at least one token has remaining spend authority, \"needs_approval\" when the agent is active but has none, and \"revoked\" when the credential is not active. It covers hosted identity + on-chain spend authority ONLY — the hosted server cannot see the LOCAL signer, so \"ready\" does not mean the signer can start; verify the signer with a signer tool call or connect --doctor. An over-budget payment is declined before any money moves: there is no approval queue, so ask the owner to grant or raise the budget in Haven rather than waiting for an approval. allowances[] carries remainingAtomic and remainingDisplay per token. Identity fields
|
|
2311
|
+
readonly behavior: "Reads identity plus the live spend-authority snapshot in one shot — the agent's active on-chain budget delegation. spend_authority_readiness (readiness is a deprecated alias, same value) is \"ready\" when at least one token has remaining spend authority, \"needs_approval\" when the agent is active but has none, and \"revoked\" when the credential is not active. It covers hosted identity + on-chain spend authority ONLY — the hosted server cannot see the LOCAL signer, so \"ready\" does not mean the signer can start; verify the signer with a signer tool call or connect --doctor. An over-budget payment is declined before any money moves: there is no approval queue, so ask the owner to grant or raise the budget in Haven rather than waiting for an approval. allowances[] carries remainingAtomic and remainingDisplay per token. Identity fields: id, name, status, accountAddress (safeAddress: deprecated alias, same value), delegateAddress, chainId.";
|
|
2234
2312
|
readonly nextActionGuidance: "";
|
|
2235
2313
|
};
|
|
2236
2314
|
readonly getAllowances: {
|
|
@@ -2270,7 +2348,7 @@ declare const toolDescriptions: {
|
|
|
2270
2348
|
readonly nextActionGuidance: "Give the verify_token and the well-known instructions (from getCatalogSubmissionStatus) to the merchant so they can publish the proof line, then poll the submission status until it reaches verified_payable or failed.";
|
|
2271
2349
|
};
|
|
2272
2350
|
readonly sweep_delegate: {
|
|
2273
|
-
readonly summary: "Sweep stranded USDC and/or ETH from the delegate wallet back to the originating
|
|
2351
|
+
readonly summary: "Sweep stranded USDC and/or ETH from the delegate wallet back to the originating account.";
|
|
2274
2352
|
readonly selectionGuidance: string;
|
|
2275
2353
|
readonly behavior: string;
|
|
2276
2354
|
readonly nextActionGuidance: string;
|
|
@@ -2480,7 +2558,7 @@ declare const AGENT_README_SECTION_MD = "## Are you an AI agent whose user has n
|
|
|
2480
2558
|
* one or it has none. `?next=` / `?via=agent` / `?setup=` are the hand-off
|
|
2481
2559
|
* link shapes from #2522.
|
|
2482
2560
|
*/
|
|
2483
|
-
declare const 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@<channel> 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. The `<channel>` in that command is the tag your deployment names \u2014 read it from `/.well-known/haven.json` (`packages.cli.channel`), never a tag you pick. 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. `haven wallets funding` prints the address, the amount **and which chain** in one place; without a CLI session, the dashboard's funding card shows the address and amount and its Receive-funds screen names the chain. Read the chain off whichever you used and put it in your message \u2014 never assume one: a testnet deployment and production both call themselves Haven.\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## Budget changes later (second token, raise, revoke)\n\nThe first budget rides the setup above. 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 agents show <agentId>`.\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 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) \u00B7 [everything agent-readable](/llms.txt)\n";
|
|
2561
|
+
declare const 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@<channel> 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. The `<channel>` in that command is the tag your deployment names \u2014 read it from `/.well-known/haven.json` (`packages.cli.channel`), never a tag you pick. 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 (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## Budget changes later (second token, raise, revoke)\n\nThe first budget rides the setup above. 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 agents show <agentId>`.\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 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) \u00B7 [everything agent-readable](/llms.txt)\n";
|
|
2484
2562
|
/**
|
|
2485
2563
|
* The **onboarding prompt** — the whole-onboarding text the dashboard offers a
|
|
2486
2564
|
* signed-in user to paste to their agent (#2535, epic #2519).
|
|
@@ -2706,6 +2784,74 @@ interface UnsupportedNodeVersionMessageOptions {
|
|
|
2706
2784
|
*/
|
|
2707
2785
|
declare function unsupportedNodeVersionMessage(options: UnsupportedNodeVersionMessageOptions): string;
|
|
2708
2786
|
|
|
2787
|
+
/**
|
|
2788
|
+
* #2908 (naming epic #2906, phase 1): the account-vocabulary reads and the
|
|
2789
|
+
* dual-name emissions every published package shares during the one-release
|
|
2790
|
+
* compatibility window.
|
|
2791
|
+
*
|
|
2792
|
+
* The rule, stated once: READ both names and prefer the new; EMIT both names
|
|
2793
|
+
* with the same value; WRITE only the new. The old names on server responses
|
|
2794
|
+
* are removed by #2914, one release after the one that carries this module.
|
|
2795
|
+
* The credential-FILE fallbacks (`safe_address` / `safeAddress` in a file on
|
|
2796
|
+
* disk) are NOT part of that window — they are permanent, because a file that
|
|
2797
|
+
* was written before this release never rewrites itself.
|
|
2798
|
+
*
|
|
2799
|
+
* Kept as tiny pure functions so a reader has exactly one fallback chain per
|
|
2800
|
+
* shape and a test can mutate it: dropping the new name fails the new-shape
|
|
2801
|
+
* test, dropping the old name fails the old-shape test.
|
|
2802
|
+
*/
|
|
2803
|
+
/**
|
|
2804
|
+
* The account address off a snake_case server shape, new name first.
|
|
2805
|
+
*
|
|
2806
|
+
* `account_address` is the P0 (#2907) twin the server emits beside
|
|
2807
|
+
* `safe_address`; an older server emits only `safe_address`. A missing pair
|
|
2808
|
+
* resolves to `undefined` rather than an empty string so callers can tell
|
|
2809
|
+
* "absent" from "blank".
|
|
2810
|
+
*/
|
|
2811
|
+
declare function readAccountAddress(raw: {
|
|
2812
|
+
account_address?: string | null;
|
|
2813
|
+
safe_address?: string | null;
|
|
2814
|
+
}): string | undefined;
|
|
2815
|
+
/**
|
|
2816
|
+
* The account id off a snake_case server shape, new name first
|
|
2817
|
+
* (`account_id`, the #2907 twin of `safe_id`).
|
|
2818
|
+
*/
|
|
2819
|
+
declare function readAccountId(raw: {
|
|
2820
|
+
account_id?: string | null;
|
|
2821
|
+
safe_id?: string | null;
|
|
2822
|
+
}): string | undefined;
|
|
2823
|
+
/**
|
|
2824
|
+
* Both camelCase names for one address, for the SDK's public shapes (and the
|
|
2825
|
+
* hosted MCP outputs that spread them). Same value under both keys; the
|
|
2826
|
+
* `safeAddress` key is the deprecated one and goes at #2914.
|
|
2827
|
+
*/
|
|
2828
|
+
declare function accountAddressTwins(address: string | undefined): {
|
|
2829
|
+
accountAddress: string;
|
|
2830
|
+
safeAddress: string;
|
|
2831
|
+
};
|
|
2832
|
+
/**
|
|
2833
|
+
* The x402 receipt's `payer` off a funding-authorization response, in the
|
|
2834
|
+
* order the issue pins (#2908): the explicit `payer`, then the top-level
|
|
2835
|
+
* account address (new name, then old), then the `sign_data.components`
|
|
2836
|
+
* twins — `payer_account` (the #2907 twin) before `safe`.
|
|
2837
|
+
*
|
|
2838
|
+
* `components.account` is deliberately NOT in this chain: on the funding
|
|
2839
|
+
* shapes it holds the DELEGATE account address, a different address, and
|
|
2840
|
+
* reading it here would silently corrupt the receipt's payer.
|
|
2841
|
+
*/
|
|
2842
|
+
declare function readX402ReceiptPayer(raw: {
|
|
2843
|
+
payer?: string;
|
|
2844
|
+
account_address?: string;
|
|
2845
|
+
safe_address?: string;
|
|
2846
|
+
sign_data?: {
|
|
2847
|
+
components?: {
|
|
2848
|
+
payer_account?: string;
|
|
2849
|
+
safe?: string;
|
|
2850
|
+
account?: string;
|
|
2851
|
+
};
|
|
2852
|
+
};
|
|
2853
|
+
}): string | undefined;
|
|
2854
|
+
|
|
2709
2855
|
/**
|
|
2710
2856
|
* x402 protocol support for the Haven SDK.
|
|
2711
2857
|
*
|
|
@@ -3054,4 +3200,4 @@ declare function discoverMerchantMcpUrl(inputUrl: string): Promise<string | null
|
|
|
3054
3200
|
/** Trailing-slash/percent-case echoes compare equal; unparseable never does. */
|
|
3055
3201
|
declare function sameUrl(a: string, b: string): boolean;
|
|
3056
3202
|
|
|
3057
|
-
export { AGENT_APPROVAL_RELAY_JSON_SENTENCE, AGENT_APPROVAL_RELAY_PROSE_SENTENCE, AGENT_COMMAND_MODIFICATION_SENTENCE, AGENT_JSON_MODE_SENTENCE, AGENT_LOCAL_KEY_SENTENCE, AGENT_NETWORK_ACCESS_SENTENCE, AGENT_ONBOARDING_PROMPT, AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AGENT_README_SECTION_MD, AGENT_SECRET_HYGIENE_SENTENCE, AGENT_WIRING_COLLISION_RELAY_SENTENCE, type AgentNextStep, type AgentPaymentEnumSchema, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, type AgentPaymentSummary, type AgentPaymentWarning, AgentPaymentWarningCode, type AgentPurchaseSummary, CONNECTOR_PACKAGE_NAME, type CatalogSubmissionAccepted, type ClaudeTool, DEFAULT_CONFIRMATION_TIMEOUT_MS, DISCOVERY_MAX_BYTES, ERC7710_ASSET_TRANSFER_METHOD, HAVEN_AGENT_RUNBOOK_MD, HAVEN_CONNECTOR_CHANNEL, HAVEN_MINIMUM_NODE_VERSION, HAVEN_SKILL_BODY_MD, HAVEN_SKILL_MD, type HavenAgent, type HavenAgentAllowanceSummary, type HavenAgentReadiness, type HavenAgentSummary, type HavenAllowance, type HavenAllowanceSummary, HavenApiError, type HavenCatalogEntry, type HavenCatalogSubmission, HavenClient, type HavenClientConfig, HavenError, type HavenPaymentReceipt, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, HavenUnsupportedSignerVersionError, MERCHANT_DISCOVERY_PATHS, type MachinePaymentRail, MerchantTimeoutError, type OpenAITool, type PaymentFee, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentReceipt, type PaymentRequest, type PaymentResult, type PaymentResumeState, type PaymentStatus, type PaymentStatusResult, type PostPurchaseAllowanceSummary, RECEIPT_VERSION, type ReceiptVerification, type ResumeAuthorizedX402Input, type ResumeX402PaymentInput, SIGNER_UPDATE_FALLBACK, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, type SharedToolKey, type SignData, SignerRefusalCode, type SweepAuthorization, type SweepConfirmation, type SweepEip712Domain, type SweepEntry, type SweepExpectedAuth, type SweepPreparation, type SweepPrepareResponse, type SweepResult, type SweepSubmitResponse, type SweepSubmitResult, type SweepTypedData, TRANSFER_WITH_AUTHORIZATION_TYPES, type ToolDescription, type UnsupportedNodeVersionMessageOptions, X402AlreadySettledError, type X402AuthorizationOptions, type X402Erc7710Settlement, type X402ExpectedAuth, type X402ExpectedContext, type X402Intent, type X402McpCallContext, type X402McpTransport, type X402MerchantCallContext, type X402MerchantOutcome, type X402MerchantOutcomeReport, type X402PaymentHeaderContext, X402PaymentHeaderValidationError, type X402PaymentOption, type X402PaymentRequired, type X402Quote, type X402Receipt, type X402RequestSnapshot, type X402ResumeState, type X402SchemeSelection, X402UnexpectedStatusError, X402_LEGACY_PAYMENT_HEADER_NAME, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_PAYMENT_HEADER_NAME, X402_PAYMENT_HEADER_NAMES_SENT, X402_PAYMENT_REQUIRED_HEADER_NAME, X402_PAYMENT_RESPONSE_HEADER_NAME, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, addressFromKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, compareNodeVersions, composeDescription, connectorRerunCommand, connectorSpec, decodeBase64Json, decodeBase64Utf8, discoverMerchantMcpUrl, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, havenTools, isConnectorChannel, isErc7710Option, isSupportedNodeVersion, isSweepableChain, normalizePaymentRequired, parsePaymentRequired, parsePaymentRequiredResponse, resolveConnectorChannel, resolveTokenFromAddress, sameUrl, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, signHash, signUserOpTypedDataForDelegation, signerUpdateFallback, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, verifyPaymentReceipt, verifySignature, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses, x402V2PaymentEnvelope };
|
|
3203
|
+
export { AGENT_APPROVAL_RELAY_JSON_SENTENCE, AGENT_APPROVAL_RELAY_PROSE_SENTENCE, AGENT_COMMAND_MODIFICATION_SENTENCE, AGENT_JSON_MODE_SENTENCE, AGENT_LOCAL_KEY_SENTENCE, AGENT_NETWORK_ACCESS_SENTENCE, AGENT_ONBOARDING_PROMPT, AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AGENT_README_SECTION_MD, AGENT_SECRET_HYGIENE_SENTENCE, AGENT_WIRING_COLLISION_RELAY_SENTENCE, type AgentNextStep, type AgentPaymentEnumSchema, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionAccountAlias, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, type AgentPaymentNextActionWire, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, type AgentPaymentSummary, type AgentPaymentWarning, AgentPaymentWarningCode, type AgentPurchaseSummary, CONNECTOR_PACKAGE_NAME, type CatalogSubmissionAccepted, type ClaudeTool, DEFAULT_CONFIRMATION_TIMEOUT_MS, DISCOVERY_MAX_BYTES, ERC7710_ASSET_TRANSFER_METHOD, HAVEN_AGENT_RUNBOOK_MD, HAVEN_CONNECTOR_CHANNEL, HAVEN_MINIMUM_NODE_VERSION, HAVEN_SKILL_BODY_MD, HAVEN_SKILL_MD, type HavenAgent, type HavenAgentAllowanceSummary, type HavenAgentReadiness, type HavenAgentSummary, type HavenAllowance, type HavenAllowanceSummary, HavenApiError, type HavenCatalogEntry, type HavenCatalogSubmission, HavenClient, type HavenClientConfig, HavenError, type HavenPaymentReceipt, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, HavenUnsupportedSignerVersionError, MERCHANT_DISCOVERY_PATHS, type MachinePaymentRail, MerchantTimeoutError, type OpenAITool, type PaymentFee, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentReceipt, type PaymentRequest, type PaymentResult, type PaymentResumeState, type PaymentStatus, type PaymentStatusResult, type PostPurchaseAllowanceSummary, RECEIPT_VERSION, type ReceiptVerification, type ResumeAuthorizedX402Input, type ResumeX402PaymentInput, SIGNER_UPDATE_FALLBACK, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, type SharedToolKey, type SignData, SignerRefusalCode, type SweepAuthorization, type SweepConfirmation, type SweepEip712Domain, type SweepEntry, type SweepExpectedAuth, type SweepPreparation, type SweepPrepareResponse, type SweepResult, type SweepSubmitResponse, type SweepSubmitResult, type SweepTypedData, TRANSFER_WITH_AUTHORIZATION_TYPES, type ToolDescription, type UnsupportedNodeVersionMessageOptions, X402AlreadySettledError, type X402AuthorizationOptions, type X402Erc7710Settlement, type X402ExpectedAuth, type X402ExpectedContext, type X402Intent, type X402McpCallContext, type X402McpTransport, type X402MerchantCallContext, type X402MerchantOutcome, type X402MerchantOutcomeReport, type X402PaymentHeaderContext, X402PaymentHeaderValidationError, type X402PaymentOption, type X402PaymentRequired, type X402Quote, type X402Receipt, type X402RequestSnapshot, type X402ResumeState, type X402SchemeSelection, X402UnexpectedStatusError, X402_LEGACY_PAYMENT_HEADER_NAME, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_PAYMENT_HEADER_NAME, X402_PAYMENT_HEADER_NAMES_SENT, X402_PAYMENT_REQUIRED_HEADER_NAME, X402_PAYMENT_RESPONSE_HEADER_NAME, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, accountAddressTwins, addressFromKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, canonicalAgentPaymentNextAction, compareNodeVersions, composeDescription, connectorRerunCommand, connectorSpec, decodeBase64Json, decodeBase64Utf8, discoverMerchantMcpUrl, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, havenTools, isConnectorChannel, isErc7710Option, isFundAccountOrRaiseAllowance, isSupportedNodeVersion, isSweepableChain, normalizePaymentRequired, parsePaymentRequired, parsePaymentRequiredResponse, readAccountAddress, readAccountId, readX402ReceiptPayer, resolveConnectorChannel, resolveTokenFromAddress, sameUrl, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, signHash, signUserOpTypedDataForDelegation, signerUpdateFallback, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, verifyPaymentReceipt, verifySignature, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses, x402V2PaymentEnvelope };
|
package/dist/index.js
CHANGED
|
@@ -108,9 +108,14 @@ var AgentPaymentNextAction = {
|
|
|
108
108
|
*/
|
|
109
109
|
PaymentWindowExpired: "payment_window_expired",
|
|
110
110
|
/**
|
|
111
|
-
* Stop and tell the user that the originating
|
|
111
|
+
* Stop and tell the user that the originating account needs to be funded or
|
|
112
112
|
* the agent's per-token allowance needs to be raised before the payment
|
|
113
113
|
* can succeed. A user approval will not fix this state on its own.
|
|
114
|
+
*
|
|
115
|
+
* #2908: the wire twin `fund_account_or_raise_allowance`
|
|
116
|
+
* ({@link AgentPaymentNextActionAccountAlias}) means the same thing; the
|
|
117
|
+
* server keeps emitting THIS value until #2914. Compare via
|
|
118
|
+
* {@link canonicalAgentPaymentNextAction}.
|
|
114
119
|
*/
|
|
115
120
|
FundSafeOrRaiseAllowance: "fund_safe_or_raise_allowance",
|
|
116
121
|
/**
|
|
@@ -120,6 +125,19 @@ var AgentPaymentNextAction = {
|
|
|
120
125
|
*/
|
|
121
126
|
SweepStrandedFunds: "sweep_stranded_funds"
|
|
122
127
|
};
|
|
128
|
+
var AgentPaymentNextActionAccountAlias = {
|
|
129
|
+
/** Account-vocabulary twin of `fund_safe_or_raise_allowance`; same meaning. */
|
|
130
|
+
FundAccountOrRaiseAllowance: "fund_account_or_raise_allowance"
|
|
131
|
+
};
|
|
132
|
+
function canonicalAgentPaymentNextAction(value) {
|
|
133
|
+
if (value === AgentPaymentNextActionAccountAlias.FundAccountOrRaiseAllowance) {
|
|
134
|
+
return AgentPaymentNextAction.FundSafeOrRaiseAllowance;
|
|
135
|
+
}
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
function isFundAccountOrRaiseAllowance(value) {
|
|
139
|
+
return value === AgentPaymentNextAction.FundSafeOrRaiseAllowance || value === AgentPaymentNextActionAccountAlias.FundAccountOrRaiseAllowance;
|
|
140
|
+
}
|
|
123
141
|
var AgentPaymentFailureCode = {
|
|
124
142
|
/** A merchant-authoritative x402 price exceeds the caller's pre-funding max_amount cap. */
|
|
125
143
|
PriceExceedsMax: "PRICE_EXCEEDS_MAX",
|
|
@@ -1126,7 +1144,10 @@ function mapPaymentStatusResult(raw) {
|
|
|
1126
1144
|
rail: raw.rail,
|
|
1127
1145
|
status: raw.status,
|
|
1128
1146
|
phase: raw.phase,
|
|
1129
|
-
|
|
1147
|
+
// #2908: the account-vocabulary alias collapses onto the canonical value
|
|
1148
|
+
// so every `=== AgentPaymentNextAction.X` downstream keeps working when
|
|
1149
|
+
// the server flips its emit at #2914.
|
|
1150
|
+
nextAction: canonicalAgentPaymentNextAction(raw.next_action),
|
|
1130
1151
|
amount: raw.amount,
|
|
1131
1152
|
token: raw.token,
|
|
1132
1153
|
resourceUrl: raw.resource_url,
|
|
@@ -1258,7 +1279,7 @@ function messageForState(label, status, paymentId, nextAction) {
|
|
|
1258
1279
|
function paymentStateFromRaw(label, raw) {
|
|
1259
1280
|
if (!raw.payment_id || !raw.status) return null;
|
|
1260
1281
|
const phase = raw.phase ?? phaseForStatus(raw.status);
|
|
1261
|
-
const nextAction = raw.next_action ?? nextActionForStatus(raw.status);
|
|
1282
|
+
const nextAction = canonicalAgentPaymentNextAction(raw.next_action) ?? nextActionForStatus(raw.status);
|
|
1262
1283
|
if (!phase || !nextAction) return null;
|
|
1263
1284
|
const amount = raw.amount ?? raw.requested ?? "";
|
|
1264
1285
|
const token = raw.token ?? "";
|
|
@@ -1581,6 +1602,20 @@ function verifyPaymentReceipt(receipt, recover = defaultRecover) {
|
|
|
1581
1602
|
return { verified: true, recoveredSigner: recovered };
|
|
1582
1603
|
}
|
|
1583
1604
|
|
|
1605
|
+
// src/account-naming.ts
|
|
1606
|
+
function readAccountAddress(raw) {
|
|
1607
|
+
return raw.account_address ?? raw.safe_address ?? void 0;
|
|
1608
|
+
}
|
|
1609
|
+
function readAccountId(raw) {
|
|
1610
|
+
return raw.account_id ?? raw.safe_id ?? void 0;
|
|
1611
|
+
}
|
|
1612
|
+
function accountAddressTwins(address) {
|
|
1613
|
+
return { accountAddress: address, safeAddress: address };
|
|
1614
|
+
}
|
|
1615
|
+
function readX402ReceiptPayer(raw) {
|
|
1616
|
+
return raw.payer ?? raw.account_address ?? raw.sign_data?.components?.payer_account ?? raw.safe_address ?? raw.sign_data?.components?.safe;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1584
1619
|
// src/account-reads.ts
|
|
1585
1620
|
function safeBigInt(value) {
|
|
1586
1621
|
try {
|
|
@@ -1639,7 +1674,10 @@ var AccountReads = class {
|
|
|
1639
1674
|
const raw = await this.transport.get("/machine-payments/allowances");
|
|
1640
1675
|
return {
|
|
1641
1676
|
agentId: raw.agent_id,
|
|
1642
|
-
|
|
1677
|
+
// #2908: one mapper, both names, same value — `readAccountAddress`
|
|
1678
|
+
// prefers the server's `account_address` twin and falls back to
|
|
1679
|
+
// `safe_address` for a pre-#2907 server.
|
|
1680
|
+
...accountAddressTwins(readAccountAddress(raw)),
|
|
1643
1681
|
delegateAddress: raw.delegate_address,
|
|
1644
1682
|
chainId: raw.chain_id,
|
|
1645
1683
|
allowances: raw.allowances.map((allowance) => ({
|
|
@@ -1728,7 +1766,10 @@ var AccountReads = class {
|
|
|
1728
1766
|
id: raw.id,
|
|
1729
1767
|
name: raw.name,
|
|
1730
1768
|
status: raw.status,
|
|
1731
|
-
|
|
1769
|
+
// #2908: both camelCase names off whichever snake_case name the server
|
|
1770
|
+
// sent (new first). The hosted MCP's `haven_get_agent` spreads this
|
|
1771
|
+
// object, so this is also the hosted output's dual-emit point.
|
|
1772
|
+
...accountAddressTwins(readAccountAddress(raw)),
|
|
1732
1773
|
delegateAddress: raw.delegate_address,
|
|
1733
1774
|
chainId: raw.chain_id,
|
|
1734
1775
|
executionRail: raw.execution_rail === "delegation" ? "delegation" : "legacy"
|
|
@@ -1778,7 +1819,7 @@ var DelegateSweepApi = class {
|
|
|
1778
1819
|
const contract = createErc20Contract(sweepUsdcAddress(agent.chainId), ["function balanceOf(address) view returns (uint256)", "function transfer(address to, uint256 amount) returns (bool)"], wallet);
|
|
1779
1820
|
const balance2 = await contract.balanceOf(agent.delegateAddress);
|
|
1780
1821
|
if (balance2 > 0n) {
|
|
1781
|
-
const tx = await contract.transfer(agent.
|
|
1822
|
+
const tx = await contract.transfer(agent.accountAddress, balance2);
|
|
1782
1823
|
const { txHash, confirmation } = await waitForSweepTx(tx);
|
|
1783
1824
|
transfers.push({ asset: "USDC", amount: format(balance2, 6), amountAtomic: balance2.toString(), txHash, explorerUrl: this.options.buildExplorerUrl(agent.chainId, txHash), confirmation });
|
|
1784
1825
|
}
|
|
@@ -1788,12 +1829,12 @@ var DelegateSweepApi = class {
|
|
|
1788
1829
|
const fee = await provider.getFeeData();
|
|
1789
1830
|
const send = balance - (fee.maxFeePerGas ?? fee.gasPrice ?? 1000000n) * 21000n * 2n;
|
|
1790
1831
|
if (send > 0n) {
|
|
1791
|
-
const tx = await wallet.sendTransaction({ to: agent.
|
|
1832
|
+
const tx = await wallet.sendTransaction({ to: agent.accountAddress, value: send });
|
|
1792
1833
|
const { txHash, confirmation } = await waitForSweepTx(tx);
|
|
1793
1834
|
transfers.push({ asset: "ETH", amount: format(send, 18), amountAtomic: send.toString(), txHash, explorerUrl: this.options.buildExplorerUrl(agent.chainId, txHash), confirmation });
|
|
1794
1835
|
}
|
|
1795
1836
|
}
|
|
1796
|
-
return { fromAddress: agent.delegateAddress, toAddress: agent.
|
|
1837
|
+
return { fromAddress: agent.delegateAddress, toAddress: agent.accountAddress, chainId: agent.chainId, transfers, unconfirmed: transfers.some((t) => t.confirmation === "unconfirmed") };
|
|
1797
1838
|
}
|
|
1798
1839
|
prepareSweep() {
|
|
1799
1840
|
return this.options.transport.post("/machine-payments/sweep/prepare", {});
|
|
@@ -2187,7 +2228,7 @@ var X402FundingLeg = class {
|
|
|
2187
2228
|
const to = execResult?.to ?? raw.to ?? this.delegateAddress ?? "";
|
|
2188
2229
|
const explorerUrl = execResult?.explorer_url ?? raw.explorer_url ?? explorerUrlOrEmpty(chainId, txHash);
|
|
2189
2230
|
const merchantTo = execResult?.merchant_to ?? raw.merchant_to ?? option.payTo;
|
|
2190
|
-
const payer = raw
|
|
2231
|
+
const payer = readX402ReceiptPayer(raw);
|
|
2191
2232
|
return buildX402Receipt({
|
|
2192
2233
|
paymentId: raw.payment_id,
|
|
2193
2234
|
txHash,
|
|
@@ -3182,7 +3223,8 @@ var HavenClient = class {
|
|
|
3182
3223
|
* Sign a payment's `sign_data` with the correct scheme for its rail.
|
|
3183
3224
|
*
|
|
3184
3225
|
* Dispatching on the server-provided scheme means a caller never has to
|
|
3185
|
-
* know which rail an account is on; an unknown scheme
|
|
3226
|
+
* know which rail an account is on; an unknown scheme — or an absent one,
|
|
3227
|
+
* since the legacy AllowanceModule rail retired (#2850) — is a hard error,
|
|
3186
3228
|
* never a guessed signature. The session rail's 'eip191_userop' is retired
|
|
3187
3229
|
* (#834) — the backend refuses those intents with HTTP 410 before any
|
|
3188
3230
|
* sign_data reaches a client, so encountering it here is a hard error too.
|
|
@@ -3216,7 +3258,9 @@ var HavenClient = class {
|
|
|
3216
3258
|
return signSettlementDelegationTypedData(this.delegateKey, signData.typed_data);
|
|
3217
3259
|
}
|
|
3218
3260
|
if (scheme === void 0) {
|
|
3219
|
-
|
|
3261
|
+
throw new HavenSigningError(
|
|
3262
|
+
"sign_data.signature_scheme is required \u2014 the legacy AllowanceModule rail that signed the bare hash is retired (#2850). Refusing to guess a signing scheme."
|
|
3263
|
+
);
|
|
3220
3264
|
}
|
|
3221
3265
|
throw new HavenSigningError(
|
|
3222
3266
|
`Unknown sign_data.signature_scheme '${scheme}' \u2014 refusing to guess a signing scheme. Update @haven_ai/sdk.`
|
|
@@ -3346,8 +3390,10 @@ var HavenClient = class {
|
|
|
3346
3390
|
* allowance/budget summary a settle response carries.
|
|
3347
3391
|
*
|
|
3348
3392
|
* #1310/#1311 parity: this is the ONE home for logic that was duplicated
|
|
3349
|
-
* verbatim in
|
|
3350
|
-
*
|
|
3393
|
+
* verbatim in the hosted and local `haven_get_payment_status` handlers —
|
|
3394
|
+
* `packages/mcp-server/src/tools/state-direct-recovery.ts` since #2809 (it
|
|
3395
|
+
* was `packages/mcp-server/src/tools.ts` when this was written) and
|
|
3396
|
+
* `packages/mcp/src/tools.ts` — extracted
|
|
3351
3397
|
* here because both packages already depend on `@haven_ai/sdk` and call
|
|
3352
3398
|
* methods on a `HavenClient` instance, so this needed no new dependency
|
|
3353
3399
|
* edge. `funded_but_unsettled` is deliberately excluded: that phase means
|
|
@@ -4015,13 +4061,13 @@ var toolDescriptions = {
|
|
|
4015
4061
|
summary: "Pay an inspected x402 quote. The delegate key signs locally; Haven only validates and relays signed, on-chain-constrained payment transactions.",
|
|
4016
4062
|
selectionGuidance: "Do not use this for read-only allowance, budget, spend-limit, remaining-amount, reset-period, or what-can-I-spend questions; use the allowance lookup tool instead.",
|
|
4017
4063
|
behavior: "Signs the payment locally and returns the merchant response. Settlement is either direct account-to-merchant with no funding leg, or a bridge that first redeems the agent's budget delegation to fund the delegate wallet for an EIP-3009 authorization. A payment outside the on-chain budget is declined before any money moves; nothing is queued for a human to approve later.",
|
|
4018
|
-
nextActionGuidance: "Preserve the returned resume_state \u2014 it identifies this payment if you need to ask about it later. This tool performs the merchant retry itself, so do not wait on a signal while the call is in flight. If the process crashes after this call and a later haven_get_payment_status reports nextAction=retry_original_x402_request, Haven's funding leg confirmed but no merchant response was ever recorded \u2014 call the resume tool with the preserved resume_state or payment_id instead of paying again. If the response carries phase=insufficient_funds and nextAction=fund_safe_or_raise_allowance, the payment cannot be retried until the account is funded or the agent budget raised \u2014 stop and tell the user the shortfall reported on the response."
|
|
4064
|
+
nextActionGuidance: "Preserve the returned resume_state \u2014 it identifies this payment if you need to ask about it later. This tool performs the merchant retry itself, so do not wait on a signal while the call is in flight. If the process crashes after this call and a later haven_get_payment_status reports nextAction=retry_original_x402_request, Haven's funding leg confirmed but no merchant response was ever recorded \u2014 call the resume tool with the preserved resume_state or payment_id instead of paying again. If the response carries phase=insufficient_funds and nextAction=fund_safe_or_raise_allowance (or fund_account_or_raise_allowance), the payment cannot be retried until the account is funded or the agent budget raised \u2014 stop and tell the user the shortfall reported on the response."
|
|
4019
4065
|
},
|
|
4020
4066
|
payX402OneShot: {
|
|
4021
4067
|
summary: "Fetch an x402 paid HTTP resource in a single call. Handles the full probe -> pay -> retry round trip and returns the merchant response.",
|
|
4022
4068
|
selectionGuidance: "Prefer this over the quote+pay split when the agent just wants the paid resource and does not need to inspect the price first. If you already have a quote from haven_quote_x402, use haven_pay_x402_quote instead. Do not use for read-only allowance, budget, spend-limit, remaining-amount, reset-period, or what-can-I-spend questions; use the allowance lookup tool instead.",
|
|
4023
4069
|
behavior: "Calls the URL, parses any HTTP 402 x402 challenge, signs the payment locally, then retries the original request with the signed payment header (sent under PAYMENT-SIGNATURE, plus the legacy X-PAYMENT on the EIP-3009 path only) and returns the merchant response. Settlement is either direct account-to-merchant with no funding leg, or a bridge that first redeems the agent's budget delegation to fund the delegate wallet for an EIP-3009 authorization. A payment outside the on-chain budget is declined before any money moves; nothing is queued for a human to approve later. If the resource returns a non-402 status, returns it unchanged without contacting Haven.",
|
|
4024
|
-
nextActionGuidance: "Preserve the returned resume_state or paymentId \u2014 either identifies this payment if you need to ask about it later. This tool performs the merchant retry itself, so do not wait on a signal while the call is in flight. If the process crashes after this call and a later haven_get_payment_status reports nextAction=retry_original_x402_request, Haven's funding leg confirmed but no merchant response was ever recorded \u2014 call the resume tool with the preserved resume_state or payment_id instead of paying again. If the response carries phase=insufficient_funds and nextAction=fund_safe_or_raise_allowance, the payment cannot be retried until the account is funded or the agent budget raised \u2014 stop and tell the user the shortfall reported on the response."
|
|
4070
|
+
nextActionGuidance: "Preserve the returned resume_state or paymentId \u2014 either identifies this payment if you need to ask about it later. This tool performs the merchant retry itself, so do not wait on a signal while the call is in flight. If the process crashes after this call and a later haven_get_payment_status reports nextAction=retry_original_x402_request, Haven's funding leg confirmed but no merchant response was ever recorded \u2014 call the resume tool with the preserved resume_state or payment_id instead of paying again. If the response carries phase=insufficient_funds and nextAction=fund_safe_or_raise_allowance (or fund_account_or_raise_allowance), the payment cannot be retried until the account is funded or the agent budget raised \u2014 stop and tell the user the shortfall reported on the response."
|
|
4025
4071
|
},
|
|
4026
4072
|
resumeX402: {
|
|
4027
4073
|
summary: "Resume an x402 payment whose Haven-side authorization already succeeded but whose merchant retry did not complete.",
|
|
@@ -4045,7 +4091,7 @@ var toolDescriptions = {
|
|
|
4045
4091
|
getAgent: {
|
|
4046
4092
|
summary: "Return the authenticated agent identity AND its live spend authority in one call: Haven wallet, delegate, chain, raw status, spend_authority_readiness, and per-token remaining allowance (atomic + human-readable). The recommended first call in a new session to confirm who you are and whether Haven will let you spend right now.",
|
|
4047
4093
|
selectionGuidance: "Use this as the one-shot orientation/bootstrap at the start of a session, or whenever you need to confirm identity together with whether the agent can spend right now. For a detailed per-token breakdown (configured vs spent vs reset window) use haven_get_allowances.",
|
|
4048
|
-
behavior: `Reads identity plus the live spend-authority snapshot in one shot \u2014 the agent's active on-chain budget delegation. spend_authority_readiness (readiness is a deprecated alias, same value) is "ready" when at least one token has remaining spend authority, "needs_approval" when the agent is active but has none, and "revoked" when the credential is not active. It covers hosted identity + on-chain spend authority ONLY \u2014 the hosted server cannot see the LOCAL signer, so "ready" does not mean the signer can start; verify the signer with a signer tool call or connect --doctor. An over-budget payment is declined before any money moves: there is no approval queue, so ask the owner to grant or raise the budget in Haven rather than waiting for an approval. allowances[] carries remainingAtomic and remainingDisplay per token. Identity fields
|
|
4094
|
+
behavior: `Reads identity plus the live spend-authority snapshot in one shot \u2014 the agent's active on-chain budget delegation. spend_authority_readiness (readiness is a deprecated alias, same value) is "ready" when at least one token has remaining spend authority, "needs_approval" when the agent is active but has none, and "revoked" when the credential is not active. It covers hosted identity + on-chain spend authority ONLY \u2014 the hosted server cannot see the LOCAL signer, so "ready" does not mean the signer can start; verify the signer with a signer tool call or connect --doctor. An over-budget payment is declined before any money moves: there is no approval queue, so ask the owner to grant or raise the budget in Haven rather than waiting for an approval. allowances[] carries remainingAtomic and remainingDisplay per token. Identity fields: id, name, status, accountAddress (safeAddress: deprecated alias, same value), delegateAddress, chainId.`,
|
|
4049
4095
|
nextActionGuidance: ""
|
|
4050
4096
|
},
|
|
4051
4097
|
getAllowances: {
|
|
@@ -4085,9 +4131,9 @@ var toolDescriptions = {
|
|
|
4085
4131
|
nextActionGuidance: "Give the verify_token and the well-known instructions (from getCatalogSubmissionStatus) to the merchant so they can publish the proof line, then poll the submission status until it reaches verified_payable or failed."
|
|
4086
4132
|
},
|
|
4087
4133
|
sweep_delegate: {
|
|
4088
|
-
summary: "Sweep stranded USDC and/or ETH from the delegate wallet back to the originating
|
|
4134
|
+
summary: "Sweep stranded USDC and/or ETH from the delegate wallet back to the originating account.",
|
|
4089
4135
|
selectionGuidance: "Use this when the user instructs you to recover stranded funds on the delegate wallet, or when a payment status returns nextAction=sweep_stranded_funds. Do NOT use for normal payments \u2014 use haven_pay_x402. Do NOT use to read balances only \u2014 use haven_get_allowances.",
|
|
4090
|
-
behavior: `Reads the delegate EOA's on-chain USDC and ETH balances. For each non-zero balance, signs and submits a transfer from the delegate EOA to the originating
|
|
4136
|
+
behavior: `Reads the delegate EOA's on-chain USDC and ETH balances. For each non-zero balance, signs and submits a transfer from the delegate EOA to the originating account (hardcoded destination). The delegate key signs locally \u2014 Haven never sees it and the backend never constructs signed transactions (CASP/MiCA Red Line #2). Returns tx hashes and recovered amounts. Returns an empty transfers list when nothing is stranded. Each transfer carries confirmation: "confirmed" (a receipt was seen \u2014 the funds are in the account) or "unconfirmed" (broadcast but not confirmed within 90 seconds \u2014 still in the mempool, may still land). The top-level unconfirmed flag is true when any transfer is unconfirmed.`,
|
|
4091
4137
|
nextActionGuidance: 'If transfers is non-empty, confirm the amounts with the user. Report a transfer as recovered ONLY when its confirmation is "confirmed". For an "unconfirmed" transfer, tell the user it was submitted but not yet confirmed, give them its txHash and explorerUrl to check, and do not re-run the sweep immediately \u2014 a re-run after it lands will simply find nothing stranded.'
|
|
4092
4138
|
},
|
|
4093
4139
|
send: {
|
|
@@ -4346,7 +4392,7 @@ Your user gives you a **budget on their own account** \u2014 not their wallet, a
|
|
|
4346
4392
|
Four 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.
|
|
4347
4393
|
|
|
4348
4394
|
1. **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@<channel> 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. The \`<channel>\` in that command is the tag your deployment names \u2014 read it from \`/.well-known/haven.json\` (\`packages.cli.channel\`), never a tag you pick. 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.
|
|
4349
|
-
2. **HUMAN \u2014 fund it.** USDC only, no ETH: Haven sponsors the gas. \`haven wallets funding\` prints the address, the amount
|
|
4395
|
+
2. **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.
|
|
4350
4396
|
3. **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.
|
|
4351
4397
|
4. **YOU \u2014 run the connector command** in that prompt (below). It makes your signing key locally, registering only the public address.
|
|
4352
4398
|
5. **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.
|
|
@@ -4812,6 +4858,6 @@ function sameUrl(a, b) {
|
|
|
4812
4858
|
}
|
|
4813
4859
|
}
|
|
4814
4860
|
|
|
4815
|
-
export { AGENT_APPROVAL_RELAY_JSON_SENTENCE, AGENT_APPROVAL_RELAY_PROSE_SENTENCE, AGENT_COMMAND_MODIFICATION_SENTENCE, AGENT_JSON_MODE_SENTENCE, AGENT_LOCAL_KEY_SENTENCE, AGENT_NETWORK_ACCESS_SENTENCE, AGENT_ONBOARDING_PROMPT, AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AGENT_README_SECTION_MD, AGENT_SECRET_HYGIENE_SENTENCE, AGENT_WIRING_COLLISION_RELAY_SENTENCE, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, AgentPaymentWarningCode, CONNECTOR_PACKAGE_NAME, DEFAULT_CONFIRMATION_TIMEOUT_MS, DISCOVERY_MAX_BYTES, ERC7710_ASSET_TRANSFER_METHOD, HAVEN_AGENT_RUNBOOK_MD, HAVEN_CONNECTOR_CHANNEL, HAVEN_MINIMUM_NODE_VERSION, HAVEN_SKILL_BODY_MD, HAVEN_SKILL_MD, HavenApiError, HavenClient, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, HavenUnsupportedSignerVersionError, MERCHANT_DISCOVERY_PATHS, MerchantTimeoutError, RECEIPT_VERSION, SIGNER_UPDATE_FALLBACK, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, SignerRefusalCode, TRANSFER_WITH_AUTHORIZATION_TYPES, X402AlreadySettledError, X402PaymentHeaderValidationError, X402UnexpectedStatusError, X402_LEGACY_PAYMENT_HEADER_NAME, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_PAYMENT_HEADER_NAME, X402_PAYMENT_HEADER_NAMES_SENT, X402_PAYMENT_REQUIRED_HEADER_NAME, X402_PAYMENT_RESPONSE_HEADER_NAME, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, addressFromKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, compareNodeVersions, composeDescription, connectorRerunCommand, connectorSpec, decodeBase64Json, decodeBase64Utf8, discoverMerchantMcpUrl, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, havenTools, isConnectorChannel, isErc7710Option, isSupportedNodeVersion, isSweepableChain, normalizePaymentRequired, parsePaymentRequired, parsePaymentRequiredResponse, resolveConnectorChannel, resolveTokenFromAddress, sameUrl, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, signHash, signUserOpTypedDataForDelegation, signerUpdateFallback, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, verifyPaymentReceipt, verifySignature, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses, x402V2PaymentEnvelope };
|
|
4861
|
+
export { AGENT_APPROVAL_RELAY_JSON_SENTENCE, AGENT_APPROVAL_RELAY_PROSE_SENTENCE, AGENT_COMMAND_MODIFICATION_SENTENCE, AGENT_JSON_MODE_SENTENCE, AGENT_LOCAL_KEY_SENTENCE, AGENT_NETWORK_ACCESS_SENTENCE, AGENT_ONBOARDING_PROMPT, AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AGENT_README_SECTION_MD, AGENT_SECRET_HYGIENE_SENTENCE, AGENT_WIRING_COLLISION_RELAY_SENTENCE, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionAccountAlias, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, AgentPaymentWarningCode, CONNECTOR_PACKAGE_NAME, DEFAULT_CONFIRMATION_TIMEOUT_MS, DISCOVERY_MAX_BYTES, ERC7710_ASSET_TRANSFER_METHOD, HAVEN_AGENT_RUNBOOK_MD, HAVEN_CONNECTOR_CHANNEL, HAVEN_MINIMUM_NODE_VERSION, HAVEN_SKILL_BODY_MD, HAVEN_SKILL_MD, HavenApiError, HavenClient, HavenError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, HavenUnsupportedSignerVersionError, MERCHANT_DISCOVERY_PATHS, MerchantTimeoutError, RECEIPT_VERSION, SIGNER_UPDATE_FALLBACK, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_SEPOLIA_CHAIN_ID, SWEEP_BASE_SEPOLIA_USDC_ADDRESS, SWEEP_BASE_USDC_ADDRESS, SignerRefusalCode, TRANSFER_WITH_AUTHORIZATION_TYPES, X402AlreadySettledError, X402PaymentHeaderValidationError, X402UnexpectedStatusError, X402_LEGACY_PAYMENT_HEADER_NAME, X402_MAX_AUTHORIZATION_WINDOW_SECONDS, X402_PAYMENT_HEADER_NAME, X402_PAYMENT_HEADER_NAMES_SENT, X402_PAYMENT_REQUIRED_HEADER_NAME, X402_PAYMENT_RESPONSE_HEADER_NAME, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS, accountAddressTwins, addressFromKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, canonicalAgentPaymentNextAction, compareNodeVersions, composeDescription, connectorRerunCommand, connectorSpec, decodeBase64Json, decodeBase64Utf8, discoverMerchantMcpUrl, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, havenTools, isConnectorChannel, isErc7710Option, isFundAccountOrRaiseAllowance, isSupportedNodeVersion, isSweepableChain, normalizePaymentRequired, parsePaymentRequired, parsePaymentRequiredResponse, readAccountAddress, readAccountId, readX402ReceiptPayer, resolveConnectorChannel, resolveTokenFromAddress, sameUrl, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, signHash, signUserOpTypedDataForDelegation, signerUpdateFallback, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, verifyPaymentReceipt, verifySignature, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses, x402V2PaymentEnvelope };
|
|
4816
4862
|
//# sourceMappingURL=index.js.map
|
|
4817
4863
|
//# sourceMappingURL=index.js.map
|