@haven_ai/sdk 0.1.33-alpha.0 → 0.1.35-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.js CHANGED
@@ -7,6 +7,33 @@ import { privateKeyToAccount } from 'viem/accounts';
7
7
 
8
8
  // src/client.ts
9
9
 
10
+ // src/connector-channel.ts
11
+ var CONNECTOR_PACKAGE_NAME = "@haven_ai/connect";
12
+ var HAVEN_CONNECTOR_CHANNEL = "alpha";
13
+ var CHANNEL_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
14
+ function isConnectorChannel(value) {
15
+ return CHANNEL_PATTERN.test(value);
16
+ }
17
+ function resolveConnectorChannel(raw, fallback = HAVEN_CONNECTOR_CHANNEL) {
18
+ const trimmed = (raw ?? "").trim();
19
+ if (trimmed === "") return fallback;
20
+ if (!isConnectorChannel(trimmed)) {
21
+ throw new Error(
22
+ `HAVEN_CONNECTOR_CHANNEL is set to ${JSON.stringify(raw)}, which is not a valid npm dist-tag (lowercase letter first, then letters, digits or hyphens). Refusing to start rather than fall back to the default channel, because falling back would hand out the production connector while looking configured.`
23
+ );
24
+ }
25
+ return trimmed;
26
+ }
27
+ function connectorSpec(channel = HAVEN_CONNECTOR_CHANNEL) {
28
+ return `${CONNECTOR_PACKAGE_NAME}@${channel}`;
29
+ }
30
+ function connectorRerunCommand(args, options) {
31
+ const channel = options?.channel ?? HAVEN_CONNECTOR_CHANNEL;
32
+ const flags = options?.npxFlags ? `${options.npxFlags} ` : "";
33
+ const command = `npx ${flags}${connectorSpec(channel)}`;
34
+ return args ? `${command} ${args}` : command;
35
+ }
36
+
10
37
  // src/types.ts
11
38
  var DEFAULT_CONFIRMATION_TIMEOUT_MS = 9e4;
