@haven_ai/mcp 0.3.0-alpha.0 → 0.4.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/cli.js CHANGED
@@ -302,11 +302,14 @@ var toolSchemas = {
302
302
  website: z.string().optional()
303
303
  },
304
304
  haven_list_receipts: {
305
- limit: z.number().int().min(1).max(100).optional()
305
+ limit: z.number().int().min(1).max(100).optional(),
306
+ /** #3128: the previous page's next_cursor (a receipt id). */
307
+ cursor: z.string().min(1).optional()
306
308
  },
307
309
  haven_verify_receipt: {
308
310
  receipt: z.unknown()
309
311
  }
312
+ // #3101: keys survive on the type (see the hosted server's contracts.ts).
310
313
  };
311
314
  var toolDescriptions = {
312
315
  haven_send: composeDescription(toolDescriptions$1.send),
@@ -497,12 +500,32 @@ function createToolHandlers(haven) {
497
500
  source: entry.source,
498
501
  domain_verified: entry.domainVerified,
499
502
  verified_payable: entry.verifiedPayable,
500
- // Which Haven pay tool reaches this entry from the local MCP surface.
503
+ // Which Haven pay tool reaches this entry from the local MCP surface,
504
+ // and — #3100 (epic #3105, decision 4) — the arguments that tool
505
+ // accepts VERBATIM, spelled in ITS vocabulary (`merchant_url`, not
506
+ // the entry's `resource_url`). The local surface keeps pointing at
507
+ // its pay tools: they need no cap, so a verbatim hint exists.
501
508
  // #1328: the 'mpp' rail's only-ever catalog row (the Haven MPP demo
502
509
  // resource) is delisted with the mpp_demo retirement, so this
503
510
  // fallback is unreachable today; it stays x402 rather than naming a
504
511
  // deleted tool in case a future non-demo 'mpp' rail entry appears.
505
- suggested_tool: entry.protocol === "mcp" ? "haven_pay_mcp_tool" : "haven_pay_x402"
512
+ // A row without a tool_name cannot get a verbatim hint —
513
+ // haven_pay_mcp_tool requires tool_name — so it gets the REASON
514
+ // instead of a hint its own tool refuses (haven-reviewer on #3113;
515
+ // the epic's "omitted + reason, never null" shape, decision 3).
516
+ ...entry.protocol === "mcp" ? entry.toolName ? {
517
+ suggested_tool: "haven_pay_mcp_tool",
518
+ suggested_arguments: {
519
+ merchant_url: entry.resourceUrl,
520
+ tool_name: entry.toolName,
521
+ ...entry.toolArguments ? { arguments: entry.toolArguments } : {}
522
+ }
523
+ } : {
524
+ suggested_tool_omitted_reason: "this catalog row carries no tool_name, which haven_pay_mcp_tool requires; read the merchant's tool list yourself, then call haven_pay_mcp_tool with merchant_url, tool_name and arguments"
525
+ } : {
526
+ suggested_tool: "haven_pay_x402",
527
+ suggested_arguments: { url: entry.resourceUrl }
528
+ }
506
529
  }));
507
530
  });
508
531
  },
@@ -522,7 +545,7 @@ function createToolHandlers(haven) {
522
545
  },
523
546
  haven_list_receipts: async (input) => {
524
547
  const args = objectInput("haven_list_receipts", input);
525
- return runTool(async () => haven.listReceipts({ limit: args.limit }));
548
+ return runTool(async () => haven.listReceiptsPage({ limit: args.limit, cursor: args.cursor }));
526
549
  },
527
550
  haven_verify_receipt: async (input) => {
528
551
  const args = objectInput("haven_verify_receipt", input);
@@ -667,7 +690,11 @@ function normalizeError(err) {
667
690
  message: err.message,
668
691
  statusCode: err.statusCode,
669
692
  nextAction: err.nextAction,
670
- retry_with_new_quote: err.retryWithNewQuote
693
+ next_action: err.nextAction,
694
+ retry_with_new_quote: err.retryWithNewQuote,
695
+ // #3103: the local runtime's one decision site — no tool can act until
696
+ // the merchant recovers; the message carries retry_after_s.
697
+ next_tool_omitted_reason: "the merchant needs to recover first; re-quote after the retry_after_s in the message"
671
698
  };
672
699
  }
673
700
  if (err instanceof HavenPaymentStateError) {
@@ -680,6 +707,7 @@ function normalizeError(err) {
680
707
  status: err.status,
681
708
  phase: err.phase,
682
709
  nextAction: err.nextAction,
710
+ next_action: err.nextAction,
683
711
  resume_state: err.resumeState,
684
712
  body: err.body
685
713
  };
@@ -701,6 +729,7 @@ function normalizeError(err) {
701
729
  paymentId: err.paymentId,
702
730
  phase: stringOrUndefined(body?.phase),
703
731
  nextAction: stringOrUndefined(body?.nextAction) ?? stringOrUndefined(body?.next_action) ?? AgentPaymentNextAction.StopAndTellUser,
732
+ next_action: stringOrUndefined(body?.nextAction) ?? stringOrUndefined(body?.next_action) ?? AgentPaymentNextAction.StopAndTellUser,
704
733
  body: err.body
705
734
  };
706
735
  }
@@ -717,7 +746,11 @@ function normalizeError(err) {
717
746
  success: false,
718
747
  code: "UNKNOWN_ERROR",
719
748
  message: err instanceof Error ? err.message : String(err),
720
- nextAction: AgentPaymentNextAction.StopAndTellUser
749
+ nextAction: AgentPaymentNextAction.StopAndTellUser,
750
+ next_action: AgentPaymentNextAction.StopAndTellUser,
751
+ // #3103: the second local decision site — nothing structured can follow an
752
+ // error this runtime did not recognise.
753
+ next_tool_omitted_reason: "an error this runtime does not recognise; tell the user what the message says"
721
754
  };
722
755
  }
723
756
  function stringOrUndefined(value) {
@@ -913,7 +946,7 @@ async function resolveHavenClient(options = {}) {
913
946
  return { client, credentials };
914
947
  }
915
948
  var MCP_NAME = "@haven_ai/mcp";
916
- var MCP_VERSION = "0.3.0-alpha.0";
949
+ var MCP_VERSION = "0.4.0-alpha.0";
917
950
  var MCP_INSTRUCTIONS = [
918
951
  "Haven local MCP server: signs in-process with the delegate key it holds on",
919
952
  "this machine \u2014 the key never leaves this process. Call haven_get_agent",
@@ -922,7 +955,8 @@ var MCP_INSTRUCTIONS = [
922
955
  "",
923
956
  "To pay: haven_discover_tools to find a payable service, then",
924
957
  "haven_pay_mcp_tool for MCP merchants or haven_pay_x402 for any x402",
925
- "paywall. Tool responses carry nextAction \u2014 follow it; description prose",
958
+ "paywall. Tool responses carry next_action (nextAction is the same value, kept one more",
959
+ "release) and, when no tool follows, next_tool_omitted_reason \u2014 follow them; description prose",
926
960
  "is fallback, not the source of truth.",
927
961
  "",
928
962
  "A payment outside the agent budget is declined before any money moves. Haven",