@agent-smith/cli 0.0.101 → 0.0.103
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/aliases.js +23 -0
- package/dist/cmd/lib/agents/cmd.d.ts +3 -0
- package/dist/cmd/lib/agents/cmd.js +10 -0
- package/dist/cmd/lib/tasks/cmd.js +14 -15
- package/dist/cmd/lib/tasks/read.d.ts +6 -3
- package/dist/cmd/lib/tasks/read.js +16 -4
- package/dist/cmd/lib/tasks/utils.d.ts +5 -2
- package/dist/cmd/lib/tasks/utils.js +9 -8
- package/dist/cmd/lib/tools.js +1 -1
- package/dist/cmd/lib/utils.d.ts +1 -3
- package/dist/cmd/lib/utils.js +1 -9
- package/dist/cmd/lib/workflows/cmd.js +6 -10
- package/dist/cmd/sys/read_features.js +17 -4
- package/dist/db/read.js +2 -1
- package/dist/db/schemas.js +10 -2
- package/dist/db/write.js +13 -0
- package/dist/index.js +5 -0
- package/dist/interfaces.d.ts +11 -5
- package/dist/state/auto/usercmds.js +9 -2
- package/dist/state/features.js +2 -0
- package/package.json +5 -4
|
@@ -2,9 +2,32 @@ import { allOptions } from "../options.js";
|
|
|
2
2
|
import { executeTaskCmd } from "../lib/tasks/cmd.js";
|
|
3
3
|
import { executeActionCmd } from "../lib/actions/cmd.js";
|
|
4
4
|
import { executeWorkflowCmd } from "../lib/workflows/cmd.js";
|
|
5
|
+
import { executeAgentCmd } from "../lib/agents/cmd.js";
|
|
5
6
|
function initCommandsFromAliases(program, aliases, features) {
|
|
6
7
|
aliases.forEach((alias) => {
|
|
7
8
|
switch (alias.type) {
|
|
9
|
+
case "agent":
|
|
10
|
+
const agcmd = program.command(`${alias.name} [prompt_and_vars...]`)
|
|
11
|
+
.description("agent: " + alias.name)
|
|
12
|
+
.action(async (...args) => {
|
|
13
|
+
await executeAgentCmd(alias.name, args);
|
|
14
|
+
});
|
|
15
|
+
allOptions.forEach(o => agcmd.addOption(o));
|
|
16
|
+
if (features.agent[alias.name]?.variables) {
|
|
17
|
+
const rtv = features.agent[alias.name].variables?.required;
|
|
18
|
+
if (rtv) {
|
|
19
|
+
for (const name of Object.keys(rtv)) {
|
|
20
|
+
agcmd.option(`--${name} <value>`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const otv = features.agent[alias.name].variables?.optional;
|
|
24
|
+
if (otv) {
|
|
25
|
+
for (const name of Object.keys(otv)) {
|
|
26
|
+
agcmd.option(`--${name} <value>`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
8
31
|
case "task":
|
|
9
32
|
const tcmd = program.command(`${alias.name} [prompt_and_vars...]`)
|
|
10
33
|
.description("task: " + alias.name)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { parseCommandArgs } from "../options_parsers.js";
|
|
2
|
+
import { getTaskPrompt } from "../tasks/utils.js";
|
|
3
|
+
import { executeTask } from "../tasks/cmd.js";
|
|
4
|
+
async function executeAgentCmd(name, targs = []) {
|
|
5
|
+
const ca = parseCommandArgs(targs);
|
|
6
|
+
const prompt = await getTaskPrompt(name, ca.args, ca.options);
|
|
7
|
+
ca.options.isAgent = true;
|
|
8
|
+
return await executeTask(name, { prompt: prompt }, ca.options);
|
|
9
|
+
}
|
|
10
|
+
export { executeAgentCmd, };
|
|
@@ -10,7 +10,7 @@ import { initTaskSettings, isTaskSettingsInitialized, tasksSettings } from "../.
|
|
|
10
10
|
import { chat, program } from "../../cmds.js";
|
|
11
11
|
import { parseCommandArgs } from "../options_parsers.js";
|
|
12
12
|
import { runtimeDataError, runtimeError, runtimeWarning } from "../user_msgs.js";
|
|
13
|
-
import {
|
|
13
|
+
import { processOutput } from "../utils.js";
|
|
14
14
|
import { readTask } from "./read.js";
|
|
15
15
|
import { getTaskPrompt } from "./utils.js";
|
|
16
16
|
async function executeTask(name, payload, options) {
|
|
@@ -37,7 +37,7 @@ async function executeTask(name, payload, options) {
|
|
|
37
37
|
if (options?.debug || options?.backend) {
|
|
38
38
|
console.log("Agent:", colors.bold(agent.lm.name), "( " + agent.lm.providerType + " backend type)");
|
|
39
39
|
}
|
|
40
|
-
const { task, model, conf, vars, mcpServers } = await readTask(name, payload, options, agent);
|
|
40
|
+
const { task, model, conf, vars, mcpServers, taskDir } = await readTask(name, payload, options, agent);
|
|
41
41
|
if (hasSettings) {
|
|
42
42
|
if (!model?.inferParams) {
|
|
43
43
|
model.inferParams = {};
|
|
@@ -86,17 +86,18 @@ async function executeTask(name, payload, options) {
|
|
|
86
86
|
console.log("Task model:", model);
|
|
87
87
|
console.log("Task vars:", vars);
|
|
88
88
|
}
|
|
89
|
+
let emittedTokens = 0;
|
|
89
90
|
const printToken = (t) => {
|
|
90
91
|
if (options?.tokens === true) {
|
|
91
92
|
let txt = t;
|
|
92
93
|
txt = c ? t : `\x1b[100m${t}\x1b[0m`;
|
|
93
94
|
process.stdout.write(txt);
|
|
94
|
-
++i;
|
|
95
95
|
c = !c;
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
98
|
process.stdout.write(t);
|
|
99
99
|
}
|
|
100
|
+
++emittedTokens;
|
|
100
101
|
};
|
|
101
102
|
let hasTools = false;
|
|
102
103
|
if (task.def?.tools) {
|
|
@@ -113,12 +114,11 @@ async function executeTask(name, payload, options) {
|
|
|
113
114
|
return `${ts} ${color.bold(i.toString())} ${te}`;
|
|
114
115
|
};
|
|
115
116
|
const perfTimer = usePerfTimer(false);
|
|
116
|
-
let i = 0;
|
|
117
117
|
const processToken = (t) => {
|
|
118
|
-
if (
|
|
118
|
+
if (emittedTokens == 0) {
|
|
119
119
|
perfTimer.start();
|
|
120
120
|
}
|
|
121
|
-
spinner.text = formatTokenCount(
|
|
121
|
+
spinner.text = formatTokenCount(emittedTokens);
|
|
122
122
|
if (!options?.verbose && !options?.debug) {
|
|
123
123
|
if (hasThink && tpl) {
|
|
124
124
|
if (t == tpl.tags.think?.start) {
|
|
@@ -129,7 +129,7 @@ async function executeTask(name, payload, options) {
|
|
|
129
129
|
else if (t == tpl.tags.think?.end) {
|
|
130
130
|
continueWrite = true;
|
|
131
131
|
skipNextEmptyLinesToken = true;
|
|
132
|
-
let msg = color.dim("Thinking:") + ` ${
|
|
132
|
+
let msg = color.dim("Thinking:") + ` ${emittedTokens} ${color.dim("tokens")}`;
|
|
133
133
|
msg = msg + " " + color.dim(perfTimer.time());
|
|
134
134
|
spinner.info(msg);
|
|
135
135
|
return;
|
|
@@ -139,7 +139,7 @@ async function executeTask(name, payload, options) {
|
|
|
139
139
|
else {
|
|
140
140
|
if (tpl) {
|
|
141
141
|
if (t == tpl.tags.think?.end) {
|
|
142
|
-
let msg = color.dim("Thinking:") + ` ${
|
|
142
|
+
let msg = color.dim("Thinking:") + ` ${emittedTokens} ${color.dim("tokens")}`;
|
|
143
143
|
msg = msg + " " + color.dim(perfTimer.time());
|
|
144
144
|
console.log(msg);
|
|
145
145
|
}
|
|
@@ -165,17 +165,15 @@ async function executeTask(name, payload, options) {
|
|
|
165
165
|
}
|
|
166
166
|
printToken(t);
|
|
167
167
|
}
|
|
168
|
-
++
|
|
168
|
+
++emittedTokens;
|
|
169
169
|
};
|
|
170
|
-
const spinnerInit = (name) => ora(`Executing ${name} tool ...\n`);
|
|
171
|
-
let tcspinner;
|
|
172
170
|
const onToolCall = (tc) => {
|
|
173
171
|
console.log("⚒️ ", color.bold(name), "=>", `${color.yellowBright(tc.name)}`, tc.arguments);
|
|
174
|
-
tcspinner = spinnerInit(tc.name);
|
|
175
|
-
tcspinner.start();
|
|
176
172
|
};
|
|
177
173
|
const onToolCallEnd = (tr) => {
|
|
178
|
-
|
|
174
|
+
if (options?.debug) {
|
|
175
|
+
console.log(tr);
|
|
176
|
+
}
|
|
179
177
|
};
|
|
180
178
|
if (options?.onToken) {
|
|
181
179
|
task.agent.lm.onToken = options.onToken;
|
|
@@ -191,6 +189,7 @@ async function executeTask(name, payload, options) {
|
|
|
191
189
|
delete conf.model;
|
|
192
190
|
}
|
|
193
191
|
const tconf = {
|
|
192
|
+
baseDir: taskDir,
|
|
194
193
|
model: model,
|
|
195
194
|
onToolCall: onToolCall,
|
|
196
195
|
onToolCallEnd: onToolCallEnd,
|
|
@@ -249,7 +248,7 @@ async function executeTask(name, payload, options) {
|
|
|
249
248
|
}
|
|
250
249
|
if (options?.debug === true || options?.verbose === true) {
|
|
251
250
|
try {
|
|
252
|
-
console.log("
|
|
251
|
+
console.log(emittedTokens.toString(), color.dim("tokens"), out.answer.stats.tokensPerSecond, color.dim("tps"));
|
|
253
252
|
if (options?.debug === true) {
|
|
254
253
|
console.log(out.answer.stats);
|
|
255
254
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Agent } from "@agent-smith/agent";
|
|
2
|
-
import { ModelSpec
|
|
2
|
+
import { ModelSpec } from "@agent-smith/task";
|
|
3
|
+
import { NodeTask } from "@agent-smith/nodetask";
|
|
3
4
|
import { McpClient } from "../mcp.js";
|
|
5
|
+
import type { LmTaskConfig } from "../../../interfaces.js";
|
|
4
6
|
declare function readTask(name: string, payload: Record<string, any>, options: Record<string, any>, agent: Agent): Promise<{
|
|
5
|
-
task:
|
|
7
|
+
task: NodeTask;
|
|
6
8
|
model: ModelSpec;
|
|
7
|
-
conf:
|
|
9
|
+
conf: LmTaskConfig;
|
|
8
10
|
vars: Record<string, any>;
|
|
9
11
|
mcpServers: Array<McpClient>;
|
|
12
|
+
taskDir: string;
|
|
10
13
|
}>;
|
|
11
14
|
export { readTask };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { NodeTask } from "@agent-smith/nodetask";
|
|
2
3
|
import { compile, serializeGrammar } from "@intrinsicai/gbnfgen";
|
|
3
4
|
import { readTool } from "../../../db/read.js";
|
|
4
5
|
import { executeAction } from "../actions/cmd.js";
|
|
@@ -15,7 +16,8 @@ async function readTask(name, payload, options, agent) {
|
|
|
15
16
|
console.log("Payload:", payload);
|
|
16
17
|
console.log("Task options:", options);
|
|
17
18
|
}
|
|
18
|
-
const taskFileSpec = openTaskSpec(name);
|
|
19
|
+
const { taskFileSpec, taskPath } = openTaskSpec(name, options?.isAgent);
|
|
20
|
+
const taskDir = path.dirname(taskPath);
|
|
19
21
|
const opts = payload?.inferParams ? { ...options, ...payload.inferParams } : options;
|
|
20
22
|
const conf = parseTaskConfigOptions(opts);
|
|
21
23
|
if (options?.debug) {
|
|
@@ -96,9 +98,19 @@ async function readTask(name, payload, options, agent) {
|
|
|
96
98
|
return res;
|
|
97
99
|
case "task":
|
|
98
100
|
options.isToolCall = true;
|
|
101
|
+
options.isAgent = false;
|
|
99
102
|
const tres = await executeTask(toolName, params, options);
|
|
100
103
|
options.isToolCall = false;
|
|
101
104
|
return tres.answer.text;
|
|
105
|
+
case "agent":
|
|
106
|
+
options.isToolCall = true;
|
|
107
|
+
options.isAgent = true;
|
|
108
|
+
const agres = await executeTask(toolName, params, options);
|
|
109
|
+
options.isToolCall = false;
|
|
110
|
+
if (agres?.answer?.text) {
|
|
111
|
+
return agres.answer.text;
|
|
112
|
+
}
|
|
113
|
+
return agres;
|
|
102
114
|
case "workflow":
|
|
103
115
|
const wres = await executeWorkflow(toolName, params, options);
|
|
104
116
|
return wres;
|
|
@@ -115,11 +127,11 @@ async function readTask(name, payload, options, agent) {
|
|
|
115
127
|
delete taskSpec.toolsList;
|
|
116
128
|
}
|
|
117
129
|
;
|
|
118
|
-
const task = new
|
|
130
|
+
const task = new NodeTask(agent, taskSpec);
|
|
119
131
|
if (model?.inferParams?.tsGrammar) {
|
|
120
132
|
model.inferParams.grammar = serializeGrammar(await compile(model.inferParams.tsGrammar, "Grammar"));
|
|
121
133
|
delete model.inferParams.tsGrammar;
|
|
122
134
|
}
|
|
123
|
-
return { task, model, conf, vars, mcpServers };
|
|
135
|
+
return { task, model, conf, vars, mcpServers, taskDir };
|
|
124
136
|
}
|
|
125
137
|
export { readTask };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { LmTaskFileSpec } from "../../../interfaces.js";
|
|
2
|
-
declare function openTaskSpec(name: string):
|
|
2
|
+
declare function openTaskSpec(name: string, isAgent?: boolean): {
|
|
3
|
+
taskFileSpec: LmTaskFileSpec;
|
|
4
|
+
taskPath: string;
|
|
5
|
+
};
|
|
3
6
|
declare function getTaskPrompt(name: string, args: Array<string>, options: Record<string, any>): Promise<string>;
|
|
4
|
-
export {
|
|
7
|
+
export { getTaskPrompt, openTaskSpec };
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import YAML from 'yaml';
|
|
2
|
+
import { readClipboard } from '../../../cmd/sys/clipboard.js';
|
|
2
3
|
import { readTask } from "../../../cmd/sys/read_task.js";
|
|
3
4
|
import { getFeatureSpec } from "../../../state/features.js";
|
|
4
|
-
import { readClipboard } from '../../../cmd/sys/clipboard.js';
|
|
5
|
-
import { readPromptFile } from '../utils.js';
|
|
6
5
|
import { runtimeDataError } from '../user_msgs.js';
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { readPromptFile } from '../utils.js';
|
|
7
|
+
function openTaskSpec(name, isAgent = false) {
|
|
8
|
+
const ft = isAgent ? "agent" : "task";
|
|
9
|
+
const { found, path } = getFeatureSpec(name, ft);
|
|
9
10
|
if (!found) {
|
|
10
|
-
throw new Error(
|
|
11
|
+
throw new Error(`${ft} ${name} not found`);
|
|
11
12
|
}
|
|
12
13
|
const res = readTask(path);
|
|
13
14
|
if (!res.found) {
|
|
14
|
-
throw new Error(
|
|
15
|
+
throw new Error(`${ft} ${name}, ${path} not found`);
|
|
15
16
|
}
|
|
16
17
|
const taskFileSpec = YAML.parse(res.ymlTask);
|
|
17
18
|
taskFileSpec.name = name;
|
|
18
|
-
return taskFileSpec;
|
|
19
|
+
return { taskFileSpec: taskFileSpec, taskPath: path };
|
|
19
20
|
}
|
|
20
21
|
async function getTaskPrompt(name, args, options) {
|
|
21
22
|
let pr;
|
|
@@ -36,4 +37,4 @@ async function getTaskPrompt(name, args, options) {
|
|
|
36
37
|
}
|
|
37
38
|
return pr;
|
|
38
39
|
}
|
|
39
|
-
export {
|
|
40
|
+
export { getTaskPrompt, openTaskSpec };
|
package/dist/cmd/lib/tools.js
CHANGED
|
@@ -66,7 +66,7 @@ function _parseToolDoc(rawTxt, name) {
|
|
|
66
66
|
return res;
|
|
67
67
|
}
|
|
68
68
|
catch (e) {
|
|
69
|
-
throw new Error(`Error parsing tool ${name}:
|
|
69
|
+
throw new Error(`Error parsing tool ${name}: ${e} \nData:\n${rawTxt}\n`);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
function _parseTaskVariables(data) {
|
package/dist/cmd/lib/utils.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { InferenceStats } from "@locallm/types";
|
|
2
1
|
declare function readPromptFile(): string;
|
|
3
2
|
declare function processOutput(res: any): Promise<void>;
|
|
4
|
-
|
|
5
|
-
export { formatStats, processOutput, readPromptFile, };
|
|
3
|
+
export { processOutput, readPromptFile, };
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -46,12 +46,4 @@ async function processOutput(res) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
const buf = new Array();
|
|
51
|
-
buf.push(`${stats.tokensPerSecond} tps`);
|
|
52
|
-
buf.push(`- ${stats.totalTimeSeconds}s`);
|
|
53
|
-
buf.push(`(${stats.ingestionTimeSeconds}s ingestion /`);
|
|
54
|
-
buf.push(`${stats.inferenceTimeSeconds}s inference)`);
|
|
55
|
-
return buf.join(" ");
|
|
56
|
-
}
|
|
57
|
-
export { formatStats, processOutput, readPromptFile, };
|
|
49
|
+
export { processOutput, readPromptFile, };
|
|
@@ -27,26 +27,22 @@ async function executeWorkflow(wname, args, options = {}) {
|
|
|
27
27
|
switch (step.type) {
|
|
28
28
|
case "task":
|
|
29
29
|
try {
|
|
30
|
-
let
|
|
30
|
+
let tdata = {};
|
|
31
31
|
if (i == 0) {
|
|
32
|
-
|
|
32
|
+
tdata.prompt = await getTaskPrompt(step.name, taskRes.cmdArgs, options);
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
if (prevStepType) {
|
|
36
36
|
if (prevStepType == "task") {
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (!pr) {
|
|
41
|
-
if (taskRes?.prompt) {
|
|
42
|
-
pr = taskRes.prompt;
|
|
37
|
+
tdata.prompt = taskRes.answer.text;
|
|
43
38
|
}
|
|
44
39
|
}
|
|
40
|
+
tdata = taskRes;
|
|
45
41
|
}
|
|
46
|
-
if (!
|
|
42
|
+
if (!tdata?.prompt) {
|
|
47
43
|
throw new Error(`Workflow ${wname} step ${i + 1}: provide a prompt for the task ${step.name}`);
|
|
48
44
|
}
|
|
49
|
-
const tr = await executeTask(step.name,
|
|
45
|
+
const tr = await executeTask(step.name, tdata, options);
|
|
50
46
|
taskRes = { ...tr, ...taskRes };
|
|
51
47
|
}
|
|
52
48
|
catch (e) {
|
|
@@ -6,10 +6,8 @@ function _readDir(dir, ext) {
|
|
|
6
6
|
const filepath = path.join(dir, filename);
|
|
7
7
|
const isDir = fs.statSync(filepath).isDirectory();
|
|
8
8
|
if (!isDir) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
fileNames.push(filename);
|
|
12
|
-
}
|
|
9
|
+
if (ext.includes(path.extname(filename))) {
|
|
10
|
+
fileNames.push(filename);
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
13
|
});
|
|
@@ -22,6 +20,7 @@ function readFeaturesDir(dir) {
|
|
|
22
20
|
cmd: [],
|
|
23
21
|
workflow: [],
|
|
24
22
|
adaptater: [],
|
|
23
|
+
agent: [],
|
|
25
24
|
};
|
|
26
25
|
let dirpath = path.join(dir, "tasks");
|
|
27
26
|
if (fs.existsSync(dirpath)) {
|
|
@@ -37,6 +36,20 @@ function readFeaturesDir(dir) {
|
|
|
37
36
|
});
|
|
38
37
|
});
|
|
39
38
|
}
|
|
39
|
+
dirpath = path.join(dir, "agents");
|
|
40
|
+
if (fs.existsSync(dirpath)) {
|
|
41
|
+
const data = _readDir(dirpath, [".yml"]);
|
|
42
|
+
data.forEach((filename) => {
|
|
43
|
+
const parts = filename.split(".");
|
|
44
|
+
const ext = parts.pop();
|
|
45
|
+
const name = parts.join("");
|
|
46
|
+
feats.agent.push({
|
|
47
|
+
name: name,
|
|
48
|
+
path: path.join(dirpath),
|
|
49
|
+
ext: ext,
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
40
53
|
dirpath = path.join(dir, "workflows");
|
|
41
54
|
if (fs.existsSync(dirpath)) {
|
|
42
55
|
const data = _readDir(dirpath, [".yml"]);
|
package/dist/db/read.js
CHANGED
|
@@ -43,8 +43,9 @@ function readFeaturesType(type) {
|
|
|
43
43
|
}
|
|
44
44
|
function readFeatures() {
|
|
45
45
|
const feats = {
|
|
46
|
-
task: {}, action: {}, cmd: {}, workflow: {}, adaptater: {}
|
|
46
|
+
task: {}, action: {}, cmd: {}, workflow: {}, adaptater: {}, agent: {}
|
|
47
47
|
};
|
|
48
|
+
feats.agent = readFeaturesType("agent");
|
|
48
49
|
feats.task = readFeaturesType("task");
|
|
49
50
|
feats.action = readFeaturesType("action");
|
|
50
51
|
feats.cmd = readFeaturesType("cmd");
|
package/dist/db/schemas.js
CHANGED
|
@@ -19,6 +19,13 @@ const tasks = `CREATE TABLE IF NOT EXISTS task (
|
|
|
19
19
|
variables TEXT,
|
|
20
20
|
ext TEXT NOT NULL CHECK ( ext IN ('yml') )
|
|
21
21
|
);`;
|
|
22
|
+
const agents = `CREATE TABLE IF NOT EXISTS agent (
|
|
23
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
24
|
+
name TEXT UNIQUE NOT NULL,
|
|
25
|
+
path TEXT NOT NULL,
|
|
26
|
+
variables TEXT,
|
|
27
|
+
ext TEXT NOT NULL CHECK ( ext IN ('yml') )
|
|
28
|
+
);`;
|
|
22
29
|
const workflow = `CREATE TABLE IF NOT EXISTS workflow (
|
|
23
30
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
24
31
|
name TEXT UNIQUE NOT NULL,
|
|
@@ -51,12 +58,12 @@ const tool = `CREATE TABLE IF NOT EXISTS tool (
|
|
|
51
58
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
52
59
|
name TEXT UNIQUE NOT NULL,
|
|
53
60
|
spec TEXT NOT NULL,
|
|
54
|
-
type TEXT NOT NULL CHECK ( type IN ('task', 'action', 'workflow') )
|
|
61
|
+
type TEXT NOT NULL CHECK ( type IN ('agent', 'task', 'action', 'workflow') )
|
|
55
62
|
);`;
|
|
56
63
|
const alias = `CREATE TABLE IF NOT EXISTS aliases (
|
|
57
64
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
58
65
|
name TEXT UNIQUE NOT NULL,
|
|
59
|
-
type TEXT NOT NULL CHECK ( type IN ('task', 'action', 'workflow') )
|
|
66
|
+
type TEXT NOT NULL CHECK ( type IN ('agent', 'task', 'action', 'workflow') )
|
|
60
67
|
);`;
|
|
61
68
|
const backend = `CREATE TABLE IF NOT EXISTS backend (
|
|
62
69
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
@@ -93,5 +100,6 @@ const schemas = [
|
|
|
93
100
|
adaptater,
|
|
94
101
|
backend,
|
|
95
102
|
tasksSettings,
|
|
103
|
+
agents,
|
|
96
104
|
];
|
|
97
105
|
export { schemas };
|
package/dist/db/write.js
CHANGED
|
@@ -96,6 +96,9 @@ function updateAliases(feats) {
|
|
|
96
96
|
const deleteStmt = db.prepare("DELETE FROM aliases");
|
|
97
97
|
deleteStmt.run();
|
|
98
98
|
let existingAliases = new Array();
|
|
99
|
+
feats.agent.forEach((feat) => {
|
|
100
|
+
existingAliases = _updateAlias(existingAliases, feat.name, "agent");
|
|
101
|
+
});
|
|
99
102
|
feats.task.forEach((feat) => {
|
|
100
103
|
existingAliases = _updateAlias(existingAliases, feat.name, "task");
|
|
101
104
|
});
|
|
@@ -158,6 +161,16 @@ function upsertTool(name, type, toolDoc) {
|
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
163
|
function updateFeatures(feats) {
|
|
164
|
+
upsertAndCleanFeatures(feats.agent, "agent");
|
|
165
|
+
feats.agent.forEach((feat) => {
|
|
166
|
+
const { toolDoc, variables } = extractTaskToolDocAndVariables(feat.name, feat.ext, feat.path);
|
|
167
|
+
if (toolDoc.length > 0) {
|
|
168
|
+
upsertTool(feat.name, "agent", toolDoc);
|
|
169
|
+
}
|
|
170
|
+
if (Object.keys(variables.required).length > 0 || Object.keys(variables.optional).length > 0) {
|
|
171
|
+
updateVariables(feat.name, JSON.stringify(variables, null, " "));
|
|
172
|
+
}
|
|
173
|
+
});
|
|
161
174
|
upsertAndCleanFeatures(feats.task, "task");
|
|
162
175
|
feats.task.forEach((feat) => {
|
|
163
176
|
const { toolDoc, variables } = extractTaskToolDocAndVariables(feat.name, feat.ext, feat.path);
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { query } from "./cli.js";
|
|
|
4
4
|
import { buildCmds, parseCmd } from './cmd/cmds.js';
|
|
5
5
|
import { formatMode, init, inputMode, isChatMode, outputMode, runMode } from './state/state.js';
|
|
6
6
|
import { updateConfCmd } from './cmd/clicmds/updateconf.js';
|
|
7
|
+
import { resetDbCmd } from './cmd/clicmds/cmds.js';
|
|
7
8
|
async function main() {
|
|
8
9
|
const nargs = argv.length;
|
|
9
10
|
if (nargs == 2) {
|
|
@@ -14,6 +15,10 @@ async function main() {
|
|
|
14
15
|
await updateConfCmd(argv.slice(-1));
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
18
|
+
else if (argv[2] == "reset") {
|
|
19
|
+
await resetDbCmd();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
17
22
|
}
|
|
18
23
|
await init();
|
|
19
24
|
const program = await buildCmds();
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ interface FeatureSpec {
|
|
|
8
8
|
variables?: TaskVariables;
|
|
9
9
|
}
|
|
10
10
|
interface Features {
|
|
11
|
+
agent: Array<{
|
|
12
|
+
name: string;
|
|
13
|
+
path: string;
|
|
14
|
+
ext: AgentExtension;
|
|
15
|
+
}>;
|
|
11
16
|
task: Array<{
|
|
12
17
|
name: string;
|
|
13
18
|
path: string;
|
|
@@ -136,14 +141,15 @@ type OutputMode = "txt" | "clipboard";
|
|
|
136
141
|
type RunMode = "cli" | "cmd";
|
|
137
142
|
type FormatMode = "text" | "markdown";
|
|
138
143
|
type VerbosityMode = "quiet" | "verbose" | "debug";
|
|
139
|
-
type FeatureType = "task" | "action" | "cmd" | "workflow" | "adaptater";
|
|
140
|
-
type ToolType = "task" | "action" | "cmd" | "workflow";
|
|
144
|
+
type FeatureType = "task" | "agent" | "action" | "cmd" | "workflow" | "adaptater";
|
|
145
|
+
type ToolType = "task" | "agent" | "action" | "cmd" | "workflow";
|
|
141
146
|
type ActionExtension = "js" | "mjs" | "py" | "yml";
|
|
142
147
|
type TaskExtension = "yml";
|
|
148
|
+
type AgentExtension = "yml";
|
|
143
149
|
type AdaptaterExtension = "js";
|
|
144
150
|
type WorkflowExtension = "yml";
|
|
145
151
|
type CmdExtension = "js";
|
|
146
|
-
type FeatureExtension = TaskExtension | CmdExtension | ActionExtension | WorkflowExtension;
|
|
147
|
-
type AliasType = "task" | "action" | "workflow";
|
|
152
|
+
type FeatureExtension = TaskExtension | AgentExtension | CmdExtension | ActionExtension | WorkflowExtension;
|
|
153
|
+
type AliasType = "task" | "agent" | "action" | "workflow";
|
|
148
154
|
type FeatureExecutor<I = any, O = any> = (params: I, options: Record<string, any>) => Promise<O>;
|
|
149
|
-
export { InputMode, VerbosityMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, McpServerSpec, McpServerTool, InferenceBackend, ConfInferenceBackend, FeatureExecutor, WorkflowStep, TaskSettings, };
|
|
155
|
+
export { InputMode, VerbosityMode, OutputMode, RunMode, FormatMode, FeatureType, ActionExtension, TaskExtension, AgentExtension, WorkflowExtension, AdaptaterExtension, CmdExtension, FeatureSpec, Features, ConfigFile, FeatureExtension, AliasType, ToolType, Settings, DbModelDef, ModelSpec, ModelfileSpec, ModelPack, LmTaskFileSpec, LmTaskConfig, FinalLmTaskConfig, McpServerSpec, McpServerTool, InferenceBackend, ConfInferenceBackend, FeatureExecutor, WorkflowStep, TaskSettings, };
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { cmd as c1 } from "file:///home/ggg/dev/js/agent-smith-plugins/system/fs/dist/cmds/lsdir.js";
|
|
2
|
+
import { cmd as c2 } from "file:///home/ggg/dev/js/agent-smith-plugins/code/git/dist/cmds/commit.js";
|
|
3
|
+
import { cmd as c3 } from "file:///home/ggg/dev/js/agent-smith-plugins/code/git/dist/cmds/commita.js";
|
|
4
|
+
import { cmd as c4 } from "file:///home/ggg/dev/js/snowind-astro/features/cmds/design-component.js";
|
|
5
|
+
import { cmd as c5 } from "file:///home/ggg/dev/js/docdundee/package/features/dist/cmds/tsdoccmd.js";
|
|
6
|
+
|
|
7
|
+
const cmds = [ c1, c2, c3, c4, c5 ]
|
|
8
|
+
|
|
9
|
+
export { cmds }
|
package/dist/state/features.js
CHANGED
|
@@ -8,9 +8,11 @@ function readFeaturesDirs(featuresPaths) {
|
|
|
8
8
|
cmd: [],
|
|
9
9
|
workflow: [],
|
|
10
10
|
adaptater: [],
|
|
11
|
+
agent: [],
|
|
11
12
|
};
|
|
12
13
|
featuresPaths.forEach((dir) => {
|
|
13
14
|
const _f = readFeaturesDir(dir);
|
|
15
|
+
_f.agent.forEach((item) => feats.agent.push(item));
|
|
14
16
|
_f.task.forEach((item) => feats.task.push(item));
|
|
15
17
|
_f.action.forEach((item) => feats.action.push(item));
|
|
16
18
|
_f.cmd.forEach((item) => feats.cmd.push(item));
|
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.103",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@agent-smith/agent": "^0.2.0",
|
|
14
|
-
"@agent-smith/task": "^0.2.
|
|
14
|
+
"@agent-smith/task": "^0.2.1",
|
|
15
|
+
"@agent-smith/nodetask": "^0.1.0",
|
|
15
16
|
"@agent-smith/tfm": "^0.2.0",
|
|
16
17
|
"@inquirer/prompts": "^8.1.0",
|
|
17
18
|
"@intrinsicai/gbnfgen": "0.12.0",
|
|
18
19
|
"@locallm/api": "^0.7.3",
|
|
19
|
-
"@modelcontextprotocol/sdk": "^1.25.
|
|
20
|
+
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
20
21
|
"@vue/reactivity": "^3.5.26",
|
|
21
22
|
"ansi-colors": "^4.1.3",
|
|
22
23
|
"better-sqlite3": "^12.5.0",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"@types/node": "^25.0.3",
|
|
40
41
|
"openai": "^6.15.0",
|
|
41
42
|
"restmix": "^0.6.1",
|
|
42
|
-
"rollup": "^4.
|
|
43
|
+
"rollup": "^4.55.1",
|
|
43
44
|
"ts-node": "^10.9.2",
|
|
44
45
|
"tslib": "2.8.1",
|
|
45
46
|
"typescript": "^5.9.3"
|