@haven_ai/sdk 0.0.0-dev.202609281335.705f436 → 0.0.0-dev.202609281945.3f83e0e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -244,7 +244,12 @@ case where two purchases collided on a key you did not choose.
244
244
 
245
245
  This applies to the **EIP-3009 funding-leg** scheme, which routes money
246
246
  through the delegate EOA. **erc7710 direct settlement is unaffected**: it has
247
- no funding leg and no delegate balance to exhaust.
247
+ no funding leg and no delegate balance to exhaust. On erc7710, a key whose
248
+ payment to the same merchant for the same resource already settled makes
249
+ `prepareX402Erc7710()` throw `X402Erc7710AlreadySettledError` (`paymentId`,
250
+ `txHash`) instead of minting a settlement child. A key already used for a
251
+ payment to a different payee or resource is refused with a 409
252
+ `HavenApiError`; amount and MCP tool call are not compared (#3417).
248
253
 
249
254
  For agents that need to inspect the price before paying, use the quote-first
250
255
  path. `quoteX402()` probes the merchant and parses the HTTP 402 response, but it
@@ -640,11 +645,18 @@ try {
640
645
  }
641
646
  ```
642
647
 
643
- `X402AlreadySettledError` extends `HavenApiError` (status 409) and is the one
644
- error above that is **not** a failure to pay — it reports that the payment it
645
- describes *succeeded*, earlier. Handle it before the generic `HavenApiError`
646
- branch, and treat `err.receipt` as proof of purchase rather than retrying. See
647
- [Idempotency](#idempotency-what-the-key-guarantees-and-what-it-costs).
648
+ Two errors are **not** a failure to pay; each reports that the payment it
649
+ describes *succeeded*, earlier. Handle both before the generic branches, and
650
+ treat them as proof of purchase rather than retrying:
651
+
652
+ - `X402AlreadySettledError` extends `HavenApiError` (status 409; EIP-3009
653
+ path) and carries `err.receipt`.
654
+ - `X402Erc7710AlreadySettledError` extends `HavenError`, **not**
655
+ `HavenApiError` (no status; code `PAYMENT_ALREADY_SETTLED`; erc7710
656
+ `prepareX402Erc7710()`), and carries `err.paymentId` and `err.txHash`. An
657
+ `instanceof HavenApiError` branch does not catch it.
658
+
659
+ See [Idempotency](#idempotency-what-the-key-guarantees-and-what-it-costs).
648
660
 
649
661
  ## License
650
662
 
@@ -697,7 +697,7 @@ interface HavenAgentAllowanceSummary {
697
697
  remainingAtomic: string;
698
698
  /** Human-readable remaining, e.g. "4.96 USDC". */
699
699
  remainingDisplay: string;
700
- /** Configured allowance amount (atomic) the owner granted. */
700
+ /** Configured allowance amount in whole token units (human decimal, e.g. "1.00" — NOT atomic; on-chain.amount is the atomic figure). */
701
701
  configuredAmount: string;
702
702
  resetPeriodMin: number;
703
703
  isResetPending: boolean;
@@ -1609,6 +1609,32 @@ declare class MerchantTimeoutError extends HavenApiError {
1609
1609
  readonly merchantErrorCode: "merchant_timeout";
1610
1610
  constructor(message: string);
1611
1611
  }
1612
+ /**
1613
+ * #3417: an erc7710 `POST /x402` authorize replayed a key whose payment to THIS
1614
+ * merchant for THIS resource has already settled. The backend returns
1615
+ * `200 { status: 'confirmed', tx_hash, to, resource_url }` and, correctly, no
1616
+ * `sign_data`, because nothing is left to sign
1617
+ * (`packages/backend/src/modules/x402/replay.ts`). Before this class the
1618
+ * erc7710 path read that answer as a scheme mismatch and threw a 500, which
1619
+ * hosted callers relayed as "transient, retry". Typed so a caller can report
1620
+ * the original settlement instead of retrying, and never signs anything.
1621
+ *
1622
+ * Only thrown when the confirmed row pays the merchant this request names, for
1623
+ * the resource it asked for. The backend's replay lookup is keyed on the
1624
+ * idempotency key alone, so a key reused for another payee or resource — or
1625
+ * first spent on an EIP-3009 funding leg, whose confirmed `tx_hash` proves only
1626
+ * that the delegate was funded — is refused as a 409 collision instead of read
1627
+ * as this settlement. Amount and the MCP tool call are not compared: on an MCP
1628
+ * merchant the resource is its endpoint, so a key reused for another tool
1629
+ * there is answered as that merchant's earlier payment. A `HavenError`, not a `HavenApiError`: nothing failed upstream.
1630
+ */
1631
+ declare class X402Erc7710AlreadySettledError extends HavenError {
1632
+ readonly paymentId: string;
1633
+ readonly txHash: string;
1634
+ readonly body?: unknown | undefined;
1635
+ readonly x402ErrorCode: "payment_already_settled";
1636
+ constructor(paymentId: string, txHash: string, body?: unknown | undefined);
1637
+ }
1612
1638
  declare class X402UnexpectedStatusError extends HavenApiError {
1613
1639
  readonly x402ErrorCode: "unexpected_non_402_status";
1614
1640
  /**
@@ -1969,7 +1995,7 @@ declare function buildSweepAuthorizationMessage(auth: SweepAuthorization): strin
1969
1995
  * This SDK's own version. Owned by `scripts/release-bump.mjs`, which rewrites
1970
1996
  * it with the package version on every release — never hand-edit it.
1971
1997
  */
1972
- declare const SDK_VERSION = "0.0.0-dev.202609281335.705f436";
1998
+ declare const SDK_VERSION = "0.0.0-dev.202609281945.3f83e0e";
1973
1999
  /** The request header every published Haven client sends. */
1974
2000
  declare const HAVEN_CLIENT_HEADER = "X-Haven-Client";
1975
2001
  /** `<package>/<version>` — the value of {@link HAVEN_CLIENT_HEADER}. */
@@ -2562,6 +2588,19 @@ declare function resolveTokenFromAddress(address: string, network?: string): {
2562
2588
  symbol: string;
2563
2589
  decimals: number;
2564
2590
  } | null;
2591
+ /**
2592
+ * #3410: token decimals from a SYMBOL + CHAIN — the same registry
2593
+ * `resolveTokenFromAddress` reads, keyed the other way. The address-based
2594
+ * resolver needs the token's contract address, which the consent seed path
2595
+ * (setup-time credential files) does not carry; the symbol and chain it does
2596
+ * carry. Null when the symbol is not registered on that chain (unknown or
2597
+ * custom tokens) — callers must fall back to an explicit atomic label rather
2598
+ * than reading an atomic amount as whole tokens.
2599
+ */
2600
+ declare function resolveTokenBySymbol(chainId: number, symbol: string): {
2601
+ symbol: string;
2602
+ decimals: number;
2603
+ } | null;
2565
2604
 
2566
2605
  /**
2567
2606
  * #3271: the integrity check every client runs before signing a direct
@@ -3045,4 +3084,4 @@ declare function encodeBase64Json(value: unknown): string;
3045
3084
  */
3046
3085
  declare function decodeBase64Json<T>(value: string, label?: string): T;
3047
3086
 
3048
- export { AgentPaymentPhase as $, type AgentPaymentWarning as A, type ResumeAuthorizedX402Input as B, type CloseTaskBudgetResult as C, type ResumeX402PaymentInput as D, type X402ResumeState as E, type X402McpTransport as F, type X402MerchantCallContext as G, type HavenClientConfig as H, HavenError as I, AGENT_PAYMENT_FAILURE_CODE_VALUES as J, AGENT_PAYMENT_NEXT_ACTION_VALUES as K, AGENT_PAYMENT_PHASE_VALUES as L, AGENT_PAYMENT_RAIL_VALUES as M, type AgentNextStep as N, type OpenTaskBudgetResult as O, type PaymentRequest as P, type AgentPaymentEnumSchema as Q, type RawPaymentParties as R, type SweepResult as S, type TaskBudgetSignContext as T, AgentPaymentFailureCode as U, AgentPaymentFailureCodeDescriptions as V, AgentPaymentFailureCodeSchema as W, type X402PaymentRequired as X, AgentPaymentNextAction as Y, AgentPaymentNextActionDescriptions as Z, AgentPaymentNextActionSchema as _, type HavenClientUpdate as a, type SweepExpectedAuth as a$, AgentPaymentPhaseDescriptions as a0, AgentPaymentPhaseSchema as a1, AgentPaymentRail as a2, AgentPaymentRailDescriptions as a3, AgentPaymentRailSchema as a4, type AgentPaymentSummary as a5, AgentPaymentWarningCode as a6, type AgentPurchaseSummary as a7, CONNECTOR_PACKAGE_NAME as a8, type CatalogSubmissionAccepted as a9, NEXT_TOOL_SERVER_NAMES as aA, NEXT_TOOL_SERVER_ROLES as aB, type NextStep as aC, type NextStepArguments as aD, type NextStepHandoff as aE, type NextStepInput as aF, type NextStepTarget as aG, type NextStepTargets as aH, type NextToolServerRole as aI, PACKED_USER_OPERATION_FIELDS as aJ, type PaymentFee as aK, type PaymentNextAction as aL, type PaymentPhase as aM, type PaymentStatus as aN, ROOT_AUTHORITY as aO, SDK_CLIENT_IDENTITY as aP, SDK_VERSION as aQ, SIGNER_UPDATE_FALLBACK as aR, SWEEP_BASE_CHAIN_ID as aS, SWEEP_BASE_SEPOLIA_CHAIN_ID as aT, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as aU, SWEEP_BASE_USDC_ADDRESS as aV, type SettlementChildExpectation as aW, SignerRefusalCode as aX, type SweepConfirmation as aY, type SweepEip712Domain as aZ, type SweepEntry as a_, DEFAULT_CONFIRMATION_TIMEOUT_MS as aa, DEFAULT_NEXT_TOOL_BY_ACTION as ab, DIRECT_SIGN_CONTEXT_VERSION as ac, ENTRY_POINT_V07 as ad, ERC7710_ASSET_TRANSFER_METHOD as ae, HAVEN_CLIENT_HEADER as af, HAVEN_CONNECTOR_CHANNEL as ag, HAVEN_MINIMUM_NODE_VERSION as ah, HYBRID_DELEGATOR_DOMAIN_NAME as ai, HYBRID_DELEGATOR_DOMAIN_VERSION as aj, type HavenAgentAllowanceSummary as ak, type HavenAgentReadiness as al, type HavenAllowance as am, HavenApiError as an, type HavenCatalogMerchant as ao, type HavenListScope as ap, HavenPaymentStateError as aq, HavenSigningError as ar, HavenTimeoutError as as, HavenTypedDataRefusedError as at, HavenUnsupportedSignerVersionError as au, HavenUserOpBindingError as av, HavenZeroSettlementHashError as aw, MAX_TASK_BUDGET_TTL_SECONDS as ax, type MachinePaymentRail as ay, MerchantTimeoutError as az, type PaymentResult as b, selectPaymentOption as b$, type SweepPreparation as b0, type SweepSubmitResult as b1, type SweepTypedData as b2, TRANSFER_WITH_AUTHORIZATION_TYPES as b3, TYPED_DATA_NOT_ALLOWED as b4, type TaskBudgetCloseExpectation as b5, type TaskChildExpectation as b6, type TaskChildTypedData as b7, type UnsupportedNodeVersionMessageOptions as b8, X402AlreadySettledError as b9, connectorUpgradeCommand as bA, createNextStepBuilder as bB, decodeBase64Json as bC, decodeBase64Utf8 as bD, defaultNextToolFor as bE, deriveDelegateAccountAddress as bF, encodeBase64Json as bG, encodeBase64Utf8 as bH, encodePaymentProof as bI, hashDelegation as bJ, havenClientIdentity as bK, isConnectorChannel as bL, isErc7710Option as bM, isPackedUserOperationTypedData as bN, isSupportedNodeVersion as bO, isSweepableChain as bP, isTaskChildTypedData as bQ, normalizePaymentRequired as bR, packedUserOperationHash as bS, parseNextTool as bT, parsePaymentRequired as bU, parsePaymentRequiredResponse as bV, readClientUpdate as bW, renderNextTool as bX, resolveConnectorChannel as bY, resolveTokenFromAddress as bZ, selectErc7710PaymentOption as b_, type X402ExpectedAuth as ba, type X402ExpectedContext as bb, type X402PaymentHeaderContext as bc, X402PaymentHeaderValidationError as bd, type X402PaymentOption as be, type X402RequestSnapshot as bf, type X402SchemeSelection as bg, X402TaskBudgetMismatchError as bh, X402UnexpectedStatusError as bi, X402_LEGACY_PAYMENT_HEADER_NAME as bj, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as bk, X402_PAYMENT_HEADER_NAME as bl, X402_PAYMENT_HEADER_NAMES_SENT as bm, X402_PAYMENT_REQUIRED_HEADER_NAME as bn, X402_PAYMENT_RESPONSE_HEADER_NAME as bo, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as bp, assertBoundDirectPaymentUserOp as bq, assertOwnTaskBudgetCloseUserOp as br, assertOwnTaskChild as bs, assertUserOpTypedDataBinding as bt, buildSweepAuthorizationMessage as bu, buildSweepTypedData as bv, buildX402ExpectedMessage as bw, compareNodeVersions as bx, connectorRerunCommand as by, connectorSpec as bz, type PaymentIntent as c, selectStandardPaymentOption as c0, selectX402SettlementScheme as c1, signerUpdateFallback as c2, sweepUsdcAddress as c3, sweepUsdcDomain as c4, toStandardPaymentRequirements as c5, unsupportedNodeVersionMessage as c6, validateStandardX402PaymentHeader as c7, verifySettlementChild as c8, x402AssetTransferMethod as c9, x402AuthorizationAmount as ca, x402FacilitatorAddresses as cb, x402V2PaymentEnvelope as cc, CAVEAT_ENFORCERS as cd, CAVEAT_TYPEHASH as ce, DELEGATION_MANAGER as cf, DELEGATION_TYPEHASH as cg, DIRECT_PAYMENT_CHAIN_IDS as ch, type DelegationForHashing as ci, EXECUTE_ABI as cj, HYBRID_DELEGATOR_IMPLEMENTATION as ck, MAX_SETTLEMENT_WINDOW_SECONDS as cl, SIMPLE_FACTORY_ADDRESS as cm, type SettlementChildTypedData as cn, assertFundingLegPaysDelegate as co, assertOwnSettlementChild as cp, chainIdForNetwork as cq, isSettlementChildTypedData as cr, type X402AuthorizationOptions as d, type X402Intent as e, type PaymentStatusResult as f, type HavenAgent as g, type HavenAgentSummary as h, type SweepPrepareResponse as i, type SweepAuthorization as j, type SweepSubmitResponse as k, type HavenAllowanceSummary as l, type HavenBalanceCoverage as m, type PostPurchaseAllowanceSummary as n, type HavenCatalogEntry as o, type HavenCatalogSubmission as p, type HavenPaymentReceipt as q, type HavenPaymentReceiptsPage as r, type HavenTaskBudget as s, type SubmitTaskBudgetResult as t, type PaymentResumeState as u, type X402Receipt as v, type X402Quote as w, type X402Erc7710Settlement as x, type X402McpCallContext as y, type SignData as z };
3087
+ export { AgentPaymentPhase as $, type AgentPaymentWarning as A, type ResumeAuthorizedX402Input as B, type CloseTaskBudgetResult as C, type ResumeX402PaymentInput as D, type X402ResumeState as E, type X402McpTransport as F, type X402MerchantCallContext as G, type HavenClientConfig as H, HavenError as I, AGENT_PAYMENT_FAILURE_CODE_VALUES as J, AGENT_PAYMENT_NEXT_ACTION_VALUES as K, AGENT_PAYMENT_PHASE_VALUES as L, AGENT_PAYMENT_RAIL_VALUES as M, type AgentNextStep as N, type OpenTaskBudgetResult as O, type PaymentRequest as P, type AgentPaymentEnumSchema as Q, type RawPaymentParties as R, type SweepResult as S, type TaskBudgetSignContext as T, AgentPaymentFailureCode as U, AgentPaymentFailureCodeDescriptions as V, AgentPaymentFailureCodeSchema as W, type X402PaymentRequired as X, AgentPaymentNextAction as Y, AgentPaymentNextActionDescriptions as Z, AgentPaymentNextActionSchema as _, type HavenClientUpdate as a, type SweepExpectedAuth as a$, AgentPaymentPhaseDescriptions as a0, AgentPaymentPhaseSchema as a1, AgentPaymentRail as a2, AgentPaymentRailDescriptions as a3, AgentPaymentRailSchema as a4, type AgentPaymentSummary as a5, AgentPaymentWarningCode as a6, type AgentPurchaseSummary as a7, CONNECTOR_PACKAGE_NAME as a8, type CatalogSubmissionAccepted as a9, NEXT_TOOL_SERVER_NAMES as aA, NEXT_TOOL_SERVER_ROLES as aB, type NextStep as aC, type NextStepArguments as aD, type NextStepHandoff as aE, type NextStepInput as aF, type NextStepTarget as aG, type NextStepTargets as aH, type NextToolServerRole as aI, PACKED_USER_OPERATION_FIELDS as aJ, type PaymentFee as aK, type PaymentNextAction as aL, type PaymentPhase as aM, type PaymentStatus as aN, ROOT_AUTHORITY as aO, SDK_CLIENT_IDENTITY as aP, SDK_VERSION as aQ, SIGNER_UPDATE_FALLBACK as aR, SWEEP_BASE_CHAIN_ID as aS, SWEEP_BASE_SEPOLIA_CHAIN_ID as aT, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as aU, SWEEP_BASE_USDC_ADDRESS as aV, type SettlementChildExpectation as aW, SignerRefusalCode as aX, type SweepConfirmation as aY, type SweepEip712Domain as aZ, type SweepEntry as a_, DEFAULT_CONFIRMATION_TIMEOUT_MS as aa, DEFAULT_NEXT_TOOL_BY_ACTION as ab, DIRECT_SIGN_CONTEXT_VERSION as ac, ENTRY_POINT_V07 as ad, ERC7710_ASSET_TRANSFER_METHOD as ae, HAVEN_CLIENT_HEADER as af, HAVEN_CONNECTOR_CHANNEL as ag, HAVEN_MINIMUM_NODE_VERSION as ah, HYBRID_DELEGATOR_DOMAIN_NAME as ai, HYBRID_DELEGATOR_DOMAIN_VERSION as aj, type HavenAgentAllowanceSummary as ak, type HavenAgentReadiness as al, type HavenAllowance as am, HavenApiError as an, type HavenCatalogMerchant as ao, type HavenListScope as ap, HavenPaymentStateError as aq, HavenSigningError as ar, HavenTimeoutError as as, HavenTypedDataRefusedError as at, HavenUnsupportedSignerVersionError as au, HavenUserOpBindingError as av, HavenZeroSettlementHashError as aw, MAX_TASK_BUDGET_TTL_SECONDS as ax, type MachinePaymentRail as ay, MerchantTimeoutError as az, type PaymentResult as b, resolveTokenFromAddress as b$, type SweepPreparation as b0, type SweepSubmitResult as b1, type SweepTypedData as b2, TRANSFER_WITH_AUTHORIZATION_TYPES as b3, TYPED_DATA_NOT_ALLOWED as b4, type TaskBudgetCloseExpectation as b5, type TaskChildExpectation as b6, type TaskChildTypedData as b7, type UnsupportedNodeVersionMessageOptions as b8, X402AlreadySettledError as b9, connectorSpec as bA, connectorUpgradeCommand as bB, createNextStepBuilder as bC, decodeBase64Json as bD, decodeBase64Utf8 as bE, defaultNextToolFor as bF, deriveDelegateAccountAddress as bG, encodeBase64Json as bH, encodeBase64Utf8 as bI, encodePaymentProof as bJ, hashDelegation as bK, havenClientIdentity as bL, isConnectorChannel as bM, isErc7710Option as bN, isPackedUserOperationTypedData as bO, isSupportedNodeVersion as bP, isSweepableChain as bQ, isTaskChildTypedData as bR, normalizePaymentRequired as bS, packedUserOperationHash as bT, parseNextTool as bU, parsePaymentRequired as bV, parsePaymentRequiredResponse as bW, readClientUpdate as bX, renderNextTool as bY, resolveConnectorChannel as bZ, resolveTokenBySymbol as b_, X402Erc7710AlreadySettledError as ba, type X402ExpectedAuth as bb, type X402ExpectedContext as bc, type X402PaymentHeaderContext as bd, X402PaymentHeaderValidationError as be, type X402PaymentOption as bf, type X402RequestSnapshot as bg, type X402SchemeSelection as bh, X402TaskBudgetMismatchError as bi, X402UnexpectedStatusError as bj, X402_LEGACY_PAYMENT_HEADER_NAME as bk, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as bl, X402_PAYMENT_HEADER_NAME as bm, X402_PAYMENT_HEADER_NAMES_SENT as bn, X402_PAYMENT_REQUIRED_HEADER_NAME as bo, X402_PAYMENT_RESPONSE_HEADER_NAME as bp, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as bq, assertBoundDirectPaymentUserOp as br, assertOwnTaskBudgetCloseUserOp as bs, assertOwnTaskChild as bt, assertUserOpTypedDataBinding as bu, buildSweepAuthorizationMessage as bv, buildSweepTypedData as bw, buildX402ExpectedMessage as bx, compareNodeVersions as by, connectorRerunCommand as bz, type PaymentIntent as c, selectErc7710PaymentOption as c0, selectPaymentOption as c1, selectStandardPaymentOption as c2, selectX402SettlementScheme as c3, signerUpdateFallback as c4, sweepUsdcAddress as c5, sweepUsdcDomain as c6, toStandardPaymentRequirements as c7, unsupportedNodeVersionMessage as c8, validateStandardX402PaymentHeader as c9, verifySettlementChild as ca, x402AssetTransferMethod as cb, x402AuthorizationAmount as cc, x402FacilitatorAddresses as cd, x402V2PaymentEnvelope as ce, CAVEAT_ENFORCERS as cf, CAVEAT_TYPEHASH as cg, DELEGATION_MANAGER as ch, DELEGATION_TYPEHASH as ci, DIRECT_PAYMENT_CHAIN_IDS as cj, type DelegationForHashing as ck, EXECUTE_ABI as cl, HYBRID_DELEGATOR_IMPLEMENTATION as cm, MAX_SETTLEMENT_WINDOW_SECONDS as cn, SIMPLE_FACTORY_ADDRESS as co, type SettlementChildTypedData as cp, assertFundingLegPaysDelegate as cq, assertOwnSettlementChild as cr, chainIdForNetwork as cs, isSettlementChildTypedData as ct, type X402AuthorizationOptions as d, type X402Intent as e, type PaymentStatusResult as f, type HavenAgent as g, type HavenAgentSummary as h, type SweepPrepareResponse as i, type SweepAuthorization as j, type SweepSubmitResponse as k, type HavenAllowanceSummary as l, type HavenBalanceCoverage as m, type PostPurchaseAllowanceSummary as n, type HavenCatalogEntry as o, type HavenCatalogSubmission as p, type HavenPaymentReceipt as q, type HavenPaymentReceiptsPage as r, type HavenTaskBudget as s, type SubmitTaskBudgetResult as t, type PaymentResumeState as u, type X402Receipt as v, type X402Quote as w, type X402Erc7710Settlement as x, type X402McpCallContext as y, type SignData as z };
@@ -697,7 +697,7 @@ interface HavenAgentAllowanceSummary {
697
697
  remainingAtomic: string;
698
698
  /** Human-readable remaining, e.g. "4.96 USDC". */
699
699
  remainingDisplay: string;
700
- /** Configured allowance amount (atomic) the owner granted. */
700
+ /** Configured allowance amount in whole token units (human decimal, e.g. "1.00" — NOT atomic; on-chain.amount is the atomic figure). */
701
701
  configuredAmount: string;
702
702
  resetPeriodMin: number;
703
703
  isResetPending: boolean;
@@ -1609,6 +1609,32 @@ declare class MerchantTimeoutError extends HavenApiError {
1609
1609
  readonly merchantErrorCode: "merchant_timeout";
1610
1610
  constructor(message: string);
1611
1611
  }
1612
+ /**
1613
+ * #3417: an erc7710 `POST /x402` authorize replayed a key whose payment to THIS
1614
+ * merchant for THIS resource has already settled. The backend returns
1615
+ * `200 { status: 'confirmed', tx_hash, to, resource_url }` and, correctly, no
1616
+ * `sign_data`, because nothing is left to sign
1617
+ * (`packages/backend/src/modules/x402/replay.ts`). Before this class the
1618
+ * erc7710 path read that answer as a scheme mismatch and threw a 500, which
1619
+ * hosted callers relayed as "transient, retry". Typed so a caller can report
1620
+ * the original settlement instead of retrying, and never signs anything.
1621
+ *
1622
+ * Only thrown when the confirmed row pays the merchant this request names, for
1623
+ * the resource it asked for. The backend's replay lookup is keyed on the
1624
+ * idempotency key alone, so a key reused for another payee or resource — or
1625
+ * first spent on an EIP-3009 funding leg, whose confirmed `tx_hash` proves only
1626
+ * that the delegate was funded — is refused as a 409 collision instead of read
1627
+ * as this settlement. Amount and the MCP tool call are not compared: on an MCP
1628
+ * merchant the resource is its endpoint, so a key reused for another tool
1629
+ * there is answered as that merchant's earlier payment. A `HavenError`, not a `HavenApiError`: nothing failed upstream.
1630
+ */
1631
+ declare class X402Erc7710AlreadySettledError extends HavenError {
1632
+ readonly paymentId: string;
1633
+ readonly txHash: string;
1634
+ readonly body?: unknown | undefined;
1635
+ readonly x402ErrorCode: "payment_already_settled";
1636
+ constructor(paymentId: string, txHash: string, body?: unknown | undefined);
1637
+ }
1612
1638
  declare class X402UnexpectedStatusError extends HavenApiError {
1613
1639
  readonly x402ErrorCode: "unexpected_non_402_status";
1614
1640
  /**
@@ -1969,7 +1995,7 @@ declare function buildSweepAuthorizationMessage(auth: SweepAuthorization): strin
1969
1995
  * This SDK's own version. Owned by `scripts/release-bump.mjs`, which rewrites
1970
1996
  * it with the package version on every release — never hand-edit it.
1971
1997
  */
1972
- declare const SDK_VERSION = "0.0.0-dev.202609281335.705f436";
1998
+ declare const SDK_VERSION = "0.0.0-dev.202609281945.3f83e0e";
1973
1999
  /** The request header every published Haven client sends. */
1974
2000
  declare const HAVEN_CLIENT_HEADER = "X-Haven-Client";
1975
2001
  /** `<package>/<version>` — the value of {@link HAVEN_CLIENT_HEADER}. */
@@ -2562,6 +2588,19 @@ declare function resolveTokenFromAddress(address: string, network?: string): {
2562
2588
  symbol: string;
2563
2589
  decimals: number;
2564
2590
  } | null;
2591
+ /**
2592
+ * #3410: token decimals from a SYMBOL + CHAIN — the same registry
2593
+ * `resolveTokenFromAddress` reads, keyed the other way. The address-based
2594
+ * resolver needs the token's contract address, which the consent seed path
2595
+ * (setup-time credential files) does not carry; the symbol and chain it does
2596
+ * carry. Null when the symbol is not registered on that chain (unknown or
2597
+ * custom tokens) — callers must fall back to an explicit atomic label rather
2598
+ * than reading an atomic amount as whole tokens.
2599
+ */
2600
+ declare function resolveTokenBySymbol(chainId: number, symbol: string): {
2601
+ symbol: string;
2602
+ decimals: number;
2603
+ } | null;
2565
2604
 
2566
2605
  /**
2567
2606
  * #3271: the integrity check every client runs before signing a direct
@@ -3045,4 +3084,4 @@ declare function encodeBase64Json(value: unknown): string;
3045
3084
  */
3046
3085
  declare function decodeBase64Json<T>(value: string, label?: string): T;
3047
3086
 
3048
- export { AgentPaymentPhase as $, type AgentPaymentWarning as A, type ResumeAuthorizedX402Input as B, type CloseTaskBudgetResult as C, type ResumeX402PaymentInput as D, type X402ResumeState as E, type X402McpTransport as F, type X402MerchantCallContext as G, type HavenClientConfig as H, HavenError as I, AGENT_PAYMENT_FAILURE_CODE_VALUES as J, AGENT_PAYMENT_NEXT_ACTION_VALUES as K, AGENT_PAYMENT_PHASE_VALUES as L, AGENT_PAYMENT_RAIL_VALUES as M, type AgentNextStep as N, type OpenTaskBudgetResult as O, type PaymentRequest as P, type AgentPaymentEnumSchema as Q, type RawPaymentParties as R, type SweepResult as S, type TaskBudgetSignContext as T, AgentPaymentFailureCode as U, AgentPaymentFailureCodeDescriptions as V, AgentPaymentFailureCodeSchema as W, type X402PaymentRequired as X, AgentPaymentNextAction as Y, AgentPaymentNextActionDescriptions as Z, AgentPaymentNextActionSchema as _, type HavenClientUpdate as a, type SweepExpectedAuth as a$, AgentPaymentPhaseDescriptions as a0, AgentPaymentPhaseSchema as a1, AgentPaymentRail as a2, AgentPaymentRailDescriptions as a3, AgentPaymentRailSchema as a4, type AgentPaymentSummary as a5, AgentPaymentWarningCode as a6, type AgentPurchaseSummary as a7, CONNECTOR_PACKAGE_NAME as a8, type CatalogSubmissionAccepted as a9, NEXT_TOOL_SERVER_NAMES as aA, NEXT_TOOL_SERVER_ROLES as aB, type NextStep as aC, type NextStepArguments as aD, type NextStepHandoff as aE, type NextStepInput as aF, type NextStepTarget as aG, type NextStepTargets as aH, type NextToolServerRole as aI, PACKED_USER_OPERATION_FIELDS as aJ, type PaymentFee as aK, type PaymentNextAction as aL, type PaymentPhase as aM, type PaymentStatus as aN, ROOT_AUTHORITY as aO, SDK_CLIENT_IDENTITY as aP, SDK_VERSION as aQ, SIGNER_UPDATE_FALLBACK as aR, SWEEP_BASE_CHAIN_ID as aS, SWEEP_BASE_SEPOLIA_CHAIN_ID as aT, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as aU, SWEEP_BASE_USDC_ADDRESS as aV, type SettlementChildExpectation as aW, SignerRefusalCode as aX, type SweepConfirmation as aY, type SweepEip712Domain as aZ, type SweepEntry as a_, DEFAULT_CONFIRMATION_TIMEOUT_MS as aa, DEFAULT_NEXT_TOOL_BY_ACTION as ab, DIRECT_SIGN_CONTEXT_VERSION as ac, ENTRY_POINT_V07 as ad, ERC7710_ASSET_TRANSFER_METHOD as ae, HAVEN_CLIENT_HEADER as af, HAVEN_CONNECTOR_CHANNEL as ag, HAVEN_MINIMUM_NODE_VERSION as ah, HYBRID_DELEGATOR_DOMAIN_NAME as ai, HYBRID_DELEGATOR_DOMAIN_VERSION as aj, type HavenAgentAllowanceSummary as ak, type HavenAgentReadiness as al, type HavenAllowance as am, HavenApiError as an, type HavenCatalogMerchant as ao, type HavenListScope as ap, HavenPaymentStateError as aq, HavenSigningError as ar, HavenTimeoutError as as, HavenTypedDataRefusedError as at, HavenUnsupportedSignerVersionError as au, HavenUserOpBindingError as av, HavenZeroSettlementHashError as aw, MAX_TASK_BUDGET_TTL_SECONDS as ax, type MachinePaymentRail as ay, MerchantTimeoutError as az, type PaymentResult as b, selectPaymentOption as b$, type SweepPreparation as b0, type SweepSubmitResult as b1, type SweepTypedData as b2, TRANSFER_WITH_AUTHORIZATION_TYPES as b3, TYPED_DATA_NOT_ALLOWED as b4, type TaskBudgetCloseExpectation as b5, type TaskChildExpectation as b6, type TaskChildTypedData as b7, type UnsupportedNodeVersionMessageOptions as b8, X402AlreadySettledError as b9, connectorUpgradeCommand as bA, createNextStepBuilder as bB, decodeBase64Json as bC, decodeBase64Utf8 as bD, defaultNextToolFor as bE, deriveDelegateAccountAddress as bF, encodeBase64Json as bG, encodeBase64Utf8 as bH, encodePaymentProof as bI, hashDelegation as bJ, havenClientIdentity as bK, isConnectorChannel as bL, isErc7710Option as bM, isPackedUserOperationTypedData as bN, isSupportedNodeVersion as bO, isSweepableChain as bP, isTaskChildTypedData as bQ, normalizePaymentRequired as bR, packedUserOperationHash as bS, parseNextTool as bT, parsePaymentRequired as bU, parsePaymentRequiredResponse as bV, readClientUpdate as bW, renderNextTool as bX, resolveConnectorChannel as bY, resolveTokenFromAddress as bZ, selectErc7710PaymentOption as b_, type X402ExpectedAuth as ba, type X402ExpectedContext as bb, type X402PaymentHeaderContext as bc, X402PaymentHeaderValidationError as bd, type X402PaymentOption as be, type X402RequestSnapshot as bf, type X402SchemeSelection as bg, X402TaskBudgetMismatchError as bh, X402UnexpectedStatusError as bi, X402_LEGACY_PAYMENT_HEADER_NAME as bj, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as bk, X402_PAYMENT_HEADER_NAME as bl, X402_PAYMENT_HEADER_NAMES_SENT as bm, X402_PAYMENT_REQUIRED_HEADER_NAME as bn, X402_PAYMENT_RESPONSE_HEADER_NAME as bo, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as bp, assertBoundDirectPaymentUserOp as bq, assertOwnTaskBudgetCloseUserOp as br, assertOwnTaskChild as bs, assertUserOpTypedDataBinding as bt, buildSweepAuthorizationMessage as bu, buildSweepTypedData as bv, buildX402ExpectedMessage as bw, compareNodeVersions as bx, connectorRerunCommand as by, connectorSpec as bz, type PaymentIntent as c, selectStandardPaymentOption as c0, selectX402SettlementScheme as c1, signerUpdateFallback as c2, sweepUsdcAddress as c3, sweepUsdcDomain as c4, toStandardPaymentRequirements as c5, unsupportedNodeVersionMessage as c6, validateStandardX402PaymentHeader as c7, verifySettlementChild as c8, x402AssetTransferMethod as c9, x402AuthorizationAmount as ca, x402FacilitatorAddresses as cb, x402V2PaymentEnvelope as cc, CAVEAT_ENFORCERS as cd, CAVEAT_TYPEHASH as ce, DELEGATION_MANAGER as cf, DELEGATION_TYPEHASH as cg, DIRECT_PAYMENT_CHAIN_IDS as ch, type DelegationForHashing as ci, EXECUTE_ABI as cj, HYBRID_DELEGATOR_IMPLEMENTATION as ck, MAX_SETTLEMENT_WINDOW_SECONDS as cl, SIMPLE_FACTORY_ADDRESS as cm, type SettlementChildTypedData as cn, assertFundingLegPaysDelegate as co, assertOwnSettlementChild as cp, chainIdForNetwork as cq, isSettlementChildTypedData as cr, type X402AuthorizationOptions as d, type X402Intent as e, type PaymentStatusResult as f, type HavenAgent as g, type HavenAgentSummary as h, type SweepPrepareResponse as i, type SweepAuthorization as j, type SweepSubmitResponse as k, type HavenAllowanceSummary as l, type HavenBalanceCoverage as m, type PostPurchaseAllowanceSummary as n, type HavenCatalogEntry as o, type HavenCatalogSubmission as p, type HavenPaymentReceipt as q, type HavenPaymentReceiptsPage as r, type HavenTaskBudget as s, type SubmitTaskBudgetResult as t, type PaymentResumeState as u, type X402Receipt as v, type X402Quote as w, type X402Erc7710Settlement as x, type X402McpCallContext as y, type SignData as z };
3087
+ export { AgentPaymentPhase as $, type AgentPaymentWarning as A, type ResumeAuthorizedX402Input as B, type CloseTaskBudgetResult as C, type ResumeX402PaymentInput as D, type X402ResumeState as E, type X402McpTransport as F, type X402MerchantCallContext as G, type HavenClientConfig as H, HavenError as I, AGENT_PAYMENT_FAILURE_CODE_VALUES as J, AGENT_PAYMENT_NEXT_ACTION_VALUES as K, AGENT_PAYMENT_PHASE_VALUES as L, AGENT_PAYMENT_RAIL_VALUES as M, type AgentNextStep as N, type OpenTaskBudgetResult as O, type PaymentRequest as P, type AgentPaymentEnumSchema as Q, type RawPaymentParties as R, type SweepResult as S, type TaskBudgetSignContext as T, AgentPaymentFailureCode as U, AgentPaymentFailureCodeDescriptions as V, AgentPaymentFailureCodeSchema as W, type X402PaymentRequired as X, AgentPaymentNextAction as Y, AgentPaymentNextActionDescriptions as Z, AgentPaymentNextActionSchema as _, type HavenClientUpdate as a, type SweepExpectedAuth as a$, AgentPaymentPhaseDescriptions as a0, AgentPaymentPhaseSchema as a1, AgentPaymentRail as a2, AgentPaymentRailDescriptions as a3, AgentPaymentRailSchema as a4, type AgentPaymentSummary as a5, AgentPaymentWarningCode as a6, type AgentPurchaseSummary as a7, CONNECTOR_PACKAGE_NAME as a8, type CatalogSubmissionAccepted as a9, NEXT_TOOL_SERVER_NAMES as aA, NEXT_TOOL_SERVER_ROLES as aB, type NextStep as aC, type NextStepArguments as aD, type NextStepHandoff as aE, type NextStepInput as aF, type NextStepTarget as aG, type NextStepTargets as aH, type NextToolServerRole as aI, PACKED_USER_OPERATION_FIELDS as aJ, type PaymentFee as aK, type PaymentNextAction as aL, type PaymentPhase as aM, type PaymentStatus as aN, ROOT_AUTHORITY as aO, SDK_CLIENT_IDENTITY as aP, SDK_VERSION as aQ, SIGNER_UPDATE_FALLBACK as aR, SWEEP_BASE_CHAIN_ID as aS, SWEEP_BASE_SEPOLIA_CHAIN_ID as aT, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as aU, SWEEP_BASE_USDC_ADDRESS as aV, type SettlementChildExpectation as aW, SignerRefusalCode as aX, type SweepConfirmation as aY, type SweepEip712Domain as aZ, type SweepEntry as a_, DEFAULT_CONFIRMATION_TIMEOUT_MS as aa, DEFAULT_NEXT_TOOL_BY_ACTION as ab, DIRECT_SIGN_CONTEXT_VERSION as ac, ENTRY_POINT_V07 as ad, ERC7710_ASSET_TRANSFER_METHOD as ae, HAVEN_CLIENT_HEADER as af, HAVEN_CONNECTOR_CHANNEL as ag, HAVEN_MINIMUM_NODE_VERSION as ah, HYBRID_DELEGATOR_DOMAIN_NAME as ai, HYBRID_DELEGATOR_DOMAIN_VERSION as aj, type HavenAgentAllowanceSummary as ak, type HavenAgentReadiness as al, type HavenAllowance as am, HavenApiError as an, type HavenCatalogMerchant as ao, type HavenListScope as ap, HavenPaymentStateError as aq, HavenSigningError as ar, HavenTimeoutError as as, HavenTypedDataRefusedError as at, HavenUnsupportedSignerVersionError as au, HavenUserOpBindingError as av, HavenZeroSettlementHashError as aw, MAX_TASK_BUDGET_TTL_SECONDS as ax, type MachinePaymentRail as ay, MerchantTimeoutError as az, type PaymentResult as b, resolveTokenFromAddress as b$, type SweepPreparation as b0, type SweepSubmitResult as b1, type SweepTypedData as b2, TRANSFER_WITH_AUTHORIZATION_TYPES as b3, TYPED_DATA_NOT_ALLOWED as b4, type TaskBudgetCloseExpectation as b5, type TaskChildExpectation as b6, type TaskChildTypedData as b7, type UnsupportedNodeVersionMessageOptions as b8, X402AlreadySettledError as b9, connectorSpec as bA, connectorUpgradeCommand as bB, createNextStepBuilder as bC, decodeBase64Json as bD, decodeBase64Utf8 as bE, defaultNextToolFor as bF, deriveDelegateAccountAddress as bG, encodeBase64Json as bH, encodeBase64Utf8 as bI, encodePaymentProof as bJ, hashDelegation as bK, havenClientIdentity as bL, isConnectorChannel as bM, isErc7710Option as bN, isPackedUserOperationTypedData as bO, isSupportedNodeVersion as bP, isSweepableChain as bQ, isTaskChildTypedData as bR, normalizePaymentRequired as bS, packedUserOperationHash as bT, parseNextTool as bU, parsePaymentRequired as bV, parsePaymentRequiredResponse as bW, readClientUpdate as bX, renderNextTool as bY, resolveConnectorChannel as bZ, resolveTokenBySymbol as b_, X402Erc7710AlreadySettledError as ba, type X402ExpectedAuth as bb, type X402ExpectedContext as bc, type X402PaymentHeaderContext as bd, X402PaymentHeaderValidationError as be, type X402PaymentOption as bf, type X402RequestSnapshot as bg, type X402SchemeSelection as bh, X402TaskBudgetMismatchError as bi, X402UnexpectedStatusError as bj, X402_LEGACY_PAYMENT_HEADER_NAME as bk, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as bl, X402_PAYMENT_HEADER_NAME as bm, X402_PAYMENT_HEADER_NAMES_SENT as bn, X402_PAYMENT_REQUIRED_HEADER_NAME as bo, X402_PAYMENT_RESPONSE_HEADER_NAME as bp, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as bq, assertBoundDirectPaymentUserOp as br, assertOwnTaskBudgetCloseUserOp as bs, assertOwnTaskChild as bt, assertUserOpTypedDataBinding as bu, buildSweepAuthorizationMessage as bv, buildSweepTypedData as bw, buildX402ExpectedMessage as bx, compareNodeVersions as by, connectorRerunCommand as bz, type PaymentIntent as c, selectErc7710PaymentOption as c0, selectPaymentOption as c1, selectStandardPaymentOption as c2, selectX402SettlementScheme as c3, signerUpdateFallback as c4, sweepUsdcAddress as c5, sweepUsdcDomain as c6, toStandardPaymentRequirements as c7, unsupportedNodeVersionMessage as c8, validateStandardX402PaymentHeader as c9, verifySettlementChild as ca, x402AssetTransferMethod as cb, x402AuthorizationAmount as cc, x402FacilitatorAddresses as cd, x402V2PaymentEnvelope as ce, CAVEAT_ENFORCERS as cf, CAVEAT_TYPEHASH as cg, DELEGATION_MANAGER as ch, DELEGATION_TYPEHASH as ci, DIRECT_PAYMENT_CHAIN_IDS as cj, type DelegationForHashing as ck, EXECUTE_ABI as cl, HYBRID_DELEGATOR_IMPLEMENTATION as cm, MAX_SETTLEMENT_WINDOW_SECONDS as cn, SIMPLE_FACTORY_ADDRESS as co, type SettlementChildTypedData as cp, assertFundingLegPaysDelegate as cq, assertOwnSettlementChild as cr, chainIdForNetwork as cs, isSettlementChildTypedData as ct, type X402AuthorizationOptions as d, type X402Intent as e, type PaymentStatusResult as f, type HavenAgent as g, type HavenAgentSummary as h, type SweepPrepareResponse as i, type SweepAuthorization as j, type SweepSubmitResponse as k, type HavenAllowanceSummary as l, type HavenBalanceCoverage as m, type PostPurchaseAllowanceSummary as n, type HavenCatalogEntry as o, type HavenCatalogSubmission as p, type HavenPaymentReceipt as q, type HavenPaymentReceiptsPage as r, type HavenTaskBudget as s, type SubmitTaskBudgetResult as t, type PaymentResumeState as u, type X402Receipt as v, type X402Quote as w, type X402Erc7710Settlement as x, type X402McpCallContext as y, type SignData as z };
@@ -359,6 +359,24 @@ var MerchantTimeoutError = class extends HavenApiError {
359
359
  this.name = "MerchantTimeoutError";
360
360
  }
361
361
  };
362
+ var X402Erc7710AlreadySettledError = class extends HavenError {
363
+ constructor(paymentId, txHash, body) {
364
+ super(
365
+ `Payment ${paymentId} already settled on-chain (tx ${txHash}); this idempotency key is spent. Nothing was signed and nothing new was charged.`,
366
+ "PAYMENT_ALREADY_SETTLED",
367
+ void 0,
368
+ paymentId
369
+ );
370
+ this.paymentId = paymentId;
371
+ this.txHash = txHash;
372
+ this.body = body;
373
+ this.name = "X402Erc7710AlreadySettledError";
374
+ }
375
+ paymentId;
376
+ txHash;
377
+ body;
378
+ x402ErrorCode = "payment_already_settled";
379
+ };
362
380
  var X402UnexpectedStatusError = class extends HavenApiError {
363
381
  x402ErrorCode = "unexpected_non_402_status";
364
382
  /**
@@ -998,6 +1016,7 @@ exports.SIMPLE_FACTORY_ADDRESS = SIMPLE_FACTORY_ADDRESS;
998
1016
  exports.SINGLE_DEFAULT_MODE = SINGLE_DEFAULT_MODE;
999
1017
  exports.SignerRefusalCode = SignerRefusalCode;
1000
1018
  exports.X402AlreadySettledError = X402AlreadySettledError;
1019
+ exports.X402Erc7710AlreadySettledError = X402Erc7710AlreadySettledError;
1001
1020
  exports.X402TaskBudgetMismatchError = X402TaskBudgetMismatchError;
1002
1021
  exports.X402UnexpectedStatusError = X402UnexpectedStatusError;
1003
1022
  exports.assertRedeemsOwnBudgetDelegation = assertRedeemsOwnBudgetDelegation;
@@ -1014,5 +1033,5 @@ exports.packedUserOperationHash = packedUserOperationHash;
1014
1033
  exports.resolveConnectorChannel = resolveConnectorChannel;
1015
1034
  exports.signerUpdateFallback = signerUpdateFallback;
1016
1035
  exports.verifySettlementChild = verifySettlementChild;
1017
- //# sourceMappingURL=chunk-DIZIO4QD.cjs.map
1018
- //# sourceMappingURL=chunk-DIZIO4QD.cjs.map
1036
+ //# sourceMappingURL=chunk-FXPB3NEJ.cjs.map
1037
+ //# sourceMappingURL=chunk-FXPB3NEJ.cjs.map