@agentwonderland/mcp 0.1.52 → 0.1.54

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.
Files changed (37) hide show
  1. package/dist/core/__tests__/api-client.test.js +40 -0
  2. package/dist/core/__tests__/link-cli.test.d.ts +1 -0
  3. package/dist/core/__tests__/link-cli.test.js +102 -0
  4. package/dist/core/api-client.js +18 -0
  5. package/dist/core/link-cli.d.ts +5 -0
  6. package/dist/core/link-cli.js +25 -25
  7. package/dist/core/version.d.ts +1 -1
  8. package/dist/core/version.js +1 -1
  9. package/dist/index.js +8 -5
  10. package/dist/tools/__tests__/playbooks.test.d.ts +1 -0
  11. package/dist/tools/__tests__/playbooks.test.js +2043 -0
  12. package/dist/tools/__tests__/run.test.js +26 -0
  13. package/dist/tools/__tests__/wallet.test.js +5 -4
  14. package/dist/tools/index.d.ts +1 -0
  15. package/dist/tools/index.js +1 -0
  16. package/dist/tools/passes.js +4 -21
  17. package/dist/tools/playbooks.d.ts +2 -0
  18. package/dist/tools/playbooks.js +880 -0
  19. package/dist/tools/run.js +10 -18
  20. package/dist/tools/solve.js +12 -19
  21. package/dist/tools/wallet.js +9 -12
  22. package/package.json +1 -1
  23. package/src/core/__tests__/api-client.test.ts +44 -0
  24. package/src/core/__tests__/link-cli.test.ts +125 -0
  25. package/src/core/api-client.ts +18 -0
  26. package/src/core/link-cli.ts +25 -27
  27. package/src/core/version.ts +1 -1
  28. package/src/index.ts +8 -5
  29. package/src/tools/__tests__/playbooks.test.ts +2285 -0
  30. package/src/tools/__tests__/run.test.ts +33 -0
  31. package/src/tools/__tests__/wallet.test.ts +5 -4
  32. package/src/tools/index.ts +1 -0
  33. package/src/tools/passes.ts +3 -21
  34. package/src/tools/playbooks.ts +1100 -0
  35. package/src/tools/run.ts +10 -17
  36. package/src/tools/solve.ts +11 -18
  37. package/src/tools/wallet.ts +9 -12
package/src/tools/run.ts CHANGED
@@ -14,13 +14,11 @@ import {
14
14
  hasWalletConfigured,
15
15
  getWalletAddress,
16
16
  normalizePaymentMethod,
17
- isCardPaymentEnabled,
18
17
  } from "../core/payments.js";
19
18
  import { requiresSpendConfirmation, getDefaultTipAmount } from "../core/config.js";
20
19
  import { formatRunResult } from "../core/formatters.js";
21
20
  import { canSpend, recordSpend, requiresPolicyConfirmation } from "../core/spend-policy.js";
22
21
  import { storeFeedbackToken } from "./_token-cache.js";
