@agent-smith/cli 0.0.110 → 0.0.112

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.
@@ -64,7 +64,7 @@ function initCommandsFromAliases(program, aliases, features) {
64
64
  const wcmd = program.command(`${alias.name} [args...]`)
65
65
  .description("workflow: " + alias.name)
66
66
  .action(async (...args) => {
67
- executeWorkflowCmd(alias.name, args);
67
+ await executeWorkflowCmd(alias.name, args);
68
68
  });
69
69
  allOptions.forEach(o => wcmd.addOption(o));
70
70
  }
package/dist/cmd/cmds.js CHANGED
@@ -7,7 +7,6 @@ import { isChatMode, runMode } from "../state/state.js";
7
7
  import { initCommandsFromAliases } from "./clicmds/aliases.js";
8
8
  import { initBaseCommands } from "./clicmds/base.js";
9
9
  import { initUserCmds } from "./clicmds/cmds.js";
10
- import { exit } from "node:process";
11
10
  //import { usePerfTimer } from "../main.js";
12
11
  const program = new Command();
13
12
  async function chat(program, options, agent, mcpServers) {
@@ -103,7 +102,8 @@ async function parseCmd(program) {
103
102
  program.name('Agent Smith terminal client');
104
103
  program.description('Terminal agents toolkit');
105
104
  await program.parseAsync();
106
- exit(0);
105
+ //console.log("CMD END");
106
+ //exit(0)
107
107
  /*if (isChatMode.value) {
108
108
  await chat(program)
109
109
  }*/
@@ -157,7 +157,7 @@ async function executeTask(name, payload, options) {
157
157
  };
158
158
  const perfTimer = usePerfTimer(false);
159
159
  let abort = options?.abort ? options.abort : new AbortController();
160
- setInterval(() => {
160
+ const abortTicker = setInterval(() => {
161
161
  //console.log("ABS", abort.signal.aborted);
162
162
  if (abort.signal.aborted) {
163
163
  agent.lm.abort();
@@ -254,6 +254,7 @@ async function executeTask(name, payload, options) {
254
254
  const onToolsTurnEnd = options?.onToolsTurnEnd ?? undefined;
255
255
  const onTurnEnd = options?.onTurnEnd ?? undefined;
256
256
  const onAssistant = options?.onAssistant ?? undefined;
257
+ const onThink = options?.onThink ?? undefined;
257
258
  //console.log("OOT", options?.onToken, "/", processToken);
258
259
  if (options?.onToken) {
259
260
  task.agent.lm.onToken = options.onToken;
@@ -278,6 +279,7 @@ async function executeTask(name, payload, options) {
278
279
  onToolsTurnEnd: onToolsTurnEnd,
279
280
  onTurnEnd: onTurnEnd,
280
281
  onAssistant: onAssistant,
282
+ onThink: onThink,
281
283
  ...conf,
282
284
  };
283
285
  if (options?.history) {
@@ -294,7 +296,7 @@ async function executeTask(name, payload, options) {
294
296
  out = await task.run({ prompt: payload.prompt, ...vars }, tconf);
295
297
  }
296
298
  catch (e) {
297
- console.log("ERR CATCH", e);
299
+ //console.log("ERR CATCH", e);
298
300
  const errMsg = `${e}`;
299
301
  if (errMsg.includes("502 Bad Gateway")) {
300
302
  runtimeError("The server answered with a 502 Bad Gateway error. It might be down or misconfigured. Check your inference server.");
@@ -329,6 +331,7 @@ async function executeTask(name, payload, options) {
329
331
  throw new Error(errMsg);
330
332
  }
331
333
  }
334
+ clearInterval(abortTicker);
332
335
  //console.log("END TASK", out);
333
336
  if (!options?.isToolCall) {
334
337
  if (!out.answer.text.endsWith("\n")) {
@@ -125,6 +125,7 @@ async function executeWorkflow(wname, args, options = {}) {
125
125
  catch (e) {
126
126
  throw new Error(`workflow action ${i + 1}: ${e}`);
127
127
  }
128
+ //console.log("END ACTION", step.name)
128
129
  break;
129
130
  case "adaptater":
130
131
  try {
@@ -171,7 +172,13 @@ async function executeWorkflow(wname, args, options = {}) {
171
172
  throw new Error(`Command ${step.name} not found`);
172
173
  }
173
174
  const url = pathToFileURL(path).href;
174
- const jsa = await import(/* @vite-ignore */ url);
175
+ let jsa;
176
+ try {
177
+ jsa = await import(/* @vite-ignore */ url);
178
+ }
179
+ catch (e) {
180
+ throw new Error(`cmd import error ${e}`);
181
+ }
175
182
  if (!jsa?.runCmd) {
176
183
  runtimeError(`workflow ${wname}: can not import the runCmd function from step ${i} for command ${step.name}: please add a runCmd function export`);
177
184
  return;
@@ -210,6 +217,7 @@ async function executeWorkflow(wname, args, options = {}) {
210
217
  //console.log("WFR", taskRes)
211
218
  ++i;
212
219
  }
220
+ //console.log("WF RES")
213
221
  return taskRes;
214
222
  }
215
223
  async function executeWorkflowCmd(name, wargs) {
package/dist/conf.d.ts CHANGED
@@ -3,9 +3,10 @@ declare function getConfigPath(appName: string, filename: string): {
3
3
  dbPath: string;
4
4
  };
5
5
  declare const confDir: string, dbPath: string;
6
+ declare function createConfigFile(cfp?: string): string;
6
7
  declare function processConfPath(confPath: string): Promise<{
7
8
  paths: Array<string>;
8
9
  pf: string;
9
10
  dd: string;
10
11
  }>;
11
- export { confDir, dbPath, processConfPath, getConfigPath, };
12
+ export { confDir, dbPath, processConfPath, getConfigPath, createConfigFile, };
package/dist/conf.js CHANGED
@@ -1,3 +1,4 @@
1
+ import fs from "node:fs";
1
2
  import { readConf } from "./cmd/sys/read_conf.js";
2
3
  import { upsertBackends, insertFeaturesPathIfNotExists, insertPluginIfNotExists, upsertTaskSettings, deleteTaskSettings } from "./db/write.js";
3
4
  import { buildPluginsPaths } from "./state/plugins.js";
@@ -7,6 +8,8 @@ import { homedir } from 'os';
7
8
  import { join } from 'path';
8
9
  import { createDirectoryIfNotExists } from "./cmd/sys/dirs.js";
9
10
  import { initTaskSettings, tasksSettings } from "./state/tasks.js";
11
+ import path from "node:path";
12
+ import yaml from "yaml";
10
13
  function getConfigPath(appName, filename) {
11
14
  let confDir;
12
15
  let dbPath;
@@ -25,6 +28,33 @@ function getConfigPath(appName, filename) {
25
28
  return { confDir: confDir, dbPath: dbPath };
26
29
  }
27
30
  const { confDir, dbPath } = getConfigPath("agent-smith", "config.db");
31
+ function createConfigFile(cfp) {
32
+ createDirectoryIfNotExists(confDir);
33
+ const fp = cfp ? cfp : path.join(confDir, "config.yml");
34
+ const fc = {
35
+ promptfile: "",
36
+ backends: {
37
+ default: "llamacpp",
38
+ local: ["llamacpp", "koboldcpp", "ollama"],
39
+ llamacpp_oai: {
40
+ type: "openai",
41
+ url: "http://localhost:8080/v1"
42
+ }
43
+ }
44
+ };
45
+ const txt = yaml.stringify(fc);
46
+ try {
47
+ if (fs.existsSync(fp)) {
48
+ const err = `Config file ${fp} already exists`;
49
+ throw new Error(err);
50
+ }
51
+ fs.writeFileSync(fp, txt);
52
+ }
53
+ catch (e) {
54
+ throw new Error(`Error creating config file at ${fp}: ${e}`);
55
+ }
56
+ return fp;
57
+ }
28
58
  async function processConfPath(confPath) {
29
59
  createDirectoryIfNotExists(confDir);
30
60
  const { found, data } = readConf(confPath);
@@ -118,4 +148,4 @@ async function processConfPath(confPath) {
118
148
  }
119
149
  return { paths: allPaths, pf: pf, dd: dd };
120
150
  }
121
- export { confDir, dbPath, processConfPath, getConfigPath, };
151
+ export { confDir, dbPath, processConfPath, getConfigPath, createConfigFile, };
package/dist/index.js CHANGED
@@ -54,8 +54,10 @@ async function main() {
54
54
  break;
55
55
  default:
56
56
  await parseCmd(program);
57
+ //console.log("PARSE CMD END")
57
58
  break;
58
59
  }
60
+ //console.log("END");
59
61
  }
60
62
  (async () => {
61
63
  await main();
package/dist/main.d.ts CHANGED
@@ -13,19 +13,23 @@ import { displayOptions, ioOptions, inferenceOptions, allOptions } from "./cmd/o
13
13
  import { McpClient } from "./cmd/lib/mcp.js";
14
14
  import { readTask } from "./cmd/lib/tasks/read.js";
15
15
  import { FeatureType, TaskSettings } from "./interfaces.js";
16
- import { getConfigPath } from "./conf.js";
17
- import { readFeaturesType, readFilePaths } from "./db/read.js";
16
+ import { getConfigPath, createConfigFile } from "./conf.js";
17
+ import { readFeaturesType, readFilePaths, readTool } from "./db/read.js";
18
18
  import { readConf } from "./cmd/sys/read_conf.js";
19
19
  import { backend } from "./state/backends.js";
20
20
  import { getTaskSettings } from "./state/tasks.js";
21
21
  import { upsertTaskSettings } from "./db/write.js";
22
+ import { initDb } from "./db/db.js";
23
+ import { updateConfCmd } from "./cmd/clicmds/updateconf.js";
22
24
  declare const db: {
25
+ init: typeof initDb;
23
26
  readFilePaths: typeof readFilePaths;
24
27
  readFeaturesType: typeof readFeaturesType;
28
+ readTool: typeof readTool;
25
29
  getTaskSettings: typeof getTaskSettings;
26
30
  upsertTaskSettings: typeof upsertTaskSettings;
27
31
  };
28
32
  declare const fs: {
29
33
  openTaskSpec: typeof openTaskSpec;
30
34
  };
31
- export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initState, init, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, isStateReady, backend, McpClient, readTask, FeatureType, getConfigPath, readConf, TaskSettings, db, fs, };
35
+ export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initState, init, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, isStateReady, backend, McpClient, readTask, FeatureType, getConfigPath, readConf, TaskSettings, db, fs, createConfigFile, updateConfCmd, };
package/dist/main.js CHANGED
@@ -12,19 +12,23 @@ import { extractBetweenTags, splitThinking } from "./utils/text.js";
12
12
  import { displayOptions, ioOptions, inferenceOptions, allOptions } from "./cmd/options.js";
13
13
  import { McpClient } from "./cmd/lib/mcp.js";
14
14
  import { readTask } from "./cmd/lib/tasks/read.js";
15
- import { getConfigPath } from "./conf.js";
16
- import { readFeaturesType, readFilePaths } from "./db/read.js";
15
+ import { getConfigPath, createConfigFile } from "./conf.js";
16
+ import { readFeaturesType, readFilePaths, readTool } from "./db/read.js";
17
17
  import { readConf } from "./cmd/sys/read_conf.js";
18
18
  import { backend } from "./state/backends.js";
19
19
  import { getTaskSettings } from "./state/tasks.js";
20
20
  import { upsertTaskSettings } from "./db/write.js";
21
+ import { initDb } from "./db/db.js";
22
+ import { updateConfCmd } from "./cmd/clicmds/updateconf.js";
21
23
  const db = {
24
+ init: initDb,
22
25
  readFilePaths,
23
26
  readFeaturesType,
27
+ readTool,
24
28
  getTaskSettings,
25
29
  upsertTaskSettings,
26
30
  };
27
31
  const fs = {
28
32
  openTaskSpec,
29
33
  };
30
- export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initState, init, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, isStateReady, backend, McpClient, readTask, getConfigPath, readConf, db, fs, };
34
+ export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initState, init, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, isStateReady, backend, McpClient, readTask, getConfigPath, readConf, db, fs, createConfigFile, updateConfCmd, };
package/package.json CHANGED
@@ -1,29 +1,28 @@
1
1
  {
2
2
  "name": "@agent-smith/cli",
3
3
  "description": "Agent Smith: terminal client for language model agents",
4
- "repository": "https://github.com/synw/agent-smith",
5
- "version": "0.0.110",
4
+ "version": "0.0.112",
6
5
  "scripts": {
7
6
  "build": "rm -rf dist/* && tsc",
8
7
  "cli": "node --loader ts-node/esm bin/index.ts",
9
8
  "watch": "tsc --noCheck -p . -w"
10
9
  },
11
10
  "dependencies": {
12
- "@agent-smith/agent": "^0.3.0",
11
+ "@agent-smith/agent": "^0.3.2",
13
12
  "@agent-smith/nodetask": "^0.2.0",
14
- "@agent-smith/task": "^0.3.0",
13
+ "@agent-smith/task": "^0.3.2",
15
14
  "@agent-smith/tfm": "^0.2.0",
16
- "@inquirer/prompts": "^8.2.1",
17
- "@intrinsicai/gbnfgen": "^0.7.0",
15
+ "@inquirer/prompts": "^8.3.0",
16
+ "@intrinsicai/gbnfgen": "^0.12.0",
18
17
  "@locallm/api": "^0.7.3",
19
- "@modelcontextprotocol/sdk": "^1.26.0",
20
- "@vue/reactivity": "^3.5.28",
18
+ "@modelcontextprotocol/sdk": "^1.27.1",
19
+ "@vue/reactivity": "^3.5.29",
21
20
  "ansi-colors": "^4.1.3",
22
21
  "better-sqlite3": "^12.6.2",
23
- "clipboardy": "^5.3.0",
22
+ "clipboardy": "^5.3.1",
24
23
  "commander": "^14.0.3",
25
24
  "marked-terminal": "^7.3.0",
26
- "modprompt": "^0.14.0",
25
+ "modprompt": "^0.14.1",
27
26
  "ora": "^9.3.0",
28
27
  "python-shell": "^5.0.0",
29
28
  "yaml": "^2.8.2"
@@ -31,13 +30,13 @@
31
30
  "devDependencies": {
32
31
  "@cfworker/json-schema": "^4.1.1",
33
32
  "@commander-js/extra-typings": "^14.0.0",
34
- "@locallm/types": "^0.7.0",
33
+ "@locallm/types": "^0.7.1",
35
34
  "@rollup/plugin-node-resolve": "^16.0.3",
36
35
  "@rollup/plugin-typescript": "^12.3.0",
37
36
  "@types/better-sqlite3": "^7.6.13",
38
37
  "@types/marked-terminal": "^6.1.1",
39
- "@types/node": "^25.3.0",
40
- "openai": "^6.22.0",
38
+ "@types/node": "^25.3.1",
39
+ "openai": "^6.25.0",
41
40
  "restmix": "^0.6.1",
42
41
  "tslib": "2.8.1",
43
42
  "typescript": "^5.9.3"
@@ -60,5 +59,9 @@
60
59
  "access": "public",
61
60
  "registry": "https://registry.npmjs.org/"
62
61
  },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/synw/agent-smith.git"
65
+ },
63
66
  "license": "MIT"
64
67
  }