@livx.cc/agentx 0.99.50 → 0.99.52

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
@@ -9167,8 +9167,35 @@ function describeSpec(s) {
9167
9167
  args: ${JSON.stringify(s.inputSchema)}` : "";
9168
9168
  return `${s.name} \u2014 ${s.description ?? "(no description)"}${schema}`;
9169
9169
  }
9170
+ function editDistance(a, b) {
9171
+ let prev = Array.from({ length: b.length + 1 }, (_, j) => j);
9172
+ for (let i = 1; i <= a.length; i++) {
9173
+ const cur = [i];
9174
+ for (let j = 1; j <= b.length; j++) cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
9175
+ prev = cur;
9176
+ }
9177
+ return prev[b.length];
9178
+ }
9179
+ function closestName(name, known) {
9180
+ let best, bestD = Infinity;
9181
+ for (const k of known) {
9182
+ const d = editDistance(name.toLowerCase(), k.toLowerCase());
9183
+ if (d < bestD) {
9184
+ best = k;
9185
+ bestD = d;
9186
+ }
9187
+ }
9188
+ return best !== void 0 && bestD <= Math.max(2, Math.floor(name.length * 0.3)) ? best : void 0;
9189
+ }
9190
+ function unknownMcpToolMessage(name, known, prefix = "mcp__") {
9191
+ const guess = closestName(name, known);
9192
+ if (guess) return `Error: unknown MCP tool '${name}' \u2014 did you mean '${guess}'?`;
9193
+ if (!name.startsWith(prefix) && known.some((k) => k.startsWith(prefix))) return `Error: '${name}' is not an MCP tool (MCP tool names start with '${prefix}'). If it is one of your own tools, call it directly, not via McpCall; otherwise use ToolSearch to find the MCP tool you need.`;
9194
+ return `Error: unknown MCP tool '${name}'. Use ToolSearch to find valid names.`;
9195
+ }
9170
9196
  function makeMcpToolSearch(specs, callTool, options = {}) {
9171
9197
  const maxResults = options.maxResults ?? 10;
9198
+ const prefix = options.prefix ?? "mcp__";
9172
9199
  const callTimeoutMs = options.timeoutMs ?? MCP_CALL_TIMEOUT_MS;
9173
9200
  const byName = new Map(specs.map((s) => [s.name, s]));
9174
9201
  const catalogLine = `${specs.length} MCP tool(s) available \u2014 search by keyword, then call by exact name.`;
@@ -9196,9 +9223,12 @@ function makeMcpToolSearch(specs, callTool, options = {}) {
9196
9223
  }
9197
9224
  },
9198
9225
  maxDurationMs: callTimeoutMs,
9199
- async run({ name, args }, ctx) {
9200
- const n = String(name ?? "");
9201
- if (!byName.has(n)) return `Error: unknown MCP tool '${n}'. Use ToolSearch to find valid names.`;
9226
+ async run(input, ctx) {
9227
+ const { name, args } = input ?? {};
9228
+ const n = String(name ?? "").trim();
9229
+ if (!n) return `Error: McpCall requires \`name\` (the exact MCP tool name) \u2014 got keys [${Object.keys(input ?? {}).join(", ")}]. Call it as McpCall({ name: "mcp__<server>__<tool>", args: {...} }).`;
9230
+ if (n === searchTool.name) return searchTool.run({ query: args?.query ?? args?.keyword ?? args?.q }, ctx);
9231
+ if (!byName.has(n)) return unknownMcpToolMessage(n, [...byName.keys()], prefix);
9202
9232
  return runMcpCall(n, (o) => callTool(n, args ?? {}, o), ctx, callTimeoutMs);
9203
9233
  }
9204
9234
  };
@@ -13716,6 +13746,11 @@ function parseArgs(argv) {
13716
13746
  const f = argv[++i];
13717
13747
  if (f !== "text" && f !== "json" && f !== "stream-json") throw new Error(`invalid --output-format: ${f ?? "(missing)"} (use text|json|stream-json)`);
13718
13748
  a.outputFormat = f;
13749
+ } else if (x === "--") {
13750
+ rest.push(...argv.slice(i + 1));
13751
+ break;
13752
+ } else if (x.length > 1 && x.startsWith("-")) {
13753
+ throw new Error(`unknown flag: ${x} (see --help; to pass it as prompt text, put it after \`--\`)`);
13719
13754
  } else rest.push(x);
13720
13755
  }
13721
13756
  if (!a.task && rest.length) a.task = rest.join(" ");