23
- import { getOrCreatePendingCardSetup, formatCardSetupBlocks } from "../core/card-setup.js";
24
22
  import {
25
23
  formatPaymentLabel,
26
24
  formatRunConfirmationCommand,
@@ -127,30 +125,18 @@ export function registerRunTools(server: McpServer): void {
127
125
  {
128
126
  agent_id: z.string().describe("Agent ID (UUID, slug, or name)"),
129
127
  input: z.record(z.string(), z.unknown()).describe("Input payload for the agent"),
130
- pay_with: z.string().trim().min(1).optional().describe("Payment method — wallet ID, chain name (tempo, base, solana), 'link', or 'card'. Auto-detected if omitted."),
128
+ pay_with: z.string().trim().min(1).optional().describe("Launch payment method — wallet ID or chain name (tempo, base, solana). Auto-detected if omitted."),
131
129
  confirmed: z.boolean().optional().describe("Set to true to confirm spending after seeing the price quote."),
132
130
  },
133
131
  async ({ agent_id, input, pay_with, confirmed }) => {
134
132
  if (!hasWalletConfigured()) {
135
- if (isCardPaymentEnabled()) {
136
- try {
137
- const { url } = await getOrCreatePendingCardSetup();
138
- return multiText(...formatCardSetupBlocks(url));
139
- } catch {
140
- // Fall through to the setup message below.
141
- }
142
- }
143
133
  const setupLines = [
144
134
  "No payment method configured.",
145
135
  "",
146
- "Recommended: wallet_setup({ action: \"add-link\" }) to connect a Link card or bank account.",
147
- "You can also run wallet_setup({ action: \"start\" }) to see all payment options.",
136
+ "Run wallet_setup({ action: \"start\" }) to configure a launch USDC payment method.",
148
137
  "",
149
- "USDC options: Tempo, Base, or Solana.",
138
+ "Launch options: Tempo USDC, Base USDC, or Solana USDC.",
150
139
  ];
151
- if (isCardPaymentEnabled()) {
152
- setupLines.push("", "Or wallet_setup({ action: \"add-card\" }) to connect a credit card.");
153
- }
154
140
  return text(setupLines.join("\n"));
155
141
  }
156
142
 
@@ -220,6 +206,10 @@ export function registerRunTools(server: McpServer): void {
220
206
  ` Payment: ${formatPaymentLabel(method)}`,
221
207
  ];
222
208
 
209
+ if (method === "link") {
210
+ quoteLines.push(" Link: after confirming here, approve the Link spend request and rerun the confirmed call.");
211
+ }
212
+
223
213
  const creditPackLines = buildCreditPackOfferLines(agent);
224
214
  if (creditPackLines.length > 0) {
225
215
  quoteLines.push("", ...creditPackLines);
@@ -299,6 +289,9 @@ export function registerRunTools(server: McpServer): void {
299
289
  );
300
290
  }
301
291
  const msg = apiErr?.message ?? "Failed to run agent";
292
+ if (msg.includes("Link approval required.")) {
293
+ return text(msg);
294
+ }
302
295
  if (msg.includes("Missing required field") || msg.includes("validation failed")) {
303
296
  return text(`Error: ${msg}\n\nUse get_agent("${agent_id}") to see the required input fields.`);
304
297
  }
@@ -1,7 +1,6 @@
1
1
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { z } from "zod";
3
3
  import { apiGet, apiPost, apiPostWithPayment } from "../core/api-client.js";
4
- import { getOrCreatePendingCardSetup, formatCardSetupBlocks } from "../core/card-setup.js";
5
4
  import {
6
5
  getCompatiblePaymentMethods,
7
6
  hasWalletConfigured,
@@ -10,7 +9,6 @@ import {
10
9
  getWalletAddress,
11
10
  normalizePaymentMethod,
12
11
  toRegistryPaymentMethod,
13
- isCardPaymentEnabled,
14
12
  } from "../core/payments.js";
15
13
  import { requiresSpendConfirmation, getDefaultTipAmount } from "../core/config.js";
16
14
  import { agentList, formatRunResult } from "../core/formatters.js";
@@ -159,7 +157,7 @@ export function registerSolveTools(server: McpServer): void {
159
157
  .trim()
160
158
  .min(1)
161
159
  .optional()
162
- .describe("Payment method — wallet ID, chain name (tempo, base, solana), 'link', or 'card'. Auto-detected if omitted."),
160
+ .describe("Launch payment method — wallet ID or chain name (tempo, base, solana). Auto-detected if omitted."),
163
161
  confirmed: z
164
162
  .boolean()
165
163
  .optional()
@@ -167,25 +165,13 @@ export function registerSolveTools(server: McpServer): void {
167
165
  },
168
166
  async ({ intent, input, budget, pay_with, confirmed }) => {
169
167
  if (!hasWalletConfigured()) {
170
- if (isCardPaymentEnabled()) {
171
- try {
172
- const { url } = await getOrCreatePendingCardSetup();
173
- return multiText(...formatCardSetupBlocks(url));
174
- } catch {
175
- // Fall through to the setup message below.
176
- }
177
- }
178
168
  const setupLines = [
179
169
  "No payment method configured.",
180
170
  "",
181
- "Recommended: wallet_setup({ action: \"add-link\" }) to connect a Link card or bank account.",
182
- "You can also run wallet_setup({ action: \"start\" }) to see all payment options.",
171
+ "Run wallet_setup({ action: \"start\" }) to configure a launch USDC payment method.",
183
172
  "",
184
- "USDC options: Tempo, Base, or Solana.",
173
+ "Launch options: Tempo USDC, Base USDC, or Solana USDC.",
185
174
  ];
186
- if (isCardPaymentEnabled()) {
187
- setupLines.push("", "Or wallet_setup({ action: \"add-card\" }) to connect a credit card.");
188
- }
189
175
  return text(setupLines.join("\n"));
190
176
  }
191
177
 
@@ -292,6 +278,9 @@ export function registerSolveTools(server: McpServer): void {
292
278
  `Best match: ${selected.name}`,
293
279
  `Cost: $${estimatedCost.toFixed(2)}`,
294
280
  `Payment: ${formatPaymentLabel(method)}`,
281
+ ...(method === "link"
282
+ ? ["Link: after confirming here, approve the Link spend request and rerun the confirmed call."]
283
+ : []),
295
284
  ...(() => {
296
285
  const summary = buildCreditPackSummary(selected);
297
286
  return summary.length > 0 ? ["", ...summary] : [];
@@ -361,7 +350,11 @@ export function registerSolveTools(server: McpServer): void {
361
350
  ].join("\n"),
362
351
  );
363
352
  }
364
- return text(`Error: ${apiErr?.message ?? "Failed to run agent"}`);
353
+ const msg = apiErr?.message ?? "Failed to run agent";
354
+ if (msg.includes("Link approval required.")) {
355
+ return text(msg);
356
+ }
357
+ return text(`Error: ${msg}`);
365
358
  }
366
359
 
367
360
  pendingSolves.delete(pendingKey);
@@ -66,21 +66,18 @@ function isFreshLinkSetup(pending: { createdAt: string }): boolean {
66
66
 
67
67
  function formatPaymentSetupMenu(): string {
68
68
  return [
69
- "Choose a payment method to set up:",
69
+ "Choose a launch payment method to set up:",
70
70
  "",
71
- "1. Link card or bank account (recommended)",
72
- " wallet_setup({ action: \"add-link\" })",
73
- "",
74
- "2. Tempo USDC",
71
+ "1. Tempo USDC",
75
72
  " wallet_setup({ action: \"create\", chain: \"tempo\" })",
76
73
  "",
77
- "3. Base USDC",
74
+ "2. Base USDC",
78
75
  " wallet_setup({ action: \"create\", chain: \"base\" })",
79
76
  "",
80
- "4. Solana USDC",
77
+ "3. Solana USDC",
81
78
  " wallet_setup({ action: \"create\", chain: \"solana\" })",
82
79
  "",
83
- "5. Import an existing wallet",
80
+ "4. Import an existing wallet",
84
81
  " wallet_setup({ action: \"import\", chain: \"base\", key: \"<private key>\" })",
85
82
  ].join("\n");
86
83
  }
@@ -93,7 +90,7 @@ export function registerWalletTools(server: McpServer): void {
93
90
  // ── wallet_status (extracted from check_wallet) ─────────────────
94
91
  server.tool(
95
92
  "wallet_status",
96
- "Check payment readiness. Shows all configured wallets, their chains, addresses, and card status.",
93
+ "Check launch payment readiness. Shows configured wallets, chains, addresses, and USDC balances.",
97
94
  {},
98
95
  async () => {
99
96
  const wallets = getWallets();
@@ -192,11 +189,11 @@ export function registerWalletTools(server: McpServer): void {
192
189
  // ── wallet_setup ────────────────────────────────────────────────
193
190
  server.tool(
194
191
  "wallet_setup",
195
- "Set up or manage an Agent Wonderland payment method. Use 'start' for a guided setup menu. Link card/bank is recommended for most users. 'add-link' connects a Link card or bank account for agent payments. 'create' makes a new crypto wallet (encrypted via OWS if available, otherwise plaintext — run 'enable-ows' to upgrade). 'import' takes an existing private key. 'enable-ows' installs the Open Wallet Standard native module for encrypted at-rest storage. Tempo/Base share one EVM key; Solana uses a separate ed25519 key. NEVER delete or rotate keys programmatically; direct users to edit ~/.agentwonderland/config.json or ~/.ows/ manually.",
192
+ "Set up or manage an Agent Wonderland launch payment method. Use 'start' for a guided USDC setup menu. 'create' makes a new crypto wallet (encrypted via OWS if available, otherwise plaintext — run 'enable-ows' to upgrade). 'import' takes an existing private key. 'enable-ows' installs the Open Wallet Standard native module for encrypted at-rest storage. Tempo/Base share one EVM key; Solana uses a separate ed25519 key. Card and Link actions are present for non-launch compatibility only and should not be recommended for launch runs. NEVER delete or rotate keys programmatically; direct users to edit ~/.agentwonderland/config.json or ~/.ows/ manually.",
196
193
  {
197
194
  action: z
198
195
  .enum(["start", "create", "import", "add-card", "remove-card", "add-link", "remove-link", "enable-ows"])
199
- .describe("'start' shows the guided payment setup menu, 'add-link' connects Link card/bank, 'create' makes a crypto wallet, 'import' imports an existing key, 'enable-ows' installs encrypted key storage"),
196
+ .describe("'start' shows the guided launch USDC setup menu, 'create' makes a crypto wallet, 'import' imports an existing key, 'enable-ows' installs encrypted key storage; add-card/add-link are non-launch compatibility actions"),
200
197
  name: z
201
198
  .string()
202
199
  .optional()
@@ -212,7 +209,7 @@ export function registerWalletTools(server: McpServer): void {
212
209
  link_payment_method_id: z.string().optional()
213
210
  .describe("Link payment method ID from `npx @stripe/link-cli payment-methods list`; used with action 'add-link'."),
214
211
  link_payment_method: z.string().optional()
215
- .describe("Friendly Link payment method selector, such as a card/bank name or last4; used with action 'add-link'."),
212
+ .describe("Friendly Link payment method selector, such as a saved payment method label or last4; used with action 'add-link'."),
216
213
  },
217
214
  async ({ action, name, key, chain, link_payment_method_id, link_payment_method }) => {
218
215
  if (action === "start") {