@agent-smith/cli 0.0.69 → 0.0.71

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/agent.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { LmTaskBuilder } from "@agent-smith/lmtask";
1
+ import { LmBackend } from "@agent-smith/brain";
2
+ import { LmTaskBuilder } from "../../lmtask/dist/task.js";
2
3
  import { marked } from 'marked';
3
4
  import { FeatureType } from "./interfaces.js";
4
5
  declare let brain: import("@agent-smith/brain").AgentBrain<Record<string, any>>;
5
6
  declare const taskBuilder: LmTaskBuilder<FeatureType, Record<string, any>>;
6
- declare function initAgent(): Promise<boolean>;
7
+ declare function initAgent(backends: Array<LmBackend>): Promise<boolean>;
7
8
  export { brain, initAgent, marked, taskBuilder };
package/dist/agent.js CHANGED
@@ -1,22 +1,19 @@
1
1
  import { useAgentBrain } from "@agent-smith/brain";
2
- import { LmTaskBuilder } from "@agent-smith/lmtask";
2
+ import { LmTaskBuilder } from "../../lmtask/dist/task.js";
3
3
  import { marked } from 'marked';
4
4
  import { markedTerminal } from "marked-terminal";
5
5
  marked.use(markedTerminal());
6
6
  let brain = useAgentBrain();
7
7
  const taskBuilder = new LmTaskBuilder(brain);
