@haven_ai/mcp 0.0.0-dev.202610091112.2d759b4 → 0.0.0-dev.202610091522.ece043a
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/cli.cjs +26 -8
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +26 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +26 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -992,17 +992,26 @@ function parseMaybeJson(text) {
|
|
|
992
992
|
return text;
|
|
993
993
|
}
|
|
994
994
|
}
|
|
995
|
+
var MERCHANT_OUT_OF_GAS_REASON = "settlement_wallet_out_of_gas";
|
|
996
|
+
function merchantOutOfGasMessage(settlementsRemaining, failFloor) {
|
|
997
|
+
const remaining = typeof settlementsRemaining === "number" ? settlementsRemaining : null;
|
|
998
|
+
const floor = typeof failFloor === "number" ? failFloor : null;
|
|
999
|
+
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}.` : "";
|
|
1000
|
+
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.";
|
|
1001
|
+
}
|
|
995
1002
|
var MerchantNotReadyError = class extends Error {
|
|
1003
|
+
constructor(message, nextToolOmittedReason = "the merchant needs to recover first; re-quote after the retry_after_s in the message") {
|
|
1004
|
+
super(message);
|
|
1005
|
+
this.nextToolOmittedReason = nextToolOmittedReason;
|
|
1006
|
+
this.name = "MerchantNotReadyError";
|
|
1007
|
+
}
|
|
1008
|
+
nextToolOmittedReason;
|
|
996
1009
|
code = sdk.AgentPaymentFailureCode.MerchantNotReady;
|
|
997
1010
|
statusCode = 503;
|
|
998
1011
|
nextAction = sdk.AgentPaymentNextAction.StopAndTellUser;
|
|
999
1012
|
// Genuinely retryable — unlike a rejection, nothing about THIS call was
|
|
1000
1013
|
// wrong; the merchant's own wallet needs to recover first.
|
|
1001
1014
|
retryWithNewQuote = true;
|
|
1002
|
-
constructor(message) {
|
|
1003
|
-
super(message);
|
|
1004
|
-
this.name = "MerchantNotReadyError";
|
|
1005
|
-
}
|
|
1006
1015
|
};
|
|
1007
1016
|
async function merchantNotReadyErrorFor(response) {
|
|
1008
1017
|
if (response.status !== 503) return null;
|
|
@@ -1015,7 +1024,14 @@ async function merchantNotReadyErrorFor(response) {
|
|
|
1015
1024
|
if (!body || typeof body !== "object" || body.error !== "merchant_not_ready") {
|
|
1016
1025
|
return null;
|
|
1017
1026
|
}
|
|
1018
|
-
const { reason_code, settlements_remaining, retry_after_s } = body;
|
|
1027
|
+
const { reason_code, settlements_remaining, fail_floor, retry_after_s } = body;
|
|
1028
|
+
if (reason_code === MERCHANT_OUT_OF_GAS_REASON) {
|
|
1029
|
+
return new MerchantNotReadyError(
|
|
1030
|
+
merchantOutOfGasMessage(settlements_remaining, fail_floor),
|
|
1031
|
+
// Same reason the hosted runtime returns (support/mcp-context.ts).
|
|
1032
|
+
"the merchant's operator must top up its settlement wallet first; re-quote after that"
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1019
1035
|
return new MerchantNotReadyError(
|
|
1020
1036
|
"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
1037
|
);
|
|
@@ -1036,8 +1052,10 @@ function normalizeError(err) {
|
|
|
1036
1052
|
next_action: err.nextAction,
|
|
1037
1053
|
retry_with_new_quote: err.retryWithNewQuote,
|
|
1038
1054
|
// #3103: the local runtime's one decision site — no tool can act until
|
|
1039
|
-
// the merchant recovers
|
|
1040
|
-
|
|
1055
|
+
// the merchant recovers. The reason rides the error (#3834): the
|
|
1056
|
+
// generic one points at the message's retry_after_s, the out-of-gas
|
|
1057
|
+
// one at the operator top-up.
|
|
1058
|
+
next_tool_omitted_reason: err.nextToolOmittedReason
|
|
1041
1059
|
};
|
|
1042
1060
|
}
|
|
1043
1061
|
if (err instanceof sdk.HavenPaymentStateError) {
|
|
@@ -1315,7 +1333,7 @@ async function resolveHavenClient(options = {}) {
|
|
|
1315
1333
|
return { client, credentials };
|
|
1316
1334
|
}
|
|
1317
1335
|
var MCP_NAME = "@haven_ai/mcp";
|
|
1318
|
-
var MCP_VERSION = "0.0.0-dev.
|
|
1336
|
+
var MCP_VERSION = "0.0.0-dev.202610091522.ece043a";
|
|
1319
1337
|
var MCP_INSTRUCTIONS = [
|
|
1320
1338
|
"Haven local MCP server: signs in-process with the delegate key it holds on",
|
|
1321
1339
|
"this machine \u2014 the key never leaves this process. Call haven_get_agent",
|