@haven_ai/sdk 0.10.0-alpha.0 → 0.11.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +8 -5
  2. package/dist/{base64-CiR5BJhk.d.cts → base64-D4VZhgUg.d.ts} +2 -2
  3. package/dist/{base64-CxkinHPQ.d.ts → base64-DR4Gl8cD.d.cts} +2 -2
  4. package/dist/{chunk-EWTHDEIW.js → chunk-34YJQFCM.js} +3 -3
  5. package/dist/{chunk-EWTHDEIW.js.map → chunk-34YJQFCM.js.map} +1 -1
  6. package/dist/{chunk-6LEXYQ7J.cjs → chunk-DXBAN4SN.cjs} +4 -4
  7. package/dist/{chunk-6LEXYQ7J.cjs.map → chunk-DXBAN4SN.cjs.map} +1 -1
  8. package/dist/{chunk-TD2PHUYP.js → chunk-I7SL4A6X.js} +19 -3
  9. package/dist/chunk-I7SL4A6X.js.map +1 -0
  10. package/dist/{chunk-22FJ4JQO.cjs → chunk-IKQIIMM6.cjs} +35 -35
  11. package/dist/{chunk-22FJ4JQO.cjs.map → chunk-IKQIIMM6.cjs.map} +1 -1
  12. package/dist/{chunk-H37YVYZA.cjs → chunk-MZKLAHBK.cjs} +19 -3
  13. package/dist/chunk-MZKLAHBK.cjs.map +1 -0
  14. package/dist/{chunk-MLUWABVT.js → chunk-ZDJ55LR7.js} +4 -4
  15. package/dist/{chunk-MLUWABVT.js.map → chunk-ZDJ55LR7.js.map} +1 -1
  16. package/dist/edge.cjs +93 -93
  17. package/dist/edge.d.cts +4 -4
  18. package/dist/edge.d.ts +4 -4
  19. package/dist/edge.js +4 -4
  20. package/dist/index.cjs +755 -450
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +55 -26
  23. package/dist/index.d.ts +55 -26
  24. package/dist/index.js +439 -134
  25. package/dist/index.js.map +1 -1
  26. package/dist/{receipt-Cg9a5Seq.d.ts → receipt-CbD8L0WL.d.ts} +1 -1
  27. package/dist/{receipt-q7ez8Zb2.d.cts → receipt-_bWCELEH.d.cts} +1 -1
  28. package/dist/test-support.cjs +21 -21
  29. package/dist/test-support.d.cts +2 -2
  30. package/dist/test-support.d.ts +2 -2
  31. package/dist/test-support.js +2 -2
  32. package/dist/{types-BKgqzvnk.d.cts → types-DKmvjXK6.d.cts} +65 -10
  33. package/dist/{types-BKgqzvnk.d.ts → types-DKmvjXK6.d.ts} +65 -10
  34. package/package.json +1 -1
  35. package/dist/chunk-H37YVYZA.cjs.map +0 -1
  36. package/dist/chunk-TD2PHUYP.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk22FJ4JQO_cjs = require('./chunk-22FJ4JQO.cjs');
4
- var chunk6LEXYQ7J_cjs = require('./chunk-6LEXYQ7J.cjs');
5
- var chunkH37YVYZA_cjs = require('./chunk-H37YVYZA.cjs');
3
+ var chunkIKQIIMM6_cjs = require('./chunk-IKQIIMM6.cjs');
4
+ var chunkDXBAN4SN_cjs = require('./chunk-DXBAN4SN.cjs');
5
+ var chunkMZKLAHBK_cjs = require('./chunk-MZKLAHBK.cjs');
6
6
  var viem = require('viem');
7
7
  var ethers = require('ethers');
8
8
  var async_hooks = require('async_hooks');
@@ -15,7 +15,7 @@ function signHash(privateKey, hash) {
15
15
  const sig = signingKey.sign(hash);
16
16
  return sig.serialized;
17
17
  } catch (err) {
18
- throw new chunkH37YVYZA_cjs.HavenSigningError(
18
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
19
19
  `Failed to sign hash: ${err instanceof Error ? err.message : String(err)}`
20
20
  );
21
21
  }
@@ -31,7 +31,7 @@ async function signTypedDataVerbatim(privateKey, typedData, label) {
31
31
  typedData.message
32
32
  );
33
33
  } catch (err) {
34
- throw new chunkH37YVYZA_cjs.HavenSigningError(
34
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
35
35
  `Failed to sign ${label}: ${err instanceof Error ? err.message : String(err)}`
36
36
  );
37
37
  }
