@agent-smith/cli 0.0.109 → 0.0.111
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/cli.js +1 -0
- package/dist/cmd/clicmds/aliases.js +12 -1
- package/dist/cmd/clicmds/base.js +3 -0
- package/dist/cmd/clicmds/cmds.js +9 -0
- package/dist/cmd/clicmds/updateconf.js +1 -0
- package/dist/cmd/cmds.js +70 -0
- package/dist/cmd/lib/actions/cmd.js +21 -1
- package/dist/cmd/lib/actions/read.js +4 -0
- package/dist/cmd/lib/adaptaters/cmd.js +8 -1
- package/dist/cmd/lib/agents/cmd.js +2 -1
- package/dist/cmd/lib/mcp.js +6 -0
- package/dist/cmd/lib/options_parsers.js +5 -0
- package/dist/cmd/lib/tasks/cmd.js +90 -4
- package/dist/cmd/lib/tasks/conf.js +35 -0
- package/dist/cmd/lib/tasks/read.js +30 -1
- package/dist/cmd/lib/tools.js +10 -4
- package/dist/cmd/lib/user_msgs.js +4 -3
- package/dist/cmd/lib/utils.js +5 -0
- package/dist/cmd/lib/workflows/cmd.js +32 -1
- package/dist/cmd/lib/workflows/read.js +5 -0
- package/dist/cmd/options.js +1 -0
- package/dist/cmd/sys/clipboard.js +25 -0
- package/dist/cmd/sys/execute.js +1 -0
- package/dist/cmd/sys/read_cmds.js +2 -2
- package/dist/cmd/sys/read_conf.js +1 -0
- package/dist/cmd/sys/read_features.js +1 -0
- package/dist/cmd/sys/run_python.js +4 -0
- package/dist/conf.d.ts +5 -1
- package/dist/conf.js +6 -2
- package/dist/db/db.js +1 -0
- package/dist/db/read.js +1 -0
- package/dist/db/write.js +32 -0
- package/dist/index.js +10 -0
- package/dist/main.d.ts +17 -2
- package/dist/main.js +16 -1
- package/dist/state/backends.js +14 -0
- package/dist/state/plugins.js +3 -0
- package/dist/state/state.js +21 -2
- package/dist/state/tasks.d.ts +2 -1
- package/dist/state/tasks.js +8 -1
- package/dist/utils/text.js +4 -0
- package/dist/utils/user_msgs.js +2 -0
- package/package.json +19 -16
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ import { backend } from './state/backends.js';
|
|
|
6
6
|
async function query(program) {
|
|
7
7
|
const data = { message: "$", default: "" };
|
|
8
8
|
const q = await input(data);
|
|
9
|
+
//console.log("QUERY", q);
|
|
9
10
|
const args = q.split(" ");
|
|
10
11
|
await program.parseAsync(args, { from: "user" });
|
|
11
12
|
if (isChatMode.value) {
|
|
@@ -4,6 +4,7 @@ import { executeWorkflowCmd } from "../lib/workflows/cmd.js";
|
|
|
4
4
|
import { executeAgentCmd } from "../lib/agents/cmd.js";
|
|
5
5
|
function initCommandsFromAliases(program, aliases, features) {
|
|
6
6
|
aliases.forEach((alias) => {
|
|
7
|
+
//console.log("A", alias)
|
|
7
8
|
switch (alias.type) {
|
|
8
9
|
case "agent":
|
|
9
10
|
const agcmd = program.command(`${alias.name} [prompt_and_vars...]`)
|
|
@@ -12,6 +13,7 @@ function initCommandsFromAliases(program, aliases, features) {
|
|
|
12
13
|
await executeAgentCmd(alias.name, args);
|
|
13
14
|
});
|
|
14
15
|
allOptions.forEach(o => agcmd.addOption(o));
|
|
16
|
+
//console.log("TVARS", alias.name, features.task[alias.name]?.variables)
|
|
15
17
|
if (features.agent[alias.name]?.variables) {
|
|
16
18
|
const rtv = features.agent[alias.name].variables?.required;
|
|
17
19
|
if (rtv) {
|
|
@@ -34,6 +36,7 @@ function initCommandsFromAliases(program, aliases, features) {
|
|
|
34
36
|
await executeTaskCmd(alias.name, args);
|
|
35
37
|
});
|
|
36
38
|
allOptions.forEach(o => tcmd.addOption(o));
|
|
39
|
+
//console.log("TVARS", alias.name, features.task[alias.name]?.variables)
|
|
37
40
|
if (features.task[alias.name]?.variables) {
|
|
38
41
|
const rtv = features.task[alias.name].variables?.required;
|
|
39
42
|
if (rtv) {
|
|
@@ -49,11 +52,19 @@ function initCommandsFromAliases(program, aliases, features) {
|
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
break;
|
|
55
|
+
/*case "action":
|
|
56
|
+
const acmd = program.command(`${alias.name} [args...]`)
|
|
57
|
+
.description("action: " + alias.name)
|
|
58
|
+
.action(async (...args: Array<any>) => {
|
|
59
|
+
await executeActionCmd(alias.name, args)
|
|
60
|
+
});
|
|
61
|
+
allOptions.forEach(o => acmd.addOption(o));
|
|
62
|
+
break;*/
|
|
52
63
|
case "workflow":
|
|
53
64
|
const wcmd = program.command(`${alias.name} [args...]`)
|
|
54
65
|
.description("workflow: " + alias.name)
|
|
55
66
|
.action(async (...args) => {
|
|
56
|
-
executeWorkflowCmd(alias.name, args);
|
|
67
|
+
await executeWorkflowCmd(alias.name, args);
|
|
57
68
|
});
|
|
58
69
|
allOptions.forEach(o => wcmd.addOption(o));
|
|
59
70
|
}
|
package/dist/cmd/clicmds/base.js
CHANGED
|
@@ -5,6 +5,9 @@ import { processTaskCmd, processTasksCmd, resetDbCmd } from "./cmds.js";
|
|
|
5
5
|
import { updateConfCmd, updateFeaturesCmd } from "./updateconf.js";
|
|
6
6
|
import { displayOptions, inferenceOptions } from "../options.js";
|
|
7
7
|
function initBaseCommands(program) {
|
|
8
|
+
/*program.command("ping")
|
|
9
|
+
.description("ping inference servers")
|
|
10
|
+
.action(async (...args: Array<any>) => { console.log("Found working inference server(s):", await initAgent(initRemoteBackends())) });*/
|
|
8
11
|
program.command("exit")
|
|
9
12
|
.description("exit the cli")
|
|
10
13
|
.action(() => process.exit(0));
|
package/dist/cmd/clicmds/cmds.js
CHANGED
|
@@ -18,12 +18,14 @@ async function initUserCmds(cmdFeats, program) {
|
|
|
18
18
|
const features = Object.values(cmdFeats);
|
|
19
19
|
const usrCmds = [];
|
|
20
20
|
for (const feat of features) {
|
|
21
|
+
//console.log("Init cmd", feat);
|
|
21
22
|
const hasVariables = feat?.variables ? true : false;
|
|
22
23
|
const vars = hasVariables ? feat.variables : {};
|
|
23
24
|
let desc = "";
|
|
24
25
|
if (hasVariables) {
|
|
25
26
|
desc = vars.description;
|
|
26
27
|
}
|
|
28
|
+
// @ts-ignore
|
|
27
29
|
const cmd = program.command(feat.variables.name)
|
|
28
30
|
.description(desc)
|
|
29
31
|
.action(async (...args) => {
|
|
@@ -43,6 +45,7 @@ async function initUserCmds(cmdFeats, program) {
|
|
|
43
45
|
cmd.addOption(new Option(opt[0], opt[1]));
|
|
44
46
|
}
|
|
45
47
|
else {
|
|
48
|
+
// predefined option
|
|
46
49
|
switch (opt) {
|
|
47
50
|
case "all":
|
|
48
51
|
allOptions.forEach(o => cmd.addOption(o));
|
|
@@ -64,6 +67,7 @@ async function initUserCmds(cmdFeats, program) {
|
|
|
64
67
|
}
|
|
65
68
|
usrCmds.push(cmd);
|
|
66
69
|
}
|
|
70
|
+
//console.log("USRCMDS", usrCmds.map(c => c.name()))
|
|
67
71
|
return usrCmds;
|
|
68
72
|
}
|
|
69
73
|
async function resetDbCmd() {
|
|
@@ -79,6 +83,7 @@ async function processTasksCmd(args, options) {
|
|
|
79
83
|
if (!isTaskSettingsInitialized.value) {
|
|
80
84
|
initTaskSettings();
|
|
81
85
|
}
|
|
86
|
+
//console.log("PTS", tasksSettings);
|
|
82
87
|
console.log(YAML.stringify({ "tasks": tasksSettings }));
|
|
83
88
|
}
|
|
84
89
|
else {
|
|
@@ -87,6 +92,7 @@ async function processTasksCmd(args, options) {
|
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
async function processTaskCmd(args, options) {
|
|
95
|
+
//console.log("TASK OPTS", options);
|
|
90
96
|
if (args.length == 0) {
|
|
91
97
|
console.warn("Provide a task name");
|
|
92
98
|
return;
|
|
@@ -101,10 +107,12 @@ async function processTaskCmd(args, options) {
|
|
|
101
107
|
console.log("Task", args[0], "reset ok");
|
|
102
108
|
return;
|
|
103
109
|
}
|
|
110
|
+
//console.log("RT", path)
|
|
104
111
|
const res = readTask(path);
|
|
105
112
|
if (!res.found) {
|
|
106
113
|
throw new Error(`Task ${args[0]}, ${path} not found`);
|
|
107
114
|
}
|
|
115
|
+
//const ts = JSON.parse(res.ymlTask);
|
|
108
116
|
console.log(res.ymlTask);
|
|
109
117
|
if (Object.keys(options).length > 0) {
|
|
110
118
|
upsertTaskSettings(args[0], options);
|
|
@@ -122,5 +130,6 @@ async function processTaskCmd(args, options) {
|
|
|
122
130
|
}
|
|
123
131
|
console.log(colors.dim("Settings") + ":", display);
|
|
124
132
|
}
|
|
133
|
+
//console.log(JSON.stringify(ts, null, " "));
|
|
125
134
|
}
|
|
126
135
|
export { initUserCmds, processTaskCmd, processTasksCmd, resetDbCmd, };
|
|
@@ -42,6 +42,7 @@ async function updateFeaturesCmd(options) {
|
|
|
42
42
|
}
|
|
43
43
|
async function updateConfCmd(args) {
|
|
44
44
|
initDb(false, true);
|
|
45
|
+
// try to find a conf path in db
|
|
45
46
|
const { found, path } = readFilePath("conf");
|
|
46
47
|
const userProvidedConfPath = (args[0] != "conf") ? args[0] : null;
|
|
47
48
|
if (!found && !userProvidedConfPath) {
|
package/dist/cmd/cmds.js
CHANGED
|
@@ -7,8 +7,10 @@ import { isChatMode, runMode } from "../state/state.js";
|
|
|
7
7
|
import { initCommandsFromAliases } from "./clicmds/aliases.js";
|
|
8
8
|
import { initBaseCommands } from "./clicmds/base.js";
|
|
9
9
|
import { initUserCmds } from "./clicmds/cmds.js";
|
|
10
|
+
//import { usePerfTimer } from "../main.js";
|
|
10
11
|
const program = new Command();
|
|
11
12
|
async function chat(program, options, agent, mcpServers) {
|
|
13
|
+
//console.log("CHAT OPTS", options);
|
|
12
14
|
const data = { message: '>', default: "" };
|
|
13
15
|
const prompt = await input(data);
|
|
14
16
|
if (prompt == "/q") {
|
|
@@ -21,21 +23,89 @@ async function chat(program, options, agent, mcpServers) {
|
|
|
21
23
|
await query(program);
|
|
22
24
|
}
|
|
23
25
|
}
|
|
26
|
+
//console.log("CHAT HIST", agent.history);
|
|
27
|
+
//options.history = undefined;
|
|
28
|
+
//console.log("RUN W PROMPT", prompt);
|
|
24
29
|
await agent.run(prompt, chatInferenceParams, options, chatTemplate ? chatTemplate : undefined);
|
|
25
30
|
console.log();
|
|
26
31
|
await chat(program, options, agent, mcpServers);
|
|
27
32
|
}
|
|
28
33
|
async function buildCmds() {
|
|
34
|
+
//program.allowUnknownOption(true);
|
|
35
|
+
//const perf = usePerfTimer();
|
|
29
36
|
initBaseCommands(program);
|
|
37
|
+
//perf.measure("initBaseCommands");
|
|
30
38
|
const aliases = readAliases();
|
|
39
|
+
//perf.measure("readAliases");
|
|
31
40
|
const feats = readFeatures();
|
|
41
|
+
//perf.measure("readFeatures");
|
|
32
42
|
initCommandsFromAliases(program, aliases, feats);
|
|
43
|
+
//perf.measure("initCommandsFromAliases");
|
|
33
44
|
await initUserCmds(feats.cmd, program);
|
|
45
|
+
//perf.measure("initUserCmds");
|
|
46
|
+
//perf.measure("cmds for each");
|
|
47
|
+
//perf.final("buildCmds");
|
|
34
48
|
return program;
|
|
35
49
|
}
|
|
50
|
+
/*async function buildCmds(): Promise<Command> {
|
|
51
|
+
// Performance measurement start
|
|
52
|
+
const startTime = process.hrtime.bigint();
|
|
53
|
+
const measurements: { name: string; time: number; percentage: number }[] = [];
|
|
54
|
+
let lastTime = startTime;
|
|
55
|
+
|
|
56
|
+
function measureFunction(name: string) {
|
|
57
|
+
const currentTime = process.hrtime.bigint();
|
|
58
|
+
const elapsedNs = Number(currentTime - lastTime);
|
|
59
|
+
const elapsedSec = elapsedNs / 1_000_000_000;
|
|
60
|
+
measurements.push({ name, time: elapsedSec, percentage: 0 });
|
|
61
|
+
lastTime = currentTime;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//program.allowUnknownOption(true);
|
|
65
|
+
measureFunction("start");
|
|
66
|
+
initBaseCommands(program);
|
|
67
|
+
|
|
68
|
+
measureFunction("initBaseCommands");
|
|
69
|
+
const aliases = readAliases();
|
|
70
|
+
|
|
71
|
+
measureFunction("readAliases");
|
|
72
|
+
const feats = readFeatures();
|
|
73
|
+
|
|
74
|
+
measureFunction("readFeatures");
|
|
75
|
+
initCommandsFromAliases(program, aliases, feats);
|
|
76
|
+
|
|
77
|
+
measureFunction("initCommandsFromAliases");
|
|
78
|
+
const cmds = await initUserCmds(feats.cmd);
|
|
79
|
+
|
|
80
|
+
measureFunction("initUserCmds");
|
|
81
|
+
cmds.forEach(c => {
|
|
82
|
+
//console.log("Add cmd", c.name());
|
|
83
|
+
program.addCommand(c)
|
|
84
|
+
});
|
|
85
|
+
measureFunction("cmds.forEach");
|
|
86
|
+
|
|
87
|
+
// Calculate percentages and display results
|
|
88
|
+
const totalTime = Number(process.hrtime.bigint() - startTime) / 1_000_000_000;
|
|
89
|
+
measurements.forEach(m => {
|
|
90
|
+
m.percentage = (m.time / totalTime) * 100;
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
console.log("\nPerformance Measurements for buildCmds:");
|
|
94
|
+
measurements.forEach(m => {
|
|
95
|
+
console.log(`${m.name}: ${m.time.toFixed(6)}s (${m.percentage.toFixed(2)}%)`);
|
|
96
|
+
});
|
|
97
|
+
console.log(`Total time: ${totalTime.toFixed(6)}s\n`);
|
|
98
|
+
|
|
99
|
+
return program
|
|
100
|
+
}*/
|
|
36
101
|
async function parseCmd(program) {
|
|
37
102
|
program.name('Agent Smith terminal client');
|
|
38
103
|
program.description('Terminal agents toolkit');
|
|
39
104
|
await program.parseAsync();
|
|
105
|
+
//console.log("CMD END");
|
|
106
|
+
//exit(0)
|
|
107
|
+
/*if (isChatMode.value) {
|
|
108
|
+
await chat(program)
|
|
109
|
+
}*/
|
|
40
110
|
}
|
|
41
111
|
export { buildCmds, chat, parseCmd, program };
|
|
@@ -12,6 +12,7 @@ import { pathToFileURL } from 'url';
|
|
|
12
12
|
import { getInputFromOptions } from '../tasks/utils.js';
|
|
13
13
|
async function executeAction(name, payload, options, quiet = false) {
|
|
14
14
|
let run;
|
|
15
|
+
//console.log("GET ACTION", name, payload);
|
|
15
16
|
const inputData = await getInputFromOptions(options);
|
|
16
17
|
if (inputData) {
|
|
17
18
|
if (Array.isArray(payload)) {
|
|
@@ -22,11 +23,14 @@ async function executeAction(name, payload, options, quiet = false) {
|
|
|
22
23
|
if (!found) {
|
|
23
24
|
throw new Error(`Action ${name} not found at ${path}`);
|
|
24
25
|
}
|
|
26
|
+
//console.log("CREATE ACTION", name, ext, path);
|
|
25
27
|
switch (ext) {
|
|
26
28
|
case "js":
|
|
27
29
|
const url = pathToFileURL(path).href;
|
|
28
|
-
|
|
30
|
+
//console.log("CR JSA", url);
|
|
31
|
+
const mjsa = await import(/* @vite-ignore */ url);
|
|
29
32
|
run = createJsAction(mjsa.action);
|
|
33
|
+
//console.log("END CR JSA")
|
|
30
34
|
break;
|
|
31
35
|
case "yml":
|
|
32
36
|
run = systemAction(path);
|
|
@@ -37,6 +41,7 @@ async function executeAction(name, payload, options, quiet = false) {
|
|
|
37
41
|
default:
|
|
38
42
|
throw new Error(`Action ext ${ext} not implemented`);
|
|
39
43
|
}
|
|
44
|
+
//console.log("RUN", payload);
|
|
40
45
|
const res = await run(payload, options);
|
|
41
46
|
if (!quiet) {
|
|
42
47
|
if (res) {
|
|
@@ -47,7 +52,9 @@ async function executeAction(name, payload, options, quiet = false) {
|
|
|
47
52
|
return res;
|
|
48
53
|
}
|
|
49
54
|
async function executeActionCmd(name, aargs, quiet = false) {
|
|
55
|
+
//console.log("AARGs", aargs)
|
|
50
56
|
const { args, options } = parseCommandArgs(aargs);
|
|
57
|
+
//console.log("CMDA", args)
|
|
51
58
|
const params = args;
|
|
52
59
|
if (options?.clipBoardInput) {
|
|
53
60
|
params.push(await readClipboard());
|
|
@@ -62,9 +69,12 @@ async function executeActionCmd(name, aargs, quiet = false) {
|
|
|
62
69
|
}
|
|
63
70
|
function systemAction(path) {
|
|
64
71
|
const run = async (params) => {
|
|
72
|
+
//console.log("SYS ACTION PARAMS", params);
|
|
65
73
|
let runArgs = new Array();
|
|
74
|
+
// convert args for tool calls
|
|
66
75
|
if (!Array.isArray(params)) {
|
|
67
76
|
try {
|
|
77
|
+
// obviously a tool call
|
|
68
78
|
if (typeof params == "string") {
|
|
69
79
|
runArgs.push(params);
|
|
70
80
|
}
|
|
@@ -83,9 +93,12 @@ function systemAction(path) {
|
|
|
83
93
|
if (!actionSpec.found) {
|
|
84
94
|
runtimeError("System action yml file", path, "not found");
|
|
85
95
|
}
|
|
96
|
+
//console.log("Yml action", JSON.stringify(actionSpec.data, null, " "));
|
|
97
|
+
//console.log("Args", args)
|
|
86
98
|
if (!actionSpec.data?.args) {
|
|
87
99
|
actionSpec.data.args = [];
|
|
88
100
|
}
|
|
101
|
+
//console.log("EXEC", actionSpec.data.cmd, [...actionSpec.data.args, ...runArgs]);
|
|
89
102
|
const out = await execute(actionSpec.data.cmd, [...actionSpec.data.args, ...runArgs]);
|
|
90
103
|
return out.trim();
|
|
91
104
|
};
|
|
@@ -93,9 +106,11 @@ function systemAction(path) {
|
|
|
93
106
|
}
|
|
94
107
|
function pythonAction(path) {
|
|
95
108
|
const run = async (params) => {
|
|
109
|
+
//console.log("PY ACTION PARAMS", params);
|
|
96
110
|
let runArgs = new Array();
|
|
97
111
|
if (!Array.isArray(params)) {
|
|
98
112
|
try {
|
|
113
|
+
// obviously a tool call
|
|
99
114
|
if (typeof params == "string") {
|
|
100
115
|
runArgs.push(params);
|
|
101
116
|
}
|
|
@@ -110,7 +125,11 @@ function pythonAction(path) {
|
|
|
110
125
|
else {
|
|
111
126
|
runArgs = params;
|
|
112
127
|
}
|
|
128
|
+
//console.log("Py action", path);
|
|
113
129
|
const { data, error } = await runPyScript(pyShell, "python3", path, runArgs);
|
|
130
|
+
/*console.log("----------------");
|
|
131
|
+
console.log("PYOUT", data);
|
|
132
|
+
console.log("----------------");*/
|
|
114
133
|
if (error) {
|
|
115
134
|
throw new Error(`python error: ${error}`);
|
|
116
135
|
}
|
|
@@ -125,6 +144,7 @@ function pythonAction(path) {
|
|
|
125
144
|
}
|
|
126
145
|
catch (e) {
|
|
127
146
|
console.warn("Can not parse json from python action", path, e);
|
|
147
|
+
//throw new Error(`python error: ${error}`)
|
|
128
148
|
}
|
|
129
149
|
}
|
|
130
150
|
return final;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
function createJsAction(action) {
|
|
2
2
|
const run = async (args, options) => {
|
|
3
|
+
//console.log("JS ACTION PARAMS", args);
|
|
3
4
|
try {
|
|
4
5
|
const res = await action(args, options);
|
|
5
6
|
return res;
|
|
6
7
|
}
|
|
7
8
|
catch (e) {
|
|
9
|
+
/*if (e?.text) {
|
|
10
|
+
throw new Error(`executing action:${e.text()}. Args: ${args}`);
|
|
11
|
+
}*/
|
|
8
12
|
throw new Error(`executing action:${e}. Args: ${args}`);
|
|
9
13
|
}
|
|
10
14
|
};
|
|
@@ -3,6 +3,9 @@ import { createJsAction } from "../actions/read.js";
|
|
|
3
3
|
import { pathToFileURL } from 'url';
|
|
4
4
|
import { getInputFromOptions } from "../tasks/utils.js";
|
|
5
5
|
async function executeAdaptater(name, params, options) {
|
|
6
|
+
/*if (params?.args) {
|
|
7
|
+
params = params.args;
|
|
8
|
+
}*/
|
|
6
9
|
const { found, path } = getFeatureSpec(name, "adaptater");
|
|
7
10
|
if (!found) {
|
|
8
11
|
throw new Error(`adaptater ${name} not found`);
|
|
@@ -15,11 +18,13 @@ async function executeAdaptater(name, params, options) {
|
|
|
15
18
|
}
|
|
16
19
|
let run;
|
|
17
20
|
const url = pathToFileURL(path).href;
|
|
18
|
-
const jsa = await import(url);
|
|
21
|
+
const jsa = await import(/* @vite-ignore */ url);
|
|
19
22
|
run = createJsAction(jsa.action);
|
|
20
23
|
let res;
|
|
21
24
|
try {
|
|
25
|
+
//console.log("ADAPT RUN PARAMS", params);
|
|
22
26
|
res = await run(params, options);
|
|
27
|
+
//console.log("ADAPT RES", res);
|
|
23
28
|
}
|
|
24
29
|
catch (e) {
|
|
25
30
|
throw new Error(`adaptater ${name}: ${e}`);
|
|
@@ -27,6 +32,8 @@ async function executeAdaptater(name, params, options) {
|
|
|
27
32
|
if (res?.error) {
|
|
28
33
|
throw res.error;
|
|
29
34
|
}
|
|
35
|
+
//await processOutput(res);
|
|
36
|
+
//console.log("ADRES", res);
|
|
30
37
|
return res;
|
|
31
38
|
}
|
|
32
39
|
export { executeAdaptater, };
|
|
@@ -5,6 +5,7 @@ async function executeAgentCmd(name, targs = []) {
|
|
|
5
5
|
const ca = parseCommandArgs(targs);
|
|
6
6
|
const prompt = await getTaskPrompt(name, ca.args, ca.options);
|
|
7
7
|
ca.options.isAgent = true;
|
|
8
|
-
|
|
8
|
+
const res = await executeTask(name, { prompt: prompt }, ca.options);
|
|
9
|
+
return res;
|
|
9
10
|
}
|
|
10
11
|
export { executeAgentCmd, };
|
package/dist/cmd/lib/mcp.js
CHANGED
|
@@ -9,6 +9,9 @@ class McpClient {
|
|
|
9
9
|
askUserTools = null;
|
|
10
10
|
tools = {};
|
|
11
11
|
constructor(servername, command, args, authorizedTools = null, askUserTools = null) {
|
|
12
|
+
//console.log("MCP servername", servername);
|
|
13
|
+
//console.log("MCP command", command);
|
|
14
|
+
//console.log("MCP ARGS", typeof args, args);
|
|
12
15
|
this.name = servername;
|
|
13
16
|
const okargs = new Array();
|
|
14
17
|
for (const arg of args) {
|
|
@@ -59,7 +62,9 @@ class McpClient {
|
|
|
59
62
|
argsTypes[k] = vv.type;
|
|
60
63
|
}
|
|
61
64
|
}
|
|
65
|
+
//console.log("MCP ARGS TYPES", argsTypes);
|
|
62
66
|
const exec = async (args) => {
|
|
67
|
+
//console.log("MCP EXEC ARGS", args);
|
|
63
68
|
const _iargs = args;
|
|
64
69
|
for (const [k, v] of Object.entries(_iargs)) {
|
|
65
70
|
if (argsTypes[k] == "array") {
|
|
@@ -76,6 +81,7 @@ class McpClient {
|
|
|
76
81
|
name: tool.name,
|
|
77
82
|
arguments: _iargs,
|
|
78
83
|
};
|
|
84
|
+
//console.log("PAY", payload);
|
|
79
85
|
const res = await this.client.callTool(payload);
|
|
80
86
|
return res;
|
|
81
87
|
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
function parseCommandArgs(args) {
|
|
2
|
+
//return { args: program.args, options: program.opts() }
|
|
3
|
+
//discard the command (last arg)
|
|
2
4
|
args.pop();
|
|
5
|
+
//console.log("Raw command args:", args);
|
|
3
6
|
const res = {
|
|
4
7
|
args: new Array(),
|
|
5
8
|
options: {},
|
|
6
9
|
};
|
|
7
10
|
res.options = args.pop();
|
|
8
11
|
res.args = Array.isArray(args[0]) ? args[0] : args;
|
|
12
|
+
//console.log("PARSE ARGS RES", res.args);
|
|
13
|
+
//console.log("PARSE OPTS RES", res.options);
|
|
9
14
|
return res;
|
|
10
15
|
}
|
|
11
16
|
function parseTaskConfigOptions(options) {
|