@agent-smith/cli 0.0.68 → 0.0.70

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.
@@ -1,4 +1,4 @@
1
- import { actionOptions, taskOptions, workflowOptions } from "../options.js";
1
+ import { allOptions } from "../options.js";
2
2
  import { executeTaskCmd } from "../lib/tasks/cmd.js";
3
3
  import { executeActionCmd } from "../lib/actions/cmd.js";
4
4
  import { executeWorkflowCmd } from "../lib/workflows/cmd.js";
@@ -11,7 +11,7 @@ function initCommandsFromAliases(program, aliases, features) {
11
11
  .action(async (...args) => {
12
12
  await executeTaskCmd(alias.name, args);
13
13
  });
14
- taskOptions.forEach(o => tcmd.addOption(o));
14
+ allOptions.forEach(o => tcmd.addOption(o));
15
15
  if (features.task[alias.name]?.variables) {
16
16
  features.task[alias.name].variables?.optional.forEach(v => {
17
17
  tcmd.option(`--${v} <value>`);
@@ -27,7 +27,7 @@ function initCommandsFromAliases(program, aliases, features) {
27
27
  .action(async (...args) => {
28
28
  await executeActionCmd(alias.name, args);
29
29
  });
30
- actionOptions.forEach(o => acmd.addOption(o));
30
+ allOptions.forEach(o => acmd.addOption(o));
31
31
  break;
32
32
  case "workflow":
33
33
  const wcmd = program.command(`${alias.name} [args...]`)
@@ -35,7 +35,7 @@ function initCommandsFromAliases(program, aliases, features) {
35
35
  .action(async (...args) => {
36
36
  executeWorkflowCmd(alias.name, args);
37
37
  });
38
- workflowOptions.forEach(o => wcmd.addOption(o));
38
+ allOptions.forEach(o => wcmd.addOption(o));
39
39
  }
40
40
  });
41
41
  return program;
package/dist/cmd/cmds.js CHANGED
@@ -38,6 +38,8 @@ async function buildCmds() {
38
38
  return program;
39
39
  }
40
40
  async function parseCmd(program) {
41
+ program.name('Agent Smith terminal client');
42
+ program.description('Terminal agents toolkit');
41
43
  await program.parseAsync();
42
44
  }
43
45
  export { program, buildCmds, chat, parseCmd, };
@@ -1,14 +1,15 @@
1
1
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
3
3
  import { LmTaskToolSpec } from "@agent-smith/lmtask/dist/interfaces.js";
4
- declare class McpServer {
4
+ declare class McpClient {
5
+ name: string;
5
6
  transport: StdioClientTransport;
6
7
  client: Client;
7
8
  authorizedTools: Array<string> | null;
8
9
  tools: Record<string, LmTaskToolSpec>;
9
- constructor(command: string, args: Array<string>, authorizedTools?: Array<string> | null);
10
+ constructor(servername: string, command: string, args: Array<string>, authorizedTools?: Array<string> | null);
10
11
  start(): Promise<void>;
11
12
  stop(): Promise<void>;
12
13
  extractTools(): Promise<Array<LmTaskToolSpec>>;
13
14
  }
14
- export { McpServer, };
15
+ export { McpClient, };
@@ -1,16 +1,31 @@
1
1
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
3
- class McpServer {
3
+ class McpClient {
4
+ name;
4
5
  transport;
5
6
  client;
6
7
  authorizedTools = null;
7
8
  tools = {};
8
- constructor(command, args, authorizedTools = null) {
9
+ constructor(servername, command, args, authorizedTools = null) {
10
+ this.name = servername;
11
+ const okargs = new Array();
12
+ for (const arg of args) {
13
+ let _arg = arg;
14
+ if (arg.startsWith("Authorization:")) {
15
+ const k = `MCP_${servername.toUpperCase()}_AUTH`;
16
+ const v = process.env[k];
17
+ if (!v) {
18
+ throw new Error(`Env variable ${k} not found for ${servername} mcp auth`);
19
+ }
20
+ _arg = arg.replace("$MCP_AUTH", v);
21
+ }
22
+ okargs.push(_arg);
23
+ }
9
24
  this.transport = new StdioClientTransport({
10
25
  command: command,
11
26
  args: args
12
27
  });
13
- this.client = new Client({ name: "AgentSmith", version: "1.0.0" });
28
+ this.client = new Client({ name: "AgentSmith", version: "0.1.0" });
14
29
  if (authorizedTools) {
15
30
  this.authorizedTools = authorizedTools;
16
31
  }
@@ -57,4 +72,4 @@ class McpServer {
57
72
  return toolSpecs;
58
73
  }
59
74
  }
60
- export { McpServer, };
75
+ export { McpClient, };
@@ -15,7 +15,7 @@ import { runtimeDataError, runtimeWarning } from "../user_msgs.js";
15
15
  import { formatStats, processOutput, readPromptFile } from "../utils.js";
16
16
  import { executeWorkflow } from "../workflows/cmd.js";
17
17
  import { configureTaskModel, mergeInferParams } from "./conf.js";
18
- import { McpServer } from "../mcp.js";
18
+ import { McpClient } from "../mcp.js";
19
19
  import { openTaskSpec } from "./utils.js";
20
20
  async function executeTask(name, payload, options, quiet, expert) {
21
21
  await initAgent();
@@ -49,8 +49,8 @@ async function executeTask(name, payload, options, quiet, expert) {
49
49
  const mcpServers = new Array();
50
50
  if (taskFileSpec?.mcp) {
51
51
  taskSpec.tools = [];
52
- for (const tool of Object.values(taskFileSpec.mcp)) {
53
- const mcp = new McpServer(tool.command, tool.arguments, tool?.tools ?? null);
52
+ for (const [servername, tool] of Object.entries(taskFileSpec.mcp)) {
53
+ const mcp = new McpClient(servername, tool.command, tool.args, tool?.tools ?? null);
54
54
  mcpServers.push(mcp);
55
55
  await mcp.start();
56
56
  const tools = await mcp.extractTools();
@@ -3,6 +3,7 @@ import { formatMode, initFilepaths, outputMode, promptfilePath } from "../../sta
3
3
  import { writeToClipboard } from "../sys/clipboard.js";
4
4
  import { readFile } from "../sys/read.js";
5
5
  import { splitThinking } from "../../utils/text.js";
6
+ import { runtimeError } from "./user_msgs.js";
6
7
  function readPromptFile() {
7
8
  initFilepaths();
8
9
  return readFile(promptfilePath.value);
@@ -22,7 +23,12 @@ async function processOutput(res) {
22
23
  hasTextData = true;
23
24
  }
24
25
  else {
25
- data = JSON.stringify(res);
26
+ try {
27
+ data = JSON.stringify(res);
28
+ }
29
+ catch (e) {
30
+ runtimeError("Unable to parse json result");
31
+ }
26
32
  }
27
33
  }
28
34
  else {
@@ -2,7 +2,5 @@ import { Option } from "commander";
2
2
  declare const displayOptions: Array<Option>;
3
3
  declare const inferenceOptions: Array<Option>;
4
4
  declare const ioOptions: Array<Option>;
5
- declare const taskOptions: Array<Option>;
6
- declare const actionOptions: Array<Option>;
7
- declare const workflowOptions: Array<Option>;
8
- export { displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions, };
5
+ declare const allOptions: Array<Option>;
6
+ export { displayOptions, ioOptions, inferenceOptions, allOptions, };
@@ -22,20 +22,13 @@ const ioOptions = [
22
22
  new Option("--omd, --markdown-output", "use markdown output"),
23
23
  new Option("--otxt, --text-output", "use text output (default)"),
24
24
  ];
25
- const taskOptions = [
25
+ const allOptions = [
26
26
  ...displayOptions,
27
27
  ...ioOptions,
28
28
  ...inferenceOptions,
29
29
  new Option("--tokens", "toggle show tokens mode"),
30
30
  new Option("-c, --chat", "toggle chat mode for tasks"),
31
31
  ];
32
- const actionOptions = [
33
- ...displayOptions,
34
- ...ioOptions,
35
- ];
36
- const workflowOptions = [
37
- ...taskOptions
38
- ];
39
32
  function parseString(value) {
40
33
  if (typeof value !== 'string')
41
34
  throw new InvalidArgumentError('The value must be a string');
@@ -59,4 +52,4 @@ function parseFloatValue(value) {
59
52
  else
60
53
  throw new InvalidArgumentError(`Invalid float: ${value}`);
61
54
  }
62
- export { displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions, };
55
+ export { displayOptions, ioOptions, inferenceOptions, allOptions, };
package/dist/index.js CHANGED
File without changes
package/dist/main.d.ts CHANGED
@@ -11,6 +11,6 @@ import { LmTaskConf } from "@agent-smith/lmtask/dist/interfaces.js";
11
11
  import { extractToolDoc } from "./cmd/lib/tools.js";
12
12
  import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
13
13
  import { extractBetweenTags, splitThinking } from "./utils/text.js";
14
- import { displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions } from "./cmd/options.js";
15
- import { McpServer } from "./cmd/lib/mcp.js";
16
- export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, LmTaskConf, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions, McpServer, };
14
+ import { displayOptions, ioOptions, inferenceOptions, allOptions } from "./cmd/options.js";
15
+ import { McpClient } from "./cmd/lib/mcp.js";
16
+ export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, LmTaskConf, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, McpClient, };
package/dist/main.js CHANGED
@@ -10,6 +10,6 @@ import { parseCommandArgs } from "./cmd/lib/options_parsers.js";
10
10
  import { extractToolDoc } from "./cmd/lib/tools.js";
11
11
  import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
12
12
  import { extractBetweenTags, splitThinking } from "./utils/text.js";
13
- import { displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions } from "./cmd/options.js";
14
- import { McpServer } from "./cmd/lib/mcp.js";
15
- export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions, McpServer, };
13
+ import { displayOptions, ioOptions, inferenceOptions, allOptions } from "./cmd/options.js";
14
+ import { McpClient } from "./cmd/lib/mcp.js";
15
+ export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, McpClient, };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@agent-smith/cli",
3
3
  "description": "Agent Smith: terminal client for language model agents",
4
4
  "repository": "https://github.com/synw/agent-smith",
5
- "version": "0.0.68",
5
+ "version": "0.0.70",
6
6
  "scripts": {
7
7
  "buildrl": "rm -rf dist/* && rollup -c",
8
8
  "build": "rm -rf dist/* && tsc",
@@ -10,14 +10,14 @@
10
10
  "watch": "tsc --noCheck -p . -w"
11
11
  },
12
12
  "dependencies": {
13
- "@agent-smith/brain": "^0.0.43",
13
+ "@agent-smith/brain": "^0.0.44",
14
14
  "@agent-smith/jobs": "^0.0.14",
15
- "@agent-smith/lmtask": "^0.0.45",
15
+ "@agent-smith/lmtask": "^0.0.46",
16
16
  "@agent-smith/tfm": "^0.1.2",
17
17
  "@inquirer/prompts": "^7.5.3",
18
18
  "@inquirer/select": "^4.2.3",
19
- "@modelcontextprotocol/sdk": "^1.12.1",
20
- "@vue/reactivity": "^3.5.16",
19
+ "@modelcontextprotocol/sdk": "^1.13.0",
20
+ "@vue/reactivity": "^3.5.17",
21
21
  "ansi-colors": "^4.1.3",
22
22
  "better-sqlite3": "^11.10.0",
23
23
  "chalk": "^5.4.1",
@@ -34,12 +34,12 @@
34
34
  "@commander-js/extra-typings": "^14.0.0",
35
35
  "@locallm/types": "^0.1.9",
36
36
  "@rollup/plugin-node-resolve": "^16.0.1",
37
- "@rollup/plugin-typescript": "^12.1.2",
37
+ "@rollup/plugin-typescript": "^12.1.3",
38
38
  "@types/better-sqlite3": "^7.6.13",
39
39
  "@types/marked-terminal": "^6.1.1",
40
- "@types/node": "^22.15.27",
40
+ "@types/node": "^24.0.3",
41
41
  "restmix": "^0.5.0",
42
- "rollup": "^4.41.1",
42
+ "rollup": "^4.44.0",
43
43
  "ts-node": "^10.9.2",
44
44
  "tslib": "2.8.1",
45
45
  "typescript": "^5.8.3"