@haven_ai/sdk 0.0.0-dev.202609141609.ad8a780 → 0.0.0-dev.202609141754.2199891

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 CHANGED
@@ -136,8 +136,11 @@ var AgentPaymentNextAction = {
136
136
  * first appears. Poll {@link CheckStatusLater}'s tool
137
137
  * (`haven_get_payment_status`) once more, roughly two minutes later; if it
138
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 —
139
+ * Haven holds no verified settlement evidence for this payment. If the
140
+ * agent holds the merchant's real settlement transaction hash (from
141
+ * `PAYMENT-RESPONSE`'s `transaction` field, or a prior settle/complete
142
+ * result's `settlement_tx_hash`), report it with the hosted
143
+ * `haven_report_settlement_evidence` tool instead of waiting —
141
144
  * `haven_report_x402_outcome` takes no hash and refuses a non-`confirmed`
142
145
  * intent.
143
146
  */
@@ -241,7 +244,7 @@ var AgentPaymentNextActionDescriptions = {
241
244
  [AgentPaymentNextAction.FundSafeOrRaiseAllowance]: "Stop and tell the user that the account needs to be funded or the agent budget raised before the payment can succeed.",
242
245
  [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.",
243
246
  [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."
247
+ [AgentPaymentNextAction.AwaitingSettlementEvidence]: "The settlement window passed with no verified on-chain evidence yet. If you hold the merchant's real settlement transaction hash, report it with haven_report_settlement_evidence. Otherwise, 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."
245
248
  };
246
249
  var AgentPaymentFailureCodeDescriptions = {
247
250
  [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.",
@@ -385,6 +388,17 @@ var HavenSigningError = class extends HavenError {
385
388
  this.name = "HavenSigningError";
386
389
  }
387
390
  };
391
+ var HavenZeroSettlementHashError = class extends HavenError {
392
+ constructor(paymentId) {
393
+ super(
394
+ "settlement_tx_hash is the zero hash (0x00\u202600), which is never a real settlement transaction \u2014 refused before any report was sent.",
395
+ "ZERO_SETTLEMENT_HASH",
396
+ 400,
397
+ paymentId
398
+ );
399
+ this.name = "HavenZeroSettlementHashError";
400
+ }
401
+ };
388
402
  var SignerRefusalCode = {
389
403
  /** `SUPPORTED_X402_EXPECTED_VERSIONS` in `@haven_ai/signer` does not include the received version. */
390
404
  UnsupportedExpectedContextVersion: "UNSUPPORTED_EXPECTED_CONTEXT_VERSION",
@@ -2957,6 +2971,39 @@ var MerchantCompletion = class {
2957
2971
  }
2958
2972
  }
2959
2973
  }
2974
+ /**
2975
+ * #2972: report the merchant's REAL settlement transaction hash for an
2976
+ * erc7710 x402 payment out of band — the remedy #2970's guidance could not
2977
+ * name, because no hosted tool accepted a hash. An agent reaches this after
2978
+ * `haven_settle_mcp_tool` / `haven_complete_mcp_tool` answered
2979
+ * `DELIVERED_UNSETTLED` or `SETTLEMENT_PENDING`, or after
2980
+ * `haven_get_payment_status` reports `awaiting_settlement_evidence` — in
2981
+ * every one of those cases the agent may be holding the merchant's own
2982
+ * `PAYMENT-RESPONSE.transaction` while Haven has nothing.
2983
+ *
2984
+ * Reuses `reportEvidence` — same backend seam
2985
+ * (`POST /machine-payments/evidence` → `observeErc7710Settlement`,
2986
+ * fail-closed — see `settlement-observed.ts`), same three-outcome contract.
2987
+ * `resourceUrl` and `merchantStatus` are omitted: this call has no fresh
2988
+ * merchant HTTP exchange to read either from, and both are optional at the
2989
+ * backend (see the parameter doc on `reportEvidence`).
2990
+ *
2991
+ * The zero hash is refused HERE, client-side, before any network call —
2992
+ * never posted. `isZeroSettlementTxHash` is the same recognizer the #2970
2993
+ * gate uses, so a caller cannot "fix" a missing hash by reporting the demo
2994
+ * merchant's own marker and getting a different verdict than the settle
2995
+ * path already gave it.
2996
+ */
2997
+ async reportSettlementEvidence(paymentId, settlementTxHash) {
2998
+ if (isZeroSettlementTxHash(settlementTxHash)) {
2999
+ throw new HavenZeroSettlementHashError(paymentId);
3000
+ }
3001
+ return this.reportEvidence({
3002
+ paymentId,
3003
+ rail: "x402",
3004
+ txHash: settlementTxHash
3005
+ });
3006
+ }
2960
3007
  };
2961
3008
  function isZeroSettlementTxHash(hash) {
2962
3009
  return typeof hash === "string" && /^0x0+$/i.test(hash);
@@ -3947,6 +3994,19 @@ var HavenClient = class {
3947
3994
  async reportX402MerchantOutcome(input) {
3948
3995
  return await this.merchantCompletion.reportMerchantOutcome(input);
3949
3996
  }
3997
+ /**
3998
+ * #2972: report the merchant's real settlement transaction hash for an
3999
+ * erc7710 x402 payment — the remedy for `DELIVERED_UNSETTLED` /
4000
+ * `SETTLEMENT_PENDING` / `awaiting_settlement_evidence` when the agent
4001
+ * holds the hash (`PAYMENT-RESPONSE.transaction`, or a prior settle/
4002
+ * complete result's `settlement_tx_hash`) and Haven does not. See
4003
+ * `MerchantCompletion.reportSettlementEvidence` for the fail-closed
4004
+ * verification this posts into (`observeErc7710Settlement`) and the
4005
+ * client-side zero-hash refusal.
4006
+ */
4007
+ async reportSettlementEvidence(paymentId, settlementTxHash) {
4008
+ return await this.merchantCompletion.reportSettlementEvidence(paymentId, settlementTxHash);
4009
+ }
3950
4010
  /**
3951
4011
  * GET /x402/:id/merchant-call-context — the settle-leg twin of #1263's
3952
4012
  * sign-context fetch (#1307). Re-serves the stored merchant MCP-tool call
@@ -4183,6 +4243,11 @@ var toolDescriptions = {
4183
4243
  selectionGuidance: "Use this for plain transfers \u2014 refunding a user, paying a freelancer, topping up a co-agent's wallet, or moving funds between addresses. Do NOT use for x402 paid endpoints \u2014 use haven_pay_x402 instead. Do NOT use for read-only allowance, budget, or what-can-I-spend questions \u2014 use haven_get_allowances.",
4184
4244
  behavior: "Sends the requested amount by redeeming the agent's on-chain budget delegation, account to recipient with no funding leg. Budget, recipient and expiry are enforced on-chain while the transfer is prepared, so a request outside them is declined before any money moves and before the agent is asked to sign \u2014 it is never queued for a human to approve later. The agent's signing key signs the account's typed data; Haven never receives the key.",
4185
4245
  nextActionGuidance: "On a decline, report the reason to the user and ask them to grant or raise the budget in Haven \u2014 there is nothing to poll and no approval will arrive. After a successful send, poll haven_get_payment_status until nextAction=none."
4246
+ },
4247
+ reportSettlementEvidence: {
4248
+ summary: "Report an erc7710 payment's real settlement transaction hash so Haven can verify it on-chain and confirm the payment.",
4249
+ behavior: "Pass payment_id and settlement_tx_hash (0x + 64 hex chars) \u2014 from PAYMENT-RESPONSE or a prior settlement_tx_hash. Haven verifies on-chain before confirming; a zero, mismatched, or reverted hash is refused. Your own payments only.",
4250
+ nextActionGuidance: "code DELIVERED_UNSETTLED: did not verify, do not retry \u2014 poll haven_get_payment_status. code SETTLEMENT_PENDING (retryable:true): not mined or RPC unreachable \u2014 report the same hash again shortly."
4186
4251
  }
4187
4252
  };
4188
4253
 
@@ -4944,6 +5009,7 @@ exports.HavenPaymentStateError = HavenPaymentStateError;
4944
5009
  exports.HavenSigningError = HavenSigningError;
4945
5010
  exports.HavenTimeoutError = HavenTimeoutError;
4946
5011
  exports.HavenUnsupportedSignerVersionError = HavenUnsupportedSignerVersionError;
5012
+ exports.HavenZeroSettlementHashError = HavenZeroSettlementHashError;
4947
5013
  exports.MERCHANT_DISCOVERY_PATHS = MERCHANT_DISCOVERY_PATHS;
4948
5014
  exports.MerchantTimeoutError = MerchantTimeoutError;
4949
5015
  exports.RECEIPT_VERSION = RECEIPT_VERSION;