@haven_ai/sdk 0.1.13-alpha.0 → 0.1.15-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -109,6 +109,7 @@ interface X402PaymentRequired {
109
109
  };
110
110
  accepts: X402PaymentOption[];
111
111
  error?: string;
112
+ extensions?: Record<string, unknown>;
112
113
  }
113
114
  /** A single payment option from x402 PaymentRequired. */
114
115
  interface X402PaymentOption {
@@ -173,6 +174,8 @@ interface X402AuthorizationOptions {
173
174
  interface X402Intent {
174
175
  /** Haven payment id for the funding transfer. */
175
176
  paymentId: string;
177
+ /** Stable key used to create or refresh this x402 funding intent. */
178
+ idempotencyKey: string;
176
179
  status: 'pending_signature';
177
180
  /** ISO 8601 expiry of the funding intent, if returned. */
178
181
  expiresAt?: string;
@@ -203,6 +206,8 @@ interface X402ExpectedContext {
203
206
  amount: string;
204
207
  asset: string;
205
208
  network: string;
209
+ /** Optional ISO expiry for the funding/quote window. When present, it is bound into the Haven-authenticated context. */
210
+ expiresAt?: string;
206
211
  }
207
212
  interface X402ExpectedAuth {
208
213
  version: 1;
@@ -217,6 +222,10 @@ interface X402RequestSnapshot {
217
222
  headers: [string, string][];
218
223
  body?: string;
219
224
  }
225
+ interface X402McpTransport {
226
+ handshakeRequired: boolean;
227
+ source: 'path' | 'bazaar';
228
+ }
220
229
  /** Quote parsed from an HTTP 402 response without creating a Haven payment. */
221
230
  interface X402Quote {
222
231
  rail: 'x402';
@@ -224,6 +233,7 @@ interface X402Quote {
224
233
  paymentRequired: X402PaymentRequired;
225
234
  accepted: X402PaymentOption;
226
235
  request: X402RequestSnapshot;
236
+ mcpTransport?: X402McpTransport;
227
237
  resourceUrl: string;
228
238
  description: string | null;
229
239
  mimeType: string | null;
@@ -520,6 +530,11 @@ declare const AgentPaymentNextAction: {
520
530
  readonly StopAndTellUser: "stop_and_tell_user";
521
531
  /** Ask again only if the user still wants the payment after expiry. */
522
532
  readonly RequestAgainIfUserStillWantsIt: "request_again_if_user_still_wants_it";
533
+ /**
534
+ * The x402 funding/quote window expired. Re-quote the same logical merchant
535
+ * operation with the same idempotency key to stay double-charge-safe.
536
+ */
537
+ readonly PaymentWindowExpired: "payment_window_expired";
523
538
  /**
524
539
  * Stop and tell the user that the originating Safe needs to be funded or
525
540
  * the agent's per-token allowance needs to be raised before the payment
@@ -534,6 +549,15 @@ declare const AgentPaymentNextAction: {
534
549
  readonly SweepStrandedFunds: "sweep_stranded_funds";
535
550
  };
536
551
  type AgentPaymentNextAction = (typeof AgentPaymentNextAction)[keyof typeof AgentPaymentNextAction];
552
+ declare const AgentPaymentFailureCode: {
553
+ /** A merchant-authoritative x402 price exceeds the caller's pre-funding max_amount cap. */
554
+ readonly PriceExceedsMax: "PRICE_EXCEEDS_MAX";
555
+ /** The x402 funding/quote window expired before the signer or hosted settle step could finish. */
556
+ readonly PaymentWindowExpired: "PAYMENT_WINDOW_EXPIRED";
557
+ /** The Haven funding leg succeeded, but the merchant rejected the paid retry. */
558
+ readonly MerchantRejectedAfterFunding: "MERCHANT_REJECTED_AFTER_FUNDING";
559
+ };
560
+ type AgentPaymentFailureCode = (typeof AgentPaymentFailureCode)[keyof typeof AgentPaymentFailureCode];
537
561
  /**
538
562
  * Stable rail identifier carried on Haven agent payment responses and resume
539
563
  * state.
@@ -572,13 +596,16 @@ type AgentPaymentRail = (typeof AgentPaymentRail)[keyof typeof AgentPaymentRail]
572
596
  type PaymentPhase = AgentPaymentPhase;
573
597
  type PaymentNextAction = AgentPaymentNextAction;
574
598
  declare const AGENT_PAYMENT_PHASE_VALUES: ("rejected" | "expired" | "failed" | "agent_signature_required" | "payment_submitted" | "payment_confirmed" | "user_approval_required" | "user_execution_required" | "waiting_for_additional_approvals" | "funding_sent" | "insufficient_funds" | "funded_but_unsettled")[];
575
- declare const AGENT_PAYMENT_NEXT_ACTION_VALUES: ("sign_and_submit_payment" | "check_status_later" | "none" | "wait_for_user_approval" | "wait_for_user_to_complete_payment" | "retry_original_x402_request" | "stop_and_tell_user" | "request_again_if_user_still_wants_it" | "fund_safe_or_raise_allowance" | "sweep_stranded_funds")[];
599
+ declare const AGENT_PAYMENT_NEXT_ACTION_VALUES: ("sign_and_submit_payment" | "check_status_later" | "none" | "wait_for_user_approval" | "wait_for_user_to_complete_payment" | "retry_original_x402_request" | "stop_and_tell_user" | "request_again_if_user_still_wants_it" | "payment_window_expired" | "fund_safe_or_raise_allowance" | "sweep_stranded_funds")[];
600
+ declare const AGENT_PAYMENT_FAILURE_CODE_VALUES: ("PRICE_EXCEEDS_MAX" | "PAYMENT_WINDOW_EXPIRED" | "MERCHANT_REJECTED_AFTER_FUNDING")[];
576
601
  declare const AGENT_PAYMENT_RAIL_VALUES: ("x402" | "mpp" | "mpp_demo" | "mpp_crypto" | "stripe_deposit" | "spt" | "direct")[];
577
602
  declare const AgentPaymentPhaseDescriptions: Record<AgentPaymentPhase, string>;
578
603
  declare const AgentPaymentNextActionDescriptions: Record<AgentPaymentNextAction, string>;
604
+ declare const AgentPaymentFailureCodeDescriptions: Record<AgentPaymentFailureCode, string>;
579
605
  declare const AgentPaymentRailDescriptions: Record<AgentPaymentRail, string>;
580
606
  declare const AgentPaymentPhaseSchema: AgentPaymentEnumSchema;
581
607
  declare const AgentPaymentNextActionSchema: AgentPaymentEnumSchema;
608
+ declare const AgentPaymentFailureCodeSchema: AgentPaymentEnumSchema;
582
609
  declare const AgentPaymentRailSchema: AgentPaymentEnumSchema;
583
610
  interface PaymentStatusResult {
584
611
  paymentId: string;
@@ -671,6 +698,166 @@ declare class HavenTimeoutError extends HavenError {
671
698
  constructor(paymentId: string);
672
699
  }
673
700
 
701
+ /**
702
+ * Gasless delegate-sweep primitives — the single source of truth shared by the
703
+ * edge signer (which signs) and the Haven backend (which relays).
704
+ *
705
+ * A stranded delegate EOA holds USDC but no ETH, so a raw ERC-20 transfer can't
706
+ * pay for its own gas. Instead the delegate signs an *off-chain* EIP-3009
707
+ * `TransferWithAuthorization` and the Haven relayer submits it on-chain and pays
708
+ * gas. The relayer is only a gas payer: it holds no allowance and is never a
709
+ * spender, so a relayer compromise cannot move user funds.
710
+ *
711
+ * Framework-neutral on purpose: `buildSweepTypedData` returns a plain
712
+ * `{ domain, types, primaryType, message }` that both viem
713
+ * (`signTypedData`/`recoverTypedDataAddress`) and ethers v6
714
+ * (`signTypedData`/`verifyTypedData`) accept, so the signer (viem) and backend
715
+ * (ethers) stay in lockstep without sharing a crypto library.
716
+ */
717
+ /** Base mainnet. The only chain Haven sweeps today. */
718
+ declare const SWEEP_BASE_CHAIN_ID = 8453;
719
+ /** Canonical Circle USDC on Base (FiatTokenV2_2). */
720
+ declare const SWEEP_BASE_USDC_ADDRESS = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
721
+ /** EIP-712 `TransferWithAuthorization` struct, per EIP-3009. */
722
+ declare const TRANSFER_WITH_AUTHORIZATION_TYPES: {
723
+ readonly TransferWithAuthorization: readonly [{
724
+ readonly name: "from";
725
+ readonly type: "address";
726
+ }, {
727
+ readonly name: "to";
728
+ readonly type: "address";
729
+ }, {
730
+ readonly name: "value";
731
+ readonly type: "uint256";
732
+ }, {
733
+ readonly name: "validAfter";
734
+ readonly type: "uint256";
735
+ }, {
736
+ readonly name: "validBefore";
737
+ readonly type: "uint256";
738
+ }, {
739
+ readonly name: "nonce";
740
+ readonly type: "bytes32";
741
+ }];
742
+ };
743
+ interface SweepEip712Domain {
744
+ name: string;
745
+ version: string;
746
+ chainId: number;
747
+ verifyingContract: string;
748
+ }
749
+ /**
750
+ * A fully-specified EIP-3009 authorization. All amounts/times are decimal
751
+ * strings (JSON-safe) and `nonce` is a 0x-prefixed 32-byte hex value. `token`
752
+ * and `chainId` are carried explicitly so the signer can assert they are
753
+ * canonical before signing.
754
+ */
755
+ interface SweepAuthorization {
756
+ /** Delegate EOA the funds are swept FROM. */
757
+ from: string;
758
+ /** Originating Safe the funds are swept TO. */
759
+ to: string;
760
+ /** Atomic USDC amount (decimal string). */
761
+ value: string;
762
+ /** Unix seconds the authorization becomes valid (decimal string, usually "0"). */
763
+ validAfter: string;
764
+ /** Unix seconds the authorization expires (decimal string). */
765
+ validBefore: string;
766
+ /** Random 0x-prefixed 32-byte hex nonce. */
767
+ nonce: string;
768
+ /** USDC contract address. */
769
+ token: string;
770
+ /** Chain id (8453 today). */
771
+ chainId: number;
772
+ }
773
+ /**
774
+ * Haven's signature over the sweep authorization context, signed with the same
775
+ * binding key the x402 expected-context uses. Lets the edge signer verify the
776
+ * authorization actually came from Haven (and wasn't crafted by a compromised
777
+ * hosted server pointing `to` at an attacker) before it signs.
778
+ */
779
+ interface SweepExpectedAuth {
780
+ version: 1;
781
+ message: string;
782
+ signature: string;
783
+ signer: string;
784
+ }
785
+ /** What `POST /machine-payments/sweep/prepare` returns when funds are stranded. */
786
+ interface SweepPreparation {
787
+ authorization: SweepAuthorization;
788
+ expectedAuth: SweepExpectedAuth;
789
+ }
790
+ /** Wire response from `POST /machine-payments/sweep/prepare` (snake_case). */
791
+ interface SweepPrepareResponse {
792
+ /** Present and true when the delegate holds nothing to recover. */
793
+ nothing_stranded?: boolean;
794
+ /** The authorization to sign — absent when nothing is stranded. */
795
+ authorization?: SweepAuthorization;
796
+ /** Haven's binding over the authorization — absent when nothing is stranded. */
797
+ expected_auth?: SweepExpectedAuth;
798
+ asset?: string;
799
+ amount?: string;
800
+ amount_atomic?: string;
801
+ chain_id: number;
802
+ sign_instructions?: string;
803
+ message?: string;
804
+ }
805
+ /** Wire response from `POST /machine-payments/sweep/submit` (snake_case). */
806
+ interface SweepSubmitResponse {
807
+ tx_hash: string;
808
+ asset: string;
809
+ amount: string;
810
+ amount_atomic: string;
811
+ from_address: string;
812
+ to_address: string;
813
+ chain_id: number;
814
+ explorer_url: string;
815
+ idempotent_replay?: boolean;
816
+ }
817
+ /** Result of a submitted gasless sweep. */
818
+ interface SweepSubmitResult {
819
+ txHash: string;
820
+ amount: string;
821
+ amountAtomic: string;
822
+ asset: string;
823
+ fromAddress: string;
824
+ toAddress: string;
825
+ chainId: number;
826
+ explorerUrl: string;
827
+ }
828
+ interface SweepTypedData {
829
+ domain: SweepEip712Domain;
830
+ types: typeof TRANSFER_WITH_AUTHORIZATION_TYPES;
831
+ primaryType: 'TransferWithAuthorization';
832
+ message: {
833
+ from: string;
834
+ to: string;
835
+ value: bigint;
836
+ validAfter: bigint;
837
+ validBefore: bigint;
838
+ nonce: string;
839
+ };
840
+ }
841
+ /** Resolve the canonical USDC contract for a sweepable chain, or throw. */
842
+ declare function sweepUsdcAddress(chainId: number): string;
843
+ /** Resolve the USDC EIP-712 domain for a sweepable chain, or throw. */
844
+ declare function sweepUsdcDomain(chainId: number): SweepEip712Domain;
845
+ /**
846
+ * Build the EIP-712 typed data for an authorization, validating that the token
847
+ * and chain are canonical (the domain's `verifyingContract` must match the
848
+ * authorization's `token`). Returns bigint-valued fields so both viem and
849
+ * ethers v6 sign/recover identically.
850
+ */
851
+ declare function buildSweepTypedData(auth: SweepAuthorization): SweepTypedData;
852
+ /**
853
+ * Canonical, deterministic string the backend signs and the signer re-derives
854
+ * for the authorization binding. The `Haven sweep authorization v1` namespace
855
+ * (and `kind`) is distinct from the x402 expected-context namespace so an x402
856
+ * binding can never be replayed as a sweep authorization even though they share
857
+ * a signing key.
858
+ */
859
+ declare function buildSweepAuthorizationMessage(auth: SweepAuthorization): string;
860
+
674
861
  declare class HavenClient {
675
862
  private readonly apiKey;
676
863
  private readonly delegateKey;
@@ -790,6 +977,23 @@ declare class HavenClient {
790
977
  * Requires `chainRpcs` to be set for the agent's chain in `HavenClientConfig`.
791
978
  */
792
979
  sweepDelegate(): Promise<SweepResult>;
980
+ /**
981
+ * Hosted (keyless) split-signer sweep — step 1 of 2.
982
+ *
983
+ * Asks the backend to build a gasless EIP-3009 sweep authorization for the
984
+ * delegate's stranded USDC. Returns `nothing_stranded` when the delegate is
985
+ * empty, otherwise an `authorization` + Haven `expected_auth` to hand to the
986
+ * edge signer's `haven_sign_sweep_delegate`. No key is required on this client.
987
+ */
988
+ prepareSweep(): Promise<SweepPrepareResponse>;
989
+ /**
990
+ * Hosted (keyless) split-signer sweep — step 2 of 2.
991
+ *
992
+ * Relays the delegate-signed authorization. The Haven relayer submits the
993
+ * on-chain `transferWithAuthorization` and pays gas; this client never holds
994
+ * the key.
995
+ */
996
+ submitSweep(authorization: SweepAuthorization, signature: string): Promise<SweepSubmitResponse>;
793
997
  /**
794
998
  * Get configured and on-chain allowances for the authenticated agent.
795
999
  */
@@ -903,6 +1107,37 @@ declare class HavenClient {
903
1107
  */
904
1108
  payMppChallenge(quote: MppQuote, options?: MppAuthorizationOptions): Promise<Response>;
905
1109
  private retryX402Request;
1110
+ /**
1111
+ * Deliver an already-signed x402 payment header to the merchant and return
1112
+ * the merchant's response. Used by the hosted MCP server to complete the
1113
+ * merchant leg of an MCP tool payment after the edge signer has built the
1114
+ * `X-PAYMENT` header.
1115
+ *
1116
+ * Custody note: this never needs the delegate key. It relays a signed,
1117
+ * amount/merchant/nonce-bound EIP-3009 authorization the edge signer already
1118
+ * produced — the hosted server cannot mint or reuse signing authority.
1119
+ *
1120
+ * When the URL is MCP-shaped (`/mcp` path) or the quote-time transport context
1121
+ * says the merchant was Bazaar-discoverable, runs a fresh `initialize`
1122
+ * handshake (the quote-time session is gone once funding confirms; the x402
1123
+ * challenge is stateless w.r.t. the MCP session, so a fresh session is
1124
+ * accepted), threads the session + wallet headers, sets `X-PAYMENT`, and
1125
+ * collapses an SSE JSON-RPC response to its `result`.
1126
+ */
1127
+ completeX402MerchantCall(input: {
1128
+ url: string;
1129
+ init?: RequestInit;
1130
+ paymentId: string;
1131
+ paymentHeader: string;
1132
+ mcpTransport?: X402McpTransport;
1133
+ }): Promise<{
1134
+ status: number;
1135
+ ok: boolean;
1136
+ body: unknown;
1137
+ settlementTxHash?: string;
1138
+ }>;
1139
+ private resolveX402MerchantCompletionContext;
1140
+ private resolveX402WalletForMerchantCall;
906
1141
  authorizeMachinePayment(challenge: MachinePaymentChallenge, options?: MppAuthorizationOptions): Promise<MachinePaymentReceipt>;
907
1142
  private authorizeMppDemoPayment;
908
1143
  resumeAuthorizedMpp(input: ResumeAuthorizedMppInput): Promise<MachinePaymentReceipt>;
@@ -939,6 +1174,7 @@ declare class HavenClient {
939
1174
  private requestInitFromSnapshot;
940
1175
  private withX402Wallet;
941
1176
  private buildX402Quote;
1177
+ private detectX402McpTransport;
942
1178
  private buildX402ResumeState;
943
1179
  private buildMppQuote;
944
1180
  private buildMppResumeState;
@@ -1154,7 +1390,7 @@ declare const toolDescriptions: {
1154
1390
  readonly summary: "Discover payable services from Haven's curated merchant catalog — names, prices, and which pay tool to use.";
1155
1391
  readonly selectionGuidance: string;
1156
1392
  readonly behavior: string;
1157
- readonly nextActionGuidance: "Pick an entry, confirm the price with the user if it is non-trivial, and pay it with the tool named in suggested_tool, passing the entry's resource_url (and tool_name for MCP merchants).";
1393
+ readonly nextActionGuidance: "Pick an entry and pay it with the tool named in suggested_tool, passing the entry's resource_url (and tool_name for MCP merchants). Confirm the price from the live pay-tool result (not the catalog), and pass max_amount when the user has a cap.";
1158
1394
  };
1159
1395
  readonly sweep_delegate: {
1160
1396
  readonly summary: "Sweep stranded USDC and/or ETH from the delegate wallet back to the originating Safe.";
@@ -1188,7 +1424,7 @@ type SharedToolKey = keyof typeof toolDescriptions;
1188
1424
  * this canonical string and asserts byte-for-byte equality, so the two copies
1189
1425
  * cannot drift.
1190
1426
  */
1191
- declare const HAVEN_SKILL_MD = "---\nname: haven-pay\ndescription: Pay for things from the user's Haven wallet within their agent rules. Use when the user asks to send, pay, tip, or transfer crypto \u2014 or when a request hits an HTTP 402 (x402) paywall.\n---\n\n# Haven: pay from a Haven wallet\n\nThis skill lets the agent make payments from the user's Haven wallet through\nthe Haven MCP tools. Every payment is checked against the agent's on-chain\nbudget before money moves; payments above the remaining budget wait for the\nuser's approval in Haven.\n\n## When to use this skill\n\n- The user asks to send money, pay someone, tip, donate, or transfer tokens.\n- A request returns HTTP 402 (x402): use the Haven pay tools to settle it,\n then retry the original request.\n\n## Identity and budget come from the tools \u2014 never assume them\n\nDo not guess the wallet address, network, or budget. Read them live:\n\n- `haven_get_agent` \u2014 agent identity, Haven wallet address, network.\n- `haven_get_allowances` \u2014 current per-token budgets and what remains.\n\nBudgets reset on a period the user chose. If a payment exceeds the remaining\nbudget it is queued for the user to approve in the Haven dashboard \u2014 this is\nnormal, not an error.\n\n## Paying\n\n- **Direct transfer:** `haven_pay` with recipient, amount, and token.\n- **x402 paywall:** `haven_quote_x402` to get a quote, then\n `haven_pay_x402_quote`. In the hosted setup the signing step happens in\n the local Haven signer; follow the tool results \u2014 they tell you the next\n action at every step. Retry the original request only when the result says\n `retry_original_x402_request`.\n- **Status:** `haven_get_payment_status` with a `payment_id` to check on\n queued or in-flight payments. Do not poll in a tight loop.\n\n## Approval semantics\n\n- A result with `pending_approval` means the payment exceeded the remaining\n budget and is waiting for the user in Haven. Tell the user, then check\n status later.\n- Never ask the user for private keys and never try to sign anything\n yourself \u2014 Haven signs. If a tool reports a missing or invalid credential,\n tell the user to re-run the Haven setup command.\n\n## Failure handling\n\nHaven errors are shaped `{ error, status, details? }` and written for\nhumans \u2014 surface the message verbatim. Common cases:\n\n- `pending_approval`: queued for the user's approval (see above).\n- `insufficient_funds`: the Haven wallet doesn't hold enough of that token.\n Suggest the user add funds in the Haven dashboard.\n- Budget exceeded: tell the user how much remains (from\n `haven_get_allowances`) and that they can raise the budget in Haven.\n\n## Revoke\n\nIf this agent's credential may have leaked, tell the user to pause or revoke\nthe agent in the Haven dashboard under Agents. New requests stop immediately\nfor that credential.\n";
1427
+ declare const HAVEN_SKILL_MD = "---\nname: haven-pay\ndescription: Pay for things from the user's Haven wallet within their agent rules. Use when the user asks to send, pay, tip, or transfer crypto \u2014 or when a request hits an HTTP 402 (x402) paywall.\n---\n\n# Haven: pay from a Haven wallet\n\nThis skill lets the agent make payments from the user's Haven wallet through\nthe Haven MCP tools. Every payment is checked against the agent's on-chain\nbudget before money moves; payments above the remaining budget wait for the\nuser's approval in Haven.\n\nHosted tools run in the `mcp__haven__` namespace. Local signing tools run in\nthe `mcp__haven-signer__` namespace and keep the delegate key on this machine.\n\n## When to use this skill\n\n- The user asks to send money, pay someone, tip, donate, or transfer tokens.\n- A request returns HTTP 402 (x402): use the Haven pay tools to settle it,\n then retry the original request.\n\n## Identity and budget come from the tools \u2014 never assume them\n\nDo not guess the wallet address, network, or budget. Read them live:\n\n- `haven_get_agent` \u2014 agent identity, Haven wallet address, network.\n- `haven_get_allowances` \u2014 current per-token budgets and what remains.\n\nBudgets reset on a period the user chose. If a payment exceeds the remaining\nbudget it is queued for the user to approve in the Haven dashboard \u2014 this is\nnormal, not an error.\n\n## Paying\n\n- **Direct transfer:** `haven_pay` with recipient, amount, and token.\n- **x402 paywall:** `haven_quote_x402` to get a quote, then\n `haven_pay_x402_quote`. In the hosted setup the signing step happens in\n the local Haven signer; follow the tool results \u2014 they tell you the next\n action at every step. Retry the original request only when the result says\n `retry_original_x402_request`.\n- **Paid MCP tool call:** `mcp__haven__haven_pay_mcp_tool` with the merchant\n URL, tool name, and arguments, then finish in two calls (fast path):\n `mcp__haven-signer__haven_sign_x402` on the local signer (pass\n `payload_hash`, `x402_expected` as the nested `x402.expected` object, and\n `payment_required`) returns `{ signature, payment_header }`; then\n `mcp__haven__haven_settle_mcp_tool` (pass `payment_id`, `signature`,\n `payment_header`, `merchant_url`, `tool_name`, `arguments`,\n `mcp_transport`) funds and settles in one step and returns the tool result.\n If it returns `settled: false`, funding is queued for the user's approval \u2014\n tell them and check status later, do not re-pay. Step-by-step alternative:\n `mcp__haven-signer__haven_sign` \u2192 `mcp__haven__haven_submit` \u2192\n `mcp__haven-signer__haven_x402_sign_header` \u2192\n `mcp__haven__haven_complete_mcp_tool`. Pass `payment_required`,\n `arguments`, and `mcp_transport` verbatim from the\n `mcp__haven__haven_pay_mcp_tool` result. The returned `expires_at` is the\n signing window; if a tool returns `PAYMENT_WINDOW_EXPIRED`, re-run\n `mcp__haven__haven_pay_mcp_tool` with the same\n `idempotency_key`. Do not call the merchant yourself \u2014 Haven completes the\n merchant leg for you.\n- **Prices:** show the user the live price from the pay-tool result, never a\n catalog price. `haven_discover_tools` prices are indicative\n (`price_is_indicative`) and can be stale. The pay-tool result's `amount` /\n `amount_atomic` is the amount Haven authorizes for the call \u2014 a ceiling the\n merchant settles at or below \u2014 so present it as the most the user will pay.\n Pass `max_amount` (atomic units) to `haven_pay_mcp_tool` /\n `haven_pay_x402_quote` to reject a quote whose authorized amount is above the\n user's cap, before any funds move.\n- **Status:** `haven_get_payment_status` with a `payment_id` to check on\n queued or in-flight payments. Do not poll in a tight loop.\n\n## Approval semantics\n\n- A result with `pending_approval` means the payment exceeded the remaining\n budget and is waiting for the user in Haven. Tell the user, then check\n status later.\n- Never ask the user for private keys. Signing happens only in the local Haven\n signer; the hosted Haven tools never receive the signing key. If a tool\n reports a missing or invalid credential, tell the user to re-run the Haven\n setup command.\n\n## Failure handling\n\nHaven tool failures are shaped like `{ success: false, code, message, ... }`\nor older `{ error, status, details? }` responses. Branch on `code` when\npresent and surface `message` or `error` verbatim. Common cases:\n\n- `pending_approval`: queued for the user's approval (see above).\n- `insufficient_funds`: the Haven wallet doesn't hold enough of that token.\n Suggest the user add funds in the Haven dashboard.\n- `PRICE_EXCEEDS_MAX`: the live merchant price exceeded your `max_amount`.\n No funds moved; ask the user before retrying with a higher cap.\n- `PAYMENT_WINDOW_EXPIRED`: re-run `mcp__haven__haven_pay_mcp_tool` with the same\n `idempotency_key`, then sign the fresh `payload_hash`.\n- `MERCHANT_REJECTED_AFTER_FUNDING`: stop retrying the merchant and use\n `mcp__haven__haven_sweep_delegate` to recover stranded delegate funds.\n- Budget exceeded: tell the user how much remains (from\n `haven_get_allowances`) and that they can raise the budget in Haven.\n\n## Revoke\n\nIf this agent's credential may have leaked, tell the user to pause or revoke\nthe agent in the Haven dashboard under Agents. New requests stop immediately\nfor that credential.\n";
1192
1428
  /** Directory name for the installed skill folder. */
1193
1429
  declare const SKILL_FOLDER_NAME = "haven-pay";
1194
1430
 
@@ -1300,4 +1536,4 @@ declare function encodeBase64Json(value: unknown): string;
1300
1536
  */
1301
1537
  declare function decodeBase64Json<T>(value: string, label?: string): T;
1302
1538
 
1303
- export { AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, type AgentPaymentEnumSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, type ClaudeTool, HAVEN_SKILL_MD, type HavenAgent, type HavenAllowance, type HavenAllowanceSummary, HavenApiError, type HavenCatalogEntry, HavenClient, type HavenClientConfig, HavenError, type HavenPaymentReceipt, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, type MachinePaymentChallenge, type MachinePaymentRail, type MachinePaymentReceipt, type MppAuthorizationOptions, type MppQuote, type MppResumeState, type OpenAITool, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentRequest, type PaymentResult, type PaymentResumeState, type PaymentStatus, type PaymentStatusResult, type PendingApproval, type ResumeAuthorizedMppInput, type ResumeAuthorizedX402Input, type ResumeMppPaymentInput, type ResumeX402PaymentInput, SKILL_FOLDER_NAME, type SharedToolKey, type SignData, type SweepEntry, type SweepResult, type ToolDescription, type X402AuthorizationOptions, type X402ExpectedAuth, type X402ExpectedContext, type X402Intent, type X402PaymentOption, type X402PaymentRequired, type X402Quote, type X402Receipt, type X402RequestSnapshot, type X402ResumeState, addressFromKey, buildMachinePaymentIdempotencyKey, buildX402ExpectedMessage, composeDescription, decodeBase64Json, decodeBase64Utf8, encodeBase64Json, encodeBase64Utf8, encodeMachinePaymentProof, encodePaymentProof, havenTools, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, toStandardPaymentRequirements, toolDescriptions, verifySignature, x402AuthorizationAmount };
1539
+ export { AGENT_PAYMENT_FAILURE_CODE_VALUES, AGENT_PAYMENT_NEXT_ACTION_VALUES, AGENT_PAYMENT_PHASE_VALUES, AGENT_PAYMENT_RAIL_VALUES, type AgentPaymentEnumSchema, AgentPaymentFailureCode, AgentPaymentFailureCodeDescriptions, AgentPaymentFailureCodeSchema, AgentPaymentNextAction, AgentPaymentNextActionDescriptions, AgentPaymentNextActionSchema, AgentPaymentPhase, AgentPaymentPhaseDescriptions, AgentPaymentPhaseSchema, AgentPaymentRail, AgentPaymentRailDescriptions, AgentPaymentRailSchema, type ClaudeTool, HAVEN_SKILL_MD, type HavenAgent, type HavenAllowance, type HavenAllowanceSummary, HavenApiError, type HavenCatalogEntry, HavenClient, type HavenClientConfig, HavenError, type HavenPaymentReceipt, HavenPaymentStateError, HavenSigningError, HavenTimeoutError, type MachinePaymentChallenge, type MachinePaymentRail, type MachinePaymentReceipt, type MppAuthorizationOptions, type MppQuote, type MppResumeState, type OpenAITool, type PaymentIntent, type PaymentNextAction, type PaymentPhase, type PaymentRequest, type PaymentResult, type PaymentResumeState, type PaymentStatus, type PaymentStatusResult, type PendingApproval, type ResumeAuthorizedMppInput, type ResumeAuthorizedX402Input, type ResumeMppPaymentInput, type ResumeX402PaymentInput, SKILL_FOLDER_NAME, SWEEP_BASE_CHAIN_ID, SWEEP_BASE_USDC_ADDRESS, type SharedToolKey, type SignData, type SweepAuthorization, type SweepEip712Domain, type SweepEntry, type SweepExpectedAuth, type SweepPreparation, type SweepPrepareResponse, type SweepResult, type SweepSubmitResponse, type SweepSubmitResult, type SweepTypedData, TRANSFER_WITH_AUTHORIZATION_TYPES, type ToolDescription, type X402AuthorizationOptions, type X402ExpectedAuth, type X402ExpectedContext, type X402Intent, type X402McpTransport, type X402PaymentOption, type X402PaymentRequired, type X402Quote, type X402Receipt, type X402RequestSnapshot, type X402ResumeState, addressFromKey, buildMachinePaymentIdempotencyKey, buildSweepAuthorizationMessage, buildSweepTypedData, buildX402ExpectedMessage, composeDescription, decodeBase64Json, decodeBase64Utf8, encodeBase64Json, encodeBase64Utf8, encodeMachinePaymentProof, encodePaymentProof, havenTools, parseMachinePaymentChallenge, parseMachinePaymentChallengeResponse, parsePaymentRequired, parsePaymentRequiredResponse, selectPaymentOption, selectStandardPaymentOption, signHash, sweepUsdcAddress, sweepUsdcDomain, toStandardPaymentRequirements, toolDescriptions, verifySignature, x402AuthorizationAmount };