@agent-smith/cli 0.0.92 → 0.0.94
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/lib/tasks/cmd.js +25 -2
- package/dist/cmd/lib/tasks/conf.js +14 -12
- package/dist/cmd/lib/tasks/read.js +1 -1
- package/dist/state/backends.d.ts +1 -1
- package/dist/state/backends.js +21 -13
- package/package.json +9 -9
|
@@ -9,7 +9,7 @@ import { usePerfTimer } from "../../../main.js";
|
|
|
9
9
|
import { isChatMode, runMode, agent } from "../../../state/state.js";
|
|
10
10
|
import { program } from "../../cmds.js";
|
|
11
11
|
import { parseCommandArgs } from "../options_parsers.js";
|
|
12
|
-
import { runtimeDataError, runtimeWarning } from "../user_msgs.js";
|
|
12
|
+
import { runtimeDataError, runtimeError, runtimeWarning } from "../user_msgs.js";
|
|
13
13
|
import { formatStats, processOutput, readPromptFile } from "../utils.js";
|
|
14
14
|
import { readTask } from "./read.js";
|
|
15
15
|
async function executeTask(name, payload, options, quiet) {
|
|
@@ -141,7 +141,30 @@ async function executeTask(name, payload, options, quiet) {
|
|
|
141
141
|
...conf,
|
|
142
142
|
};
|
|
143
143
|
let out;
|
|
144
|
-
|
|
144
|
+
try {
|
|
145
|
+
out = await task.run({ prompt: payload.prompt, ...vars }, tconf);
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
const errMsg = `${e}`;
|
|
149
|
+
if (errMsg.includes("502 Bad Gateway")) {
|
|
150
|
+
runtimeError("The server answered with a 502 Bad Gateway error. It might be down or misconfigured. Check your inference server.");
|
|
151
|
+
if (options?.debug) {
|
|
152
|
+
throw new Error(errMsg);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
else if (errMsg.includes("404 Not Found")) {
|
|
157
|
+
runtimeError("The server answered with a 404 Not Found error. That usually mean that the model you are requesting does not exist on the server.");
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
else if (errMsg.includes("fetch failed")) {
|
|
161
|
+
runtimeError("The server is not responding. Check if your inference backend is running.");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
throw new Error(errMsg);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
145
168
|
if (!out.answer.text.endsWith("\n")) {
|
|
146
169
|
console.log();
|
|
147
170
|
}
|
|
@@ -17,22 +17,24 @@ function configureTaskModel(itConf, taskSpec) {
|
|
|
17
17
|
model.template = itConf.templateName;
|
|
18
18
|
foundTemplate = true;
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
21
|
-
if (itConf?.model?.name
|
|
22
|
-
|
|
20
|
+
if (!foundTemplate) {
|
|
21
|
+
if (itConf?.model?.name) {
|
|
22
|
+
if (itConf?.model?.name != taskSpec.model.name) {
|
|
23
|
+
const gt = guessTemplate(itConf.model.name);
|
|
24
|
+
model.template = gt;
|
|
25
|
+
foundTemplate = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else if (taskSpec?.model?.template) {
|
|
29
|
+
model.template = taskSpec.model.template;
|
|
30
|
+
foundTemplate = true;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const gt = guessTemplate(taskSpec.model.name);
|
|
23
34
|
model.template = gt;
|
|
24
35
|
foundTemplate = true;
|
|
25
36
|
}
|
|
26
37
|
}
|
|
27
|
-
else if (taskSpec?.model?.template) {
|
|
28
|
-
model.template = taskSpec.model.template;
|
|
29
|
-
foundTemplate = true;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
const gt = guessTemplate(taskSpec.model.name);
|
|
33
|
-
model.template = gt;
|
|
34
|
-
foundTemplate = true;
|
|
35
|
-
}
|
|
36
38
|
if (itConf?.model?.name) {
|
|
37
39
|
if (taskSpec?.models && Object.keys(taskSpec.models).includes(itConf.model.name)) {
|
|
38
40
|
for (const [k, v] of Object.entries(taskSpec.models)) {
|
|
@@ -18,7 +18,7 @@ async function readTask(name, payload, options, agent) {
|
|
|
18
18
|
const opts = payload?.inferParams ? { ...options, ...payload.inferParams } : options;
|
|
19
19
|
const conf = parseTaskConfigOptions(opts);
|
|
20
20
|
if (options?.debug) {
|
|
21
|
-
console.log("conf:", conf);
|
|
21
|
+
console.log("Task conf:", conf);
|
|
22
22
|
conf.debug = true;
|
|
23
23
|
}
|
|
24
24
|
conf.inferParams = mergeInferParams(conf.inferParams, taskFileSpec.inferParams ?? {});
|
package/dist/state/backends.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Lm } from "@locallm/api";
|
|
2
2
|
declare const backend: import("@vue/reactivity").Ref<Lm | undefined, Lm | undefined>;
|
|
3
3
|
declare const backends: Record<string, Lm>;
|
|
4
|
-
declare function initBackends(
|
|
4
|
+
declare function initBackends(): Promise<void>;
|
|
5
5
|
declare function setBackend(name: string, isVerbose?: boolean): Promise<void>;
|
|
6
6
|
declare function listBackends(): Promise<void>;
|
|
7
7
|
export { backend, backends, initBackends, listBackends, setBackend };
|
package/dist/state/backends.js
CHANGED
|
@@ -7,30 +7,38 @@ import { runtimeDataError } from "../utils/user_msgs.js";
|
|
|
7
7
|
const backend = ref();
|
|
8
8
|
const backends = reactive({});
|
|
9
9
|
const isBackendUp = ref(false);
|
|
10
|
-
async function initBackends(
|
|
10
|
+
async function initBackends() {
|
|
11
11
|
const rmb = readBackends();
|
|
12
12
|
let defaultBackendName = null;
|
|
13
13
|
for (const bk of Object.values(rmb)) {
|
|
14
|
+
let name = bk.name;
|
|
15
|
+
let apiKey = "";
|
|
16
|
+
if (bk?.apiKey) {
|
|
17
|
+
if (bk.apiKey == "$OPENROUTER_API_KEY") {
|
|
18
|
+
const apk = process.env.OPENROUTER_API_KEY;
|
|
19
|
+
if (apk === undefined) {
|
|
20
|
+
runtimeDataError("No $OPENROUTER_API_KEY environment variable found, required for ", name);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
apiKey = apk;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
apiKey = bk.apiKey;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
;
|
|
14
30
|
const lm = new Lm({
|
|
15
31
|
providerType: bk.type,
|
|
16
32
|
serverUrl: bk.url,
|
|
33
|
+
apiKey: apiKey.length > 0 ? apiKey : undefined,
|
|
17
34
|
});
|
|
18
|
-
|
|
19
|
-
if (bk?.apiKey) {
|
|
20
|
-
lm.apiKey = bk.apiKey;
|
|
21
|
-
}
|
|
22
|
-
;
|
|
23
|
-
backends[bk.name] = lm;
|
|
35
|
+
backends[name] = lm;
|
|
24
36
|
if (bk.isDefault) {
|
|
25
37
|
defaultBackendName = bk.name;
|
|
26
38
|
}
|
|
27
39
|
}
|
|
28
40
|
if (defaultBackendName !== null) {
|
|
29
41
|
backend.value = backends[defaultBackendName];
|
|
30
|
-
isBackendUp.value = await probeBackend(backend.value, isVerbose);
|
|
31
|
-
if (isBackendUp.value && backend.value.providerType == "ollama") {
|
|
32
|
-
await backend.value.modelsInfo();
|
|
33
|
-
}
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
async function setBackend(name, isVerbose = false) {
|
|
@@ -55,8 +63,8 @@ const probeBackend = async (lm, isVerbose) => {
|
|
|
55
63
|
switch (lm.providerType) {
|
|
56
64
|
case "llamacpp":
|
|
57
65
|
try {
|
|
58
|
-
const info = await lm.info();
|
|
59
66
|
if (isVerbose) {
|
|
67
|
+
const info = await lm.modelInfo();
|
|
60
68
|
console.log(`Provider ${lm.name} up`, info);
|
|
61
69
|
}
|
|
62
70
|
isUp = true;
|
|
@@ -69,9 +77,9 @@ const probeBackend = async (lm, isVerbose) => {
|
|
|
69
77
|
break;
|
|
70
78
|
case "koboldcpp":
|
|
71
79
|
try {
|
|
72
|
-
const info = await lm.info();
|
|
73
80
|
if (lm.model.name.length > 0) {
|
|
74
81
|
if (isVerbose) {
|
|
82
|
+
const info = await lm.modelInfo();
|
|
75
83
|
console.log(`Provider ${lm.name} up`, info);
|
|
76
84
|
}
|
|
77
85
|
isUp = true;
|
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.94",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
"watch": "tsc --noCheck -p . -w"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-smith/agent": "^0.1.
|
|
14
|
-
"@agent-smith/task": "^0.1.
|
|
13
|
+
"@agent-smith/agent": "^0.1.4",
|
|
14
|
+
"@agent-smith/task": "^0.1.5",
|
|
15
15
|
"@agent-smith/tfm": "^0.2.0",
|
|
16
16
|
"@inquirer/prompts": "^7.10.1",
|
|
17
17
|
"@intrinsicai/gbnfgen": "0.12.0",
|
|
18
|
-
"@locallm/api": "^0.
|
|
19
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
20
|
-
"@vue/reactivity": "^3.5.
|
|
18
|
+
"@locallm/api": "^0.7.0",
|
|
19
|
+
"@modelcontextprotocol/sdk": "^1.23.0",
|
|
20
|
+
"@vue/reactivity": "^3.5.25",
|
|
21
21
|
"ansi-colors": "^4.1.3",
|
|
22
|
-
"better-sqlite3": "^12.4.
|
|
22
|
+
"better-sqlite3": "^12.4.6",
|
|
23
23
|
"clipboardy": "^5.0.1",
|
|
24
24
|
"commander": "^14.0.2",
|
|
25
25
|
"marked-terminal": "^7.3.0",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"@agent-smith/tmem-jobs": "^0.0.4",
|
|
33
33
|
"@cfworker/json-schema": "^4.1.1",
|
|
34
34
|
"@commander-js/extra-typings": "^14.0.0",
|
|
35
|
-
"@locallm/types": "^0.
|
|
35
|
+
"@locallm/types": "^0.6.2",
|
|
36
36
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
37
37
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
38
38
|
"@types/better-sqlite3": "^7.6.13",
|
|
39
39
|
"@types/marked-terminal": "^6.1.1",
|
|
40
40
|
"@types/node": "^24.10.1",
|
|
41
|
-
"restmix": "^0.
|
|
41
|
+
"restmix": "^0.6.1",
|
|
42
42
|
"rollup": "^4.53.3",
|
|
43
43
|
"ts-node": "^10.9.2",
|
|
44
44
|
"tslib": "2.8.1",
|