@agent-smith/cli 0.0.103 → 0.0.105
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/cli.js +4 -1
- package/dist/cmd/clicmds/cache.js +2 -2
- package/dist/cmd/clicmds/cmds.js +3 -8
- package/dist/cmd/cmds.d.ts +3 -1
- package/dist/cmd/cmds.js +4 -3
- package/dist/cmd/lib/tasks/cmd.js +32 -7
- package/dist/cmd/lib/tasks/read.js +20 -3
- package/dist/cmd/lib/workflows/cmd.js +55 -4
- package/dist/cmd/lib/workflows/read.js +5 -92
- package/dist/cmd/options.js +1 -0
- package/dist/cmd/sys/read_features.js +1 -1
- package/dist/interfaces.d.ts +0 -1
- package/dist/state/auto/usercmds.d.ts +4 -1
- package/dist/state/auto/usercmds.js +10 -7
- package/dist/state/state.d.ts +1 -3
- package/dist/state/state.js +1 -4
- package/package.json +6 -7
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { input } from '@inquirer/prompts';
|
|
2
2
|
import { chat } from './cmd/cmds.js';
|
|
3
3
|
import { isChatMode } from './state/state.js';
|
|
4
|
+
import { Agent } from '@agent-smith/agent';
|
|
5
|
+
import { backend } from './state/backends.js';
|
|
4
6
|
async function query(program) {
|
|
5
7
|
const data = { message: "$", default: "" };
|
|
6
8
|
const q = await input(data);
|
|
7
9
|
const args = q.split(" ");
|
|
8
10
|
await program.parseAsync(args, { from: "user" });
|
|
9
11
|
if (isChatMode.value) {
|
|
10
|
-
|
|
12
|
+
const agent = new Agent(backend.value, "chat");
|
|
13
|
+
await chat(program, {}, agent, []);
|
|
11
14
|
}
|
|
12
15
|
await query(program);
|
|
13
16
|
}
|
|
@@ -15,8 +15,8 @@ function createCacheFileContent(cmdFeats) {
|
|
|
15
15
|
++i;
|
|
16
16
|
});
|
|
17
17
|
const finalImports = imports.join("\n");
|
|
18
|
-
const cmds = `const cmds = [ ${cmdNames.join(", ")} ]
|
|
19
|
-
const end = "export { cmds }";
|
|
18
|
+
const cmds = `const cmds = [ ${cmdNames.join(", ")} ];\nconst isCacheReady = true;`;
|
|
19
|
+
const end = "export { isCacheReady, cmds }";
|
|
20
20
|
return `${finalImports}\n\n${cmds}\n\n${end}`;
|
|
21
21
|
}
|
|
22
22
|
function ensureUserCmdsCacheFileExists(cacheFilePath) {
|
package/dist/cmd/clicmds/cmds.js
CHANGED
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import colors from "ansi-colors";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { pathToFileURL } from 'url';
|
|
4
3
|
import YAML from 'yaml';
|
|
5
4
|
import { cacheFilePath, dbPath } from "../../conf.js";
|
|
6
5
|
import { readFeaturePaths, readFeaturesType, readTaskSetting } from "../../db/read.js";
|
|
7
6
|
import { cleanupFeaturePaths, deleteTaskSetting, updateAliases, updateFeatures, upsertTaskSettings } from "../../db/write.js";
|
|
7
|
+
import { isCacheReady, cmds } from "../../state/auto/usercmds.js";
|
|
8
8
|
import { getFeatureSpec, readFeaturesDirs } from "../../state/features.js";
|
|
9
9
|
import { readPluginsPaths } from "../../state/plugins.js";
|
|
10
10
|
import { runMode } from "../../state/state.js";
|
|
11
11
|
import { initTaskSettings, isTaskSettingsInitialized, tasksSettings } from '../../state/tasks.js';
|
|
12
|
-
import { cmds } from "../../state/auto/usercmds.js";
|
|
13
12
|
import { deleteFileIfExists } from "../sys/delete_file.js";
|
|
14
13
|
import { readCmd } from "../sys/read_cmds.js";
|
|
15
14
|
import { readTask } from "../sys/read_task.js";
|
|
16
15
|
import { updateUserCmdsCache } from './cache.js';
|
|
17
16
|
async function initUserCmds(cmdFeats) {
|
|
18
17
|
const features = Object.values(cmdFeats);
|
|
19
|
-
if (features.length == 0) {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
18
|
let endCmds = cmds;
|
|
23
|
-
if (
|
|
19
|
+
if (!isCacheReady) {
|
|
24
20
|
updateUserCmdsCache(cacheFilePath, features);
|
|
25
|
-
const
|
|
26
|
-
const usrCmds = new Array();
|
|
21
|
+
const usrCmds = [];
|
|
27
22
|
for (const feat of features) {
|
|
28
23
|
const cmdPath = path.join(feat.path, feat.name + "." + feat.ext);
|
|
29
24
|
const c = await readCmd(feat.name, cmdPath);
|
package/dist/cmd/cmds.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { InferenceOptions } from "@locallm/types/dist/inference.js";
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
+
import type { McpClient } from "../main.js";
|
|
4
|
+
import type { Agent } from "@agent-smith/agent";
|
|
3
5
|
declare const program: Command;
|
|
4
|
-
declare function chat(program: Command, options: InferenceOptions): Promise<void>;
|
|
6
|
+
declare function chat(program: Command, options: InferenceOptions, agent: Agent, mcpServers: Array<McpClient>): Promise<void>;
|
|
5
7
|
declare function buildCmds(): Promise<Command>;
|
|
6
8
|
declare function parseCmd(program: Command): Promise<void>;
|
|
7
9
|
export { buildCmds, chat, parseCmd, program };
|
package/dist/cmd/cmds.js
CHANGED
|
@@ -3,12 +3,12 @@ import { Command } from "commander";
|
|
|
3
3
|
import { query } from "../cli.js";
|
|
4
4
|
import { readAliases, readFeatures } from "../db/read.js";
|
|
5
5
|
import { chatInferenceParams, chatTemplate } from "../state/chat.js";
|
|
6
|
-
import {
|
|
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
10
|
const program = new Command();
|
|
11
|
-
async function chat(program, options) {
|
|
11
|
+
async function chat(program, options, agent, mcpServers) {
|
|
12
12
|
const data = { message: '>', default: "" };
|
|
13
13
|
const prompt = await input(data);
|
|
14
14
|
if (prompt == "/q") {
|
|
@@ -17,12 +17,13 @@ async function chat(program, options) {
|
|
|
17
17
|
process.exit(0);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
+
mcpServers.forEach(async (s) => await s.stop());
|
|
20
21
|
await query(program);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
await agent.run(prompt, chatInferenceParams, options, chatTemplate ? chatTemplate : undefined);
|
|
24
25
|
console.log();
|
|
25
|
-
await chat(program, options);
|
|
26
|
+
await chat(program, options, agent, mcpServers);
|
|
26
27
|
}
|
|
27
28
|
async function buildCmds() {
|
|
28
29
|
initBaseCommands(program);
|
|
@@ -5,7 +5,7 @@ import ora from 'ora';
|
|
|
5
5
|
import { usePerfTimer } from "../../../main.js";
|
|
6
6
|
import { backend, backends, listBackends } from "../../../state/backends.js";
|
|
7
7
|
import { setChatInferenceParams, setChatTemplate } from "../../../state/chat.js";
|
|
8
|
-
import {
|
|
8
|
+
import { isChatMode } from "../../../state/state.js";
|
|
9
9
|
import { initTaskSettings, isTaskSettingsInitialized, tasksSettings } from "../../../state/tasks.js";
|
|
10
10
|
import { chat, program } from "../../cmds.js";
|
|
11
11
|
import { parseCommandArgs } from "../options_parsers.js";
|
|
@@ -13,10 +13,12 @@ import { runtimeDataError, runtimeError, runtimeWarning } from "../user_msgs.js"
|
|
|
13
13
|
import { processOutput } from "../utils.js";
|
|
14
14
|
import { readTask } from "./read.js";
|
|
15
15
|
import { getTaskPrompt } from "./utils.js";
|
|
16
|
+
import { Agent } from "@agent-smith/agent";
|
|
16
17
|
async function executeTask(name, payload, options) {
|
|
17
18
|
if (!isTaskSettingsInitialized.value) {
|
|
18
19
|
initTaskSettings();
|
|
19
20
|
}
|
|
21
|
+
const agent = new Agent(backend.value, name);
|
|
20
22
|
const hasSettings = Object.keys(tasksSettings).includes(name);
|
|
21
23
|
let settings = {};
|
|
22
24
|
if (hasSettings) {
|
|
@@ -35,9 +37,20 @@ async function executeTask(name, payload, options) {
|
|
|
35
37
|
agent.lm = backends[settings.backend];
|
|
36
38
|
}
|
|
37
39
|
if (options?.debug || options?.backend) {
|
|
38
|
-
console.log("Agent:", colors.bold(agent.
|
|
40
|
+
console.log("Agent:", colors.bold(agent.name), "( " + agent.lm.providerType + " backend type)");
|
|
39
41
|
}
|
|
40
42
|
const { task, model, conf, vars, mcpServers, taskDir } = await readTask(name, payload, options, agent);
|
|
43
|
+
if (options?.debug && mcpServers.length > 0) {
|
|
44
|
+
console.log("Starting", mcpServers.length, "mcp servers");
|
|
45
|
+
}
|
|
46
|
+
for (const mcp of mcpServers) {
|
|
47
|
+
await mcp.start();
|
|
48
|
+
const tools = await mcp.extractTools();
|
|
49
|
+
tools.forEach(t => task.def.tools?.push(t));
|
|
50
|
+
if (options?.debug) {
|
|
51
|
+
console.log("MCP start", mcp.name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
41
54
|
if (hasSettings) {
|
|
42
55
|
if (!model?.inferParams) {
|
|
43
56
|
model.inferParams = {};
|
|
@@ -222,10 +235,22 @@ async function executeTask(name, payload, options) {
|
|
|
222
235
|
throw new Error(errMsg);
|
|
223
236
|
}
|
|
224
237
|
}
|
|
225
|
-
if (!
|
|
226
|
-
|
|
238
|
+
if (!options?.isToolCall) {
|
|
239
|
+
if (!out.answer.text.endsWith("\n")) {
|
|
240
|
+
console.log();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (!isChatMode.value || options?.isToolCall) {
|
|
244
|
+
if (options?.debug) {
|
|
245
|
+
console.log("Closing", mcpServers.length, "mcp server(s)");
|
|
246
|
+
}
|
|
247
|
+
mcpServers.forEach((s) => {
|
|
248
|
+
s.stop();
|
|
249
|
+
if (options?.debug) {
|
|
250
|
+
console.log("MCP stop", s.name);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
227
253
|
}
|
|
228
|
-
mcpServers.forEach(async (s) => await s.stop());
|
|
229
254
|
await processOutput(out);
|
|
230
255
|
if (!options?.isToolCall && isChatMode.value) {
|
|
231
256
|
if (tpl) {
|
|
@@ -244,7 +269,7 @@ async function executeTask(name, payload, options) {
|
|
|
244
269
|
options.assistant = task.def.template.assistant;
|
|
245
270
|
}
|
|
246
271
|
setChatInferenceParams(initialInferParams);
|
|
247
|
-
await chat(program, options);
|
|
272
|
+
await chat(program, options, agent, mcpServers);
|
|
248
273
|
}
|
|
249
274
|
if (options?.debug === true || options?.verbose === true) {
|
|
250
275
|
try {
|
|
@@ -257,7 +282,7 @@ async function executeTask(name, payload, options) {
|
|
|
257
282
|
runtimeWarning("Error formating stats:", `${e}`);
|
|
258
283
|
}
|
|
259
284
|
}
|
|
260
|
-
if (options?.backend) {
|
|
285
|
+
if (options?.backend || settings?.backend) {
|
|
261
286
|
agent.lm = backend.value;
|
|
262
287
|
}
|
|
263
288
|
return out;
|
|
@@ -55,6 +55,22 @@ async function readTask(name, payload, options, agent) {
|
|
|
55
55
|
if (!taskSpec?.tools) {
|
|
56
56
|
taskSpec.tools = [];
|
|
57
57
|
}
|
|
58
|
+
const mcpServersArgs = {};
|
|
59
|
+
if (options?.mcp) {
|
|
60
|
+
options.mcp.forEach(v => {
|
|
61
|
+
const s = v.split(":");
|
|
62
|
+
if (s.length < 2) {
|
|
63
|
+
throw new Error(`Malformed mcp option ${v}: use --mcp servername:arg1,arg2`);
|
|
64
|
+
}
|
|
65
|
+
const sn = s[0];
|
|
66
|
+
const sa = s[1];
|
|
67
|
+
const _margs = sa.split(",");
|
|
68
|
+
mcpServersArgs[sn] = _margs;
|
|
69
|
+
});
|
|
70
|
+
if (options?.debug) {
|
|
71
|
+
console.log("Opening", options.mcp.length, "server(s)");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
58
74
|
if (taskFileSpec?.mcp) {
|
|
59
75
|
for (const [servername, tool] of Object.entries(taskFileSpec.mcp)) {
|
|
60
76
|
const authorizedTools = new Array();
|
|
@@ -69,11 +85,12 @@ async function readTask(name, payload, options, agent) {
|
|
|
69
85
|
authorizedTools.push(tn);
|
|
70
86
|
});
|
|
71
87
|
}
|
|
88
|
+
const margs = tool.arguments;
|
|
89
|
+
if (servername in mcpServersArgs) {
|
|
90
|
+
margs.push(...mcpServersArgs[servername]);
|
|
91
|
+
}
|
|
72
92
|
const mcp = new McpClient(servername, tool.command, tool.arguments, authorizedTools.length > 0 ? authorizedTools : null, askUserTools.length > 0 ? askUserTools : null);
|
|
73
93
|
mcpServers.push(mcp);
|
|
74
|
-
await mcp.start();
|
|
75
|
-
const tools = await mcp.extractTools();
|
|
76
|
-
tools.forEach(t => taskSpec.tools?.push(t));
|
|
77
94
|
}
|
|
78
95
|
}
|
|
79
96
|
if (taskSpec.toolsList) {
|
|
@@ -5,6 +5,9 @@ import { executeTask } from "../tasks/cmd.js";
|
|
|
5
5
|
import { getTaskPrompt } from "../tasks/utils.js";
|
|
6
6
|
import { readWorkflow } from "./read.js";
|
|
7
7
|
import colors from "ansi-colors";
|
|
8
|
+
import { getFeatureSpec } from "../../../state/features.js";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
import { runtimeError } from "../user_msgs.js";
|
|
8
11
|
async function executeWorkflow(wname, args, options = {}) {
|
|
9
12
|
const { workflow, found } = await readWorkflow(wname);
|
|
10
13
|
if (!found) {
|
|
@@ -27,7 +30,7 @@ async function executeWorkflow(wname, args, options = {}) {
|
|
|
27
30
|
switch (step.type) {
|
|
28
31
|
case "task":
|
|
29
32
|
try {
|
|
30
|
-
let tdata =
|
|
33
|
+
let tdata = taskRes;
|
|
31
34
|
if (i == 0) {
|
|
32
35
|
tdata.prompt = await getTaskPrompt(step.name, taskRes.cmdArgs, options);
|
|
33
36
|
}
|
|
@@ -37,7 +40,6 @@ async function executeWorkflow(wname, args, options = {}) {
|
|
|
37
40
|
tdata.prompt = taskRes.answer.text;
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
|
-
tdata = taskRes;
|
|
41
43
|
}
|
|
42
44
|
if (!tdata?.prompt) {
|
|
43
45
|
throw new Error(`Workflow ${wname} step ${i + 1}: provide a prompt for the task ${step.name}`);
|
|
@@ -49,6 +51,31 @@ async function executeWorkflow(wname, args, options = {}) {
|
|
|
49
51
|
throw new Error(`workflow task ${i + 1}: ${e}`);
|
|
50
52
|
}
|
|
51
53
|
break;
|
|
54
|
+
case "agent":
|
|
55
|
+
try {
|
|
56
|
+
let tdata = taskRes;
|
|
57
|
+
if (i == 0) {
|
|
58
|
+
tdata.prompt = await getTaskPrompt(step.name, taskRes.cmdArgs, options);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (prevStepType) {
|
|
62
|
+
if (prevStepType == "task") {
|
|
63
|
+
tdata.prompt = taskRes.answer.text;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!tdata?.prompt) {
|
|
68
|
+
throw new Error(`Workflow ${wname} step ${i + 1}: provide a prompt for the task ${step.name}`);
|
|
69
|
+
}
|
|
70
|
+
options.isAgent = true;
|
|
71
|
+
const tr = await executeTask(step.name, tdata, options);
|
|
72
|
+
options.isAgent = false;
|
|
73
|
+
taskRes = { ...tr, ...taskRes };
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
throw new Error(`workflow task ${i + 1}: ${e}`);
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
52
79
|
case "action":
|
|
53
80
|
try {
|
|
54
81
|
const actArgs = i == 0 ? taskRes.cmdArgs : taskRes;
|
|
@@ -75,7 +102,7 @@ async function executeWorkflow(wname, args, options = {}) {
|
|
|
75
102
|
taskRes.args = adres;
|
|
76
103
|
}
|
|
77
104
|
else {
|
|
78
|
-
taskRes = { ...adres
|
|
105
|
+
taskRes = { ...adres };
|
|
79
106
|
}
|
|
80
107
|
if (i == finalTaskIndex) {
|
|
81
108
|
console.log(taskRes);
|
|
@@ -85,8 +112,32 @@ async function executeWorkflow(wname, args, options = {}) {
|
|
|
85
112
|
throw new Error(`workflow adaptater ${i + 1}: ${e}`);
|
|
86
113
|
}
|
|
87
114
|
break;
|
|
115
|
+
case "cmd":
|
|
116
|
+
try {
|
|
117
|
+
const { found, path } = getFeatureSpec(step.name, "cmd");
|
|
118
|
+
if (!found) {
|
|
119
|
+
throw new Error(`Command ${step.name} not found`);
|
|
120
|
+
}
|
|
121
|
+
const url = pathToFileURL(path).href;
|
|
122
|
+
const jsa = await import(url);
|
|
123
|
+
if (!jsa?.runCmd) {
|
|
124
|
+
runtimeError(`workflow ${wname}: can not import the runCmd function from step ${i} for command ${step.name}: please add a runCmd function export`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const cres = await jsa.runCmd(args, options);
|
|
128
|
+
if (typeof cres == "string" || Array.isArray(cres)) {
|
|
129
|
+
taskRes.args = cres;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
taskRes = { ...cres, ...taskRes };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
throw new Error(`workflow command ${i + 1}: ${e}`);
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
88
139
|
default:
|
|
89
|
-
throw new Error(`unknown
|
|
140
|
+
throw new Error(`unknown workflow step type ${step.type} in workflow ${wname}`);
|
|
90
141
|
}
|
|
91
142
|
prevStepType = step.type;
|
|
92
143
|
++i;
|
|
@@ -1,104 +1,17 @@
|
|
|
1
|
-
import { Agent } from '@agent-smith/agent';
|
|
2
|
-
import { Task } from '@agent-smith/task';
|
|
3
1
|
import { default as fs } from "fs";
|
|
4
2
|
import YAML from 'yaml';
|
|
5
|
-
import { backend } from '../../../state/backends.js';
|
|
6
3
|
import { getFeatureSpec } from '../../../state/features.js';
|
|
7
|
-
import { readTask } from "../../sys/read_task.js";
|
|
8
|
-
import { pythonAction, systemAction } from '../actions/cmd.js';
|
|
9
|
-
import { createJsAction } from '../actions/read.js';
|
|
10
|
-
import { pathToFileURL } from 'url';
|
|
11
4
|
async function _createWorkflowFromSpec(spec) {
|
|
12
5
|
const steps = [];
|
|
13
|
-
let i = 1;
|
|
14
6
|
for (const step of spec.steps) {
|
|
15
7
|
const type = Object.keys(step)[0];
|
|
16
8
|
const sval = step[type];
|
|
17
9
|
const name = sval;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
switch (ext) {
|
|
24
|
-
case "js":
|
|
25
|
-
const url = pathToFileURL(path).href;
|
|
26
|
-
const { action } = await import(url);
|
|
27
|
-
const at = action;
|
|
28
|
-
const wf = {
|
|
29
|
-
name: name,
|
|
30
|
-
type: "action",
|
|
31
|
-
run: at,
|
|
32
|
-
};
|
|
33
|
-
steps.push(wf);
|
|
34
|
-
break;
|
|
35
|
-
case "mjs":
|
|
36
|
-
const url2 = pathToFileURL(path).href;
|
|
37
|
-
const mjsa = await import(url2);
|
|
38
|
-
const act = createJsAction(mjsa.action);
|
|
39
|
-
const wf2 = {
|
|
40
|
-
name: name,
|
|
41
|
-
type: "action",
|
|
42
|
-
run: act,
|
|
43
|
-
};
|
|
44
|
-
steps.push(wf2);
|
|
45
|
-
break;
|
|
46
|
-
case "yml":
|
|
47
|
-
const _t1 = systemAction(path);
|
|
48
|
-
const wf3 = {
|
|
49
|
-
name: name,
|
|
50
|
-
type: "action",
|
|
51
|
-
run: _t1,
|
|
52
|
-
};
|
|
53
|
-
steps.push(wf3);
|
|
54
|
-
break;
|
|
55
|
-
case "py":
|
|
56
|
-
const _t = pythonAction(path);
|
|
57
|
-
const wf4 = {
|
|
58
|
-
name: name,
|
|
59
|
-
type: "action",
|
|
60
|
-
run: _t,
|
|
61
|
-
};
|
|
62
|
-
steps.push(wf4);
|
|
63
|
-
break;
|
|
64
|
-
default:
|
|
65
|
-
throw new Error(`Unknown feature extension ${ext}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else if (type == "adaptater") {
|
|
69
|
-
const { found, path } = getFeatureSpec(name, "adaptater");
|
|
70
|
-
if (!found) {
|
|
71
|
-
throw new Error(`Adaptater ${name} not found`);
|
|
72
|
-
}
|
|
73
|
-
const url = pathToFileURL(path).href;
|
|
74
|
-
const jsa = await import(url);
|
|
75
|
-
const act = createJsAction(jsa.action);
|
|
76
|
-
const wf = {
|
|
77
|
-
name: name,
|
|
78
|
-
type: "adaptater",
|
|
79
|
-
run: act,
|
|
80
|
-
};
|
|
81
|
-
steps.push(wf);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
const { found, path } = getFeatureSpec(name, "task");
|
|
85
|
-
if (!found) {
|
|
86
|
-
throw new Error(`Task ${name} not found`);
|
|
87
|
-
}
|
|
88
|
-
const res = readTask(path);
|
|
89
|
-
if (!res.found) {
|
|
90
|
-
throw new Error(`Unable to read task ${name} ${path}`);
|
|
91
|
-
}
|
|
92
|
-
const agent = new Agent(backend.value);
|
|
93
|
-
const tsk = Task.fromYaml(agent, res.ymlTask);
|
|
94
|
-
const wf = {
|
|
95
|
-
name: name,
|
|
96
|
-
type: "task",
|
|
97
|
-
run: tsk.run,
|
|
98
|
-
};
|
|
99
|
-
steps.push(wf);
|
|
100
|
-
}
|
|
101
|
-
++i;
|
|
10
|
+
const wf = {
|
|
11
|
+
name: name,
|
|
12
|
+
type: type == "command" ? "cmd" : type,
|
|
13
|
+
};
|
|
14
|
+
steps.push(wf);
|
|
102
15
|
}
|
|
103
16
|
return steps;
|
|
104
17
|
}
|
package/dist/cmd/options.js
CHANGED
|
@@ -14,6 +14,7 @@ const inferenceOptions = [
|
|
|
14
14
|
new Option("-t, --temperature <number>", "adjusts randomness in sampling; higher values mean more randomness").argParser(parseFloatValue),
|
|
15
15
|
new Option("-r, --repeat_penalty <number>", "adjusts penalty for repeated tokens").argParser(parseFloatValue),
|
|
16
16
|
new Option("-b, --backend <name>", "use a given backend. It must be registered in config").argParser(parseString),
|
|
17
|
+
new Option("--mcp [args...]", "extra arguments for mcp server arguments: --mcp servername:arg1,arg2"),
|
|
17
18
|
];
|
|
18
19
|
const ioOptions = [
|
|
19
20
|
new Option("--if, --input-file", "use promptfile input mode"),
|
|
@@ -66,7 +66,7 @@ function readFeaturesDir(dir) {
|
|
|
66
66
|
}
|
|
67
67
|
dirpath = path.join(dir, "actions");
|
|
68
68
|
if (fs.existsSync(dirpath)) {
|
|
69
|
-
const data = _readDir(dirpath, ["yml", ".js", "
|
|
69
|
+
const data = _readDir(dirpath, [".yml", ".js", ".py"]);
|
|
70
70
|
data.forEach((filename) => {
|
|
71
71
|
const parts = filename.split(".");
|
|
72
72
|
const ext = parts.pop();
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { cmd as c1 } from "file:///home/ggg/
|
|
2
|
-
import { cmd as c2 } from "file:///home/ggg/dev/js/agent-smith-plugins/
|
|
3
|
-
import { cmd as c3 } from "file:///home/ggg/dev/js/agent-smith-plugins/code/git/dist/cmds/
|
|
4
|
-
import { cmd as c4 } from "file:///home/ggg/dev/js/
|
|
5
|
-
import { cmd as c5 } from "file:///home/ggg/dev/js/
|
|
1
|
+
import { cmd as c1 } from "file:///home/ggg/lm/features/dist/cmds/testcmd.js";
|
|
2
|
+
import { cmd as c2 } from "file:///home/ggg/dev/js/agent-smith-plugins/system/fs/dist/cmds/lsdir.js";
|
|
3
|
+
import { cmd as c3 } from "file:///home/ggg/dev/js/agent-smith-plugins/code/git/dist/cmds/commit.js";
|
|
4
|
+
import { cmd as c4 } from "file:///home/ggg/dev/js/agent-smith-plugins/code/git/dist/cmds/commita.js";
|
|
5
|
+
import { cmd as c5 } from "file:///home/ggg/dev/js/agent-smith-plugins/vision/dist/cmds/imgs2base64.js";
|
|
6
|
+
import { cmd as c6 } from "file:///home/ggg/dev/js/snowind-astro/features/cmds/design-component.js";
|
|
7
|
+
import { cmd as c7 } from "file:///home/ggg/dev/js/docdundee/package/features/dist/cmds/tsdoccmd.js";
|
|
6
8
|
|
|
7
|
-
const cmds = [ c1, c2, c3, c4, c5 ]
|
|
9
|
+
const cmds = [ c1, c2, c3, c4, c5, c6, c7 ];
|
|
10
|
+
const isCacheReady = true;
|
|
8
11
|
|
|
9
|
-
export { cmds }
|
|
12
|
+
export { isCacheReady, cmds }
|
package/dist/state/state.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PythonShell } from 'python-shell';
|
|
2
2
|
import { InputMode, RunMode, FormatMode, OutputMode } from "../interfaces.js";
|
|
3
|
-
import { Agent } from "@agent-smith/agent";
|
|
4
3
|
declare let pyShell: PythonShell;
|
|
5
4
|
declare const inputMode: import("@vue/reactivity").Ref<InputMode, InputMode>;
|
|
6
5
|
declare const outputMode: import("@vue/reactivity").Ref<OutputMode, OutputMode>;
|
|
@@ -10,7 +9,6 @@ declare const isChatMode: import("@vue/reactivity").Ref<boolean, boolean>;
|
|
|
10
9
|
declare const promptfilePath: import("@vue/reactivity").Ref<string, string>;
|
|
11
10
|
declare const dataDirPath: import("@vue/reactivity").Ref<string, string>;
|
|
12
11
|
declare const isStateReady: import("@vue/reactivity").Ref<boolean, boolean>;
|
|
13
|
-
declare let agent: Agent;
|
|
14
12
|
declare const lastCmd: {
|
|
15
13
|
name: string;
|
|
16
14
|
args: Array<string>;
|
|
@@ -19,4 +17,4 @@ declare function initFilepaths(): void;
|
|
|
19
17
|
declare function init(): Promise<void>;
|
|
20
18
|
declare function initState(): Promise<void>;
|
|
21
19
|
declare function pluginDataDir(pluginName: string): string;
|
|
22
|
-
export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, init, pyShell,
|
|
20
|
+
export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, init, pyShell, };
|
package/dist/state/state.js
CHANGED
|
@@ -4,7 +4,6 @@ import { readFilePaths } from "../db/read.js";
|
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { createDirectoryIfNotExists } from "../cmd/sys/dirs.js";
|
|
6
6
|
import { backend, initBackends } from "./backends.js";
|
|
7
|
-
import { Agent } from "@agent-smith/agent";
|
|
8
7
|
import { runtimeDataError } from "../utils/user_msgs.js";
|
|
9
8
|
let pyShell;
|
|
10
9
|
const inputMode = ref("manual");
|
|
@@ -15,7 +14,6 @@ const isChatMode = ref(false);
|
|
|
15
14
|
const promptfilePath = ref("");
|
|
16
15
|
const dataDirPath = ref("");
|
|
17
16
|
const isStateReady = ref(false);
|
|
18
|
-
let agent;
|
|
19
17
|
const lastCmd = reactive({
|
|
20
18
|
name: "",
|
|
21
19
|
args: [],
|
|
@@ -39,7 +37,6 @@ async function init() {
|
|
|
39
37
|
runtimeDataError("No backend found, can not initialize agent");
|
|
40
38
|
return;
|
|
41
39
|
}
|
|
42
|
-
agent = new Agent(backend.value);
|
|
43
40
|
}
|
|
44
41
|
async function initState() {
|
|
45
42
|
if (isStateReady.value) {
|
|
@@ -61,4 +58,4 @@ function pluginDataDir(pluginName) {
|
|
|
61
58
|
createDirectoryIfNotExists(pluginDatapath);
|
|
62
59
|
return pluginDatapath;
|
|
63
60
|
}
|
|
64
|
-
export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, init, pyShell,
|
|
61
|
+
export { inputMode, outputMode, isChatMode, runMode, formatMode, lastCmd, promptfilePath, dataDirPath, isStateReady, pluginDataDir, initState, initFilepaths, init, 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.105",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"watch": "tsc --noCheck -p . -w"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-smith/agent": "^0.2.
|
|
13
|
+
"@agent-smith/agent": "^0.2.1",
|
|
14
14
|
"@agent-smith/task": "^0.2.1",
|
|
15
15
|
"@agent-smith/nodetask": "^0.1.0",
|
|
16
16
|
"@agent-smith/tfm": "^0.2.0",
|
|
17
|
-
"@inquirer/prompts": "^8.
|
|
17
|
+
"@inquirer/prompts": "^8.2.0",
|
|
18
18
|
"@intrinsicai/gbnfgen": "0.12.0",
|
|
19
19
|
"@locallm/api": "^0.7.3",
|
|
20
20
|
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
21
21
|
"@vue/reactivity": "^3.5.26",
|
|
22
22
|
"ansi-colors": "^4.1.3",
|
|
23
|
-
"better-sqlite3": "^12.
|
|
23
|
+
"better-sqlite3": "^12.6.0",
|
|
24
24
|
"clipboardy": "^5.0.2",
|
|
25
25
|
"commander": "^14.0.2",
|
|
26
26
|
"marked-terminal": "^7.3.0",
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
"yaml": "^2.8.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@agent-smith/tmem-jobs": "^0.0.4",
|
|
33
32
|
"@cfworker/json-schema": "^4.1.1",
|
|
34
33
|
"@commander-js/extra-typings": "^14.0.0",
|
|
35
34
|
"@locallm/types": "^0.6.7",
|
|
@@ -37,8 +36,8 @@
|
|
|
37
36
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
38
37
|
"@types/better-sqlite3": "^7.6.13",
|
|
39
38
|
"@types/marked-terminal": "^6.1.1",
|
|
40
|
-
"@types/node": "^25.0.
|
|
41
|
-
"openai": "^6.
|
|
39
|
+
"@types/node": "^25.0.8",
|
|
40
|
+
"openai": "^6.16.0",
|
|
42
41
|
"restmix": "^0.6.1",
|
|
43
42
|
"rollup": "^4.55.1",
|
|
44
43
|
"ts-node": "^10.9.2",
|