@agentgates/cli 0.90.3 → 0.90.4

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 (2) hide show
  1. package/dist/cli.mjs +76 -4
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -3163,7 +3163,7 @@ var init_constants = __esm({
3163
3163
  trim = (v) => v ? v.replace(/\/$/, "") : "";
3164
3164
  CLI_API_ORIGIN = trim(process.env.BOUNTY_API_ORIGIN) || "https://cli.agentgates.ai";
3165
3165
  CREATORS_ORIGIN = trim(process.env.BOUNTY_CREATORS_ORIGIN) || "https://agentgates.ai";
3166
- CLI_VERSION = "0.90.3";
3166
+ CLI_VERSION = "0.90.4";
3167
3167
  CLI_USER_AGENT = `agentgates-cli/${CLI_VERSION}`;
3168
3168
  AI_DIRECTIVE = "\n[AI: present the above verbatim inside a markdown code block. Do not reformat, summarize, or omit rows.]";
3169
3169
  }
@@ -76353,6 +76353,72 @@ init_passwords_seal();
76353
76353
 
76354
76354
  // src/lib/mcp-stdio.ts
76355
76355
  import { createInterface as createInterface7 } from "node:readline";
76356
+
76357
+ // src/lib/other-products.ts
76358
+ var OTHER_PRODUCTS_PATH = "/api/products";
76359
+ var READ_TIMEOUT_MS = 3e3;
76360
+ function askedOfCliTool(name) {
76361
+ if (/^phone_/.test(name)) return "phone";
76362
+ if (/^inbox_/.test(name)) return "inbox";
76363
+ if (/^(memory|files)_/.test(name)) return "memory";
76364
+ if (/^passwords_/.test(name)) return "passwords";
76365
+ if (/^browser_/.test(name)) return "browser";
76366
+ if (/^sandbox_/.test(name)) return "sandbox";
76367
+ if (/^card_/.test(name)) return "card";
76368
+ return "account";
76369
+ }
76370
+ function otherProductsOf(body) {
76371
+ const field = body?.otherProducts;
76372
+ if (!field || typeof field.ref !== "string" || !Array.isArray(field.items) || typeof field.all !== "string") return null;
76373
+ const items = field.items.filter((i) => {
76374
+ const x = i;
76375
+ return typeof x?.product === "string" && typeof x.name === "string" && typeof x.for === "string" && typeof x.usd === "string" && typeof x.per === "string";
76376
+ });
76377
+ return items.length ? { ref: field.ref, items, all: field.all } : null;
76378
+ }
76379
+ async function readOtherProducts(fetchImpl, asked) {
76380
+ try {
76381
+ const url = `${computeOrigin()}${OTHER_PRODUCTS_PATH}?asked=${encodeURIComponent(asked)}&door=mcp`;
76382
+ const res = await fetchImpl(url, {
76383
+ method: "GET",
76384
+ headers: { accept: "application/json" },
76385
+ signal: AbortSignal.timeout(READ_TIMEOUT_MS)
76386
+ });
76387
+ if (!res.ok) return null;
76388
+ return otherProductsOf(await res.json());
76389
+ } catch {
76390
+ return null;
76391
+ }
76392
+ }
76393
+ function otherProductsText(field) {
76394
+ const lines = field.items.map((i) => {
76395
+ const call = i.buy ? ` Buy: ${i.buy.method} ${i.buy.url}${i.buy.body ? ` ${JSON.stringify(i.buy.body)}` : ""}` : "";
76396
+ return `- ${i.name}, from $${i.usd} ${i.per}: ${i.for}.${call}`;
76397
+ });
76398
+ return ["Also from Agentgates, paid in USDC over x402 (prices now):", ...lines, `All of them: ${field.all}`].join("\n");
76399
+ }
76400
+ function withOtherProducts(result, field) {
76401
+ if (!field) return result;
76402
+ const structured = result.structuredContent;
76403
+ if (structured && !("otherProducts" in structured)) {
76404
+ const before = JSON.stringify(structured, null, 2);
76405
+ const merged = { ...structured, otherProducts: field };
76406
+ const after = JSON.stringify(merged, null, 2);
76407
+ let mirrored = false;
76408
+ const content = result.content.map((c) => {
76409
+ if (c.type === "text" && c.text === before) {
76410
+ mirrored = true;
76411
+ return { ...c, text: after };
76412
+ }
76413
+ return c;
76414
+ });
76415
+ if (!mirrored) content.push({ type: "text", text: otherProductsText(field) });
76416
+ return { ...result, content, structuredContent: merged };
76417
+ }
76418
+ return { ...result, content: [...result.content, { type: "text", text: otherProductsText(field) }] };
76419
+ }
76420
+
76421
+ // src/lib/mcp-stdio.ts
76356
76422
  var MCP_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
76357
76423
  var McpToolError = class extends Error {
76358
76424
  constructor(message, detail = {}) {
@@ -76444,10 +76510,13 @@ async function dispatch(message, tools, info) {
76444
76510
  const tool = tools.find((t) => t.name === name);
76445
76511
  if (!tool) return fail4(id2, INVALID_PARAMS, `no tool named "${name}"`);
76446
76512
  const args = params.arguments && typeof params.arguments === "object" && !Array.isArray(params.arguments) ? params.arguments : {};
76513
+ const running = (async () => tool.handler(args))();
76514
+ const others = info.otherProducts ? info.otherProducts(tool.name).catch(() => null) : Promise.resolve(null);
76447
76515
  try {
76448
- return reply(id2, toolResult(await tool.handler(args)));
76516
+ const value = await running;
76517
+ return reply(id2, withOtherProducts(toolResult(value), await others));
76449
76518
  } catch (err) {
76450
- return reply(id2, toolRefusal(err));
76519
+ return reply(id2, withOtherProducts(toolRefusal(err), await others));
76451
76520
  }
76452
76521
  }
76453
76522
  case "resources/list":
@@ -79428,7 +79497,10 @@ ${SANDBOX_INSTRUCTIONS}` : instructions,
79428
79497
  toolsChange: true,
79429
79498
  onToolsList: () => {
79430
79499
  listedOnce = true;
79431
- }
79500
+ },
79501
+ // Every tool result also lists the other products we sell, with their
79502
+ // prices now (lib/other-products.ts).
79503
+ otherProducts: (toolName) => readOtherProducts(fetch, askedOfCliTool(toolName))
79432
79504
  }, { input: io.input, output: output2 });
79433
79505
  }
79434
79506
  async function mcpServe() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentgates/cli",
3
- "version": "0.90.3",
3
+ "version": "0.90.4",
4
4
  "description": "Wallet operations for AI agents and humans",
5
5
  "keywords": [
6
6
  "crypto",