@haven_ai/sdk 0.0.0-dev.202609141522.72645b4 → 0.0.0-dev.202609141609.ad8a780
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.cjs +40 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -4
- package/dist/index.d.ts +61 -4
- package/dist/index.js +40 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -125,7 +125,23 @@ var AgentPaymentNextAction = {
|
|
|
125
125
|
* settled to the merchant. The wallet owner should initiate a sweep to
|
|
126
126
|
* return those funds to the originating Safe.
|
|
127
127
|
*/
|
|
128
|
-
SweepStrandedFunds: "sweep_stranded_funds"
|
|
128
|
+
SweepStrandedFunds: "sweep_stranded_funds",
|
|
129
|
+
/**
|
|
130
|
+
* #2970: a `submitted` erc7710 x402 intent whose settlement window has
|
|
131
|
+
* passed with no on-chain settlement evidence Haven could verify. Distinct
|
|
132
|
+
* from {@link CheckStatusLater}, which this REPLACES once the window is
|
|
133
|
+
* past — but it is not futile: Haven's settlement sweep (120s tick) scans
|
|
134
|
+
* each candidate over its own window plus a 120s clock-skew allowance, so
|
|
135
|
+
* it can still attribute the settlement for a short while after this value
|
|
136
|
+
* first appears. Poll {@link CheckStatusLater}'s tool
|
|
137
|
+
* (`haven_get_payment_status`) once more, roughly two minutes later; if it
|
|
138
|
+
* still shows no evidence, tell the user the goods were delivered but
|
|
139
|
+
* Haven holds no verified settlement evidence for this payment. There is
|
|
140
|
+
* no tool that reports a settlement transaction hash for this scheme —
|
|
141
|
+
* `haven_report_x402_outcome` takes no hash and refuses a non-`confirmed`
|
|
142
|
+
* intent.
|
|
143
|
+
*/
|
|
144
|
+
AwaitingSettlementEvidence: "awaiting_settlement_evidence"
|
|
129
145
|
};
|
|
130
146
|
var AgentPaymentNextActionAccountAlias = {
|
|
131
147
|
/** Account-vocabulary twin of `fund_safe_or_raise_allowance`; same meaning. */
|
|
@@ -224,7 +240,8 @@ var AgentPaymentNextActionDescriptions = {
|
|
|
224
240
|
[AgentPaymentNextAction.PaymentWindowExpired]: "The x402 funding/quote window expired. Re-quote with the same idempotency key before asking the signer to build a merchant payment header again.",
|
|
225
241
|
[AgentPaymentNextAction.FundSafeOrRaiseAllowance]: "Stop and tell the user that the account needs to be funded or the agent budget raised before the payment can succeed.",
|
|
226
242
|
[AgentPaymentNextAction.RetryWithExplicitContext]: "Retry the same tool call, this time passing merchant_url, tool_name, arguments, and mcp_transport explicitly \u2014 the server had no stored context to rehydrate for this payment id.",
|
|
227
|
-
[AgentPaymentNextAction.SweepStrandedFunds]: "Tell the user that funds may be stranded in the delegate wallet and prompt them to initiate a sweep in Haven to return them to the originating account."
|
|
243
|
+
[AgentPaymentNextAction.SweepStrandedFunds]: "Tell the user that funds may be stranded in the delegate wallet and prompt them to initiate a sweep in Haven to return them to the originating account.",
|
|
244
|
+
[AgentPaymentNextAction.AwaitingSettlementEvidence]: "The settlement window passed with no verified on-chain evidence yet. Haven's settlement sweep may still attribute it within about two minutes \u2014 poll getPaymentStatus once more, then tell the user the goods were delivered but unverified if it still shows nothing."
|
|
228
245
|
};
|
|
229
246
|
var AgentPaymentFailureCodeDescriptions = {
|
|
230
247
|
[AgentPaymentFailureCode.PriceExceedsMax]: "The merchant-authoritative x402 amount exceeds the caller's max_amount cap. No funding transfer was created; ask the user before retrying with a larger cap.",
|
|
@@ -2926,15 +2943,24 @@ var MerchantCompletion = class {
|
|
|
2926
2943
|
for (let attempt = 0; ; attempt += 1) {
|
|
2927
2944
|
try {
|
|
2928
2945
|
await this.post("/machine-payments/evidence", body);
|
|
2929
|
-
return;
|
|
2946
|
+
return { outcome: "confirmed" };
|
|
2930
2947
|
} catch (err) {
|
|
2931
|
-
const
|
|
2932
|
-
|
|
2948
|
+
const statusCode = err instanceof HavenApiError ? err.statusCode : void 0;
|
|
2949
|
+
const retryable = statusCode === EVIDENCE_RETRYABLE_STATUS;
|
|
2950
|
+
if (!retryable) {
|
|
2951
|
+
return { outcome: "refused", statusCode: statusCode ?? 0 };
|
|
2952
|
+
}
|
|
2953
|
+
if (attempt >= EVIDENCE_RETRY_DELAYS_MS.length) {
|
|
2954
|
+
return { outcome: "retryable", statusCode };
|
|
2955
|
+
}
|
|
2933
2956
|
await this.sleep(EVIDENCE_RETRY_DELAYS_MS[attempt]);
|
|
2934
2957
|
}
|
|
2935
2958
|
}
|
|
2936
2959
|
}
|
|
2937
2960
|
};
|
|
2961
|
+
function isZeroSettlementTxHash(hash) {
|
|
2962
|
+
return typeof hash === "string" && /^0x0+$/i.test(hash);
|
|
2963
|
+
}
|
|
2938
2964
|
function parseMerchantSettlement(header) {
|
|
2939
2965
|
if (!header) return {};
|
|
2940
2966
|
const parsed = parseProtocolReceiptHeader(header);
|
|
@@ -3864,6 +3890,7 @@ var HavenClient = class {
|
|
|
3864
3890
|
} catch {
|
|
3865
3891
|
body = text;
|
|
3866
3892
|
}
|
|
3893
|
+
let evidenceOutcome;
|
|
3867
3894
|
if (!surfaced.ok) {
|
|
3868
3895
|
if (!input.noFundingLeg && fundingTxHash) {
|
|
3869
3896
|
await this.merchantCompletion.recordRetryRejected({
|
|
@@ -3883,9 +3910,10 @@ var HavenClient = class {
|
|
|
3883
3910
|
});
|
|
3884
3911
|
}
|
|
3885
3912
|
} else {
|
|
3886
|
-
const
|
|
3913
|
+
const rawEvidenceTxHash = input.noFundingLeg ? settlement.settlementTxHash ?? void 0 : fundingTxHash ?? void 0;
|
|
3914
|
+
const evidenceTxHash = rawEvidenceTxHash && !isZeroSettlementTxHash(rawEvidenceTxHash) ? rawEvidenceTxHash : void 0;
|
|
3887
3915
|
if (evidenceTxHash) {
|
|
3888
|
-
await this.merchantCompletion.reportEvidence({
|
|
3916
|
+
evidenceOutcome = await this.merchantCompletion.reportEvidence({
|
|
3889
3917
|
paymentId: evidenceContext.paymentId,
|
|
3890
3918
|
rail: "x402",
|
|
3891
3919
|
txHash: evidenceTxHash,
|
|
@@ -3903,7 +3931,8 @@ var HavenClient = class {
|
|
|
3903
3931
|
status: surfaced.status,
|
|
3904
3932
|
ok: surfaced.ok,
|
|
3905
3933
|
body,
|
|
3906
|
-
settlementTxHash: settlement.settlementTxHash ?? void 0
|
|
3934
|
+
settlementTxHash: settlement.settlementTxHash ?? void 0,
|
|
3935
|
+
evidenceOutcome
|
|
3907
3936
|
};
|
|
3908
3937
|
}
|
|
3909
3938
|
/**
|
|
@@ -4092,8 +4121,8 @@ var toolDescriptions = {
|
|
|
4092
4121
|
// MACHINE-PAYMENT-CHALLENGE was never produced by anything besides the now
|
|
4093
4122
|
// deleted `/demo/mpp/*` route. Use the x402 fragments above instead.
|
|
4094
4123
|
getPaymentStatus: {
|
|
4095
|
-
summary: "Fetch structured Haven payment status
|
|
4096
|
-
behavior: "State
|
|
4124
|
+
summary: "Fetch structured Haven payment status for agent recovery.",
|
|
4125
|
+
behavior: "State: phase, nextAction, rail, amount, merchant, resource, idempotency, message; parties: treasury/delegate/delegateAccount/merchant. awaiting_settlement_evidence: poll once, else unverified.",
|
|
4097
4126
|
nextActionGuidance: ""
|
|
4098
4127
|
},
|
|
4099
4128
|
getResumeState: {
|
|
@@ -4958,6 +4987,7 @@ exports.isErc7710Option = isErc7710Option;
|
|
|
4958
4987
|
exports.isFundAccountOrRaiseAllowance = isFundAccountOrRaiseAllowance;
|
|
4959
4988
|
exports.isSupportedNodeVersion = isSupportedNodeVersion;
|
|
4960
4989
|
exports.isSweepableChain = isSweepableChain;
|
|
4990
|
+
exports.isZeroSettlementTxHash = isZeroSettlementTxHash;
|
|
4961
4991
|
exports.normalizePaymentRequired = normalizePaymentRequired;
|
|
4962
4992
|
exports.parsePaymentRequired = parsePaymentRequired;
|
|
4963
4993
|
exports.parsePaymentRequiredResponse = parsePaymentRequiredResponse;
|