@haven_ai/sdk 0.1.14-alpha.0 → 0.1.16-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/README.md CHANGED
@@ -229,6 +229,8 @@ The enum values and JSON Schema fragments are exported from `@haven_ai/sdk`:
229
229
  import {
230
230
  AgentPaymentNextAction,
231
231
  AgentPaymentNextActionSchema,
232
+ AgentPaymentFailureCode,
233
+ AgentPaymentFailureCodeSchema,
232
234
  AgentPaymentPhase,
233
235
  AgentPaymentPhaseSchema,
234
236
  AgentPaymentRail,
@@ -277,6 +279,10 @@ Terminal from any non-confirmed phase:
277
279
  rejected → stop_and_tell_user
278
280
  failed → stop_and_tell_user
279
281
  expired → request_again_if_user_still_wants_it
282
+
283
+ x402 tool-window failures:
284
+ expired funding/quote window → PAYMENT_WINDOW_EXPIRED → re-quote with same idempotency_key
285
+ merchant rejection after funding → MERCHANT_REJECTED_AFTER_FUNDING → haven_sweep_delegate
280
286
  ```
281
287
 
282
288
  ### `phase` reference
@@ -308,6 +314,18 @@ The merchant settlement leg of x402 (and the MPP retry) is the agent's own reque
308
314
  | `retry_original_x402_request` | Resume this payment id and retry the original x402 request with the merchant payment header. Do not start a new merchant session. |
309
315
  | `stop_and_tell_user` | Stop retrying and tell the user the payment failed or was rejected. |
310
316
  | `request_again_if_user_still_wants_it` | The request expired; ask again only if the user still wants the payment. |
317
+ | `payment_window_expired` | The x402 funding/quote window expired. Re-quote the same paid MCP tool call with the same `idempotency_key`, then sign the fresh `payload_hash`. |
318
+ | `sweep_stranded_funds` | A funding leg succeeded but the merchant/protocol leg did not settle. Stop retrying and use `haven_sweep_delegate` to recover stranded delegate funds. |
319
+
320
+ ### Machine-readable recovery codes
321
+
322
+ Hosted MCP and signer tools also return stable `code` values on recoverable x402 failures:
323
+
324
+ | `code` | Meaning | Agent recovery |
325
+ |--------|---------|----------------|
326
+ | `PRICE_EXCEEDS_MAX` | The merchant-authoritative x402 price is above the caller's `max_amount` cap. No funding transfer was created. | Tell the user the live price exceeded the cap and retry only after they confirm a higher `max_amount`. |
327
+ | `PAYMENT_WINDOW_EXPIRED` | The funding/quote window closed before `haven_x402_sign_header`, `haven_submit`, or `haven_complete_mcp_tool` could finish. | Re-run `haven_pay_mcp_tool` with the same `idempotency_key`, then sign and complete the fresh quote. Payloads include `retry_with_new_quote: true`. |
328
+ | `MERCHANT_REJECTED_AFTER_FUNDING` | Haven's funding leg succeeded, but the merchant rejected the paid retry. | Stop retrying the merchant and call `haven_sweep_delegate` so the user can recover stranded delegate USDC. |
311
329
 
312
330
  ## Payments above the on-chain allowance
313
331