@agent-smith/cli 0.0.59 → 0.0.61
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 +4 -3
- package/dist/cmd/lib/actions/cmd.js +15 -6
- package/dist/cmd/lib/tasks/cmd.js +78 -20
- package/dist/cmd/lib/tasks/conf.d.ts +2 -1
- package/dist/cmd/lib/tasks/conf.js +11 -1
- package/dist/cmd/lib/tasks/utils.js +1 -0
- package/dist/cmd/lib/utils.js +10 -3
- package/dist/db/read.js +1 -2
- package/dist/interfaces.d.ts +3 -1
- package/dist/main.d.ts +4 -3
- package/dist/main.js +4 -3
- package/dist/state/state.d.ts +6 -4
- package/dist/state/state.js +9 -4
- package/dist/{primitives → utils}/args.js +5 -1
- package/dist/utils/text.d.ts +6 -0
- package/dist/utils/text.js +37 -0
- package/package.json +8 -7
- /package/dist/{primitives → utils}/args.d.ts +0 -0
- /package/dist/{primitives → utils}/perf.d.ts +0 -0
- /package/dist/{primitives → utils}/perf.js +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { formatMode, inputMode, isChatMode,
|
|
1
|
+
import { formatMode, inputMode, isChatMode, isShowTokens, isVerbose, outputMode, runMode, setVerbosity } from "../../state/state.js";
|
|
2
2
|
const modes = {
|
|
3
3
|
"-d": {
|
|
4
4
|
cmd: async () => {
|
|
5
|
-
|
|
5
|
+
setVerbosity("debug");
|
|
6
6
|
if (runMode.value == "cli") {
|
|
7
7
|
console.log("Debug mode is on");
|
|
8
8
|
}
|
|
@@ -20,7 +20,8 @@ const modes = {
|
|
|
20
20
|
},
|
|
21
21
|
"-v": {
|
|
22
22
|
cmd: async () => {
|
|
23
|
-
|
|
23
|
+
setVerbosity("verbose");
|
|
24
|
+
;
|
|
24
25
|
if (runMode.value == "cli") {
|
|
25
26
|
console.log("Verbose mode is", isVerbose.value ? "on" : "off");
|
|
26
27
|
}
|
|
@@ -10,12 +10,24 @@ function systemAction(path) {
|
|
|
10
10
|
id: "system_action",
|
|
11
11
|
title: "",
|
|
12
12
|
run: async (args) => {
|
|
13
|
+
let runArgs = new Array();
|
|
14
|
+
if (!Array.isArray(args)) {
|
|
15
|
+
try {
|
|
16
|
+
runArgs = Object.values(args);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
throw new Error(`wrong system action args: ${e}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
runArgs = args;
|
|
24
|
+
}
|
|
13
25
|
const actionSpec = readYmlFile(path);
|
|
14
26
|
if (!actionSpec.data?.args) {
|
|
15
27
|
actionSpec.data.args = [];
|
|
16
28
|
}
|
|
17
|
-
const out = await execute(actionSpec.data.cmd, [...actionSpec.data.args, ...
|
|
18
|
-
return
|
|
29
|
+
const out = await execute(actionSpec.data.cmd, [...actionSpec.data.args, ...runArgs]);
|
|
30
|
+
return out.trim();
|
|
19
31
|
}
|
|
20
32
|
});
|
|
21
33
|
return action;
|
|
@@ -79,12 +91,9 @@ async function executeActionCmd(args = [], options = {}, quiet = false) {
|
|
|
79
91
|
throw new Error(`Action ext ${ext} not implemented`);
|
|
80
92
|
}
|
|
81
93
|
const res = await act.run(args, options);
|
|
82
|
-
if (res?.error) {
|
|
83
|
-
throw res.error;
|
|
84
|
-
}
|
|
85
94
|
if (!quiet) {
|
|
86
95
|
if (res) {
|
|
87
|
-
console.log(res);
|
|
96
|
+
console.log("ARES", res);
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
99
|
return res;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { compile, serializeGrammar } from "@intrinsicai/gbnfgen";
|
|
2
|
+
import ora from 'ora';
|
|
2
3
|
import { brain, initAgent, taskBuilder } from "../../../agent.js";
|
|
3
4
|
import { readTool } from "../../../db/read.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { isChatMode, isDebug, isQuiet, isShowTokens, isVerbose } from "../../../state/state.js";
|
|
6
|
+
import { parseArgs } from "../../../utils/args.js";
|
|
6
7
|
import { executeActionCmd, } from "../actions/cmd.js";
|
|
7
8
|
import { formatStats, parseInputOptions } from "../utils.js";
|
|
8
9
|
import { executeWorkflowCmd } from "../workflows/cmd.js";
|
|
9
|
-
import { configureTaskModel, mergeInferParams } from "./conf.js";
|
|
10
|
+
import { configureTaskModel, mergeConfOptions, mergeInferParams } from "./conf.js";
|
|
10
11
|
import { openTaskSpec } from "./utils.js";
|
|
11
12
|
async function executeTaskCmd(args = [], options = {}) {
|
|
12
13
|
await initAgent();
|
|
@@ -44,7 +45,8 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
44
45
|
pr = args.prompt;
|
|
45
46
|
}
|
|
46
47
|
const taskFileSpec = openTaskSpec(name);
|
|
47
|
-
|
|
48
|
+
let { conf, vars } = parseArgs(args, true);
|
|
49
|
+
conf = mergeConfOptions(conf, options);
|
|
48
50
|
conf.inferParams = mergeInferParams(conf.inferParams, taskFileSpec.inferParams ?? {});
|
|
49
51
|
const model = configureTaskModel(conf, taskFileSpec);
|
|
50
52
|
const taskSpec = taskFileSpec;
|
|
@@ -64,13 +66,14 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
64
66
|
};
|
|
65
67
|
switch (type) {
|
|
66
68
|
case "action":
|
|
67
|
-
const res = await executeActionCmd(normalizedArgs,
|
|
69
|
+
const res = await executeActionCmd(normalizedArgs, conf, true);
|
|
68
70
|
return res;
|
|
69
71
|
case "task":
|
|
70
|
-
|
|
72
|
+
conf.quiet = !isDebug.value;
|
|
73
|
+
const tres = await executeTaskCmd(normalizedArgs, conf);
|
|
71
74
|
return tres.answer.text;
|
|
72
75
|
case "workflow":
|
|
73
|
-
const wres = await executeWorkflowCmd(toolName, normalizedArgs,
|
|
76
|
+
const wres = await executeWorkflowCmd(toolName, normalizedArgs, conf);
|
|
74
77
|
return wres;
|
|
75
78
|
default:
|
|
76
79
|
throw new Error(`unknown tool execution function type: ${type} for ${toolName}`);
|
|
@@ -98,34 +101,89 @@ async function executeTaskCmd(args = [], options = {}) {
|
|
|
98
101
|
ex.checkStatus();
|
|
99
102
|
let i = 0;
|
|
100
103
|
let c = false;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
ex.backend.setOnToken((t) => {
|
|
104
|
+
const hasThink = ex.template?.tags?.think;
|
|
105
|
+
const hasTools = ex.template?.tags?.toolCall;
|
|
106
|
+
const printToken = (t) => {
|
|
107
|
+
if (isShowTokens.value) {
|
|
106
108
|
let txt = t;
|
|
107
|
-
|
|
108
|
-
txt = c ? t : `\x1b[100m${t}\x1b[0m`;
|
|
109
|
-
}
|
|
109
|
+
txt = c ? t : `\x1b[100m${t}\x1b[0m`;
|
|
110
110
|
process.stdout.write(txt);
|
|
111
111
|
++i;
|
|
112
112
|
c = !c;
|
|
113
|
-
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
process.stdout.write(t);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
let processToken = printToken;
|
|
119
|
+
if ((hasThink || hasTools) && !isDebug.value) {
|
|
120
|
+
let continueWrite = true;
|
|
121
|
+
let skipNextEmptyLinesToken = false;
|
|
122
|
+
const spinner = ora("Thinking ...");
|
|
123
|
+
processToken = (t) => {
|
|
124
|
+
if (isQuiet.value) {
|
|
125
|
+
if (hasThink) {
|
|
126
|
+
if (t == ex.template.tags.think?.start) {
|
|
127
|
+
spinner.start();
|
|
128
|
+
continueWrite = false;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
else if (t == ex.template.tags.think?.end) {
|
|
132
|
+
continueWrite = true;
|
|
133
|
+
skipNextEmptyLinesToken = true;
|
|
134
|
+
spinner.stop();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (hasTools) {
|
|
140
|
+
if (t == ex.template.tags.toolCall?.start) {
|
|
141
|
+
continueWrite = false;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
else if (t == ex.template.tags.toolCall?.end) {
|
|
145
|
+
if (isVerbose.value) {
|
|
146
|
+
skipNextEmptyLinesToken = true;
|
|
147
|
+
continueWrite = true;
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (continueWrite) {
|
|
153
|
+
if (skipNextEmptyLinesToken) {
|
|
154
|
+
if (t == "\n\n") {
|
|
155
|
+
skipNextEmptyLinesToken = false;
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
printToken(t);
|
|
160
|
+
}
|
|
161
|
+
++i;
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const onToolCall = (tc) => {
|
|
165
|
+
console.log("⚒️ ", `Executing [${name}]`, tc.name, tc.arguments);
|
|
166
|
+
};
|
|
167
|
+
if (options?.onToken) {
|
|
168
|
+
ex.backend.setOnToken(options.onToken);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
ex.backend.setOnToken(processToken);
|
|
114
172
|
}
|
|
115
173
|
const tconf = {
|
|
116
174
|
expert: ex,
|
|
117
175
|
model: model,
|
|
118
176
|
debug: isDebug.value,
|
|
177
|
+
onToolCall: onToolCall,
|
|
119
178
|
...conf,
|
|
120
179
|
};
|
|
121
180
|
tconf.expert = ex;
|
|
122
|
-
if (isDebug.value || isVerbose.value) {
|
|
123
|
-
tconf.debug = true;
|
|
124
|
-
}
|
|
125
181
|
let out;
|
|
126
182
|
try {
|
|
127
183
|
out = await task.run({ prompt: pr, ...vars }, tconf);
|
|
128
|
-
|
|
184
|
+
if (!out.answer.text.endsWith("\n")) {
|
|
185
|
+
console.log();
|
|
186
|
+
}
|
|
129
187
|
}
|
|
130
188
|
catch (err) {
|
|
131
189
|
throw new Error(`executing task: ${name} (${err})`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InferenceParams } from "@locallm/types";
|
|
2
2
|
import { LmTaskConfig, LmTaskFileSpec, ModelSpec } from "../../../interfaces.js";
|
|
3
3
|
declare function configureTaskModel(itConf: LmTaskConfig, taskSpec: LmTaskFileSpec): ModelSpec;
|
|
4
|
+
declare function mergeConfOptions(conf: LmTaskConfig, options: Record<string, any>): LmTaskConfig;
|
|
4
5
|
declare function mergeInferParams(userInferParams: Record<string, any>, taskInferParams: InferenceParams): InferenceParams;
|
|
5
|
-
export { mergeInferParams, configureTaskModel, };
|
|
6
|
+
export { mergeConfOptions, mergeInferParams, configureTaskModel, };
|
|
@@ -83,6 +83,16 @@ function configureTaskModel(itConf, taskSpec) {
|
|
|
83
83
|
}
|
|
84
84
|
return model;
|
|
85
85
|
}
|
|
86
|
+
function mergeConfOptions(conf, options) {
|
|
87
|
+
const res = conf;
|
|
88
|
+
for (const [k, v] of Object.entries(options)) {
|
|
89
|
+
if (k == "inferParams") {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
res[k] = v;
|
|
93
|
+
}
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
86
96
|
function mergeInferParams(userInferParams, taskInferParams) {
|
|
87
97
|
const ip = taskInferParams;
|
|
88
98
|
for (const [k, v] of Object.entries(userInferParams)) {
|
|
@@ -90,4 +100,4 @@ function mergeInferParams(userInferParams, taskInferParams) {
|
|
|
90
100
|
}
|
|
91
101
|
return ip;
|
|
92
102
|
}
|
|
93
|
-
export { mergeInferParams, configureTaskModel, };
|
|
103
|
+
export { mergeConfOptions, mergeInferParams, configureTaskModel, };
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ import { formatMode, initFilepaths, inputMode, outputMode, promptfilePath } from
|
|
|
3
3
|
import { modes } from "../clicmds/modes.js";
|
|
4
4
|
import { readClipboard, writeToClipboard } from "../sys/clipboard.js";
|
|
5
5
|
import { readFile } from "../sys/read.js";
|
|
6
|
+
import { splitThinking } from "../../utils/text.js";
|
|
6
7
|
async function setOptions(args = [], options) {
|
|
7
8
|
for (const k of Object.keys(options)) {
|
|
8
9
|
let opt;
|
|
@@ -33,7 +34,13 @@ async function processOutput(res) {
|
|
|
33
34
|
let hasTextData = false;
|
|
34
35
|
if (typeof res == "object") {
|
|
35
36
|
if (res?.answer?.text) {
|
|
36
|
-
|
|
37
|
+
if (res?.template?.tags?.think) {
|
|
38
|
+
const { finalAnswer } = splitThinking(res.answer.text, res.template.tags.think.start, res.template.tags.think.end);
|
|
39
|
+
data = finalAnswer;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
data = res.answer.text;
|
|
43
|
+
}
|
|
37
44
|
hasTextData = true;
|
|
38
45
|
}
|
|
39
46
|
else {
|
|
@@ -46,8 +53,8 @@ async function processOutput(res) {
|
|
|
46
53
|
if (outputMode.value == "clipboard") {
|
|
47
54
|
await writeToClipboard(data);
|
|
48
55
|
}
|
|
49
|
-
if (
|
|
50
|
-
if (
|
|
56
|
+
if (hasTextData) {
|
|
57
|
+
if (formatMode.value == "markdown") {
|
|
51
58
|
console.log("\n------------------\n");
|
|
52
59
|
console.log(marked.parse(data).trim());
|
|
53
60
|
}
|
package/dist/db/read.js
CHANGED
|
@@ -67,9 +67,8 @@ function readTool(name) {
|
|
|
67
67
|
const q = `SELECT id, name, type, spec FROM tool WHERE name='${name}'`;
|
|
68
68
|
const stmt = db.prepare(q);
|
|
69
69
|
const result = stmt.get();
|
|
70
|
-
const tool = JSON.parse(result.spec);
|
|
71
|
-
tool["name"] = name;
|
|
72
70
|
if (result?.id) {
|
|
71
|
+
const tool = JSON.parse(result.spec);
|
|
73
72
|
return {
|
|
74
73
|
found: true,
|
|
75
74
|
tool: tool,
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -86,6 +86,7 @@ interface BaseLmTaskConfig {
|
|
|
86
86
|
}
|
|
87
87
|
interface LmTaskConfig extends BaseLmTaskConfig {
|
|
88
88
|
modelname?: string;
|
|
89
|
+
quiet?: boolean;
|
|
89
90
|
}
|
|
90
91
|
interface FinalLmTaskConfig {
|
|
91
92
|
model?: ModelSpec;
|
|
@@ -96,6 +97,7 @@ type InputMode = "manual" | "promptfile" | "clipboard";
|
|
|
96
97
|
type OutputMode = "txt" | "clipboard";
|
|
97
98
|
type RunMode = "cli" | "cmd";
|
|
98
99
|
type FormatMode = "text" | "markdown";
|
|
100
|
+
type VerbosityMode = "quiet" | "verbose" | "debug";
|
|
99
101
|
type FeatureType = "task" | "action" | "cmd" | "workflow" | "adaptater" | "modelfile";
|
|
100
102
|
type ToolType = "task" | "action" | "cmd" | "workflow";
|
|
101
103
|
type ActionExtension = "js" | "mjs" | "py" | "yml";
|
|
@@ -106,4 +108,4 @@ type CmdExtension = "js";
|
|
|
106
108
|
type ModelFileExtension = "yml";
|
|
107
109
|
type FeatureExtension = TaskExtension | CmdExtension | ActionExtension | WorkflowExtension | ModelFileExtension;
|
|
108
110
|
type AliasType = "task" | "action" | "workflow";
|
|
109
|
-
export { Cmd, CmdExecutor, InputMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, ModelFileExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, };
|
|
111
|
+
export { Cmd, CmdExecutor, InputMode, VerbosityMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, ModelFileExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, };
|
package/dist/main.d.ts
CHANGED
|
@@ -6,9 +6,10 @@ import { writeToClipboard } from "./cmd/sys/clipboard.js";
|
|
|
6
6
|
import { pingCmd } from "./cmd/clicmds/cmds.js";
|
|
7
7
|
import { initAgent } from "./agent.js";
|
|
8
8
|
import { initState, pluginDataDir } from "./state/state.js";
|
|
9
|
-
import { usePerfTimer } from "./
|
|
10
|
-
import { parseArgs } from "./
|
|
9
|
+
import { usePerfTimer } from "./utils/perf.js";
|
|
10
|
+
import { parseArgs } from "./utils/args.js";
|
|
11
11
|
import { LmTaskConf } from "@agent-smith/lmtask/dist/interfaces.js";
|
|
12
12
|
import { extractToolDoc } from "./cmd/lib/tools.js";
|
|
13
13
|
import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
|
|
14
|
-
|
|
14
|
+
import { extractBetweenTags, splitThinking } from "./utils/text.js";
|
|
15
|
+
export { execute, run, pingCmd, executeWorkflowCmd, executeActionCmd, executeTaskCmd, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseArgs, extractToolDoc, LmTaskConf, openTaskSpec, extractBetweenTags, splitThinking, };
|
package/dist/main.js
CHANGED
|
@@ -6,8 +6,9 @@ import { writeToClipboard } from "./cmd/sys/clipboard.js";
|
|
|
6
6
|
import { pingCmd } from "./cmd/clicmds/cmds.js";
|
|
7
7
|
import { initAgent } from "./agent.js";
|
|
8
8
|
import { initState, pluginDataDir } from "./state/state.js";
|
|
9
|
-
import { usePerfTimer } from "./
|
|
10
|
-
import { parseArgs } from "./
|
|
9
|
+
import { usePerfTimer } from "./utils/perf.js";
|
|
10
|
+
import { parseArgs } from "./utils/args.js";
|
|
11
11
|
import { extractToolDoc } from "./cmd/lib/tools.js";
|
|
12
12
|
import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
|
|
13
|
-
|
|
13
|
+
import { extractBetweenTags, splitThinking } from "./utils/text.js";
|
|
14
|
+
export { execute, run, pingCmd, executeWorkflowCmd, executeActionCmd, executeTaskCmd, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, };
|
package/dist/state/state.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { PythonShell } from 'python-shell';
|
|
2
|
-
import { InputMode, RunMode, FormatMode, OutputMode } from "../interfaces.js";
|
|
2
|
+
import { InputMode, RunMode, FormatMode, OutputMode, VerbosityMode } from "../interfaces.js";
|
|
3
3
|
declare let pyShell: PythonShell;
|
|
4
4
|
declare const inputMode: import("@vue/reactivity").Ref<InputMode, InputMode>;
|
|
5
5
|
declare const outputMode: import("@vue/reactivity").Ref<OutputMode, OutputMode>;
|
|
6
6
|
declare const runMode: import("@vue/reactivity").Ref<RunMode, RunMode>;
|
|
7
7
|
declare const formatMode: import("@vue/reactivity").Ref<FormatMode, FormatMode>;
|
|
8
8
|
declare const isChatMode: import("@vue/reactivity").Ref<boolean, boolean>;
|
|
9
|
-
declare const isDebug: import("@vue/reactivity").
|
|
10
|
-
declare const isVerbose: import("@vue/reactivity").
|
|
9
|
+
declare const isDebug: import("@vue/reactivity").ComputedRef<boolean>;
|
|
10
|
+
declare const isVerbose: import("@vue/reactivity").ComputedRef<boolean>;
|
|
11
|
+
declare const isQuiet: import("@vue/reactivity").ComputedRef<boolean>;
|
|
11
12
|
declare const isShowTokens: import("@vue/reactivity").Ref<boolean, boolean>;
|
|
12
13
|
declare const promptfilePath: import("@vue/reactivity").Ref<string, string>;
|
|
13
14
|
declare const dataDirPath: import("@vue/reactivity").Ref<string, string>;
|
|
@@ -18,4 +19,5 @@ declare const lastCmd: {
|
|
|
18
19
|
declare function initFilepaths(): void;
|
|
19
20
|
declare function initState(): Promise<void>;
|
|
20
21
|
declare function pluginDataDir(pluginName: string): string;
|
|
21
|
-
|
|
22
|
+
declare function setVerbosity(mode: VerbosityMode): void;
|
|
23
|
+
export { inputMode, outputMode, isChatMode, isShowTokens, runMode, formatMode, lastCmd, isDebug, isVerbose, isQuiet, promptfilePath, dataDirPath, pluginDataDir, initState, initFilepaths, setVerbosity, pyShell, };
|
package/dist/state/state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reactive, ref } from "@vue/reactivity";
|
|
1
|
+
import { computed, reactive, ref } from "@vue/reactivity";
|
|
2
2
|
import { initDb } from "../db/db.js";
|
|
3
3
|
import { readFilePaths } from "../db/read.js";
|
|
4
4
|
import path from "path";
|
|
@@ -9,8 +9,10 @@ const outputMode = ref("txt");
|
|
|
9
9
|
const runMode = ref("cmd");
|
|
10
10
|
const formatMode = ref("text");
|
|
11
11
|
const isChatMode = ref(false);
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const verbosity = ref("quiet");
|
|
13
|
+
const isDebug = computed(() => verbosity.value == "debug");
|
|
14
|
+
const isVerbose = computed(() => verbosity.value == "verbose");
|
|
15
|
+
const isQuiet = computed(() => verbosity.value == "quiet");
|
|
14
16
|
const isShowTokens = ref(false);
|
|
15
17
|
const promptfilePath = ref("");
|
|
16
18
|
const dataDirPath = ref("");
|
|
@@ -51,4 +53,7 @@ function pluginDataDir(pluginName) {
|
|
|
51
53
|
createDirectoryIfNotExists(pluginDatapath);
|
|
52
54
|
return pluginDatapath;
|
|
53
55
|
}
|
|
54
|
-
|
|
56
|
+
function setVerbosity(mode) {
|
|
57
|
+
verbosity.value = mode;
|
|
58
|
+
}
|
|
59
|
+
export { inputMode, outputMode, isChatMode, isShowTokens, runMode, formatMode, lastCmd, isDebug, isVerbose, isQuiet, promptfilePath, dataDirPath, pluginDataDir, initState, initFilepaths, setVerbosity, pyShell, };
|
|
@@ -47,7 +47,11 @@ function parseArrayArgs(args) {
|
|
|
47
47
|
const _nargs = new Array();
|
|
48
48
|
args.forEach((a) => {
|
|
49
49
|
if (a.includes("=")) {
|
|
50
|
-
const
|
|
50
|
+
const index = a.indexOf('=');
|
|
51
|
+
const t = [
|
|
52
|
+
a.slice(0, index),
|
|
53
|
+
a.slice(index + 1)
|
|
54
|
+
];
|
|
51
55
|
const k = t[0];
|
|
52
56
|
const v = t[1];
|
|
53
57
|
switch (k) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare function extractBetweenTags(text: string, startTag: string, endTag: string): string;
|
|
2
|
+
declare function splitThinking(text: string, startTag: string, endTag: string): {
|
|
3
|
+
think: string;
|
|
4
|
+
finalAnswer: string;
|
|
5
|
+
};
|
|
6
|
+
export { extractBetweenTags, splitThinking, };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
function extractBetweenTags(text, startTag, endTag) {
|
|
2
|
+
try {
|
|
3
|
+
const startIndex = text.indexOf(startTag);
|
|
4
|
+
if (startIndex === -1)
|
|
5
|
+
return text;
|
|
6
|
+
let contentStart = startIndex + startTag.length;
|
|
7
|
+
let contentEnd;
|
|
8
|
+
if (endTag) {
|
|
9
|
+
contentEnd = text.indexOf(endTag, contentStart);
|
|
10
|
+
if (contentEnd === -1)
|
|
11
|
+
return text;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
contentEnd = text.indexOf('\n', contentStart);
|
|
15
|
+
if (contentEnd === -1)
|
|
16
|
+
contentEnd = text.length;
|
|
17
|
+
}
|
|
18
|
+
return text.substring(contentStart, contentEnd).trim();
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
throw new Error(`Error parsing content between tags ${startTag} ${endTag}: ${error}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function splitThinking(text, startTag, endTag) {
|
|
25
|
+
let think = "";
|
|
26
|
+
let answer = "";
|
|
27
|
+
const st = text.split(endTag);
|
|
28
|
+
if (st.length > 1) {
|
|
29
|
+
think = extractBetweenTags(text, startTag, endTag);
|
|
30
|
+
answer = st[1].trim();
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
answer = text;
|
|
34
|
+
}
|
|
35
|
+
return { think: think, finalAnswer: answer };
|
|
36
|
+
}
|
|
37
|
+
export { extractBetweenTags, splitThinking, };
|
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.61",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -10,22 +10,23 @@
|
|
|
10
10
|
"watch": "tsc --noCheck -p . -w"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@agent-smith/brain": "^0.0.
|
|
13
|
+
"@agent-smith/brain": "^0.0.43",
|
|
14
14
|
"@agent-smith/jobs": "^0.0.14",
|
|
15
|
-
"@agent-smith/lmtask": "^0.0.
|
|
15
|
+
"@agent-smith/lmtask": "^0.0.43",
|
|
16
16
|
"@agent-smith/tfm": "^0.1.2",
|
|
17
17
|
"@inquirer/prompts": "^7.5.0",
|
|
18
18
|
"@inquirer/select": "^4.2.0",
|
|
19
19
|
"@vue/reactivity": "^3.5.13",
|
|
20
20
|
"@wllama/wllama": "^2.3.1",
|
|
21
21
|
"ansi-colors": "^4.1.3",
|
|
22
|
-
"better-sqlite3": "^11.
|
|
22
|
+
"better-sqlite3": "^11.10.0",
|
|
23
23
|
"clipboardy": "^4.0.0",
|
|
24
24
|
"commander": "^13.1.0",
|
|
25
25
|
"marked-terminal": "^7.3.0",
|
|
26
|
-
"modprompt": "^0.11.
|
|
26
|
+
"modprompt": "^0.11.6",
|
|
27
27
|
"python-shell": "^5.0.0",
|
|
28
|
-
"yaml": "^2.7.1"
|
|
28
|
+
"yaml": "^2.7.1",
|
|
29
|
+
"ora": "^8.2.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@agent-smith/tmem-jobs": "^0.0.4",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
36
37
|
"@types/better-sqlite3": "^7.6.13",
|
|
37
38
|
"@types/marked-terminal": "^6.1.1",
|
|
38
|
-
"@types/node": "^22.15.
|
|
39
|
+
"@types/node": "^22.15.17",
|
|
39
40
|
"restmix": "^0.5.0",
|
|
40
41
|
"rollup": "^4.40.2",
|
|
41
42
|
"ts-node": "^10.9.2",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|