@aigne/cli 1.27.1-0 → 1.28.0
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/CHANGELOG.md +26 -0
- package/dist/cli.d.ts +6 -1
- package/dist/cli.js +1 -1
- package/dist/commands/app.d.ts +17 -0
- package/dist/commands/app.js +218 -68
- package/dist/commands/connect.d.ts +1 -1
- package/dist/commands/create.d.ts +1 -1
- package/dist/commands/observe.d.ts +1 -1
- package/dist/commands/run.js +2 -1
- package/dist/commands/serve-mcp.d.ts +8 -1
- package/dist/commands/serve-mcp.js +13 -10
- package/dist/commands/test.d.ts +1 -1
- package/dist/utils/download.js +2 -0
- package/dist/utils/run-with-aigne.d.ts +1 -0
- package/dist/utils/run-with-aigne.js +4 -3
- package/dist/utils/serve-mcp.js +1 -1
- package/package.json +15 -15
- package/templates/default/aigne.yaml +1 -1
- package/templates/default/chat.yaml +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.28.0](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.27.0...cli-v1.28.0) (2025-07-31)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **cli:** support dynamic download and execution of doc-smith app ([#293](https://github.com/AIGNE-io/aigne-framework/issues/293)) ([4c40077](https://github.com/AIGNE-io/aigne-framework/commit/4c40077bacef076bc4b098879e948ef866218e39))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @aigne/agent-library bumped to 1.21.7
|
|
16
|
+
* @aigne/agentic-memory bumped to 1.0.7
|
|
17
|
+
* @aigne/aigne-hub bumped to 0.3.1
|
|
18
|
+
* @aigne/anthropic bumped to 0.10.3
|
|
19
|
+
* @aigne/bedrock bumped to 0.8.7
|
|
20
|
+
* @aigne/core bumped to 1.40.0
|
|
21
|
+
* @aigne/deepseek bumped to 0.7.7
|
|
22
|
+
* @aigne/default-memory bumped to 1.0.7
|
|
23
|
+
* @aigne/gemini bumped to 0.8.7
|
|
24
|
+
* @aigne/ollama bumped to 0.7.7
|
|
25
|
+
* @aigne/open-router bumped to 0.7.7
|
|
26
|
+
* @aigne/openai bumped to 0.10.7
|
|
27
|
+
* @aigne/xai bumped to 0.7.7
|
|
28
|
+
|
|
3
29
|
## [1.27.0](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.26.0...cli-v1.27.0) (2025-07-30)
|
|
4
30
|
|
|
5
31
|
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ function getAIGNEFilePath() {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
const aigneFilePath = getAIGNEFilePath();
|
|
19
|
-
createAIGNECommand({ aigneFilePath })
|
|
19
|
+
export default createAIGNECommand({ aigneFilePath })
|
|
20
20
|
.parseAsync(hideBin([...process.argv.slice(0, 2), ...process.argv.slice(aigneFilePath ? 3 : 2)]))
|
|
21
21
|
.catch((error) => {
|
|
22
22
|
console.log(""); // Add an empty line for better readability
|
package/dist/commands/app.d.ts
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
import { AIGNE, type Message } from "@aigne/core";
|
|
1
2
|
import type { CommandModule } from "yargs";
|
|
2
3
|
export declare function createAppCommands(): CommandModule[];
|
|
4
|
+
export declare function invokeCLIAgentFromDir(options: {
|
|
5
|
+
dir: string;
|
|
6
|
+
agent: string;
|
|
7
|
+
input: Message & {
|
|
8
|
+
input?: string[];
|
|
9
|
+
format?: "yaml" | "json";
|
|
10
|
+
};
|
|
11
|
+
}): Promise<void>;
|
|
12
|
+
export declare function loadApplication({ name, dir, }: {
|
|
13
|
+
name: string;
|
|
14
|
+
dir?: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
aigne: AIGNE;
|
|
17
|
+
dir: string;
|
|
18
|
+
version: string;
|
|
19
|
+
}>;
|
package/dist/commands/app.js
CHANGED
|
@@ -1,88 +1,232 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
|
-
import {
|
|
3
|
+
import { readFile, stat, writeFile } from "node:fs/promises";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import {
|
|
5
|
+
import { extname, join } from "node:path";
|
|
6
|
+
import { isatty } from "node:tty";
|
|
7
|
+
import { AIAgent, AIGNE, readAllString } from "@aigne/core";
|
|
8
|
+
import { pick } from "@aigne/core/utils/type-utils.js";
|
|
9
|
+
import { Listr, PRESET_TIMER } from "@aigne/listr2";
|
|
7
10
|
import { joinURL } from "ufo";
|
|
11
|
+
import { parse } from "yaml";
|
|
8
12
|
import { ZodObject, ZodString } from "zod";
|
|
9
13
|
import { availableModels } from "../constants.js";
|
|
10
14
|
import { downloadAndExtract } from "../utils/download.js";
|
|
11
|
-
import {
|
|
15
|
+
import { loadAIGNE } from "../utils/load-aigne.js";
|
|
16
|
+
import { runAgentWithAIGNE, stdinHasData } from "../utils/run-with-aigne.js";
|
|
17
|
+
import { serveMCPServerFromDir } from "./serve-mcp.js";
|
|
12
18
|
const NPM_PACKAGE_CACHE_TIME_MS = 1000 * 60 * 60 * 24; // 1 day
|
|
19
|
+
const builtinApps = [
|
|
20
|
+
{
|
|
21
|
+
name: "doc-smith",
|
|
22
|
+
describe: "Generate professional documents by doc-smith",
|
|
23
|
+
aliases: ["docsmith", "doc"],
|
|
24
|
+
},
|
|
25
|
+
];
|
|
13
26
|
export function createAppCommands() {
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// TODO: support more types
|
|
27
|
-
type: config instanceof ZodString ? "string" : "string",
|
|
28
|
-
description: config.description,
|
|
29
|
-
});
|
|
30
|
-
if (!(config.isNullable() || config.isOptional())) {
|
|
31
|
-
yargs.demandOption(option);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}, async (argv) => {
|
|
35
|
-
try {
|
|
36
|
-
await runAgentWithAIGNE(aigne, agent, { input: argv });
|
|
37
|
-
}
|
|
38
|
-
finally {
|
|
39
|
-
await aigne.shutdown();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
yargs.version('hello world');
|
|
44
|
-
return yargs.demandCommand();
|
|
45
|
-
},
|
|
46
|
-
handler: () => { },
|
|
27
|
+
return builtinApps.map((app) => ({
|
|
28
|
+
command: app.name,
|
|
29
|
+
describe: app.describe,
|
|
30
|
+
aliases: app.aliases,
|
|
31
|
+
builder: async (yargs) => {
|
|
32
|
+
const { aigne, dir, version } = await loadApplication({ name: app.name });
|
|
33
|
+
yargs.command(serveMcpCommandModule({ name: app.name, dir }));
|
|
34
|
+
for (const agent of aigne.cli?.agents ?? []) {
|
|
35
|
+
yargs.command(agentCommandModule({ dir, agent }));
|
|
36
|
+
}
|
|
37
|
+
yargs.version(`${app.name} v${version}`);
|
|
38
|
+
return yargs.demandCommand();
|
|
47
39
|
},
|
|
48
|
-
|
|
40
|
+
handler: () => { },
|
|
41
|
+
}));
|
|
49
42
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
const serveMcpCommandModule = ({ name, dir, }) => ({
|
|
44
|
+
command: "serve-mcp",
|
|
45
|
+
describe: `Serve ${name} a MCP server (streamable http)`,
|
|
46
|
+
builder: (yargs) => {
|
|
47
|
+
return yargs
|
|
48
|
+
.option("host", {
|
|
49
|
+
describe: "Host to run the MCP server on, use 0.0.0.0 to publicly expose the server",
|
|
50
|
+
type: "string",
|
|
51
|
+
default: "localhost",
|
|
52
|
+
})
|
|
53
|
+
.option("port", {
|
|
54
|
+
describe: "Port to run the MCP server on",
|
|
55
|
+
type: "number",
|
|
56
|
+
})
|
|
57
|
+
.option("pathname", {
|
|
58
|
+
describe: "Pathname to the service",
|
|
59
|
+
type: "string",
|
|
60
|
+
default: "/mcp",
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
handler: async (options) => {
|
|
64
|
+
await serveMCPServerFromDir({ ...options, dir });
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const agentCommandModule = ({ dir, agent, }) => {
|
|
68
|
+
const inputSchema = agent.inputSchema instanceof ZodObject ? agent.inputSchema.shape : {};
|
|
69
|
+
return {
|
|
70
|
+
command: agent.name,
|
|
71
|
+
describe: agent.description || "",
|
|
72
|
+
builder: (yargs) => {
|
|
73
|
+
for (const [option, config] of Object.entries(inputSchema)) {
|
|
74
|
+
yargs.option(option, {
|
|
75
|
+
// TODO: support more types
|
|
76
|
+
type: "string",
|
|
77
|
+
description: config.description,
|
|
78
|
+
});
|
|
79
|
+
if (!(config.isNullable() || config.isOptional())) {
|
|
80
|
+
yargs.demandOption(option);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return yargs
|
|
84
|
+
.option("input", {
|
|
85
|
+
type: "array",
|
|
86
|
+
description: "Input to the agent, use @<file> to read from a file",
|
|
87
|
+
alias: ["i"],
|
|
88
|
+
})
|
|
89
|
+
.option("format", {
|
|
90
|
+
type: "string",
|
|
91
|
+
description: 'Input format, can be "json" or "yaml"',
|
|
92
|
+
choices: ["json", "yaml"],
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
handler: async (input) => {
|
|
96
|
+
await invokeCLIAgentFromDir({ dir, agent: agent.name, input });
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export async function invokeCLIAgentFromDir(options) {
|
|
101
|
+
const aigne = await loadAIGNE(options.dir);
|
|
102
|
+
try {
|
|
103
|
+
const agent = aigne.cli.agents[options.agent];
|
|
104
|
+
assert(agent, `Agent ${options.agent} not found in ${options.dir}`);
|
|
105
|
+
const inputSchema = agent.inputSchema instanceof ZodObject ? agent.inputSchema.shape : {};
|
|
106
|
+
const input = Object.fromEntries(await Promise.all(Object.entries(pick(options.input, Object.keys(inputSchema))).map(async ([key, val]) => {
|
|
107
|
+
if (typeof val === "string" && val.startsWith("@")) {
|
|
108
|
+
const schema = inputSchema[key];
|
|
109
|
+
val = await readFileAsInput(val, {
|
|
110
|
+
format: schema instanceof ZodString ? "raw" : undefined,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return [key, val];
|
|
114
|
+
})));
|
|
115
|
+
const rawInput = options.input.input ||
|
|
116
|
+
(isatty(process.stdin.fd) || !(await stdinHasData())
|
|
117
|
+
? null
|
|
118
|
+
: [await readAllString(process.stdin)].filter(Boolean));
|
|
119
|
+
if (rawInput) {
|
|
120
|
+
for (const raw of rawInput) {
|
|
121
|
+
const parsed = raw.startsWith("@")
|
|
122
|
+
? await readFileAsInput(raw, { format: options.input.format })
|
|
123
|
+
: raw;
|
|
124
|
+
if (typeof parsed !== "string") {
|
|
125
|
+
Object.assign(input, parsed);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const inputKey = agent instanceof AIAgent ? agent.inputKey : undefined;
|
|
129
|
+
if (inputKey) {
|
|
130
|
+
Object.assign(input, { [inputKey]: parsed });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
await runAgentWithAIGNE(aigne, agent, { input });
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
await aigne.shutdown();
|
|
58
139
|
}
|
|
59
|
-
return AIGNE.load(info.dir, { models: availableModels() });
|
|
60
140
|
}
|
|
61
|
-
async function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
141
|
+
async function readFileAsInput(value, { format } = {}) {
|
|
142
|
+
if (value.startsWith("@")) {
|
|
143
|
+
const ext = extname(value);
|
|
144
|
+
value = await readFile(value.slice(1), "utf8");
|
|
145
|
+
if (!format) {
|
|
146
|
+
if (ext === ".json")
|
|
147
|
+
format = "json";
|
|
148
|
+
else if (ext === ".yaml" || ext === ".yml")
|
|
149
|
+
format = "yaml";
|
|
67
150
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
151
|
+
}
|
|
152
|
+
if (format === "json") {
|
|
153
|
+
return JSON.parse(value);
|
|
154
|
+
}
|
|
155
|
+
else if (format === "yaml") {
|
|
156
|
+
return parse(value);
|
|
157
|
+
}
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
export async function loadApplication({ name, dir, }) {
|
|
161
|
+
name = `@aigne/${name}`;
|
|
162
|
+
dir ??= join(homedir(), ".aigne", "registry.npmjs.org", name);
|
|
163
|
+
const check = await isInstallationAvailable(dir);
|
|
164
|
+
if (check?.available) {
|
|
71
165
|
return {
|
|
72
|
-
|
|
166
|
+
aigne: await AIGNE.load(dir, { models: availableModels() }),
|
|
73
167
|
dir,
|
|
74
|
-
|
|
168
|
+
version: check.version,
|
|
75
169
|
};
|
|
76
|
-
|
|
170
|
+
}
|
|
171
|
+
const result = await new Listr([
|
|
172
|
+
{
|
|
173
|
+
title: "Fetching application metadata",
|
|
174
|
+
task: async (ctx) => {
|
|
175
|
+
const info = await getNpmTgzInfo(name);
|
|
176
|
+
Object.assign(ctx, info);
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
title: "Downloading application",
|
|
181
|
+
skip: (ctx) => ctx.version === check?.version,
|
|
182
|
+
task: async (ctx) => {
|
|
183
|
+
await downloadAndExtract(ctx.url, dir, { strip: 1 });
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
title: "Installing dependencies",
|
|
188
|
+
skip: (ctx) => ctx.version === check?.version,
|
|
189
|
+
task: async () => {
|
|
190
|
+
await installDependencies(dir);
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
], {
|
|
194
|
+
rendererOptions: {
|
|
195
|
+
collapseSubtasks: false,
|
|
196
|
+
showErrorMessage: false,
|
|
197
|
+
timer: PRESET_TIMER,
|
|
198
|
+
},
|
|
199
|
+
}).run();
|
|
200
|
+
return {
|
|
201
|
+
aigne: await AIGNE.load(dir, { models: availableModels() }),
|
|
202
|
+
dir,
|
|
203
|
+
version: result.version,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
async function isInstallationAvailable(dir, { cacheTimeMs = NPM_PACKAGE_CACHE_TIME_MS } = {}) {
|
|
207
|
+
const s = await stat(join(dir, "package.json")).catch(() => null);
|
|
208
|
+
if (!s)
|
|
209
|
+
return null;
|
|
210
|
+
const version = safeParseJSON(await readFile(join(dir, "package.json"), "utf-8"))?.version;
|
|
211
|
+
if (!version)
|
|
212
|
+
return null;
|
|
213
|
+
const installedAt = safeParseJSON(await readFile(join(dir, ".aigne-cli.json"), "utf-8").catch(() => "{}"))?.installedAt;
|
|
214
|
+
if (!installedAt)
|
|
215
|
+
return null;
|
|
77
216
|
const now = Date.now();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
217
|
+
const available = installedAt ? now - installedAt < cacheTimeMs : false;
|
|
218
|
+
return { version, available };
|
|
219
|
+
}
|
|
220
|
+
async function installDependencies(dir) {
|
|
221
|
+
const { stderr, status } = spawnSync("npm", ["install", "--omit", "dev"], {
|
|
222
|
+
cwd: dir,
|
|
223
|
+
stdio: "pipe",
|
|
224
|
+
});
|
|
225
|
+
if (status !== 0) {
|
|
226
|
+
console.error(stderr.toString());
|
|
227
|
+
throw new Error(`Failed to install dependencies in ${dir}`);
|
|
84
228
|
}
|
|
85
|
-
|
|
229
|
+
await writeFile(join(dir, ".aigne-cli.json"), JSON.stringify({ installedAt: Date.now() }, null, 2));
|
|
86
230
|
}
|
|
87
231
|
async function getNpmTgzInfo(name) {
|
|
88
232
|
const res = await fetch(joinURL("https://registry.npmjs.org", name));
|
|
@@ -90,9 +234,15 @@ async function getNpmTgzInfo(name) {
|
|
|
90
234
|
throw new Error(`Failed to fetch package info for ${name}: ${res.statusText}`);
|
|
91
235
|
const data = await res.json();
|
|
92
236
|
const latestVersion = data["dist-tags"].latest;
|
|
93
|
-
const
|
|
237
|
+
const url = data.versions[latestVersion].dist.tarball;
|
|
94
238
|
return {
|
|
95
239
|
version: latestVersion,
|
|
96
|
-
|
|
240
|
+
url,
|
|
97
241
|
};
|
|
98
242
|
}
|
|
243
|
+
function safeParseJSON(raw) {
|
|
244
|
+
try {
|
|
245
|
+
return JSON.parse(raw);
|
|
246
|
+
}
|
|
247
|
+
catch { }
|
|
248
|
+
}
|
|
@@ -2,5 +2,5 @@ import type { CommandModule } from "yargs";
|
|
|
2
2
|
interface ConnectOptions {
|
|
3
3
|
url?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function createConnectCommand(): CommandModule<
|
|
5
|
+
export declare function createConnectCommand(): CommandModule<unknown, ConnectOptions>;
|
|
6
6
|
export {};
|
|
@@ -2,5 +2,5 @@ import type { CommandModule } from "yargs";
|
|
|
2
2
|
interface CreateOptions {
|
|
3
3
|
path: string;
|
|
4
4
|
}
|
|
5
|
-
export declare function createCreateCommand(): CommandModule<
|
|
5
|
+
export declare function createCreateCommand(): CommandModule<unknown, CreateOptions>;
|
|
6
6
|
export {};
|
package/dist/commands/run.js
CHANGED
|
@@ -31,7 +31,8 @@ export function createRunCommand({ aigneFilePath, } = {}) {
|
|
|
31
31
|
.option("cache-dir", {
|
|
32
32
|
describe: "Directory to download the package to (defaults to the ~/.aigne/xxx)",
|
|
33
33
|
type: "string",
|
|
34
|
-
})
|
|
34
|
+
})
|
|
35
|
+
.strict(false);
|
|
35
36
|
},
|
|
36
37
|
handler: async (argv) => {
|
|
37
38
|
const options = argv;
|
|
@@ -5,7 +5,14 @@ interface ServeMCPOptions {
|
|
|
5
5
|
port?: number;
|
|
6
6
|
pathname: string;
|
|
7
7
|
}
|
|
8
|
+
export declare const DEFAULT_PORT: () => number;
|
|
8
9
|
export declare function createServeMCPCommand({ aigneFilePath, }?: {
|
|
9
10
|
aigneFilePath?: string;
|
|
10
|
-
}): CommandModule<
|
|
11
|
+
}): CommandModule<unknown, ServeMCPOptions>;
|
|
12
|
+
export declare function serveMCPServerFromDir(options: {
|
|
13
|
+
dir: string;
|
|
14
|
+
host: string;
|
|
15
|
+
port?: number;
|
|
16
|
+
pathname: string;
|
|
17
|
+
}): Promise<void>;
|
|
11
18
|
export {};
|
|
@@ -2,7 +2,7 @@ import { isAbsolute, resolve } from "node:path";
|
|
|
2
2
|
import { tryOrThrow } from "@aigne/core/utils/type-utils.js";
|
|
3
3
|
import { loadAIGNE } from "../utils/load-aigne.js";
|
|
4
4
|
import { serveMCPServer } from "../utils/serve-mcp.js";
|
|
5
|
-
const DEFAULT_PORT = () => tryOrThrow(() => {
|
|
5
|
+
export const DEFAULT_PORT = () => tryOrThrow(() => {
|
|
6
6
|
const { PORT } = process.env;
|
|
7
7
|
if (!PORT)
|
|
8
8
|
return 3000;
|
|
@@ -41,15 +41,18 @@ export function createServeMCPCommand({ aigneFilePath, } = {}) {
|
|
|
41
41
|
handler: async (options) => {
|
|
42
42
|
const path = aigneFilePath || options.path;
|
|
43
43
|
const absolutePath = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
44
|
-
|
|
45
|
-
const aigne = await loadAIGNE(absolutePath);
|
|
46
|
-
await serveMCPServer({
|
|
47
|
-
aigne,
|
|
48
|
-
host: options.host,
|
|
49
|
-
port,
|
|
50
|
-
pathname: options.pathname,
|
|
51
|
-
});
|
|
52
|
-
console.log(`MCP server is running on http://${options.host}:${port}${options.pathname}`);
|
|
44
|
+
await serveMCPServerFromDir({ ...options, dir: absolutePath });
|
|
53
45
|
},
|
|
54
46
|
};
|
|
55
47
|
}
|
|
48
|
+
export async function serveMCPServerFromDir(options) {
|
|
49
|
+
const port = options.port || DEFAULT_PORT();
|
|
50
|
+
const aigne = await loadAIGNE(options.dir);
|
|
51
|
+
await serveMCPServer({
|
|
52
|
+
aigne,
|
|
53
|
+
host: options.host,
|
|
54
|
+
port,
|
|
55
|
+
pathname: options.pathname,
|
|
56
|
+
});
|
|
57
|
+
console.log(`MCP server is running on http://${options.host}:${port}${options.pathname}`);
|
|
58
|
+
}
|
package/dist/commands/test.d.ts
CHANGED
package/dist/utils/download.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
1
2
|
import { Readable } from "node:stream";
|
|
2
3
|
import { finished } from "node:stream/promises";
|
|
3
4
|
import { x } from "tar";
|
|
@@ -12,6 +13,7 @@ export async function downloadAndExtract(url, dir, options = {}) {
|
|
|
12
13
|
throw new Error(`Failed to download package from ${url}: Unexpected to get empty response`);
|
|
13
14
|
}
|
|
14
15
|
try {
|
|
16
|
+
await mkdir(dir, { recursive: true });
|
|
15
17
|
await finished(Readable.fromWeb(response.body).pipe(x({ C: dir, ...options })));
|
|
16
18
|
}
|
|
17
19
|
catch (error) {
|
|
@@ -7,10 +7,11 @@ import { exists } from "@aigne/agent-library/utils/fs.js";
|
|
|
7
7
|
import { AIAgent, AIGNE, DEFAULT_OUTPUT_KEY, readAllString, UserAgent, } from "@aigne/core";
|
|
8
8
|
import { loadModel } from "@aigne/core/loader/index.js";
|
|
9
9
|
import { getLevelFromEnv, LogLevel, logger } from "@aigne/core/utils/logger.js";
|
|
10
|
-
import { flat, isEmpty, tryOrThrow
|
|
10
|
+
import { flat, isEmpty, tryOrThrow } from "@aigne/core/utils/type-utils.js";
|
|
11
11
|
import chalk from "chalk";
|
|
12
12
|
import { parse } from "yaml";
|
|
13
13
|
import yargs from "yargs";
|
|
14
|
+
import { hideBin } from "yargs/helpers";
|
|
14
15
|
import { ZodError, ZodObject, z } from "zod";
|
|
15
16
|
import { availableModels } from "../constants.js";
|
|
16
17
|
import { TerminalTracer } from "../tracer/terminal.js";
|
|
@@ -157,7 +158,7 @@ export async function runWithAIGNE(agentCreator, { argv = process.argv, chatLoop
|
|
|
157
158
|
})
|
|
158
159
|
.alias("h", "help")
|
|
159
160
|
.alias("v", "version")
|
|
160
|
-
.parseAsync(argv)
|
|
161
|
+
.parseAsync(hideBin(argv))
|
|
161
162
|
.catch((error) => {
|
|
162
163
|
console.error(`${chalk.red("Error:")} ${error.message}`);
|
|
163
164
|
process.exit(1);
|
|
@@ -209,7 +210,7 @@ export async function runAgentWithAIGNE(aigne, agent, { outputKey, chatLoopOptio
|
|
|
209
210
|
}
|
|
210
211
|
return { result };
|
|
211
212
|
}
|
|
212
|
-
async function stdinHasData() {
|
|
213
|
+
export async function stdinHasData() {
|
|
213
214
|
const stats = await promisify(fstat)(0);
|
|
214
215
|
return stats.isFIFO() || stats.isFile();
|
|
215
216
|
}
|
package/dist/utils/serve-mcp.js
CHANGED
|
@@ -72,7 +72,7 @@ export function createMcpServer(aigne) {
|
|
|
72
72
|
capabilities: { tools: {} },
|
|
73
73
|
instructions: aigne.description,
|
|
74
74
|
});
|
|
75
|
-
for (const agent of aigne.agents) {
|
|
75
|
+
for (const agent of aigne.mcpServer?.agents ?? []) {
|
|
76
76
|
const schema = agent.inputSchema;
|
|
77
77
|
if (!(schema instanceof ZodObject))
|
|
78
78
|
throw new Error("Agent input schema must be a ZodObject");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"description": "cli for AIGNE framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -70,20 +70,20 @@
|
|
|
70
70
|
"yaml": "^2.8.0",
|
|
71
71
|
"yargs": "^18.0.0",
|
|
72
72
|
"zod": "^3.25.67",
|
|
73
|
-
"@aigne/
|
|
74
|
-
"@aigne/
|
|
75
|
-
"@aigne/aigne-hub": "^0.3.
|
|
76
|
-
"@aigne/anthropic": "^0.10.
|
|
77
|
-
"@aigne/bedrock": "^0.8.
|
|
78
|
-
"@aigne/core": "^1.
|
|
79
|
-
"@aigne/
|
|
80
|
-
"@aigne/
|
|
81
|
-
"@aigne/
|
|
82
|
-
"@aigne/
|
|
83
|
-
"@aigne/
|
|
84
|
-
"@aigne/
|
|
85
|
-
"@aigne/
|
|
86
|
-
"@aigne/
|
|
73
|
+
"@aigne/agentic-memory": "^1.0.7",
|
|
74
|
+
"@aigne/agent-library": "^1.21.7",
|
|
75
|
+
"@aigne/aigne-hub": "^0.3.1",
|
|
76
|
+
"@aigne/anthropic": "^0.10.3",
|
|
77
|
+
"@aigne/bedrock": "^0.8.7",
|
|
78
|
+
"@aigne/core": "^1.40.0",
|
|
79
|
+
"@aigne/default-memory": "^1.0.7",
|
|
80
|
+
"@aigne/gemini": "^0.8.7",
|
|
81
|
+
"@aigne/deepseek": "^0.7.7",
|
|
82
|
+
"@aigne/observability-api": "^0.8.2",
|
|
83
|
+
"@aigne/ollama": "^0.7.7",
|
|
84
|
+
"@aigne/open-router": "^0.7.7",
|
|
85
|
+
"@aigne/openai": "^0.10.7",
|
|
86
|
+
"@aigne/xai": "^0.7.7"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@types/archiver": "^6.0.3",
|