@haven_ai/sdk 0.7.0-alpha.0 → 0.8.1-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 +11 -9
- package/dist/{base64-_seD1uw8.d.cts → base64-BjxHPgtC.d.cts} +275 -16
- package/dist/{base64-_seD1uw8.d.ts → base64-BjxHPgtC.d.ts} +275 -16
- package/dist/{chunk-NNIT7WAI.js → chunk-H4APV67M.js} +2 -2
- package/dist/chunk-H4APV67M.js.map +1 -0
- package/dist/{chunk-J6DQEBK2.cjs → chunk-HFOAYTD4.cjs} +216 -40
- package/dist/chunk-HFOAYTD4.cjs.map +1 -0
- package/dist/{chunk-3SVPI4LS.cjs → chunk-HX34HOW4.cjs} +2 -2
- package/dist/chunk-HX34HOW4.cjs.map +1 -0
- package/dist/{chunk-R3RZJJWL.js → chunk-WDA3IGJP.js} +180 -17
- package/dist/chunk-WDA3IGJP.js.map +1 -0
- package/dist/edge.cjs +128 -128
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +172 -3
- package/dist/edge.d.ts +172 -3
- package/dist/edge.js +5 -54
- package/dist/edge.js.map +1 -1
- package/dist/index.cjs +685 -348
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -21
- package/dist/index.d.ts +76 -21
- package/dist/index.js +392 -55
- 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-3SVPI4LS.cjs.map +0 -1
- package/dist/chunk-J6DQEBK2.cjs.map +0 -1
- package/dist/chunk-NNIT7WAI.js.map +0 -1
- package/dist/chunk-R3RZJJWL.js.map +0 -1
package/README.md
CHANGED
|
@@ -46,13 +46,13 @@ const haven = new HavenClient({
|
|
|
46
46
|
|
|
47
47
|
// One-liner payment — handles intent, signing, submission, and confirmation
|
|
48
48
|
const result = await haven.pay({
|
|
49
|
-
token: '
|
|
49
|
+
token: 'USDC',
|
|
50
50
|
amount: '5.00',
|
|
51
51
|
to: '0xabc...',
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
console.log(result.txHash) // 0x...
|
|
55
|
-
console.log(result.explorerUrl) // https://
|
|
55
|
+
console.log(result.explorerUrl) // https://basescan.org/tx/0x... (sepolia.basescan.org on Base Sepolia)
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
## Pay for an x402 resource
|
|
@@ -82,8 +82,8 @@ shows up in your Haven dashboard activity feed.
|
|
|
82
82
|
|
|
83
83
|
| Network | CAIP-2 | Tokens |
|
|
84
84
|
|---------|--------|--------|
|
|
85
|
-
|
|
|
86
|
-
| Base | `eip155:
|
|
85
|
+
| Base | `eip155:8453` | USDC |
|
|
86
|
+
| Base Sepolia (dev/QA) | `eip155:84532` | USDC |
|
|
87
87
|
|
|
88
88
|
## Credential Lifecycle
|
|
89
89
|
|
|
@@ -290,7 +290,7 @@ const anthropic = new Anthropic()
|
|
|
290
290
|
const response = await anthropic.messages.create({
|
|
291
291
|
model: 'claude-opus-4-7',
|
|
292
292
|
tools: havenTools.claude(), // or havenTools.openai() for OpenAI
|
|
293
|
-
messages: [{ role: 'user', content: 'Pay 5
|
|
293
|
+
messages: [{ role: 'user', content: 'Pay 5 USDC to 0xabc for API access' }],
|
|
294
294
|
})
|
|
295
295
|
|
|
296
296
|
// Handle tool calls
|
|
@@ -470,9 +470,11 @@ answers HTTP 410 at every agent-payment entry point.
|
|
|
470
470
|
If an agent requests a payment outside that policy, Haven **declines it before
|
|
471
471
|
any money moves** — during prepare, before anything is written and before the
|
|
472
472
|
agent is asked to sign. `POST /payments` answers `403` when no active delegation
|
|
473
|
-
authorizes that token and recipient,
|
|
474
|
-
|
|
475
|
-
|
|
473
|
+
authorizes that token and recipient, `403 delegation_budget_exceeded` when the
|
|
474
|
+
remaining period budget cannot cover the amount (#3503; the x402 authorize path
|
|
475
|
+
answers the same), and `502` when the on-chain caveat check rejects a
|
|
476
|
+
redemption anyway (a recipient outside a pin or an expired grant already gets
|
|
477
|
+
the first `403`, since no active delegation matches). In every case the SDK raises `HavenApiError` and no
|
|
476
478
|
`payment_id` exists to poll.
|
|
477
479
|
|
|
478
480
|
Surface that to the user as a decline, not a wait: **nothing will arrive later.**
|
|
@@ -630,7 +632,7 @@ inspection, saved resume state, and final retry.
|
|
|
630
632
|
import { HavenApiError, HavenPaymentStateError, HavenSigningError, HavenTimeoutError } from '@haven_ai/sdk'
|
|
631
633
|
|
|
632
634
|
try {
|
|
633
|
-
await haven.pay({ token: '
|
|
635
|
+
await haven.pay({ token: 'USDC', amount: '5.00', to: '0xabc...' })
|
|
634
636
|
} catch (err) {
|
|
635
637
|
if (err instanceof HavenPaymentStateError) {
|
|
636
638
|
console.log(err.paymentId, err.phase, err.nextAction)
|
|
@@ -55,7 +55,7 @@ interface HavenClientConfig {
|
|
|
55
55
|
chainRpcs?: Record<number, string>;
|
|
56
56
|
}
|
|
57
57
|
interface PaymentRequest {
|
|
58
|
-
/** Token symbol: "
|
|
58
|
+
/** Token symbol: "USDC" (agent budgets are USDC on Base and Base Sepolia) */
|
|
59
59
|
token: string;
|
|
60
60
|
/** Amount as a decimal string, e.g. "5.00" */
|
|
61
61
|
amount: string;
|
|
@@ -133,6 +133,15 @@ interface PaymentIntent {
|
|
|
133
133
|
expiresAt: string;
|
|
134
134
|
/** Data needed to sign the payment */
|
|
135
135
|
signData: SignData;
|
|
136
|
+
/**
|
|
137
|
+
* #3531: advisory, history-only recipient classification — `previously_paid`
|
|
138
|
+
* when this agent has a prior confirmed payment to this recipient,
|
|
139
|
+
* `new_address` otherwise. Never affects signing or policy. Absent against
|
|
140
|
+
* an older backend, and when the backend's history read fails.
|
|
141
|
+
*/
|
|
142
|
+
recipient?: {
|
|
143
|
+
class: 'previously_paid' | 'new_address';
|
|
144
|
+
};
|
|
136
145
|
}
|
|
137
146
|
type PaymentStatus = 'pending_signature' | 'submitted' | 'confirmed' | 'pending_approval' | 'approved' | 'proposed' | 'executed' | 'rejected' | 'expired' | 'failed';
|
|
138
147
|
interface PaymentResult {
|
|
@@ -550,6 +559,26 @@ interface HavenAllowance {
|
|
|
550
559
|
tokenSymbol: string;
|
|
551
560
|
configuredAmount: string;
|
|
552
561
|
resetPeriodMin: number;
|
|
562
|
+
/**
|
|
563
|
+
* #3518: this budget's SCOPE, so an agent holding more than one budget
|
|
564
|
+
* for a token can name the merchant-locked one before paying. The
|
|
565
|
+
* recipient pin is null for an open budget; `merchantId` is set only on a
|
|
566
|
+
* #3331 merchant-locked budget (which always carries a pin). Additive —
|
|
567
|
+
* undefined on an older backend that does not send them.
|
|
568
|
+
*/
|
|
569
|
+
delegationHash?: string;
|
|
570
|
+
recipientAddress?: string | null;
|
|
571
|
+
merchantId?: string | null;
|
|
572
|
+
/**
|
|
573
|
+
* #3518: the Haven-side reservation against this budget — the sum of its
|
|
574
|
+
* open, unexpired task- and sub-budget children's caps, in ATOMIC units.
|
|
575
|
+
* Reported beside `onchain.remaining` and never folded into it (the
|
|
576
|
+
* on-chain figure stays authoritative; a reservation releases on
|
|
577
|
+
* close/expire without any chain event). `'0'` also covers a failed
|
|
578
|
+
* read — the sum is best-effort server-side. Additive; undefined on an
|
|
579
|
+
* older backend.
|
|
580
|
+
*/
|
|
581
|
+
reservedHavenAtomic?: string;
|
|
553
582
|
/**
|
|
554
583
|
* #3128: human-readable `onchain.remaining`, e.g. "4.96 USDC" — the SAME
|
|
555
584
|
* string {@link HavenAgentAllowanceSummary.remainingDisplay} carries for
|
|
@@ -590,8 +619,12 @@ interface HavenAllowanceSummary {
|
|
|
590
619
|
* (#1310). Read-only reporting — the on-chain policy remains the actual
|
|
591
620
|
* spend gate either way, this only says what is left after the purchase.
|
|
592
621
|
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
622
|
+
* #3464: the canonical key spelling is the ONE `haven_get_agent`'s
|
|
623
|
+
* `allowances[]` rows use — the read the server tells an agent to make
|
|
624
|
+
* first — with the figures named `remainingAtomic`, `remainingDisplay`,
|
|
625
|
+
* `resetPeriodMin`, `tokenSymbol`, `tokenAddress`. Deliberately the SAME
|
|
626
|
+
* spelling as #1306's catalog-purchase preflight `allowance` block (never a
|
|
627
|
+
* new spelling; the hosted result types carry the same names),
|
|
595
628
|
* minus the preflight-only `sufficient` field: post-purchase reporting
|
|
596
629
|
* answers "what is left", not "was this purchase covered". Read through the
|
|
597
630
|
* exact same source as {@link HavenAllowanceSummary} / `haven_get_allowances`
|
|
@@ -599,19 +632,57 @@ interface HavenAllowanceSummary {
|
|
|
599
632
|
* `deriveDelegationBudgets`-backed enforcer read, never `agent_allowances`),
|
|
600
633
|
* so this can never disagree with `haven_get_allowances` for the same
|
|
601
634
|
* fixture.
|
|
635
|
+
*
|
|
636
|
+
* The snake_case keys below are DEPRECATED since #3464 and kept for one
|
|
637
|
+
* deprecation window so existing readers keep working; every value is also
|
|
638
|
+
* emitted under the camelCase name above. Removal condition: once
|
|
639
|
+
* `packages/qa-agent` reads the camelCase keys on a released qa-agent build,
|
|
640
|
+
* the snake_case keys go — tracked as the additive-window close, not a
|
|
641
|
+
* separate decision. The new keys stay OPTIONAL on this exported type so
|
|
642
|
+
* existing constructors keep type-checking unchanged.
|
|
602
643
|
*/
|
|
603
644
|
interface PostPurchaseAllowanceSummary {
|
|
604
|
-
/**
|
|
605
|
-
|
|
645
|
+
/**
|
|
646
|
+
* Which on-chain policy primitive gates this agent's spend (#1306
|
|
647
|
+
* labeling). #3464: `'legacy'` removed — unreachable since #1986/#2020
|
|
648
|
+
* (`GET /machine-payments/allowances` answers 410 before this summary is
|
|
649
|
+
* built), superseding #2265's keep-as-declared rationale; the public
|
|
650
|
+
* {@link HavenAgent.executionRail} keeps its declared union.
|
|
651
|
+
*/
|
|
652
|
+
rail: 'delegation';
|
|
606
653
|
/** Remaining atomic units, read through the same source as {@link HavenAllowance.onchain.remaining}. */
|
|
607
654
|
remaining_atomic: string;
|
|
608
|
-
/**
|
|
655
|
+
/**
|
|
656
|
+
* @deprecated #3464 — use `remainingAtomic` (same value). Kept for the
|
|
657
|
+
* deprecation window; removed once `packages/qa-agent` reads the camelCase
|
|
658
|
+
* keys.
|
|
659
|
+
*/
|
|
609
660
|
remaining_display?: string;
|
|
661
|
+
/** @deprecated #3464 — use `tokenSymbol` (same value). Same removal condition. */
|
|
610
662
|
token_symbol?: string;
|
|
663
|
+
/** @deprecated #3464 — use `tokenAddress` (same value). Same removal condition. */
|
|
611
664
|
token_address?: string;
|
|
612
|
-
/**
|
|
665
|
+
/** @deprecated #3464 — use `resetPeriodMin` (same value). Same removal condition. */
|
|
613
666
|
reset_period?: number;
|
|
614
|
-
|
|
667
|
+
/**
|
|
668
|
+
* Which source produced the figures. #3464: `'allowance_module'` removed
|
|
669
|
+
* for the same unreachability as `rail: 'legacy'` above.
|
|
670
|
+
*/
|
|
671
|
+
source: 'active_delegations';
|
|
672
|
+
/** Remaining atomic units — the same figure `remaining_atomic` carries. Optional on the type, always emitted at runtime. */
|
|
673
|
+
remainingAtomic?: string;
|
|
674
|
+
/**
|
|
675
|
+
* Human-readable remaining, formatted by the ONE shared formatter
|
|
676
|
+
* (`formatRemainingDisplay`) — always emitted at runtime, never omitted:
|
|
677
|
+
* an unknown-decimals token gets the same explicit atomic label
|
|
678
|
+
* `haven_get_agent`'s `allowances[]` rows carry. Optional on the type so
|
|
679
|
+
* existing constructors stay valid.
|
|
680
|
+
*/
|
|
681
|
+
remainingDisplay?: string;
|
|
682
|
+
/** Minutes — mirrors {@link HavenAllowance.resetPeriodMin} / the delegation's period. */
|
|
683
|
+
resetPeriodMin?: number;
|
|
684
|
+
tokenSymbol?: string;
|
|
685
|
+
tokenAddress?: string;
|
|
615
686
|
}
|
|
616
687
|
/**
|
|
617
688
|
* #3126 — the answer to "is there money actually HELD behind my budget?",
|
|
@@ -669,6 +740,13 @@ interface HavenBalanceCoverage {
|
|
|
669
740
|
* token (nothing was read).
|
|
670
741
|
*/
|
|
671
742
|
budgetRemainingIsFromChain?: boolean;
|
|
743
|
+
/**
|
|
744
|
+
* #3518: present only when `budgetRemainingAtomic` is "0" because the
|
|
745
|
+
* agent has no OPEN budget for the token but holds live merchant-locked
|
|
746
|
+
* budgets — their recipients (lowercase). Those budgets pay only these
|
|
747
|
+
* addresses; `getAllowances()` reports their remaining figures.
|
|
748
|
+
*/
|
|
749
|
+
budgetRecipientAddresses?: string[];
|
|
672
750
|
}
|
|
673
751
|
/**
|
|
674
752
|
* Affirmative spend-readiness for the authenticated agent, derived from the raw
|
|
@@ -752,6 +830,81 @@ interface HavenAgentSummary extends HavenAgent {
|
|
|
752
830
|
* budgets", not a fetch failure).
|
|
753
831
|
*/
|
|
754
832
|
taskBudgets: HavenTaskBudgetSummary[];
|
|
833
|
+
/**
|
|
834
|
+
* #3506: the sub-budget rows THIS agent must still sign as the DELEGATING
|
|
835
|
+
* agent — the owner issued a sub-budget (a parent-child row for this agent
|
|
836
|
+
* plus a grant to the sub-agent), and each row is `pending` until this
|
|
837
|
+
* agent's delegate key signs it (or `closing` until it signs the close).
|
|
838
|
+
* A derived VIEW, populated from `GET /sub-budgets?status=awaiting_signature`;
|
|
839
|
+
* empty (never throws) against a backend that predates the filter.
|
|
840
|
+
*/
|
|
841
|
+
pendingSubBudgetSignatures: HavenPendingSubBudgetSignature[];
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* #3506: one sub-budget row awaiting THIS agent's signature — what
|
|
845
|
+
* `haven_get_agent` carries per row so the agent can call
|
|
846
|
+
* `haven_sign { sub_budget_id }` then `haven_submit { sub_budget_id, signature }`.
|
|
847
|
+
*/
|
|
848
|
+
interface HavenPendingSubBudgetSignature {
|
|
849
|
+
subBudgetId: string;
|
|
850
|
+
/** The parent-child row a grant hangs under; null on the parent-child row itself (they share a tree). */
|
|
851
|
+
parentSubBudgetId: string | null;
|
|
852
|
+
/** `open`: sign the child delegation (row is pending). `close`: sign the revocation (row is closing). */
|
|
853
|
+
purpose: 'open' | 'close';
|
|
854
|
+
/** `parent-child`: this agent's own narrowing of its budget. `grant`: the slice delegated to the sub-agent. */
|
|
855
|
+
what: 'parent-child' | 'grant';
|
|
856
|
+
/** The sub-agent that holds the grant; null on this agent's own parent-child row. */
|
|
857
|
+
subAgentId: string | null;
|
|
858
|
+
tokenAddress: string;
|
|
859
|
+
recipientAddress: string | null;
|
|
860
|
+
periodAmountAtomic: string;
|
|
861
|
+
expiresAt: number;
|
|
862
|
+
isExpired: boolean;
|
|
863
|
+
}
|
|
864
|
+
/** #3506: sub-budget lifecycle status, as the wire names it. */
|
|
865
|
+
type HavenSubBudgetStatus = 'pending' | 'open' | 'closing' | 'closed';
|
|
866
|
+
/** #3506: `RawSubBudget`, camelCased — what the SDK sub-budget methods return. */
|
|
867
|
+
interface HavenSubBudget {
|
|
868
|
+
id: string;
|
|
869
|
+
agentId: string;
|
|
870
|
+
parentAgentId: string;
|
|
871
|
+
parentSubBudgetId: string | null;
|
|
872
|
+
chainId: number;
|
|
873
|
+
tokenAddress: string;
|
|
874
|
+
recipientAddress: string | null;
|
|
875
|
+
parentDelegationHash: string;
|
|
876
|
+
delegationHash: string;
|
|
877
|
+
label: string | null;
|
|
878
|
+
periodAmountAtomic: string;
|
|
879
|
+
status: HavenSubBudgetStatus;
|
|
880
|
+
expiresAt: number;
|
|
881
|
+
isExpired: boolean;
|
|
882
|
+
createdAt: string;
|
|
883
|
+
openedAt: string | null;
|
|
884
|
+
closedAt: string | null;
|
|
885
|
+
closeTxHash: string | null;
|
|
886
|
+
}
|
|
887
|
+
/** #3506: `POST /sub-budgets/:id/submit` — opened (from pending) or closed (from closing). */
|
|
888
|
+
interface SubmitSubBudgetResult {
|
|
889
|
+
subBudget: HavenSubBudget;
|
|
890
|
+
status: 'open' | 'closed';
|
|
891
|
+
/** Present only once the close UserOp lands (`status === 'closed'` from `closing`). */
|
|
892
|
+
closeTxHash?: string;
|
|
893
|
+
}
|
|
894
|
+
/** #3506: the sign data a live-child close returns (the revocation UserOp's typed data). */
|
|
895
|
+
interface HavenSubBudgetCloseSignData {
|
|
896
|
+
signature_scheme: 'eip712_userop';
|
|
897
|
+
typed_data: Record<string, unknown>;
|
|
898
|
+
user_op_hash: string;
|
|
899
|
+
}
|
|
900
|
+
/** #3506: `POST /sub-budgets/:id/close`. */
|
|
901
|
+
interface CloseSubBudgetResult {
|
|
902
|
+
subBudget: HavenSubBudget;
|
|
903
|
+
/** `closed` on a trivial close (never signed, or already expired); absent when a close signature is pending. */
|
|
904
|
+
status?: 'closed';
|
|
905
|
+
/** Present only when the close needed a signature (a live child). */
|
|
906
|
+
signData?: HavenSubBudgetCloseSignData;
|
|
907
|
+
nextAction?: string;
|
|
755
908
|
}
|
|
756
909
|
/** #3329: task-budget lifecycle status, as the wire names it. */
|
|
757
910
|
type HavenTaskBudgetStatus = 'pending' | 'open' | 'closing' | 'closed';
|
|
@@ -766,6 +919,22 @@ interface HavenTaskBudget {
|
|
|
766
919
|
delegationHash: string;
|
|
767
920
|
label: string | null;
|
|
768
921
|
maxAtomic: string;
|
|
922
|
+
/**
|
|
923
|
+
* #3501: camelCase form of `spent_atomic` — the live enforcer figure.
|
|
924
|
+
* Present on GET reads of an open task budget; null when the read failed;
|
|
925
|
+
* absent when the response did not read the chain.
|
|
926
|
+
*/
|
|
927
|
+
spentAtomic?: string | null;
|
|
928
|
+
/**
|
|
929
|
+
* #3501: what the chain will still allow through this child (cap minus
|
|
930
|
+
* spent, clamped at zero). A failed read is null — never the full cap.
|
|
931
|
+
*/
|
|
932
|
+
remainingAtomic?: string | null;
|
|
933
|
+
/**
|
|
934
|
+
* #3501: provenance of `remainingAtomic`, the parent allowance's honesty
|
|
935
|
+
* flag (`onchain.remainingIsFromChain`, #1319) on the task-budget surface.
|
|
936
|
+
*/
|
|
937
|
+
remainingIsFromChain?: boolean;
|
|
769
938
|
status: HavenTaskBudgetStatus;
|
|
770
939
|
expiresAt: number;
|
|
771
940
|
isExpired: boolean;
|
|
@@ -778,6 +947,15 @@ interface HavenTaskBudget {
|
|
|
778
947
|
* #3329: the condensed row `getAgentSummary()` carries per open, unexpired
|
|
779
948
|
* task budget — enough to render a "reserved by open task budgets" line and
|
|
780
949
|
* a task-budget list without a second read.
|
|
950
|
+
*
|
|
951
|
+
* #3501: each row also carries the budget-visibility figure the issue asks
|
|
952
|
+
* for — what the chain will still allow through this child — so an agent
|
|
953
|
+
* reading `haven_get_agent` can tell BEFORE its next payment whether the
|
|
954
|
+
* task budget will refuse it. `remainingAtomic` is null when the on-chain
|
|
955
|
+
* read failed (never the full cap as remaining), and
|
|
956
|
+
* `remainingIsFromChain` is the same honesty flag the parent allowance's
|
|
957
|
+
* `onchain.remainingIsFromChain` carries (#1319): true = live enforcer
|
|
958
|
+
* read, false = the read failed and the figures are null.
|
|
781
959
|
*/
|
|
782
960
|
interface HavenTaskBudgetSummary {
|
|
783
961
|
id: string;
|
|
@@ -785,8 +963,55 @@ interface HavenTaskBudgetSummary {
|
|
|
785
963
|
tokenAddress: string;
|
|
786
964
|
maxAtomic: string;
|
|
787
965
|
maxDisplay: string;
|
|
966
|
+
/**
|
|
967
|
+
* #3501: spent so far through this child, from the enforcer's `spentMap`.
|
|
968
|
+
* Null when the on-chain read failed; also null for a budget whose
|
|
969
|
+
* delegation the read could not speak for.
|
|
970
|
+
*/
|
|
971
|
+
spentAtomic: string | null;
|
|
972
|
+
/**
|
|
973
|
+
* #3501: `maxAtomic` minus spent, clamped at zero. Null — never the full
|
|
974
|
+
* cap — when the on-chain read failed.
|
|
975
|
+
*/
|
|
976
|
+
remainingAtomic: string | null;
|
|
977
|
+
/**
|
|
978
|
+
* #3501: true when `remainingAtomic` came from the live enforcer read,
|
|
979
|
+
* false when that read failed (spent/remaining are then null).
|
|
980
|
+
*/
|
|
981
|
+
remainingIsFromChain: boolean;
|
|
982
|
+
/**
|
|
983
|
+
* #3501: human form of `remainingAtomic` ("0.001 USDC"), derived by the
|
|
984
|
+
* same formatter as `maxDisplay`. Null exactly when `remainingAtomic` is
|
|
985
|
+
* null — a failed read never renders as an amount.
|
|
986
|
+
*/
|
|
987
|
+
remainingDisplay: string | null;
|
|
788
988
|
recipientAddress: string | null;
|
|
789
989
|
expiresAt: number;
|
|
990
|
+
/**
|
|
991
|
+
* #3518: the budget's lifecycle status (`pending` | `open` | `closing` |
|
|
992
|
+
* `closed`) — `haven_get_agent` lists closing and pending budgets too (a
|
|
993
|
+
* close refusal says "re-check the budget's status", so the status must
|
|
994
|
+
* be readable there), and an agent that only ever saw open rows could
|
|
995
|
+
* not. Additive; undefined on a stale cached read from an older client
|
|
996
|
+
* build.
|
|
997
|
+
*/
|
|
998
|
+
status?: HavenTaskBudgetStatus;
|
|
999
|
+
isExpired?: boolean;
|
|
1000
|
+
}
|
|
1001
|
+
/**
|
|
1002
|
+
* `precheckBudget()`'s 200 answer. #3518: the `budget_*` fields name the
|
|
1003
|
+
* budget the compare ran against — the one the payment would draw on
|
|
1004
|
+
* (absent when no budget row matched the token).
|
|
1005
|
+
*/
|
|
1006
|
+
interface BudgetPrecheckResult {
|
|
1007
|
+
sufficient: boolean;
|
|
1008
|
+
remaining_atomic: string;
|
|
1009
|
+
remaining_is_from_chain?: boolean;
|
|
1010
|
+
replay?: boolean;
|
|
1011
|
+
budget_id?: string;
|
|
1012
|
+
budget_delegation_hash?: string;
|
|
1013
|
+
budget_recipient_address?: string | null;
|
|
1014
|
+
budget_merchant_id?: string | null;
|
|
790
1015
|
}
|
|
791
1016
|
/** #3329: `POST /task-budgets` and `POST /task-budgets/:id/close` — the sign-then-submit envelope. */
|
|
792
1017
|
interface HavenTaskBudgetSignData {
|
|
@@ -949,8 +1174,10 @@ interface HavenPaymentReceipt {
|
|
|
949
1174
|
/**
|
|
950
1175
|
* The delegate → merchant settlement transaction (#2998). Trust level differs
|
|
951
1176
|
* by scheme: on erc7710 it is `txHash` itself and Haven VERIFIED it on-chain
|
|
952
|
-
* before the receipt existed
|
|
953
|
-
* (
|
|
1177
|
+
* before the receipt existed. On eip3009 it is the settlement the agent
|
|
1178
|
+
* reported through `reportSettlementEvidence()` when there is one, which Haven
|
|
1179
|
+
* also VERIFIED on-chain (#3475); otherwise the merchant's claim as relayed
|
|
1180
|
+
* (PAYMENT-RESPONSE), NOT verified on-chain by Haven — cite that as such.
|
|
954
1181
|
*/
|
|
955
1182
|
settlementTxHash: string | null;
|
|
956
1183
|
chainId: number;
|
|
@@ -1487,6 +1714,38 @@ interface PaymentStatusResult {
|
|
|
1487
1714
|
* row records its response); absent = unknown. See the raw field's doc.
|
|
1488
1715
|
*/
|
|
1489
1716
|
delivered?: boolean;
|
|
1717
|
+
/**
|
|
1718
|
+
* #3475 follow-up: which settlement branch this x402 payment runs (#946).
|
|
1719
|
+
* `null` on the legacy rail, on any x402 intent whose scheme metadata
|
|
1720
|
+
* predates #946, or any stored value outside this enum.
|
|
1721
|
+
*/
|
|
1722
|
+
settlementScheme?: 'eip3009' | 'erc7710' | null;
|
|
1723
|
+
/**
|
|
1724
|
+
* #3475 follow-up: `true` only when an eip3009 payment's merchant
|
|
1725
|
+
* settlement transaction is already recorded and on-chain-verified.
|
|
1726
|
+
* Absent — never `false` — when unknown or on erc7710, matching
|
|
1727
|
+
* `delivered`'s own honesty rule.
|
|
1728
|
+
*/
|
|
1729
|
+
merchantSettlementRecorded?: boolean;
|
|
1730
|
+
/**
|
|
1731
|
+
* #3494: a bounded, redacted cause for a `failed` payment — present
|
|
1732
|
+
* (possibly `null`, when no message was recorded) only when `status` is
|
|
1733
|
+
* `'failed'`; absent on every other status.
|
|
1734
|
+
*/
|
|
1735
|
+
failureReason?: string | null;
|
|
1736
|
+
/**
|
|
1737
|
+
* #3518: the budget delegation that METERED this payment, recorded at
|
|
1738
|
+
* authorize (migration 053) — the settle summary's authoritative answer
|
|
1739
|
+
* to "which budget paid". Absent on the legacy rail and on rows
|
|
1740
|
+
* predating migration 053.
|
|
1741
|
+
*/
|
|
1742
|
+
budgetDelegationHash?: string;
|
|
1743
|
+
/**
|
|
1744
|
+
* #3564: `true` only while a payment's submit is receipt-unconfirmed and
|
|
1745
|
+
* not yet reconciled from the chain. Absent — never `false` — on every
|
|
1746
|
+
* other row, matching `delivered`'s own honesty rule.
|
|
1747
|
+
*/
|
|
1748
|
+
submissionOutcomePending?: true;
|
|
1490
1749
|
/** Platform fee surfaced so it's never silently collected (#386). */
|
|
1491
1750
|
fee?: PaymentFee | null;
|
|
1492
1751
|
amountAtomic?: string | null;
|
|
@@ -2033,7 +2292,7 @@ declare function buildSweepAuthorizationMessage(auth: SweepAuthorization): strin
|
|
|
2033
2292
|
* This SDK's own version. Owned by `scripts/release-bump.mjs`, which rewrites
|
|
2034
2293
|
* it with the package version on every release — never hand-edit it.
|
|
2035
2294
|
*/
|
|
2036
|
-
declare const SDK_VERSION = "0.
|
|
2295
|
+
declare const SDK_VERSION = "0.8.1-alpha.0";
|
|
2037
2296
|
/** The request header every published Haven client sends. */
|
|
2038
2297
|
declare const HAVEN_CLIENT_HEADER = "X-Haven-Client";
|
|
2039
2298
|
/** `<package>/<version>` — the value of {@link HAVEN_CLIENT_HEADER}. */
|
|
@@ -2620,7 +2879,7 @@ declare function encodePaymentProof(receipt: {
|
|
|
2620
2879
|
* Resolve a token symbol from a contract address.
|
|
2621
2880
|
*
|
|
2622
2881
|
* Checks all supported chains. For chain-specific resolution,
|
|
2623
|
-
* pass the optional `network` CAIP-2 string (e.g. "eip155:
|
|
2882
|
+
* pass the optional `network` CAIP-2 string (e.g. "eip155:8453").
|
|
2624
2883
|
*/
|
|
2625
2884
|
declare function resolveTokenFromAddress(address: string, network?: string): {
|
|
2626
2885
|
symbol: string;
|
|
@@ -2918,9 +3177,9 @@ declare class HavenTypedDataRefusedError extends HavenSigningError {
|
|
|
2918
3177
|
/**
|
|
2919
3178
|
* Chains the delegation rail has PINNED delegation contracts for
|
|
2920
3179
|
* (`packages/backend/src/rails/delegation-contracts.ts`) — the only chains a
|
|
2921
|
-
* direct-payment UserOp may be scoped to.
|
|
2922
|
-
* DelegationManager/enforcer set, so
|
|
2923
|
-
* the delegate account itself could exist
|
|
3180
|
+
* direct-payment UserOp may be scoped to. No other chain has a pinned
|
|
3181
|
+
* DelegationManager/enforcer set, so every other chain is deliberately
|
|
3182
|
+
* excluded even where the delegate account itself could exist.
|
|
2924
3183
|
*/
|
|
2925
3184
|
declare const DIRECT_PAYMENT_CHAIN_IDS: ReadonlySet<number>;
|
|
2926
3185
|
/** The DeleGator's single-execution `execute((address,uint256,bytes))` — selector `0x5c1c6dcd`. */
|
|
@@ -3135,4 +3394,4 @@ declare function encodeBase64Json(value: unknown): string;
|
|
|
3135
3394
|
*/
|
|
3136
3395
|
declare function decodeBase64Json<T>(value: string, label?: string): T;
|
|
3137
3396
|
|
|
3138
|
-
export {
|
|
3397
|
+
export { AgentPaymentFailureCodeSchema as $, type AgentPaymentWarning as A, type BudgetPrecheckResult as B, type CloseTaskBudgetResult as C, type X402Erc7710Settlement as D, type X402McpCallContext as E, type SignData as F, type ResumeAuthorizedX402Input as G, type HavenClientConfig as H, type ResumeX402PaymentInput as I, type X402ResumeState as J, type X402McpTransport as K, type X402MerchantCallContext as L, HavenError as M, AGENT_PAYMENT_FAILURE_CODE_VALUES as N, type OpenTaskBudgetResult as O, type PaymentRequest as P, AGENT_PAYMENT_NEXT_ACTION_VALUES as Q, type RawPaymentParties as R, type SweepResult as S, type TaskBudgetSignContext as T, AGENT_PAYMENT_PHASE_VALUES as U, AGENT_PAYMENT_RAIL_VALUES as V, type AgentNextStep as W, type X402PaymentRequired as X, type AgentPaymentEnumSchema as Y, AgentPaymentFailureCode as Z, AgentPaymentFailureCodeDescriptions as _, type HavenClientUpdate as a, SignerRefusalCode as a$, AgentPaymentNextAction as a0, AgentPaymentNextActionDescriptions as a1, AgentPaymentNextActionSchema as a2, AgentPaymentPhase as a3, AgentPaymentPhaseDescriptions as a4, AgentPaymentPhaseSchema as a5, AgentPaymentRail as a6, AgentPaymentRailDescriptions as a7, AgentPaymentRailSchema as a8, type AgentPaymentSummary as a9, HavenZeroSettlementHashError as aA, MAX_TASK_BUDGET_TTL_SECONDS as aB, type MachinePaymentRail as aC, MerchantTimeoutError as aD, NEXT_TOOL_SERVER_NAMES as aE, NEXT_TOOL_SERVER_ROLES as aF, type NextStep as aG, type NextStepArguments as aH, type NextStepHandoff as aI, type NextStepInput as aJ, type NextStepTarget as aK, type NextStepTargets as aL, type NextToolServerRole as aM, PACKED_USER_OPERATION_FIELDS as aN, type PaymentFee as aO, type PaymentNextAction as aP, type PaymentPhase as aQ, type PaymentStatus as aR, ROOT_AUTHORITY as aS, SDK_CLIENT_IDENTITY as aT, SDK_VERSION as aU, SIGNER_UPDATE_FALLBACK as aV, SWEEP_BASE_CHAIN_ID as aW, SWEEP_BASE_SEPOLIA_CHAIN_ID as aX, SWEEP_BASE_SEPOLIA_USDC_ADDRESS as aY, SWEEP_BASE_USDC_ADDRESS as aZ, type SettlementChildExpectation as a_, AgentPaymentWarningCode as aa, type AgentPurchaseSummary as ab, CONNECTOR_PACKAGE_NAME as ac, type CatalogSubmissionAccepted as ad, DEFAULT_CONFIRMATION_TIMEOUT_MS as ae, DEFAULT_NEXT_TOOL_BY_ACTION as af, DIRECT_SIGN_CONTEXT_VERSION as ag, ENTRY_POINT_V07 as ah, ERC7710_ASSET_TRANSFER_METHOD as ai, HAVEN_CLIENT_HEADER as aj, HAVEN_CONNECTOR_CHANNEL as ak, HAVEN_MINIMUM_NODE_VERSION as al, HYBRID_DELEGATOR_DOMAIN_NAME as am, HYBRID_DELEGATOR_DOMAIN_VERSION as an, type HavenAgentAllowanceSummary as ao, type HavenAgentReadiness as ap, type HavenAllowance as aq, HavenApiError as ar, type HavenCatalogMerchant as as, type HavenListScope as at, HavenPaymentStateError as au, HavenSigningError as av, HavenTimeoutError as aw, HavenTypedDataRefusedError as ax, HavenUnsupportedSignerVersionError as ay, HavenUserOpBindingError as az, type PaymentResult as b, parsePaymentRequiredResponse as b$, type SweepConfirmation as b0, type SweepEip712Domain as b1, type SweepEntry as b2, type SweepExpectedAuth as b3, type SweepPreparation as b4, type SweepSubmitResult as b5, type SweepTypedData as b6, TASK_SIGN_CONTEXT_VERSION as b7, TRANSFER_WITH_AUTHORIZATION_TYPES as b8, TYPED_DATA_NOT_ALLOWED as b9, buildSweepAuthorizationMessage as bA, buildSweepTypedData as bB, buildX402ExpectedMessage as bC, compareNodeVersions as bD, connectorRerunCommand as bE, connectorSpec as bF, connectorUpgradeCommand as bG, createNextStepBuilder as bH, decodeBase64Json as bI, decodeBase64Utf8 as bJ, defaultNextToolFor as bK, deriveDelegateAccountAddress as bL, encodeBase64Json as bM, encodeBase64Utf8 as bN, encodePaymentProof as bO, hashDelegation as bP, havenClientIdentity as bQ, isConnectorChannel as bR, isErc7710Option as bS, isPackedUserOperationTypedData as bT, isSupportedNodeVersion as bU, isSweepableChain as bV, isTaskChildTypedData as bW, normalizePaymentRequired as bX, packedUserOperationHash as bY, parseNextTool as bZ, parsePaymentRequired as b_, type TaskBudgetCloseExpectation as ba, type TaskChildExpectation as bb, type TaskChildTypedData as bc, type UnsupportedNodeVersionMessageOptions as bd, X402AlreadySettledError as be, X402Erc7710AlreadySettledError as bf, type X402ExpectedAuth as bg, type X402ExpectedContext as bh, type X402PaymentHeaderContext as bi, X402PaymentHeaderValidationError as bj, type X402PaymentOption as bk, type X402RequestSnapshot as bl, type X402SchemeSelection as bm, X402TaskBudgetMismatchError as bn, X402UnexpectedStatusError as bo, X402_LEGACY_PAYMENT_HEADER_NAME as bp, X402_MAX_AUTHORIZATION_WINDOW_SECONDS as bq, X402_PAYMENT_HEADER_NAME as br, X402_PAYMENT_HEADER_NAMES_SENT as bs, X402_PAYMENT_REQUIRED_HEADER_NAME as bt, X402_PAYMENT_RESPONSE_HEADER_NAME as bu, X402_SETTLEMENT_FORWARD_MARGIN_SECONDS as bv, assertBoundDirectPaymentUserOp as bw, assertOwnTaskBudgetCloseUserOp as bx, assertOwnTaskChild as by, assertUserOpTypedDataBinding as bz, type PaymentIntent as c, readClientUpdate as c0, renderNextTool as c1, resolveConnectorChannel as c2, resolveTokenBySymbol as c3, resolveTokenFromAddress as c4, selectErc7710PaymentOption as c5, selectPaymentOption as c6, selectStandardPaymentOption as c7, selectX402SettlementScheme as c8, signerUpdateFallback as c9, sweepUsdcAddress as ca, sweepUsdcDomain as cb, toStandardPaymentRequirements as cc, unsupportedNodeVersionMessage as cd, validateStandardX402PaymentHeader as ce, verifySettlementChild as cf, x402AssetTransferMethod as cg, x402AuthorizationAmount as ch, x402FacilitatorAddresses as ci, x402V2PaymentEnvelope as cj, type DelegationForHashing as ck, CAVEAT_ENFORCERS as cl, CAVEAT_TYPEHASH as cm, DELEGATION_MANAGER as cn, DELEGATION_TYPEHASH as co, DIRECT_PAYMENT_CHAIN_IDS as cp, EXECUTE_ABI as cq, HYBRID_DELEGATOR_IMPLEMENTATION as cr, MAX_SETTLEMENT_WINDOW_SECONDS as cs, SIMPLE_FACTORY_ADDRESS as ct, type SettlementChildTypedData as cu, assertFundingLegPaysDelegate as cv, assertOwnSettlementChild as cw, chainIdForNetwork as cx, isSettlementChildTypedData as cy, 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 SubmitSubBudgetResult as u, type HavenPendingSubBudgetSignature as v, type CloseSubBudgetResult as w, type PaymentResumeState as x, type X402Receipt as y, type X402Quote as z };
|