@agent-smith/cli 0.0.66 → 0.0.68
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/mcp.d.ts → mcp.d.ts} +2 -1
- package/dist/cmd/lib/{tasks/mcp.js → mcp.js} +6 -3
- package/dist/cmd/lib/options_parsers.js +3 -0
- package/dist/cmd/lib/tasks/cmd.js +12 -5
- package/dist/cmd/lib/utils.d.ts +1 -2
- package/dist/cmd/lib/utils.js +3 -13
- package/dist/index.js +13 -1
- package/dist/main.d.ts +2 -1
- package/dist/main.js +2 -1
- package/package.json +2 -1
|
@@ -5,7 +5,8 @@ declare class McpServer {
|
|
|
5
5
|
transport: StdioClientTransport;
|
|
6
6
|
client: Client;
|
|
7
7
|
authorizedTools: Array<string> | null;
|
|
8
|
-
|
|
8
|
+
tools: Record<string, LmTaskToolSpec>;
|
|
9
|
+
constructor(command: string, args: Array<string>, authorizedTools?: Array<string> | null);
|
|
9
10
|
start(): Promise<void>;
|
|
10
11
|
stop(): Promise<void>;
|
|
11
12
|
extractTools(): Promise<Array<LmTaskToolSpec>>;
|
|
@@ -4,7 +4,8 @@ class McpServer {
|
|
|
4
4
|
transport;
|
|
5
5
|
client;
|
|
6
6
|
authorizedTools = null;
|
|
7
|
-
|
|
7
|
+
tools = {};
|
|
8
|
+
constructor(command, args, authorizedTools = null) {
|
|
8
9
|
this.transport = new StdioClientTransport({
|
|
9
10
|
command: command,
|
|
10
11
|
args: args
|
|
@@ -37,10 +38,11 @@ class McpServer {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
const exec = async (args) => {
|
|
40
|
-
const
|
|
41
|
+
const payload = {
|
|
41
42
|
name: tool.name,
|
|
42
43
|
arguments: args,
|
|
43
|
-
}
|
|
44
|
+
};
|
|
45
|
+
const res = await this.client.callTool(payload);
|
|
44
46
|
return res;
|
|
45
47
|
};
|
|
46
48
|
const t = {
|
|
@@ -49,6 +51,7 @@ class McpServer {
|
|
|
49
51
|
arguments: args,
|
|
50
52
|
execute: exec
|
|
51
53
|
};
|
|
54
|
+
this.tools[tool.name] = t;
|
|
52
55
|
toolSpecs.push(t);
|
|
53
56
|
}
|
|
54
57
|
return toolSpecs;
|
|
@@ -29,6 +29,9 @@ function parseTaskConfigOptions(options) {
|
|
|
29
29
|
if (options?.repeat_penalty !== undefined) {
|
|
30
30
|
optionsInferParams.repeat_penalty = options.repeat_penalty;
|
|
31
31
|
}
|
|
32
|
+
if (options?.images) {
|
|
33
|
+
optionsInferParams.images = options.images;
|
|
34
|
+
}
|
|
32
35
|
if (options?.model !== undefined) {
|
|
33
36
|
conf.modelname = options.model;
|
|
34
37
|
}
|
|
@@ -11,11 +11,11 @@ import { isChatMode, runMode } from "../../../state/state.js";
|
|
|
11
11
|
import { program } from "../../cmds.js";
|
|
12
12
|
import { executeAction } from "../actions/cmd.js";
|
|
13
13
|
import { parseCommandArgs, parseTaskConfigOptions } from "../options_parsers.js";
|
|
14
|
-
import { runtimeDataError } from "../user_msgs.js";
|
|
15
|
-
import { formatStats, readPromptFile } from "../utils.js";
|
|
14
|
+
import { runtimeDataError, runtimeWarning } from "../user_msgs.js";
|
|
15
|
+
import { formatStats, processOutput, readPromptFile } from "../utils.js";
|
|
16
16
|
import { executeWorkflow } from "../workflows/cmd.js";
|
|
17
17
|
import { configureTaskModel, mergeInferParams } from "./conf.js";
|
|
18
|
-
import { McpServer } from "
|
|
18
|
+
import { McpServer } from "../mcp.js";
|
|
19
19
|
import { openTaskSpec } from "./utils.js";
|
|
20
20
|
async function executeTask(name, payload, options, quiet, expert) {
|
|
21
21
|
await initAgent();
|
|
@@ -24,7 +24,8 @@ async function executeTask(name, payload, options, quiet, expert) {
|
|
|
24
24
|
console.log("Task options:", options);
|
|
25
25
|
}
|
|
26
26
|
const taskFileSpec = openTaskSpec(name);
|
|
27
|
-
const
|
|
27
|
+
const opts = payload?.inferParams ? { ...options, ...payload.inferParams } : options;
|
|
28
|
+
const conf = parseTaskConfigOptions(opts);
|
|
28
29
|
if (options.debug) {
|
|
29
30
|
console.log("conf:", conf);
|
|
30
31
|
}
|
|
@@ -212,6 +213,7 @@ async function executeTask(name, payload, options, quiet, expert) {
|
|
|
212
213
|
throw new Error(`executing task: ${name} (${err})`);
|
|
213
214
|
}
|
|
214
215
|
mcpServers.forEach(async (s) => await s.stop());
|
|
216
|
+
await processOutput(out);
|
|
215
217
|
if (isChatMode.value) {
|
|
216
218
|
const data = { message: '>', default: "" };
|
|
217
219
|
const prompt = await input(data);
|
|
@@ -229,7 +231,12 @@ async function executeTask(name, payload, options, quiet, expert) {
|
|
|
229
231
|
}
|
|
230
232
|
}
|
|
231
233
|
if (options?.debug === true || options?.verbose === true) {
|
|
232
|
-
|
|
234
|
+
try {
|
|
235
|
+
console.log("\n", formatStats(out.answer.stats));
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
runtimeWarning("Error formating stats:", `${e}`);
|
|
239
|
+
}
|
|
233
240
|
}
|
|
234
241
|
return out;
|
|
235
242
|
}
|
package/dist/cmd/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { InferenceStats } from "@locallm/types";
|
|
2
2
|
declare function readPromptFile(): string;
|
|
3
3
|
declare function processOutput(res: any): Promise<void>;
|
|
4
|
-
declare function parseInputOptions(options: any): Promise<string | null>;
|
|
5
4
|
declare function formatStats(stats: InferenceStats): string;
|
|
6
|
-
export { formatStats,
|
|
5
|
+
export { formatStats, processOutput, readPromptFile, };
|
package/dist/cmd/lib/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { marked } from "../../agent.js";
|
|
2
|
-
import { formatMode, initFilepaths,
|
|
3
|
-
import {
|
|
2
|
+
import { formatMode, initFilepaths, outputMode, promptfilePath } from "../../state/state.js";
|
|
3
|
+
import { writeToClipboard } from "../sys/clipboard.js";
|
|
4
4
|
import { readFile } from "../sys/read.js";
|
|
5
5
|
import { splitThinking } from "../../utils/text.js";
|
|
6
6
|
function readPromptFile() {
|
|
@@ -38,16 +38,6 @@ async function processOutput(res) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
async function parseInputOptions(options) {
|
|
42
|
-
let out = null;
|
|
43
|
-
if (options?.Ic == true || inputMode.value == "clipboard") {
|
|
44
|
-
out = await readClipboard();
|
|
45
|
-
}
|
|
46
|
-
else if (options.Pf || inputMode.value == "promptfile") {
|
|
47
|
-
out = readPromptFile();
|
|
48
|
-
}
|
|
49
|
-
return out;
|
|
50
|
-
}
|
|
51
41
|
function formatStats(stats) {
|
|
52
42
|
const buf = new Array();
|
|
53
43
|
buf.push(`${stats.tokensPerSecond} tps`);
|
|
@@ -56,4 +46,4 @@ function formatStats(stats) {
|
|
|
56
46
|
buf.push(`${stats.inferenceTimeSeconds}s inference)`);
|
|
57
47
|
return buf.join(" ");
|
|
58
48
|
}
|
|
59
|
-
export { formatStats,
|
|
49
|
+
export { formatStats, processOutput, readPromptFile, };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { argv } from 'process';
|
|
|
3
3
|
import { initAgent } from './agent.js';
|
|
4
4
|
import { query } from "./cli.js";
|
|
5
5
|
import { buildCmds, parseCmd } from './cmd/cmds.js';
|
|
6
|
-
import { initState, isChatMode, runMode } from './state/state.js';
|
|
6
|
+
import { formatMode, initState, inputMode, isChatMode, outputMode, runMode } from './state/state.js';
|
|
7
7
|
import { updateConfCmd } from './cmd/clicmds/update.js';
|
|
8
8
|
async function main() {
|
|
9
9
|
const nargs = argv.length;
|
|
@@ -24,6 +24,18 @@ async function main() {
|
|
|
24
24
|
if (options?.chat === true) {
|
|
25
25
|
isChatMode.value = true;
|
|
26
26
|
}
|
|
27
|
+
if (options?.clipboardInput !== undefined) {
|
|
28
|
+
inputMode.value = "clipboard";
|
|
29
|
+
}
|
|
30
|
+
if (options?.inputFile !== undefined) {
|
|
31
|
+
inputMode.value = "promptfile";
|
|
32
|
+
}
|
|
33
|
+
if (options?.markdownOutput !== undefined) {
|
|
34
|
+
formatMode.value = "markdown";
|
|
35
|
+
}
|
|
36
|
+
if (options?.clipboardOutput !== undefined) {
|
|
37
|
+
outputMode.value = "clipboard";
|
|
38
|
+
}
|
|
27
39
|
});
|
|
28
40
|
switch (runMode.value) {
|
|
29
41
|
case "cli":
|
package/dist/main.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ 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
14
|
import { displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions } from "./cmd/options.js";
|
|
15
|
-
|
|
15
|
+
import { McpServer } from "./cmd/lib/mcp.js";
|
|
16
|
+
export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, LmTaskConf, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions, McpServer, };
|
package/dist/main.js
CHANGED
|
@@ -11,4 +11,5 @@ import { extractToolDoc } from "./cmd/lib/tools.js";
|
|
|
11
11
|
import { openTaskSpec } from "./cmd/lib/tasks/utils.js";
|
|
12
12
|
import { extractBetweenTags, splitThinking } from "./utils/text.js";
|
|
13
13
|
import { displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions } from "./cmd/options.js";
|
|
14
|
-
|
|
14
|
+
import { McpServer } from "./cmd/lib/mcp.js";
|
|
15
|
+
export { execute, run, executeTask, executeAction, executeWorkflow, writeToClipboard, initAgent, initState, pluginDataDir, usePerfTimer, parseCommandArgs, extractToolDoc, openTaskSpec, extractBetweenTags, splitThinking, displayOptions, ioOptions, inferenceOptions, taskOptions, actionOptions, workflowOptions, McpServer, };
|
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.68",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"buildrl": "rm -rf dist/* && rollup -c",
|
|
8
8
|
"build": "rm -rf dist/* && tsc",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"@agent-smith/tfm": "^0.1.2",
|
|
17
17
|
"@inquirer/prompts": "^7.5.3",
|
|
18
18
|
"@inquirer/select": "^4.2.3",
|
|
19
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
19
20
|
"@vue/reactivity": "^3.5.16",
|
|
20
21
|
"ansi-colors": "^4.1.3",
|
|
21
22
|
"better-sqlite3": "^11.10.0",
|