@agent-smith/cli 0.0.114 → 0.0.115

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,6 +1,6 @@
1
1
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
2
2
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
3
- import { ToolSpec } from "@locallm/types/dist/tools";
3
+ import { ToolSpec } from "@locallm/types";
4
4
  declare class McpClient {
5
5
  name: string;
6
6
  transport: StdioClientTransport;
@@ -98,21 +98,21 @@ async function executeTask(name, payload, options) {
98
98
  }
99
99
  //let i = 0;
100
100
  let c = false;
101
- const useTemplates = agent.lm.providerType !== "openai";
101
+ //const useTemplates = agent.lm.providerType !== "openai";
102
102
  let hasThink = false;
103
103
  let tpl = null;
104
104
  //console.log("Use templates:", useTemplates);
105
- if (useTemplates) {
106
- try {
107
- tpl = new PromptTemplate(model.template ?? "none");
108
- }
109
- catch (e) {
110
- throw new Error(`Can not load template ${model.template}\nAvailable templates: ${Object.keys(templates)}\n`);
111
- }
112
- //console.log("TPL:", tpl.id);
113
- hasThink = tpl.tags?.think ? true : false;
114
- //console.log("HT", hasThink);
105
+ //if (useTemplates) {
106
+ try {
107
+ tpl = new PromptTemplate(model.template ?? "none");
108
+ }
109
+ catch (e) {
110
+ throw new Error(`Can not load template ${model.template}\nAvailable templates: ${Object.keys(templates)}\n`);
115
111
  }
112
+ //console.log("TPL:", tpl.id);
113
+ hasThink = tpl.tags?.think ? true : false;
114
+ //console.log("HT", hasThink);
115
+ //}
116
116
  if (options?.debug) {
117
117
  console.log("Task model:", model);
118
118
  console.log("Task vars:", vars);
@@ -299,32 +299,46 @@ async function executeTask(name, payload, options) {
299
299
  //console.log("ERR CATCH", e);
300
300
  const errMsg = `${e}`;
301
301
  if (errMsg.includes("502 Bad Gateway")) {
302
+ clearInterval(abortTicker);
302
303
  runtimeError("The server answered with a 502 Bad Gateway error. It might be down or misconfigured. Check your inference server.");
303
- if (options?.debug) {
304
+ if (options?.nocli) {
304
305
  throw new Error(errMsg);
305
306
  }
306
307
  //@ts-ignore
307
308
  return;
308
309
  }
309
310
  else if (errMsg.includes("404 Not Found")) {
311
+ clearInterval(abortTicker);
310
312
  runtimeError("The server answered with a 404 Not Found error. That might mean that the model you are requesting does not exist on the server.");
313
+ if (options?.nocli) {
314
+ throw new Error(errMsg);
315
+ }
311
316
  //@ts-ignore
312
317
  return;
313
318
  }
314
319
  else if (errMsg.includes("400 Bad Request")) {
320
+ clearInterval(abortTicker);
315
321
  runtimeError("The server answered with a 400 Bad Request error. That might mean that the model you are requesting does not exist on the server, a parameter is wrong or missing in your request.");
322
+ if (options?.nocli) {
323
+ throw new Error(errMsg);
324
+ }
316
325
  //@ts-ignore
317
326
  return;
318
327
  }
319
328
  else if (errMsg.includes("fetch failed")) {
329
+ clearInterval(abortTicker);
320
330
  runtimeError("The server is not responding. Check if your inference backend is running.");
331
+ if (options?.nocli) {
332
+ throw new Error(errMsg);
333
+ }
321
334
  //@ts-ignore
322
335
  return;
323
336
  }
324
337
  else if (e instanceof DOMException && e.name === 'AbortError') {
325
338
  if (options?.debug || options?.verbose) {
326
- console.log("The request was canceled by the user");
339
+ console.warn("\n*** The request was canceled by the user ***");
327
340
  }
341
+ clearInterval(abortTicker);
328
342
  return {};
329
343
  }
330
344
  else {
@@ -355,9 +369,7 @@ async function executeTask(name, payload, options) {
355
369
  // chat mode
356
370
  //console.log("CLI CONF IP", initialInferParams);
357
371
  if (!options?.isToolCall && isChatMode.value) {
358
- if (tpl) {
359
- setChatTemplate(tpl);
360
- }
372
+ setChatTemplate(tpl);
361
373
  if (task.def.tools) {
362
374
  options.tools = task.def.tools;
363
375
  }
package/dist/conf.d.ts CHANGED
@@ -5,7 +5,7 @@ declare function getConfigPath(appName: string, filename: string): {
5
5
  };
6
6
  declare const confDir: string, dbPath: string;
7
7
  declare function updateConfigFile(conf: ConfigFile, cfp?: string): string;
8
- declare function createConfigFile(cfp?: string): string;
8
+ declare function createConfigFile(cfp?: string, local?: Array<"llamacpp" | "koboldcpp" | "ollama">): string;
9
9
  declare function processConfPath(confPath: string): Promise<{
10
10
  paths: Array<string>;
11
11
  pf: string;
package/dist/conf.js CHANGED
@@ -43,13 +43,13 @@ function updateConfigFile(conf, cfp) {
43
43
  }
44
44
  return fp;
45
45
  }
46
- function createConfigFile(cfp) {
46
+ function createConfigFile(cfp, local = ["llamacpp", "koboldcpp", "ollama"]) {
47
47
  createDirectoryIfNotExists(confDir);
48
48
  const fp = cfp ? cfp : path.join(confDir, "config.yml");
49
49
  const fc = {
50
50
  backends: {
51
51
  default: "llamacpp",
52
- local: ["llamacpp", "koboldcpp", "ollama"],
52
+ local: local,
53
53
  llamacpp_oai: {
54
54
  type: "openai",
55
55
  url: "http://localhost:8080/v1"
package/dist/main.d.ts CHANGED
@@ -1,27 +1,27 @@
1
- import { execute, run } from "./cmd/sys/execute.js";
2
- import { executeTask } from "./cmd/lib/tasks/cmd.js";
1
+ import { updateConfCmd } from "./cmd/clicmds/updateconf.js";
3
2
  import { executeAction } from "./cmd/lib/actions/cmd.js";
4
- import { executeWorkflow } from "./cmd/lib/workflows/cmd.js";
5
- import { writeToClipboard } from "./cmd/sys/clipboard.js";
6
- import { initState, pluginDataDir, init, isStateReady } from "./state/state.js";
7
- import { usePerfTimer } from "./utils/perf.js";
8
- import { parseCommandArgs } from "./cmd/lib/options_parsers.js";
9
- import { extractToolDoc } from "./cmd/lib/tools.js";
10
- import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
11
- import { extractBetweenTags, splitThinking } from "./utils/text.js";
12
- import { displayOptions, ioOptions, inferenceOptions, allOptions } from "./cmd/options.js";
13
3
  import { McpClient } from "./cmd/lib/mcp.js";
4
+ import { parseCommandArgs } from "./cmd/lib/options_parsers.js";
5
+ import { executeTask } from "./cmd/lib/tasks/cmd.js";
14
6
  import { readTask } from "./cmd/lib/tasks/read.js";
15
- import { FeatureType, TaskSettings } from "./interfaces.js";
16
- import { getConfigPath, createConfigFile } from "./conf.js";
17
- import { readFeaturesType, readFilePaths, readTool } from "./db/read.js";
7
+ import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
8
+ import { extractToolDoc } from "./cmd/lib/tools.js";
9
+ import { executeWorkflow } from "./cmd/lib/workflows/cmd.js";
10
+ import { readWorkflow } from "./cmd/lib/workflows/read.js";
11
+ import { allOptions, displayOptions, inferenceOptions, ioOptions } from "./cmd/options.js";
12
+ import { writeToClipboard } from "./cmd/sys/clipboard.js";
13
+ import { execute, run } from "./cmd/sys/execute.js";
18
14
  import { readConf } from "./cmd/sys/read_conf.js";
19
- import { backend } from "./state/backends.js";
20
- import { getTaskSettings } from "./state/tasks.js";
21
- import { upsertTaskSettings } from "./db/write.js";
15
+ import { createConfigFile, getConfigPath, processConfPath, updateConfigFile } from "./conf.js";
22
16
  import { initDb } from "./db/db.js";
23
- import { updateConfCmd } from "./cmd/clicmds/updateconf.js";
24
- import { updateConfigFile, processConfPath } from "./conf.js";
17
+ import { readBackends, readFeaturesType, readFilePaths, readTool } from "./db/read.js";
18
+ import { upsertTaskSettings } from "./db/write.js";
19
+ import { FeatureType, TaskSettings } from "./interfaces.js";
20
+ import { backend, setBackend } from "./state/backends.js";
21
+ import { init, initState, isStateReady, pluginDataDir } from "./state/state.js";
22
+ import { getTaskSettings } from "./state/tasks.js";
23
+ import { usePerfTimer } from "./utils/perf.js";
24
+ import { extractBetweenTags, splitThinking } from "./utils/text.js";
25
25
  declare const db: {
26
26
  init: typeof initDb;
27
27
  readFilePaths: typeof readFilePaths;
@@ -29,8 +29,10 @@ declare const db: {
29
29
  readTool: typeof readTool;
30
30
  getTaskSettings: typeof getTaskSettings;
31
31
  upsertTaskSettings: typeof upsertTaskSettings;
32
+ readBackends: typeof readBackends;
32
33
  };
33
34
  declare const fs: {
34
35
  openTaskSpec: typeof openTaskSpec;
36
+ readWorkflow: typeof readWorkflow;
35
37
  };
36
- 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, updateConfigFile, processConfPath, };
38
+ export { allOptions, backend, createConfigFile, db, displayOptions, execute, executeAction, executeTask, executeWorkflow, extractBetweenTags, extractToolDoc, FeatureType, fs, getConfigPath, inferenceOptions, init, initState, ioOptions, isStateReady, McpClient, openTaskSpec, parseCommandArgs, pluginDataDir, processConfPath, readConf, readTask, run, setBackend, splitThinking, TaskSettings, updateConfCmd, updateConfigFile, usePerfTimer, writeToClipboard, };
package/dist/main.js CHANGED
@@ -1,26 +1,26 @@
1
- import { execute, run } from "./cmd/sys/execute.js";
2
- import { executeTask } from "./cmd/lib/tasks/cmd.js";
1
+ import { updateConfCmd } from "./cmd/clicmds/updateconf.js";
3
2
  import { executeAction } from "./cmd/lib/actions/cmd.js";
4
- import { executeWorkflow } from "./cmd/lib/workflows/cmd.js";
5
- import { writeToClipboard } from "./cmd/sys/clipboard.js";
6
- import { initState, pluginDataDir, init, isStateReady } from "./state/state.js";
7
- import { usePerfTimer } from "./utils/perf.js";
8
- import { parseCommandArgs } from "./cmd/lib/options_parsers.js";
9
- import { extractToolDoc } from "./cmd/lib/tools.js";
10
- import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
11
- import { extractBetweenTags, splitThinking } from "./utils/text.js";
12
- import { displayOptions, ioOptions, inferenceOptions, allOptions } from "./cmd/options.js";
13
3
  import { McpClient } from "./cmd/lib/mcp.js";
4
+ import { parseCommandArgs } from "./cmd/lib/options_parsers.js";
5
+ import { executeTask } from "./cmd/lib/tasks/cmd.js";
14
6
  import { readTask } from "./cmd/lib/tasks/read.js";
15
- import { getConfigPath, createConfigFile } from "./conf.js";
16
- import { readFeaturesType, readFilePaths, readTool } from "./db/read.js";
7
+ import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
8
+ import { extractToolDoc } from "./cmd/lib/tools.js";
9
+ import { executeWorkflow } from "./cmd/lib/workflows/cmd.js";
10
+ import { readWorkflow } from "./cmd/lib/workflows/read.js";
11
+ import { allOptions, displayOptions, inferenceOptions, ioOptions } from "./cmd/options.js";
12
+ import { writeToClipboard } from "./cmd/sys/clipboard.js";
13
+ import { execute, run } from "./cmd/sys/execute.js";
17
14
  import { readConf } from "./cmd/sys/read_conf.js";
18
- import { backend } from "./state/backends.js";
19
- import { getTaskSettings } from "./state/tasks.js";
20
- import { upsertTaskSettings } from "./db/write.js";
15
+ import { createConfigFile, getConfigPath, processConfPath, updateConfigFile } from "./conf.js";
21
16
  import { initDb } from "./db/db.js";
22
- import { updateConfCmd } from "./cmd/clicmds/updateconf.js";
23
- import { updateConfigFile, processConfPath } from "./conf.js";
17
+ import { readBackends, readFeaturesType, readFilePaths, readTool } from "./db/read.js";
18
+ import { upsertTaskSettings } from "./db/write.js";
19
+ import { backend, setBackend } from "./state/backends.js";
20
+ import { init, initState, isStateReady, pluginDataDir } from "./state/state.js";
21
+ import { getTaskSettings } from "./state/tasks.js";
22
+ import { usePerfTimer } from "./utils/perf.js";
23
+ import { extractBetweenTags, splitThinking } from "./utils/text.js";
24
24
  const db = {
25
25
  init: initDb,
26
26
  readFilePaths,
@@ -28,8 +28,10 @@ const db = {
28
28
  readTool,
29
29
  getTaskSettings,
30
30
  upsertTaskSettings,
31
+ readBackends,
31
32
  };
32
33
  const fs = {
33
34
  openTaskSpec,
35
+ readWorkflow,
34
36
  };
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, getConfigPath, readConf, db, fs, createConfigFile, updateConfCmd, updateConfigFile, processConfPath, };
37
+ export { allOptions, backend, createConfigFile, db, displayOptions, execute, executeAction, executeTask, executeWorkflow, extractBetweenTags, extractToolDoc, fs, getConfigPath, inferenceOptions, init, initState, ioOptions, isStateReady, McpClient, openTaskSpec, parseCommandArgs, pluginDataDir, processConfPath, readConf, readTask, run, setBackend, splitThinking, updateConfCmd, updateConfigFile, usePerfTimer, writeToClipboard, };
@@ -2,6 +2,6 @@ import { Lm } from "@locallm/api";
2
2
  declare const backend: import("@vue/reactivity").Ref<Lm | undefined, Lm | undefined>;
3
3
  declare const backends: Record<string, Lm>;
4
4
  declare function initBackends(): Promise<void>;
5
- declare function setBackend(name: string, isVerbose?: boolean): Promise<void>;
5
+ declare function setBackend(name: string, isVerbose?: boolean): Promise<boolean>;
6
6
  declare function listBackends(printResult?: boolean): Promise<string>;
7
7
  export { backend, backends, initBackends, listBackends, setBackend };
@@ -34,6 +34,8 @@ async function initBackends() {
34
34
  serverUrl: bk.url,
35
35
  apiKey: apiKey.length > 0 ? apiKey : undefined,
36
36
  });
37
+ lm.name = bk.name;
38
+ //console.log("ADD BK", lm);
37
39
  backends[name] = lm;
38
40
  if (bk.isDefault) {
39
41
  defaultBackendName = bk.name;
@@ -52,18 +54,19 @@ async function initBackends() {
52
54
  async function setBackend(name, isVerbose = false) {
53
55
  if (!(Object.keys(backends).includes(name))) {
54
56
  runtimeDataError(`Backend ${name} not found. Available backends: ${Object.keys(backends)}`);
55
- return;
57
+ return false;
56
58
  }
57
59
  backend.value = backends[name];
58
60
  setDefaultBackend(name);
59
61
  console.log("Default backend set to", name);
60
62
  isBackendUp.value = await probeBackend(backend.value, isVerbose);
63
+ return isBackendUp.value;
61
64
  }
62
65
  async function listBackends(printResult = true) {
63
66
  //console.log("DEFB", backend.value?.name);
64
67
  const allBk = new Array();
65
68
  for (const [name, lm] of Object.entries(backends)) {
66
- const bcn = name == backend.value?.name ? colors.bold(name) : name;
69
+ const bcn = (name == backend.value?.name) ? colors.bold(name) : name;
67
70
  //const isUp = await probeBackend(lm, false);
68
71
  const buf = new Array("-", bcn, colors.dim("(" + lm.providerType + ") " + lm.serverUrl));
69
72
  const str = buf.join(" ");
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "@agent-smith/cli",
3
3
  "description": "Agent Smith: terminal client for language model agents",
4
- "version": "0.0.114",
4
+ "version": "0.0.115",
5
5
  "scripts": {
6
6
  "build": "rm -rf dist/* && tsc",
7
7
  "cli": "node --loader ts-node/esm bin/index.ts",
8
8
  "watch": "tsc --noCheck -p . -w"
9
9
  },
10
10
  "dependencies": {
11
- "@agent-smith/agent": "^0.3.3",
12
- "@agent-smith/nodetask": "^0.2.1",
13
- "@agent-smith/task": "^0.3.3",
14
- "@agent-smith/tfm": "^0.2.0",
15
- "@inquirer/prompts": "^8.3.0",
11
+ "@agent-smith/agent": "^0.4.0",
12
+ "@agent-smith/nodetask": "^0.3.0",
13
+ "@agent-smith/task": "^0.4.0",
14
+ "@agent-smith/tfm": "^0.3.0",
15
+ "@inquirer/prompts": "^8.3.2",
16
16
  "@intrinsicai/gbnfgen": "^0.12.0",
17
- "@locallm/api": "^0.7.3",
18
- "@modelcontextprotocol/sdk": "^1.27.1",
19
- "@vue/reactivity": "^3.5.29",
17
+ "@locallm/api": "^0.8.0",
18
+ "@modelcontextprotocol/sdk": "^1.28.0",
19
+ "@vue/reactivity": "^3.5.31",
20
20
  "ansi-colors": "^4.1.3",
21
- "better-sqlite3": "^12.6.2",
21
+ "better-sqlite3": "^12.8.0",
22
22
  "clipboardy": "^5.3.1",
23
23
  "commander": "^14.0.3",
24
24
  "marked-terminal": "^7.3.0",
25
25
  "modprompt": "^0.14.2",
26
26
  "ora": "^9.3.0",
27
27
  "python-shell": "^5.0.0",
28
- "yaml": "^2.8.2"
28
+ "yaml": "^2.8.3"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@cfworker/json-schema": "^4.1.1",
@@ -35,8 +35,8 @@
35
35
  "@rollup/plugin-typescript": "^12.3.0",
36
36
  "@types/better-sqlite3": "^7.6.13",
37
37
  "@types/marked-terminal": "^6.1.1",
38
- "@types/node": "^25.3.1",
39
- "openai": "^6.25.0",
38
+ "@types/node": "^25.5.0",
39
+ "openai": "^6.33.0",
40
40
  "restmix": "^0.6.1",
41
41
  "tslib": "2.8.1",
42
42
  "typescript": "^5.9.3"