@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
@@ -173,4 +173,37 @@ describe("run_agent MCP tool", () => {
173
173
  expect(text).toContain("Paid: $0.01 via card");
174
174
  expect(text).toContain("Job ID: job-1");
175
175
  });
176
+
177
+ it("returns Link approval instructions without wrapping them as an execution error", async () => {
178
+ mockGetConfiguredMethods.mockReturnValue(["link"]);
179
+ mockGetCompatiblePaymentMethods.mockReturnValue(["link"]);
180
+ mockApiPostWithPayment.mockRejectedValueOnce(
181
+ new Error([
182
+ "Link approval required.",
183
+ "The agent has not run yet and no charge has been captured.",
184
+ "Approve this spend request in Link: https://link.example/approve/lsrq_test",
185
+ "After approving, rerun the same tool call with confirmed: true.",
186
+ ].join("\n")),
187
+ );
188
+
189
+ const { registerRunTools } = await import("../run.js");
190
+ const harness = makeServerHarness();
191
+ registerRunTools(harness.server as never);
192
+
193
+ const runAgent = harness.handlers.get("run_agent");
194
+ expect(runAgent).toBeDefined();
195
+
196
+ const result = await runAgent!({
197
+ agent_id: selectedAgent.id,
198
+ input: { text: "hello", target_language: "es" },
199
+ pay_with: "link",
200
+ confirmed: true,
201
+ });
202
+ const text = flattenToolText(result);
203
+
204
+ expect(text).toContain("Link approval required.");
205
+ expect(text).toContain("https://link.example/approve/lsrq_test");
206
+ expect(text).not.toContain("Error: Link approval required.");
207
+ expect(mockRecordSpend).not.toHaveBeenCalled();
208
+ });
176
209
  });
@@ -287,9 +287,9 @@ describe("wallet_setup tool", () => {
287
287
  const result = await walletSetup({ action: "start" });
288
288
  const text = flattenText(result);
289
289
 
290
- expect(text).toContain("Choose a payment method to set up:");
291
- expect(text).toContain("Link card or bank account (recommended)");
292
- expect(text).toContain('wallet_setup({ action: "add-link" })');
290
+ expect(text).toContain("Choose a launch payment method to set up:");
291
+ expect(text).not.toContain("Link card or bank account (recommended)");
292
+ expect(text).not.toContain('wallet_setup({ action: "add-link" })');
293
293
  expect(text).toContain('wallet_setup({ action: "create", chain: "tempo" })');
294
294
  expect(text).toContain('wallet_setup({ action: "create", chain: "base" })');
295
295
  expect(text).toContain('wallet_setup({ action: "create", chain: "solana" })');
@@ -317,7 +317,8 @@ describe("wallet_setup tool", () => {
317
317
  const text = flattenText(result);
318
318
 
319
319
  expect(text).toContain("No payment methods configured.");
320
- expect(text).toContain("Link card or bank account (recommended)");
320
+ expect(text).toContain("Choose a launch payment method to set up:");
321
+ expect(text).not.toContain("Link card or bank account (recommended)");
321
322
  });
322
323
 
323
324
  it("imports a wallet into OWS encrypted storage with Base as the default chain", async () => {
@@ -12,3 +12,4 @@ export { registerRebateTools } from "./rebates.js";
12
12
  export { registerUploadTools } from "./upload.js";
13
13
  export { registerProbeTools } from "./probe.js";
14
14
  export { registerProviderTools } from "./providers.js";
15
+ export { registerPlaybookTools } from "./playbooks.js";
@@ -12,11 +12,9 @@ import {
12
12
  getConfiguredMethods,
13
13
  hasWalletConfigured,
14
14
  normalizePaymentMethod,
15
- isCardPaymentEnabled,
16
15
  } from "../core/payments.js";
17
16
  import { requiresSpendConfirmation } from "../core/config.js";
18
17
  import { ensureConsumerPrincipalForMethod } from "../core/principal.js";
19
- import { getOrCreatePendingCardSetup, formatCardSetupBlocks } from "../core/card-setup.js";
20
18
  import {
21
19
  formatPaymentChoicePrompt,
22
20
  formatPaymentLabel,
@@ -36,10 +34,6 @@ function text(t: string) {
36
34
  return { content: [{ type: "text" as const, text: t }] };
37
35
  }
38
36
 
39
- function multiText(...blocks: string[]) {
40
- return { content: blocks.map((t) => ({ type: "text" as const, text: t })) };
41
- }
42
-
43
37
  async function getAgent(agentId: string): Promise<AgentRecord> {
44
38
  return apiGet<AgentRecord>(`/agents/${agentId}`);
45
39
  }
@@ -67,30 +61,18 @@ export function registerPassTools(server: McpServer): void {
67
61
  {
68
62
  agent_id: z.string().describe("Agent ID (UUID, slug, or name)"),
69
63
  pack_id: z.string().optional().describe("Specific pack key to buy, like 'starter' or 'growth'. If omitted and only one pack exists, it is selected automatically."),
70
- pay_with: z.string().optional().describe("Payment method — wallet ID, chain name, 'link', or 'card'. Auto-detected if omitted."),
64
+ pay_with: z.string().optional().describe("Launch payment method — wallet ID or chain name (tempo, base, solana). Auto-detected if omitted."),
71
65
  confirmed: z.boolean().optional().describe("Set to true to confirm the purchase after seeing the quote."),
72
66
  },
73
67
  async ({ agent_id, pack_id, pay_with, confirmed }) => {
74
68
  if (!hasWalletConfigured()) {
75
- if (isCardPaymentEnabled()) {
76
- try {
77
- const { url } = await getOrCreatePendingCardSetup();
78
- return multiText(...formatCardSetupBlocks(url));
79
- } catch {
80
- // Fall through to the setup message below.
81
- }
82
- }
83
69
  const setupLines = [
84
70
  "No payment method configured.",
85
71
  "",
86
- "Recommended: wallet_setup({ action: \"add-link\" }) to connect a Link card or bank account.",
87
- "You can also run wallet_setup({ action: \"start\" }) to see all payment options.",
72
+ "Run wallet_setup({ action: \"start\" }) to configure a launch USDC payment method.",
88
73
  "",
89
- "USDC options: Tempo, Base, or Solana.",
74
+ "Launch options: Tempo USDC, Base USDC, or Solana USDC.",
90
75
  ];
91
- if (isCardPaymentEnabled()) {
92
- setupLines.push("", "Or wallet_setup({ action: \"add-card\" }) to connect a credit card.");
93
- }
94
76
  return text(setupLines.join("\n"));
95
77
  }
96
78