@haven_ai/sdk 0.0.0-dev.202609180817.b16be14 → 0.0.0-dev.202609181540.08a5f50
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 +73 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +106 -2
- package/dist/index.d.ts +106 -2
- package/dist/index.js +67 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4738,8 +4738,10 @@ the \`mcp__haven-signer__\` namespace and keep the delegate key on this machine.
|
|
|
4738
4738
|
That namespacing is Claude-family; other runtimes name the servers by their
|
|
4739
4739
|
own config keys (Codex: \`haven\`, \`haven_signer\`). Tool results carry the
|
|
4740
4740
|
exact next step (\`next_action\`, \`next_tool\`, \`next_arguments\`, plus the
|
|
4741
|
-
runtime-neutral \`next_tool_server\` + \`next_tool_name\`
|
|
4742
|
-
on that logical server, whatever your runtime calls it).
|
|
4741
|
+
runtime-neutral \`next_tool_server\` + \`next_tool_name\` + \`next_tool_server_role\`
|
|
4742
|
+
\u2014 the bare tool name on that logical server, whatever your runtime calls it).
|
|
4743
|
+
When no tool follows, \`next_tool\` is absent and \`next_tool_omitted_reason\`
|
|
4744
|
+
says why; that is a complete answer.
|
|
4743
4745
|
Follow those fields first; the prose below is fallback and orientation, not
|
|
4744
4746
|
the source of truth.
|
|
4745
4747
|
|
|
@@ -4954,8 +4956,10 @@ check on in-flight payments. Do not poll in a tight loop.
|
|
|
4954
4956
|
## Failure handling
|
|
4955
4957
|
|
|
4956
4958
|
Haven tool failures are shaped like \`{ success: false, code, message, ... }\`
|
|
4957
|
-
or older \`{ error, status, details? }\` responses.
|
|
4958
|
-
|
|
4959
|
+
or older \`{ error, status, details? }\` responses. A failure carries the same
|
|
4960
|
+
\`next_action\` / \`next_tool\` / \`next_arguments\` / \`next_tool_omitted_reason\`
|
|
4961
|
+
fields a success does; follow them first, then branch on \`code\` and surface
|
|
4962
|
+
\`message\` or \`error\` verbatim. Common cases:
|
|
4959
4963
|
|
|
4960
4964
|
- \`insufficient_funds\`: the Haven wallet doesn't hold enough of that token.
|
|
4961
4965
|
Suggest the user add funds in the Haven dashboard.
|
|
@@ -5016,6 +5020,64 @@ for that credential.
|
|
|
5016
5020
|
var SKILL_FOLDER_NAME = "haven-pay";
|
|
5017
5021
|
var HAVEN_SKILL_BODY_MD = HAVEN_SKILL_MD.replace(/^---\n[\s\S]*?\n---\n+/, "");
|
|
5018
5022
|
|
|
5023
|
+
// src/next-step.ts
|
|
5024
|
+
var NEXT_TOOL_SERVER_NAMES = {
|
|
5025
|
+
hosted: "haven",
|
|
5026
|
+
signer: "haven-signer"
|
|
5027
|
+
};
|
|
5028
|
+
var NEXT_TOOL_SERVER_ROLES = {
|
|
5029
|
+
haven: "hosted",
|
|
5030
|
+
"haven-signer": "signer"
|
|
5031
|
+
};
|
|
5032
|
+
function renderNextTool(role, name) {
|
|
5033
|
+
return `mcp__${NEXT_TOOL_SERVER_NAMES[role]}__${name}`;
|
|
5034
|
+
}
|
|
5035
|
+
function parseNextTool(literal) {
|
|
5036
|
+
const m = /^mcp__([a-z0-9-]+)__([a-z0-9_]+)$/.exec(literal);
|
|
5037
|
+
if (!m) return null;
|
|
5038
|
+
const role = NEXT_TOOL_SERVER_ROLES[m[1]];
|
|
5039
|
+
return { server: m[1], name: m[2], ...role ? { role } : {} };
|
|
5040
|
+
}
|
|
5041
|
+
var DEFAULT_NEXT_TOOL_BY_ACTION = {
|
|
5042
|
+
check_status_later: "haven_get_payment_status",
|
|
5043
|
+
sweep_stranded_funds: "haven_sweep_delegate"
|
|
5044
|
+
// `retry_original_x402_request` is NOT here: its only live emitter
|
|
5045
|
+
// (state-direct-recovery.ts, erc7710) names no tool on purpose — the retry
|
|
5046
|
+
// is the agent's own HTTP call — so a default would contradict the site.
|
|
5047
|
+
};
|
|
5048
|
+
function defaultNextToolFor(action) {
|
|
5049
|
+
return DEFAULT_NEXT_TOOL_BY_ACTION[action];
|
|
5050
|
+
}
|
|
5051
|
+
function createNextStepBuilder(targets) {
|
|
5052
|
+
return function nextStep(input) {
|
|
5053
|
+
const i = input;
|
|
5054
|
+
const base = {
|
|
5055
|
+
next_action: input.nextAction,
|
|
5056
|
+
safe_to_continue: input.safeToContinue,
|
|
5057
|
+
reason: input.reason
|
|
5058
|
+
};
|
|
5059
|
+
if (i.nextTool === null) {
|
|
5060
|
+
return { ...base, next_tool_omitted_reason: i.nextToolOmittedReason ?? "no next tool" };
|
|
5061
|
+
}
|
|
5062
|
+
const target = targets[i.nextTool];
|
|
5063
|
+
if (!target) {
|
|
5064
|
+
return { ...base, next_tool_omitted_reason: `${i.nextTool} is not a registered next-step target` };
|
|
5065
|
+
}
|
|
5066
|
+
const problem = target.validate(i.nextArguments);
|
|
5067
|
+
if (problem) {
|
|
5068
|
+
return { ...base, next_tool_omitted_reason: `next_arguments do not parse under ${i.nextTool}: ${problem}` };
|
|
5069
|
+
}
|
|
5070
|
+
return {
|
|
5071
|
+
...base,
|
|
5072
|
+
next_tool: renderNextTool(target.role, i.nextTool),
|
|
5073
|
+
next_tool_server: NEXT_TOOL_SERVER_NAMES[target.role],
|
|
5074
|
+
next_tool_name: i.nextTool,
|
|
5075
|
+
next_tool_server_role: target.role,
|
|
5076
|
+
next_arguments: i.nextArguments
|
|
5077
|
+
};
|
|
5078
|
+
};
|
|
5079
|
+
}
|
|
5080
|
+
|
|
5019
5081
|
// src/node-version.ts
|
|
5020
5082
|
var HAVEN_MINIMUM_NODE_VERSION = "22.0.0";
|
|
5021
5083
|
function parseNodeVersion(value) {
|
|
@@ -5128,6 +5190,7 @@ exports.AgentPaymentRailSchema = AgentPaymentRailSchema;
|
|
|
5128
5190
|
exports.AgentPaymentWarningCode = AgentPaymentWarningCode;
|
|
5129
5191
|
exports.CONNECTOR_PACKAGE_NAME = CONNECTOR_PACKAGE_NAME;
|
|
5130
5192
|
exports.DEFAULT_CONFIRMATION_TIMEOUT_MS = DEFAULT_CONFIRMATION_TIMEOUT_MS;
|
|
5193
|
+
exports.DEFAULT_NEXT_TOOL_BY_ACTION = DEFAULT_NEXT_TOOL_BY_ACTION;
|
|
5131
5194
|
exports.DISCOVERY_MAX_BYTES = DISCOVERY_MAX_BYTES;
|
|
5132
5195
|
exports.ERC7710_ASSET_TRANSFER_METHOD = ERC7710_ASSET_TRANSFER_METHOD;
|
|
5133
5196
|
exports.HAVEN_AGENT_RUNBOOK_MD = HAVEN_AGENT_RUNBOOK_MD;
|
|
@@ -5147,6 +5210,8 @@ exports.HavenZeroSettlementHashError = HavenZeroSettlementHashError;
|
|
|
5147
5210
|
exports.INSECURE_RETRY_TARGET_CODE = INSECURE_RETRY_TARGET_CODE;
|
|
5148
5211
|
exports.MERCHANT_DISCOVERY_PATHS = MERCHANT_DISCOVERY_PATHS;
|
|
5149
5212
|
exports.MerchantTimeoutError = MerchantTimeoutError;
|
|
5213
|
+
exports.NEXT_TOOL_SERVER_NAMES = NEXT_TOOL_SERVER_NAMES;
|
|
5214
|
+
exports.NEXT_TOOL_SERVER_ROLES = NEXT_TOOL_SERVER_ROLES;
|
|
5150
5215
|
exports.RECEIPT_VERSION = RECEIPT_VERSION;
|
|
5151
5216
|
exports.SIGNER_UPDATE_FALLBACK = SIGNER_UPDATE_FALLBACK;
|
|
5152
5217
|
exports.SKILL_FOLDER_NAME = SKILL_FOLDER_NAME;
|
|
@@ -5175,8 +5240,10 @@ exports.compareNodeVersions = compareNodeVersions;
|
|
|
5175
5240
|
exports.composeDescription = composeDescription;
|
|
5176
5241
|
exports.connectorRerunCommand = connectorRerunCommand;
|
|
5177
5242
|
exports.connectorSpec = connectorSpec;
|
|
5243
|
+
exports.createNextStepBuilder = createNextStepBuilder;
|
|
5178
5244
|
exports.decodeBase64Json = decodeBase64Json;
|
|
5179
5245
|
exports.decodeBase64Utf8 = decodeBase64Utf8;
|
|
5246
|
+
exports.defaultNextToolFor = defaultNextToolFor;
|
|
5180
5247
|
exports.discoverMerchantMcpUrl = discoverMerchantMcpUrl;
|
|
5181
5248
|
exports.encodeBase64Json = encodeBase64Json;
|
|
5182
5249
|
exports.encodeBase64Utf8 = encodeBase64Utf8;
|
|
@@ -5189,9 +5256,11 @@ exports.isSupportedNodeVersion = isSupportedNodeVersion;
|
|
|
5189
5256
|
exports.isSweepableChain = isSweepableChain;
|
|
5190
5257
|
exports.isZeroSettlementTxHash = isZeroSettlementTxHash;
|
|
5191
5258
|
exports.normalizePaymentRequired = normalizePaymentRequired;
|
|
5259
|
+
exports.parseNextTool = parseNextTool;
|
|
5192
5260
|
exports.parsePaymentRequired = parsePaymentRequired;
|
|
5193
5261
|
exports.parsePaymentRequiredResponse = parsePaymentRequiredResponse;
|
|
5194
5262
|
exports.readX402ReceiptPayer = readX402ReceiptPayer;
|
|
5263
|
+
exports.renderNextTool = renderNextTool;
|
|
5195
5264
|
exports.resolveConnectorChannel = resolveConnectorChannel;
|
|
5196
5265
|
exports.resolveTokenFromAddress = resolveTokenFromAddress;
|
|
5197
5266
|
exports.resolveX402RetryTarget = resolveX402RetryTarget;
|