@agent-smith/cli 0.0.34 → 0.0.36
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.
|
@@ -26,7 +26,12 @@ function pythonAction(path) {
|
|
|
26
26
|
title: "",
|
|
27
27
|
run: async (args) => {
|
|
28
28
|
const out = await runPyScript(pyShell, "python3", path, args);
|
|
29
|
-
|
|
29
|
+
const txt = out.join("\n");
|
|
30
|
+
let data = txt;
|
|
31
|
+
if (txt.startsWith("{") || txt.startsWith("[")) {
|
|
32
|
+
data = JSON.parse(data);
|
|
33
|
+
}
|
|
34
|
+
return { data: data, error: "", ok: true };
|
|
30
35
|
}
|
|
31
36
|
});
|
|
32
37
|
return action;
|
|
@@ -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, isVerbose } from '../../state/state.js';
|
|
7
|
-
import { createJsAction, initTaskConf, initTaskParams, initTaskVars, parseInputOptions, readTask } from './utils.js';
|
|
7
|
+
import { createJsAction, initActionVars, initTaskConf, initTaskParams, initTaskVars, parseInputOptions, readTask } from './utils.js';
|
|
8
8
|
import { pythonAction, systemAction } from './execute_action.js';
|
|
9
9
|
async function executeJobCmd(name, args = [], options = {}) {
|
|
10
10
|
const { job, found } = await _dispatchReadJob(name);
|
|
@@ -54,7 +54,7 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
54
54
|
params.prompt = params.text;
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
|
-
throw new Error(`No prompt provided for task ${name}.\Params: ${params}`);
|
|
57
|
+
throw new Error(`No prompt provided for task ${name}.\Params: ${JSON.stringify(params, null, 2)}`);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
const vs = initTaskParams(params, taskSpec?.inferParams ? taskSpec.inferParams : {});
|
|
@@ -87,6 +87,7 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
87
87
|
ex.backend.setOnToken((t) => {
|
|
88
88
|
process.stdout.write(t);
|
|
89
89
|
});
|
|
90
|
+
brain.setDefaultExpert(ex);
|
|
90
91
|
conf["expert"] = ex;
|
|
91
92
|
try {
|
|
92
93
|
if (isDebug.value || isVerbose.value) {
|
|
@@ -96,6 +97,7 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
96
97
|
const invars = { ...params, ...vars };
|
|
97
98
|
try {
|
|
98
99
|
res = await job.runTask(name, invars, conf);
|
|
100
|
+
console.log("");
|
|
99
101
|
}
|
|
100
102
|
catch (e) {
|
|
101
103
|
throw new Error(`Error running task ${name}: ${e}`);
|
|
@@ -139,6 +141,11 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
139
141
|
else {
|
|
140
142
|
try {
|
|
141
143
|
const _p = i == 0 ? args : params;
|
|
144
|
+
let nextParams = {};
|
|
145
|
+
if (i == 0) {
|
|
146
|
+
const { vars } = initActionVars(args);
|
|
147
|
+
nextParams = vars;
|
|
148
|
+
}
|
|
142
149
|
if (isDebug.value) {
|
|
143
150
|
console.log(i + 1, "Running action", name, _p);
|
|
144
151
|
}
|
|
@@ -160,7 +167,7 @@ async function executeJobCmd(name, args = [], options = {}) {
|
|
|
160
167
|
else {
|
|
161
168
|
params = res.data;
|
|
162
169
|
}
|
|
163
|
-
params = res.data;
|
|
170
|
+
params = { ...res.data, ...nextParams };
|
|
164
171
|
}
|
|
165
172
|
catch (err) {
|
|
166
173
|
return { error: `Error executing (${task.type}) task ${name}: ${err}` };
|
package/dist/cmd/lib/utils.d.ts
CHANGED
|
@@ -14,10 +14,11 @@ declare function initTaskParams(params: Record<string, any>, inferParams: Record
|
|
|
14
14
|
conf: Record<string, any>;
|
|
15
15
|
vars: Record<string, any>;
|
|
16
16
|
};
|
|
17
|
+
declare function initActionVars(args: Array<any>): Record<string, any>;
|
|
17
18
|
declare function initTaskVars(args: Array<any>, inferParams: Record<string, any>): {
|
|
18
19
|
conf: Record<string, any>;
|
|
19
20
|
vars: Record<string, any>;
|
|
20
21
|
};
|
|
21
22
|
declare function parseInputOptions(options: any): Promise<string | null>;
|
|
22
23
|
declare function createJsAction(action: CallableFunction): AgentTask<FeatureType>;
|
|
23
|
-
export { createJsAction, initTaskConf, initTaskParams, initTaskVars, parseInputOptions, processOutput, readPromptFile, readTask, readTasksDir, setOptions };
|
|
24
|
+
export { createJsAction, initTaskConf, initTaskParams, initTaskVars, initActionVars, parseInputOptions, processOutput, readPromptFile, readTask, readTasksDir, setOptions };
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -135,9 +135,56 @@ function initTaskParams(params, inferParams) {
|
|
|
135
135
|
conf.inferParams.images = params.images;
|
|
136
136
|
delete params.images;
|
|
137
137
|
}
|
|
138
|
+
if (params?.size) {
|
|
139
|
+
conf.size = params.size;
|
|
140
|
+
delete params.size;
|
|
141
|
+
}
|
|
142
|
+
if (params?.model) {
|
|
143
|
+
conf.model = params.model;
|
|
144
|
+
delete params.model;
|
|
145
|
+
}
|
|
146
|
+
if (params?.template) {
|
|
147
|
+
conf.template = params.template;
|
|
148
|
+
delete params.template;
|
|
149
|
+
}
|
|
138
150
|
const res = { conf: conf, vars: params };
|
|
139
151
|
return res;
|
|
140
152
|
}
|
|
153
|
+
function initActionVars(args) {
|
|
154
|
+
const vars = {};
|
|
155
|
+
args.forEach((a) => {
|
|
156
|
+
if (a.includes("=")) {
|
|
157
|
+
const t = a.split("=");
|
|
158
|
+
const k = t[0];
|
|
159
|
+
const v = t[1];
|
|
160
|
+
switch (k) {
|
|
161
|
+
case "m":
|
|
162
|
+
if (v.includes("/")) {
|
|
163
|
+
const _s = v.split("/");
|
|
164
|
+
vars.model = _s[0];
|
|
165
|
+
vars.template = _s[1];
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
vars.model = v;
|
|
169
|
+
}
|
|
170
|
+
break;
|
|
171
|
+
case "ip":
|
|
172
|
+
v.split(",").forEach((p) => {
|
|
173
|
+
const s = p.split(":");
|
|
174
|
+
vars["inferParams"][s[0]] = parseFloat(s[1]);
|
|
175
|
+
});
|
|
176
|
+
break;
|
|
177
|
+
case "s":
|
|
178
|
+
vars.size = v;
|
|
179
|
+
break;
|
|
180
|
+
default:
|
|
181
|
+
vars[k] = v;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
return { vars };
|
|
187
|
+
}
|
|
141
188
|
function initTaskVars(args, inferParams) {
|
|
142
189
|
const conf = { inferParams: inferParams };
|
|
143
190
|
const vars = {};
|
|
@@ -195,4 +242,4 @@ function createJsAction(action) {
|
|
|
195
242
|
});
|
|
196
243
|
return task;
|
|
197
244
|
}
|
|
198
|
-
export { createJsAction, initTaskConf, initTaskParams, initTaskVars, parseInputOptions, processOutput, readPromptFile, readTask, readTasksDir, setOptions };
|
|
245
|
+
export { createJsAction, initTaskConf, initTaskParams, initTaskVars, initActionVars, parseInputOptions, processOutput, readPromptFile, readTask, readTasksDir, setOptions };
|
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.36",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc --noCheck",
|
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
"watch": "tsc --noCheck -p . -w"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-smith/brain": "^0.0.
|
|
13
|
+
"@agent-smith/brain": "^0.0.38",
|
|
14
14
|
"@agent-smith/jobs": "^0.0.12",
|
|
15
|
-
"@agent-smith/lmtask": "^0.0.
|
|
15
|
+
"@agent-smith/lmtask": "^0.0.30",
|
|
16
16
|
"@agent-smith/tfm": "^0.1.1",
|
|
17
|
-
"@inquirer/prompts": "^7.3.
|
|
18
|
-
"@inquirer/select": "^4.0.
|
|
17
|
+
"@inquirer/prompts": "^7.3.3",
|
|
18
|
+
"@inquirer/select": "^4.0.10",
|
|
19
19
|
"@vue/reactivity": "^3.5.13",
|
|
20
20
|
"better-sqlite3": "^11.8.1",
|
|
21
21
|
"clipboardy": "^4.0.0",
|
|
22
22
|
"commander": "^13.1.0",
|
|
23
23
|
"marked-terminal": "^7.3.0",
|
|
24
|
-
"modprompt": "^0.10.
|
|
24
|
+
"modprompt": "^0.10.3",
|
|
25
25
|
"python-shell": "^5.0.0",
|
|
26
26
|
"yaml": "^2.7.0"
|
|
27
27
|
},
|
|
@@ -33,9 +33,9 @@
|
|
|
33
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.13.
|
|
36
|
+
"@types/node": "^22.13.10",
|
|
37
37
|
"restmix": "^0.5.0",
|
|
38
|
-
"rollup": "^4.
|
|
38
|
+
"rollup": "^4.35.0",
|
|
39
39
|
"ts-node": "^10.9.2",
|
|
40
40
|
"tslib": "2.8.1",
|
|
41
41
|
"typescript": "^5.8.2"
|