@agent-smith/cli 0.0.70 → 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 +3 -2
- package/dist/agent.js +8 -11
- package/dist/cmd/backends.d.ts +3 -0
- package/dist/cmd/backends.js +20 -0
- package/dist/cmd/clicmds/base.js +2 -1
- package/dist/cmd/clicmds/cmds.js +5 -0
- package/dist/cmd/lib/tasks/cmd.js +7 -83
- package/dist/cmd/lib/tasks/conf.js +14 -9
- package/dist/cmd/lib/tasks/read.d.ts +12 -0
- package/dist/cmd/lib/tasks/read.js +90 -0
- package/dist/cmd/lib/tools.js +2 -2
- package/dist/conf.js +13 -1
- package/dist/db/read.d.ts +2 -1
- package/dist/db/read.js +10 -1
- package/dist/db/schemas.js +8 -0
- package/dist/db/write.d.ts +3 -2
- package/dist/db/write.js +13 -1
- package/dist/index.js +3 -1
- package/dist/interfaces.d.ts +9 -1
- package/dist/main.d.ts +3 -2
- package/dist/main.js +2 -1
- package/dist/state/state.d.ts +2 -1
- package/dist/state/state.js +1 -1
- package/package.json +3 -3
package/dist/agent.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
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 "
|
|
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
|
|
9
|
-
|
|
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
|
-
|
|
19
|
-
|
|
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,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, };
|
package/dist/cmd/clicmds/base.js
CHANGED
|
@@ -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));
|
package/dist/cmd/clicmds/cmds.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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
|
|
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 {
|
|
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 {
|
|
17
|
-
import { configureTaskModel, mergeInferParams } from "./conf.js";
|
|
18
|
-
import { McpClient } 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
|
|
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 [servername, tool] of Object.entries(taskFileSpec.mcp)) {
|
|
53
|
-
const mcp = new McpClient(servername, tool.command, tool.args, 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
|
|
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
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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 };
|
package/dist/cmd/lib/tools.js
CHANGED
|
@@ -42,7 +42,7 @@ function _extractYamlToolDoc(filePath, name) {
|
|
|
42
42
|
if (!found) {
|
|
43
43
|
return { found: false, tspec: {} };
|
|
44
44
|
}
|
|
45
|
-
if (!data
|
|
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
|
|
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, };
|
package/dist/db/schemas.js
CHANGED
|
@@ -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 };
|
package/dist/db/write.d.ts
CHANGED
|
@@ -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
|
-
|
|
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();
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
14
|
import { McpClient } from "./cmd/lib/mcp.js";
|
|
16
|
-
|
|
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
|
@@ -12,4 +12,5 @@ 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
14
|
import { McpClient } from "./cmd/lib/mcp.js";
|
|
15
|
-
|
|
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, };
|
package/dist/state/state.d.ts
CHANGED
|
@@ -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, };
|
package/dist/state/state.js
CHANGED
|
@@ -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.
|
|
5
|
+
"version": "0.0.71",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"watch": "tsc --noCheck -p . -w"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-smith/brain": "^0.0.
|
|
13
|
+
"@agent-smith/brain": "^0.0.46",
|
|
14
14
|
"@agent-smith/jobs": "^0.0.14",
|
|
15
|
-
"@agent-smith/lmtask": "^0.0.
|
|
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",
|