@agent-smith/cli 0.0.10 → 0.0.12
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/cmd/clicmds/cmds.js
CHANGED
|
@@ -128,7 +128,7 @@ async function _executeTaskCmd(args = [], options) {
|
|
|
128
128
|
console.warn("Provide a task name");
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
|
-
const { ok, data, error } = await executeTaskCmd(args);
|
|
131
|
+
const { ok, data, error } = await executeTaskCmd(args, options);
|
|
132
132
|
if (!ok) {
|
|
133
133
|
console.warn(error);
|
|
134
134
|
}
|
|
@@ -12,13 +12,23 @@ async function executeJobCmd(name, args = []) {
|
|
|
12
12
|
return { error: `Job ${name} not found` };
|
|
13
13
|
}
|
|
14
14
|
await job.start();
|
|
15
|
-
let params = args;
|
|
16
15
|
let res = {};
|
|
16
|
+
let params = {};
|
|
17
17
|
brain.backendsForModelsInfo();
|
|
18
|
+
let i = 0;
|
|
18
19
|
for (const [name, task] of Object.entries(job.tasks)) {
|
|
19
20
|
if (task.type == "task") {
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
let conf = {};
|
|
22
|
+
let vars = {};
|
|
23
|
+
if (i == 0) {
|
|
24
|
+
const tv = initTaskVars(args);
|
|
25
|
+
conf = tv.conf;
|
|
26
|
+
vars = tv.vars;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
conf = {};
|
|
30
|
+
vars = params;
|
|
31
|
+
}
|
|
22
32
|
const { found, path } = getFeatureSpec(name, "task");
|
|
23
33
|
if (!found) {
|
|
24
34
|
return { ok: false, data: {}, error: `Task ${name} not found` };
|
|
@@ -37,7 +47,6 @@ async function executeJobCmd(name, args = []) {
|
|
|
37
47
|
process.stdout.write(t);
|
|
38
48
|
});
|
|
39
49
|
conf["expert"] = ex;
|
|
40
|
-
vars["prompt"] = pr;
|
|
41
50
|
try {
|
|
42
51
|
res = await job.runTask(name, vars, conf);
|
|
43
52
|
if ("text" in res) {
|
|
@@ -46,19 +55,27 @@ async function executeJobCmd(name, args = []) {
|
|
|
46
55
|
console.log(marked.parse(res.text).trim());
|
|
47
56
|
}
|
|
48
57
|
}
|
|
58
|
+
params = res;
|
|
49
59
|
}
|
|
50
60
|
catch (err) {
|
|
51
|
-
return { error: `Error executing task ${name}: ${err}` };
|
|
61
|
+
return { error: `Error executing (${task.type}) task ${name}: ${err}` };
|
|
52
62
|
}
|
|
53
63
|
}
|
|
54
64
|
else {
|
|
55
65
|
try {
|
|
56
|
-
|
|
66
|
+
if (i == 0) {
|
|
67
|
+
res = await job.runTask(name, args);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
res = await job.runTask(name, params);
|
|
71
|
+
}
|
|
72
|
+
params = res.data;
|
|
57
73
|
}
|
|
58
74
|
catch (err) {
|
|
59
|
-
return { error: `Error executing task ${name}: ${err}` };
|
|
75
|
+
return { error: `Error executing (${task.type}) task ${name}: ${err}` };
|
|
60
76
|
}
|
|
61
77
|
}
|
|
78
|
+
++i;
|
|
62
79
|
}
|
|
63
80
|
await job.finish(true);
|
|
64
81
|
return res;
|
|
@@ -2,9 +2,21 @@ import { brain, initAgent, taskBuilder } from "../../agent.js";
|
|
|
2
2
|
import { getFeatureSpec } from "../../state/features.js";
|
|
3
3
|
import { runMode } from "../../state/state.js";
|
|
4
4
|
import { initTaskVars, readTask } from "./utils.js";
|
|
5
|
+
import { readClipboard } from "../sys/clipboard.js";
|
|
5
6
|
async function executeTaskCmd(args = [], options = {}) {
|
|
6
7
|
await initAgent(runMode.value);
|
|
7
8
|
const name = args.shift();
|
|
9
|
+
const params = args.filter((x) => x.length > 0);
|
|
10
|
+
let pr;
|
|
11
|
+
if (options?.Ic == true) {
|
|
12
|
+
pr = await readClipboard();
|
|
13
|
+
}
|
|
14
|
+
else if (params.length > 0) {
|
|
15
|
+
pr = params.shift();
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
throw new Error("Please provide a prompt");
|
|
19
|
+
}
|
|
8
20
|
const { found, path } = getFeatureSpec(name, "task");
|
|
9
21
|
if (!found) {
|
|
10
22
|
return { ok: false, data: {}, error: `Task ${name} not found` };
|
|
@@ -15,7 +27,6 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
15
27
|
}
|
|
16
28
|
const taskSpec = taskBuilder.readFromYaml(res.ymlTask);
|
|
17
29
|
const task = taskBuilder.fromYaml(res.ymlTask);
|
|
18
|
-
const pr = args.shift();
|
|
19
30
|
const { conf, vars } = initTaskVars(args);
|
|
20
31
|
const ex = brain.getOrCreateExpertForModel(taskSpec.model.name, taskSpec.template.name);
|
|
21
32
|
if (!ex) {
|
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.12",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"watch": "tsc -p . -w"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-smith/brain": "^0.0.
|
|
13
|
+
"@agent-smith/brain": "^0.0.31",
|
|
14
14
|
"@agent-smith/jobs": "^0.0.11",
|
|
15
15
|
"@agent-smith/lmtask": "^0.0.20",
|
|
16
16
|
"@inquirer/prompts": "^6.0.1",
|
|
17
17
|
"@inquirer/select": "^3.0.1",
|
|
18
|
-
"@vue/reactivity": "^3.5.
|
|
18
|
+
"@vue/reactivity": "^3.5.11",
|
|
19
19
|
"better-sqlite3": "^11.3.0",
|
|
20
20
|
"clipboardy": "^4.0.0",
|
|
21
21
|
"commander": "^12.1.0",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"@agent-smith/tmem-jobs": "^0.0.4",
|
|
30
30
|
"@commander-js/extra-typings": "^12.1.0",
|
|
31
31
|
"@locallm/types": "^0.1.5",
|
|
32
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
33
|
-
"@rollup/plugin-typescript": "^
|
|
32
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
33
|
+
"@rollup/plugin-typescript": "^12.1.0",
|
|
34
34
|
"@types/better-sqlite3": "^7.6.11",
|
|
35
35
|
"@types/marked-terminal": "^6.1.1",
|
|
36
|
-
"@types/node": "^22.
|
|
36
|
+
"@types/node": "^22.7.4",
|
|
37
37
|
"restmix": "^0.5.0",
|
|
38
|
-
"rollup": "^4.
|
|
38
|
+
"rollup": "^4.24.0",
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
40
|
"tslib": "2.7.0",
|
|
41
41
|
"typescript": "^5.6.2"
|