@haven_ai/sdk 0.10.0-alpha.0 → 0.12.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 +45 -9
- package/dist/{base64-CiR5BJhk.d.cts → base64-C5OrJLij.d.ts} +10 -2
- package/dist/{base64-CxkinHPQ.d.ts → base64-COaV1Sis.d.cts} +10 -2
- package/dist/{chunk-6LEXYQ7J.cjs → chunk-4JTLJVBS.cjs} +4 -4
- package/dist/chunk-4JTLJVBS.cjs.map +1 -0
- package/dist/{chunk-MLUWABVT.js → chunk-7M3CIW7W.js} +7 -6
- package/dist/chunk-7M3CIW7W.js.map +1 -0
- package/dist/{chunk-TD2PHUYP.js → chunk-UPEDQLAL.js} +72 -6
- package/dist/chunk-UPEDQLAL.js.map +1 -0
- package/dist/{chunk-22FJ4JQO.cjs → chunk-V2ODMLDD.cjs} +38 -37
- package/dist/chunk-V2ODMLDD.cjs.map +1 -0
- package/dist/{chunk-EWTHDEIW.js → chunk-WFTGZS24.js} +3 -3
- package/dist/chunk-WFTGZS24.js.map +1 -0
- package/dist/{chunk-H37YVYZA.cjs → chunk-ZA3NOSO2.cjs} +73 -5
- package/dist/chunk-ZA3NOSO2.cjs.map +1 -0
- package/dist/edge.cjs +93 -93
- package/dist/edge.d.cts +11 -8
- package/dist/edge.d.ts +11 -8
- package/dist/edge.js +4 -4
- package/dist/index.cjs +866 -475
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -33
- package/dist/index.d.ts +69 -33
- package/dist/index.js +554 -171
- package/dist/index.js.map +1 -1
- package/dist/{receipt-q7ez8Zb2.d.cts → receipt-Dy77vCea.d.cts} +5 -4
- package/dist/{receipt-Cg9a5Seq.d.ts → receipt-DyUInpvF.d.ts} +5 -4
- package/dist/test-support.cjs +21 -21
- package/dist/test-support.d.cts +2 -2
- package/dist/test-support.d.ts +2 -2
- package/dist/test-support.js +2 -2
- package/dist/{types-BKgqzvnk.d.ts → types-CAvsjRKi.d.cts} +209 -12
- package/dist/{types-BKgqzvnk.d.cts → types-CAvsjRKi.d.ts} +209 -12
- package/package.json +1 -1
- package/dist/chunk-22FJ4JQO.cjs.map +0 -1
- package/dist/chunk-6LEXYQ7J.cjs.map +0 -1
- package/dist/chunk-EWTHDEIW.js.map +0 -1
- package/dist/chunk-H37YVYZA.cjs.map +0 -1
- package/dist/chunk-MLUWABVT.js.map +0 -1
- package/dist/chunk-TD2PHUYP.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aZ as RawPaymentParties } from './types-CAvsjRKi.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Verifiable payment receipts.
|
|
@@ -56,7 +56,7 @@ interface PaymentReceipt {
|
|
|
56
56
|
* #2960: one party vocabulary for "who paid", additive alongside `account`
|
|
57
57
|
* above (which is `parties.treasury_account` only). Optional: a server
|
|
58
58
|
* from before #2960 emits neither. Ignored by `verifyPaymentReceipt`,
|
|
59
|
-
* which reads only `authorization`.
|
|
59
|
+
* which reads only the bundle's `authorization` and `onChain.chainId`.
|
|
60
60
|
*/
|
|
61
61
|
parties?: RawPaymentParties;
|
|
62
62
|
chainId: number;
|
|
@@ -67,8 +67,9 @@ interface PaymentReceipt {
|
|
|
67
67
|
* merchant DELIVERED (`ok` / `unusable` / `partial`, plus a bounded
|
|
68
68
|
* note). Additive and OPTIONAL: a server from before #3770 emits
|
|
69
69
|
* neither, and `null` means the agent has not reported. Ignored by
|
|
70
|
-
* `verifyPaymentReceipt`, which reads only `authorization`
|
|
71
|
-
* rule `parties` follows. Evidence
|
|
70
|
+
* `verifyPaymentReceipt`, which reads only the bundle's `authorization`
|
|
71
|
+
* and `onChain.chainId` — the same rule `parties` follows. Evidence
|
|
72
|
+
* only: it never changes what the
|
|
72
73
|
* payment itself is, and `settled`/amounts are untouched by a report.
|
|
73
74
|
*/
|
|
74
75
|
deliveryQuality?: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aZ as RawPaymentParties } from './types-CAvsjRKi.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Verifiable payment receipts.
|
|
@@ -56,7 +56,7 @@ interface PaymentReceipt {
|
|
|
56
56
|
* #2960: one party vocabulary for "who paid", additive alongside `account`
|
|
57
57
|
* above (which is `parties.treasury_account` only). Optional: a server
|
|
58
58
|
* from before #2960 emits neither. Ignored by `verifyPaymentReceipt`,
|
|
59
|
-
* which reads only `authorization`.
|
|
59
|
+
* which reads only the bundle's `authorization` and `onChain.chainId`.
|
|
60
60
|
*/
|
|
61
61
|
parties?: RawPaymentParties;
|
|
62
62
|
chainId: number;
|
|
@@ -67,8 +67,9 @@ interface PaymentReceipt {
|
|
|
67
67
|
* merchant DELIVERED (`ok` / `unusable` / `partial`, plus a bounded
|
|
68
68
|
* note). Additive and OPTIONAL: a server from before #3770 emits
|
|
69
69
|
* neither, and `null` means the agent has not reported. Ignored by
|
|
70
|
-
* `verifyPaymentReceipt`, which reads only `authorization`
|
|
71
|
-
* rule `parties` follows. Evidence
|
|
70
|
+
* `verifyPaymentReceipt`, which reads only the bundle's `authorization`
|
|
71
|
+
* and `onChain.chainId` — the same rule `parties` follows. Evidence
|
|
72
|
+
* only: it never changes what the
|
|
72
73
|
* payment itself is, and `settled`/amounts are untouched by a report.
|
|
73
74
|
*/
|
|
74
75
|
deliveryQuality?: {
|
package/dist/test-support.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk4JTLJVBS_cjs = require('./chunk-4JTLJVBS.cjs');
|
|
4
|
+
var chunkZA3NOSO2_cjs = require('./chunk-ZA3NOSO2.cjs');
|
|
5
5
|
var viem = require('viem');
|
|
6
6
|
var ethers = require('ethers');
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ var ZERO_BYTES32 = `0x${"00".repeat(32)}`;
|
|
|
9
9
|
var ROOT_AUTHORITY = `0x${"ff".repeat(32)}`;
|
|
10
10
|
var DEFAULT_DELEGATOR = "0x98989898989898989898989898989898989898De";
|
|
11
11
|
var DELEGATION_ARRAY_PARAM = [
|
|
12
|
-
{ type: "tuple[]", components:
|
|
12
|
+
{ type: "tuple[]", components: chunkZA3NOSO2_cjs.DELEGATION_TUPLE_COMPONENTS }
|
|
13
13
|
];
|
|
14
14
|
var EXECUTE_ABI = [
|
|
15
15
|
{
|
|
@@ -85,16 +85,16 @@ function buildBoundRedeemDelegationsCallData(options) {
|
|
|
85
85
|
10000n
|
|
86
86
|
);
|
|
87
87
|
return viem.encodeFunctionData({
|
|
88
|
-
abi:
|
|
88
|
+
abi: chunkZA3NOSO2_cjs.REDEEM_DELEGATIONS_ABI,
|
|
89
89
|
functionName: "redeemDelegations",
|
|
90
|
-
args: [[permissionContext], [
|
|
90
|
+
args: [[permissionContext], [chunkZA3NOSO2_cjs.SINGLE_DEFAULT_MODE], [executionCallData]]
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
function buildEmptyPermissionContextRedemption(selfCallCallData) {
|
|
94
94
|
return viem.encodeFunctionData({
|
|
95
|
-
abi:
|
|
95
|
+
abi: chunkZA3NOSO2_cjs.REDEEM_DELEGATIONS_ABI,
|
|
96
96
|
functionName: "redeemDelegations",
|
|
97
|
-
args: [[buildEmptyPermissionContext()], [
|
|
97
|
+
args: [[buildEmptyPermissionContext()], [chunkZA3NOSO2_cjs.SINGLE_DEFAULT_MODE], [selfCallCallData]]
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
function buildExecuteCallData(target, value, innerCallData) {
|
|
@@ -106,20 +106,20 @@ function buildExecuteCallData(target, value, innerCallData) {
|
|
|
106
106
|
}
|
|
107
107
|
function buildBoundDirectUserOp(options) {
|
|
108
108
|
const chainId = options.chainId ?? 84532;
|
|
109
|
-
const sender = options.sender ??
|
|
109
|
+
const sender = options.sender ?? chunkZA3NOSO2_cjs.deriveDelegateAccountAddress(options.delegate);
|
|
110
110
|
const callData = options.callData ?? buildExecuteCallData(
|
|
111
|
-
options.target ??
|
|
111
|
+
options.target ?? chunkZA3NOSO2_cjs.DELEGATION_MANAGER,
|
|
112
112
|
options.value ?? 0n,
|
|
113
113
|
buildBoundRedeemDelegationsCallData({ delegate: sender, delegator: options.delegator })
|
|
114
114
|
);
|
|
115
115
|
const typedData = {
|
|
116
116
|
domain: {
|
|
117
|
-
name:
|
|
118
|
-
version:
|
|
117
|
+
name: chunkZA3NOSO2_cjs.HYBRID_DELEGATOR_DOMAIN_NAME,
|
|
118
|
+
version: chunkZA3NOSO2_cjs.HYBRID_DELEGATOR_DOMAIN_VERSION,
|
|
119
119
|
chainId,
|
|
120
120
|
verifyingContract: sender
|
|
121
121
|
},
|
|
122
|
-
types: { PackedUserOperation:
|
|
122
|
+
types: { PackedUserOperation: chunkZA3NOSO2_cjs.PACKED_USER_OPERATION_FIELDS.map((field) => ({ ...field })) },
|
|
123
123
|
primaryType: "PackedUserOperation",
|
|
124
124
|
message: {
|
|
125
125
|
sender,
|
|
@@ -130,10 +130,10 @@ function buildBoundDirectUserOp(options) {
|
|
|
130
130
|
preVerificationGas: "0",
|
|
131
131
|
gasFees: ZERO_BYTES32,
|
|
132
132
|
paymasterAndData: "0x",
|
|
133
|
-
entryPoint:
|
|
133
|
+
entryPoint: chunkZA3NOSO2_cjs.ENTRY_POINT_V07
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
-
const payloadHash =
|
|
136
|
+
const payloadHash = chunkZA3NOSO2_cjs.packedUserOperationHash(typedData);
|
|
137
137
|
return { typedData, payloadHash, sender };
|
|
138
138
|
}
|
|
139
139
|
function buildSelfCallCallData(sender) {
|
|
@@ -151,7 +151,7 @@ function rebuildDirectUserOpForSender(fixtureTypedData, newSender) {
|
|
|
151
151
|
const originalCallData = fixtureTypedData.message.callData;
|
|
152
152
|
const { args: executeArgs } = viem.decodeFunctionData({ abi: EXECUTE_ABI, data: originalCallData });
|
|
153
153
|
const execution = executeArgs[0];
|
|
154
|
-
const { args: redeemArgs } = viem.decodeFunctionData({ abi:
|
|
154
|
+
const { args: redeemArgs } = viem.decodeFunctionData({ abi: chunkZA3NOSO2_cjs.REDEEM_DELEGATIONS_ABI, data: execution.callData });
|
|
155
155
|
const [permissionContexts, modes, executionCallDatas] = redeemArgs;
|
|
156
156
|
const [delegations] = viem.decodeAbiParameters(DELEGATION_ARRAY_PARAM, permissionContexts[0]);
|
|
157
157
|
const adjustedDelegations = delegations.map(
|
|
@@ -159,7 +159,7 @@ function rebuildDirectUserOpForSender(fixtureTypedData, newSender) {
|
|
|
159
159
|
);
|
|
160
160
|
const adjustedPermissionContext = viem.encodeAbiParameters(DELEGATION_ARRAY_PARAM, [adjustedDelegations]);
|
|
161
161
|
const adjustedRedeemCallData = viem.encodeFunctionData({
|
|
162
|
-
abi:
|
|
162
|
+
abi: chunkZA3NOSO2_cjs.REDEEM_DELEGATIONS_ABI,
|
|
163
163
|
functionName: "redeemDelegations",
|
|
164
164
|
args: [[adjustedPermissionContext], modes, executionCallDatas]
|
|
165
165
|
});
|
|
@@ -173,13 +173,13 @@ function rebuildDirectUserOpForSender(fixtureTypedData, newSender) {
|
|
|
173
173
|
domain: { ...fixtureTypedData.domain, verifyingContract: newSender },
|
|
174
174
|
message: { ...fixtureTypedData.message, sender: newSender, callData: adjustedCallData }
|
|
175
175
|
};
|
|
176
|
-
const payloadHash =
|
|
176
|
+
const payloadHash = chunkZA3NOSO2_cjs.packedUserOperationHash(typedData);
|
|
177
177
|
return { typedData, payloadHash };
|
|
178
178
|
}
|
|
179
179
|
function buildFundingLegUserOp(options) {
|
|
180
|
-
const sender =
|
|
180
|
+
const sender = chunkZA3NOSO2_cjs.deriveDelegateAccountAddress(options.delegate);
|
|
181
181
|
const callData = buildExecuteCallData(
|
|
182
|
-
|
|
182
|
+
chunkZA3NOSO2_cjs.DELEGATION_MANAGER,
|
|
183
183
|
0n,
|
|
184
184
|
buildBoundRedeemDelegationsCallData({
|
|
185
185
|
delegate: sender,
|
|
@@ -212,7 +212,7 @@ function delegationDigest(signHash, chainId) {
|
|
|
212
212
|
viem.keccak256(viem.toBytes("DelegationManager")),
|
|
213
213
|
viem.keccak256(viem.toBytes("1")),
|
|
214
214
|
BigInt(chainId),
|
|
215
|
-
|
|
215
|
+
chunkZA3NOSO2_cjs.DELEGATION_MANAGER
|
|
216
216
|
]
|
|
217
217
|
)
|
|
218
218
|
);
|
|
@@ -224,7 +224,7 @@ function signedErc7710Receipt(options = {}) {
|
|
|
224
224
|
const delegate = new ethers.Wallet(options.delegateKey ?? RECEIPT_DELEGATE_KEY);
|
|
225
225
|
const signature = delegate.signingKey.sign(delegationDigest(signHash, chainId)).serialized;
|
|
226
226
|
return {
|
|
227
|
-
version:
|
|
227
|
+
version: chunk4JTLJVBS_cjs.RECEIPT_VERSION,
|
|
228
228
|
paymentId: options.paymentId ?? "pay_3723",
|
|
229
229
|
payment: {
|
|
230
230
|
token: "USDC",
|
package/dist/test-support.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Address, Hex } from 'viem';
|
|
2
|
-
import { P as PaymentReceipt } from './receipt-
|
|
3
|
-
import './types-
|
|
2
|
+
import { P as PaymentReceipt } from './receipt-Dy77vCea.cjs';
|
|
3
|
+
import './types-CAvsjRKi.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* #3272 — a real-shaped, BOUND direct-payment `PackedUserOperation` for
|
package/dist/test-support.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Address, Hex } from 'viem';
|
|
2
|
-
import { P as PaymentReceipt } from './receipt-
|
|
3
|
-
import './types-
|
|
2
|
+
import { P as PaymentReceipt } from './receipt-DyUInpvF.js';
|
|
3
|
+
import './types-CAvsjRKi.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* #3272 — a real-shaped, BOUND direct-payment `PackedUserOperation` for
|
package/dist/test-support.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RECEIPT_VERSION } from './chunk-
|
|
2
|
-
import { DELEGATION_TUPLE_COMPONENTS, SINGLE_DEFAULT_MODE, REDEEM_DELEGATIONS_ABI, deriveDelegateAccountAddress, DELEGATION_MANAGER, PACKED_USER_OPERATION_FIELDS, packedUserOperationHash, ENTRY_POINT_V07, HYBRID_DELEGATOR_DOMAIN_VERSION, HYBRID_DELEGATOR_DOMAIN_NAME } from './chunk-
|
|
1
|
+
import { RECEIPT_VERSION } from './chunk-WFTGZS24.js';
|
|
2
|
+
import { DELEGATION_TUPLE_COMPONENTS, SINGLE_DEFAULT_MODE, REDEEM_DELEGATIONS_ABI, deriveDelegateAccountAddress, DELEGATION_MANAGER, PACKED_USER_OPERATION_FIELDS, packedUserOperationHash, ENTRY_POINT_V07, HYBRID_DELEGATOR_DOMAIN_VERSION, HYBRID_DELEGATOR_DOMAIN_NAME } from './chunk-UPEDQLAL.js';
|
|
3
3
|
import { keccak256, toBytes, encodeAbiParameters, encodePacked, encodeFunctionData, decodeFunctionData, decodeAbiParameters, hashTypedData, concatHex } from 'viem';
|
|
4
4
|
import { Wallet } from 'ethers';
|
|
5
5
|
|
|
@@ -14,9 +14,14 @@
|
|
|
14
14
|
* it is a string check. A public host name whose DNS ANSWER points at
|
|
15
15
|
* private space is NOT blocked here — that needs the resolution-time
|
|
16
16
|
* checks parked in #3742–#3744 (owner-accepted residual, 2026-10-07).
|
|
17
|
-
* - Without `merchantEgress
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* - Without `merchantEgress` there is no URL check, no body capping and no
|
|
18
|
+
* per-use budget. Redirects are still followed by the transport (#4257),
|
|
19
|
+
* under the platform's rules (20 hops, the Fetch spec's method/body
|
|
20
|
+
* rewrite), plus the one rule both paths share: a hop to another origin
|
|
21
|
+
* carries only the cross-origin header allow-list. A paid request (the
|
|
22
|
+
* delivery, or a body with an x402 payment in `_meta`) is never re-sent
|
|
23
|
+
* to another origin by a redirect that keeps the body (307/308, or 301/302
|
|
24
|
+
* on a method other than POST); any other request follows as before.
|
|
20
25
|
* - The policy is network policy, not spend control. It never gates a
|
|
21
26
|
* payment's authority — the on-chain allowance stays the real control
|
|
22
27
|
* (CASP: off-chain policy is never the spend control).
|
|
@@ -48,7 +53,10 @@ interface MerchantEgressPolicy {
|
|
|
48
53
|
/**
|
|
49
54
|
* How many GET redirects may be followed; EVERY hop is re-asserted against
|
|
50
55
|
* `assertUrl` before it connects. A redirect on any other method is
|
|
51
|
-
* refused outright.
|
|
56
|
+
* refused outright. A hop to a different origin carries only the
|
|
57
|
+
* transport's cross-origin header allow-list (#4244): credentials and other
|
|
58
|
+
* caller headers stay with the origin they were sent to.
|
|
59
|
+
* `undefined` = no redirect following.
|
|
52
60
|
*/
|
|
53
61
|
maxGetRedirects?: number;
|
|
54
62
|
/** Per-use timeouts (ms). The effective deadline is `min(this, merchantTimeout)`. */
|
|
@@ -59,7 +67,14 @@ interface MerchantEgressPolicy {
|
|
|
59
67
|
*/
|
|
60
68
|
responseByteCaps?: Partial<Record<MerchantEgressUse, number>>;
|
|
61
69
|
}
|
|
62
|
-
type MerchantEgressRefusalReason = 'url_not_allowed' | 'redirect_on_non_get' | 'redirect_missing_location' | 'redirect_invalid_location' | 'redirect_budget_exceeded'
|
|
70
|
+
type MerchantEgressRefusalReason = 'url_not_allowed' | 'redirect_on_non_get' | 'redirect_missing_location' | 'redirect_invalid_location' | 'redirect_budget_exceeded'
|
|
71
|
+
/**
|
|
72
|
+
* #4257: a redirect that keeps the body (307/308, or 301/302 on a method
|
|
73
|
+
* other than POST) would re-send it to another origin. Under a
|
|
74
|
+
* policy (GET only) this is unreachable; without one it fires for a paid
|
|
75
|
+
* delivery, or a body carrying an x402 payment in `_meta`.
|
|
76
|
+
*/
|
|
77
|
+
| 'redirect_cross_origin_body';
|
|
63
78
|
declare const MERCHANT_EGRESS_REFUSED_CODE = "MERCHANT_EGRESS_REFUSED";
|
|
64
79
|
/**
|
|
65
80
|
* The policy refused a merchant request. `beforeRequest` is true when the
|
|
@@ -73,7 +88,27 @@ declare class MerchantEgressRefusedError extends HavenError {
|
|
|
73
88
|
readonly url: string;
|
|
74
89
|
readonly refusal: MerchantEgressRefusalReason;
|
|
75
90
|
readonly beforeRequest: boolean;
|
|
76
|
-
|
|
91
|
+
/** #4257: the redirect status that was not followed, when a redirect was refused. */
|
|
92
|
+
readonly redirectStatus?: number;
|
|
93
|
+
/**
|
|
94
|
+
* #4257: set only when `url` IS the redirect target (a cross-origin body
|
|
95
|
+
* re-send, a spent hop budget, a hop `assertUrl` refused). A refusal that
|
|
96
|
+
* stopped at the answering URL itself (a non-GET redirect, a missing or
|
|
97
|
+
* unresolvable Location) leaves it unset, and `url` is that answering URL.
|
|
98
|
+
*/
|
|
99
|
+
readonly redirectTarget?: string;
|
|
100
|
+
/**
|
|
101
|
+
* #4257: set when the refusal interrupted a PAID delivery and the local
|
|
102
|
+
* completion has re-thrown it with the payment it belongs to — the funded,
|
|
103
|
+
* undelivered state, never "nothing happened".
|
|
104
|
+
*/
|
|
105
|
+
readonly settlementScheme?: 'eip3009' | 'erc7710';
|
|
106
|
+
constructor(message: string, url: string, refusal: MerchantEgressRefusalReason, beforeRequest: boolean, extra?: {
|
|
107
|
+
redirectStatus?: number;
|
|
108
|
+
redirectTarget?: string;
|
|
109
|
+
paymentId?: string;
|
|
110
|
+
settlementScheme?: 'eip3009' | 'erc7710';
|
|
111
|
+
});
|
|
77
112
|
}
|
|
78
113
|
declare const MERCHANT_EGRESS_RESPONSE_CAP_CODE = "MERCHANT_EGRESS_RESPONSE_CAP";
|
|
79
114
|
/**
|
|
@@ -752,6 +787,14 @@ interface HavenAllowance {
|
|
|
752
787
|
* compared alone — they do not add up. Never a balance figure.
|
|
753
788
|
*/
|
|
754
789
|
fundsCoverRemaining: boolean | null;
|
|
790
|
+
/**
|
|
791
|
+
* #4355: when THIS budget next refills — the end of its current period
|
|
792
|
+
* (ISO 8601), or its start for a budget not yet started. `null` when it
|
|
793
|
+
* never refills again (it ends first), and on a backend that predates the
|
|
794
|
+
* field. With a remaining of 0 it says the budget is spent for this period
|
|
795
|
+
* and when it comes back — not that nobody approved one.
|
|
796
|
+
*/
|
|
797
|
+
nextRefillAt: string | null;
|
|
755
798
|
/**
|
|
756
799
|
* #3518: this budget's SCOPE, so an agent holding more than one budget
|
|
757
800
|
* for a token can name the merchant-locked one before paying. The
|
|
@@ -806,6 +849,14 @@ interface HavenAllowanceSummary {
|
|
|
806
849
|
delegateAddress: string;
|
|
807
850
|
chainId: number;
|
|
808
851
|
allowances: HavenAllowance[];
|
|
852
|
+
/**
|
|
853
|
+
* #4352 (additive, decision 5): when the agent's only budgets for this
|
|
854
|
+
* chain have ENDED, the latest ended budget's expiry (ISO 8601) — read by
|
|
855
|
+
* the same narrow expired-row query the refusal answers use. `null` when no
|
|
856
|
+
* expired row exists; the field NEVER reports a live budget. `null` on a
|
|
857
|
+
* backend that predates the field.
|
|
858
|
+
*/
|
|
859
|
+
budgetEndedAt: string | null;
|
|
809
860
|
/** #3772: see {@link HavenAgent.supersededBy}. */
|
|
810
861
|
supersededBy: HavenAgentSupersession | null;
|
|
811
862
|
}
|
|
@@ -1005,6 +1056,8 @@ interface HavenAgentAllowanceSummary {
|
|
|
1005
1056
|
* read: any non-boolean wire value maps to `null`, never `undefined`.
|
|
1006
1057
|
*/
|
|
1007
1058
|
fundsCoverRemaining: boolean | null;
|
|
1059
|
+
/** #4355: the {@link HavenAllowance.nextRefillAt} projection. */
|
|
1060
|
+
nextRefillAt: string | null;
|
|
1008
1061
|
}
|
|
1009
1062
|
/**
|
|
1010
1063
|
* One-shot "am I ready?" bootstrap: identity + live spend authority + a
|
|
@@ -1028,6 +1081,27 @@ interface HavenAgentSummary extends HavenAgent {
|
|
|
1028
1081
|
* renders from `HAVEN_CONNECTOR_CHANNEL` — see `connector-channel.ts`).
|
|
1029
1082
|
*/
|
|
1030
1083
|
spend_authority_readiness: HavenAgentReadiness;
|
|
1084
|
+
/**
|
|
1085
|
+
* #4355 (additive; the readiness values are unchanged — #4349 decision 5):
|
|
1086
|
+
* set only when readiness is `needs_approval` BECAUSE every live budget is
|
|
1087
|
+
* spent for its period — `allowances[]` has rows, all at remaining 0. It is
|
|
1088
|
+
* the earliest {@link HavenAgentAllowanceSummary.nextRefillAt} among them:
|
|
1089
|
+
* wait until then, or ask the owner to raise the budget. `null` otherwise:
|
|
1090
|
+
* ready, revoked, no budget approved (`allowances[]` empty), or a spent
|
|
1091
|
+
* budget that ends before it would refill.
|
|
1092
|
+
*/
|
|
1093
|
+
budgetRefillsAt: string | null;
|
|
1094
|
+
/**
|
|
1095
|
+
* #4352 (additive; the readiness values are unchanged — #4349 decision 5):
|
|
1096
|
+
* set only when readiness is `needs_approval` BECAUSE the agent's only
|
|
1097
|
+
* budget(s) have ENDED — `allowances[]` is empty and the server's
|
|
1098
|
+
* expired-row read found one. The ended budget's expiry (ISO 8601): waiting
|
|
1099
|
+
* will not help; ask the owner to set a new one. `null` otherwise — ready,
|
|
1100
|
+
* revoked, no budget approved at all, live rows present (whether spendable
|
|
1101
|
+
* or all spent — the latter is {@link HavenAgentSummary.budgetRefillsAt}'s
|
|
1102
|
+
* case), or a backend that predates the field.
|
|
1103
|
+
*/
|
|
1104
|
+
budgetEndedAt: string | null;
|
|
1031
1105
|
allowances: HavenAgentAllowanceSummary[];
|
|
1032
1106
|
/**
|
|
1033
1107
|
* #3329: open, unexpired task budgets — a derived VIEW, same discipline as
|
|
@@ -1107,9 +1181,9 @@ interface HavenSubBudgetCloseSignData {
|
|
|
1107
1181
|
/** #3506: `POST /sub-budgets/:id/close`. */
|
|
1108
1182
|
interface CloseSubBudgetResult {
|
|
1109
1183
|
subBudget: HavenSubBudget;
|
|
1110
|
-
/** `closed` on a trivial close (never signed, or already expired); absent when a close signature is pending. */
|
|
1184
|
+
/** `closed` on a trivial close (never signed, or `open` and already expired) or when the chain already shows it disabled; absent when a close signature is pending. */
|
|
1111
1185
|
status?: 'closed';
|
|
1112
|
-
/** Present only when the close needed a signature (a live child). */
|
|
1186
|
+
/** Present only when the close needed a signature (a live child, or any `closing` row — #3923). */
|
|
1113
1187
|
signData?: HavenSubBudgetCloseSignData;
|
|
1114
1188
|
nextAction?: string;
|
|
1115
1189
|
}
|
|
@@ -1145,6 +1219,8 @@ interface HavenTaskBudget {
|
|
|
1145
1219
|
status: HavenTaskBudgetStatus;
|
|
1146
1220
|
expiresAt: number;
|
|
1147
1221
|
isExpired: boolean;
|
|
1222
|
+
/** #3922: camelCase `is_live`; absent when the backend predates it (presence preserved). */
|
|
1223
|
+
isLive?: boolean;
|
|
1148
1224
|
createdAt: string;
|
|
1149
1225
|
openedAt: string | null;
|
|
1150
1226
|
closedAt: string | null;
|
|
@@ -1352,6 +1428,23 @@ interface HavenPaymentReceipt {
|
|
|
1352
1428
|
paymentId: string;
|
|
1353
1429
|
paymentIntentId?: string | null;
|
|
1354
1430
|
approvalRequestId?: string | null;
|
|
1431
|
+
/**
|
|
1432
|
+
* #4469: which settlement branch moved the money (`eip3009` | `erc7710`),
|
|
1433
|
+
* from the intent (#946). The receipts wire declares this as raw text with
|
|
1434
|
+
* no enum (`packages/backend/src/openapi/spec.ts`), so it is typed
|
|
1435
|
+
* `string | null` here rather than narrowed: a value this SDK does not know
|
|
1436
|
+
* is still the backend's record, and narrowing it to `null` would erase it.
|
|
1437
|
+
* Absent on an older backend; `null` when the backend states no scheme
|
|
1438
|
+
* (legacy-rail receipts).
|
|
1439
|
+
*/
|
|
1440
|
+
settlementScheme?: string | null;
|
|
1441
|
+
/**
|
|
1442
|
+
* #4469: the budget delegation that METERED this payment (#3518), uniform
|
|
1443
|
+
* across schemes. `string | null` on receipts — the backend sends
|
|
1444
|
+
* `?? null` — unlike {@link PaymentStatusResult.budgetDelegationHash}, which
|
|
1445
|
+
* is `string` and absent when unknown. Absent on an older backend.
|
|
1446
|
+
*/
|
|
1447
|
+
budgetDelegationHash?: string | null;
|
|
1355
1448
|
/**
|
|
1356
1449
|
* #3134: the payment protocol this receipt settled on — one of the
|
|
1357
1450
|
* evidence-eligible rails (`x402`, `mpp_demo`, `mpp_crypto`, `spt`) — under the
|
|
@@ -1427,6 +1520,23 @@ interface HavenPaymentReceipt {
|
|
|
1427
1520
|
*/
|
|
1428
1521
|
protocolReceiptPayload?: Record<string, unknown> | null;
|
|
1429
1522
|
merchantStatus: number | null;
|
|
1523
|
+
/**
|
|
1524
|
+
* #4469: the paying agent's own delivery verdict (#3770), when it reported
|
|
1525
|
+
* one — `ok` | `unusable` | `partial`. Evidence only: it never gates
|
|
1526
|
+
* anything and the payment itself is unchanged. Absent on an older backend;
|
|
1527
|
+
* `null` when the backend states "not reported".
|
|
1528
|
+
*/
|
|
1529
|
+
deliveryQuality?: 'ok' | 'unusable' | 'partial' | null;
|
|
1530
|
+
/** #4469: the agent's optional note (max 2000 chars) saying what was wrong. Absent on an older backend. */
|
|
1531
|
+
deliveryNote?: string | null;
|
|
1532
|
+
/** #4469: when the agent reported the verdict (ISO 8601). Absent on an older backend. */
|
|
1533
|
+
deliveryReportedAt?: string | null;
|
|
1534
|
+
/**
|
|
1535
|
+
* #4469: the NON-SECRET pointer to a delivered good (#3778) — merchant,
|
|
1536
|
+
* product, value, order id. Never a redemption code or other credential:
|
|
1537
|
+
* those are refused at write. Absent on an older backend.
|
|
1538
|
+
*/
|
|
1539
|
+
deliveryReference?: string | null;
|
|
1430
1540
|
confirmedAt: string | null;
|
|
1431
1541
|
createdAt: string;
|
|
1432
1542
|
updatedAt: string;
|
|
@@ -1793,6 +1903,34 @@ declare const AgentPaymentWarningCode: {
|
|
|
1793
1903
|
* settlement can no longer land at all.
|
|
1794
1904
|
*/
|
|
1795
1905
|
readonly SettlementUnconfirmed: "SETTLEMENT_UNCONFIRMED";
|
|
1906
|
+
/**
|
|
1907
|
+
* #3967: the quote-time budget pre-check decided the quoted amount does NOT
|
|
1908
|
+
* fit the agent's remaining delegation budget — the same server-side compare
|
|
1909
|
+
* the payment path runs before funding. Travels beside
|
|
1910
|
+
* `budget_check.sufficient: false` and, on `haven_quote_x402`,
|
|
1911
|
+
* `safe_to_continue: false` with no prefilled cap. The on-chain policy
|
|
1912
|
+
* remains the actual gate either way.
|
|
1913
|
+
*/
|
|
1914
|
+
readonly QuoteExceedsRemainingBudget: "QUOTE_EXCEEDS_REMAINING_BUDGET";
|
|
1915
|
+
/**
|
|
1916
|
+
* #4458: the agent's only budget for the token has ENDED — the quote-time
|
|
1917
|
+
* pre-check answered the typed 403 `delegation_expired`, not an over-budget
|
|
1918
|
+
* compare. Travels beside `budget_check.sufficient: false` and, on
|
|
1919
|
+
* `haven_quote_x402`, `safe_to_continue: false` with no prefilled cap. The
|
|
1920
|
+
* remedy is the owner setting a NEW budget: waiting for a period to reset
|
|
1921
|
+
* cannot help, which is why this is its own code rather than
|
|
1922
|
+
* {@link AgentPaymentWarningCode.QuoteExceedsRemainingBudget}. Additive: an
|
|
1923
|
+
* older backend never emits it, and the on-chain policy remains the actual
|
|
1924
|
+
* gate either way.
|
|
1925
|
+
*/
|
|
1926
|
+
readonly QuoteBudgetEnded: "QUOTE_BUDGET_ENDED";
|
|
1927
|
+
/**
|
|
1928
|
+
* #3967: the MERCHANT reported a denial on one of its x402 payment options —
|
|
1929
|
+
* a known denial key (starting with `issuanceDenied`) in `accepts[].extra`.
|
|
1930
|
+
* Strictly informational: it flips neither `safe_to_continue` nor
|
|
1931
|
+
* `expected_settleable`; the agent should surface it to the user.
|
|
1932
|
+
*/
|
|
1933
|
+
readonly MerchantReportedDenial: "MERCHANT_REPORTED_DENIAL";
|
|
1796
1934
|
};
|
|
1797
1935
|
type AgentPaymentWarningCode = (typeof AgentPaymentWarningCode)[keyof typeof AgentPaymentWarningCode];
|
|
1798
1936
|
interface AgentPaymentWarning {
|
|
@@ -2053,9 +2191,11 @@ interface HavenCatalogEntry {
|
|
|
2053
2191
|
* (the operator vouches for the listing; the catalog refresh probe still
|
|
2054
2192
|
* checks the endpoint, see `verifiedPayable`). `ingestion` = submitted
|
|
2055
2193
|
* through the Verified Payable Directory and passed domain-ownership proof
|
|
2056
|
-
* plus the read-only quote probe.
|
|
2194
|
+
* plus the read-only quote probe. `bazaar` = written by the x402 Bazaar
|
|
2195
|
+
* discovery cron (#4245): seller-chosen name and description, no operator
|
|
2196
|
+
* review, no ownership proof.
|
|
2057
2197
|
*/
|
|
2058
|
-
source: 'operator' | 'ingestion';
|
|
2198
|
+
source: 'operator' | 'ingestion' | 'bazaar';
|
|
2059
2199
|
/** True only for `ingestion` entries — the one ownership claim. See the epic's trust claim (never merchant honesty or quality). */
|
|
2060
2200
|
domainVerified: boolean;
|
|
2061
2201
|
/**
|
|
@@ -2117,9 +2257,66 @@ declare class HavenError extends Error {
|
|
|
2117
2257
|
readonly paymentId?: string | undefined;
|
|
2118
2258
|
constructor(message: string, code: string, statusCode?: number | undefined, paymentId?: string | undefined);
|
|
2119
2259
|
}
|
|
2260
|
+
/**
|
|
2261
|
+
* #4470: why a `HavenApiError` happened, where its status alone cannot say.
|
|
2262
|
+
*
|
|
2263
|
+
* - `no_answer` — the transport got no usable answer: the request timed out
|
|
2264
|
+
* (status 408), `fetch` threw, or the body was not JSON (status 0). Whether
|
|
2265
|
+
* the call took effect is unknown, so a `GET` may be retried and a `POST`
|
|
2266
|
+
* must not be; `method` says which it was.
|
|
2267
|
+
* - `deterministic` — the SDK refused an answer it cannot use (a missing
|
|
2268
|
+
* field, the wrong shape). Repeating the same call gets the same answer,
|
|
2269
|
+
* whatever the status says.
|
|
2270
|
+
*
|
|
2271
|
+
* Absent on every other error, which keeps the status rule. A readonly field
|
|
2272
|
+
* rather than a subclass, so `name`, `code` and `statusCode` stay what
|
|
2273
|
+
* consumers already match on.
|
|
2274
|
+
*/
|
|
2275
|
+
type HavenApiFailureCause = {
|
|
2276
|
+
readonly kind: 'no_answer';
|
|
2277
|
+
readonly method: 'GET' | 'POST';
|
|
2278
|
+
} | {
|
|
2279
|
+
readonly kind: 'deterministic';
|
|
2280
|
+
};
|
|
2120
2281
|
declare class HavenApiError extends HavenError {
|
|
2121
2282
|
readonly body?: unknown | undefined;
|
|
2122
|
-
|
|
2283
|
+
readonly failureCause?: HavenApiFailureCause | undefined;
|
|
2284
|
+
constructor(message: string, statusCode: number, body?: unknown | undefined, paymentId?: string, failureCause?: HavenApiFailureCause | undefined);
|
|
2285
|
+
/**
|
|
2286
|
+
* #4470: an error a retry cannot change. The census in
|
|
2287
|
+
* `haven-api-error-census.test.ts` requires every literal 5xx site to use
|
|
2288
|
+
* this or be allowlisted there with a reason.
|
|
2289
|
+
*/
|
|
2290
|
+
static deterministic(message: string, statusCode: number, body?: unknown, paymentId?: string): HavenApiError;
|
|
2291
|
+
}
|
|
2292
|
+
/**
|
|
2293
|
+
* #4470: the funding transaction's confirmation could not be read — ethers'
|
|
2294
|
+
* `waitForTransaction` rejected (its `TIMEOUT`, or an RPC failure). Haven had
|
|
2295
|
+
* already submitted the funding leg, so funds may have reached the delegate:
|
|
2296
|
+
* the answer is check-status, never "tell the user it failed" and never a new
|
|
2297
|
+
* payment. The merchant was not called.
|
|
2298
|
+
*
|
|
2299
|
+
* Deliberately carries no `failureCause`: it is not a transport non-answer
|
|
2300
|
+
* (no Haven request went unanswered) and not deterministic (a later read may
|
|
2301
|
+
* see the receipt). Callers answer the class itself — the hosted delivery
|
|
2302
|
+
* step does in `ensureFundingConfirmedOrRefuse`; unwrapped, its 504 reads
|
|
2303
|
+
* "re-call once", which re-runs the same wait.
|
|
2304
|
+
*/
|
|
2305
|
+
declare class FundingConfirmationUnknownError extends HavenApiError {
|
|
2306
|
+
readonly txHash: string;
|
|
2307
|
+
readonly chainId: number;
|
|
2308
|
+
readonly fundingErrorCode: "funding_confirmation_unknown";
|
|
2309
|
+
constructor(txHash: string, chainId: number, reason: string);
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* #4470: the funding transaction was mined and reverted, so nothing reached
|
|
2313
|
+
* the delegate. Repeating the wait gets the same receipt.
|
|
2314
|
+
*/
|
|
2315
|
+
declare class FundingRevertedError extends HavenApiError {
|
|
2316
|
+
readonly txHash: string;
|
|
2317
|
+
readonly chainId: number;
|
|
2318
|
+
readonly fundingErrorCode: "funding_reverted";
|
|
2319
|
+
constructor(txHash: string, chainId: number);
|
|
2123
2320
|
}
|
|
2124
2321
|
/**
|
|
2125
2322
|
* #1300: quoteX402 hit a URL that answered something other than 402 — the
|
|
@@ -2325,4 +2522,4 @@ declare class HavenTimeoutError extends HavenError {
|
|
|
2325
2522
|
constructor(paymentId: string);
|
|
2326
2523
|
}
|
|
2327
2524
|
|
|
2328
|
-
export { AgentPaymentNextActionSchema as $, type AgentPaymentWarning as A, type BudgetPrecheckResult as B, type CloseTaskBudgetResult as C, type X402ResumeState as D, type X402McpTransport as E, type X402MerchantCallContext as F, type X402IntentByKey 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, type MerchantEgressPolicy as M, AGENT_PAYMENT_RAIL_VALUES as N, type OpenTaskBudgetResult as O, type PaymentRequest as P, type AgentNextStep as Q, type ResumeAuthorizedX402Input as R, type SweepResult as S, type TaskBudgetSignContext as T, type AgentPaymentEnumSchema as U, AgentPaymentFailureCode as V, AgentPaymentFailureCodeDescriptions as W, type X402PaymentRequired as X, AgentPaymentFailureCodeSchema as Y, AgentPaymentNextAction as Z, AgentPaymentNextActionDescriptions as _, type PaymentResult as a, AgentPaymentPhase as a0, AgentPaymentPhaseDescriptions as a1, AgentPaymentPhaseSchema as a2, AgentPaymentRail as a3, AgentPaymentRailDescriptions as a4, AgentPaymentRailSchema as a5, type AgentPaymentSummary as a6, AgentPaymentWarningCode as a7, type AgentPurchaseSummary as a8, type CatalogSubmissionAccepted as a9, type
|
|
2525
|
+
export { AgentPaymentNextActionSchema as $, type AgentPaymentWarning as A, type BudgetPrecheckResult as B, type CloseTaskBudgetResult as C, type X402ResumeState as D, type X402McpTransport as E, type X402MerchantCallContext as F, type X402IntentByKey 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, type MerchantEgressPolicy as M, AGENT_PAYMENT_RAIL_VALUES as N, type OpenTaskBudgetResult as O, type PaymentRequest as P, type AgentNextStep as Q, type ResumeAuthorizedX402Input as R, type SweepResult as S, type TaskBudgetSignContext as T, type AgentPaymentEnumSchema as U, AgentPaymentFailureCode as V, AgentPaymentFailureCodeDescriptions as W, type X402PaymentRequired as X, AgentPaymentFailureCodeSchema as Y, AgentPaymentNextAction as Z, AgentPaymentNextActionDescriptions as _, type PaymentResult as a, AgentPaymentPhase as a0, AgentPaymentPhaseDescriptions as a1, AgentPaymentPhaseSchema as a2, AgentPaymentRail as a3, AgentPaymentRailDescriptions as a4, AgentPaymentRailSchema as a5, type AgentPaymentSummary as a6, AgentPaymentWarningCode as a7, type AgentPurchaseSummary as a8, type CatalogSubmissionAccepted as a9, type MerchantEgressTimeouts as aA, type MerchantEgressUse as aB, MerchantTimeoutError as aC, type PaymentFee as aD, type PaymentNextAction as aE, type PaymentPhase as aF, type PaymentStatus as aG, SIGNER_UPDATE_FALLBACK as aH, SignerRefusalCode as aI, type SweepConfirmation as aJ, type SweepEntry as aK, X402AlreadySettledError as aL, X402Erc7710AlreadySettledError as aM, type X402ExpectedAuth as aN, type X402ExpectedContext as aO, type X402PaymentOption as aP, type X402RequestSnapshot as aQ, X402TaskBudgetMismatchError as aR, X402UnexpectedStatusError as aS, assertPublicHttpsMerchantUrl as aT, isPublicHttpsMerchantUrl as aU, publicHttpsMerchantUrlRefusal as aV, readBodyCapped as aW, signerUpdateFallback as aX, strictMerchantEgressPolicy as aY, type RawPaymentParties as aZ, DEFAULT_CONFIRMATION_TIMEOUT_MS as aa, FundingConfirmationUnknownError as ab, FundingRevertedError as ac, HOSTED_DISCOVERY_TIMEOUT_MS as ad, HOSTED_EGRESS_TIMEOUTS as ae, HOSTED_MAX_GET_REDIRECTS as af, HOSTED_RESPONSE_BYTE_CAPS as ag, type HavenAgentAllowanceSummary as ah, type HavenAgentReadiness as ai, type HavenAgentSupersession as aj, type HavenAllowance as ak, HavenApiError as al, type HavenApiFailureCause as am, type HavenCatalogMerchant as an, type HavenListScope as ao, HavenPaymentStateError as ap, HavenSigningError as aq, HavenTimeoutError as ar, HavenUnsupportedSignerVersionError as as, HavenZeroSettlementHashError as at, MERCHANT_EGRESS_REFUSED_CODE as au, MERCHANT_EGRESS_RESPONSE_CAP_CODE as av, type MachinePaymentRail as aw, type MerchantEgressRefusalReason as ax, MerchantEgressRefusedError as ay, MerchantEgressResponseCapError as az, type PaymentIntent as b, type X402AuthorizationOptions as c, type X402Intent as d, type PaymentStatusResult as e, type HavenAgent as f, type HavenAgentSummary as g, type HavenAllowanceSummary as h, type HavenBalanceCoverage as i, type PostPurchaseAllowanceSummary as j, type HavenCatalogEntry as k, type HavenCatalogSubmission as l, type HavenPaymentReceipt as m, type HavenPaymentReceiptsPage as n, type HavenTaskBudget as o, type SubmitTaskBudgetResult as p, type SubmitSubBudgetResult as q, type HavenPendingSubBudgetSignature as r, type CloseSubBudgetResult as s, type PaymentResumeState as t, type X402Receipt as u, type X402Quote as v, type X402Erc7710Settlement as w, type X402McpCallContext as x, type SignData as y, type ResumeX402PaymentInput as z };
|