8
- async function initExperts() {
9
- brain.experts.forEach((ex) => {
10
- ex.backend.setOnToken((t) => {
11
- process.stdout.write(t);
12
- });
13
- });
14
- }
15
- async function initAgent() {
8
+ async function initAgent(backends) {
9
+ backends.forEach(b => brain.addBackend(b));
16
10
  if (!brain.state.get().isOn) {
17
11
  brain.resetExperts();
18
- await brain.initLocal(true);
19
- await initExperts();
12
+ if (backends.length > 0) {
13
+ await brain.discover();
14
+ }
15
+ await brain.discoverLocal(true);
16
+ await brain.backendsForModelsInfo();
20
17
  }
21
18
  const brainUp = brain.state.get().isOn;
22
19
  if (!brainUp) {
@@ -0,0 +1,3 @@
1
+ import { LmBackend } from "../../../brain/dist/main.js";
2
+ declare function initRemoteBackends(): Array<LmBackend>;
3
+ export { initRemoteBackends, };
@@ -0,0 +1,20 @@
1
+ import { readBackends } from "../db/read.js";
2
+ import { useLmBackend } from "../../../brain/dist/main.js";
3
+ function initRemoteBackends() {
4
+ const rmb = readBackends();
5
+ const rmbs = new Array();
6
+ rmb.forEach(b => {
7
+ const bcs = {
8
+ name: b.name,
9
+ providerType: b.type,
10
+ serverUrl: b.uri,
11
+ };
12
+ if (b?.apiKey) {
13
+ bcs.apiKey = b.apiKey;
14
+ }
15
+ ;
16
+ rmbs.push(useLmBackend(bcs));
17
+ });
18
+ return rmbs;
19
+ }
20
+ export { initRemoteBackends, };
@@ -11,10 +11,11 @@ import { parseCommandArgs } from "../lib/options_parsers.js";
11
11
  import { deleteFileIfExists } from "../sys/delete_file.js";
12
12
  import { readTask } from "../sys/read_task.js";
13
13
  import { updateConfCmd } from "./update.js";
14
+ import { initRemoteBackends } from "../backends.js";
14
15
  function initBaseCommands(program) {
15
16
  program.command("ping")
16
17
  .description("ping inference servers")
17
- .action(async (...args) => { console.log("Found working inference server(s):", await initAgent()); });
18
+ .action(async (...args) => { console.log("Found working inference server(s):", await initAgent(initRemoteBackends())); });
18
19
  program.command("exit")
19
20
  .description("exit the cli")
20
21
  .action(() => process.exit(0));
@@ -1,9 +1,14 @@
1
1
  import { readCmds } from "../sys/read_cmds.js";
2
2
  async function initUserCmds(cmdFeats) {
3
+ const paths = new Set();
3
4
  const cmds = new Array();
4
5
  for (const feat of Object.values(cmdFeats)) {
6
+ if (paths.has(feat.path)) {
7
+ continue;
8
+ }
5
9
  const c = await readCmds(`${feat.path}`);
6
10
  cmds.push(...c);
11
+ paths.add(feat.path);
7
12
  }
8
13
  return cmds;
9
14
  }
@@ -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, };
@@ -2,100 +2,23 @@ import { input } from "@inquirer/prompts";
2
2
  import { compile, serializeGrammar } from "@intrinsicai/gbnfgen";
3
3
  import color from "ansi-colors";
4
4
  import ora from 'ora';
5
- import { brain, initAgent, taskBuilder } from "../../../agent.js";
5
+ import { brain } from "../../../agent.js";
6
6
  import { query } from "../../../cli.js";
7
7
  import { readClipboard } from "../../../cmd/sys/clipboard.js";
8
- import { readTool } from "../../../db/read.js";
9
8
  import { usePerfTimer } from "../../../main.js";
10
9
  import { isChatMode, runMode } from "../../../state/state.js";
11
10
  import { program } from "../../cmds.js";
12
- import { executeAction } from "../actions/cmd.js";
13
- import { parseCommandArgs, parseTaskConfigOptions } from "../options_parsers.js";
11
+ import { parseCommandArgs } from "../options_parsers.js";
14
12
  import { runtimeDataError, runtimeWarning } from "../user_msgs.js";
15
13
  import { formatStats, processOutput, readPromptFile } from "../utils.js";
16
- import { executeWorkflow } from "../workflows/cmd.js";
17
- import { configureTaskModel, mergeInferParams } from "./conf.js";
18
- import { McpServer } from "../mcp.js";
19
- import { openTaskSpec } from "./utils.js";
14
+ import { readTask } from "./read.js";
20
15
  async function executeTask(name, payload, options, quiet, expert) {
21
- await initAgent();
22
- if (options.debug) {
23
- console.log("Payload:", payload);
24
- console.log("Task options:", options);
25
- }
26
- const taskFileSpec = openTaskSpec(name);
27
- const opts = payload?.inferParams ? { ...options, ...payload.inferParams } : options;
28
- const conf = parseTaskConfigOptions(opts);
29
- if (options.debug) {
30
- console.log("conf:", conf);
31
- }
32
- conf.inferParams = mergeInferParams(conf.inferParams, taskFileSpec.inferParams ?? {});
33
- const model = configureTaskModel(conf, taskFileSpec);
34
- if (options?.ctx) {
35
- model.ctx = options.ctx;
36
- }
37
- const taskSpec = taskFileSpec;
38
- let vars = {};
39
- taskSpec.variables?.optional?.forEach(k => {
40
- if (k in options) {
41
- vars[k] = options[k];
42
- }
43
- });
44
- taskSpec.variables?.required?.forEach(k => {
45
- if (k in options) {
46
- vars[k] = options[k];
47
- }
48
- });
49
- const mcpServers = new Array();
50
- if (taskFileSpec?.mcp) {
51
- taskSpec.tools = [];
52
- for (const tool of Object.values(taskFileSpec.mcp)) {
53
- const mcp = new McpServer(tool.command, tool.arguments, tool?.tools ?? null);
54
- mcpServers.push(mcp);
55
- await mcp.start();
56
- const tools = await mcp.extractTools();
57
- tools.forEach(t => taskSpec.tools?.push(t));
58
- }
59
- }
60
- if (taskSpec.toolsList) {
61
- if (!taskSpec?.tools) {
62
- taskSpec.tools = [];
63
- }
64
- for (const toolName of taskSpec.toolsList) {
65
- const { found, tool, type } = readTool(toolName);
66
- if (!found) {
67
- throw new Error(`tool ${toolName} not found for task ${taskSpec.name}`);
68
- }
69
- const lmTool = {
70
- ...tool,
71
- execute: async (params) => {
72
- switch (type) {
73
- case "action":
74
- const res = await executeAction(toolName, params, options, true);
75
- return res;
76
- case "task":
77
- conf.quiet = !options?.debug;
78
- const tres = await executeTask(name, params, options, true);
79
- return tres.answer.text;
80
- case "workflow":
81
- const wres = await executeWorkflow(toolName, params, options);
82
- return wres;
83
- default:
84
- throw new Error(`unknown tool execution function type: ${type} for ${toolName}`);
85
- }
86
- }
87
- };
88
- taskSpec.tools.push(lmTool);
89
- }
90
- delete taskSpec.toolsList;
91
- }
92
- ;
93
- const task = taskBuilder.init(taskSpec);
16
+ const { task, model, conf, vars, mcpServers } = await readTask(name, payload, options);
94
17
  if (model?.inferParams?.tsGrammar) {
95
18
  model.inferParams.grammar = serializeGrammar(await compile(model.inferParams.tsGrammar, "Grammar"));
96
19
  delete model.inferParams.tsGrammar;
97
20
  }
98
- if (options.debug) {
21
+ if (options?.debug) {
99
22
  console.log("Task model:", model);
100
23
  }
101
24
  const ex = expert ?? brain.getOrCreateExpertForModel(model.name, model.template);
@@ -194,10 +117,11 @@ async function executeTask(name, payload, options, quiet, expert) {
194
117
  else {
195
118
  ex.backend.setOnToken(processToken);
196
119
  }
120
+ conf.inferParams.stream = true;
197
121
  const tconf = {
198
122
  expert: ex,
199
123
  model: model,
200
- debug: options.debug,
124
+ debug: options?.debug ?? false,
201
125
  onToolCall: onToolCall,
202
126
  ...conf,
203
127
  };
@@ -58,20 +58,25 @@ function configureTaskModel(itConf, taskSpec) {
58
58
  const m = readModel(modelName);
59
59
  if (m.found) {
60
60
  model = m.modelData;
61
- model.template = m.modelData.template;
61
+ model.template = templateName ?? m.modelData.template;
62
62
  found = true;
63
63
  }
64
64
  }
65
65
  if (!found) {
66
- const gt = tfm.guess(modelName);
67
- if (gt == "none") {
68
- throw new Error(`Unable to guess the template for ${modelName}: please provide a template name: m="modelname/templatename"`);
66
+ if (templateName && modelName) {
67
+ model = { name: modelName, template: templateName };
68
+ }
69
+ else {
70
+ const gt = tfm.guess(modelName);
71
+ if (gt == "none") {
72
+ throw new Error(`Unable to guess the template for ${modelName}: please provide a template name: --tpl templatename`);
73
+ }
74
+ const m = {
75
+ name: modelName,
76
+ template: gt
77
+ };
78
+ model = m;
69
79
  }
70
- const m = {
71
- name: modelName,
72
- template: gt
73
- };
74
- model = m;
75
80
  }
76
81
  model.inferParams = ip;
77
82
  if (!model?.ctx || !isModelFromTaskFile) {
@@ -0,0 +1,12 @@
1
+ import { LmTaskInput, LmTaskOutput, ModelSpec } from "../../../../../lmtask/dist/main.js";
2
+ import { McpClient } from "../mcp.js";
3
+ import { AgentTask } from "@agent-smith/jobs/dist/interfaces.js";
4
+ import { FeatureType, LmTaskConfig } from "../../../interfaces.js";
5
+ declare function readTask(name: string, payload: Record<string, any>, options: Record<string, any>): Promise<{
6
+ task: AgentTask<FeatureType, LmTaskInput, LmTaskOutput, Record<string, any>>;
7
+ model: ModelSpec;
8
+ conf: LmTaskConfig;
9
+ vars: Record<string, any>;
10
+ mcpServers: Array<McpClient>;
11
+ }>;
12
+ export { readTask };
@@ -0,0 +1,90 @@
1
+ import { compile, serializeGrammar } from "@intrinsicai/gbnfgen";
2
+ import { taskBuilder } from "../../../agent.js";
3
+ import { readTool } from "../../../db/read.js";
4
+ import { executeAction } from "../actions/cmd.js";
5
+ import { McpClient } from "../mcp.js";
6
+ import { parseTaskConfigOptions } from "../options_parsers.js";
7
+ import { executeWorkflow } from "../workflows/cmd.js";
8
+ import { configureTaskModel, mergeInferParams } from "./conf.js";
9
+ import { openTaskSpec } from "./utils.js";
10
+ import { executeTask } from "./cmd.js";
11
+ async function readTask(name, payload, options) {
12
+ if (options?.debug) {
13
+ console.log("Payload:", payload);
14
+ console.log("Task options:", options);
15
+ }
16
+ const taskFileSpec = openTaskSpec(name);
17
+ const opts = payload?.inferParams ? { ...options, ...payload.inferParams } : options;
18
+ const conf = parseTaskConfigOptions(opts);
19
+ if (options?.debug) {
20
+ console.log("conf:", conf);
21
+ }
22
+ conf.inferParams = mergeInferParams(conf.inferParams, taskFileSpec.inferParams ?? {});
23
+ const model = configureTaskModel(conf, taskFileSpec);
24
+ if (options?.ctx) {
25
+ model.ctx = options.ctx;
26
+ }
27
+ const taskSpec = taskFileSpec;
28
+ let vars = {};
29
+ taskSpec.variables?.optional?.forEach(k => {
30
+ if (k in options) {
31
+ vars[k] = options[k];
32
+ }
33
+ });
34
+ taskSpec.variables?.required?.forEach(k => {
35
+ if (k in options) {
36
+ vars[k] = options[k];
37
+ }
38
+ });
39
+ const mcpServers = new Array();
40
+ if (taskFileSpec?.mcp) {
41
+ taskSpec.tools = [];
42
+ for (const [servername, tool] of Object.entries(taskFileSpec.mcp)) {
43
+ const mcp = new McpClient(servername, tool.command, tool.args, tool?.tools ?? null);
44
+ mcpServers.push(mcp);
45
+ await mcp.start();
46
+ const tools = await mcp.extractTools();
47
+ tools.forEach(t => taskSpec.tools?.push(t));
48
+ }
49
+ }
50
+ if (taskSpec.toolsList) {
51
+ if (!taskSpec?.tools) {
52
+ taskSpec.tools = [];
53
+ }
54
+ for (const toolName of taskSpec.toolsList) {
55
+ const { found, tool, type } = readTool(toolName);
56
+ if (!found) {
57
+ throw new Error(`tool ${toolName} not found for task ${taskSpec.name}`);
58
+ }
59
+ const lmTool = {
60
+ ...tool,
61
+ execute: async (params) => {
62
+ switch (type) {
63
+ case "action":
64
+ const res = await executeAction(toolName, params, options, true);
65
+ return res;
66
+ case "task":
67
+ conf.quiet = !options?.debug;
68
+ const tres = await executeTask(name, params, options, true);
69
+ return tres.answer.text;
70
+ case "workflow":
71
+ const wres = await executeWorkflow(toolName, params, options);
72
+ return wres;
73
+ default:
74
+ throw new Error(`unknown tool execution function type: ${type} for ${toolName}`);
75
+ }
76
+ }
77
+ };
78
+ taskSpec.tools.push(lmTool);
79
+ }
80
+ delete taskSpec.toolsList;
81
+ }
82
+ ;
83
+ const task = taskBuilder.init(taskSpec);
84
+ if (model?.inferParams?.tsGrammar) {
85
+ model.inferParams.grammar = serializeGrammar(await compile(model.inferParams.tsGrammar, "Grammar"));
86
+ delete model.inferParams.tsGrammar;
87
+ }
88
+ return { task, model, conf, vars, mcpServers };
89
+ }
90
+ export { readTask };
@@ -42,7 +42,7 @@ function _extractYamlToolDoc(filePath, name) {
42
42
  if (!found) {
43
43
  return { found: false, tspec: {} };
44
44
  }
45
- if (!data.tool) {
45
+ if (!data?.tool) {
46
46
  return { found: false, tspec: {} };
47
47
  }
48
48
  data.tool.name = name;
@@ -78,7 +78,7 @@ function extractTaskToolDocAndVariables(name, ext, dirPath) {
78
78
  if (!found) {
79
79
  throw new Error(`extractTaskToolDocAndVariables: file ${fp} not found`);
80
80
  }
81
- if (data.tool) {
81
+ if (data?.tool) {
82
82
  data.tool.name = name;
83
83
  tspec = data.tool;
84
84
  res.toolDoc = JSON.stringify(tspec, null, " ");
package/dist/conf.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from "path";
2
2
  import { readConf } from "./cmd/sys/read_conf.js";
3
- import { insertFeaturesPathIfNotExists, insertPluginIfNotExists } from "./db/write.js";
3
+ import { upsertBackend, insertFeaturesPathIfNotExists, insertPluginIfNotExists } from "./db/write.js";
4
4
  import { buildPluginsPaths } from "./state/plugins.js";
5
5
  import { runtimeError } from "./cmd/lib/user_msgs.js";
6
6
  const confDir = path.join(process.env.HOME, ".config/agent-smith/cli");
@@ -10,7 +10,19 @@ async function processConfPath(confPath) {
10
10
  if (!found) {
11
11
  runtimeError(`Config file ${confPath} not found`);
12
12
  }
13
+ console.log(data);
13
14
  const allPaths = new Array();
15
+ if (data?.backends) {
16
+ for (const [name, bconf] of Object.entries(data.backends)) {
17
+ const bc = {
18
+ name: name,
19
+ type: bconf.type,
20
+ uri: bconf.uri,
21
+ apiKey: bconf?.apiKey,
22
+ };
23
+ upsertBackend(bc);
24
+ }
25
+ }
14
26
  if (data?.features) {
15
27
  allPaths.push(...data.features);
16
28
  const fts = new Array();
package/dist/db/read.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ToolSpec } from "modprompt";
2
2
  import { AliasType, FeatureSpec, FeatureType, DbModelDef, ToolType } from "../interfaces.js";
3
3
  declare function readFeaturePaths(): Array<string>;
4
+ declare function readBackends(): Array<Record<string, string>>;
4
5
  declare function readPlugins(): Array<Record<string, string>>;
5
6
  declare function readFeaturesType(type: FeatureType): Record<string, FeatureSpec>;
6
7
  declare function readFeatures(): Record<FeatureType, Record<string, FeatureSpec>>;
@@ -31,4 +32,4 @@ declare function readModel(shortname: string): {
31
32
  found: boolean;
32
33
  modelData: Record<string, any>;
33
34
  };
34
- export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePath, readFilePaths, readTool, readModels, readModelfiles, readModel, readFeaturesType, };
35
+ export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePath, readFilePaths, readTool, readModels, readModelfiles, readModel, readFeaturesType, readBackends, };
package/dist/db/read.js CHANGED
@@ -8,6 +8,15 @@ function readFeaturePaths() {
8
8
  });
9
9
  return f;
10
10
  }
11
+ function readBackends() {
12
+ const stmt = db.prepare("SELECT name, type, uri, apiKey FROM backend");
13
+ const data = stmt.all();
14
+ let f = new Array();
15
+ data.forEach((row) => {
16
+ f.push({ name: row.name, type: row.type, uri: row.uri, apiKey: row.apiKey });
17
+ });
18
+ return f;
19
+ }
11
20
  function readPlugins() {
12
21
  const stmt = db.prepare("SELECT name, path FROM plugin");
13
22
  const data = stmt.all();
@@ -135,4 +144,4 @@ function readModel(shortname) {
135
144
  }
136
145
  return { found: false, modelData: {} };
137
146
  }
138
- export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePath, readFilePaths, readTool, readModels, readModelfiles, readModel, readFeaturesType, };
147
+ export { readFeatures, readFeaturePaths, readFeature, readPlugins, readAliases, readFilePath, readFilePaths, readTool, readModels, readModelfiles, readModel, readFeaturesType, readBackends, };
@@ -71,6 +71,13 @@ const model = `CREATE TABLE IF NOT EXISTS model (
71
71
  shortname TEXT UNIQUE NOT NULL,
72
72
  data TEXT NOT NULL
73
73
  );`;
74
+ const backend = `CREATE TABLE IF NOT EXISTS backend (
75
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
76
+ name TEXT UNIQUE NOT NULL,
77
+ type TEXT NOT NULL CHECK ( type IN ('llamacpp', 'koboldcpp', 'ollama') ),
78
+ uri TEXT NOT NULL,
79
+ apiKey TEXT
80
+ );`;
74
81
  const schemas = [
75
82
  filepath,
76
83
  featurespath,
@@ -84,5 +91,6 @@ const schemas = [
84
91
  model,
85
92
  modelfile,
86
93
  adaptater,
94
+ backend,
87
95
  ];
88
96
  export { schemas };
@@ -1,6 +1,7 @@
1
- import { Features, DbModelDef } from "../interfaces.js";
1
+ import { Features, DbModelDef, RemoteBackend } from "../interfaces.js";
2
2
  declare function updatePromptfilePath(pf: string): void;
3
3
  declare function updateDataDirPath(dd: string): void;
4
+ declare function upsertBackend(bdata: RemoteBackend): boolean;
4
5
  declare function insertFeaturesPathIfNotExists(path: string): boolean;
5
6
  declare function insertPluginIfNotExists(n: string, p: string): boolean;
6
7
  declare function cleanupFeaturePaths(paths: Array<string>): Array<string>;
@@ -8,4 +9,4 @@ declare function updateAliases(feats: Features): void;
8
9
  declare function updateModels(models: Array<DbModelDef>): void;
9
10
  declare function updateFeatures(feats: Features): void;
10
11
  declare function upsertFilePath(name: string, newPath: string): boolean;
11
- export { updatePromptfilePath, updateDataDirPath, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, updateModels, upsertFilePath, };
12
+ export { updatePromptfilePath, updateDataDirPath, upsertBackend, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, updateModels, upsertFilePath, };
package/dist/db/write.js CHANGED
@@ -13,6 +13,18 @@ function updateDataDirPath(dd) {
13
13
  const stmt = db.prepare("INSERT INTO filepath (name, path) VALUES (?, ?)");
14
14
  stmt.run("datadir", dd);
15
15
  }
16
+ function upsertBackend(bdata) {
17
+ const stmt1 = db.prepare("SELECT * FROM backend WHERE name = ?");
18
+ const result = stmt1.get(bdata.name);
19
+ if (result?.id) {
20
+ const updateStmt = db.prepare("UPDATE backend SET type = ?, uri = ?, apiKey = ? WHERE name = ?");
21
+ updateStmt.run(bdata.type, bdata.uri, bdata?.apiKey ?? "NULL", bdata.name);
22
+ return true;
23
+ }
24
+ const stmt = db.prepare("INSERT INTO backend (name,type,uri,apiKey) VALUES (?,?,?,?)");
25
+ stmt.run(bdata.name, bdata.type, bdata.uri, bdata?.apiKey ?? "NULL");
26
+ return false;
27
+ }
16
28
  function insertFeaturesPathIfNotExists(path) {
17
29
  const stmt1 = db.prepare("SELECT * FROM featurespath WHERE path = ?");
18
30
  const result = stmt1.get(path);
@@ -194,4 +206,4 @@ function upsertFilePath(name, newPath) {
194
206
  return true;
195
207
  }
196
208
  }
197
- export { updatePromptfilePath, updateDataDirPath, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, updateModels, upsertFilePath, };
209
+ export { updatePromptfilePath, updateDataDirPath, upsertBackend, insertFeaturesPathIfNotExists, insertPluginIfNotExists, updateFeatures, updateAliases, cleanupFeaturePaths, updateModels, upsertFilePath, };
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import { query } from "./cli.js";
5
5
  import { buildCmds, parseCmd } from './cmd/cmds.js';
6
6
  import { formatMode, initState, inputMode, isChatMode, outputMode, runMode } from './state/state.js';
7
7
  import { updateConfCmd } from './cmd/clicmds/update.js';
8
+ import { initRemoteBackends } from './cmd/backends.js';
8
9
  async function main() {
9
10
  const nargs = argv.length;
10
11
  if (nargs == 2) {
@@ -17,7 +18,8 @@ async function main() {
17
18
  }
18
19
  }
19
20
  await initState();
20
- await initAgent();
21
+ const rmbs = initRemoteBackends();
22
+ await initAgent(rmbs);
21
23
  const program = await buildCmds();
22
24
  program.hook('preAction', async (thisCommand, actionCommand) => {
23
25
  const options = actionCommand.opts();
@@ -43,11 +43,18 @@ interface Features {
43
43
  ext: ModelFileExtension;
44
44
  }>;
45
45
  }
46
+ interface RemoteBackend {
47
+ name: string;
48
+ type: RemoteProviderType;
49
+ uri: string;
50
+ apiKey?: string;
51
+ }
46
52
  interface ConfigFile {
47
53
  promptfile?: string;
48
54
  datadir?: string;
49
55
  features?: Array<string>;
50
56
  plugins?: Array<string>;
57
+ backends?: Array<RemoteBackend>;
51
58
  }
52
59
  interface Settings {
53
60
  name: string;
@@ -125,4 +132,5 @@ type CmdExtension = "js";
125
132
  type ModelFileExtension = "yml";
126
133
  type FeatureExtension = TaskExtension | CmdExtension | ActionExtension | WorkflowExtension | ModelFileExtension;
127
134
  type AliasType = "task" | "action" | "workflow";
128
- export { InputMode, VerbosityMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, ModelFileExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, McpServerSpec, McpServerTool, };
135
+ type RemoteProviderType = "llamacpp" | "koboldcpp" | "ollama";
136
+ export { InputMode, VerbosityMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, ModelFileExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, McpServerSpec, McpServerTool, RemoteBackend, RemoteProviderType, };
package/dist/main.d.ts CHANGED
@@ -7,10 +7,11 @@ import { initAgent } from "./agent.js";
7
7
  import { initState, pluginDataDir } from "./state/state.js";
8
8
  import { usePerfTimer } from "./utils/perf.js";
9
9
  import { parseCommandArgs } from "./cmd/lib/options_parsers.js";
10
- import { LmTaskConf } from "@agent-smith/lmtask/dist/interfaces.js";
11
10
  import { extractToolDoc } from "./cmd/lib/tools.js";
12
11
  import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
13
12
  import { extractBetweenTags, splitThinking } from "./utils/text.js";
14
13
  import { displayOptions, ioOptions, inferenceOptions, allOptions } 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, allOptions, McpServer, };
14
+ import { McpClient } from "./cmd/lib/mcp.js";
15
+ import { readTask } from "./cmd/lib/tasks/read.js";
16
+ import { FeatureType } from "./interfaces.js";
17
+ export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, McpClient, readTask, FeatureType, };
package/dist/main.js CHANGED
@@ -11,5 +11,6 @@ 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
13
  import { displayOptions, ioOptions, inferenceOptions, allOptions } 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, allOptions, McpServer, };
14
+ import { McpClient } from "./cmd/lib/mcp.js";
15
+ import { readTask } from "./cmd/lib/tasks/read.js";
16
+ export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, allOptions, McpClient, readTask, };
@@ -8,6 +8,7 @@ declare const formatMode: import("@vue/reactivity").Ref<FormatMode, FormatMode>;
8
8
  declare const isChatMode: import("@vue/reactivity").Ref<boolean, boolean>;
9
9
  declare const promptfilePath: import("@vue/reactivity").Ref<string, string>;
10
10
  declare const dataDirPath: import("@vue/reactivity").Ref<string, string>;
11
+ declare const isStateReady: import("@vue/reactivity").Ref<boolean, boolean>;
11
12
  declare const lastCmd: {
12
13
  name: string;
13
14
  args: Array<string>;
@@ -15,4 +16,4 @@ declare const lastCmd: {
15
16
  declare function initFilepaths(): void;
16
17
  declare function initState(): Promise<void>;
17
18
  declare function pluginDataDir(pluginName: string): string;
18
- export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, pluginDataDir, initState, initFilepaths, pyShell, };
19
+ export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, pyShell, };
@@ -48,4 +48,4 @@ function pluginDataDir(pluginName) {
48
48
  createDirectoryIfNotExists(pluginDatapath);
49
49
  return pluginDatapath;
50
50
  }
51
- export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, pluginDataDir, initState, initFilepaths, pyShell, };
51
+ export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, pyShell, };
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.69",
5
+ "version": "0.0.71",
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.46",
14
14
  "@agent-smith/jobs": "^0.0.14",
15
- "@agent-smith/lmtask": "^0.0.45",
15
+ "@agent-smith/lmtask": "^0.0.47",
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.3",
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": "^24.0.2",
40
+ "@types/node": "^24.0.3",
41
41
  "restmix": "^0.5.0",
42
- "rollup": "^4.43.0",
42
+ "rollup": "^4.44.0",
43
43
  "ts-node": "^10.9.2",
44
44
  "tslib": "2.8.1",
45
45
  "typescript": "^5.8.3"