@haven_ai/sdk 0.0.0-dev.202609180817.b16be14 → 0.0.0-dev.202609181352.6793586

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
@@ -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\` \u2014 the bare 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
 
@@ -5016,6 +5018,64 @@ for that credential.
5016
5018
  var SKILL_FOLDER_NAME = "haven-pay";
5017
5019
  var HAVEN_SKILL_BODY_MD = HAVEN_SKILL_MD.replace(/^---\n[\s\S]*?\n---\n+/, "");
5018
5020
 
5021
+ // src/next-step.ts
5022
+ var NEXT_TOOL_SERVER_NAMES = {
5023
+ hosted: "haven",
5024
+ signer: "haven-signer"
5025
+ };
5026
+ var NEXT_TOOL_SERVER_ROLES = {
5027
+ haven: "hosted",
5028
+ "haven-signer": "signer"
5029
+ };
5030
+ function renderNextTool(role, name) {
5031
+ return `mcp__${NEXT_TOOL_SERVER_NAMES[role]}__${name}`;
5032
+ }
5033
+ function parseNextTool(literal) {
5034
+ const m = /^mcp__([a-z0-9-]+)__([a-z0-9_]+)$/.exec(literal);
5035
+ if (!m) return null;
5036
+ const role = NEXT_TOOL_SERVER_ROLES[m[1]];
5037
+ return { server: m[1], name: m[2], ...role ? { role } : {} };
5038
+ }
5039
+ var DEFAULT_NEXT_TOOL_BY_ACTION = {
5040
+ check_status_later: "haven_get_payment_status",
5041
+ sweep_stranded_funds: "haven_sweep_delegate"
5042
+ // `retry_original_x402_request` is NOT here: its only live emitter
5043
+ // (state-direct-recovery.ts, erc7710) names no tool on purpose — the retry
5044
+ // is the agent's own HTTP call — so a default would contradict the site.
5045
+ };
5046
+ function defaultNextToolFor(action) {
5047
+ return DEFAULT_NEXT_TOOL_BY_ACTION[action];
5048
+ }
5049
+ function createNextStepBuilder(targets) {
5050
+ return function nextStep(input) {
5051
+ const i = input;
5052
+ const base = {
5053
+ next_action: input.nextAction,
5054
+ safe_to_continue: input.safeToContinue,
5055
+ reason: input.reason
5056
+ };
5057
+ if (i.nextTool === null) {
5058
+ return { ...base, next_tool_omitted_reason: i.nextToolOmittedReason ?? "no next tool" };
5059
+ }
5060
+ const target = targets[i.nextTool];
5061
+ if (!target) {
5062
+ return { ...base, next_tool_omitted_reason: `${i.nextTool} is not a registered next-step target` };
5063
+ }
5064
+ const problem = target.validate(i.nextArguments);
5065
+ if (problem) {
5066
+ return { ...base, next_tool_omitted_reason: `next_arguments do not parse under ${i.nextTool}: ${problem}` };
5067
+ }
5068
+ return {
5069
+ ...base,
5070
+ next_tool: renderNextTool(target.role, i.nextTool),
5071
+ next_tool_server: NEXT_TOOL_SERVER_NAMES[target.role],
5072
+ next_tool_name: i.nextTool,
5073
+ next_tool_server_role: target.role,
5074
+ next_arguments: i.nextArguments
5075
+ };
5076
+ };
5077
+ }
5078
+
5019
5079
  // src/node-version.ts
5020
5080
  var HAVEN_MINIMUM_NODE_VERSION = "22.0.0";
5021
5081
  function parseNodeVersion(value) {
@@ -5128,6 +5188,7 @@ exports.AgentPaymentRailSchema = AgentPaymentRailSchema;
5128
5188
  exports.AgentPaymentWarningCode = AgentPaymentWarningCode;
5129
5189
  exports.CONNECTOR_PACKAGE_NAME = CONNECTOR_PACKAGE_NAME;
5130
5190
  exports.DEFAULT_CONFIRMATION_TIMEOUT_MS = DEFAULT_CONFIRMATION_TIMEOUT_MS;
5191
+ exports.DEFAULT_NEXT_TOOL_BY_ACTION = DEFAULT_NEXT_TOOL_BY_ACTION;
5131
5192
  exports.DISCOVERY_MAX_BYTES = DISCOVERY_MAX_BYTES;
5132
5193
  exports.ERC7710_ASSET_TRANSFER_METHOD = ERC7710_ASSET_TRANSFER_METHOD;
5133
5194
  exports.HAVEN_AGENT_RUNBOOK_MD = HAVEN_AGENT_RUNBOOK_MD;
@@ -5147,6 +5208,8 @@ exports.HavenZeroSettlementHashError = HavenZeroSettlementHashError;
5147
5208
  exports.INSECURE_RETRY_TARGET_CODE = INSECURE_RETRY_TARGET_CODE;
5148
5209
  exports.MERCHANT_DISCOVERY_PATHS = MERCHANT_DISCOVERY_PATHS;
5149
5210
  exports.MerchantTimeoutError = MerchantTimeoutError;
5211
+ exports.NEXT_TOOL_SERVER_NAMES = NEXT_TOOL_SERVER_NAMES;
5212
+ exports.NEXT_TOOL_SERVER_ROLES = NEXT_TOOL_SERVER_ROLES;
5150
5213
  exports.RECEIPT_VERSION = RECEIPT_VERSION;
5151
5214
  exports.SIGNER_UPDATE_FALLBACK = SIGNER_UPDATE_FALLBACK;
5152
5215
  exports.SKILL_FOLDER_NAME = SKILL_FOLDER_NAME;
@@ -5175,8 +5238,10 @@ exports.compareNodeVersions = compareNodeVersions;
5175
5238
  exports.composeDescription = composeDescription;
5176
5239
  exports.connectorRerunCommand = connectorRerunCommand;
5177
5240
  exports.connectorSpec = connectorSpec;
5241
+ exports.createNextStepBuilder = createNextStepBuilder;
5178
5242
  exports.decodeBase64Json = decodeBase64Json;
5179
5243
  exports.decodeBase64Utf8 = decodeBase64Utf8;
5244
+ exports.defaultNextToolFor = defaultNextToolFor;
5180
5245
  exports.discoverMerchantMcpUrl = discoverMerchantMcpUrl;
5181
5246
  exports.encodeBase64Json = encodeBase64Json;
5182
5247
  exports.encodeBase64Utf8 = encodeBase64Utf8;
@@ -5189,9 +5254,11 @@ exports.isSupportedNodeVersion = isSupportedNodeVersion;
5189
5254
  exports.isSweepableChain = isSweepableChain;
5190
5255
  exports.isZeroSettlementTxHash = isZeroSettlementTxHash;
5191
5256
  exports.normalizePaymentRequired = normalizePaymentRequired;
5257
+ exports.parseNextTool = parseNextTool;
5192
5258
  exports.parsePaymentRequired = parsePaymentRequired;
5193
5259
  exports.parsePaymentRequiredResponse = parsePaymentRequiredResponse;
5194
5260
  exports.readX402ReceiptPayer = readX402ReceiptPayer;
5261
+ exports.renderNextTool = renderNextTool;
5195
5262
  exports.resolveConnectorChannel = resolveConnectorChannel;
5196
5263
  exports.resolveTokenFromAddress = resolveTokenFromAddress;
5197
5264
  exports.resolveX402RetryTarget = resolveX402RetryTarget;