@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
@@ -146,4 +146,30 @@ describe("run_agent MCP tool", () => {
146
146
  expect(text).toContain("Paid: $0.01 via card");
147
147
  expect(text).toContain("Job ID: job-1");
148
148
  });
149
+ it("returns Link approval instructions without wrapping them as an execution error", async () => {
150
+ mockGetConfiguredMethods.mockReturnValue(["link"]);
151
+ mockGetCompatiblePaymentMethods.mockReturnValue(["link"]);
152
+ mockApiPostWithPayment.mockRejectedValueOnce(new Error([
153
+ "Link approval required.",
154
+ "The agent has not run yet and no charge has been captured.",
155
+ "Approve this spend request in Link: https://link.example/approve/lsrq_test",
156
+ "After approving, rerun the same tool call with confirmed: true.",
157
+ ].join("\n")));
158
+ const { registerRunTools } = await import("../run.js");
159
+ const harness = makeServerHarness();
160
+ registerRunTools(harness.server);
161
+ const runAgent = harness.handlers.get("run_agent");
162
+ expect(runAgent).toBeDefined();
163
+ const result = await runAgent({
164
+ agent_id: selectedAgent.id,
165
+ input: { text: "hello", target_language: "es" },
166
+ pay_with: "link",
167
+ confirmed: true,
168
+ });
169
+ const text = flattenToolText(result);
170
+ expect(text).toContain("Link approval required.");
171
+ expect(text).toContain("https://link.example/approve/lsrq_test");
172
+ expect(text).not.toContain("Error: Link approval required.");
173
+ expect(mockRecordSpend).not.toHaveBeenCalled();
174
+ });
149
175
  });
@@ -219,9 +219,9 @@ describe("wallet_setup tool", () => {
219
219
  const walletSetup = await getWalletSetupTool();
220
220
  const result = await walletSetup({ action: "start" });
221
221
  const text = flattenText(result);
222
- expect(text).toContain("Choose a payment method to set up:");
223
- expect(text).toContain("Link card or bank account (recommended)");
224
- expect(text).toContain('wallet_setup({ action: "add-link" })');
222
+ expect(text).toContain("Choose a launch payment method to set up:");
223
+ expect(text).not.toContain("Link card or bank account (recommended)");
224
+ expect(text).not.toContain('wallet_setup({ action: "add-link" })');
225
225
  expect(text).toContain('wallet_setup({ action: "create", chain: "tempo" })');
226
226
  expect(text).toContain('wallet_setup({ action: "create", chain: "base" })');
227
227
  expect(text).toContain('wallet_setup({ action: "create", chain: "solana" })');
@@ -241,7 +241,8 @@ describe("wallet_setup tool", () => {
241
241
  const result = await walletStatus({});
242
242
  const text = flattenText(result);
243
243
  expect(text).toContain("No payment methods configured.");
244
- expect(text).toContain("Link card or bank account (recommended)");
244
+ expect(text).toContain("Choose a launch payment method to set up:");
245
+ expect(text).not.toContain("Link card or bank account (recommended)");
245
246
  });
246
247
  it("imports a wallet into OWS encrypted storage with Base as the default chain", async () => {
247
248
  const walletSetup = await getWalletSetupTool();
@@ -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,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";
@@ -1,18 +1,14 @@
1
1
  import { z } from "zod";
2
2
  import { apiGet, apiPostWithPayment } from "../core/api-client.js";
3
3
  import { formatCreditPack, formatCreditPackOffer, getCreditPackInventory, getCreditPackProgram, } from "../core/passes.js";
4
- import { getCompatiblePaymentMethods, getConfiguredMethods, hasWalletConfigured, normalizePaymentMethod, isCardPaymentEnabled, } from "../core/payments.js";
4
+ import { getCompatiblePaymentMethods, getConfiguredMethods, hasWalletConfigured, normalizePaymentMethod, } from "../core/payments.js";
5
5
  import { requiresSpendConfirmation } from "../core/config.js";
6
6
  import { ensureConsumerPrincipalForMethod } from "../core/principal.js";
7
- import { getOrCreatePendingCardSetup, formatCardSetupBlocks } from "../core/card-setup.js";
8
7
  import { formatPaymentChoicePrompt, formatPaymentLabel, resolveConfirmationMethod, } from "./_payment-confirmation.js";
9
8
  const pendingCreditPackPurchases = new Map();
10
9
  function text(t) {
11
10
  return { content: [{ type: "text", text: t }] };
12
11
  }
13
- function multiText(...blocks) {
14
- return { content: blocks.map((t) => ({ type: "text", text: t })) };
15
- }
16
12
  async function getAgent(agentId) {
17
13
  return apiGet(`/agents/${agentId}`);
18
14
  }
@@ -35,30 +31,17 @@ export function registerPassTools(server) {
35
31
  server.tool("buy_agent_credit_pack", "Purchase a discounted prepaid credit pack for an agent. Credit packs are agent-specific and automatically cover future runs until the included units run out.", {
36
32
  agent_id: z.string().describe("Agent ID (UUID, slug, or name)"),
37
33
  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."),
38
- pay_with: z.string().optional().describe("Payment method — wallet ID, chain name, 'link', or 'card'. Auto-detected if omitted."),
34
+ pay_with: z.string().optional().describe("Launch payment method — wallet ID or chain name (tempo, base, solana). Auto-detected if omitted."),
39
35
  confirmed: z.boolean().optional().describe("Set to true to confirm the purchase after seeing the quote."),
40
36
  }, async ({ agent_id, pack_id, pay_with, confirmed }) => {
41
37
  if (!hasWalletConfigured()) {
42
- if (isCardPaymentEnabled()) {
43
- try {
44
- const { url } = await getOrCreatePendingCardSetup();
45
- return multiText(...formatCardSetupBlocks(url));
46
- }
47
- catch {
48
- // Fall through to the setup message below.
49
- }
50
- }
51
38
  const setupLines = [
52
39
  "No payment method configured.",
53
40
  "",
54
- "Recommended: wallet_setup({ action: \"add-link\" }) to connect a Link card or bank account.",
55
- "You can also run wallet_setup({ action: \"start\" }) to see all payment options.",
41
+ "Run wallet_setup({ action: \"start\" }) to configure a launch USDC payment method.",
56
42
  "",
57
- "USDC options: Tempo, Base, or Solana.",
43
+ "Launch options: Tempo USDC, Base USDC, or Solana USDC.",
58
44
  ];
59
- if (isCardPaymentEnabled()) {
60
- setupLines.push("", "Or wallet_setup({ action: \"add-card\" }) to connect a credit card.");
61
- }
62
45
  return text(setupLines.join("\n"));
63
46
  }
64
47
  const agent = await getAgent(agent_id);
@@ -0,0 +1,2 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ export declare function registerPlaybookTools(server: McpServer): void;