@@ -46,7 +46,7 @@ function addressFromKey(privateKey) {
46
46
  try {
47
47
  return new ethers.ethers.Wallet(privateKey).address;
48
48
  } catch (err) {
49
- throw new chunkH37YVYZA_cjs.HavenSigningError(
49
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
50
50
  `Invalid private key: ${err instanceof Error ? err.message : String(err)}`
51
51
  );
52
52
  }
@@ -62,7 +62,7 @@ function verifySignature(hash, signature, expectedAddress) {
62
62
  var DEFAULT_BASE_URL = "http://localhost:3001";
63
63
  var DEFAULT_REQUEST_TIMEOUT = 3e4;
64
64
  function withoutClientHeader(headers) {
65
- const target = chunk22FJ4JQO_cjs.HAVEN_CLIENT_HEADER.toLowerCase();
65
+ const target = chunkIKQIIMM6_cjs.HAVEN_CLIENT_HEADER.toLowerCase();
66
66
  return Object.fromEntries(Object.entries(headers).filter(([name]) => name.toLowerCase() !== target));
67
67
  }
68
68
  var HavenApiTransport = class {
@@ -78,7 +78,7 @@ var HavenApiTransport = class {
78
78
  this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
79
79
  this.requestTimeout = config.requestTimeout ?? DEFAULT_REQUEST_TIMEOUT;
80
80
  this.defaultHeaders = { ...config.defaultHeaders ?? {} };
81
- this.clientIdentity = config.clientIdentity ?? chunk22FJ4JQO_cjs.SDK_CLIENT_IDENTITY;
81
+ this.clientIdentity = config.clientIdentity ?? chunkIKQIIMM6_cjs.SDK_CLIENT_IDENTITY;
82
82
  }
83
83
  /**
84
84
  * The newest `client_update` the backend sent (#3303): inside a
@@ -91,7 +91,7 @@ var HavenApiTransport = class {
91
91
  }
92
92
  recordClientUpdate(data) {
93
93
  if (data === null || typeof data !== "object" || Array.isArray(data)) return;
94
- const hint = chunk22FJ4JQO_cjs.readClientUpdate(data.client_update);
94
+ const hint = chunkIKQIIMM6_cjs.readClientUpdate(data.client_update);
95
95
  if (!hint) return;
96
96
  this.lastClientUpdate = hint;
97
97
  const store = this.requestContext.getStore();
@@ -124,7 +124,7 @@ var HavenApiTransport = class {
124
124
  // JOIN `x-haven-client` and `X-Haven-Client` into one unparseable
125
125
  // value), so neither `defaultHeaders` nor a dispatch context can
126
126
  // misname the client; `clientIdentity` is the one way to set it.
127
- [chunk22FJ4JQO_cjs.HAVEN_CLIENT_HEADER]: this.clientIdentity
127
+ [chunkIKQIIMM6_cjs.HAVEN_CLIENT_HEADER]: this.clientIdentity
128
128
  },
129
129
  body: body ? JSON.stringify(body) : void 0,
130
130
  signal: controller.signal
@@ -137,15 +137,15 @@ var HavenApiTransport = class {
137
137
  const rawDetails = record.details ?? record.detail;
138
138
  const detailsText = typeof rawDetails === "string" ? rawDetails : rawDetails != null ? JSON.stringify(rawDetails) : void 0;
139
139
  const message = errorText && detailsText ? `${errorText}: ${detailsText}` : errorText ?? detailsText ?? "API request failed";
140
- throw new chunkH37YVYZA_cjs.HavenApiError(message, res.status, data);
140
+ throw new chunkMZKLAHBK_cjs.HavenApiError(message, res.status, data);
141
141
  }
142
142
  return data;
143
143
  } catch (err) {
144
- if (err instanceof chunkH37YVYZA_cjs.HavenApiError) throw err;
144
+ if (err instanceof chunkMZKLAHBK_cjs.HavenApiError) throw err;
145
145
  if (err instanceof Error && err.name === "AbortError") {
146
- throw new chunkH37YVYZA_cjs.HavenApiError(`Request to ${path} timed out`, 408);
146
+ throw new chunkMZKLAHBK_cjs.HavenApiError(`Request to ${path} timed out`, 408);
147
147
  }
148
- throw new chunkH37YVYZA_cjs.HavenApiError(
148
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
149
149
  `Request to ${path} failed: ${err instanceof Error ? err.message : String(err)}`,
150
150
  0
151
151
  );
@@ -168,13 +168,13 @@ async function fetchUnsignedTaxDeclaration(client) {
168
168
  if (reason === "feature_disabled" || reason === "disabled" || reason === "no_company_details" || reason === "vies_not_valid") {
169
169
  return { available: false, reason };
170
170
  }
171
- throw new chunkH37YVYZA_cjs.HavenApiError(
171
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
172
172
  "The tax-declaration endpoint answered a body that is neither the \xA72.1 content nor a named unavailability reason.",
173
173
  502
174
174
  );
175
175
  }
176
176
  async function resolveTaxDeclarationHeader(client, input) {
177
- if (chunk22FJ4JQO_cjs.isErc7710Option(input.accepted)) {
177
+ if (chunkIKQIIMM6_cjs.isErc7710Option(input.accepted)) {
178
178
  return { header: void 0 };
179
179
  }
180
180
  let content;
@@ -186,7 +186,7 @@ async function resolveTaxDeclarationHeader(client, input) {
186
186
  if (!content.available) {
187
187
  return { header: void 0 };
188
188
  }
189
- const signed = chunk22FJ4JQO_cjs.buildSignedTaxDeclaration({
189
+ const signed = chunkIKQIIMM6_cjs.buildSignedTaxDeclaration({
190
190
  content: content.declaration,
191
191
  network: input.accepted.network,
192
192
  delegateKey: input.delegateKey
@@ -195,19 +195,19 @@ async function resolveTaxDeclarationHeader(client, input) {
195
195
  `[haven-sdk] signing x402 tax declaration taxId=${JSON.stringify(content.declaration.taxId)} jurisdiction=${JSON.stringify(content.declaration.jurisdiction)} principalId=${signed.declaration.principalId}
196
196
  `
197
197
  );
198
- return { header: chunk22FJ4JQO_cjs.encodeTaxDeclarationHeader(signed) };
198
+ return { header: chunkIKQIIMM6_cjs.encodeTaxDeclarationHeader(signed) };
199
199
  }
200
200
  function withTaxDeclarationHeader(init, header) {
201
201
  if (!header) {
202
- if (init?.headers && new Headers(init.headers).has(chunk22FJ4JQO_cjs.X_TAX_DECLARATION_HEADER)) {
202
+ if (init?.headers && new Headers(init.headers).has(chunkIKQIIMM6_cjs.X_TAX_DECLARATION_HEADER)) {
203
203
  const headers2 = new Headers(init.headers);
204
- headers2.delete(chunk22FJ4JQO_cjs.X_TAX_DECLARATION_HEADER);
204
+ headers2.delete(chunkIKQIIMM6_cjs.X_TAX_DECLARATION_HEADER);
205
205
  return { ...init, headers: headers2 };
206
206
  }
207
207
  return init ?? {};
208
208
  }
209
209
  const headers = new Headers(init?.headers);
210
- headers.set(chunk22FJ4JQO_cjs.X_TAX_DECLARATION_HEADER, header);
210
+ headers.set(chunkIKQIIMM6_cjs.X_TAX_DECLARATION_HEADER, header);
211
211
  return { ...init, headers };
212
212
  }
213
213
 
@@ -373,29 +373,29 @@ function paymentStateStatusCode(status, fallback = 502) {
373
373
  return PAYMENT_STATE_STATUS_CODES[status] ?? fallback;
374
374
  }
375
375
  function phaseForStatus(status) {
376
- if (status === "pending_signature") return chunkH37YVYZA_cjs.AgentPaymentPhase.AgentSignatureRequired;
377
- if (status === "submitted") return chunkH37YVYZA_cjs.AgentPaymentPhase.PaymentSubmitted;
378
- if (status === "confirmed") return chunkH37YVYZA_cjs.AgentPaymentPhase.PaymentConfirmed;
379
- if (status === "pending" || status === "pending_approval") return chunkH37YVYZA_cjs.AgentPaymentPhase.UserApprovalRequired;
380
- if (status === "approved") return chunkH37YVYZA_cjs.AgentPaymentPhase.UserExecutionRequired;
381
- if (status === "proposed") return chunkH37YVYZA_cjs.AgentPaymentPhase.WaitingForAdditionalApprovals;
382
- if (status === "executed") return chunkH37YVYZA_cjs.AgentPaymentPhase.FundingSent;
383
- if (status === "rejected") return chunkH37YVYZA_cjs.AgentPaymentPhase.Rejected;
384
- if (status === "expired") return chunkH37YVYZA_cjs.AgentPaymentPhase.Expired;
385
- if (status === "failed") return chunkH37YVYZA_cjs.AgentPaymentPhase.Failed;
376
+ if (status === "pending_signature") return chunkMZKLAHBK_cjs.AgentPaymentPhase.AgentSignatureRequired;
377
+ if (status === "submitted") return chunkMZKLAHBK_cjs.AgentPaymentPhase.PaymentSubmitted;
378
+ if (status === "confirmed") return chunkMZKLAHBK_cjs.AgentPaymentPhase.PaymentConfirmed;
379
+ if (status === "pending" || status === "pending_approval") return chunkMZKLAHBK_cjs.AgentPaymentPhase.UserApprovalRequired;
380
+ if (status === "approved") return chunkMZKLAHBK_cjs.AgentPaymentPhase.UserExecutionRequired;
381
+ if (status === "proposed") return chunkMZKLAHBK_cjs.AgentPaymentPhase.WaitingForAdditionalApprovals;
382
+ if (status === "executed") return chunkMZKLAHBK_cjs.AgentPaymentPhase.FundingSent;
383
+ if (status === "rejected") return chunkMZKLAHBK_cjs.AgentPaymentPhase.Rejected;
384
+ if (status === "expired") return chunkMZKLAHBK_cjs.AgentPaymentPhase.Expired;
385
+ if (status === "failed") return chunkMZKLAHBK_cjs.AgentPaymentPhase.Failed;
386
386
  return null;
387
387
  }
388
388
  function nextActionForStatus(status) {
389
- if (status === "pending_signature") return chunkH37YVYZA_cjs.AgentPaymentNextAction.SignAndSubmitPayment;
390
- if (status === "submitted") return chunkH37YVYZA_cjs.AgentPaymentNextAction.CheckStatusLater;
391
- if (status === "confirmed") return chunkH37YVYZA_cjs.AgentPaymentNextAction.None;
392
- if (status === "pending" || status === "pending_approval") return chunkH37YVYZA_cjs.AgentPaymentNextAction.StopAndTellUser;
393
- if (status === "approved") return chunkH37YVYZA_cjs.AgentPaymentNextAction.StopAndTellUser;
394
- if (status === "proposed") return chunkH37YVYZA_cjs.AgentPaymentNextAction.StopAndTellUser;
395
- if (status === "executed") return chunkH37YVYZA_cjs.AgentPaymentNextAction.StopAndTellUser;
396
- if (status === "rejected") return chunkH37YVYZA_cjs.AgentPaymentNextAction.StopAndTellUser;
397
- if (status === "expired") return chunkH37YVYZA_cjs.AgentPaymentNextAction.RequestAgainIfUserStillWantsIt;
398
- if (status === "failed") return chunkH37YVYZA_cjs.AgentPaymentNextAction.StopAndTellUser;
389
+ if (status === "pending_signature") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.SignAndSubmitPayment;
390
+ if (status === "submitted") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.CheckStatusLater;
391
+ if (status === "confirmed") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.None;
392
+ if (status === "pending" || status === "pending_approval") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.StopAndTellUser;
393
+ if (status === "approved") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.StopAndTellUser;
394
+ if (status === "proposed") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.StopAndTellUser;
395
+ if (status === "executed") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.StopAndTellUser;
396
+ if (status === "rejected") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.StopAndTellUser;
397
+ if (status === "expired") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.RequestAgainIfUserStillWantsIt;
398
+ if (status === "failed") return chunkMZKLAHBK_cjs.AgentPaymentNextAction.StopAndTellUser;
399
399
  return null;
400
400
  }
401
401
  function messageForState(label, status, paymentId, nextAction) {
@@ -469,17 +469,17 @@ function throwPaymentStateError(label, raw) {
469
469
  const statusCode = paymentStateStatusCode(raw.status);
470
470
  const state = paymentStateFromRaw(label, raw);
471
471
  if (state) {
472
- throw new chunkH37YVYZA_cjs.HavenPaymentStateError(state.message, statusCode, state, raw);
472
+ throw new chunkMZKLAHBK_cjs.HavenPaymentStateError(state.message, statusCode, state, raw);
473
473
  }
474
474
  if (raw.status === "pending_approval") {
475
- throw new chunkH37YVYZA_cjs.HavenApiError(
475
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
476
476
  `${label} exceeds the agent's on-chain budget and was declined; no approval is pending and none will arrive (payment_id: ${raw.payment_id}).`,
477
477
  statusCode,
478
478
  raw
479
479
  );
480
480
  }
481
481
  if (raw.status === "expired") {
482
- throw new chunkH37YVYZA_cjs.HavenApiError(
482
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
483
483
  `${label} expired before it could be completed (payment_id: ${raw.payment_id}).`,
484
484
  statusCode,
485
485
  raw
@@ -487,7 +487,7 @@ function throwPaymentStateError(label, raw) {
487
487
  }
488
488
  const paymentId = raw.payment_id ? ` (payment_id: ${raw.payment_id})` : "";
489
489
  const message = raw.error ?? `${label} ${raw.status}${paymentId}`;
490
- throw new chunkH37YVYZA_cjs.HavenApiError(message, statusCode, raw);
490
+ throw new chunkMZKLAHBK_cjs.HavenApiError(message, statusCode, raw);
491
491
  }
492
492
 
493
493
  // src/x402-retry-target.ts
@@ -519,7 +519,7 @@ function isSecureX402RetryTarget(url) {
519
519
  return RESERVED_SUFFIXES.some((suffix) => host.endsWith(suffix));
520
520
  }
521
521
  var INSECURE_RETRY_TARGET_CODE = "INSECURE_RETRY_TARGET";
522
- var HavenInsecureRetryTargetError = class extends chunkH37YVYZA_cjs.HavenError {
522
+ var HavenInsecureRetryTargetError = class extends chunkMZKLAHBK_cjs.HavenError {
523
523
  constructor(url) {
524
524
  super(
525
525
  `Refusing to send a payment header to ${url}: the paid x402 retry must go to an https URL (or a loopback / reserved test host). The merchant's challenge declared this resource URL; retry with the https URL you quoted (pass it as \`url\`), and report a merchant whose challenge downgrades the scheme.`,
@@ -537,20 +537,38 @@ function assertSecureX402RetryTarget(url) {
537
537
 
538
538
  // src/merchant-egress.ts
539
539
  var MERCHANT_EGRESS_REFUSED_CODE = "MERCHANT_EGRESS_REFUSED";
540
- var MerchantEgressRefusedError = class extends chunkH37YVYZA_cjs.HavenError {
540
+ var MerchantEgressRefusedError = class extends chunkMZKLAHBK_cjs.HavenError {
541
541
  url;
542
542
  refusal;
543
543
  beforeRequest;
544
- constructor(message, url, refusal, beforeRequest) {
545
- super(message, MERCHANT_EGRESS_REFUSED_CODE, 400);
544
+ /** #4257: the redirect status that was not followed, when a redirect was refused. */
545
+ redirectStatus;
546
+ /**
547
+ * #4257: set only when `url` IS the redirect target (a cross-origin body
548
+ * re-send, a spent hop budget, a hop `assertUrl` refused). A refusal that
549
+ * stopped at the answering URL itself (a non-GET redirect, a missing or
550
+ * unresolvable Location) leaves it unset, and `url` is that answering URL.
551
+ */
552
+ redirectTarget;
553
+ /**
554
+ * #4257: set when the refusal interrupted a PAID delivery and the local
555
+ * completion has re-thrown it with the payment it belongs to — the funded,
556
+ * undelivered state, never "nothing happened".
557
+ */
558
+ settlementScheme;
559
+ constructor(message, url, refusal, beforeRequest, extra = {}) {
560
+ super(message, MERCHANT_EGRESS_REFUSED_CODE, 400, extra.paymentId);
546
561
  this.name = "MerchantEgressRefusedError";
547
562
  this.url = url;
548
563
  this.refusal = refusal;
549
564
  this.beforeRequest = beforeRequest;
565
+ this.redirectStatus = extra.redirectStatus;
566
+ this.redirectTarget = extra.redirectTarget;
567
+ this.settlementScheme = extra.settlementScheme;
550
568
  }
551
569
  };
552
570
  var MERCHANT_EGRESS_RESPONSE_CAP_CODE = "MERCHANT_EGRESS_RESPONSE_CAP";
553
- var MerchantEgressResponseCapError = class extends chunkH37YVYZA_cjs.HavenError {
571
+ var MerchantEgressResponseCapError = class extends chunkMZKLAHBK_cjs.HavenError {
554
572
  url;
555
573
  limitBytes;
556
574
  constructor(message, limitBytes, url) {
@@ -661,6 +679,29 @@ var MCP_X402_PAYMENT_META_KEY = "x402/payment";
661
679
  var MCP_X402_PAYMENT_RESPONSE_META_KEY = "x402/payment-response";
662
680
  var X402_RETRY_REJECTED_STATUS = 402;
663
681
  var SESSION_NOT_FOUND_NEXT_ACTION = "reinitialize_then_retry_same_payment_header";
682
+ var CROSS_ORIGIN_REDIRECT_HEADERS = /* @__PURE__ */ new Set([
683
+ "accept",
684
+ "accept-language",
685
+ "user-agent",
686
+ "x402-wallet"
687
+ ]);
688
+ function crossOriginRedirectHeaders(headers) {
689
+ const kept = new Headers();
690
+ for (const [name, value] of new Headers(headers)) {
691
+ if (CROSS_ORIGIN_REDIRECT_HEADERS.has(name)) kept.set(name, value);
692
+ }
693
+ return kept;
694
+ }
695
+ var NO_POLICY_MAX_REDIRECTS = 20;
696
+ var REQUEST_BODY_HEADERS = ["content-encoding", "content-language", "content-location", "content-type", "content-length"];
697
+ function redirectedInit(init, status) {
698
+ const method = (init.method ?? "GET").toUpperCase();
699
+ const toGet = (status === 301 || status === 302) && method === "POST" || status === 303 && method !== "GET" && method !== "HEAD";
700
+ if (!toGet) return init;
701
+ const headers = new Headers(init.headers);
702
+ for (const name of REQUEST_BODY_HEADERS) headers.delete(name);
703
+ return { ...init, method: "GET", body: null, headers };
704
+ }
664
705
  var McpMerchantTransport = class {
665
706
  merchantTimeout;
666
707
  fetchImpl;
@@ -691,99 +732,169 @@ var McpMerchantTransport = class {
691
732
  }
692
733
  /** Fetch a merchant with a settlement-sized timeout and caller cancellation. */
693
734
  async fetch(url, init = {}, timeoutMs = this.merchantTimeout, maxBytes) {
735
+ return this.send(url, init, timeoutMs, maxBytes, false);
736
+ }
737
+ /**
738
+ * `fetch`, plus whether this request is the paid delivery (#4257). A paid
739
+ * delivery, or any body carrying an x402 payment in `_meta`, is never
740
+ * re-sent to another origin by a redirect that keeps the body; without a policy every other
741
+ * request follows that redirect as the platform would, headers reduced.
742
+ */
743
+ async send(url, init, timeoutMs, maxBytes, paidDelivery) {
744
+ const carriesPayment = paidDelivery || bodyCarriesX402Payment(init.body);
694
745
  if (!this.egress) {
695
746
  const timeoutSignal = AbortSignal.timeout(timeoutMs);
696
747
  const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
697
748
  try {
698
- return await this.fetchImpl(url, { ...init, signal });
749
+ if (init.redirect === "manual" || init.redirect === "error") {
750
+ return await this.fetchImpl(url, { ...init, signal });
751
+ }
752
+ return await this.followRedirects(url, init, signal, void 0, carriesPayment);
699
753
  } catch (err) {
700
754
  if (timeoutSignal.aborted) {
701
- throw new chunkH37YVYZA_cjs.MerchantTimeoutError(`Merchant request timed out after ${timeoutMs}ms: ${url}`);
755
+ throw new chunkMZKLAHBK_cjs.MerchantTimeoutError(`Merchant request timed out after ${timeoutMs}ms: ${url}`);
702
756
  }
703
757
  throw err;
704
758
  }
705
759
  }
706
- return this.fetchUnderPolicy(url, init, timeoutMs, maxBytes);
760
+ return this.fetchUnderPolicy(url, init, timeoutMs, maxBytes, carriesPayment);
707
761
  }
708
762
  /**
709
763
  * #3747: the policy path. Every URL — the initial request and each redirect
710
764
  * hop — is `assertUrl`-checked BEFORE it connects; redirects run `manual`
711
765
  * so nothing is ever followed un-checked; GET redirects are followed up to
712
- * `maxGetRedirects` (a redirect on any other method is refused); response
713
- * bodies are capped WHILE being read, not after buffering. The timeout
766
+ * `maxGetRedirects` (a redirect on any other method is refused); a hop to
767
+ * another origin carries only `CROSS_ORIGIN_REDIRECT_HEADERS` (#4244);
768
+ * response bodies are capped WHILE being read, not after buffering. The timeout
714
769
  * signal spans the WHOLE redirect chain, and `MerchantTimeoutError`
715
770
  * classification is preserved.
716
771
  */
717
- async fetchUnderPolicy(url, init, timeoutMs, maxBytes) {
772
+ async fetchUnderPolicy(url, init, timeoutMs, maxBytes, carriesPayment) {
718
773
  const egress = this.egress;
719
774
  try {
720
775
  egress.assertUrl(url);
721
776
  } catch (err) {
722
777
  throw asRefusal(err, url, true);
723
778
  }
724
- const method = (init.method ?? "GET").toUpperCase();
725
779
  const timeoutSignal = AbortSignal.timeout(timeoutMs);
726
780
  const signal = init.signal ? AbortSignal.any([init.signal, timeoutSignal]) : timeoutSignal;
727
- const maxRedirects = egress.maxGetRedirects ?? 0;
781
+ let finalUrl = url;
782
+ try {
783
+ const response = await this.followRedirects(url, init, signal, egress, carriesPayment, (hopUrl) => {
784
+ finalUrl = hopUrl;
785
+ });
786
+ return this.capResponse(response, finalUrl, maxBytes);
787
+ } catch (err) {
788
+ if (timeoutSignal.aborted) {
789
+ throw new chunkMZKLAHBK_cjs.MerchantTimeoutError(`Merchant request timed out after ${timeoutMs}ms: ${finalUrl}`);
790
+ }
791
+ throw err;
792
+ }
793
+ }
794
+ /**
795
+ * The redirect follower both paths share (#3747, #4244, #4257). Redirects
796
+ * run `manual` and every hop is decided here:
797
+ *
798
+ * - Under a `policy`, every hop is `assertUrl`-checked before it connects,
799
+ * only GET redirects are followed (any other method is refused), up to
800
+ * `maxGetRedirects`; a missing or unresolvable Location is refused.
801
+ * - Without one, the platform's rules are kept: up to
802
+ * `NO_POLICY_MAX_REDIRECTS` hops, the Fetch spec's method/body rewrite,
803
+ * and a 3xx with no Location returned as the answer.
804
+ * - On both, a hop to another origin carries only
805
+ * `CROSS_ORIGIN_REDIRECT_HEADERS`, never restored on a later hop.
806
+ * - A hop that would re-send a request body to another origin is refused
807
+ * under a policy (which follows GET alone, so this is unreachable there),
808
+ * and without one only when `carriesPayment`: the paid delivery, or a body
809
+ * carrying an x402 payment in `_meta` (#4257). Any other body-keeping redirect is
810
+ * followed with its body, as the platform did, headers reduced.
811
+ *
812
+ * `onHop` sees every URL a request goes to, so the caller can name the hop
813
+ * it was on when the chain stops.
814
+ */
815
+ async followRedirects(url, init, signal, policy, carriesPayment, onHop) {
816
+ const maxRedirects = policy ? policy.maxGetRedirects ?? 0 : NO_POLICY_MAX_REDIRECTS;
728
817
  let currentUrl = url;
818
+ let hopInit = init;
729
819
  let hops = 0;
730
- try {
731
- while (true) {
732
- const response = await this.fetchImpl(currentUrl, {
733
- ...init,
734
- redirect: init.redirect === "error" ? "error" : "manual",
735
- signal
736
- });
737
- if (!isRedirectStatus(response.status)) return this.capResponse(response, currentUrl, maxBytes);
738
- if (method !== "GET") {
739
- throw new MerchantEgressRefusedError(
740
- `Hosted egress policy refuses the ${response.status} redirect from ${currentUrl}: redirects are followed for GET requests only, and this was a ${method}. The request itself was already sent to the checked URL; nothing was sent to the redirect target.`,
741
- currentUrl,
742
- "redirect_on_non_get",
743
- false
744
- );
745
- }
746
- const location = response.headers.get("location");
747
- if (!location) {
748
- throw new MerchantEgressRefusedError(
749
- `Hosted egress policy refuses the ${response.status} redirect from ${currentUrl}: it carries no Location header, so there is no checked target to follow.`,
750
- currentUrl,
751
- "redirect_missing_location",
752
- false
753
- );
754
- }
755
- let next;
820
+ while (true) {
821
+ onHop?.(currentUrl);
822
+ const response = await this.fetchImpl(currentUrl, {
823
+ ...hopInit,
824
+ redirect: init.redirect === "error" ? "error" : "manual",
825
+ signal
826
+ });
827
+ if (!isRedirectStatus(response.status)) return response;
828
+ const method = (hopInit.method ?? "GET").toUpperCase();
829
+ if (policy && method !== "GET") {
830
+ throw new MerchantEgressRefusedError(
831
+ `Hosted egress policy refuses the ${response.status} redirect from ${currentUrl}: redirects are followed for GET requests only, and this was a ${method}. The request itself was already sent to the checked URL; nothing was sent to the redirect target.`,
832
+ currentUrl,
833
+ "redirect_on_non_get",
834
+ false,
835
+ { redirectStatus: response.status }
836
+ );
837
+ }
838
+ const location = response.headers.get("location");
839
+ if (!location) {
840
+ if (!policy) return response;
841
+ throw new MerchantEgressRefusedError(
842
+ `Hosted egress policy refuses the ${response.status} redirect from ${currentUrl}: it carries no Location header, so there is no checked target to follow.`,
843
+ currentUrl,
844
+ "redirect_missing_location",
845
+ false,
846
+ { redirectStatus: response.status }
847
+ );
848
+ }
849
+ let next;
850
+ try {
851
+ next = new URL(location, currentUrl).toString();
852
+ } catch {
853
+ if (!policy) throw new TypeError(`fetch failed: the redirect from ${currentUrl} has an unresolvable Location header`);
854
+ throw new MerchantEgressRefusedError(
855
+ `Hosted egress policy refuses the redirect from ${currentUrl}: its Location header is not a resolvable URL.`,
856
+ currentUrl,
857
+ "redirect_invalid_location",
858
+ false,
859
+ { redirectStatus: response.status }
860
+ );
861
+ }
862
+ if (!policy && !/^https?:$/.test(new URL(next).protocol)) {
863
+ throw new TypeError(`fetch failed: the redirect from ${currentUrl} names a non-HTTP(S) URL`);
864
+ }
865
+ if (hops >= maxRedirects) {
866
+ if (!policy) throw new TypeError(`fetch failed: redirect count exceeded (${maxRedirects}) at ${currentUrl}`);
867
+ throw new MerchantEgressRefusedError(
868
+ `Hosted egress policy refuses the redirect from ${currentUrl} to ${next}: the ${maxRedirects}-redirect budget for this request is spent.`,
869
+ next,
870
+ "redirect_budget_exceeded",
871
+ false,
872
+ { redirectStatus: response.status, redirectTarget: next }
873
+ );
874
+ }
875
+ if (policy) {
756
876
  try {
757
- next = new URL(location, currentUrl).toString();
758
- } catch {
759
- throw new MerchantEgressRefusedError(
760
- `Hosted egress policy refuses the redirect from ${currentUrl}: its Location header is not a resolvable URL.`,
761
- currentUrl,
762
- "redirect_invalid_location",
763
- false
764
- );
877
+ policy.assertUrl(next);
878
+ } catch (err) {
879
+ throw asRefusal(err, next, false, { redirectStatus: response.status, redirectTarget: next });
765
880
  }
766
- if (hops >= maxRedirects) {
881
+ }
882
+ hopInit = redirectedInit(hopInit, response.status);
883
+ if (new URL(next).origin !== new URL(currentUrl).origin) {
884
+ if (hopInit.body != null && (policy || carriesPayment)) {
767
885
  throw new MerchantEgressRefusedError(
768
- `Hosted egress policy refuses the redirect from ${currentUrl} to ${next}: the ${maxRedirects}-redirect budget for this request is spent.`,
886
+ carriesPayment ? `The ${response.status} redirect of a paid request from ${currentUrl} to ${next} was not followed: following it would re-send the paid request to a different origin. The paid request, payment header and body included, was already delivered to ${currentUrl}; nothing was sent to ${next}.` : `Refusing the ${response.status} redirect from ${currentUrl} to ${next}: it would re-send the request body to a different origin. The request was already sent to the first URL; nothing was sent to the redirect target.`,
769
887
  next,
770
- "redirect_budget_exceeded",
771
- false
888
+ "redirect_cross_origin_body",
889
+ false,
890
+ { redirectStatus: response.status, redirectTarget: next }
772
891
  );
773
892
  }
774
- try {
775
- egress.assertUrl(next);
776
- } catch (err) {
777
- throw asRefusal(err, next, false);
778
- }
779
- hops++;
780
- currentUrl = next;
781
- }
782
- } catch (err) {
783
- if (timeoutSignal.aborted) {
784
- throw new chunkH37YVYZA_cjs.MerchantTimeoutError(`Merchant request timed out after ${timeoutMs}ms: ${currentUrl}`);
893
+ hopInit = { ...hopInit, headers: crossOriginRedirectHeaders(hopInit.headers) };
785
894
  }
786
- throw err;
895
+ await response.body?.cancel().catch(() => void 0);
896
+ hops++;
897
+ currentUrl = next;
787
898
  }
788
899
  }
789
900
  /**
@@ -869,7 +980,7 @@ var McpMerchantTransport = class {
869
980
  text = await response.clone().text();
870
981
  } catch (err) {
871
982
  if (err instanceof MerchantEgressResponseCapError) throw err;
872
- if (isBodyPhaseTimeout(err)) throw new chunkH37YVYZA_cjs.MerchantTimeoutError(`Merchant response body read timed out.`);
983
+ if (isBodyPhaseTimeout(err)) throw new chunkMZKLAHBK_cjs.MerchantTimeoutError(`Merchant response body read timed out.`);
873
984
  return void 0;
874
985
  }
875
986
  if ((response.headers.get("content-type") ?? "").includes("text/event-stream")) {
@@ -894,7 +1005,7 @@ var McpMerchantTransport = class {
894
1005
  text = await response.clone().text();
895
1006
  } catch (err) {
896
1007
  if (err instanceof MerchantEgressResponseCapError) throw err;
897
- if (isBodyPhaseTimeout(err)) throw new chunkH37YVYZA_cjs.MerchantTimeoutError(`Merchant response body read timed out.`);
1008
+ if (isBodyPhaseTimeout(err)) throw new chunkMZKLAHBK_cjs.MerchantTimeoutError(`Merchant response body read timed out.`);
898
1009
  return response;
899
1010
  }
900
1011
  const message = selectJsonRpcResult(parseSseJsonRpcMessages(text));
@@ -956,12 +1067,12 @@ var McpMerchantTransport = class {
956
1067
  async deliverPayment(url, init, paymentHeader) {
957
1068
  assertSecureX402RetryTarget(url);
958
1069
  const headers = new Headers(init?.headers);
959
- const send = chunk22FJ4JQO_cjs.x402PaymentHeaderNamesFor(paymentHeader);
960
- for (const name of chunk22FJ4JQO_cjs.X402_PAYMENT_HEADER_NAMES) {
1070
+ const send = chunkIKQIIMM6_cjs.x402PaymentHeaderNamesFor(paymentHeader);
1071
+ for (const name of chunkIKQIIMM6_cjs.X402_PAYMENT_HEADER_NAMES) {
961
1072
  if (send.includes(name)) headers.set(name, paymentHeader);
962
1073
  else headers.delete(name);
963
1074
  }
964
- return this.fetch(url, withMcpPaymentMeta({ ...init, headers }, paymentHeader), this.budgetFor("delivery"), this.capFor("delivery"));
1075
+ return this.send(url, withMcpPaymentMeta({ ...init, headers }, paymentHeader), this.budgetFor("delivery"), this.capFor("delivery"), true);
965
1076
  }
966
1077
  /**
967
1078
  * #3171: deliver the payment; if the merchant answers its unknown-session
@@ -1044,7 +1155,7 @@ function mcpToolResultOf(value) {
1044
1155
  function extractMcpPaymentRequired(toolResult) {
1045
1156
  if (toolResult.isError !== true) return void 0;
1046
1157
  if (isRecord(toolResult.structuredContent)) {
1047
- const parsed = chunk22FJ4JQO_cjs.normalizePaymentRequired(toolResult.structuredContent);
1158
+ const parsed = chunkIKQIIMM6_cjs.normalizePaymentRequired(toolResult.structuredContent);
1048
1159
  if (parsed) return parsed;
1049
1160
  }
1050
1161
  if (Array.isArray(toolResult.content)) {
@@ -1056,7 +1167,7 @@ function extractMcpPaymentRequired(toolResult) {
1056
1167
  } catch {
1057
1168
  continue;
1058
1169
  }
1059
- const parsed = chunk22FJ4JQO_cjs.normalizePaymentRequired(candidate);
1170
+ const parsed = chunkIKQIIMM6_cjs.normalizePaymentRequired(candidate);
1060
1171
  if (parsed) return parsed;
1061
1172
  }
1062
1173
  }
@@ -1080,7 +1191,7 @@ function withMcpPaymentMeta(init, paymentHeader) {
1080
1191
  if (!request) return init;
1081
1192
  let envelope;
1082
1193
  try {
1083
- envelope = chunk22FJ4JQO_cjs.decodeBase64Json(paymentHeader);
1194
+ envelope = chunkIKQIIMM6_cjs.decodeBase64Json(paymentHeader);
1084
1195
  } catch {
1085
1196
  return init;
1086
1197
  }
@@ -1096,7 +1207,28 @@ function withMcpPaymentMeta(init, paymentHeader) {
1096
1207
  };
1097
1208
  }
1098
1209
  function encodeMcpSettlementReceipt(settlement) {
1099
- return chunk22FJ4JQO_cjs.encodeBase64Json(settlement);
1210
+ return chunkIKQIIMM6_cjs.encodeBase64Json(settlement);
1211
+ }
1212
+ function bodyCarriesX402Payment(body) {
1213
+ let text;
1214
+ if (typeof body === "string") text = body;
1215
+ else if (body instanceof Uint8Array || body instanceof ArrayBuffer) {
1216
+ try {
1217
+ text = new TextDecoder("utf-8", { fatal: true }).decode(body);
1218
+ } catch {
1219
+ return false;
1220
+ }
1221
+ } else return false;
1222
+ let request;
1223
+ try {
1224
+ request = JSON.parse(text);
1225
+ } catch {
1226
+ return false;
1227
+ }
1228
+ return Array.isArray(request) ? request.some(messageCarriesX402Payment) : messageCarriesX402Payment(request);
1229
+ }
1230
+ function messageCarriesX402Payment(message) {
1231
+ return isRecord(message) && isRecord(message.params) && isRecord(message.params._meta) && message.params._meta[MCP_X402_PAYMENT_META_KEY] !== void 0;
1100
1232
  }
1101
1233
  function parseJsonRpcToolsCall(body) {
1102
1234
  if (typeof body !== "string") return void 0;
@@ -1136,10 +1268,10 @@ function isRecord(value) {
1136
1268
  function isRedirectStatus(status) {
1137
1269
  return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
1138
1270
  }
1139
- function asRefusal(err, url, beforeRequest) {
1271
+ function asRefusal(err, url, beforeRequest, redirect) {
1140
1272
  if (!(err instanceof MerchantEgressRefusedError)) return err;
1141
- if (err.beforeRequest === beforeRequest) return err;
1142
- return new MerchantEgressRefusedError(err.message, url, err.refusal, beforeRequest);
1273
+ if (err.beforeRequest === beforeRequest && !redirect) return err;
1274
+ return new MerchantEgressRefusedError(err.message, url, err.refusal, beforeRequest, redirect);
1143
1275
  }
1144
1276
  async function captureMerchantResponse(response) {
1145
1277
  const merchant_body = await response.text().catch((err) => {
@@ -1214,7 +1346,7 @@ function deriveReadiness(status, allowances) {
1214
1346
  return allowances.some((allowance) => safeBigInt(allowance.remainingAtomic) > 0n) ? "ready" : "needs_approval";
1215
1347
  }
1216
1348
  function formatRemainingDisplay(tokenAddress, tokenSymbol, remainingAtomic) {
1217
- const token = chunk22FJ4JQO_cjs.resolveTokenFromAddress(tokenAddress);
1349
+ const token = chunkIKQIIMM6_cjs.resolveTokenFromAddress(tokenAddress);
1218
1350
  return token ? `${formatAtomicAmount(safeBigInt(remainingAtomic), token.decimals)} ${tokenSymbol}` : `${remainingAtomic} ${tokenSymbol} (atomic; unknown decimals)`;
1219
1351
  }
1220
1352
  function formatTokenAmount(atomic, decimals) {
@@ -1234,7 +1366,7 @@ function mapSupersession(raw) {
1234
1366
  replacementAgentId,
1235
1367
  supersededAt,
1236
1368
  warning: `This agent was replaced on its machine by agent ${replacementAgentId} at ${supersededAt}. This session is still running as the old agent: restart the agent runtime so it loads the new agent, and ask the user to remove this agent on its Haven agent page if it is no longer used \u2014 it keeps any budget it still holds until then.`,
1237
- nextAction: chunkH37YVYZA_cjs.AgentPaymentNextAction.StopAndTellUser,
1369
+ nextAction: chunkMZKLAHBK_cjs.AgentPaymentNextAction.StopAndTellUser,
1238
1370
  nextToolOmittedReason: "The next step is the user's: restart this session, and remove the superseded agent in the Haven dashboard. No Haven tool does either."
1239
1371
  };
1240
1372
  }
@@ -1259,6 +1391,7 @@ function mapTaskBudget(raw) {
1259
1391
  status: raw.status,
1260
1392
  expiresAt: raw.expires_at,
1261
1393
  isExpired: raw.is_expired,
1394
+ ...raw.is_live === void 0 ? {} : { isLive: raw.is_live },
1262
1395
  createdAt: raw.created_at,
1263
1396
  openedAt: raw.opened_at,
1264
1397
  closedAt: raw.closed_at,
@@ -1303,7 +1436,7 @@ function summarizePendingSubBudget(row) {
1303
1436
  };
1304
1437
  }
1305
1438
  function summarizeTaskBudget(taskBudget) {
1306
- const token = chunk22FJ4JQO_cjs.resolveTokenFromAddress(taskBudget.tokenAddress);
1439
+ const token = chunkIKQIIMM6_cjs.resolveTokenFromAddress(taskBudget.tokenAddress);
1307
1440
  const maxDisplay = token ? `${formatAtomicAmount(safeBigInt(taskBudget.maxAtomic), token.decimals)} ${token.symbol}` : `${taskBudget.maxAtomic} (atomic; unknown decimals)`;
1308
1441
  const spendDisplay = (atomic) => {
1309
1442
  if (atomic === null) return null;
@@ -1412,7 +1545,8 @@ var AccountReads = class {
1412
1545
  * an agent can still act on, and read-by-id (`haven_get_task_budget`) is
1413
1546
  * the any-status surface for everything else:
1414
1547
  *
1415
- * - `closing` ALWAYS stays visible, expired or not — the close submit is
1548
+ * - `closing` stays visible until its expiry (#3773; an expired `closing`
1549
+ * row drops, #3923) — the close submit is
1416
1550
  * in flight and the signer's close refusal tells the caller to re-check
1417
1551
  * exactly this row's status;
1418
1552
  * - `closed` rows drop (terminal — `closed_at` names what happened, and
@@ -1421,24 +1555,30 @@ var AccountReads = class {
1421
1555
  * budget reserves nothing and pays nothing);
1422
1556
  * - unexpired `pending` and `open` rows stay.
1423
1557
  *
1424
- * The same filter also runs here, client-side: it is what keeps the list
1425
- * bounded against a backend that predates `status=live`, which refuses the
1426
- * value with a 400 — that refusal (and only that) falls back to
1427
- * `status=all`. A row whose wire carries
1558
+ * A filter also runs here, client-side. A row carrying the backend's
1559
+ * `is_live` (#3922) is kept exactly when it is true — the server's own
1560
+ * `status=live` verdict. A row without it (an older backend) is derived by
1561
+ * the same rule: `closing` stays until its expiry, then drops (#3923), as
1562
+ * the backend does since #3773. That is
1563
+ * what keeps the list bounded against a backend that predates `status=live`,
1564
+ * which refuses the value with a 400 — that refusal (and only that) falls
1565
+ * back to `status=all`. A row whose wire carries
1428
1566
  * no `is_expired` is treated as unexpired — the degraded read errs toward
1429
1567
  * KEEPING rows, never toward hiding one the agent could still act on.
1430
1568
  */
1431
1569
  async listTaskBudgetsSummary() {
1432
1570
  try {
1433
1571
  const raw = await this.transport.get("/task-budgets?status=live").catch((error) => {
1434
- if (error instanceof chunkH37YVYZA_cjs.HavenApiError && error.statusCode === 400) {
1572
+ if (error instanceof chunkMZKLAHBK_cjs.HavenApiError && error.statusCode === 400) {
1435
1573
  return this.transport.get("/task-budgets?status=all");
1436
1574
  }
1437
1575
  throw error;
1438
1576
  });
1439
1577
  const rows = raw?.task_budgets;
1440
1578
  if (!Array.isArray(rows)) return [];
1441
- return rows.map((row) => mapTaskBudget(row)).filter((tb) => tb.status === "closing" || !tb.isExpired && tb.status !== "closed").map((tb) => summarizeTaskBudget(tb));
1579
+ return rows.map((row) => mapTaskBudget(row)).filter(
1580
+ (tb) => tb.isLive !== void 0 ? tb.isLive : !tb.isExpired && tb.status !== "closed"
1581
+ ).map((tb) => summarizeTaskBudget(tb));
1442
1582
  } catch {
1443
1583
  return [];
1444
1584
  }
@@ -1539,7 +1679,7 @@ var AccountReads = class {
1539
1679
  payment: payment2,
1540
1680
  allowance: null,
1541
1681
  warnings: [{
1542
- code: chunkH37YVYZA_cjs.AgentPaymentWarningCode.AllowanceCheckUnavailable,
1682
+ code: chunkMZKLAHBK_cjs.AgentPaymentWarningCode.AllowanceCheckUnavailable,
1543
1683
  message: `Could not read the post-purchase allowance/budget for payment ${paymentId} (${detail}). The payment itself succeeded \u2014 the on-chain policy remains the actual spend gate; this only affects the remaining-budget figure reported here.`
1544
1684
  }]
1545
1685
  });
@@ -1632,7 +1772,7 @@ var AccountReads = class {
1632
1772
  */
1633
1773
  async getReceipt(paymentId) {
1634
1774
  const { receipt } = await this.transport.get(`/payments/${paymentId}/receipt`);
1635
- return { receipt, verification: chunk6LEXYQ7J_cjs.verifyPaymentReceipt(receipt) };
1775
+ return { receipt, verification: chunkDXBAN4SN_cjs.verifyPaymentReceipt(receipt) };
1636
1776
  }
1637
1777
  async fetchAgent() {
1638
1778
  const raw = await this.transport.get("/machine-payments/agent");
@@ -1668,7 +1808,7 @@ function isWaitTimeout(err) {
1668
1808
  async function waitForSweepTx(tx) {
1669
1809
  let receipt;
1670
1810
  try {
1671
- receipt = await tx.wait(1, chunkH37YVYZA_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS);
1811
+ receipt = await tx.wait(1, chunkMZKLAHBK_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS);
1672
1812
  } catch (err) {
1673
1813
  if (!isWaitTimeout(err)) throw err;
1674
1814
  return { txHash: tx.hash, confirmation: "unconfirmed" };
@@ -1682,16 +1822,16 @@ var DelegateSweepApi = class {
1682
1822
  }
1683
1823
  options;
1684
1824
  async sweepDelegate() {
1685
- if (!this.options.delegateKey) throw new chunkH37YVYZA_cjs.HavenSigningError("delegateKey is required for sweepDelegate.");
1825
+ if (!this.options.delegateKey) throw new chunkMZKLAHBK_cjs.HavenSigningError("delegateKey is required for sweepDelegate.");
1686
1826
  const agent = await this.options.getAgent();
1687
- if (!agent.delegateAddress) throw new chunkH37YVYZA_cjs.HavenApiError("Agent has no delegate address.", 422);
1827
+ if (!agent.delegateAddress) throw new chunkMZKLAHBK_cjs.HavenApiError("Agent has no delegate address.", 422);
1688
1828
  const rpcUrl = this.options.chainRpcs[agent.chainId];
1689
- if (!rpcUrl) throw new chunkH37YVYZA_cjs.HavenApiError(`chainRpcs[${agent.chainId}] must be configured to sweep the delegate wallet.`, 422);
1829
+ if (!rpcUrl) throw new chunkMZKLAHBK_cjs.HavenApiError(`chainRpcs[${agent.chainId}] must be configured to sweep the delegate wallet.`, 422);
1690
1830
  const provider = createJsonRpcProvider(rpcUrl);
1691
1831
  const wallet = createWallet(this.options.delegateKey, provider);
1692
1832
  const transfers = [];
1693
- if (chunk22FJ4JQO_cjs.isSweepableChain(agent.chainId)) {
1694
- const contract = createErc20Contract(chunk22FJ4JQO_cjs.sweepUsdcAddress(agent.chainId), ["function balanceOf(address) view returns (uint256)", "function transfer(address to, uint256 amount) returns (bool)"], wallet);
1833
+ if (chunkIKQIIMM6_cjs.isSweepableChain(agent.chainId)) {
1834
+ const contract = createErc20Contract(chunkIKQIIMM6_cjs.sweepUsdcAddress(agent.chainId), ["function balanceOf(address) view returns (uint256)", "function transfer(address to, uint256 amount) returns (bool)"], wallet);
1695
1835
  const balance2 = await contract.balanceOf(agent.delegateAddress);
1696
1836
  if (balance2 > 0n) {
1697
1837
  const tx = await contract.transfer(agent.accountAddress, balance2);
@@ -1779,7 +1919,7 @@ function snapshotRequestBody(body) {
1779
1919
  if (body == null) return void 0;
1780
1920
  if (typeof body === "string") return body;
1781
1921
  if (body instanceof URLSearchParams) return body.toString();
1782
- throw new chunkH37YVYZA_cjs.HavenApiError(
1922
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
1783
1923
  "Quote helpers can only capture resumable request bodies that are strings or URLSearchParams. For streams, blobs, or binary bodies, preserve the original request yourself and call the matching resume method with fresh init.",
1784
1924
  400
1785
1925
  );
@@ -1800,12 +1940,12 @@ function requestInitFromSnapshot(request) {
1800
1940
  };
1801
1941
  }
1802
1942
  function noCompatiblePaymentOptionError(accepts) {
1803
- const erc7710Only = chunk22FJ4JQO_cjs.selectErc7710PaymentOption(accepts) !== null;
1943
+ const erc7710Only = chunkIKQIIMM6_cjs.selectErc7710PaymentOption(accepts) !== null;
1804
1944
  const unsupportedOnly = !erc7710Only && accepts.some(
1805
- (opt) => opt !== null && typeof opt === "object" && !chunk22FJ4JQO_cjs.isErc7710Option(opt) && (chunk22FJ4JQO_cjs.x402AssetTransferMethod(opt) !== null || opt.extra?.paymentFlow !== void 0)
1945
+ (opt) => opt !== null && typeof opt === "object" && !chunkIKQIIMM6_cjs.isErc7710Option(opt) && (chunkIKQIIMM6_cjs.x402AssetTransferMethod(opt) !== null || opt.extra?.paymentFlow !== void 0)
1806
1946
  );
1807
1947
  const offeredSchemes = nonExactSchemesOnly(accepts);
1808
- return new chunkH37YVYZA_cjs.HavenApiError(
1948
+ return new chunkMZKLAHBK_cjs.HavenApiError(
1809
1949
  "No compatible payment option found in x402 requirements. Haven supports standard x402 exact payments on Base USDC." + (offeredSchemes ? ` The merchant offered only ${offeredSchemes}; Haven pays only the 'exact' scheme. For a request with a body, this often means the body or its Content-Type was missing or invalid: send the full request again (method, body, and Content-Type: application/json for a JSON API).` : erc7710Only ? " The only Haven-compatible option this merchant advertises is tagged extra.assetTransferMethod: 'erc7710' (direct settlement), which this EIP-3009 payment path cannot settle \u2014 the limitation is the settlement scheme, not the asset. Paying this merchant requires a delegation-rail erc7710 flow (settleX402Erc7710, or the hosted MCP purchase tools)." : unsupportedOnly ? " Every option this merchant advertises asks for a transfer method or payment flow Haven cannot construct (for example extra.assetTransferMethod: 'permit2', or an unrecognized extra.paymentFlow). No payment intent was created and no funds moved." : ""),
1810
1950
  400
1811
1951
  );
@@ -1824,15 +1964,15 @@ function nonExactSchemesOnly(accepts) {
1824
1964
  return schemes.map((s) => `'${s}'`).join(", ");
1825
1965
  }
1826
1966
  function buildX402Quote(paymentRequired, request, idempotencyKey, mcpTransport) {
1827
- const standard = chunk22FJ4JQO_cjs.selectStandardPaymentOption(paymentRequired.accepts);
1828
- const option = standard ?? chunk22FJ4JQO_cjs.selectErc7710PaymentOption(paymentRequired.accepts);
1967
+ const standard = chunkIKQIIMM6_cjs.selectStandardPaymentOption(paymentRequired.accepts);
1968
+ const option = standard ?? chunkIKQIIMM6_cjs.selectErc7710PaymentOption(paymentRequired.accepts);
1829
1969
  if (!option) {
1830
1970
  throw noCompatiblePaymentOptionError(paymentRequired.accepts);
1831
1971
  }
1832
- const token = chunk22FJ4JQO_cjs.resolveTokenFromAddress(option.asset, option.network);
1972
+ const token = chunkIKQIIMM6_cjs.resolveTokenFromAddress(option.asset, option.network);
1833
1973
  return {
1834
1974
  rail: "x402",
1835
- idempotencyKey: idempotencyKey ?? chunk22FJ4JQO_cjs.buildX402IdempotencyKey(paymentRequired, option),
1975
+ idempotencyKey: idempotencyKey ?? chunkIKQIIMM6_cjs.buildX402IdempotencyKey(paymentRequired, option),
1836
1976
  paymentRequired,
1837
1977
  accepted: option,
1838
1978
  acceptedScheme: standard ? "standard" : "erc7710",
@@ -1846,8 +1986,8 @@ function buildX402Quote(paymentRequired, request, idempotencyKey, mcpTransport)
1846
1986
  resourceUrlDiffersFromRequest: paymentRequired.resource.url !== request.url,
1847
1987
  description: paymentRequired.resource.description ?? option.description ?? null,
1848
1988
  mimeType: paymentRequired.resource.mimeType ?? option.mimeType ?? null,
1849
- amountAtomic: chunk22FJ4JQO_cjs.x402AuthorizationAmount(option),
1850
- amount: decimalFromUsdcAtomic(chunk22FJ4JQO_cjs.x402AuthorizationAmount(option)),
1989
+ amountAtomic: chunkIKQIIMM6_cjs.x402AuthorizationAmount(option),
1990
+ amount: decimalFromUsdcAtomic(chunkIKQIIMM6_cjs.x402AuthorizationAmount(option)),
1851
1991
  token: token?.symbol ?? "USDC",
1852
1992
  // #1351: null when the asset is unrecognised on this network — the
1853
1993
  // `token` fallback above is a LABEL, not evidence of 6 decimals, and a
@@ -1886,7 +2026,7 @@ function buildX402Receipt(input) {
1886
2026
  payTo: input.merchantTo ?? input.accepted.payTo
1887
2027
  },
1888
2028
  x402: {
1889
- amount: chunk22FJ4JQO_cjs.x402AuthorizationAmount(input.accepted),
2029
+ amount: chunkIKQIIMM6_cjs.x402AuthorizationAmount(input.accepted),
1890
2030
  token: input.token,
1891
2031
  network: input.accepted.network,
1892
2032
  asset: input.accepted.asset,
@@ -1895,7 +2035,7 @@ function buildX402Receipt(input) {
1895
2035
  };
1896
2036
  }
1897
2037
  function buildX402ResumeState(input) {
1898
- const token = chunk22FJ4JQO_cjs.resolveTokenFromAddress(input.accepted.asset, input.accepted.network);
2038
+ const token = chunkIKQIIMM6_cjs.resolveTokenFromAddress(input.accepted.asset, input.accepted.network);
1899
2039
  return {
1900
2040
  rail: "x402",
1901
2041
  paymentId: input.paymentId,
@@ -1906,8 +2046,8 @@ function buildX402ResumeState(input) {
1906
2046
  request: input.request,
1907
2047
  resourceUrl: input.paymentRequired.resource.url,
1908
2048
  description: input.paymentRequired.resource.description ?? input.accepted.description ?? null,
1909
- amountAtomic: chunk22FJ4JQO_cjs.x402AuthorizationAmount(input.accepted),
1910
- amount: decimalFromUsdcAtomic(chunk22FJ4JQO_cjs.x402AuthorizationAmount(input.accepted)),
2049
+ amountAtomic: chunkIKQIIMM6_cjs.x402AuthorizationAmount(input.accepted),
2050
+ amount: decimalFromUsdcAtomic(chunkIKQIIMM6_cjs.x402AuthorizationAmount(input.accepted)),
1911
2051
  token: token?.symbol ?? "USDC",
1912
2052
  asset: input.accepted.asset,
1913
2053
  network: input.accepted.network,
@@ -1916,7 +2056,7 @@ function buildX402ResumeState(input) {
1916
2056
  };
1917
2057
  }
1918
2058
  function attachX402ResumeState(err, paymentRequired, accepted, idempotencyKey, request) {
1919
- if (!(err instanceof chunkH37YVYZA_cjs.HavenPaymentStateError)) return;
2059
+ if (!(err instanceof chunkMZKLAHBK_cjs.HavenPaymentStateError)) return;
1920
2060
  if (err.state.rail !== "x402") return;
1921
2061
  err.resumeState = buildX402ResumeState({
1922
2062
  paymentId: err.state.paymentId,
@@ -1937,17 +2077,17 @@ function attachResumeState(err, input) {
1937
2077
  }
1938
2078
  function assertCanResumeX402(status, paymentRequired, option) {
1939
2079
  if (status.rail !== "x402") {
1940
- throw new chunkH37YVYZA_cjs.HavenPaymentStateError(
2080
+ throw new chunkMZKLAHBK_cjs.HavenPaymentStateError(
1941
2081
  `Payment ${status.paymentId} is ${status.rail}, not x402.`,
1942
2082
  409,
1943
2083
  status
1944
2084
  );
1945
2085
  }
1946
- if (status.nextAction !== chunkH37YVYZA_cjs.AgentPaymentNextAction.RetryOriginalX402Request) {
1947
- throw new chunkH37YVYZA_cjs.HavenPaymentStateError(status.message, paymentStateStatusCode(status.status, 409), status);
2086
+ if (status.nextAction !== chunkMZKLAHBK_cjs.AgentPaymentNextAction.RetryOriginalX402Request) {
2087
+ throw new chunkMZKLAHBK_cjs.HavenPaymentStateError(status.message, paymentStateStatusCode(status.status, 409), status);
1948
2088
  }
1949
2089
  if (!status.txHash) {
1950
- throw new chunkH37YVYZA_cjs.HavenApiError(
2090
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
1951
2091
  `x402 payment ${status.paymentId} is ready to retry but has no Haven transaction hash.`,
1952
2092
  502,
1953
2093
  status,
@@ -1955,7 +2095,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
1955
2095
  );
1956
2096
  }
1957
2097
  if (status.resourceUrl && status.resourceUrl !== paymentRequired.resource.url) {
1958
- throw new chunkH37YVYZA_cjs.HavenApiError(
2098
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
1959
2099
  "x402 resume request does not match the approved resource URL.",
1960
2100
  409,
1961
2101
  { status, paymentRequired },
@@ -1963,7 +2103,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
1963
2103
  );
1964
2104
  }
1965
2105
  if (status.merchantAddress && !sameAddress(status.merchantAddress, option.payTo)) {
1966
- throw new chunkH37YVYZA_cjs.HavenApiError(
2106
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
1967
2107
  "x402 resume request does not match the approved merchant.",
1968
2108
  409,
1969
2109
  { status, selectedPayment: option },
@@ -1972,7 +2112,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
1972
2112
  }
1973
2113
  const optionChainId = chainIdFromNetwork(option.network);
1974
2114
  if (status.chainId && optionChainId && status.chainId !== optionChainId) {
1975
- throw new chunkH37YVYZA_cjs.HavenApiError(
2115
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
1976
2116
  "x402 resume request does not match the approved network.",
1977
2117
  409,
1978
2118
  { status, selectedPayment: option },
@@ -1980,7 +2120,7 @@ function assertCanResumeX402(status, paymentRequired, option) {
1980
2120
  );
1981
2121
  }
1982
2122
  if (status.token && status.token !== "USDC") {
1983
- throw new chunkH37YVYZA_cjs.HavenApiError(
2123
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
1984
2124
  "x402 resume request does not match the approved token.",
1985
2125
  409,
1986
2126
  { status, selectedPayment: option },
@@ -1988,9 +2128,9 @@ function assertCanResumeX402(status, paymentRequired, option) {
1988
2128
  );
1989
2129
  }
1990
2130
  const approvedAmount = status.amount ? normalizeDecimal(status.amount) : "";
1991
- const requestedAmount = normalizeDecimal(decimalFromUsdcAtomic(chunk22FJ4JQO_cjs.x402AuthorizationAmount(option)));
2131
+ const requestedAmount = normalizeDecimal(decimalFromUsdcAtomic(chunkIKQIIMM6_cjs.x402AuthorizationAmount(option)));
1992
2132
  if (approvedAmount && approvedAmount !== requestedAmount) {
1993
- throw new chunkH37YVYZA_cjs.HavenApiError(
2133
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
1994
2134
  "x402 resume request does not match the approved amount.",
1995
2135
  409,
1996
2136
  { status, selectedPayment: option },
@@ -2046,7 +2186,7 @@ var X402FundingLeg = class {
2046
2186
  const cached = this.receiptCache.get(idempotencyKey);
2047
2187
  if (!cached || cached.expiresAt <= Date.now()) return void 0;
2048
2188
  if (!sameX402TaskBudget(cached.taskBudgetId, taskBudgetId) || !sameX402TaskBudget(cached.subBudgetId, subBudgetId)) {
2049
- throw new chunkH37YVYZA_cjs.X402TaskBudgetMismatchError(
2189
+ throw new chunkMZKLAHBK_cjs.X402TaskBudgetMismatchError(
2050
2190
  `The x402 idempotency key '${idempotencyKey}' was already used under a different authorizing budget (task '${cached.taskBudgetId ?? "none"}' vs '${taskBudgetId ?? "none"}', sub '${cached.subBudgetId ?? "none"}' vs '${subBudgetId ?? "none"}'). Pass a new idempotencyKey to pay under this budget.`,
2051
2191
  idempotencyKey,
2052
2192
  cached.taskBudgetId,
@@ -2067,7 +2207,7 @@ var X402FundingLeg = class {
2067
2207
  url: paymentRequired.resource.url,
2068
2208
  payTo: this.delegateAddress,
2069
2209
  merchantPayTo: option.payTo,
2070
- amount: chunk22FJ4JQO_cjs.x402AuthorizationAmount(option),
2210
+ amount: chunkIKQIIMM6_cjs.x402AuthorizationAmount(option),
2071
2211
  asset: option.asset,
2072
2212
  network: option.network,
2073
2213
  description: paymentRequired.resource.description,
@@ -2086,17 +2226,17 @@ var X402FundingLeg = class {
2086
2226
  ...subBudgetId ? { subBudgetId } : {}
2087
2227
  });
2088
2228
  const state = paymentStateFromRaw("x402 payment", raw);
2089
- const executedReplay = raw.success && raw.tx_hash ? "idempotency-collision" : state?.nextAction === chunkH37YVYZA_cjs.AgentPaymentNextAction.RetryOriginalX402Request ? "approval-resume" : null;
2229
+ const executedReplay = raw.success && raw.tx_hash ? "idempotency-collision" : state?.nextAction === chunkMZKLAHBK_cjs.AgentPaymentNextAction.RetryOriginalX402Request ? "approval-resume" : null;
2090
2230
  if (executedReplay) {
2091
2231
  const canFund = await this.delegateCanFund(
2092
2232
  raw.chain_id ?? state?.chainId ?? chainIdFromNetwork(option.network),
2093
2233
  option.asset,
2094
- chunk22FJ4JQO_cjs.x402AuthorizationAmount(option)
2234
+ chunkIKQIIMM6_cjs.x402AuthorizationAmount(option)
2095
2235
  );
2096
2236
  const refuse = executedReplay === "idempotency-collision" ? canFund !== true : canFund === false;
2097
2237
  if (refuse) {
2098
2238
  const settledReceipt = state && executedReplay === "approval-resume" ? this.receiptFromStatus(paymentRequired, option, void 0, state) : this.receiptFromAuthorization(paymentRequired, option, void 0, raw);
2099
- throw new chunkH37YVYZA_cjs.X402AlreadySettledError(
2239
+ throw new chunkMZKLAHBK_cjs.X402AlreadySettledError(
2100
2240
  canFund === false ? "This x402 payment already settled \u2014 the delegate no longer holds the funds to authorize it again. To buy the same item a second time, pass a distinct `idempotencyKey`; the synthesised key intentionally collapses repeat calls for the same product within a 5-minute window so a retried request cannot pay twice." : "This x402 payment already settled, and whether the delegate can still fund a new authorization could not be verified (no `chainRpcs` entry for this chain). Refusing rather than issue an authorization that may be unfundable. To buy the same item a second time, pass a distinct `idempotencyKey`; to finish an interrupted payment, resume it by `paymentId`.",
2101
2241
  settledReceipt,
2102
2242
  canFund === false ? "settled" : "unverifiable"
@@ -2109,18 +2249,18 @@ var X402FundingLeg = class {
2109
2249
  this.cacheReceipt(idempotencyKey, paymentHeader, receipt2, taskBudgetId, subBudgetId);
2110
2250
  return receipt2;
2111
2251
  }
2112
- if (state?.nextAction === chunkH37YVYZA_cjs.AgentPaymentNextAction.RetryOriginalX402Request) {
2252
+ if (state?.nextAction === chunkMZKLAHBK_cjs.AgentPaymentNextAction.RetryOriginalX402Request) {
2113
2253
  const receipt2 = this.receiptFromStatus(paymentRequired, option, paymentHeader, state);
2114
2254
  this.cacheReceipt(idempotencyKey, paymentHeader, receipt2, taskBudgetId, subBudgetId);
2115
2255
  return receipt2;
2116
2256
  }
2117
2257
  this.assertSignableAuthorizationState("x402 payment", raw);
2118
2258
  if (!raw.sign_data?.hash) {
2119
- throw new chunkH37YVYZA_cjs.HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
2259
+ throw new chunkMZKLAHBK_cjs.HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
2120
2260
  }
2121
2261
  const sig = await this.signForData(raw.sign_data, {
2122
2262
  asset: option.asset,
2123
- amount: chunk22FJ4JQO_cjs.x402AuthorizationAmount(option)
2263
+ amount: chunkIKQIIMM6_cjs.x402AuthorizationAmount(option)
2124
2264
  });
2125
2265
  const execResult = await this.post(
2126
2266
  `/payments/${raw.payment_id}/sign`,
@@ -2155,10 +2295,10 @@ var X402FundingLeg = class {
2155
2295
  */
2156
2296
  async createPaymentHeader(paymentRequired, option, paymentId) {
2157
2297
  if (!this.delegateKey) {
2158
- throw new chunkH37YVYZA_cjs.HavenSigningError("delegateKey is required to sign x402 payment headers.");
2298
+ throw new chunkMZKLAHBK_cjs.HavenSigningError("delegateKey is required to sign x402 payment headers.");
2159
2299
  }
2160
2300
  const account = accounts.privateKeyToAccount(this.delegateKey);
2161
- const requirements = chunk22FJ4JQO_cjs.toStandardPaymentRequirements(paymentRequired, option);
2301
+ const requirements = chunkIKQIIMM6_cjs.toStandardPaymentRequirements(paymentRequired, option);
2162
2302
  let header;
2163
2303
  if (paymentId) {
2164
2304
  const unsigned = schemes.exact.evm.preparePaymentHeader(
@@ -2166,7 +2306,7 @@ var X402FundingLeg = class {
2166
2306
  paymentRequired.x402Version,
2167
2307
  requirements
2168
2308
  );
2169
- unsigned.payload.authorization.nonce = chunk22FJ4JQO_cjs.deriveX402PaymentNonce(paymentId);
2309
+ unsigned.payload.authorization.nonce = chunkIKQIIMM6_cjs.deriveX402PaymentNonce(paymentId);
2170
2310
  const signed = await schemes.exact.evm.signPaymentHeader(account, requirements, unsigned);
2171
2311
  header = schemes.exact.evm.encodePayment(signed);
2172
2312
  } else {
@@ -2177,15 +2317,15 @@ var X402FundingLeg = class {
2177
2317
  );
2178
2318
  }
2179
2319
  if (paymentRequired.x402Version < 2) return header;
2180
- const payment = chunk22FJ4JQO_cjs.decodeBase64Json(header);
2181
- return chunk22FJ4JQO_cjs.encodeBase64Json(chunk22FJ4JQO_cjs.x402V2PaymentEnvelope(paymentRequired, option, payment.payload));
2320
+ const payment = chunkIKQIIMM6_cjs.decodeBase64Json(header);
2321
+ return chunkIKQIIMM6_cjs.encodeBase64Json(chunkIKQIIMM6_cjs.x402V2PaymentEnvelope(paymentRequired, option, payment.payload));
2182
2322
  }
2183
2323
  // ── Receipt mapping ──────────────────────────────────────────────
2184
2324
  receiptFromAuthorization(paymentRequired, option, paymentHeader, raw, execResult) {
2185
2325
  const txHash = execResult?.tx_hash ?? raw.tx_hash ?? "";
2186
2326
  const chainId = execResult?.chain_id ?? raw.chain_id ?? chainIdFromNetwork(option.network);
2187
2327
  const token = execResult?.token ?? raw.token ?? "USDC";
2188
- const amount = execResult?.amount ?? raw.amount ?? decimalFromUsdcAtomic(chunk22FJ4JQO_cjs.x402AuthorizationAmount(option));
2328
+ const amount = execResult?.amount ?? raw.amount ?? decimalFromUsdcAtomic(chunkIKQIIMM6_cjs.x402AuthorizationAmount(option));
2189
2329
  const to = execResult?.to ?? raw.to ?? this.delegateAddress ?? "";
2190
2330
  const explorerUrl = execResult?.explorer_url ?? raw.explorer_url ?? explorerUrlOrEmpty(chainId, txHash);
2191
2331
  const merchantTo = execResult?.merchant_to ?? raw.merchant_to ?? option.payTo;
@@ -2207,7 +2347,7 @@ var X402FundingLeg = class {
2207
2347
  }
2208
2348
  receiptFromStatus(paymentRequired, option, paymentHeader, status) {
2209
2349
  if (!status.txHash) {
2210
- throw new chunkH37YVYZA_cjs.HavenApiError(
2350
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2211
2351
  `x402 payment ${status.paymentId} is ready to retry but has no Haven transaction hash.`,
2212
2352
  502,
2213
2353
  status,
@@ -2218,7 +2358,7 @@ var X402FundingLeg = class {
2218
2358
  paymentId: status.paymentId,
2219
2359
  txHash: status.txHash,
2220
2360
  token: status.token || "USDC",
2221
- amount: status.amount || decimalFromUsdcAtomic(chunk22FJ4JQO_cjs.x402AuthorizationAmount(option)),
2361
+ amount: status.amount || decimalFromUsdcAtomic(chunkIKQIIMM6_cjs.x402AuthorizationAmount(option)),
2222
2362
  to: this.delegateAddress ?? "",
2223
2363
  resourceUrl: paymentRequired.resource.url,
2224
2364
  explorerUrl: explorerUrlOrEmpty(status.chainId, status.txHash),
@@ -2246,7 +2386,7 @@ var X402FundingLeg = class {
2246
2386
  const provider = createJsonRpcProvider(rpcUrl);
2247
2387
  const onChainReceipt = await provider.waitForTransaction(txHash, 1, timeoutMs);
2248
2388
  if (!onChainReceipt || onChainReceipt.status !== 1) {
2249
- throw new chunkH37YVYZA_cjs.HavenApiError(
2389
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2250
2390
  "Funding tx did not confirm on-chain within the timeout window.",
2251
2391
  500,
2252
2392
  { txHash, chainId }
@@ -2295,7 +2435,7 @@ var X402FundingLeg = class {
2295
2435
  };
2296
2436
  function getPaymentHeaderValidBefore(paymentHeader) {
2297
2437
  try {
2298
- const payment = chunk22FJ4JQO_cjs.decodeBase64Json(
2438
+ const payment = chunkIKQIIMM6_cjs.decodeBase64Json(
2299
2439
  paymentHeader
2300
2440
  );
2301
2441
  const payload = payment.payload;
@@ -2350,7 +2490,7 @@ var X402Erc7710 = class {
2350
2490
  */
2351
2491
  async settle(paymentRequired, options = {}) {
2352
2492
  if (!this.delegateKey) {
2353
- throw new chunkH37YVYZA_cjs.HavenSigningError(
2493
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
2354
2494
  "delegateKey is required for x402 payments. Pass it in the HavenClient config."
2355
2495
  );
2356
2496
  }
@@ -2375,21 +2515,21 @@ var X402Erc7710 = class {
2375
2515
  async prepare(paymentRequired, options = {}) {
2376
2516
  const delegationRail = options.delegationRail ?? (await this.getAgent()).executionRail === "delegation";
2377
2517
  if (!delegationRail) {
2378
- throw new chunkH37YVYZA_cjs.HavenApiError(
2518
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2379
2519
  "erc7710 settlement requires a delegation-rail account; this one is not on it. Use authorizeX402() for the standard EIP-3009 path.",
2380
2520
  400
2381
2521
  );
2382
2522
  }
2383
- const selection = chunk22FJ4JQO_cjs.selectX402SettlementScheme(paymentRequired.accepts, { delegationRail });
2523
+ const selection = chunkIKQIIMM6_cjs.selectX402SettlementScheme(paymentRequired.accepts, { delegationRail });
2384
2524
  if (!selection || selection.scheme !== "erc7710") {
2385
- throw new chunkH37YVYZA_cjs.HavenApiError(
2525
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2386
2526
  "This merchant does not advertise an erc7710 settlement option (no accepts[] entry carries extra.assetTransferMethod: 'erc7710'). Use authorizeX402() for the standard EIP-3009 path.",
2387
2527
  400
2388
2528
  );
2389
2529
  }
2390
2530
  const option = selection.option;
2391
2531
  const merchantPayTo = option.payTo;
2392
- const amountAtomic = chunk22FJ4JQO_cjs.x402AuthorizationAmount(option);
2532
+ const amountAtomic = chunkIKQIIMM6_cjs.x402AuthorizationAmount(option);
2393
2533
  const raw = await this.post("/x402", {
2394
2534
  url: options.resourceUrl ?? paymentRequired.resource?.url,
2395
2535
  // #2373: the full 402 challenge, persisted verbatim by the backend
@@ -2433,24 +2573,24 @@ var X402Erc7710 = class {
2433
2573
  ...options.subBudgetId ? { subBudgetId: options.subBudgetId } : {}
2434
2574
  });
2435
2575
  if (!raw.payment_id) {
2436
- throw new chunkH37YVYZA_cjs.HavenApiError("No payment_id returned from x402/authorize", 500, raw);
2576
+ throw new chunkMZKLAHBK_cjs.HavenApiError("No payment_id returned from x402/authorize", 500, raw);
2437
2577
  }
2438
2578
  if (raw.status === "confirmed" && raw.tx_hash) {
2439
2579
  const requestedUrl = options.resourceUrl ?? paymentRequired.resource?.url;
2440
2580
  const samePurchase = typeof raw.to === "string" && raw.to.toLowerCase() === merchantPayTo.toLowerCase() && raw.resource_url === requestedUrl;
2441
2581
  if (!samePurchase) {
2442
- throw new chunkH37YVYZA_cjs.HavenApiError(
2582
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2443
2583
  `Idempotency key already belongs to confirmed payment ${raw.payment_id}, which is not this erc7710 purchase (different payee or resource). Nothing was signed and nothing was charged. Check that payment's status before buying again: a funded but undelivered EIP-3009 payment is recovered, not paid twice. Otherwise use a new idempotency key for this purchase.`,
2444
2584
  409,
2445
2585
  raw,
2446
2586
  raw.payment_id
2447
2587
  );
2448
2588
  }
2449
- throw new chunkH37YVYZA_cjs.X402Erc7710AlreadySettledError(raw.payment_id, raw.tx_hash, raw);
2589
+ throw new chunkMZKLAHBK_cjs.X402Erc7710AlreadySettledError(raw.payment_id, raw.tx_hash, raw);
2450
2590
  }
2451
2591
  const signData = raw.sign_data;
2452
2592
  if (signData?.signature_scheme !== "eip712_delegation" || !signData.typed_data) {
2453
- throw new chunkH37YVYZA_cjs.HavenApiError(
2593
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2454
2594
  `x402/authorize did not return an erc7710 settlement child (signature_scheme was ${JSON.stringify(signData?.signature_scheme)}). Refusing to sign a payload this path did not ask for.`,
2455
2595
  500,
2456
2596
  raw
@@ -2482,9 +2622,9 @@ var X402Erc7710 = class {
2482
2622
  try {
2483
2623
  settled = await this.post(`/x402/${paymentId}/settle`, { signature });
2484
2624
  } catch (err) {
2485
- const body = err instanceof chunkH37YVYZA_cjs.HavenApiError ? err.body : void 0;
2486
- if (err instanceof chunkH37YVYZA_cjs.HavenApiError && err.statusCode === 409 && body?.code === "payment_already_settled" && typeof body.tx_hash === "string") {
2487
- throw new chunkH37YVYZA_cjs.X402Erc7710AlreadySettledError(
2625
+ const body = err instanceof chunkMZKLAHBK_cjs.HavenApiError ? err.body : void 0;
2626
+ if (err instanceof chunkMZKLAHBK_cjs.HavenApiError && err.statusCode === 409 && body?.code === "payment_already_settled" && typeof body.tx_hash === "string") {
2627
+ throw new chunkMZKLAHBK_cjs.X402Erc7710AlreadySettledError(
2488
2628
  typeof body.payment_id === "string" ? body.payment_id : paymentId,
2489
2629
  body.tx_hash,
2490
2630
  body
@@ -2493,7 +2633,7 @@ var X402Erc7710 = class {
2493
2633
  throw err;
2494
2634
  }
2495
2635
  if (!settled.payment_header) {
2496
- throw new chunkH37YVYZA_cjs.HavenApiError(
2636
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2497
2637
  "x402 settle returned no payment_header \u2014 the merchant cannot be retried.",
2498
2638
  500,
2499
2639
  settled
@@ -2503,9 +2643,9 @@ var X402Erc7710 = class {
2503
2643
  }
2504
2644
  };
2505
2645
  function settlementExpectationFromQuote(settlement) {
2506
- const chainId = chunkH37YVYZA_cjs.chainIdForNetwork(settlement.network);
2646
+ const chainId = chunkMZKLAHBK_cjs.chainIdForNetwork(settlement.network);
2507
2647
  if (chainId === void 0) {
2508
- throw new chunkH37YVYZA_cjs.HavenSigningError(
2648
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
2509
2649
  `Refusing to sign the x402 settlement child: the merchant's network ${JSON.stringify(settlement.network)} is not one this SDK can verify a settlement child on.`
2510
2650
  );
2511
2651
  }
@@ -2555,7 +2695,7 @@ function x402ToolReceipt(receipt) {
2555
2695
  };
2556
2696
  }
2557
2697
  function toolError(err) {
2558
- if (err instanceof chunkH37YVYZA_cjs.HavenPaymentStateError) {
2698
+ if (err instanceof chunkMZKLAHBK_cjs.HavenPaymentStateError) {
2559
2699
  return {
2560
2700
  success: false,
2561
2701
  payment_id: err.state.paymentId,
@@ -2600,7 +2740,7 @@ function toolError(err) {
2600
2740
  error: err.message
2601
2741
  };
2602
2742
  }
2603
- if (err instanceof chunkH37YVYZA_cjs.HavenApiError) {
2743
+ if (err instanceof chunkMZKLAHBK_cjs.HavenApiError) {
2604
2744
  return {
2605
2745
  success: false,
2606
2746
  status_code: err.statusCode,
@@ -2614,6 +2754,26 @@ function toolError(err) {
2614
2754
  };
2615
2755
  }
2616
2756
 
2757
+ // src/merchant-answer.ts
2758
+ function decidePostFundingMerchantAnswer(input) {
2759
+ const inBandChallenge = input.toolResult ? extractMcpPaymentRequired(input.toolResult) : void 0;
2760
+ const headerReceipt = input.paymentResponseHeader;
2761
+ const protocolReceiptHeaderName = headerReceipt ? "PAYMENT-RESPONSE" : input.metaSettlement ? `_meta.${MCP_X402_PAYMENT_RESPONSE_META_KEY}` : void 0;
2762
+ const protocolReceiptHeader = headerReceipt ?? (input.metaSettlement ? encodeMcpSettlementReceipt(input.metaSettlement) : void 0);
2763
+ const settlement = parseMerchantSettlement(headerReceipt ?? null);
2764
+ const settlementTxHash = settlement.settlementTxHash ?? (typeof input.metaSettlement?.transaction === "string" ? input.metaSettlement.transaction : void 0);
2765
+ const plainToolErrorAfterFunding = input.toolResult?.isError === true && inBandChallenge === void 0 && !settlementTxHash;
2766
+ const inBandRejection = inBandChallenge !== void 0 || input.metaSettlement?.success === false || plainToolErrorAfterFunding;
2767
+ return {
2768
+ accepted: input.httpOk && !inBandRejection,
2769
+ inBandRejection,
2770
+ plainToolErrorAfterFunding,
2771
+ settlementTxHash,
2772
+ protocolReceiptHeader,
2773
+ protocolReceiptHeaderName
2774
+ };
2775
+ }
2776
+
2617
2777
  // src/merchant-completion.ts
2618
2778
  var MERCHANT_BODY_SNIPPET_LIMIT = 1e3;
2619
2779
  var EVIDENCE_RETRY_DELAYS_MS = [1e3, 2e3, 4e3];
@@ -2644,14 +2804,14 @@ var MerchantCompletion = class {
2644
2804
  }
2645
2805
  async retryRequest(url, initialInit, paymentRequired, receipt) {
2646
2806
  if (!receipt.accepted) {
2647
- throw new chunkH37YVYZA_cjs.HavenApiError("No accepted x402 option was recorded for payment retry", 500);
2807
+ throw new chunkMZKLAHBK_cjs.HavenApiError("No accepted x402 option was recorded for payment retry", 500);
2648
2808
  }
2649
2809
  if (!receipt.paymentHeader) {
2650
- throw new chunkH37YVYZA_cjs.HavenApiError("No x402 payment header was returned for payment retry", 500);
2810
+ throw new chunkMZKLAHBK_cjs.HavenApiError("No x402 payment header was returned for payment retry", 500);
2651
2811
  }
2652
2812
  let retryInit = initialInit;
2653
2813
  if (this.getTaxDeclarationHeader && this.delegateKey) {
2654
- const scheme = chunk22FJ4JQO_cjs.x402PaymentHeaderNamesFor(receipt.paymentHeader);
2814
+ const scheme = chunkIKQIIMM6_cjs.x402PaymentHeaderNamesFor(receipt.paymentHeader);
2655
2815
  const isEip3009 = scheme.length > 1;
2656
2816
  if (isEip3009) {
2657
2817
  const resolved = await this.getTaxDeclarationHeader({
@@ -2663,16 +2823,31 @@ var MerchantCompletion = class {
2663
2823
  retryInit = withTaxDeclarationHeader(initialInit, void 0);
2664
2824
  }
2665
2825
  }
2666
- const retryResponse = await this.merchantTransport.deliverPaymentRecoveringSession(
2667
- url,
2668
- retryInit,
2669
- receipt.paymentHeader,
2670
- () => this.merchantTransport.initialize(url, initialInit)
2671
- );
2826
+ let retryResponse;
2827
+ try {
2828
+ retryResponse = await this.merchantTransport.deliverPaymentRecoveringSession(
2829
+ url,
2830
+ retryInit,
2831
+ receipt.paymentHeader,
2832
+ () => this.merchantTransport.initialize(url, initialInit)
2833
+ );
2834
+ } catch (err) {
2835
+ if (err instanceof MerchantEgressRefusedError && !err.beforeRequest) {
2836
+ throw await this.paidDeliveryInterrupted(err, url, receipt, receipt.paymentHeader, retryInit?.body != null);
2837
+ }
2838
+ throw err;
2839
+ }
2672
2840
  const toolResult = retryResponse.ok ? await this.merchantTransport.readToolResult(retryResponse) : void 0;
2673
- const inBandChallenge = toolResult ? extractMcpPaymentRequired(toolResult) : void 0;
2674
2841
  const metaSettlement = toolResult ? mcpSettlementFromToolResult(toolResult) : void 0;
2675
- const inBandRejection = inBandChallenge !== void 0 || metaSettlement?.success === false;
2842
+ const headerReceipt = retryResponse.headers.get("PAYMENT-RESPONSE");
2843
+ const answer = decidePostFundingMerchantAnswer({
2844
+ toolResult,
2845
+ httpOk: retryResponse.ok,
2846
+ paymentResponseHeader: headerReceipt ?? void 0,
2847
+ metaSettlement
2848
+ });
2849
+ const reportedSettlementTxHash = answer.settlementTxHash;
2850
+ const inBandRejection = answer.inBandRejection;
2676
2851
  if (!retryResponse.ok || inBandRejection) {
2677
2852
  const merchant = await captureMerchantResponse(retryResponse);
2678
2853
  await this.recordRetryRejected({
@@ -2686,8 +2861,8 @@ var MerchantCompletion = class {
2686
2861
  delegate_to: receipt.to
2687
2862
  }
2688
2863
  });
2689
- throw new chunkH37YVYZA_cjs.HavenApiError(
2690
- "x402 retry failed after Haven funded the delegate wallet; reconciliation may be required.",
2864
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2865
+ "x402 retry failed after Haven funded the delegate wallet; reconciliation may be required. The merchant may still settle late: check the payment status before sweeping the delegate.",
2691
2866
  inBandRejection ? X402_RETRY_REJECTED_STATUS : merchant.merchant_status,
2692
2867
  {
2693
2868
  marker: "x402_retry_rejected_after_funding",
@@ -2700,10 +2875,10 @@ var MerchantCompletion = class {
2700
2875
  }
2701
2876
  );
2702
2877
  }
2703
- const headerReceipt = retryResponse.headers.get("PAYMENT-RESPONSE");
2704
- const protocolReceiptHeader = headerReceipt ?? (metaSettlement ? encodeMcpSettlementReceipt(metaSettlement) : void 0);
2705
- const protocolReceiptHeaderName = headerReceipt ? "PAYMENT-RESPONSE" : metaSettlement ? `_meta.${MCP_X402_PAYMENT_RESPONSE_META_KEY}` : void 0;
2706
- const merchantSettlement = parseMerchantSettlement(protocolReceiptHeader ?? null);
2878
+ const { protocolReceiptHeader, protocolReceiptHeaderName } = answer;
2879
+ const merchantSettlement = {
2880
+ settlementTxHash: reportedSettlementTxHash ?? null
2881
+ };
2707
2882
  if (receipt.merchant && merchantSettlement.settlementTxHash) {
2708
2883
  receipt.merchant.settlementTxHash = merchantSettlement.settlementTxHash;
2709
2884
  receipt.merchant.settlementExplorerUrl = buildExplorerUrl(receipt.chainId, merchantSettlement.settlementTxHash) || null;
@@ -2716,14 +2891,19 @@ var MerchantCompletion = class {
2716
2891
  merchantStatus: retryResponse.status,
2717
2892
  challengePayload: paymentRequired,
2718
2893
  selectedPayment: receipt.accepted,
2719
- paymentProofHeaderName: chunk22FJ4JQO_cjs.x402PaymentHeaderNamesSent(receipt.paymentHeader),
2894
+ paymentProofHeaderName: chunkIKQIIMM6_cjs.x402PaymentHeaderNamesSent(receipt.paymentHeader),
2720
2895
  paymentProofHeader: receipt.paymentHeader,
2721
2896
  protocolReceiptHeaderName,
2722
2897
  protocolReceiptHeader
2723
2898
  });
2724
2899
  const settlementCandidate = merchantSettlement.settlementTxHash;
2725
2900
  if (settlementCandidate && isWellFormedSettlementTxHash(settlementCandidate) && !isZeroSettlementTxHash(settlementCandidate) && settlementCandidate.toLowerCase() !== receipt.txHash.toLowerCase()) {
2726
- await this.reportSettlementEvidenceOnce(receipt.paymentId, settlementCandidate);
2901
+ await this.reportEvidence({
2902
+ paymentId: receipt.paymentId,
2903
+ rail: "x402",
2904
+ txHash: settlementCandidate,
2905
+ ...settlementProofFields(receipt.paymentHeader)
2906
+ });
2727
2907
  }
2728
2908
  await this.reportMerchantReceipt(receipt.paymentId, retryResponse);
2729
2909
  return retryResponse;
@@ -2775,18 +2955,18 @@ var MerchantCompletion = class {
2775
2955
  async resolveCompletionContext(input) {
2776
2956
  const status = await this.getPaymentStatus(input.paymentId);
2777
2957
  if (status.rail !== "x402") {
2778
- throw new chunkH37YVYZA_cjs.HavenPaymentStateError(
2958
+ throw new chunkMZKLAHBK_cjs.HavenPaymentStateError(
2779
2959
  `Payment ${status.paymentId} is ${status.rail}, not x402.`,
2780
2960
  409,
2781
2961
  status
2782
2962
  );
2783
2963
  }
2784
- const readyForMerchantCompletion = input.noFundingLeg ? status.kind === "payment_intent" && status.status === "submitted" : status.nextAction === chunkH37YVYZA_cjs.AgentPaymentNextAction.RetryOriginalX402Request || status.kind === "payment_intent" && status.status === "confirmed" && status.phase === chunkH37YVYZA_cjs.AgentPaymentPhase.PaymentConfirmed && status.nextAction === chunkH37YVYZA_cjs.AgentPaymentNextAction.None;
2964
+ const readyForMerchantCompletion = input.noFundingLeg ? status.kind === "payment_intent" && status.status === "submitted" : status.nextAction === chunkMZKLAHBK_cjs.AgentPaymentNextAction.RetryOriginalX402Request || status.kind === "payment_intent" && status.status === "confirmed" && status.phase === chunkMZKLAHBK_cjs.AgentPaymentPhase.PaymentConfirmed && status.nextAction === chunkMZKLAHBK_cjs.AgentPaymentNextAction.None;
2785
2965
  if (!readyForMerchantCompletion) {
2786
- throw new chunkH37YVYZA_cjs.HavenPaymentStateError(status.message, paymentStateStatusCode(status.status, 409), status);
2966
+ throw new chunkMZKLAHBK_cjs.HavenPaymentStateError(status.message, paymentStateStatusCode(status.status, 409), status);
2787
2967
  }
2788
2968
  if (!input.noFundingLeg && !status.txHash) {
2789
- throw new chunkH37YVYZA_cjs.HavenApiError(
2969
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2790
2970
  `x402 payment ${status.paymentId} is ready for merchant completion but has no Haven transaction hash.`,
2791
2971
  502,
2792
2972
  status,
@@ -2795,7 +2975,7 @@ var MerchantCompletion = class {
2795
2975
  }
2796
2976
  const approvedResourceUrl = status.resourceUrl ?? status.x402?.resourceUrl ?? null;
2797
2977
  if (approvedResourceUrl && approvedResourceUrl !== input.url) {
2798
- throw new chunkH37YVYZA_cjs.HavenApiError(
2978
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2799
2979
  "x402 merchant completion does not match the approved resource URL.",
2800
2980
  409,
2801
2981
  { status, url: input.url },
@@ -2826,6 +3006,51 @@ var MerchantCompletion = class {
2826
3006
  // and MACHINE-PAYMENT-CHALLENGE was never produced by any other Haven
2827
3007
  // surface. Use the x402 flow (authorizeX402 / fetch / quoteX402 / payX402Quote)
2828
3008
  // for agent-to-merchant payments.
3009
+ /**
3010
+ * #4257: record a paid delivery that a refused redirect interrupted, and
3011
+ * return the refusal re-thrown with its payment and an accurate account:
3012
+ * the payment header (and the body, when there is one) reached `url`, the
3013
+ * merchant answered with a redirect Haven did not follow, and the merchant
3014
+ * may still settle. The record is the same
3015
+ * `merchant_retry_rejected_after_payment` event a non-2xx answer writes: its
3016
+ * `retry_status` is the redirect status, `retry_body` is null, and `details`
3017
+ * carry `refusal` plus `redirect_location` when the refusal names a redirect
3018
+ * target, or `refused_url` (the URL that answered) otherwise. The payment
3019
+ * reads as funded and undelivered.
3020
+ */
3021
+ async paidDeliveryInterrupted(err, url, receipt, paymentHeader, hasBody) {
3022
+ const scheme = chunkIKQIIMM6_cjs.x402PaymentHeaderNamesFor(paymentHeader).length > 1 ? "eip3009" : "erc7710";
3023
+ const status = err.redirectStatus ?? 0;
3024
+ await this.recordRetryRejected({
3025
+ rail: "x402",
3026
+ paymentId: receipt.paymentId,
3027
+ txHash: receipt.txHash,
3028
+ resourceUrl: receipt.resourceUrl,
3029
+ merchant: {
3030
+ merchant_status: status,
3031
+ merchant_status_text: "redirect not followed",
3032
+ merchant_headers: {},
3033
+ merchant_body: ""
3034
+ },
3035
+ details: {
3036
+ merchant_to: receipt.merchantTo,
3037
+ delegate_to: receipt.to,
3038
+ refusal: err.refusal,
3039
+ // The refusal's url is the redirect target only when it carries one;
3040
+ // otherwise it is the URL that answered (a non-GET redirect, a missing
3041
+ // or unresolvable Location), recorded under a neutral key.
3042
+ ...err.redirectTarget ? { redirect_location: err.redirectTarget } : { refused_url: err.url }
3043
+ }
3044
+ });
3045
+ const what = `The paid request was delivered to ${url}, ${hasBody ? "payment header and body" : "payment header"} included, and the merchant answered ${status ? `HTTP ${status} ` : ""}with a redirect${unfollowedRedirect(err)} Do not pay again: `;
3046
+ const next = scheme === "erc7710" ? "erc7710 has no funding leg, so there is no delegate balance to strand or sweep. The merchant may still redeem the settlement authorization within its window: check haven_get_payment_status after that window and re-quote only if it shows no settlement." : "the funding leg is confirmed on-chain and the merchant may still settle late. Check haven_get_payment_status before anything else, and sweep the delegate only if no settlement appears.";
3047
+ return new MerchantEgressRefusedError(what + next, err.url, err.refusal, false, {
3048
+ redirectStatus: err.redirectStatus,
3049
+ redirectTarget: err.redirectTarget,
3050
+ paymentId: receipt.paymentId,
3051
+ settlementScheme: scheme
3052
+ });
3053
+ }
2829
3054
  async recordRetryRejected(input) {
2830
3055
  try {
2831
3056
  await this.post("/machine-payments/reconciliation-events", {
@@ -2881,7 +3106,7 @@ var MerchantCompletion = class {
2881
3106
  */
2882
3107
  async reportMerchantOutcome(input) {
2883
3108
  if (!Number.isInteger(input.merchantStatus) || input.merchantStatus < 100 || input.merchantStatus > 599) {
2884
- throw new chunkH37YVYZA_cjs.HavenApiError(
3109
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2885
3110
  `merchant_status must be an integer HTTP status from 100 to 599 (received ${input.merchantStatus}).`,
2886
3111
  400,
2887
3112
  void 0,
@@ -2890,7 +3115,7 @@ var MerchantCompletion = class {
2890
3115
  }
2891
3116
  const looksAccepted = input.merchantStatus >= 200 && input.merchantStatus < 300;
2892
3117
  if (looksAccepted !== (input.outcome === "accepted")) {
2893
- throw new chunkH37YVYZA_cjs.HavenApiError(
3118
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2894
3119
  `outcome "${input.outcome}" contradicts merchant_status ${input.merchantStatus}: report "accepted" only for a 2xx and "rejected" only for a non-2xx.`,
2895
3120
  400,
2896
3121
  void 0,
@@ -2899,14 +3124,14 @@ var MerchantCompletion = class {
2899
3124
  }
2900
3125
  const status = await this.getPaymentStatus(input.paymentId);
2901
3126
  if (status.rail !== "x402") {
2902
- throw new chunkH37YVYZA_cjs.HavenPaymentStateError(
3127
+ throw new chunkMZKLAHBK_cjs.HavenPaymentStateError(
2903
3128
  `Payment ${status.paymentId} is ${status.rail}, not x402 \u2014 there is no merchant retry to report.`,
2904
3129
  409,
2905
3130
  status
2906
3131
  );
2907
3132
  }
2908
3133
  if (status.status !== "confirmed" || !status.txHash) {
2909
- throw new chunkH37YVYZA_cjs.HavenPaymentStateError(
3134
+ throw new chunkMZKLAHBK_cjs.HavenPaymentStateError(
2910
3135
  `Payment ${status.paymentId} has no confirmed Haven funding transaction to anchor a merchant report to (status ${status.status}). ${status.message}`,
2911
3136
  paymentStateStatusCode(status.status, 409),
2912
3137
  status
@@ -2914,7 +3139,7 @@ var MerchantCompletion = class {
2914
3139
  }
2915
3140
  const resourceUrl = status.resourceUrl ?? status.x402?.resourceUrl ?? null;
2916
3141
  if (!resourceUrl) {
2917
- throw new chunkH37YVYZA_cjs.HavenApiError(
3142
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
2918
3143
  `Payment ${status.paymentId} has no recorded resource URL, so a merchant report cannot be stored.`,
2919
3144
  409,
2920
3145
  status,
@@ -2975,23 +3200,26 @@ var MerchantCompletion = class {
2975
3200
  }
2976
3201
  }
2977
3202
  /**
2978
- * ONE evidence attempt — the body of `reportEvidence`'s loop above, and the
2979
- * whole of the #3764 settlement report below. A 503 answers `retryable`
2980
- * immediately; the caller decides whether to sleep and re-attempt
2981
- * (`reportEvidence`) or hand the outcome to its consumer (#3764 D2).
3203
+ * ONE evidence attempt — the body of `reportEvidence`'s loop above. A 503
3204
+ * answers `retryable` immediately; the caller decides whether to sleep and
3205
+ * re-attempt (`reportEvidence`, and — #4215 — the local settlement report
3206
+ * in `retryRequest`) or hand the outcome to its consumer (#3764 D2, the
3207
+ * hosted settlement report).
2982
3208
  */
2983
3209
  async postEvidenceOnce(body) {
2984
3210
  try {
2985
3211
  await this.post("/machine-payments/evidence", body);
2986
3212
  return { outcome: "confirmed" };
2987
3213
  } catch (err) {
2988
- const statusCode = err instanceof chunkH37YVYZA_cjs.HavenApiError ? err.statusCode : void 0;
3214
+ const statusCode = err instanceof chunkMZKLAHBK_cjs.HavenApiError ? err.statusCode : void 0;
2989
3215
  if (statusCode !== EVIDENCE_RETRYABLE_STATUS) {
2990
3216
  const reason = refusalReasonFromBody(err);
3217
+ const errorCode = refusalErrorCodeFromBody(err);
2991
3218
  return {
2992
3219
  outcome: "refused",
2993
3220
  statusCode: statusCode ?? 0,
2994
- ...reason ? { reason } : {}
3221
+ ...reason ? { reason } : {},
3222
+ ...errorCode ? { errorCode } : {}
2995
3223
  };
2996
3224
  }
2997
3225
  return { outcome: "retryable", statusCode };
@@ -3028,46 +3256,78 @@ var MerchantCompletion = class {
3028
3256
  * gate uses, so a caller cannot "fix" a missing hash by reporting the demo
3029
3257
  * merchant's own marker and getting a different verdict than the settle
3030
3258
  * path already gave it.
3259
+ *
3260
+ * #4061: `options.paymentHeader` is the payment header the caller sent to
3261
+ * the merchant on its paid retry. On eip3009 it is REQUIRED for the record
3262
+ * (#3925): its signed authorization proves the nonce the settlement burned
3263
+ * is this payment's, and a report without it is refused with
3264
+ * `errorCode: 'settlement_proof_header_missing'`. It is forwarded exactly
3265
+ * as the funding report forwards it (`paymentProofHeader` plus the names
3266
+ * `x402PaymentHeaderNamesSent` derives from the same payload). erc7710
3267
+ * needs none — Haven assembled that header itself.
3031
3268
  */
3032
- async reportSettlementEvidence(paymentId, settlementTxHash) {
3269
+ async reportSettlementEvidence(paymentId, settlementTxHash, options = {}) {
3033
3270
  if (isZeroSettlementTxHash(settlementTxHash)) {
3034
- throw new chunkH37YVYZA_cjs.HavenZeroSettlementHashError(paymentId);
3271
+ throw new chunkMZKLAHBK_cjs.HavenZeroSettlementHashError(paymentId);
3035
3272
  }
3036
3273
  return this.reportEvidence({
3037
3274
  paymentId,
3038
3275
  rail: "x402",
3039
- txHash: settlementTxHash
3276
+ txHash: settlementTxHash,
3277
+ ...settlementProofFields(options.paymentHeader)
3040
3278
  });
3041
3279
  }
3042
3280
  /**
3043
3281
  * #3764: report the merchant's OWN EIP-3009 settlement transaction right
3044
- * after a completed purchase — the second leg of a payment that already has
3045
- * a funding-evidence row. Same endpoint and payload shape as
3282
+ * after a completed hosted purchase — the second leg of a payment that
3283
+ * already has a funding-evidence row. Same endpoint and payload shape as
3046
3284
  * `reportSettlementEvidence` above, but with #3764's D2 budget: exactly ONE
3047
3285
  * attempt, no `EVIDENCE_RETRY_DELAYS_MS` backoff. The resource is already
3048
3286
  * paid for and delivered, so a retryable answer must not stretch the
3049
3287
  * completed purchase — the HOSTED tools hand the outcome to the agent
3050
- * (`settlementEvidenceOutcome` → `haven_report_settlement_evidence`), and
3051
- * the local caller swallows it by design (D1). Callers validate the hash
3052
- * before this call (well-formed, non-zero, different from the funding hash
3288
+ * (`settlementEvidenceOutcome` → `haven_report_settlement_evidence`). Since
3289
+ * #4215 this ONE-attempt form serves the HOSTED path only
3290
+ * (`completeX402MerchantCall`); the local `retryRequest` posts the same
3291
+ * report through `reportEvidence`, whose bounded loop re-attempts while
3292
+ * Haven answers `retryable`. Callers validate the hash before this call
3293
+ * (well-formed, non-zero, different from the funding hash
3053
3294
  * case-insensitively), so there is no client-side refusal here — the
3054
3295
  * backend verifies on-chain and is the only judge.
3296
+ *
3297
+ * #4061: `paymentHeader` is the header the paid retry sent — the #3925
3298
+ * nonce proof, forwarded as `reportSettlementEvidence` forwards it. Both
3299
+ * callers hold it; without it the backend refuses the record.
3055
3300
  */
3056
- async reportSettlementEvidenceOnce(paymentId, settlementTxHash) {
3301
+ async reportSettlementEvidenceOnce(paymentId, settlementTxHash, paymentHeader) {
3057
3302
  return this.postEvidenceOnce({
3058
3303
  paymentId,
3059
3304
  rail: "x402",
3060
- txHash: settlementTxHash
3305
+ txHash: settlementTxHash,
3306
+ ...settlementProofFields(paymentHeader)
3061
3307
  });
3062
3308
  }
3063
3309
  };
3310
+ function settlementProofFields(paymentHeader) {
3311
+ if (!paymentHeader || !paymentHeader.trim()) return {};
3312
+ return {
3313
+ paymentProofHeaderName: chunkIKQIIMM6_cjs.x402PaymentHeaderNamesSent(paymentHeader),
3314
+ paymentProofHeader: paymentHeader
3315
+ };
3316
+ }
3064
3317
  function refusalReasonFromBody(err) {
3065
- if (!(err instanceof chunkH37YVYZA_cjs.HavenApiError)) return void 0;
3318
+ if (!(err instanceof chunkMZKLAHBK_cjs.HavenApiError)) return void 0;
3066
3319
  const body = err.body;
3067
3320
  if (body === null || typeof body !== "object" || Array.isArray(body)) return void 0;
3068
3321
  const reason = body.reason;
3069
3322
  return typeof reason === "string" && reason.length > 0 ? reason : void 0;
3070
3323
  }
3324
+ function refusalErrorCodeFromBody(err) {
3325
+ if (!(err instanceof chunkMZKLAHBK_cjs.HavenApiError)) return void 0;
3326
+ const body = err.body;
3327
+ if (body === null || typeof body !== "object" || Array.isArray(body)) return void 0;
3328
+ const code = body.error_code;
3329
+ return typeof code === "string" && code.length > 0 ? code : void 0;
3330
+ }
3071
3331
  function isZeroSettlementTxHash(hash) {
3072
3332
  return typeof hash === "string" && /^0x0+$/i.test(hash);
3073
3333
  }
@@ -3079,7 +3339,7 @@ function parseMerchantSettlement(header) {
3079
3339
  }
3080
3340
  function parseProtocolReceiptHeader(value) {
3081
3341
  try {
3082
- return chunk22FJ4JQO_cjs.decodeBase64Json(value);
3342
+ return chunkIKQIIMM6_cjs.decodeBase64Json(value);
3083
3343
  } catch {
3084
3344
  try {
3085
3345
  return JSON.parse(value);
@@ -3088,6 +3348,25 @@ function parseProtocolReceiptHeader(value) {
3088
3348
  }
3089
3349
  }
3090
3350
  }
3351
+ function unfollowedRedirect(err) {
3352
+ const target = err.redirectTarget ?? err.url;
3353
+ switch (err.refusal) {
3354
+ case "redirect_cross_origin_body":
3355
+ return ` to a different origin (${target}). Haven did not follow it, so the payment was not re-sent there.`;
3356
+ case "redirect_on_non_get":
3357
+ return ". Under the egress policy only GET redirects are followed, so Haven did not follow it and nothing was sent to the redirect target.";
3358
+ case "redirect_missing_location":
3359
+ return " that named no target (no Location header). Haven did not follow it.";
3360
+ case "redirect_invalid_location":
3361
+ return " whose Location header is not a resolvable URL. Haven did not follow it.";
3362
+ case "redirect_budget_exceeded":
3363
+ return ` past the redirect budget. The chain stopped before ${target}, and nothing was sent there.`;
3364
+ case "url_not_allowed":
3365
+ return ` to a URL the egress policy does not allow (${target}). Haven did not follow it, so nothing was sent there.`;
3366
+ default:
3367
+ return ". Haven did not follow it.";
3368
+ }
3369
+ }
3091
3370
 
3092
3371
  // src/client.ts
3093
3372
  var DEFAULT_POLLING_INTERVAL = 3e3;
@@ -3096,7 +3375,7 @@ function x402TypedDataDigest(typedData) {
3096
3375
  try {
3097
3376
  return viem.hashTypedData(typedData);
3098
3377
  } catch (err) {
3099
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3378
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3100
3379
  `The x402 funding intent carried a sign_data.typed_data that is not a valid EIP-712 payload (needs domain, types, primaryType, message), so its digest cannot be derived and no signer could accept it. Underlying error: ${err instanceof Error ? err.message : String(err)}`
3101
3380
  );
3102
3381
  }
@@ -3211,7 +3490,7 @@ var HavenClient = class {
3211
3490
  this.x402Wallet = config.x402Wallet;
3212
3491
  this.egressPolicy = config.merchantEgress;
3213
3492
  this.merchantTransport = new McpMerchantTransport({ merchantTimeout: config.merchantTimeout, egress: config.merchantEgress });
3214
- this.confirmationTimeout = config.confirmationTimeout ?? chunkH37YVYZA_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS;
3493
+ this.confirmationTimeout = config.confirmationTimeout ?? chunkMZKLAHBK_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS;
3215
3494
  this.pollingInterval = config.pollingInterval ?? DEFAULT_POLLING_INTERVAL;
3216
3495
  this.chainRpcs = config.chainRpcs ?? {};
3217
3496
  if (this.delegateKey) {
@@ -3292,7 +3571,7 @@ var HavenClient = class {
3292
3571
  */
3293
3572
  async pay(request) {
3294
3573
  if (!this.delegateKey) {
3295
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3574
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3296
3575
  "Cannot use pay() without a delegateKey. Use createIntent() + submitSignature() for manual signing."
3297
3576
  );
3298
3577
  }
@@ -3348,15 +3627,15 @@ var HavenClient = class {
3348
3627
  * on-chain allowance — there is nothing to sign until the user approves.
3349
3628
  */
3350
3629
  async createX402Intent(paymentRequired, options = {}) {
3351
- const option = chunk22FJ4JQO_cjs.selectStandardPaymentOption(paymentRequired.accepts);
3630
+ const option = chunkIKQIIMM6_cjs.selectStandardPaymentOption(paymentRequired.accepts);
3352
3631
  if (!option) {
3353
3632
  throw noCompatiblePaymentOptionError(paymentRequired.accepts);
3354
3633
  }
3355
3634
  const fundingTo = options.delegateAddress ?? (await this.getAgent()).delegateAddress;
3356
3635
  if (!fundingTo) {
3357
- throw new chunkH37YVYZA_cjs.HavenApiError("Authenticated agent has no delegate address registered.", 502);
3636
+ throw new chunkMZKLAHBK_cjs.HavenApiError("Authenticated agent has no delegate address registered.", 502);
3358
3637
  }
3359
- const idempotencyKey = options.idempotencyKey ?? chunk22FJ4JQO_cjs.buildX402IdempotencyKey(paymentRequired, option);
3638
+ const idempotencyKey = options.idempotencyKey ?? chunkIKQIIMM6_cjs.buildX402IdempotencyKey(paymentRequired, option);
3360
3639
  const raw = await this.post("/x402", {
3361
3640
  url: paymentRequired.resource.url,
3362
3641
  payTo: fundingTo,
@@ -3367,7 +3646,7 @@ var HavenClient = class {
3367
3646
  // of a silent reroute to the erc7710 settlement branch (the #1358
3368
3647
  // review's open-budget misroute). Legacy-rail backends ignore the field.
3369
3648
  settlementScheme: "eip3009",
3370
- amount: chunk22FJ4JQO_cjs.x402AuthorizationAmount(option),
3649
+ amount: chunkIKQIIMM6_cjs.x402AuthorizationAmount(option),
3371
3650
  asset: option.asset,
3372
3651
  network: option.network,
3373
3652
  description: paymentRequired.resource.description,
@@ -3392,15 +3671,15 @@ var HavenClient = class {
3392
3671
  throwPaymentStateError("x402 payment", raw);
3393
3672
  }
3394
3673
  if (!raw.sign_data?.hash) {
3395
- throw new chunkH37YVYZA_cjs.HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
3674
+ throw new chunkMZKLAHBK_cjs.HavenApiError("No sign_hash returned from x402/authorize", 500, raw);
3396
3675
  }
3397
3676
  if (raw.sign_data.signature_scheme !== void 0 && !raw.sign_data.typed_data) {
3398
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3677
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3399
3678
  `This account's x402 funding intent declares signature scheme '${raw.sign_data.signature_scheme}' but carried no typed_data to sign. Refusing to fall back to the bare hash \u2014 the account would reject that signature on-chain. This is a backend contract violation; report it rather than working around it.`
3400
3679
  );
3401
3680
  }
3402
3681
  if (!raw.x402_expected_auth) {
3403
- throw new chunkH37YVYZA_cjs.HavenApiError("No x402 expected-context binding returned from x402/authorize", 500, raw);
3682
+ throw new chunkMZKLAHBK_cjs.HavenApiError("No x402 expected-context binding returned from x402/authorize", 500, raw);
3404
3683
  }
3405
3684
  return {
3406
3685
  paymentId: raw.payment_id,
@@ -3411,7 +3690,7 @@ var HavenClient = class {
3411
3690
  accepted: option,
3412
3691
  resourceUrl: paymentRequired.resource.url,
3413
3692
  merchantTo: raw.merchant_to ?? option.payTo,
3414
- amountAtomic: chunk22FJ4JQO_cjs.x402AuthorizationAmount(option),
3693
+ amountAtomic: chunkIKQIIMM6_cjs.x402AuthorizationAmount(option),
3415
3694
  asset: option.asset,
3416
3695
  network: option.network,
3417
3696
  expectedAuth: raw.x402_expected_auth,
@@ -3436,13 +3715,13 @@ var HavenClient = class {
3436
3715
  */
3437
3716
  sign(hash) {
3438
3717
  if (!this.delegateKey) {
3439
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3718
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3440
3719
  "Cannot sign without a delegateKey. Pass the private key in HavenClient config, or sign externally."
3441
3720
  );
3442
3721
  }
3443
3722
  const signature = signHash(this.delegateKey, hash);
3444
3723
  if (!verifySignature(hash, signature, this.delegateAddress)) {
3445
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3724
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3446
3725
  "Local signature verification failed \u2014 recovered address does not match delegate key."
3447
3726
  );
3448
3727
  }
@@ -3460,29 +3739,29 @@ var HavenClient = class {
3460
3739
  */
3461
3740
  async signForData(signData, settlementExpectation, fundingExpectation) {
3462
3741
  if (!this.delegateKey) {
3463
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3742
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3464
3743
  "Cannot sign without a delegateKey. Pass the private key in HavenClient config, or sign externally."
3465
3744
  );
3466
3745
  }
3467
3746
  const scheme = signData.signature_scheme;
3468
3747
  if (scheme === "eip191_userop") {
3469
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3748
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3470
3749
  "The session rail is retired \u2014 'eip191_userop' intents can no longer be signed. Re-onboard the account on the delegation rail."
3471
3750
  );
3472
3751
  }
3473
3752
  if (scheme === "eip712_userop") {
3474
3753
  if (!signData.typed_data) {
3475
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3754
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3476
3755
  "sign_data.signature_scheme is eip712_userop but typed_data is missing \u2014 refusing to sign the bare hash (the account would reject it)."
3477
3756
  );
3478
3757
  }
3479
- chunkH37YVYZA_cjs.assertUserOpTypedDataBinding(signData.typed_data, signData.hash);
3480
- chunk22FJ4JQO_cjs.assertBoundDirectPaymentUserOp(
3758
+ chunkMZKLAHBK_cjs.assertUserOpTypedDataBinding(signData.typed_data, signData.hash);
3759
+ chunkIKQIIMM6_cjs.assertBoundDirectPaymentUserOp(
3481
3760
  signData.typed_data,
3482
3761
  this.delegateAddress
3483
3762
  );
3484
3763
  if (fundingExpectation) {
3485
- chunk22FJ4JQO_cjs.assertFundingLegPaysDelegate(signData.typed_data, {
3764
+ chunkIKQIIMM6_cjs.assertFundingLegPaysDelegate(signData.typed_data, {
3486
3765
  delegateAddress: this.delegateAddress,
3487
3766
  asset: fundingExpectation.asset,
3488
3767
  amount: fundingExpectation.amount
@@ -3492,24 +3771,24 @@ var HavenClient = class {
3492
3771
  }
3493
3772
  if (scheme === "eip712_delegation") {
3494
3773
  if (!signData.typed_data) {
3495
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3774
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3496
3775
  "sign_data.signature_scheme is eip712_delegation but typed_data is missing \u2014 refusing to sign the bare hash (the settlement would be rejected on redemption)."
3497
3776
  );
3498
3777
  }
3499
3778
  if (!settlementExpectation) {
3500
- throw new chunk22FJ4JQO_cjs.HavenTypedDataRefusedError(
3779
+ throw new chunkIKQIIMM6_cjs.HavenTypedDataRefusedError(
3501
3780
  "Refusing to sign an x402 settlement child without an independent expectation of what it must pay (the merchant's 402). Pay erc7710 merchants through settleX402Erc7710(), which supplies it."
3502
3781
  );
3503
3782
  }
3504
- chunk22FJ4JQO_cjs.assertOwnSettlementChild(signData.typed_data, settlementExpectation, this.delegateAddress);
3783
+ chunkIKQIIMM6_cjs.assertOwnSettlementChild(signData.typed_data, settlementExpectation, this.delegateAddress);
3505
3784
  return signSettlementDelegationTypedData(this.delegateKey, signData.typed_data);
3506
3785
  }
3507
3786
  if (scheme === void 0) {
3508
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3787
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3509
3788
  "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."
3510
3789
  );
3511
3790
  }
3512
- throw new chunkH37YVYZA_cjs.HavenSigningError(
3791
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3513
3792
  `Unknown sign_data.signature_scheme '${scheme}' \u2014 refusing to guess a signing scheme. Update @haven_ai/sdk.`
3514
3793
  );
3515
3794
  }
@@ -3647,7 +3926,8 @@ var HavenClient = class {
3647
3926
  amountAtomic: input.amountAtomic,
3648
3927
  ...input.merchantTo !== void 0 ? { merchantTo: input.merchantTo } : {},
3649
3928
  ...input.resourceUrl !== void 0 ? { resourceUrl: input.resourceUrl } : {},
3650
- ...input.idempotencyKey !== void 0 ? { idempotencyKey: input.idempotencyKey } : {}
3929
+ ...input.idempotencyKey !== void 0 ? { idempotencyKey: input.idempotencyKey } : {},
3930
+ ...input.recordRefusal !== void 0 ? { recordRefusal: input.recordRefusal } : {}
3651
3931
  });
3652
3932
  }
3653
3933
  /**
@@ -3699,7 +3979,7 @@ var HavenClient = class {
3699
3979
  */
3700
3980
  async getPaymentStatusWithPostPurchaseAllowance(paymentId) {
3701
3981
  const status = await this.getPaymentStatus(paymentId);
3702
- if (status.rail === chunkH37YVYZA_cjs.AgentPaymentRail.X402 && status.phase === chunkH37YVYZA_cjs.AgentPaymentPhase.PaymentConfirmed) {
3982
+ if (status.rail === chunkMZKLAHBK_cjs.AgentPaymentRail.X402 && status.phase === chunkMZKLAHBK_cjs.AgentPaymentPhase.PaymentConfirmed) {
3703
3983
  const { allowance, warnings } = await this.getPostPurchaseAllowanceSummary(paymentId);
3704
3984
  return { ...status, allowance, ...warnings.length > 0 ? { warnings } : {} };
3705
3985
  }
@@ -3754,10 +4034,10 @@ var HavenClient = class {
3754
4034
  return this.get(`/catalog/submit/${encodeURIComponent(id)}`);
3755
4035
  }
3756
4036
  /**
3757
- * Fetch one curated catalog entry by id (#1306).
4037
+ * Fetch one catalog entry by id (#1306).
3758
4038
  *
3759
4039
  * Chain-scoped for free by the backend's SQL when the client is
3760
- * agent-authenticated (#1299): an unknown id and an id curated for a
4040
+ * agent-authenticated (#1299): an unknown id and an id listed for a
3761
4041
  * DIFFERENT chain than this agent's both 404 identically — this method does
3762
4042
  * not (and must not) re-filter by chain in JS. Read-only, like
3763
4043
  * {@link discoverTools}.
@@ -3913,9 +4193,10 @@ var HavenClient = class {
3913
4193
  return this.accountReads.listPendingSubBudgetSignatures();
3914
4194
  }
3915
4195
  /**
3916
- * Close a sub-budget row (delegating agent only). A `pending` or expired row
3917
- * closes immediately; a live child returns `signData` for the on-chain
3918
- * revocation — sign it (`haven_sign` with `sub_budget_id`) and call
4196
+ * Close a sub-budget row (delegating agent only). A `pending` row, or an
4197
+ * `open` one already expired, closes immediately; otherwise (a live child, or
4198
+ * any `closing` row — its disable is still owed, #3923) it returns `signData`
4199
+ * for the on-chain revocation — sign it (`haven_sign` with `sub_budget_id`) and call
3919
4200
  * `submitSubBudget`.
3920
4201
  */
3921
4202
  async closeSubBudget(id) {
@@ -3949,7 +4230,7 @@ var HavenClient = class {
3949
4230
  }
3950
4231
  await sleep(this.pollingInterval);
3951
4232
  }
3952
- throw new chunkH37YVYZA_cjs.HavenTimeoutError(paymentId);
4233
+ throw new chunkMZKLAHBK_cjs.HavenTimeoutError(paymentId);
3953
4234
  }
3954
4235
  // ── x402 Protocol Support ────────────────────────────────────────
3955
4236
  /**
@@ -3963,24 +4244,24 @@ var HavenClient = class {
3963
4244
  */
3964
4245
  async authorizeX402(paymentRequired, options = {}) {
3965
4246
  if (!this.delegateKey) {
3966
- throw new chunkH37YVYZA_cjs.HavenSigningError(
4247
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
3967
4248
  "delegateKey is required for x402 payments. Pass it in the HavenClient config."
3968
4249
  );
3969
4250
  }
3970
4251
  if (!this.delegateAddress) {
3971
- throw new chunkH37YVYZA_cjs.HavenSigningError("delegateAddress could not be derived from delegateKey.");
4252
+ throw new chunkMZKLAHBK_cjs.HavenSigningError("delegateAddress could not be derived from delegateKey.");
3972
4253
  }
3973
- const option = chunk22FJ4JQO_cjs.selectStandardPaymentOption(paymentRequired.accepts);
4254
+ const option = chunkIKQIIMM6_cjs.selectStandardPaymentOption(paymentRequired.accepts);
3974
4255
  if (!option) {
3975
4256
  throw noCompatiblePaymentOptionError(paymentRequired.accepts);
3976
4257
  }
3977
- const idempotencyKey = options.idempotencyKey ?? chunk22FJ4JQO_cjs.buildX402IdempotencyKey(paymentRequired, option);
4258
+ const idempotencyKey = options.idempotencyKey ?? chunkIKQIIMM6_cjs.buildX402IdempotencyKey(paymentRequired, option);
3978
4259
  const cached = this.fundingLeg.cachedReceipt(idempotencyKey, options.taskBudgetId, options.subBudgetId);
3979
4260
  if (cached) return cached;
3980
4261
  const inFlight = this.inFlightX402.get(idempotencyKey);
3981
4262
  if (inFlight) {
3982
4263
  if (!sameX402TaskBudget(this.inFlightX402TaskBudget.get(idempotencyKey), options.taskBudgetId) || !sameX402TaskBudget(this.inFlightX402SubBudget.get(idempotencyKey), options.subBudgetId)) {
3983
- throw new chunkH37YVYZA_cjs.X402TaskBudgetMismatchError(
4264
+ throw new chunkMZKLAHBK_cjs.X402TaskBudgetMismatchError(
3984
4265
  `The x402 idempotency key '${idempotencyKey}' has an in-flight payment created under a different authorizing budget (task '${this.inFlightX402TaskBudget.get(idempotencyKey) ?? "none"}' vs '${options.taskBudgetId ?? "none"}', sub '${this.inFlightX402SubBudget.get(idempotencyKey) ?? "none"}' vs '${options.subBudgetId ?? "none"}'). Pass a new idempotencyKey to pay under this budget.`,
3985
4266
  idempotencyKey,
3986
4267
  this.inFlightX402TaskBudget.get(idempotencyKey),
@@ -4035,16 +4316,16 @@ var HavenClient = class {
4035
4316
  if (err instanceof MerchantEgressResponseCapError) throw err;
4036
4317
  body = void 0;
4037
4318
  }
4038
- throw new chunkH37YVYZA_cjs.X402UnexpectedStatusError(
4319
+ throw new chunkMZKLAHBK_cjs.X402UnexpectedStatusError(
4039
4320
  `Expected an x402 quote response with HTTP 402, got HTTP ${response.status}.`,
4040
4321
  response.status || 400,
4041
4322
  body
4042
4323
  );
4043
4324
  }
4044
4325
  if (response.headers.get("MACHINE-PAYMENT-CHALLENGE")) {
4045
- throw new chunkH37YVYZA_cjs.HavenApiError("quoteX402 only supports standard x402 Payment Required responses.", 400);
4326
+ throw new chunkMZKLAHBK_cjs.HavenApiError("quoteX402 only supports standard x402 Payment Required responses.", 400);
4046
4327
  }
4047
- const paymentRequired = await chunk22FJ4JQO_cjs.parsePaymentRequiredResponse(response);
4328
+ const paymentRequired = await chunkIKQIIMM6_cjs.parsePaymentRequiredResponse(response);
4048
4329
  const mcpTransport = await this.merchantTransport.detect(url, paymentRequired, response);
4049
4330
  return buildX402Quote(paymentRequired, request, options.idempotencyKey, mcpTransport);
4050
4331
  }
@@ -4062,7 +4343,7 @@ var HavenClient = class {
4062
4343
  const wallet = await this.merchantCompletion.resolveWalletForMerchantCall();
4063
4344
  const sessionId = await this.merchantTransport.initialize(url, init, wallet);
4064
4345
  if (!sessionId) {
4065
- throw new chunkH37YVYZA_cjs.HavenApiError(
4346
+ throw new chunkMZKLAHBK_cjs.HavenApiError(
4066
4347
  "The merchant did not establish an MCP session before the x402 quote. No payment was created.",
4067
4348
  502,
4068
4349
  { mcpSessionNotEstablished: true }
@@ -4136,18 +4417,18 @@ var HavenClient = class {
4136
4417
  }
4137
4418
  async resumeAuthorizedX402(input) {
4138
4419
  if (!this.delegateKey) {
4139
- throw new chunkH37YVYZA_cjs.HavenSigningError(
4420
+ throw new chunkMZKLAHBK_cjs.HavenSigningError(
4140
4421
  "delegateKey is required for x402 payments. Pass it in the HavenClient config."
4141
4422
  );
4142
4423
  }
4143
4424
  if (!this.delegateAddress) {
4144
- throw new chunkH37YVYZA_cjs.HavenSigningError("delegateAddress could not be derived from delegateKey.");
4425
+ throw new chunkMZKLAHBK_cjs.HavenSigningError("delegateAddress could not be derived from delegateKey.");
4145
4426
  }
4146
- const option = chunk22FJ4JQO_cjs.selectStandardPaymentOption(input.paymentRequired.accepts);
4427
+ const option = chunkIKQIIMM6_cjs.selectStandardPaymentOption(input.paymentRequired.accepts);
4147
4428
  if (!option) {
4148
4429
  throw noCompatiblePaymentOptionError(input.paymentRequired.accepts);
4149
4430
  }
4150
- const idempotencyKey = input.idempotencyKey ?? chunk22FJ4JQO_cjs.buildX402IdempotencyKey(input.paymentRequired, option);
4431
+ const idempotencyKey = input.idempotencyKey ?? chunkIKQIIMM6_cjs.buildX402IdempotencyKey(input.paymentRequired, option);
4151
4432
  const cached = this.fundingLeg.cachedReceipt(idempotencyKey, input.taskBudgetId);
4152
4433
  if (cached) return cached;
4153
4434
  const status = await this.getPaymentStatus(input.paymentId);
@@ -4155,10 +4436,10 @@ var HavenClient = class {
4155
4436
  const canFund = await this.fundingLeg.delegateCanFund(
4156
4437
  status.chainId ?? chainIdFromNetwork(option.network),
4157
4438
  option.asset,
4158
- chunk22FJ4JQO_cjs.x402AuthorizationAmount(option)
4439
+ chunkIKQIIMM6_cjs.x402AuthorizationAmount(option)
4159
4440
  );
4160
4441
  if (canFund === false) {
4161
- throw new chunkH37YVYZA_cjs.X402AlreadySettledError(
4442
+ throw new chunkMZKLAHBK_cjs.X402AlreadySettledError(
4162
4443
  `x402 payment ${status.paymentId} has already settled \u2014 the delegate no longer holds the funds to authorize it again, so there is nothing left to resume.`,
4163
4444
  this.fundingLeg.receiptFromStatus(input.paymentRequired, option, void 0, status),
4164
4445
  "settled"
@@ -4179,13 +4460,13 @@ var HavenClient = class {
4179
4460
  const url = input.url ?? input.request?.url;
4180
4461
  if (!paymentRequired) {
4181
4462
  if (!url) {
4182
- throw new chunkH37YVYZA_cjs.HavenApiError("x402 resume requires the original URL or a captured request snapshot.", 400);
4463
+ throw new chunkMZKLAHBK_cjs.HavenApiError("x402 resume requires the original URL or a captured request snapshot.", 400);
4183
4464
  }
4184
4465
  const response = await this.merchantTransport.fetch(url, initialInit, this.merchantTransport.budgetFor("quote"), this.merchantTransport.capFor("quote"));
4185
4466
  if (response.status !== 402) {
4186
- throw new chunkH37YVYZA_cjs.HavenApiError("Expected the original x402 request to return HTTP 402 before resuming.", 400);
4467
+ throw new chunkMZKLAHBK_cjs.HavenApiError("Expected the original x402 request to return HTTP 402 before resuming.", 400);
4187
4468
  }
4188
- paymentRequired = await chunk22FJ4JQO_cjs.parsePaymentRequiredResponse(response);
4469
+ paymentRequired = await chunkIKQIIMM6_cjs.parsePaymentRequiredResponse(response);
4189
4470
  }
4190
4471
  const receipt = await this.resumeAuthorizedX402({
4191
4472
  paymentId: input.paymentId,
@@ -4238,7 +4519,7 @@ var HavenClient = class {
4238
4519
  nativeChallenge = true;
4239
4520
  } else {
4240
4521
  try {
4241
- paymentRequired = await chunk22FJ4JQO_cjs.parsePaymentRequiredResponse(response);
4522
+ paymentRequired = await chunkIKQIIMM6_cjs.parsePaymentRequiredResponse(response);
4242
4523
  } catch (err) {
4243
4524
  if (err instanceof MerchantEgressResponseCapError) throw err;
4244
4525
  return response;
@@ -4249,8 +4530,8 @@ var HavenClient = class {
4249
4530
  if (mcpSessionId) requestInit = this.merchantTransport.withSessionHeaders(requestInit, mcpSessionId);
4250
4531
  }
4251
4532
  const request = snapshotX402Request(url, requestInit);
4252
- const option = chunk22FJ4JQO_cjs.selectStandardPaymentOption(paymentRequired.accepts);
4253
- const idempotencyKey = options.idempotencyKey ?? (option ? chunk22FJ4JQO_cjs.buildX402IdempotencyKey(paymentRequired, option) : void 0);
4533
+ const option = chunkIKQIIMM6_cjs.selectStandardPaymentOption(paymentRequired.accepts);
4534
+ const idempotencyKey = options.idempotencyKey ?? (option ? chunkIKQIIMM6_cjs.buildX402IdempotencyKey(paymentRequired, option) : void 0);
4254
4535
  let receipt;
4255
4536
  try {
4256
4537
  receipt = await this.authorizeX402(paymentRequired, options);
@@ -4341,13 +4622,15 @@ var HavenClient = class {
4341
4622
  body = text;
4342
4623
  }
4343
4624
  const toolResult = mcpToolResultOf(body);
4344
- const inBandChallenge = toolResult ? extractMcpPaymentRequired(toolResult) : void 0;
4345
4625
  const metaSettlement = toolResult ? mcpSettlementFromToolResult(toolResult) : void 0;
4346
4626
  const headerReceipt = surfaced.headers.get("PAYMENT-RESPONSE") ?? void 0;
4347
- const protocolReceiptHeaderName = headerReceipt ? "PAYMENT-RESPONSE" : metaSettlement ? `_meta.${MCP_X402_PAYMENT_RESPONSE_META_KEY}` : void 0;
4348
- const protocolReceiptHeader = headerReceipt ?? (metaSettlement ? encodeMcpSettlementReceipt(metaSettlement) : void 0);
4349
- const settlement = parseMerchantSettlement(protocolReceiptHeader ?? null);
4350
- const merchantAccepted = surfaced.ok && inBandChallenge === void 0 && metaSettlement?.success !== false;
4627
+ const answer = decidePostFundingMerchantAnswer({
4628
+ toolResult,
4629
+ httpOk: surfaced.ok,
4630
+ paymentResponseHeader: headerReceipt,
4631
+ metaSettlement
4632
+ });
4633
+ const merchantAccepted = answer.accepted;
4351
4634
  let evidenceOutcome;
4352
4635
  let settlementEvidenceOutcome;
4353
4636
  if (!merchantAccepted) {
@@ -4369,7 +4652,7 @@ var HavenClient = class {
4369
4652
  });
4370
4653
  }
4371
4654
  } else {
4372
- const rawEvidenceTxHash = input.noFundingLeg ? settlement.settlementTxHash ?? void 0 : fundingTxHash ?? void 0;
4655
+ const rawEvidenceTxHash = input.noFundingLeg ? answer.settlementTxHash ?? void 0 : fundingTxHash ?? void 0;
4373
4656
  const evidenceTxHash = rawEvidenceTxHash && !isZeroSettlementTxHash(rawEvidenceTxHash) ? rawEvidenceTxHash : void 0;
4374
4657
  if (evidenceTxHash) {
4375
4658
  evidenceOutcome = await this.merchantCompletion.reportEvidence({
@@ -4378,21 +4661,22 @@ var HavenClient = class {
4378
4661
  txHash: evidenceTxHash,
4379
4662
  resourceUrl: evidenceContext.resourceUrl,
4380
4663
  merchantStatus: surfaced.status,
4381
- paymentProofHeaderName: chunk22FJ4JQO_cjs.x402PaymentHeaderNamesSent(input.paymentHeader),
4664
+ paymentProofHeaderName: chunkIKQIIMM6_cjs.x402PaymentHeaderNamesSent(input.paymentHeader),
4382
4665
  paymentProofHeader: input.paymentHeader,
4383
- protocolReceiptHeaderName,
4384
- protocolReceiptHeader,
4666
+ protocolReceiptHeaderName: answer.protocolReceiptHeaderName,
4667
+ protocolReceiptHeader: answer.protocolReceiptHeader,
4385
4668
  // #3778: the delivery pointer rides the accepted arm's evidence
4386
4669
  // report — a rejection delivered nothing to point at.
4387
4670
  ...input.deliveryReference ? { deliveryReference: input.deliveryReference } : {}
4388
4671
  });
4389
4672
  }
4390
4673
  if (!input.noFundingLeg) {
4391
- const settlementCandidate = settlement.settlementTxHash;
4674
+ const settlementCandidate = answer.settlementTxHash;
4392
4675
  if (settlementCandidate && isWellFormedSettlementTxHash(settlementCandidate) && !isZeroSettlementTxHash(settlementCandidate) && fundingTxHash && settlementCandidate.toLowerCase() !== fundingTxHash.toLowerCase()) {
4393
4676
  settlementEvidenceOutcome = await this.merchantCompletion.reportSettlementEvidenceOnce(
4394
4677
  evidenceContext.paymentId,
4395
- settlementCandidate
4678
+ settlementCandidate,
4679
+ input.paymentHeader
4396
4680
  );
4397
4681
  }
4398
4682
  }
@@ -4403,7 +4687,7 @@ var HavenClient = class {
4403
4687
  ok: merchantAccepted,
4404
4688
  body,
4405
4689
  // #3155 review S3: a transaction beside a rejection is not a settlement.
4406
- settlementTxHash: merchantAccepted ? settlement.settlementTxHash ?? void 0 : void 0,
4690
+ settlementTxHash: merchantAccepted ? answer.settlementTxHash ?? void 0 : void 0,
4407
4691
  evidenceOutcome,
4408
4692
  settlementEvidenceOutcome
4409
4693
  };
@@ -4436,9 +4720,15 @@ var HavenClient = class {
4436
4720
  * Haven verifies the delegate → merchant transfer on-chain
4437
4721
  * (`observeEip3009MerchantSettlement`) and records it beside the funding
4438
4722
  * hash, so receipts name the merchant's settlement.
4723
+ *
4724
+ * #4061: on eip3009 pass `options.paymentHeader` — the payment header you
4725
+ * sent the merchant on your paid retry. Since #3925 it is the proof the
4726
+ * settlement is recorded against; without it the report is `refused` with
4727
+ * `errorCode: 'settlement_proof_header_missing'`, and repeating it WITH the
4728
+ * header can succeed.
4439
4729
  */
4440
- async reportSettlementEvidence(paymentId, settlementTxHash) {
4441
- return await this.merchantCompletion.reportSettlementEvidence(paymentId, settlementTxHash);
4730
+ async reportSettlementEvidence(paymentId, settlementTxHash, options = {}) {
4731
+ return await this.merchantCompletion.reportSettlementEvidence(paymentId, settlementTxHash, options);
4442
4732
  }
4443
4733
  /**
4444
4734
  * #3770: record the agent's evidence-only delivery verdict on a settled
@@ -4497,7 +4787,7 @@ var HavenClient = class {
4497
4787
  try {
4498
4788
  raw = await this.get(`/x402/by-idempotency-key/${encodeURIComponent(key)}`);
4499
4789
  } catch (err) {
4500
- if (err instanceof chunkH37YVYZA_cjs.HavenApiError && err.statusCode === 404) return null;
4790
+ if (err instanceof chunkMZKLAHBK_cjs.HavenApiError && err.statusCode === 404) return null;
4501
4791
  throw err;
4502
4792
  }
4503
4793
  return {
@@ -4687,7 +4977,7 @@ var toolDescriptions = {
4687
4977
  checkFunds: {
4688
4978
  summary: "Check whether the agent's account actually holds at least the given amount of a token \u2014 funds held, not spend permitted.",
4689
4979
  selectionGuidance: "Use this before attempting a payment when it matters whether the money is really there: allowance answers say what you are PERMITTED to spend, never whether the account HOLDS it. For allowance, budget, spend-limit, remaining-budget, reset-period, or what-can-I-spend questions use the allowance lookup tool instead.",
4690
- behavior: "Returns covered: true (the account holds at least the checked amount), false (a live chain read reports less \u2014 the budget is backed by an empty account; stop and tell the user funds are missing), or null (the chain read failed \u2014 unverifiable, never treat it as absence; coverageError says why). The account balance itself is deliberately not returned: this is a sufficiency signal, not a balance read. budget_remaining_atomic is the permitted figure from the allowance lookup (the SDK spells it budgetRemainingAtomic), named so it can never be confused with holdings.",
4980
+ behavior: "Returns covered: true (the account holds at least the checked amount), false (a live chain read reports the account holds less than the checked amount; stop and tell the user it is short), or null (the chain read failed \u2014 unverifiable, never treat it as absence; coverageError says why). The account balance itself is deliberately not returned: this is a sufficiency signal, not a balance read. budget_remaining_atomic is the permitted figure from the allowance lookup (the SDK spells it budgetRemainingAtomic), named so it can never be confused with holdings.",
4691
4981
  nextActionGuidance: "On covered=false, do not attempt the payment \u2014 tell the user the account is short and let them fund it; on covered=null, retry the check shortly or proceed knowing the payment may fail on-chain."
4692
4982
  },
4693
4983
  listReceipts: {
@@ -4715,9 +5005,9 @@ var toolDescriptions = {
4715
5005
  nextActionGuidance: "On a decline, report the reason to the user and ask them to raise the budget in Haven \u2014 there is no approval queue to wait on. This tool retries the merchant itself while it runs, so do not wait on a signal mid-call. If the process crashes after payment, a later haven_get_payment_status call may report nextAction=retry_original_x402_request \u2014 resume via haven_resume_x402_payment instead of paying again."
4716
5006
  },
4717
5007
  discoverTools: {
4718
- summary: "Step 1 of a purchase: discover payable services from Haven's curated merchant catalog \u2014 names, prices, the next call.",
4719
- selectionGuidance: "Use this when the user asks what the agent can buy, pay for, or which paid services exist \u2014 or when you need a resource URL for a service the user described. Use verified=verified for entries Haven watched pass a live quote probe (operator-curated or self-submitted) \u2014 domain_verified is the only ownership claim; never treat these badges as proof of merchant honesty, quality, or reliability. Do NOT use for balance, budget, or spend-limit questions \u2014 use haven_get_allowances. Do NOT use to pay \u2014 each returned entry names the next tool to call.",
4720
- behavior: "Use each entry's suggested_tool + suggested_arguments first; an entry without them says why. Read-only lookup against Haven's curated catalog; entries are periodically re-verified against the live merchant and degraded entries are flagged. Use category for a case-insensitive category filter (for example, VPN or vpn), or search for a product name, category, or description term. Returns name, description, price, rail, resource URL, tool_name, tool_arguments, the hint, and the provenance badges source/domain_verified/verified_payable. " + FUNDING_LEG_DISCOVERY_GUIDANCE + " The catalog price (price_display/price_atomic, marked price_is_indicative) is a last-verified hint, NOT authoritative \u2014 the real price comes from the merchant's live 402 at pay time. Never creates a payment, signature, or approval.",
5008
+ summary: "Step 1 of a purchase: discover payable services from Haven's merchant catalog \u2014 names, prices, the next call.",
5009
+ selectionGuidance: "Use this when the user asks what the agent can buy, pay for, or which paid services exist \u2014 or when you need a resource URL for a service the user described. Use verified=verified for entries Haven watched pass a live quote probe (any source; bazaar seller-asserted) \u2014 domain_verified is the only ownership claim; never treat these badges as proof of merchant honesty, quality, or reliability. Do NOT use for balance, budget, or spend-limit questions \u2014 use haven_get_allowances. Do NOT use to pay \u2014 each returned entry names the next tool to call.",
5010
+ behavior: "Use each entry's suggested_tool + suggested_arguments first; an entry without them says why. Read-only lookup against Haven's catalog; entries are periodically re-verified against the live merchant and degraded entries are flagged. Use category for a case-insensitive category filter (for example, VPN or vpn), or search for a product name, category, or description term. Returns name, description, price, rail, resource URL, tool_name, tool_arguments, the hint, and the provenance badges source/domain_verified/verified_payable. " + FUNDING_LEG_DISCOVERY_GUIDANCE + " The catalog price (price_display/price_atomic, marked price_is_indicative) is a last-verified hint, NOT authoritative \u2014 the real price comes from the merchant's live 402 at pay time. Never creates a payment, signature, or approval.",
4721
5011
  nextActionGuidance: `Call suggested_tool with suggested_arguments VERBATIM (no hint: read suggested_tool_omitted_reason). Confirm the price from the live quote or pay result, not the catalog; if the next tool takes a cap, pass the user's cap as max_amount_human in whole tokens ("no more than 1 USDC" \u2192 max_amount_human: "1"), never atomic units by hand.`
4722
5012
  },
4723
5013
  submitCatalogEntry: {
@@ -4740,8 +5030,8 @@ var toolDescriptions = {
4740
5030
  },
4741
5031
  reportSettlementEvidence: {
4742
5032
  summary: "Report a payment's real merchant settlement transaction hash so Haven can verify it on-chain and record it.",
4743
- behavior: "Pass payment_id and, when you hold one, settlement_tx_hash (0x + 64 hex chars) \u2014 from PAYMENT-RESPONSE or a prior settlement_tx_hash. Omitting settlement_tx_hash succeeds as a no-op \u2014 nothing is checked or recorded, and no network call is made. Haven verifies on-chain before recording a hash; a zero, mismatched, or reverted hash is refused. Your own payments only.",
4744
- nextActionGuidance: "code SETTLEMENT_NOT_RECORDED (refusal_reason present): the payment's funding is confirmed and this hash was not accepted for it \u2014 do not retry it; refusal_reason carries why, verbatim. code DELIVERED_UNSETTLED: not verified, do not retry \u2014 poll haven_get_payment_status. code SETTLEMENT_PENDING (retryable:true): not mined or RPC unreachable \u2014 report the same hash again shortly."
5033
+ behavior: "Pass payment_id and, when you hold one, settlement_tx_hash (0x + 64 hex chars) \u2014 from PAYMENT-RESPONSE or a prior settlement_tx_hash. On EIP-3009 also pass payment_header (the header you retried the merchant with) or the report is refused. Omitting settlement_tx_hash succeeds as a no-op \u2014 nothing is checked or recorded, and no network call is made. Haven verifies on-chain before recording a hash; a zero, mismatched, or reverted hash is refused. Your own payments only.",
5034
+ nextActionGuidance: "code SETTLEMENT_PROOF_HEADER_MISSING: call again adding payment_header. code SETTLEMENT_NOT_RECORDED (refusal_reason present): the payment's funding is confirmed and this hash was not accepted for it \u2014 do not retry it; refusal_reason carries why, verbatim. code DELIVERED_UNSETTLED: not verified, do not retry \u2014 poll haven_get_payment_status. code SETTLEMENT_PENDING (retryable:true): not mined or RPC unreachable \u2014 report the same hash again shortly."
4745
5035
  }
4746
5036
  };
4747
5037
 
@@ -5001,7 +5291,7 @@ Your user gives you a **budget on their own account** \u2014 not their wallet, a
5001
5291
 
5002
5292
  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.
5003
5293
 
5004
- 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, \`<packages.cli.one_liner> login --api <api-url>\` afterwards gets you a scoped session for steps 3-4 (that flag or \`HAVEN_API_URL\`, on the first command \u2014 the session then remembers the backend; **the CLI's built-in default is Haven's hosted production backend**, so on any other deployment an omitted flag connects you somewhere real and wrong rather than failing) \u2014 they approve a code in the browser, you never hold their password. That command is the manifest's \`packages.cli.one_liner\` (\`/.well-known/haven.json\`) \u2014 run it as given: \`packages.cli.channel\` serves the full spec. Do not hold the process open while you wait: under \`--json\`, pass \`--no-wait\` to get the link object back at once, then poll it with \`haven login --poll <device_code>\` \u2014 one round per invocation, exit 3 while it is still pending, 0 once approved. It can set up agents and read the account; it cannot sign, approve a budget, move funds, or rotate any agent's keys.
5294
+ 1. **HUMAN \u2014 create the account.** Name, email, password, then a passkey or a wallet. Never offer to enter any of it: you must not have their password, and the passkey is bound to their device. With a terminal, \`<packages.cli.one_liner> login --api <api-url>\` afterwards gets you a scoped session for steps 3-4 (that flag or \`HAVEN_API_URL\`, on the first command \u2014 the session then remembers the backend; **the CLI's built-in default is Haven's hosted production backend**, so on any other deployment an omitted flag connects you somewhere real and wrong rather than failing) \u2014 they approve a code in the browser, you never hold their password. That command is the manifest's \`packages.cli.one_liner\` (\`/.well-known/haven.json\`) \u2014 run it as given: \`packages.cli.channel\` serves the full spec. Do not hold the process open while you wait: under \`--json\`, pass \`--no-wait\` to get the link object back at once, then poll it with \`haven login --poll <device_code>\` \u2014 one round per invocation, exit 3 while it is still pending, 0 once approved. It can set up agents and read the account; it cannot sign, approve a budget, move funds, or rotate any agent's keys.
5005
5295
  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.
5006
5296
  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.
5007
5297
  4. **YOU \u2014 run the connector command** in that prompt (see What you run). It makes your signing key locally, registering only the public address.
@@ -5025,7 +5315,7 @@ Send these as your own message, \`<host>\` replaced by the host you fetched this
5025
5315
 
5026
5316
  **Before signup** (step 1):
5027
5317
 
5028
- > 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\`.
5318
+ > I can do everything except the parts that need your signature. Please open \`<host>/signup?next=/agents&via=agent\` \u2014 name, email, password, then a passkey or a wallet. That is your account's key: I should not have it, and I will never ask for your password. Already have one? \`<host>/login?next=/agents\`.
5029
5319
 
5030
5320
  **At the passkey step:**
5031
5321
 
@@ -5393,10 +5683,13 @@ request, this is the only way it can learn the purchase failed \u2014 without it
5393
5683
  failed purchase reads as complete for fifteen minutes. If the merchant's
5394
5684
  \`PAYMENT-RESPONSE\` header names a \`transaction\`, pass that raw header as
5395
5685
  \`payment_response\` on the SAME \`mcp__haven__haven_report_x402_outcome\`
5396
- call: Haven decodes it, verifies the settlement on-chain, and the receipt then
5397
- shows the merchant's settlement, not only the funding transaction. Call
5686
+ call, together with \`payment_header\`: the exact header you retried the
5687
+ merchant with. Haven records a reported settlement only with that header,
5688
+ which proves the settlement is this payment's. It decodes the response,
5689
+ verifies the settlement on-chain, and the receipt then shows the merchant's
5690
+ settlement, not only the funding transaction. Call
5398
5691
  \`mcp__haven__haven_report_settlement_evidence\` only when the outcome answer
5399
- names it as the next step. On the **erc7710** scheme (the pay result says
5692
+ names it as the next step, and pass the same \`payment_header\` there too. On the **erc7710** scheme (the pay result says
5400
5693
  \`settlement_scheme: "erc7710"\`), sign with \`mcp__haven-signer__haven_sign\`,
5401
5694
  then \`mcp__haven__haven_submit\` with \`settlement_scheme: "erc7710"\`
5402
5695
  returns the \`payment_header\`; retry the merchant yourself with it as
@@ -5426,7 +5719,9 @@ for example, an invoice carrying an \`x402_payment_url\` to POST with its
5426
5719
  \`invoice_id\`, beside a raw deposit address and a web payment link.
5427
5720
  - **Quote the exact request:** \`mcp__haven__haven_quote_x402\` with \`url\`,
5428
5721
  \`method\`, \`headers\` and \`body\`, exactly as the merchant described it.
5429
- \`body\` is a JSON **string**, not an object. On a JSON POST always pass
5722
+ \`body\` is a JSON **string**, not an object. When the price is stated up
5723
+ front (an invoice total, say), also pass \`expected_amount\` \u2014 the price you
5724
+ expect, in whole tokens (\`"0.10"\`). On a JSON POST always pass
5430
5725
  \`headers: {"Content-Type": "application/json"}\` \u2014 the tool does not infer
5431
5726
  it, and a merchant may answer a request without it with a generic challenge
5432
5727
  Haven cannot pay (for example, only the \`upto\` scheme).
@@ -5455,6 +5750,16 @@ for example, an invoice carrying an \`x402_payment_url\` to POST with its
5455
5750
  report it, the merchant's settlement evidence. (A deposit transfer is bound
5456
5751
  to its payee and amount on-chain too; the difference is the record, not
5457
5752
  the binding.)
5753
+ - **If the quote says stop, stop.** The quote checks the agent's remaining
5754
+ budget at quote time, and it can check a price you state (\`expected_amount\`).
5755
+ When it returns \`safe_to_continue: false\` \u2014 the amount exceeds the budget, or
5756
+ the price does not match what you expected \u2014 it prefills no cap and names no
5757
+ next tool: stop and tell the user. If the x402 challenge itself is wrong (a
5758
+ price wildly off the invoice) and NOTHING has been paid via x402, the
5759
+ invoice's own deposit address MAY be an alternative, but only with the
5760
+ user's explicit go-ahead \u2014 never automatically. Once an x402 payment has
5761
+ been attempted or refused, never pay the deposit address: it can pay the
5762
+ invoice twice.
5458
5763
  - **Pay exactly one route, and never fall back silently.** If the x402 route
5459
5764
  is refused or fails, do not then pay the deposit address \u2014 that pays the
5460
5765
  invoice twice. Follow the result's guidance fields instead: on EIP-3009, a
@@ -5664,7 +5969,7 @@ async function discoverMerchantMcpUrl(inputUrl, egress) {
5664
5969
  } catch (err) {
5665
5970
  if (err instanceof MerchantEgressRefusedError || err instanceof MerchantEgressResponseCapError) throw err;
5666
5971
  if (isBodyPhaseTimeout(err)) {
5667
- throw new chunkH37YVYZA_cjs.MerchantTimeoutError(`Merchant discovery document read timed out after ${timeoutMs}ms.`);
5972
+ throw new chunkMZKLAHBK_cjs.MerchantTimeoutError(`Merchant discovery document read timed out after ${timeoutMs}ms.`);
5668
5973
  }
5669
5974
  continue;
5670
5975
  }
@@ -5683,499 +5988,499 @@ function sameUrl(a, b) {
5683
5988
 
5684
5989
  Object.defineProperty(exports, "DEFAULT_NEXT_TOOL_BY_ACTION", {
5685
5990
  enumerable: true,
5686
- get: function () { return chunk22FJ4JQO_cjs.DEFAULT_NEXT_TOOL_BY_ACTION; }
5991
+ get: function () { return chunkIKQIIMM6_cjs.DEFAULT_NEXT_TOOL_BY_ACTION; }
5687
5992
  });
5688
5993
  Object.defineProperty(exports, "ERC7710_ASSET_TRANSFER_METHOD", {
5689
5994
  enumerable: true,
5690
- get: function () { return chunk22FJ4JQO_cjs.ERC7710_ASSET_TRANSFER_METHOD; }
5995
+ get: function () { return chunkIKQIIMM6_cjs.ERC7710_ASSET_TRANSFER_METHOD; }
5691
5996
  });
5692
5997
  Object.defineProperty(exports, "HAVEN_CLIENT_HEADER", {
5693
5998
  enumerable: true,
5694
- get: function () { return chunk22FJ4JQO_cjs.HAVEN_CLIENT_HEADER; }
5999
+ get: function () { return chunkIKQIIMM6_cjs.HAVEN_CLIENT_HEADER; }
5695
6000
  });
5696
6001
  Object.defineProperty(exports, "HAVEN_MINIMUM_NODE_VERSION", {
5697
6002
  enumerable: true,
5698
- get: function () { return chunk22FJ4JQO_cjs.HAVEN_MINIMUM_NODE_VERSION; }
6003
+ get: function () { return chunkIKQIIMM6_cjs.HAVEN_MINIMUM_NODE_VERSION; }
5699
6004
  });
5700
6005
  Object.defineProperty(exports, "HavenTypedDataRefusedError", {
5701
6006
  enumerable: true,
5702
- get: function () { return chunk22FJ4JQO_cjs.HavenTypedDataRefusedError; }
6007
+ get: function () { return chunkIKQIIMM6_cjs.HavenTypedDataRefusedError; }
5703
6008
  });
5704
6009
  Object.defineProperty(exports, "MAX_TASK_BUDGET_TTL_SECONDS", {
5705
6010
  enumerable: true,
5706
- get: function () { return chunk22FJ4JQO_cjs.MAX_TASK_BUDGET_TTL_SECONDS; }
6011
+ get: function () { return chunkIKQIIMM6_cjs.MAX_TASK_BUDGET_TTL_SECONDS; }
5707
6012
  });
5708
6013
  Object.defineProperty(exports, "NEXT_TOOL_SERVER_NAMES", {
5709
6014
  enumerable: true,
5710
- get: function () { return chunk22FJ4JQO_cjs.NEXT_TOOL_SERVER_NAMES; }
6015
+ get: function () { return chunkIKQIIMM6_cjs.NEXT_TOOL_SERVER_NAMES; }
5711
6016
  });
5712
6017
  Object.defineProperty(exports, "NEXT_TOOL_SERVER_ROLES", {
5713
6018
  enumerable: true,
5714
- get: function () { return chunk22FJ4JQO_cjs.NEXT_TOOL_SERVER_ROLES; }
6019
+ get: function () { return chunkIKQIIMM6_cjs.NEXT_TOOL_SERVER_ROLES; }
5715
6020
  });
5716
6021
  Object.defineProperty(exports, "SDK_CLIENT_IDENTITY", {
5717
6022
  enumerable: true,
5718
- get: function () { return chunk22FJ4JQO_cjs.SDK_CLIENT_IDENTITY; }
6023
+ get: function () { return chunkIKQIIMM6_cjs.SDK_CLIENT_IDENTITY; }
5719
6024
  });
5720
6025
  Object.defineProperty(exports, "SDK_VERSION", {
5721
6026
  enumerable: true,
5722
- get: function () { return chunk22FJ4JQO_cjs.SDK_VERSION; }
6027
+ get: function () { return chunkIKQIIMM6_cjs.SDK_VERSION; }
5723
6028
  });
5724
6029
  Object.defineProperty(exports, "SWEEP_BASE_CHAIN_ID", {
5725
6030
  enumerable: true,
5726
- get: function () { return chunk22FJ4JQO_cjs.SWEEP_BASE_CHAIN_ID; }
6031
+ get: function () { return chunkIKQIIMM6_cjs.SWEEP_BASE_CHAIN_ID; }
5727
6032
  });
5728
6033
  Object.defineProperty(exports, "SWEEP_BASE_SEPOLIA_CHAIN_ID", {
5729
6034
  enumerable: true,
5730
- get: function () { return chunk22FJ4JQO_cjs.SWEEP_BASE_SEPOLIA_CHAIN_ID; }
6035
+ get: function () { return chunkIKQIIMM6_cjs.SWEEP_BASE_SEPOLIA_CHAIN_ID; }
5731
6036
  });
5732
6037
  Object.defineProperty(exports, "SWEEP_BASE_SEPOLIA_USDC_ADDRESS", {
5733
6038
  enumerable: true,
5734
- get: function () { return chunk22FJ4JQO_cjs.SWEEP_BASE_SEPOLIA_USDC_ADDRESS; }
6039
+ get: function () { return chunkIKQIIMM6_cjs.SWEEP_BASE_SEPOLIA_USDC_ADDRESS; }
5735
6040
  });
5736
6041
  Object.defineProperty(exports, "SWEEP_BASE_USDC_ADDRESS", {
5737
6042
  enumerable: true,
5738
- get: function () { return chunk22FJ4JQO_cjs.SWEEP_BASE_USDC_ADDRESS; }
6043
+ get: function () { return chunkIKQIIMM6_cjs.SWEEP_BASE_USDC_ADDRESS; }
5739
6044
  });
5740
6045
  Object.defineProperty(exports, "TRANSFER_WITH_AUTHORIZATION_TYPES", {
5741
6046
  enumerable: true,
5742
- get: function () { return chunk22FJ4JQO_cjs.TRANSFER_WITH_AUTHORIZATION_TYPES; }
6047
+ get: function () { return chunkIKQIIMM6_cjs.TRANSFER_WITH_AUTHORIZATION_TYPES; }
5743
6048
  });
5744
6049
  Object.defineProperty(exports, "TYPED_DATA_NOT_ALLOWED", {
5745
6050
  enumerable: true,
5746
- get: function () { return chunk22FJ4JQO_cjs.TYPED_DATA_NOT_ALLOWED; }
6051
+ get: function () { return chunkIKQIIMM6_cjs.TYPED_DATA_NOT_ALLOWED; }
5747
6052
  });
5748
6053
  Object.defineProperty(exports, "X402PaymentHeaderValidationError", {
5749
6054
  enumerable: true,
5750
- get: function () { return chunk22FJ4JQO_cjs.X402PaymentHeaderValidationError; }
6055
+ get: function () { return chunkIKQIIMM6_cjs.X402PaymentHeaderValidationError; }
5751
6056
  });
5752
6057
  Object.defineProperty(exports, "X402_LEGACY_PAYMENT_HEADER_NAME", {
5753
6058
  enumerable: true,
5754
- get: function () { return chunk22FJ4JQO_cjs.X402_LEGACY_PAYMENT_HEADER_NAME; }
6059
+ get: function () { return chunkIKQIIMM6_cjs.X402_LEGACY_PAYMENT_HEADER_NAME; }
5755
6060
  });
5756
6061
  Object.defineProperty(exports, "X402_MAX_AUTHORIZATION_WINDOW_SECONDS", {
5757
6062
  enumerable: true,
5758
- get: function () { return chunk22FJ4JQO_cjs.X402_MAX_AUTHORIZATION_WINDOW_SECONDS; }
6063
+ get: function () { return chunkIKQIIMM6_cjs.X402_MAX_AUTHORIZATION_WINDOW_SECONDS; }
5759
6064
  });
5760
6065
  Object.defineProperty(exports, "X402_PAYMENT_HEADER_NAME", {
5761
6066
  enumerable: true,
5762
- get: function () { return chunk22FJ4JQO_cjs.X402_PAYMENT_HEADER_NAME; }
6067
+ get: function () { return chunkIKQIIMM6_cjs.X402_PAYMENT_HEADER_NAME; }
5763
6068
  });
5764
6069
  Object.defineProperty(exports, "X402_PAYMENT_HEADER_NAMES_SENT", {
5765
6070
  enumerable: true,
5766
- get: function () { return chunk22FJ4JQO_cjs.X402_PAYMENT_HEADER_NAMES_SENT; }
6071
+ get: function () { return chunkIKQIIMM6_cjs.X402_PAYMENT_HEADER_NAMES_SENT; }
5767
6072
  });
5768
6073
  Object.defineProperty(exports, "X402_PAYMENT_NONCE_TAG", {
5769
6074
  enumerable: true,
5770
- get: function () { return chunk22FJ4JQO_cjs.X402_PAYMENT_NONCE_TAG; }
6075
+ get: function () { return chunkIKQIIMM6_cjs.X402_PAYMENT_NONCE_TAG; }
5771
6076
  });
5772
6077
  Object.defineProperty(exports, "X402_PAYMENT_REQUIRED_HEADER_NAME", {
5773
6078
  enumerable: true,
5774
- get: function () { return chunk22FJ4JQO_cjs.X402_PAYMENT_REQUIRED_HEADER_NAME; }
6079
+ get: function () { return chunkIKQIIMM6_cjs.X402_PAYMENT_REQUIRED_HEADER_NAME; }
5775
6080
  });
5776
6081
  Object.defineProperty(exports, "X402_PAYMENT_RESPONSE_HEADER_NAME", {
5777
6082
  enumerable: true,
5778
- get: function () { return chunk22FJ4JQO_cjs.X402_PAYMENT_RESPONSE_HEADER_NAME; }
6083
+ get: function () { return chunkIKQIIMM6_cjs.X402_PAYMENT_RESPONSE_HEADER_NAME; }
5779
6084
  });
5780
6085
  Object.defineProperty(exports, "X402_SETTLEMENT_FORWARD_MARGIN_SECONDS", {
5781
6086
  enumerable: true,
5782
- get: function () { return chunk22FJ4JQO_cjs.X402_SETTLEMENT_FORWARD_MARGIN_SECONDS; }
6087
+ get: function () { return chunkIKQIIMM6_cjs.X402_SETTLEMENT_FORWARD_MARGIN_SECONDS; }
5783
6088
  });
5784
6089
  Object.defineProperty(exports, "assertBoundDirectPaymentUserOp", {
5785
6090
  enumerable: true,
5786
- get: function () { return chunk22FJ4JQO_cjs.assertBoundDirectPaymentUserOp; }
6091
+ get: function () { return chunkIKQIIMM6_cjs.assertBoundDirectPaymentUserOp; }
5787
6092
  });
5788
6093
  Object.defineProperty(exports, "assertOwnTaskBudgetCloseUserOp", {
5789
6094
  enumerable: true,
5790
- get: function () { return chunk22FJ4JQO_cjs.assertOwnTaskBudgetCloseUserOp; }
6095
+ get: function () { return chunkIKQIIMM6_cjs.assertOwnTaskBudgetCloseUserOp; }
5791
6096
  });
5792
6097
  Object.defineProperty(exports, "assertOwnTaskChild", {
5793
6098
  enumerable: true,
5794
- get: function () { return chunk22FJ4JQO_cjs.assertOwnTaskChild; }
6099
+ get: function () { return chunkIKQIIMM6_cjs.assertOwnTaskChild; }
5795
6100
  });
5796
6101
  Object.defineProperty(exports, "buildSweepAuthorizationMessage", {
5797
6102
  enumerable: true,
5798
- get: function () { return chunk22FJ4JQO_cjs.buildSweepAuthorizationMessage; }
6103
+ get: function () { return chunkIKQIIMM6_cjs.buildSweepAuthorizationMessage; }
5799
6104
  });
5800
6105
  Object.defineProperty(exports, "buildSweepTypedData", {
5801
6106
  enumerable: true,
5802
- get: function () { return chunk22FJ4JQO_cjs.buildSweepTypedData; }
6107
+ get: function () { return chunkIKQIIMM6_cjs.buildSweepTypedData; }
5803
6108
  });
5804
6109
  Object.defineProperty(exports, "buildX402ExpectedMessage", {
5805
6110
  enumerable: true,
5806
- get: function () { return chunk22FJ4JQO_cjs.buildX402ExpectedMessage; }
6111
+ get: function () { return chunkIKQIIMM6_cjs.buildX402ExpectedMessage; }
5807
6112
  });
5808
6113
  Object.defineProperty(exports, "compareNodeVersions", {
5809
6114
  enumerable: true,
5810
- get: function () { return chunk22FJ4JQO_cjs.compareNodeVersions; }
6115
+ get: function () { return chunkIKQIIMM6_cjs.compareNodeVersions; }
5811
6116
  });
5812
6117
  Object.defineProperty(exports, "createNextStepBuilder", {
5813
6118
  enumerable: true,
5814
- get: function () { return chunk22FJ4JQO_cjs.createNextStepBuilder; }
6119
+ get: function () { return chunkIKQIIMM6_cjs.createNextStepBuilder; }
5815
6120
  });
5816
6121
  Object.defineProperty(exports, "decodeBase64Json", {
5817
6122
  enumerable: true,
5818
- get: function () { return chunk22FJ4JQO_cjs.decodeBase64Json; }
6123
+ get: function () { return chunkIKQIIMM6_cjs.decodeBase64Json; }
5819
6124
  });
5820
6125
  Object.defineProperty(exports, "decodeBase64Utf8", {
5821
6126
  enumerable: true,
5822
- get: function () { return chunk22FJ4JQO_cjs.decodeBase64Utf8; }
6127
+ get: function () { return chunkIKQIIMM6_cjs.decodeBase64Utf8; }
5823
6128
  });
5824
6129
  Object.defineProperty(exports, "defaultNextToolFor", {
5825
6130
  enumerable: true,
5826
- get: function () { return chunk22FJ4JQO_cjs.defaultNextToolFor; }
6131
+ get: function () { return chunkIKQIIMM6_cjs.defaultNextToolFor; }
5827
6132
  });
5828
6133
  Object.defineProperty(exports, "deriveX402PaymentNonce", {
5829
6134
  enumerable: true,
5830
- get: function () { return chunk22FJ4JQO_cjs.deriveX402PaymentNonce; }
6135
+ get: function () { return chunkIKQIIMM6_cjs.deriveX402PaymentNonce; }
5831
6136
  });
5832
6137
  Object.defineProperty(exports, "encodeBase64Json", {
5833
6138
  enumerable: true,
5834
- get: function () { return chunk22FJ4JQO_cjs.encodeBase64Json; }
6139
+ get: function () { return chunkIKQIIMM6_cjs.encodeBase64Json; }
5835
6140
  });
5836
6141
  Object.defineProperty(exports, "encodeBase64Utf8", {
5837
6142
  enumerable: true,
5838
- get: function () { return chunk22FJ4JQO_cjs.encodeBase64Utf8; }
6143
+ get: function () { return chunkIKQIIMM6_cjs.encodeBase64Utf8; }
5839
6144
  });
5840
6145
  Object.defineProperty(exports, "encodePaymentProof", {
5841
6146
  enumerable: true,
5842
- get: function () { return chunk22FJ4JQO_cjs.encodePaymentProof; }
6147
+ get: function () { return chunkIKQIIMM6_cjs.encodePaymentProof; }
5843
6148
  });
5844
6149
  Object.defineProperty(exports, "hashDelegation", {
5845
6150
  enumerable: true,
5846
- get: function () { return chunk22FJ4JQO_cjs.hashDelegation; }
6151
+ get: function () { return chunkIKQIIMM6_cjs.hashDelegation; }
5847
6152
  });
5848
6153
  Object.defineProperty(exports, "havenClientIdentity", {
5849
6154
  enumerable: true,
5850
- get: function () { return chunk22FJ4JQO_cjs.havenClientIdentity; }
6155
+ get: function () { return chunkIKQIIMM6_cjs.havenClientIdentity; }
5851
6156
  });
5852
6157
  Object.defineProperty(exports, "isErc7710Option", {
5853
6158
  enumerable: true,
5854
- get: function () { return chunk22FJ4JQO_cjs.isErc7710Option; }
6159
+ get: function () { return chunkIKQIIMM6_cjs.isErc7710Option; }
5855
6160
  });
5856
6161
  Object.defineProperty(exports, "isSupportedNodeVersion", {
5857
6162
  enumerable: true,
5858
- get: function () { return chunk22FJ4JQO_cjs.isSupportedNodeVersion; }
6163
+ get: function () { return chunkIKQIIMM6_cjs.isSupportedNodeVersion; }
5859
6164
  });
5860
6165
  Object.defineProperty(exports, "isSweepableChain", {
5861
6166
  enumerable: true,
5862
- get: function () { return chunk22FJ4JQO_cjs.isSweepableChain; }
6167
+ get: function () { return chunkIKQIIMM6_cjs.isSweepableChain; }
5863
6168
  });
5864
6169
  Object.defineProperty(exports, "isTaskChildTypedData", {
5865
6170
  enumerable: true,
5866
- get: function () { return chunk22FJ4JQO_cjs.isTaskChildTypedData; }
6171
+ get: function () { return chunkIKQIIMM6_cjs.isTaskChildTypedData; }
5867
6172
  });
5868
6173
  Object.defineProperty(exports, "normalizePaymentRequired", {
5869
6174
  enumerable: true,
5870
- get: function () { return chunk22FJ4JQO_cjs.normalizePaymentRequired; }
6175
+ get: function () { return chunkIKQIIMM6_cjs.normalizePaymentRequired; }
5871
6176
  });
5872
6177
  Object.defineProperty(exports, "parseNextTool", {
5873
6178
  enumerable: true,
5874
- get: function () { return chunk22FJ4JQO_cjs.parseNextTool; }
6179
+ get: function () { return chunkIKQIIMM6_cjs.parseNextTool; }
5875
6180
  });
5876
6181
  Object.defineProperty(exports, "parsePaymentRequired", {
5877
6182
  enumerable: true,
5878
- get: function () { return chunk22FJ4JQO_cjs.parsePaymentRequired; }
6183
+ get: function () { return chunkIKQIIMM6_cjs.parsePaymentRequired; }
5879
6184
  });
5880
6185
  Object.defineProperty(exports, "parsePaymentRequiredResponse", {
5881
6186
  enumerable: true,
5882
- get: function () { return chunk22FJ4JQO_cjs.parsePaymentRequiredResponse; }
6187
+ get: function () { return chunkIKQIIMM6_cjs.parsePaymentRequiredResponse; }
5883
6188
  });
5884
6189
  Object.defineProperty(exports, "readClientUpdate", {
5885
6190
  enumerable: true,
5886
- get: function () { return chunk22FJ4JQO_cjs.readClientUpdate; }
6191
+ get: function () { return chunkIKQIIMM6_cjs.readClientUpdate; }
5887
6192
  });
5888
6193
  Object.defineProperty(exports, "renderNextTool", {
5889
6194
  enumerable: true,
5890
- get: function () { return chunk22FJ4JQO_cjs.renderNextTool; }
6195
+ get: function () { return chunkIKQIIMM6_cjs.renderNextTool; }
5891
6196
  });
5892
6197
  Object.defineProperty(exports, "resolveTokenBySymbol", {
5893
6198
  enumerable: true,
5894
- get: function () { return chunk22FJ4JQO_cjs.resolveTokenBySymbol; }
6199
+ get: function () { return chunkIKQIIMM6_cjs.resolveTokenBySymbol; }
5895
6200
  });
5896
6201
  Object.defineProperty(exports, "resolveTokenFromAddress", {
5897
6202
  enumerable: true,
5898
- get: function () { return chunk22FJ4JQO_cjs.resolveTokenFromAddress; }
6203
+ get: function () { return chunkIKQIIMM6_cjs.resolveTokenFromAddress; }
5899
6204
  });
5900
6205
  Object.defineProperty(exports, "selectErc7710PaymentOption", {
5901
6206
  enumerable: true,
5902
- get: function () { return chunk22FJ4JQO_cjs.selectErc7710PaymentOption; }
6207
+ get: function () { return chunkIKQIIMM6_cjs.selectErc7710PaymentOption; }
5903
6208
  });
5904
6209
  Object.defineProperty(exports, "selectPaymentOption", {
5905
6210
  enumerable: true,
5906
- get: function () { return chunk22FJ4JQO_cjs.selectPaymentOption; }
6211
+ get: function () { return chunkIKQIIMM6_cjs.selectPaymentOption; }
5907
6212
  });
5908
6213
  Object.defineProperty(exports, "selectStandardPaymentOption", {
5909
6214
  enumerable: true,
5910
- get: function () { return chunk22FJ4JQO_cjs.selectStandardPaymentOption; }
6215
+ get: function () { return chunkIKQIIMM6_cjs.selectStandardPaymentOption; }
5911
6216
  });
5912
6217
  Object.defineProperty(exports, "selectX402SettlementScheme", {
5913
6218
  enumerable: true,
5914
- get: function () { return chunk22FJ4JQO_cjs.selectX402SettlementScheme; }
6219
+ get: function () { return chunkIKQIIMM6_cjs.selectX402SettlementScheme; }
5915
6220
  });
5916
6221
  Object.defineProperty(exports, "sweepUsdcAddress", {
5917
6222
  enumerable: true,
5918
- get: function () { return chunk22FJ4JQO_cjs.sweepUsdcAddress; }
6223
+ get: function () { return chunkIKQIIMM6_cjs.sweepUsdcAddress; }
5919
6224
  });
5920
6225
  Object.defineProperty(exports, "sweepUsdcDomain", {
5921
6226
  enumerable: true,
5922
- get: function () { return chunk22FJ4JQO_cjs.sweepUsdcDomain; }
6227
+ get: function () { return chunkIKQIIMM6_cjs.sweepUsdcDomain; }
5923
6228
  });
5924
6229
  Object.defineProperty(exports, "toStandardPaymentRequirements", {
5925
6230
  enumerable: true,
5926
- get: function () { return chunk22FJ4JQO_cjs.toStandardPaymentRequirements; }
6231
+ get: function () { return chunkIKQIIMM6_cjs.toStandardPaymentRequirements; }
5927
6232
  });
5928
6233
  Object.defineProperty(exports, "unsupportedNodeVersionMessage", {
5929
6234
  enumerable: true,
5930
- get: function () { return chunk22FJ4JQO_cjs.unsupportedNodeVersionMessage; }
6235
+ get: function () { return chunkIKQIIMM6_cjs.unsupportedNodeVersionMessage; }
5931
6236
  });
5932
6237
  Object.defineProperty(exports, "validateStandardX402PaymentHeader", {
5933
6238
  enumerable: true,
5934
- get: function () { return chunk22FJ4JQO_cjs.validateStandardX402PaymentHeader; }
6239
+ get: function () { return chunkIKQIIMM6_cjs.validateStandardX402PaymentHeader; }
5935
6240
  });
5936
6241
  Object.defineProperty(exports, "x402AssetTransferMethod", {
5937
6242
  enumerable: true,
5938
- get: function () { return chunk22FJ4JQO_cjs.x402AssetTransferMethod; }
6243
+ get: function () { return chunkIKQIIMM6_cjs.x402AssetTransferMethod; }
5939
6244
  });
5940
6245
  Object.defineProperty(exports, "x402AuthorizationAmount", {
5941
6246
  enumerable: true,
5942
- get: function () { return chunk22FJ4JQO_cjs.x402AuthorizationAmount; }
6247
+ get: function () { return chunkIKQIIMM6_cjs.x402AuthorizationAmount; }
5943
6248
  });
5944
6249
  Object.defineProperty(exports, "x402FacilitatorAddresses", {
5945
6250
  enumerable: true,
5946
- get: function () { return chunk22FJ4JQO_cjs.x402FacilitatorAddresses; }
6251
+ get: function () { return chunkIKQIIMM6_cjs.x402FacilitatorAddresses; }
5947
6252
  });
5948
6253
  Object.defineProperty(exports, "x402PaymentHeaderNamesFor", {
5949
6254
  enumerable: true,
5950
- get: function () { return chunk22FJ4JQO_cjs.x402PaymentHeaderNamesFor; }
6255
+ get: function () { return chunkIKQIIMM6_cjs.x402PaymentHeaderNamesFor; }
5951
6256
  });
5952
6257
  Object.defineProperty(exports, "x402RetryHeadersFor", {
5953
6258
  enumerable: true,
5954
- get: function () { return chunk22FJ4JQO_cjs.x402RetryHeadersFor; }
6259
+ get: function () { return chunkIKQIIMM6_cjs.x402RetryHeadersFor; }
5955
6260
  });
5956
6261
  Object.defineProperty(exports, "x402V2PaymentEnvelope", {
5957
6262
  enumerable: true,
5958
- get: function () { return chunk22FJ4JQO_cjs.x402V2PaymentEnvelope; }
6263
+ get: function () { return chunkIKQIIMM6_cjs.x402V2PaymentEnvelope; }
5959
6264
  });
5960
6265
  Object.defineProperty(exports, "RECEIPT_VERSION", {
5961
6266
  enumerable: true,
5962
- get: function () { return chunk6LEXYQ7J_cjs.RECEIPT_VERSION; }
6267
+ get: function () { return chunkDXBAN4SN_cjs.RECEIPT_VERSION; }
5963
6268
  });
5964
6269
  Object.defineProperty(exports, "verifyPaymentReceipt", {
5965
6270
  enumerable: true,
5966
- get: function () { return chunk6LEXYQ7J_cjs.verifyPaymentReceipt; }
6271
+ get: function () { return chunkDXBAN4SN_cjs.verifyPaymentReceipt; }
5967
6272
  });
5968
6273
  Object.defineProperty(exports, "AGENT_PAYMENT_FAILURE_CODE_VALUES", {
5969
6274
  enumerable: true,
5970
- get: function () { return chunkH37YVYZA_cjs.AGENT_PAYMENT_FAILURE_CODE_VALUES; }
6275
+ get: function () { return chunkMZKLAHBK_cjs.AGENT_PAYMENT_FAILURE_CODE_VALUES; }
5971
6276
  });
5972
6277
  Object.defineProperty(exports, "AGENT_PAYMENT_NEXT_ACTION_VALUES", {
5973
6278
  enumerable: true,
5974
- get: function () { return chunkH37YVYZA_cjs.AGENT_PAYMENT_NEXT_ACTION_VALUES; }
6279
+ get: function () { return chunkMZKLAHBK_cjs.AGENT_PAYMENT_NEXT_ACTION_VALUES; }
5975
6280
  });
5976
6281
  Object.defineProperty(exports, "AGENT_PAYMENT_PHASE_VALUES", {
5977
6282
  enumerable: true,
5978
- get: function () { return chunkH37YVYZA_cjs.AGENT_PAYMENT_PHASE_VALUES; }
6283
+ get: function () { return chunkMZKLAHBK_cjs.AGENT_PAYMENT_PHASE_VALUES; }
5979
6284
  });
5980
6285
  Object.defineProperty(exports, "AGENT_PAYMENT_RAIL_VALUES", {
5981
6286
  enumerable: true,
5982
- get: function () { return chunkH37YVYZA_cjs.AGENT_PAYMENT_RAIL_VALUES; }
6287
+ get: function () { return chunkMZKLAHBK_cjs.AGENT_PAYMENT_RAIL_VALUES; }
5983
6288
  });
5984
6289
  Object.defineProperty(exports, "AgentPaymentFailureCode", {
5985
6290
  enumerable: true,
5986
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentFailureCode; }
6291
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentFailureCode; }
5987
6292
  });
5988
6293
  Object.defineProperty(exports, "AgentPaymentFailureCodeDescriptions", {
5989
6294
  enumerable: true,
5990
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentFailureCodeDescriptions; }
6295
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentFailureCodeDescriptions; }
5991
6296
  });
5992
6297
  Object.defineProperty(exports, "AgentPaymentFailureCodeSchema", {
5993
6298
  enumerable: true,
5994
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentFailureCodeSchema; }
6299
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentFailureCodeSchema; }
5995
6300
  });
5996
6301
  Object.defineProperty(exports, "AgentPaymentNextAction", {
5997
6302
  enumerable: true,
5998
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentNextAction; }
6303
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentNextAction; }
5999
6304
  });
6000
6305
  Object.defineProperty(exports, "AgentPaymentNextActionDescriptions", {
6001
6306
  enumerable: true,
6002
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentNextActionDescriptions; }
6307
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentNextActionDescriptions; }
6003
6308
  });
6004
6309
  Object.defineProperty(exports, "AgentPaymentNextActionSchema", {
6005
6310
  enumerable: true,
6006
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentNextActionSchema; }
6311
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentNextActionSchema; }
6007
6312
  });
6008
6313
  Object.defineProperty(exports, "AgentPaymentPhase", {
6009
6314
  enumerable: true,
6010
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentPhase; }
6315
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentPhase; }
6011
6316
  });
6012
6317
  Object.defineProperty(exports, "AgentPaymentPhaseDescriptions", {
6013
6318
  enumerable: true,
6014
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentPhaseDescriptions; }
6319
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentPhaseDescriptions; }
6015
6320
  });
6016
6321
  Object.defineProperty(exports, "AgentPaymentPhaseSchema", {
6017
6322
  enumerable: true,
6018
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentPhaseSchema; }
6323
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentPhaseSchema; }
6019
6324
  });
6020
6325
  Object.defineProperty(exports, "AgentPaymentRail", {
6021
6326
  enumerable: true,
6022
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentRail; }
6327
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentRail; }
6023
6328
  });
6024
6329
  Object.defineProperty(exports, "AgentPaymentRailDescriptions", {
6025
6330
  enumerable: true,
6026
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentRailDescriptions; }
6331
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentRailDescriptions; }
6027
6332
  });
6028
6333
  Object.defineProperty(exports, "AgentPaymentRailSchema", {
6029
6334
  enumerable: true,
6030
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentRailSchema; }
6335
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentRailSchema; }
6031
6336
  });
6032
6337
  Object.defineProperty(exports, "AgentPaymentWarningCode", {
6033
6338
  enumerable: true,
6034
- get: function () { return chunkH37YVYZA_cjs.AgentPaymentWarningCode; }
6339
+ get: function () { return chunkMZKLAHBK_cjs.AgentPaymentWarningCode; }
6035
6340
  });
6036
6341
  Object.defineProperty(exports, "CONNECTOR_PACKAGE_NAME", {
6037
6342
  enumerable: true,
6038
- get: function () { return chunkH37YVYZA_cjs.CONNECTOR_PACKAGE_NAME; }
6343
+ get: function () { return chunkMZKLAHBK_cjs.CONNECTOR_PACKAGE_NAME; }
6039
6344
  });
6040
6345
  Object.defineProperty(exports, "DEFAULT_CONFIRMATION_TIMEOUT_MS", {
6041
6346
  enumerable: true,
6042
- get: function () { return chunkH37YVYZA_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS; }
6347
+ get: function () { return chunkMZKLAHBK_cjs.DEFAULT_CONFIRMATION_TIMEOUT_MS; }
6043
6348
  });
6044
6349
  Object.defineProperty(exports, "DIRECT_SIGN_CONTEXT_VERSION", {
6045
6350
  enumerable: true,
6046
- get: function () { return chunkH37YVYZA_cjs.DIRECT_SIGN_CONTEXT_VERSION; }
6351
+ get: function () { return chunkMZKLAHBK_cjs.DIRECT_SIGN_CONTEXT_VERSION; }
6047
6352
  });
6048
6353
  Object.defineProperty(exports, "ENTRY_POINT_V07", {
6049
6354
  enumerable: true,
6050
- get: function () { return chunkH37YVYZA_cjs.ENTRY_POINT_V07; }
6355
+ get: function () { return chunkMZKLAHBK_cjs.ENTRY_POINT_V07; }
6051
6356
  });
6052
6357
  Object.defineProperty(exports, "HAVEN_CONNECTOR_CHANNEL", {
6053
6358
  enumerable: true,
6054
- get: function () { return chunkH37YVYZA_cjs.HAVEN_CONNECTOR_CHANNEL; }
6359
+ get: function () { return chunkMZKLAHBK_cjs.HAVEN_CONNECTOR_CHANNEL; }
6055
6360
  });
6056
6361
  Object.defineProperty(exports, "HYBRID_DELEGATOR_DOMAIN_NAME", {
6057
6362
  enumerable: true,
6058
- get: function () { return chunkH37YVYZA_cjs.HYBRID_DELEGATOR_DOMAIN_NAME; }
6363
+ get: function () { return chunkMZKLAHBK_cjs.HYBRID_DELEGATOR_DOMAIN_NAME; }
6059
6364
  });
6060
6365
  Object.defineProperty(exports, "HYBRID_DELEGATOR_DOMAIN_VERSION", {
6061
6366
  enumerable: true,
6062
- get: function () { return chunkH37YVYZA_cjs.HYBRID_DELEGATOR_DOMAIN_VERSION; }
6367
+ get: function () { return chunkMZKLAHBK_cjs.HYBRID_DELEGATOR_DOMAIN_VERSION; }
6063
6368
  });
6064
6369
  Object.defineProperty(exports, "HavenApiError", {
6065
6370
  enumerable: true,
6066
- get: function () { return chunkH37YVYZA_cjs.HavenApiError; }
6371
+ get: function () { return chunkMZKLAHBK_cjs.HavenApiError; }
6067
6372
  });
6068
6373
  Object.defineProperty(exports, "HavenError", {
6069
6374
  enumerable: true,
6070
- get: function () { return chunkH37YVYZA_cjs.HavenError; }
6375
+ get: function () { return chunkMZKLAHBK_cjs.HavenError; }
6071
6376
  });
6072
6377
  Object.defineProperty(exports, "HavenPaymentStateError", {
6073
6378
  enumerable: true,
6074
- get: function () { return chunkH37YVYZA_cjs.HavenPaymentStateError; }
6379
+ get: function () { return chunkMZKLAHBK_cjs.HavenPaymentStateError; }
6075
6380
  });
6076
6381
  Object.defineProperty(exports, "HavenSigningError", {
6077
6382
  enumerable: true,
6078
- get: function () { return chunkH37YVYZA_cjs.HavenSigningError; }
6383
+ get: function () { return chunkMZKLAHBK_cjs.HavenSigningError; }
6079
6384
  });
6080
6385
  Object.defineProperty(exports, "HavenTimeoutError", {
6081
6386
  enumerable: true,
6082
- get: function () { return chunkH37YVYZA_cjs.HavenTimeoutError; }
6387
+ get: function () { return chunkMZKLAHBK_cjs.HavenTimeoutError; }
6083
6388
  });
6084
6389
  Object.defineProperty(exports, "HavenUnsupportedSignerVersionError", {
6085
6390
  enumerable: true,
6086
- get: function () { return chunkH37YVYZA_cjs.HavenUnsupportedSignerVersionError; }
6391
+ get: function () { return chunkMZKLAHBK_cjs.HavenUnsupportedSignerVersionError; }
6087
6392
  });
6088
6393
  Object.defineProperty(exports, "HavenUserOpBindingError", {
6089
6394
  enumerable: true,
6090
- get: function () { return chunkH37YVYZA_cjs.HavenUserOpBindingError; }
6395
+ get: function () { return chunkMZKLAHBK_cjs.HavenUserOpBindingError; }
6091
6396
  });
6092
6397
  Object.defineProperty(exports, "HavenZeroSettlementHashError", {
6093
6398
  enumerable: true,
6094
- get: function () { return chunkH37YVYZA_cjs.HavenZeroSettlementHashError; }
6399
+ get: function () { return chunkMZKLAHBK_cjs.HavenZeroSettlementHashError; }
6095
6400
  });
6096
6401
  Object.defineProperty(exports, "MerchantTimeoutError", {
6097
6402
  enumerable: true,
6098
- get: function () { return chunkH37YVYZA_cjs.MerchantTimeoutError; }
6403
+ get: function () { return chunkMZKLAHBK_cjs.MerchantTimeoutError; }
6099
6404
  });
6100
6405
  Object.defineProperty(exports, "PACKED_USER_OPERATION_FIELDS", {
6101
6406
  enumerable: true,
6102
- get: function () { return chunkH37YVYZA_cjs.PACKED_USER_OPERATION_FIELDS; }
6407
+ get: function () { return chunkMZKLAHBK_cjs.PACKED_USER_OPERATION_FIELDS; }
6103
6408
  });
6104
6409
  Object.defineProperty(exports, "ROOT_AUTHORITY", {
6105
6410
  enumerable: true,
6106
- get: function () { return chunkH37YVYZA_cjs.ROOT_AUTHORITY; }
6411
+ get: function () { return chunkMZKLAHBK_cjs.ROOT_AUTHORITY; }
6107
6412
  });
6108
6413
  Object.defineProperty(exports, "SIGNER_UPDATE_FALLBACK", {
6109
6414
  enumerable: true,
6110
- get: function () { return chunkH37YVYZA_cjs.SIGNER_UPDATE_FALLBACK; }
6415
+ get: function () { return chunkMZKLAHBK_cjs.SIGNER_UPDATE_FALLBACK; }
6111
6416
  });
6112
6417
  Object.defineProperty(exports, "SignerRefusalCode", {
6113
6418
  enumerable: true,
6114
- get: function () { return chunkH37YVYZA_cjs.SignerRefusalCode; }
6419
+ get: function () { return chunkMZKLAHBK_cjs.SignerRefusalCode; }
6115
6420
  });
6116
6421
  Object.defineProperty(exports, "TASK_SIGN_CONTEXT_VERSION", {
6117
6422
  enumerable: true,
6118
- get: function () { return chunkH37YVYZA_cjs.TASK_SIGN_CONTEXT_VERSION; }
6423
+ get: function () { return chunkMZKLAHBK_cjs.TASK_SIGN_CONTEXT_VERSION; }
6119
6424
  });
6120
6425
  Object.defineProperty(exports, "X402AlreadySettledError", {
6121
6426
  enumerable: true,
6122
- get: function () { return chunkH37YVYZA_cjs.X402AlreadySettledError; }
6427
+ get: function () { return chunkMZKLAHBK_cjs.X402AlreadySettledError; }
6123
6428
  });
6124
6429
  Object.defineProperty(exports, "X402Erc7710AlreadySettledError", {
6125
6430
  enumerable: true,
6126
- get: function () { return chunkH37YVYZA_cjs.X402Erc7710AlreadySettledError; }
6431
+ get: function () { return chunkMZKLAHBK_cjs.X402Erc7710AlreadySettledError; }
6127
6432
  });
6128
6433
  Object.defineProperty(exports, "X402TaskBudgetMismatchError", {
6129
6434
  enumerable: true,
6130
- get: function () { return chunkH37YVYZA_cjs.X402TaskBudgetMismatchError; }
6435
+ get: function () { return chunkMZKLAHBK_cjs.X402TaskBudgetMismatchError; }
6131
6436
  });
6132
6437
  Object.defineProperty(exports, "X402UnexpectedStatusError", {
6133
6438
  enumerable: true,
6134
- get: function () { return chunkH37YVYZA_cjs.X402UnexpectedStatusError; }
6439
+ get: function () { return chunkMZKLAHBK_cjs.X402UnexpectedStatusError; }
6135
6440
  });
6136
6441
  Object.defineProperty(exports, "assertUserOpTypedDataBinding", {
6137
6442
  enumerable: true,
6138
- get: function () { return chunkH37YVYZA_cjs.assertUserOpTypedDataBinding; }
6443
+ get: function () { return chunkMZKLAHBK_cjs.assertUserOpTypedDataBinding; }
6139
6444
  });
6140
6445
  Object.defineProperty(exports, "connectorRerunCommand", {
6141
6446
  enumerable: true,
6142
- get: function () { return chunkH37YVYZA_cjs.connectorRerunCommand; }
6447
+ get: function () { return chunkMZKLAHBK_cjs.connectorRerunCommand; }
6143
6448
  });
6144
6449
  Object.defineProperty(exports, "connectorSpec", {
6145
6450
  enumerable: true,
6146
- get: function () { return chunkH37YVYZA_cjs.connectorSpec; }
6451
+ get: function () { return chunkMZKLAHBK_cjs.connectorSpec; }
6147
6452
  });
6148
6453
  Object.defineProperty(exports, "connectorUpgradeCommand", {
6149
6454
  enumerable: true,
6150
- get: function () { return chunkH37YVYZA_cjs.connectorUpgradeCommand; }
6455
+ get: function () { return chunkMZKLAHBK_cjs.connectorUpgradeCommand; }
6151
6456
  });
6152
6457
  Object.defineProperty(exports, "deriveDelegateAccountAddress", {
6153
6458
  enumerable: true,
6154
- get: function () { return chunkH37YVYZA_cjs.deriveDelegateAccountAddress; }
6459
+ get: function () { return chunkMZKLAHBK_cjs.deriveDelegateAccountAddress; }
6155
6460
  });
6156
6461
  Object.defineProperty(exports, "isConnectorChannel", {
6157
6462
  enumerable: true,
6158
- get: function () { return chunkH37YVYZA_cjs.isConnectorChannel; }
6463
+ get: function () { return chunkMZKLAHBK_cjs.isConnectorChannel; }
6159
6464
  });
6160
6465
  Object.defineProperty(exports, "isPackedUserOperationTypedData", {
6161
6466
  enumerable: true,
6162
- get: function () { return chunkH37YVYZA_cjs.isPackedUserOperationTypedData; }
6467
+ get: function () { return chunkMZKLAHBK_cjs.isPackedUserOperationTypedData; }
6163
6468
  });
6164
6469
  Object.defineProperty(exports, "packedUserOperationHash", {
6165
6470
  enumerable: true,
6166
- get: function () { return chunkH37YVYZA_cjs.packedUserOperationHash; }
6471
+ get: function () { return chunkMZKLAHBK_cjs.packedUserOperationHash; }
6167
6472
  });
6168
6473
  Object.defineProperty(exports, "resolveConnectorChannel", {
6169
6474
  enumerable: true,
6170
- get: function () { return chunkH37YVYZA_cjs.resolveConnectorChannel; }
6475
+ get: function () { return chunkMZKLAHBK_cjs.resolveConnectorChannel; }
6171
6476
  });
6172
6477
  Object.defineProperty(exports, "signerUpdateFallback", {
6173
6478
  enumerable: true,
6174
- get: function () { return chunkH37YVYZA_cjs.signerUpdateFallback; }
6479
+ get: function () { return chunkMZKLAHBK_cjs.signerUpdateFallback; }
6175
6480
  });
6176
6481
  Object.defineProperty(exports, "verifySettlementChild", {
6177
6482
  enumerable: true,
6178
- get: function () { return chunkH37YVYZA_cjs.verifySettlementChild; }
6483
+ get: function () { return chunkMZKLAHBK_cjs.verifySettlementChild; }
6179
6484
  });
6180
6485
  exports.AGENT_APPROVAL_RELAY_JSON_SENTENCE = AGENT_APPROVAL_RELAY_JSON_SENTENCE;
6181
6486
  exports.AGENT_APPROVAL_RELAY_PROSE_SENTENCE = AGENT_APPROVAL_RELAY_PROSE_SENTENCE;