@haven_ai/sdk 0.5.0-alpha.1 → 0.7.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.
- package/README.md +24 -8
- package/dist/{base64-BUMXmruY.d.cts → base64-_seD1uw8.d.cts} +425 -18
- package/dist/{base64-BUMXmruY.d.ts → base64-_seD1uw8.d.ts} +425 -18
- package/dist/{chunk-JKUIE45B.cjs → chunk-3SVPI4LS.cjs} +130 -9
- package/dist/chunk-3SVPI4LS.cjs.map +1 -0
- package/dist/{chunk-QSSVOPWA.cjs → chunk-J6DQEBK2.cjs} +340 -17
- package/dist/chunk-J6DQEBK2.cjs.map +1 -0
- package/dist/{chunk-GLNG2GF7.js → chunk-NNIT7WAI.js} +127 -10
- package/dist/chunk-NNIT7WAI.js.map +1 -0
- package/dist/{chunk-KQ7JXKTV.js → chunk-R3RZJJWL.js} +321 -6
- package/dist/chunk-R3RZJJWL.js.map +1 -0
- package/dist/edge.cjs +296 -57
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +122 -5
- package/dist/edge.d.ts +122 -5
- package/dist/edge.js +204 -4
- package/dist/edge.js.map +1 -1
- package/dist/index.cjs +772 -350
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +162 -28
- package/dist/index.d.ts +162 -28
- package/dist/index.js +461 -80
- package/dist/index.js.map +1 -1
- package/dist/test-support.cjs +18 -18
- package/dist/test-support.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-GLNG2GF7.js.map +0 -1
- package/dist/chunk-JKUIE45B.cjs.map +0 -1
- package/dist/chunk-KQ7JXKTV.js.map +0 -1
- package/dist/chunk-QSSVOPWA.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -25,7 +25,8 @@ The package has three entries. `@haven_ai/sdk` is the full client. `@haven_ai/sd
|
|
|
25
25
|
(#3173) is the ethers-free subset the local signer imports — error classes, the
|
|
26
26
|
typed-next-step builder, the x402 message builders, viem-based key helpers, and
|
|
27
27
|
(#3283) the signing-surface guard: `assertBoundDirectPaymentUserOp`, the
|
|
28
|
-
redemption guard, `deriveDelegateAccountAddress
|
|
28
|
+
redemption guard, `deriveDelegateAccountAddress`, `verifySettlementChild` and
|
|
29
|
+
(#3281) the funding-leg recipient pin `assertFundingLegPaysDelegate` —
|
|
29
30
|
and loads in about a third of the time; use it when you need those helpers
|
|
30
31
|
without the HTTP client. A class imported from either entry is the same class.
|
|
31
32
|
`@haven_ai/sdk/test-support` (#3283) holds test fixture builders shared by
|
|
@@ -243,7 +244,12 @@ case where two purchases collided on a key you did not choose.
|
|
|
243
244
|
|
|
244
245
|
This applies to the **EIP-3009 funding-leg** scheme, which routes money
|
|
245
246
|
through the delegate EOA. **erc7710 direct settlement is unaffected**: it has
|
|
246
|
-
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).
|
|
247
253
|
|
|
248
254
|
For agents that need to inspect the price before paying, use the quote-first
|
|
249
255
|
path. `quoteX402()` probes the merchant and parses the HTTP 402 response, but it
|
|
@@ -419,6 +425,7 @@ x402 tool-window failures:
|
|
|
419
425
|
| `rejected` | The payment was rejected and cannot proceed. | yes |
|
|
420
426
|
| `expired` | Payment expired before completion. | yes |
|
|
421
427
|
| `failed` | Haven could not complete the payment. | yes |
|
|
428
|
+
| `delivered_unverified` | **#3420: terminal.** The merchant delivered, but the settlement window and the sweep's last attribution chance have both passed with no verified on-chain evidence. Polling cannot change this; the only remedy is reporting a real settlement hash (`haven_report_settlement_evidence`). | yes |
|
|
422
429
|
|
|
423
430
|
The merchant settlement leg of x402 (and the MPP retry) is the agent's own request to the merchant — it does not have a Haven `phase`. The payment is `funding_sent` until the agent retries with the payment header (`PAYMENT-SIGNATURE`, plus `X-PAYMENT` on this bridged path) (x402) or the MPP proof header; from Haven's perspective the payment becomes `executed` only after the agent successfully resumes.
|
|
424
431
|
|
|
@@ -429,10 +436,11 @@ The merchant settlement leg of x402 (and the MPP retry) is the agent's own reque
|
|
|
429
436
|
| `sign_and_submit_payment` | Sign with the delegate key and submit the payment to Haven. |
|
|
430
437
|
| `check_status_later` | Poll `getPaymentStatus(payment_id)` later. |
|
|
431
438
|
| `none` | Stop polling; no more action is needed for this payment id. |
|
|
439
|
+
| `awaiting_settlement_evidence` | #2970/#3420: the erc7710 settlement window passed with no verified evidence. Poll `getPaymentStatus(payment_id)` once more shortly after the payment's expiry; if it still shows nothing (or already answers the terminal `delivered_unverified` phase), tell the user the goods were delivered but unverified. |
|
|
432
440
|
| `wait_for_user_approval` | **No longer produced — nothing maps to it.** Retired with the Safe rail's approval queue; kept in the exported enum for wire compatibility. The SDK's own status mapping now answers `stop_and_tell_user` for the statuses that used to yield this. |
|
|
433
441
|
| `wait_for_user_to_complete_payment` | **No longer produced — nothing maps to it.** Same retirement as above. |
|
|
434
442
|
| `retry_original_x402_request` | Haven's funding leg confirmed but no merchant response was ever recorded — most often because the process crashed between the funding confirmation and the merchant retry (a 15-minute grace window applies before this fires; a client-reported merchant rejection instead yields `sweep_stranded_funds`). Call `resumeX402Payment()` with the preserved `resumeState`, or rehydrate it first with `getResumeState(payment_id)`. Do not start a new payment for the same purchase. |
|
|
435
|
-
| `stop_and_tell_user` | Stop retrying and tell the user the payment failed or was
|
|
443
|
+
| `stop_and_tell_user` | Stop retrying and tell the user what happened — the payment failed, was rejected, or (#3420) was delivered but its settlement can no longer be verified. |
|
|
436
444
|
| `request_again_if_user_still_wants_it` | The request expired; ask again only if the user still wants the payment. |
|
|
437
445
|
| `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`. |
|
|
438
446
|
| `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. |
|
|
@@ -639,11 +647,19 @@ try {
|
|
|
639
647
|
}
|
|
640
648
|
```
|
|
641
649
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
650
|
+
Two errors are **not** a failure to pay; each reports that the payment it
|
|
651
|
+
describes *succeeded*, earlier. Handle both before the generic branches, and
|
|
652
|
+
treat them as proof of purchase rather than retrying:
|
|
653
|
+
|
|
654
|
+
- `X402AlreadySettledError` extends `HavenApiError` (status 409; EIP-3009
|
|
655
|
+
path) and carries `err.receipt`.
|
|
656
|
+
- `X402Erc7710AlreadySettledError` extends `HavenError`, **not**
|
|
657
|
+
`HavenApiError` (no status; code `PAYMENT_ALREADY_SETTLED`; erc7710
|
|
658
|
+
`prepareX402Erc7710()`, and since #3423 `submitX402Erc7710()` on a repeated
|
|
659
|
+
settle), and carries `err.paymentId` and `err.txHash`. An
|
|
660
|
+
`instanceof HavenApiError` branch does not catch it.
|
|
661
|
+
|
|
662
|
+
See [Idempotency](#idempotency-what-the-key-guarantees-and-what-it-costs).
|
|
647
663
|
|
|
648
664
|
## License
|
|
649
665
|
|