@haven_ai/mcp 0.9.0-alpha.0 → 0.10.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/dist/index.cjs CHANGED
@@ -727,6 +727,10 @@ function createToolHandlers(haven) {
727
727
  price_atomic: entry.priceAtomic,
728
728
  asset: entry.asset,
729
729
  network: entry.network,
730
+ // #3839: same hint the hosted surface emits — a catalog hint, the
731
+ // live quote stays authoritative; "unknown" when nothing is recorded.
732
+ asset_transfer_methods: entry.assetTransferMethods ?? null,
733
+ funding_leg_expected: sdk.catalogFundingLegExpected(entry.assetTransferMethods),
730
734
  status: entry.status,
731
735
  verified_at: entry.verifiedAt,
732
736
  source: entry.source,
@@ -992,17 +996,26 @@ function parseMaybeJson(text) {
992
996
  return text;
993
997
  }
994
998
  }
999
+ var MERCHANT_OUT_OF_GAS_REASON = "settlement_wallet_out_of_gas";
1000
+ function merchantOutOfGasMessage(settlementsRemaining, failFloor) {
1001
+ const remaining = typeof settlementsRemaining === "number" ? settlementsRemaining : null;
1002
+ const floor = typeof failFloor === "number" ? failFloor : null;
1003
+ const figures = remaining !== null && floor !== null ? ` It has gas for ${remaining} more settlement${remaining === 1 ? "" : "s"} and refuses new payments below ${floor} (settlements_remaining: ${remaining}, fail_floor: ${floor}).` : remaining !== null ? ` settlements_remaining: ${remaining}.` : "";
1004
+ return `The merchant refused this call: its settlement wallet is out of gas (reason_code: ${MERCHANT_OUT_OF_GAS_REASON}).` + figures + " No payment was created. The merchant's operator must top up its settlement wallet; until then every retry is refused again. Tell the user, and re-quote once the merchant has been topped up.";
1005
+ }
995
1006
  var MerchantNotReadyError = class extends Error {
1007
+ constructor(message, nextToolOmittedReason = "the merchant needs to recover first; re-quote after the retry_after_s in the message") {
1008
+ super(message);
1009
+ this.nextToolOmittedReason = nextToolOmittedReason;
1010
+ this.name = "MerchantNotReadyError";
1011
+ }
1012
+ nextToolOmittedReason;
996
1013
  code = sdk.AgentPaymentFailureCode.MerchantNotReady;
997
1014
  statusCode = 503;
998
1015
  nextAction = sdk.AgentPaymentNextAction.StopAndTellUser;
999
1016
  // Genuinely retryable — unlike a rejection, nothing about THIS call was
1000
1017
  // wrong; the merchant's own wallet needs to recover first.
1001
1018
  retryWithNewQuote = true;
1002
- constructor(message) {
1003
- super(message);
1004
- this.name = "MerchantNotReadyError";
1005
- }
1006
1019
  };
1007
1020
  async function merchantNotReadyErrorFor(response) {
1008
1021
  if (response.status !== 503) return null;
@@ -1015,7 +1028,14 @@ async function merchantNotReadyErrorFor(response) {
1015
1028
  if (!body || typeof body !== "object" || body.error !== "merchant_not_ready") {
1016
1029
  return null;
1017
1030
  }
1018
- const { reason_code, settlements_remaining, retry_after_s } = body;
1031
+ const { reason_code, settlements_remaining, fail_floor, retry_after_s } = body;
1032
+ if (reason_code === MERCHANT_OUT_OF_GAS_REASON) {
1033
+ return new MerchantNotReadyError(
1034
+ merchantOutOfGasMessage(settlements_remaining, fail_floor),
1035
+ // Same reason the hosted runtime returns (support/mcp-context.ts).
1036
+ "the merchant's operator must top up its settlement wallet first; re-quote after that"
1037
+ );
1038
+ }
1019
1039
  return new MerchantNotReadyError(
1020
1040
  "The merchant refused this call: it cannot settle a payment right now" + (typeof reason_code === "string" ? ` (reason_code: ${reason_code})` : "") + (typeof settlements_remaining === "number" ? `, settlements_remaining: ${settlements_remaining}` : "") + ". No payment was created." + (typeof retry_after_s === "number" ? ` Retry after approximately ${retry_after_s}s.` : " This is often transient; retry later.")
1021
1041
  );
@@ -1036,8 +1056,10 @@ function normalizeError(err) {
1036
1056
  next_action: err.nextAction,
1037
1057
  retry_with_new_quote: err.retryWithNewQuote,
1038
1058
  // #3103: the local runtime's one decision site — no tool can act until
1039
- // the merchant recovers; the message carries retry_after_s.
1040
- next_tool_omitted_reason: "the merchant needs to recover first; re-quote after the retry_after_s in the message"
1059
+ // the merchant recovers. The reason rides the error (#3834): the
1060
+ // generic one points at the message's retry_after_s, the out-of-gas
1061
+ // one at the operator top-up.
1062
+ next_tool_omitted_reason: err.nextToolOmittedReason
1041
1063
  };
1042
1064
  }
1043
1065
  if (err instanceof sdk.HavenPaymentStateError) {
@@ -1323,7 +1345,7 @@ async function createHavenMcpServer(options = {}) {
1323
1345
  return buildMcpServer(haven);
1324
1346
  }
1325
1347
  var MCP_NAME = "@haven_ai/mcp";
1326
- var MCP_VERSION = "0.9.0-alpha.0";
1348
+ var MCP_VERSION = "0.10.0-alpha.0";
1327
1349
  var MCP_INSTRUCTIONS = [
1328
1350
  "Haven local MCP server: signs in-process with the delegate key it holds on",
1329
1351
  "this machine \u2014 the key never leaves this process. Call haven_get_agent",