12
39
  var AgentPaymentPhase = {
@@ -327,7 +354,10 @@ var SignerRefusalCode = {
327
354
  /** `SUPPORTED_SWEEP_BINDING_VERSIONS` in `@haven_ai/signer` does not include the received version. */
328
355
  UnsupportedSweepBindingVersion: "UNSUPPORTED_SWEEP_BINDING_VERSION"
329
356
  };
330
- var SIGNER_UPDATE_FALLBACK = "Update @haven_ai/signer by rerunning `npx @haven_ai/connect@alpha`, which reinstalls the pinned MCP runtime, then retry the same signing call. Nothing was signed or spent \u2014 the quote or payment this version came from is unaffected and does not need to be re-quoted.";
357
+ function signerUpdateFallback(channel = HAVEN_CONNECTOR_CHANNEL) {
358
+ return `Update @haven_ai/signer by rerunning \`${connectorRerunCommand(void 0, { channel })}\`, which reinstalls the pinned MCP runtime, then retry the same signing call. Nothing was signed or spent \u2014 the quote or payment this version came from is unaffected and does not need to be re-quoted.`;
359
+ }
360
+ var SIGNER_UPDATE_FALLBACK = signerUpdateFallback();
331
361
  var HavenUnsupportedSignerVersionError = class extends HavenError {
332
362
  constructor(message, code, supportedVersions, receivedVersion, fallback) {
333
363
  super(message, code);
@@ -615,6 +645,7 @@ function normalizePaymentRequired(value) {
615
645
  const resourceUrl = candidate.resource?.url ?? first.resource;
616
646
  if (!resourceUrl) return null;
617
647
  const resource = {
648
+ ...candidate.resource && typeof candidate.resource === "object" ? candidate.resource : {},
618
649
  url: resourceUrl,
619
650
  description: candidate.resource?.description ?? first.description,
620
651
  mimeType: candidate.resource?.mimeType ?? first.mimeType
@@ -689,6 +720,17 @@ function x402PaymentHeaderNamesFor(paymentHeader) {
689
720
  function x402PaymentHeaderNamesSent(paymentHeader) {
690
721
  return x402PaymentHeaderNamesFor(paymentHeader).join(", ");
691
722
  }
723
+ function x402V2PaymentEnvelope(paymentRequired, accepted, payload) {
724
+ const resource = paymentRequired.resource;
725
+ const extensions = paymentRequired.extensions;
726
+ return {
727
+ x402Version: paymentRequired.x402Version,
728
+ ...resource && typeof resource === "object" && !Array.isArray(resource) ? { resource } : {},
729
+ accepted,
730
+ payload,
731
+ ...extensions && typeof extensions === "object" && !Array.isArray(extensions) ? { extensions } : {}
732
+ };
733
+ }
692
734
  function parsePaymentRequired(response) {
693
735
  const v2Header = response.headers.get("PAYMENT-REQUIRED");
694
736
  if (v2Header) {
@@ -868,7 +910,15 @@ async function validateStandardX402PaymentHeader(paymentHeader, context) {
868
910
  throw new Error("context");
869
911
  }
870
912
  } else {
871
- if (!hasOnlyKeys(decoded, ["x402Version", "accepted", "payload"])) throw new Error("shape");
913
+ if (!hasOnlyKeys(decoded, ["x402Version", "accepted", "payload"], ["resource", "extensions"])) {
914
+ throw new Error("shape");
915
+ }
916
+ if ("resource" in decoded && (!decoded.resource || typeof decoded.resource !== "object" || Array.isArray(decoded.resource))) {
917
+ throw new Error("shape");
918
+ }
919
+ if ("extensions" in decoded && (!decoded.extensions || typeof decoded.extensions !== "object" || Array.isArray(decoded.extensions))) {
920
+ throw new Error("shape");
921
+ }
872
922
  const accepted = selectStandardPaymentOption([decoded.accepted]);
873
923
  if (!accepted || !matchesHeaderContext(accepted, context)) throw new Error("context");
874
924
  }
@@ -920,8 +970,8 @@ async function validateStandardX402PaymentHeader(paymentHeader, context) {
920
970
  throw new X402PaymentHeaderValidationError();
921
971
  }
922
972
  }
923
- function hasOnlyKeys(value, allowed) {
924
- return Object.keys(value).every((key) => allowed.includes(key)) && allowed.every((key) => key in value);
973
+ function hasOnlyKeys(value, required, optional = []) {
974
+ return Object.keys(value).every((key) => required.includes(key) || optional.includes(key)) && required.every((key) => key in value);
925
975
  }
926
976
  function sameAddress2(left, right) {
927
977
  return left.toLowerCase() === right.toLowerCase();
@@ -2126,11 +2176,7 @@ var X402FundingLeg = class {
2126
2176
  );
2127
2177
  if (paymentRequired.x402Version < 2) return header;
2128
2178
  const payment = decodeBase64Json(header);
2129
- return encodeBase64Json({
2130
- x402Version: paymentRequired.x402Version,
2131
- accepted: option,
2132
- payload: payment.payload
2133
- });
2179
+ return encodeBase64Json(x402V2PaymentEnvelope(paymentRequired, option, payment.payload));
2134
2180
  }
2135
2181
  // ── Receipt mapping ──────────────────────────────────────────────
2136
2182
  receiptFromAuthorization(paymentRequired, option, paymentHeader, raw, execResult) {
@@ -2341,6 +2387,16 @@ var X402Erc7710 = class {
2341
2387
  const amountAtomic = x402AuthorizationAmount(option);
2342
2388
  const raw = await this.post("/x402", {
2343
2389
  url: options.resourceUrl ?? paymentRequired.resource?.url,
2390
+ // #2373: the full 402 challenge, persisted verbatim by the backend
2391
+ // (#1355) so the settle handoff can echo its resource/extensions into
2392
+ // the X-PAYMENT envelope (#2361). This scheme decomposes the challenge
2393
+ // into the fields below for AUTHORITY; the stored copy exists for the
2394
+ // echo, which cannot be reconstructed from the decomposition — omitting
2395
+ // it is how every erc7710 payment failed a merchant that enforces the
2396
+ // spec's extensions-echo MUST. Same ≤64KB guard and omission behaviour
2397
+ // as the 3009 path (client.ts): an oversized challenge omits the field
2398
+ // rather than failing the payment, and the settle echo then omits too.
2399
+ ...new TextEncoder().encode(JSON.stringify(paymentRequired)).length <= 65536 ? { paymentRequired } : {},
2344
2400
  // payTo = the MERCHANT is what selects direct settlement server-side.
2345
2401
  // The explicit settlementScheme must AGREE with that shape (#1360) —
2346
2402
  // disagreement is a 400 by design, so that a stale delegate address
@@ -4256,10 +4312,146 @@ var havenTools = {
4256
4312
  openai: openaiTools
4257
4313
  };
4258
4314
 
4315
+ // src/agent-guidance.ts
4316
+ var AGENT_SECRET_HYGIENE_SENTENCE = "Do not print private keys, API keys, credential file contents, or config secrets in chat or logs.";
4317
+ var AGENT_LOCAL_KEY_SENTENCE = "The Haven connector generates the signing key locally and sends Haven only the public signing address plus proof.";
4318
+ var AGENT_NETWORK_ACCESS_SENTENCE = "Network access is expected: this command downloads the npm package and contacts the Haven API, so if your environment is sandboxed, run it with network access enabled or request network access escalation; that changes the execution environment, not the command, and is not a third command modification.";
4319
+ var AGENT_JSON_MODE_SENTENCE = "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.";
4320
+ var AGENT_APPROVAL_RELAY_JSON_SENTENCE = "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.";
4321
+ var AGENT_APPROVAL_RELAY_PROSE_SENTENCE = "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.";
4322
+ var AGENT_WIRING_COLLISION_RELAY_SENTENCE = "If the connector refuses with wiring_collision, this machine is already wired to a different agent: relay that refusal to me with the superseded_agent_ids and suggested_name it carries, and let me choose whether to replace the existing wiring or add this agent alongside it. Never pick for me by adding --replace or --name yourself.";
4323
+ var AGENT_COMMAND_MODIFICATION_SENTENCE = "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.";
4324
+ var AGENT_README_SECTION_MD = `## Are you an AI agent whose user has no Haven account yet?
4325
+
4326
+ Read **\`/for-agents.md\`** on the Haven host your user gave you \u2014 or
4327
+ [the copy in this repository](https://github.com/d-hinders/Haven-AI/blob/dev/packages/frontend/public/for-agents.md)
4328
+ if you do not have that host yet.
4329
+
4330
+ Your user creates the account and the passkey: those are theirs, they need a
4331
+ human, and you should never ask for their password. You can do everything else
4332
+ \u2014 including running the connector command from the setup prompt they paste you,
4333
+ and managing the account from the shell with \`@haven_ai/cli\`.`;
4334
+ var HAVEN_AGENT_RUNBOOK_MD = `# Haven for agents \u2014 set your user up to let you pay
4335
+
4336
+ You are an AI agent whose user has no Haven account yet, or has one but has not connected you.
4337
+
4338
+ > Links below are paths on this same host: resolve them against the URL you fetched this file from.
4339
+
4340
+ ## What Haven is, in three sentences
4341
+
4342
+ Your 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.
4343
+
4344
+ ## The sequence
4345
+
4346
+ 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
+
4348
+ 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 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. 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 **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.
4350
+ 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
+ 4. **YOU \u2014 run the connector command** in that prompt (below). It makes your signing key locally, registering only the public address.
4352
+ 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.
4353
+ 6. **YOU \u2014 verify, then pay.**
4354
+
4355
+ ## Budget changes later (second token, raise, revoke)
4356
+
4357
+ The 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:
4358
+
4359
+ \`\`\`
4360
+ haven budget grant <agentId> --amount <n> --token USDC --period <minutes> [--recipient <address>] [--wait]
4361
+ haven budget revoke <agentId> <delegationHash> [--wait]
4362
+ \`\`\`
4363
+
4364
+ The 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>\`.
4365
+
4366
+ ## Hand-off scripts
4367
+
4368
+ Send 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.
4369
+
4370
+ **Before signup** (step 1):
4371
+
4372
+ > 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\`.
4373
+
4374
+ **At the passkey step:**
4375
+
4376
+ > 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.
4377
+
4378
+ **At funding** (step 2):
4379
+
4380
+ > 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.
4381
+
4382
+ **At the budget** (step 3):
4383
+
4384
+ > 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.
4385
+
4386
+ **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.
4387
+
4388
+ > Setup is done on my side. Approve the budget here: <approval.url>. Approve it with your passkey; nothing can be spent until you do.
4389
+
4390
+ > 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.
4391
+
4392
+ ## What you run
4393
+
4394
+ The setup prompt carries a **connector command** shaped like this:
4395
+
4396
+ \`\`\`
4397
+ npx -y @haven_ai/connect@<channel> --setup EXAMPLE-SETUP-TOKEN-NOT-REAL --api <api-url> --ack-local-tools
4398
+ \`\`\`
4399
+
4400
+ Run 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.
4401
+
4402
+ - ${AGENT_JSON_MODE_SENTENCE}
4403
+ - ${AGENT_APPROVAL_RELAY_JSON_SENTENCE}
4404
+ - ${AGENT_APPROVAL_RELAY_PROSE_SENTENCE}
4405
+ - ${AGENT_COMMAND_MODIFICATION_SENTENCE}
4406
+ - ${AGENT_SECRET_HYGIENE_SENTENCE}
4407
+
4408
+ If 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.
4409
+
4410
+ ## How to verify
4411
+
4412
+ Call \`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\`:
4413
+
4414
+ - \`ready\` \u2014 a budget is live; you can pay.
4415
+ - \`needs_approval\` \u2014 the connector finished, nobody approved yet. Ask your user again, in their Haven tab; there is no queue to wait in.
4416
+ - \`revoked\` \u2014 the credential is not active; ask your user to create a new agent.
4417
+
4418
+ \`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.
4419
+
4420
+ ## If you cannot open a browser
4421
+
4422
+ Nothing 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.
4423
+
4424
+ ## Vocabulary
4425
+
4426
+ | Term | What it is |
4427
+ |---|---|
4428
+ | **setup prompt** | The text the dashboard hands your user to paste to you. Carries the command and its rules. |
4429
+ | **connector command** | The \`npx -y @haven_ai/connect@\u2026\` line you run. One-time token, one use. |
4430
+ | **agent credential** | Your API key (\`sk_agent_\u2026\`), written to \`~/.haven\`. It identifies you; alone it cannot move money. |
4431
+ | **delegate key** | Your signing key, made on this machine and never sent anywhere. |
4432
+ | **budget** | The on-chain delegation your user signed. It authorises the payment; Haven constructs and relays it. |
4433
+
4434
+ Next: [your agent hit a 402](/402.md) \xB7 [everything agent-readable](/llms.txt)
4435
+ `;
4436
+ var AGENT_ONBOARDING_PROMPT = `I have a Haven account and I am signed in at {{HAVEN_ORIGIN}}. Please set up Haven so you can pay for things within a budget I approve.
4437
+
4438
+ Start by reading {{HAVEN_ORIGIN}}/for-agents.md \u2014 it is written for you and explains which steps are mine.
4439
+
4440
+ Then:
4441
+
4442
+ 1. Run \`npx @haven_ai/cli login\`. It prints a link and a code and does not need my password \u2014 it must never ask for it. Give me the link straight away and wait for me to approve it in my browser.
4443
+ 2. Once I have approved, run \`haven agents connect --name <a name you choose> --budget <amount> --token USDC --period <minutes>\` with the budget I tell you. If I have not given you one, ask me before running it. Add \`--run\` to complete the connection in the same step.
4444
+ 3. ${AGENT_APPROVAL_RELAY_JSON_SENTENCE}
4445
+ 4. Once I have approved the budget, verify with the \`haven_get_agent\` tool: \`ready\` means you can pay, \`needs_approval\` means my approval has not landed yet.
4446
+
4447
+ Two things only I can do: approving that budget with my passkey, and funding the account with USDC on Base \u2014 no ETH, Haven sponsors the gas. Tell me if either is missing rather than working around it.
4448
+
4449
+ ${AGENT_SECRET_HYGIENE_SENTENCE}`;
4450
+
4259
4451
  // src/skill-content.ts
4260
4452
  var HAVEN_SKILL_MD = `---
4261
4453
  name: haven-pay
4262
- description: Pay for things from the user's Haven wallet within their agent rules. Use when the user asks to send, pay, tip, or transfer crypto \u2014 or when a request hits an HTTP 402 (x402) paywall.
4454
+ description: Pay for things from the user's Haven wallet within their agent rules, and set Haven up when it is not yet connected. Use when the user asks to send, pay, tip, or transfer crypto; when a request hits an HTTP 402 (x402) paywall; or when they ask to create a Haven account, create an agent, or connect one.
4263
4455
  ---
4264
4456
 
4265
4457
  # Haven: pay from a Haven wallet
@@ -4285,6 +4477,59 @@ the source of truth.
4285
4477
  - A request returns HTTP 402 (x402): use the Haven pay tools to settle it,
4286
4478
  then retry the original request.
4287
4479
 
4480
+ ## Onboarding and setup
4481
+
4482
+ You are in this mode when there is no Haven agent credential on this machine,
4483
+ or when your user asks you to create a Haven account, create an agent, or
4484
+ connect one \u2014 for themselves or for someone else.
4485
+
4486
+ **None of the tools below creates authority.** They spend a budget a human
4487
+ already signed. There is no tool here that opens an account, mints a
4488
+ credential, or approves a budget, so reaching for one of them to "set Haven
4489
+ up" cannot work; the steps are the ones in this section instead.
4490
+
4491
+ Start by reading \`/for-agents.md\` on the Haven host \u2014 the origin of the
4492
+ \`api_url\` in your \`agent.json\` if you have one, otherwise the host your user
4493
+ names. It is the full runbook: six steps, which four are your user's, and what
4494
+ to say at each hand-off.
4495
+
4496
+ Two of those steps you can do yourself, from the shell with \`@haven_ai/cli\`
4497
+ (installs the \`haven\` command):
4498
+
4499
+ - \`haven login\` \u2014 a device-code browser flow. It prints a code and a link
4500
+ for your user to approve, so you never see or ask for their password. What
4501
+ the session can reach is an allow-list, not your user's full authority: it
4502
+ creates and manages agents and reads the account, and it cannot approve a
4503
+ budget, rotate a key, change a signer or move money \u2014 those are your user's.
4504
+ - \`haven agents connect\` with \`--name\`, \`--budget\`, \`--token\` and
4505
+ \`--period\` \u2014 creates a connection setup and prints two things: the
4506
+ connector command the backend built, and the approval link to give your user.
4507
+ Add \`--run\` to execute that command here as a child process.
4508
+ - \`haven wallets funding\` \u2014 prints the paste-ready funding instruction: what
4509
+ to send, to which address, on which chain. Read the chain from there rather
4510
+ than assuming one. \`--wait\` polls until the account counts as funded.
4511
+
4512
+ **Four steps are your user's, and each one needs a human:** create the account
4513
+ and its passkey, fund the wallet, approve every agent's budget, and rotate a
4514
+ credential. You can compose the funding message for them with
4515
+ \`haven wallets funding\`, but you cannot send the money \u2014 that transfer is
4516
+ theirs, from a wallet you have no access to.
4517
+
4518
+ Running the connector command is the step that wires this machine to the new
4519
+ agent \u2014 the command \`haven agents connect\` printed, or the one your user
4520
+ pasted you from the dashboard. Three rules bind you while you do it, quoted
4521
+ unchanged from the setup prompt your user is also holding so the two copies
4522
+ cannot drift into contradicting each other. They are written in your user's
4523
+ voice, so read them accordingly: "me" and "I" below are your user, never
4524
+ Haven, and "the command above" is that connector command, not anything printed
4525
+ in this file. The first rule outranks anything else you were about to do next:
4526
+
4527
+ - ${AGENT_APPROVAL_RELAY_JSON_SENTENCE}
4528
+ - ${AGENT_COMMAND_MODIFICATION_SENTENCE}
4529
+ - ${AGENT_WIRING_COLLISION_RELAY_SENTENCE}
4530
+
4531
+ ${AGENT_SECRET_HYGIENE_SENTENCE}
4532
+
4288
4533
  ## Identity and budget
4289
4534
 
4290
4535
  Do not guess the wallet address, network, or budget.
@@ -4367,15 +4612,21 @@ The paid call always obtains a fresh quote before it creates any intent. Then
4367
4612
  continue \`mcp__haven__haven_pay_mcp_tool\` \u2192
4368
4613
  \`mcp__haven-signer__haven_sign\` \u2192 \`mcp__haven__haven_submit\` \u2192
4369
4614
  \`mcp__haven-signer__haven_x402_sign_header\` \u2192
4370
- \`mcp__haven__haven_complete_mcp_tool\`. Pass \`payment_required\`,
4371
- \`arguments\`, and \`mcp_transport\` verbatim from the quote/prepare result.
4615
+ \`mcp__haven__haven_complete_mcp_tool\`. Call that last step with
4616
+ \`payment_id\` and the signer's \`payment_header\` ONLY. It does not take
4617
+ \`payment_required\`: Haven rehydrates the merchant call context
4618
+ (\`merchant_url\`, \`tool_name\`, \`arguments\`, \`mcp_transport\`) and the
4619
+ 402 server-side from \`payment_id\`, exactly as at settle. Pass that context
4620
+ explicitly only as a version-skew fallback when Haven has no stored context
4621
+ for the id \u2014 \`merchant_url\` and \`tool_name\` both or none together, never
4622
+ just one.
4372
4623
  The returned \`expires_at\` is the signing window; if a tool returns
4373
4624
  \`PAYMENT_WINDOW_EXPIRED\`, re-run the same quote/prepare tool with the same
4374
4625
  \`idempotency_key\`. Do not call the merchant yourself \u2014 Haven completes the
4375
4626
  merchant leg for you.
4376
4627
 
4377
4628
  **Direct transfer / non-MCP paywall:** \`mcp__haven__haven_pay\` with
4378
- recipient, amount, and token for a plain transfer. For an arbitrary,
4629
+ \`to\`, \`amount\`, and \`token\` for a plain transfer. For an arbitrary,
4379
4630
  non-MCP x402 paywall: \`mcp__haven__haven_quote_x402\` to get a quote, then
4380
4631
  \`mcp__haven__haven_pay_x402_quote\` \u2014 follow the result's guidance fields
4381
4632
  first and sign in the local Haven signer. On THIS path Haven does not talk to
@@ -4426,7 +4677,7 @@ check on in-flight payments. Do not poll in a tight loop.
4426
4677
  - Never ask the user for private keys. Signing happens only in the local Haven
4427
4678
  signer; the hosted Haven tools never receive the signing key. If a tool
4428
4679
  reports a missing or invalid credential, tell the user to re-run the Haven
4429
- setup command.
4680
+ connector command.
4430
4681
 
4431
4682
  ## Failure handling
4432
4683
 
@@ -4561,6 +4812,6 @@ function sameUrl(a, b) {
4561
4812
  }
4562
4813
  }
4563
4814
 
4564
- export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, AgentPaymentWarningCode, DEFAULT_CONFIRMATION_TIMEOUT_MS, DISCOVERY_MAX_BYTES, ERC7710_ASSET_TRANSFER_METHOD, 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, decodeBase64Json, decodeBase64Utf8, discoverMerchantMcpUrl, encodeBase64Json, encodeBase64Utf8, encodePaymentProof, havenTools, isErc7710Option, isSupportedNodeVersion, isSweepableChain, normalizePaymentRequired, parsePaymentRequired, parsePaymentRequiredResponse, resolveTokenFromAddress, sameUrl, selectErc7710PaymentOption, selectPaymentOption, selectStandardPaymentOption, selectX402SettlementScheme, signHash, signUserOpTypedDataForDelegation, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, unsupportedNodeVersionMessage, validateStandardX402PaymentHeader, verifyPaymentReceipt, verifySignature, x402AssetTransferMethod, x402AuthorizationAmount, x402FacilitatorAddresses };
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 };
4565
4816
  //# sourceMappingURL=index.js.map
4566
4817
  //# sourceMappingURL=index.js.map