@agent-smith/cli 0.0.27 → 0.0.28
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/modes.js +6 -6
- package/dist/cmd/lib/execute_job.js +9 -17
- package/dist/cmd/lib/execute_task.js +5 -43
- package/dist/cmd/lib/utils.d.ts +3 -1
- package/dist/cmd/lib/utils.js +51 -2
- package/package.json +14 -14
|
@@ -18,7 +18,7 @@ const modes = {
|
|
|
18
18
|
},
|
|
19
19
|
description: "use chat mode for tasks",
|
|
20
20
|
},
|
|
21
|
-
"
|
|
21
|
+
"--if": {
|
|
22
22
|
cmd: async () => {
|
|
23
23
|
inputMode.value = "promptfile";
|
|
24
24
|
if (runMode.value == "cli") {
|
|
@@ -27,7 +27,7 @@ const modes = {
|
|
|
27
27
|
},
|
|
28
28
|
description: "use promptfile input mode",
|
|
29
29
|
},
|
|
30
|
-
"
|
|
30
|
+
"--ic": {
|
|
31
31
|
cmd: async () => {
|
|
32
32
|
inputMode.value = "clipboard";
|
|
33
33
|
if (runMode.value == "cli") {
|
|
@@ -36,7 +36,7 @@ const modes = {
|
|
|
36
36
|
},
|
|
37
37
|
description: "use clipboard input mode"
|
|
38
38
|
},
|
|
39
|
-
"
|
|
39
|
+
"--im": {
|
|
40
40
|
cmd: async () => {
|
|
41
41
|
inputMode.value = "manual";
|
|
42
42
|
if (runMode.value == "cli") {
|
|
@@ -45,7 +45,7 @@ const modes = {
|
|
|
45
45
|
},
|
|
46
46
|
description: "use manual input mode (default)"
|
|
47
47
|
},
|
|
48
|
-
"
|
|
48
|
+
"--oc": {
|
|
49
49
|
cmd: async () => {
|
|
50
50
|
outputMode.value = "clipboard";
|
|
51
51
|
if (runMode.value == "cli") {
|
|
@@ -54,7 +54,7 @@ const modes = {
|
|
|
54
54
|
},
|
|
55
55
|
description: "use clipboard output mode"
|
|
56
56
|
},
|
|
57
|
-
"
|
|
57
|
+
"--omd": {
|
|
58
58
|
cmd: async () => {
|
|
59
59
|
formatMode.value = "markdown";
|
|
60
60
|
if (runMode.value == "cli") {
|
|
@@ -63,7 +63,7 @@ const modes = {
|
|
|
63
63
|
},
|
|
64
64
|
description: "use markdown output"
|
|
65
65
|
},
|
|
66
|
-
"
|
|
66
|
+
"--otxt": {
|
|
67
67
|
cmd: async () => {
|
|
68
68
|
formatMode.value = "text";
|
|
69
69
|
if (runMode.value == "cli") {
|
|
@@ -4,7 +4,7 @@ import { useAgentJob } from "@agent-smith/jobs";
|
|
|
4
4
|
import { brain, marked, taskBuilder } from '../../agent.js';
|
|
5
5
|
import { getFeatureSpec } from '../../state/features.js';
|
|
6
6
|
import { formatMode, isDebug } from '../../state/state.js';
|
|
7
|
-
import { initTaskVars, readTask } from './utils.js';
|
|
7
|
+
import { initTaskConf, initTaskVars, readTask } from './utils.js';
|
|
8
8
|
async function executeJobCmd(name, args = [], options = {}) {
|
|
9
9
|
const { job, found } = await _dispatchReadJob(name);
|
|
10
10
|
if (!found) {
|
|
@@ -27,26 +27,15 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
27
27
|
throw new Error(`Task ${name}, ${path} not found`);
|
|
28
28
|
}
|
|
29
29
|
const taskSpec = taskBuilder.readFromYaml(tres.ymlTask);
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
let conf = {};
|
|
33
|
-
let vars = {};
|
|
34
|
-
const tv = initTaskVars(args, taskSpec?.inferParams ? taskSpec.inferParams : {});
|
|
35
|
-
conf = tv.conf;
|
|
36
|
-
vars = i == 0 ? tv.vars : params;
|
|
30
|
+
let { conf, vars } = initTaskVars(args, taskSpec?.inferParams ? taskSpec.inferParams : {});
|
|
31
|
+
conf = initTaskConf(conf, taskSpec);
|
|
37
32
|
if (isDebug.value) {
|
|
38
33
|
console.log("Task conf:", conf);
|
|
39
34
|
console.log("Task vars:", vars);
|
|
40
35
|
}
|
|
41
|
-
|
|
42
|
-
m = conf.model;
|
|
43
|
-
}
|
|
44
|
-
if (conf?.template) {
|
|
45
|
-
t = conf.template;
|
|
46
|
-
}
|
|
47
|
-
const ex = brain.getOrCreateExpertForModel(m, t);
|
|
36
|
+
const ex = brain.getOrCreateExpertForModel(conf.model.name, conf.model.template);
|
|
48
37
|
if (!ex) {
|
|
49
|
-
throw new Error("No expert found for model " +
|
|
38
|
+
throw new Error("No expert found for model " + conf.model.name);
|
|
50
39
|
}
|
|
51
40
|
ex.checkStatus();
|
|
52
41
|
ex.backend.setOnToken((t) => {
|
|
@@ -54,7 +43,10 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
54
43
|
});
|
|
55
44
|
conf["expert"] = ex;
|
|
56
45
|
try {
|
|
57
|
-
|
|
46
|
+
if (isDebug) {
|
|
47
|
+
console.log("Running", name);
|
|
48
|
+
}
|
|
49
|
+
res = await job.runTask(name, { ...params, ...vars }, conf);
|
|
58
50
|
if ("text" in res) {
|
|
59
51
|
if (formatMode.value == "markdown") {
|
|
60
52
|
console.log("\n\n------------------\n");
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { brain, initAgent, taskBuilder } from "../../agent.js";
|
|
2
2
|
import { getFeatureSpec } from "../../state/features.js";
|
|
3
3
|
import { isChatMode, isDebug } from "../../state/state.js";
|
|
4
|
-
import { initTaskVars, parseInputOptions, readTask } from "./utils.js";
|
|
5
|
-
import { useTemplateForModel } from "@agent-smith/tfm";
|
|
6
|
-
const tfm = useTemplateForModel();
|
|
4
|
+
import { initTaskConf, initTaskVars, parseInputOptions, readTask } from "./utils.js";
|
|
7
5
|
async function executeTaskCmd(args = [], options = {}) {
|
|
8
6
|
await initAgent();
|
|
9
7
|
if (isDebug.value) {
|
|
@@ -32,51 +30,15 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
32
30
|
}
|
|
33
31
|
const taskSpec = taskBuilder.readFromYaml(res.ymlTask);
|
|
34
32
|
const task = taskBuilder.fromYaml(res.ymlTask);
|
|
35
|
-
|
|
33
|
+
let { conf, vars } = initTaskVars(args, taskSpec?.inferParams ? taskSpec.inferParams : {});
|
|
34
|
+
conf = initTaskConf(conf, taskSpec);
|
|
36
35
|
if (isDebug.value) {
|
|
37
36
|
console.log("Task conf:", conf);
|
|
38
37
|
console.log("Task vars:", vars);
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
let t = taskSpec.model.template;
|
|
42
|
-
let c = taskSpec.model.ctx;
|
|
43
|
-
if (conf?.model) {
|
|
44
|
-
m = conf.model;
|
|
45
|
-
if (conf?.template) {
|
|
46
|
-
t = conf.template;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
const gt = tfm.guess(m);
|
|
50
|
-
if (gt == "none") {
|
|
51
|
-
throw new Error(`Unable to guess the template for ${conf.model}: please provide a template name"`);
|
|
52
|
-
}
|
|
53
|
-
t = gt;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
if (conf?.size) {
|
|
58
|
-
if (!taskSpec?.models) {
|
|
59
|
-
throw new Error(`Model ${conf.size} not found in task`);
|
|
60
|
-
}
|
|
61
|
-
if (!Object.keys(taskSpec.models).includes(conf.size)) {
|
|
62
|
-
throw new Error(`Model ${conf.size} not found in task`);
|
|
63
|
-
}
|
|
64
|
-
m = taskSpec.models[conf.size].name;
|
|
65
|
-
t = taskSpec.models[conf.size].template;
|
|
66
|
-
c = taskSpec.models[conf.size].ctx;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
conf.model = {
|
|
70
|
-
name: m,
|
|
71
|
-
template: t,
|
|
72
|
-
ctx: c,
|
|
73
|
-
};
|
|
74
|
-
if (isDebug.value) {
|
|
75
|
-
console.log("Model:", conf.model);
|
|
76
|
-
}
|
|
77
|
-
const ex = brain.getOrCreateExpertForModel(m, t);
|
|
39
|
+
const ex = brain.getOrCreateExpertForModel(conf.model.name, conf.model.template);
|
|
78
40
|
if (!ex) {
|
|
79
|
-
throw new Error("No expert found for model " +
|
|
41
|
+
throw new Error("No expert found for model " + conf.model.name);
|
|
80
42
|
}
|
|
81
43
|
ex.checkStatus();
|
|
82
44
|
let i = 0;
|
package/dist/cmd/lib/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LmTask } from "@agent-smith/lmtask/dist/interfaces.js";
|
|
1
2
|
declare function setOptions(args: Array<string> | undefined, options: Record<string, any>): Promise<Array<string>>;
|
|
2
3
|
declare function readPromptFile(): string;
|
|
3
4
|
declare function processOutput(res: any): Promise<void>;
|
|
@@ -6,9 +7,10 @@ declare function readTask(taskpath: string): {
|
|
|
6
7
|
ymlTask: string;
|
|
7
8
|
};
|
|
8
9
|
declare function readTasksDir(dir: string): Array<string>;
|
|
10
|
+
declare function initTaskConf(conf: Record<string, any>, taskSpec: LmTask): Record<string, any>;
|
|
9
11
|
declare function initTaskVars(args: Array<any>, inferParams: Record<string, any>): {
|
|
10
12
|
conf: Record<string, any>;
|
|
11
13
|
vars: Record<string, any>;
|
|
12
14
|
};
|
|
13
15
|
declare function parseInputOptions(options: any): Promise<string | null>;
|
|
14
|
-
export { readPromptFile, processOutput, setOptions, readTask, readTasksDir, initTaskVars, parseInputOptions, };
|
|
16
|
+
export { readPromptFile, processOutput, setOptions, readTask, readTasksDir, initTaskVars, initTaskConf, parseInputOptions, };
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -4,9 +4,17 @@ import { outputMode, promptfile } from "../../state/state.js";
|
|
|
4
4
|
import { inputMode } from "../../state/state.js";
|
|
5
5
|
import { readClipboard, writeToClipboard } from "../sys/clipboard.js";
|
|
6
6
|
import { modes } from "../clicmds/modes.js";
|
|
7
|
+
import { useTemplateForModel } from "@agent-smith/tfm";
|
|
8
|
+
const tfm = useTemplateForModel();
|
|
7
9
|
async function setOptions(args = [], options) {
|
|
8
10
|
for (const k of Object.keys(options)) {
|
|
9
|
-
|
|
11
|
+
let opt;
|
|
12
|
+
if (k.length == 1) {
|
|
13
|
+
opt = modes["-" + k.toLowerCase()];
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
opt = modes["--" + k.toLowerCase()];
|
|
17
|
+
}
|
|
10
18
|
await opt.cmd([], undefined);
|
|
11
19
|
}
|
|
12
20
|
if (inputMode.value == "promptfile") {
|
|
@@ -73,6 +81,47 @@ function readTasksDir(dir) {
|
|
|
73
81
|
});
|
|
74
82
|
return tasks;
|
|
75
83
|
}
|
|
84
|
+
function initTaskConf(conf, taskSpec) {
|
|
85
|
+
const _conf = conf;
|
|
86
|
+
let m = taskSpec.model.name;
|
|
87
|
+
let t = taskSpec.model.template;
|
|
88
|
+
let c = taskSpec.model.ctx;
|
|
89
|
+
if (conf?.model) {
|
|
90
|
+
m = conf.model;
|
|
91
|
+
if (conf?.template) {
|
|
92
|
+
t = conf.template;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const gt = tfm.guess(m);
|
|
96
|
+
if (gt == "none") {
|
|
97
|
+
throw new Error(`Unable to guess the template for ${m}: please provide a template name"`);
|
|
98
|
+
}
|
|
99
|
+
t = gt;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (conf?.size) {
|
|
104
|
+
if (!taskSpec?.models) {
|
|
105
|
+
throw new Error(`Model ${conf.size} not found in task`);
|
|
106
|
+
}
|
|
107
|
+
if (!Object.keys(taskSpec.models).includes(conf.size)) {
|
|
108
|
+
throw new Error(`Model ${conf.size} not found in task`);
|
|
109
|
+
}
|
|
110
|
+
m = taskSpec.models[conf.size].name;
|
|
111
|
+
t = taskSpec.models[conf.size].template;
|
|
112
|
+
c = taskSpec.models[conf.size].ctx;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
_conf.model = {
|
|
116
|
+
name: m,
|
|
117
|
+
template: t,
|
|
118
|
+
ctx: c,
|
|
119
|
+
};
|
|
120
|
+
if (_conf?.template) {
|
|
121
|
+
delete conf.template;
|
|
122
|
+
}
|
|
123
|
+
return _conf;
|
|
124
|
+
}
|
|
76
125
|
function initTaskVars(args, inferParams) {
|
|
77
126
|
const conf = { inferParams: inferParams };
|
|
78
127
|
const vars = {};
|
|
@@ -117,4 +166,4 @@ async function parseInputOptions(options) {
|
|
|
117
166
|
}
|
|
118
167
|
return out;
|
|
119
168
|
}
|
|
120
|
-
export { readPromptFile, processOutput, setOptions, readTask, readTasksDir, initTaskVars, parseInputOptions, };
|
|
169
|
+
export { readPromptFile, processOutput, setOptions, readTask, readTasksDir, initTaskVars, initTaskConf, parseInputOptions, };
|
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.28",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -12,33 +12,33 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@agent-smith/brain": "^0.0.33",
|
|
14
14
|
"@agent-smith/jobs": "^0.0.11",
|
|
15
|
-
"@agent-smith/lmtask": "^0.0.
|
|
15
|
+
"@agent-smith/lmtask": "^0.0.26",
|
|
16
16
|
"@agent-smith/tfm": "^0.1.1",
|
|
17
|
-
"@inquirer/prompts": "^7.
|
|
18
|
-
"@inquirer/select": "^4.0.
|
|
17
|
+
"@inquirer/prompts": "^7.2.3",
|
|
18
|
+
"@inquirer/select": "^4.0.6",
|
|
19
19
|
"@vue/reactivity": "^3.5.13",
|
|
20
|
-
"better-sqlite3": "^11.
|
|
20
|
+
"better-sqlite3": "^11.8.1",
|
|
21
21
|
"clipboardy": "^4.0.0",
|
|
22
|
-
"commander": "^
|
|
22
|
+
"commander": "^13.1.0",
|
|
23
23
|
"marked-terminal": "^7.2.1",
|
|
24
|
-
"modprompt": "^0.9.
|
|
24
|
+
"modprompt": "^0.9.4",
|
|
25
25
|
"python-shell": "^5.0.0",
|
|
26
|
-
"yaml": "^2.
|
|
26
|
+
"yaml": "^2.7.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@agent-smith/tmem-jobs": "^0.0.4",
|
|
30
|
-
"@commander-js/extra-typings": "^
|
|
30
|
+
"@commander-js/extra-typings": "^13.1.0",
|
|
31
31
|
"@locallm/types": "^0.1.5",
|
|
32
|
-
"@rollup/plugin-node-resolve": "^
|
|
33
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
32
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
33
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
34
34
|
"@types/better-sqlite3": "^7.6.12",
|
|
35
35
|
"@types/marked-terminal": "^6.1.1",
|
|
36
|
-
"@types/node": "^22.
|
|
36
|
+
"@types/node": "^22.10.10",
|
|
37
37
|
"restmix": "^0.5.0",
|
|
38
|
-
"rollup": "^4.
|
|
38
|
+
"rollup": "^4.32.0",
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
40
|
"tslib": "2.8.1",
|
|
41
|
-
"typescript": "^5.
|
|
41
|
+
"typescript": "^5.7.3"
|
|
42
42
|
},
|
|
43
43
|
"type": "module",
|
|
44
44
|
"preferGlobal": true,
|