@aigne/cli 1.60.0-beta → 1.74.0-beta
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/README.md +12 -12
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/bunwrapper.cjs +22 -0
- package/dist/bunwrapper.d.cts +1 -0
- package/dist/bunwrapper.d.mts +1 -0
- package/dist/bunwrapper.mjs +23 -0
- package/dist/bunwrapper.mjs.map +1 -0
- package/dist/cli.cjs +42 -0
- package/dist/cli.d.cts +9 -0
- package/dist/cli.d.cts.map +1 -0
- package/dist/cli.d.mts +10 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +41 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/commands/aigne.cjs +23 -0
- package/dist/commands/aigne.mjs +22 -0
- package/dist/commands/aigne.mjs.map +1 -0
- package/dist/commands/app/agent.cjs +117 -0
- package/dist/commands/app/agent.mjs +113 -0
- package/dist/commands/app/agent.mjs.map +1 -0
- package/dist/commands/app/app.cjs +92 -0
- package/dist/commands/app/app.mjs +90 -0
- package/dist/commands/app/app.mjs.map +1 -0
- package/dist/commands/app/cli.cjs +6 -0
- package/dist/commands/app/cli.d.cts +1 -0
- package/dist/commands/app/cli.d.mts +1 -0
- package/dist/commands/app/cli.mjs +8 -0
- package/dist/commands/app/cli.mjs.map +1 -0
- package/dist/commands/app/upgrade.cjs +243 -0
- package/dist/commands/app/upgrade.mjs +240 -0
- package/dist/commands/app/upgrade.mjs.map +1 -0
- package/dist/commands/app.cjs +53 -0
- package/dist/commands/app.mjs +53 -0
- package/dist/commands/app.mjs.map +1 -0
- package/dist/commands/create.cjs +66 -0
- package/dist/commands/create.mjs +65 -0
- package/dist/commands/create.mjs.map +1 -0
- package/dist/commands/deploy.cjs +237 -0
- package/dist/commands/deploy.mjs +237 -0
- package/dist/commands/deploy.mjs.map +1 -0
- package/dist/commands/eval.cjs +88 -0
- package/dist/commands/eval.mjs +88 -0
- package/dist/commands/eval.mjs.map +1 -0
- package/dist/commands/hub.cjs +297 -0
- package/dist/commands/hub.mjs +294 -0
- package/dist/commands/hub.mjs.map +1 -0
- package/dist/commands/observe.cjs +49 -0
- package/dist/commands/observe.mjs +46 -0
- package/dist/commands/observe.mjs.map +1 -0
- package/dist/commands/run-skill.cjs +84 -0
- package/dist/commands/run-skill.mjs +81 -0
- package/dist/commands/run-skill.mjs.map +1 -0
- package/dist/commands/run.cjs +172 -0
- package/dist/commands/run.mjs +171 -0
- package/dist/commands/run.mjs.map +1 -0
- package/dist/commands/serve-mcp.cjs +68 -0
- package/dist/commands/serve-mcp.mjs +67 -0
- package/dist/commands/serve-mcp.mjs.map +1 -0
- package/dist/commands/test.cjs +40 -0
- package/dist/commands/test.mjs +39 -0
- package/dist/commands/test.mjs.map +1 -0
- package/dist/constants.cjs +28 -0
- package/dist/constants.d.cts +9 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +9 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +24 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/global.d.cjs +0 -0
- package/dist/global.d.cts +6 -0
- package/dist/global.d.cts.map +1 -0
- package/dist/global.d.mts +6 -0
- package/dist/global.d.mts.map +1 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/tracer/terminal.cjs +336 -0
- package/dist/tracer/terminal.mjs +332 -0
- package/dist/tracer/terminal.mjs.map +1 -0
- package/dist/type.cjs +0 -0
- package/dist/type.d.cts +10 -0
- package/dist/type.d.cts.map +1 -0
- package/dist/type.d.mts +10 -0
- package/dist/type.d.mts.map +1 -0
- package/dist/type.mjs +1 -0
- package/dist/ui/utils/terminal-input.cjs +145 -0
- package/dist/ui/utils/terminal-input.mjs +144 -0
- package/dist/ui/utils/terminal-input.mjs.map +1 -0
- package/dist/ui/utils/text-buffer.cjs +865 -0
- package/dist/ui/utils/text-buffer.mjs +865 -0
- package/dist/ui/utils/text-buffer.mjs.map +1 -0
- package/dist/ui/utils/text-utils.cjs +85 -0
- package/dist/ui/utils/text-utils.mjs +78 -0
- package/dist/ui/utils/text-utils.mjs.map +1 -0
- package/dist/utils/agent-v1.cjs +180 -0
- package/dist/utils/agent-v1.d.cts +138 -0
- package/dist/utils/agent-v1.d.cts.map +1 -0
- package/dist/utils/agent-v1.d.mts +138 -0
- package/dist/utils/agent-v1.d.mts.map +1 -0
- package/dist/utils/agent-v1.mjs +179 -0
- package/dist/utils/agent-v1.mjs.map +1 -0
- package/dist/utils/aigne-hub/constants.cjs +22 -0
- package/dist/utils/aigne-hub/constants.mjs +18 -0
- package/dist/utils/aigne-hub/constants.mjs.map +1 -0
- package/dist/utils/aigne-hub/credential.cjs +179 -0
- package/dist/utils/aigne-hub/credential.mjs +175 -0
- package/dist/utils/aigne-hub/credential.mjs.map +1 -0
- package/dist/utils/aigne-hub/crypto.cjs +41 -0
- package/dist/utils/aigne-hub/crypto.mjs +33 -0
- package/dist/utils/aigne-hub/crypto.mjs.map +1 -0
- package/dist/utils/aigne-hub/model.cjs +112 -0
- package/dist/utils/aigne-hub/model.d.cts +19 -0
- package/dist/utils/aigne-hub/model.d.cts.map +1 -0
- package/dist/utils/aigne-hub/model.d.mts +19 -0
- package/dist/utils/aigne-hub/model.d.mts.map +1 -0
- package/dist/utils/aigne-hub/model.mjs +106 -0
- package/dist/utils/aigne-hub/model.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/file.cjs +64 -0
- package/dist/utils/aigne-hub/store/file.mjs +64 -0
- package/dist/utils/aigne-hub/store/file.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/index.cjs +37 -0
- package/dist/utils/aigne-hub/store/index.mjs +37 -0
- package/dist/utils/aigne-hub/store/index.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/keytar.cjs +61 -0
- package/dist/utils/aigne-hub/store/keytar.mjs +61 -0
- package/dist/utils/aigne-hub/store/keytar.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/migrate.cjs +46 -0
- package/dist/utils/aigne-hub/store/migrate.mjs +45 -0
- package/dist/utils/aigne-hub/store/migrate.mjs.map +1 -0
- package/dist/utils/aigne-hub/type.d.cts +18 -0
- package/dist/utils/aigne-hub/type.d.cts.map +1 -0
- package/dist/utils/aigne-hub/type.d.mts +18 -0
- package/dist/utils/aigne-hub/type.d.mts.map +1 -0
- package/dist/utils/aigne-hub-user.cjs +11 -0
- package/dist/utils/aigne-hub-user.d.cts +23 -0
- package/dist/utils/aigne-hub-user.d.cts.map +1 -0
- package/dist/utils/aigne-hub-user.d.mts +23 -0
- package/dist/utils/aigne-hub-user.d.mts.map +1 -0
- package/dist/utils/aigne-hub-user.mjs +11 -0
- package/dist/utils/aigne-hub-user.mjs.map +1 -0
- package/dist/utils/ascii-logo.cjs +30 -0
- package/dist/utils/ascii-logo.d.cts +5 -0
- package/dist/utils/ascii-logo.d.cts.map +1 -0
- package/dist/utils/ascii-logo.d.mts +5 -0
- package/dist/utils/ascii-logo.d.mts.map +1 -0
- package/dist/utils/{ascii-logo.js → ascii-logo.mjs} +13 -3
- package/dist/utils/ascii-logo.mjs.map +1 -0
- package/dist/utils/download.cjs +25 -0
- package/dist/utils/download.d.cts +7 -0
- package/dist/utils/download.d.cts.map +1 -0
- package/dist/utils/download.d.mts +7 -0
- package/dist/utils/download.d.mts.map +1 -0
- package/dist/utils/download.mjs +25 -0
- package/dist/utils/download.mjs.map +1 -0
- package/dist/utils/evaluation/core.cjs +84 -0
- package/dist/utils/evaluation/core.mjs +84 -0
- package/dist/utils/evaluation/core.mjs.map +1 -0
- package/dist/utils/evaluation/dataset.cjs +47 -0
- package/dist/utils/evaluation/dataset.mjs +46 -0
- package/dist/utils/evaluation/dataset.mjs.map +1 -0
- package/dist/utils/evaluation/evaluator.cjs +109 -0
- package/dist/utils/evaluation/{evaluator.js → evaluator.mjs} +48 -45
- package/dist/utils/evaluation/evaluator.mjs.map +1 -0
- package/dist/utils/evaluation/reporter.cjs +225 -0
- package/dist/utils/evaluation/reporter.mjs +220 -0
- package/dist/utils/evaluation/reporter.mjs.map +1 -0
- package/dist/utils/evaluation/runner.cjs +85 -0
- package/dist/utils/evaluation/runner.mjs +85 -0
- package/dist/utils/evaluation/runner.mjs.map +1 -0
- package/dist/utils/get-url-origin.cjs +12 -0
- package/dist/utils/get-url-origin.d.cts +5 -0
- package/dist/utils/get-url-origin.d.cts.map +1 -0
- package/dist/utils/get-url-origin.d.mts +5 -0
- package/dist/utils/get-url-origin.d.mts.map +1 -0
- package/dist/utils/get-url-origin.mjs +12 -0
- package/dist/utils/get-url-origin.mjs.map +1 -0
- package/dist/utils/inquirer/checkbox.cjs +265 -0
- package/dist/utils/inquirer/checkbox.mjs +262 -0
- package/dist/utils/inquirer/checkbox.mjs.map +1 -0
- package/dist/utils/listr.cjs +226 -0
- package/dist/utils/listr.d.cts +71 -0
- package/dist/utils/listr.d.cts.map +1 -0
- package/dist/utils/listr.d.mts +71 -0
- package/dist/utils/listr.d.mts.map +1 -0
- package/dist/utils/listr.mjs +222 -0
- package/dist/utils/listr.mjs.map +1 -0
- package/dist/utils/load-aigne.cjs +77 -0
- package/dist/utils/load-aigne.d.cts +29 -0
- package/dist/utils/load-aigne.d.cts.map +1 -0
- package/dist/utils/load-aigne.d.mts +29 -0
- package/dist/utils/load-aigne.d.mts.map +1 -0
- package/dist/utils/load-aigne.mjs +74 -0
- package/dist/utils/load-aigne.mjs.map +1 -0
- package/dist/utils/run-chat-loop.cjs +90 -0
- package/dist/utils/run-chat-loop.d.cts +20 -0
- package/dist/utils/run-chat-loop.d.cts.map +1 -0
- package/dist/utils/run-chat-loop.d.mts +20 -0
- package/dist/utils/run-chat-loop.d.mts.map +1 -0
- package/dist/utils/run-chat-loop.mjs +89 -0
- package/dist/utils/run-chat-loop.mjs.map +1 -0
- package/dist/utils/run-with-aigne.cjs +131 -0
- package/dist/utils/run-with-aigne.d.cts +46 -0
- package/dist/utils/run-with-aigne.d.cts.map +1 -0
- package/dist/utils/run-with-aigne.d.mts +46 -0
- package/dist/utils/run-with-aigne.d.mts.map +1 -0
- package/dist/utils/run-with-aigne.mjs +126 -0
- package/dist/utils/run-with-aigne.mjs.map +1 -0
- package/dist/utils/serve-mcp.cjs +91 -0
- package/dist/utils/serve-mcp.d.cts +20 -0
- package/dist/utils/serve-mcp.d.cts.map +1 -0
- package/dist/utils/serve-mcp.d.mts +20 -0
- package/dist/utils/serve-mcp.d.mts.map +1 -0
- package/dist/utils/serve-mcp.mjs +89 -0
- package/dist/utils/serve-mcp.mjs.map +1 -0
- package/dist/utils/spinner.cjs +19 -0
- package/dist/utils/spinner.d.cts +5 -0
- package/dist/utils/spinner.d.cts.map +1 -0
- package/dist/utils/spinner.d.mts +5 -0
- package/dist/utils/spinner.d.mts.map +1 -0
- package/dist/utils/spinner.mjs +19 -0
- package/dist/utils/spinner.mjs.map +1 -0
- package/dist/utils/string-utils.cjs +11 -0
- package/dist/utils/string-utils.d.cts +5 -0
- package/dist/utils/string-utils.d.cts.map +1 -0
- package/dist/utils/string-utils.d.mts +5 -0
- package/dist/utils/string-utils.d.mts.map +1 -0
- package/dist/utils/string-utils.mjs +10 -0
- package/dist/utils/string-utils.mjs.map +1 -0
- package/dist/utils/time.cjs +14 -0
- package/dist/utils/time.d.cts +5 -0
- package/dist/utils/time.d.cts.map +1 -0
- package/dist/utils/time.d.mts +5 -0
- package/dist/utils/time.d.mts.map +1 -0
- package/dist/utils/time.mjs +14 -0
- package/dist/utils/time.mjs.map +1 -0
- package/dist/utils/url.cjs +8 -0
- package/dist/utils/url.d.cts +5 -0
- package/dist/utils/url.d.cts.map +1 -0
- package/dist/utils/url.d.mts +5 -0
- package/dist/utils/url.d.mts.map +1 -0
- package/dist/utils/url.mjs +8 -0
- package/dist/utils/url.mjs.map +1 -0
- package/dist/utils/yargs.cjs +191 -0
- package/dist/utils/yargs.d.cts +96 -0
- package/dist/utils/yargs.d.cts.map +1 -0
- package/dist/utils/yargs.d.mts +96 -0
- package/dist/utils/yargs.d.mts.map +1 -0
- package/dist/utils/yargs.mjs +186 -0
- package/dist/utils/yargs.mjs.map +1 -0
- package/package.json +122 -45
- package/CHANGELOG.md +0 -5019
- package/dist/bunwrapper.d.ts +0 -2
- package/dist/bunwrapper.js +0 -18
- package/dist/cli.d.ts +0 -7
- package/dist/cli.js +0 -42
- package/dist/commands/aigne.d.ts +0 -4
- package/dist/commands/aigne.js +0 -35
- package/dist/commands/app/agent.d.ts +0 -26
- package/dist/commands/app/agent.js +0 -122
- package/dist/commands/app/app.d.ts +0 -7
- package/dist/commands/app/app.js +0 -92
- package/dist/commands/app/cli.d.ts +0 -1
- package/dist/commands/app/cli.js +0 -2
- package/dist/commands/app/upgrade.d.ts +0 -54
- package/dist/commands/app/upgrade.js +0 -236
- package/dist/commands/app.d.ts +0 -4
- package/dist/commands/app.js +0 -54
- package/dist/commands/create.d.ts +0 -6
- package/dist/commands/create.js +0 -74
- package/dist/commands/deploy.d.ts +0 -11
- package/dist/commands/deploy.js +0 -255
- package/dist/commands/eval.d.ts +0 -11
- package/dist/commands/eval.js +0 -110
- package/dist/commands/hub.d.ts +0 -3
- package/dist/commands/hub.js +0 -323
- package/dist/commands/observe.d.ts +0 -7
- package/dist/commands/observe.js +0 -41
- package/dist/commands/run-skill.d.ts +0 -6
- package/dist/commands/run-skill.js +0 -102
- package/dist/commands/run.d.ts +0 -9
- package/dist/commands/run.js +0 -187
- package/dist/commands/serve-mcp.d.ts +0 -20
- package/dist/commands/serve-mcp.js +0 -67
- package/dist/commands/test.d.ts +0 -9
- package/dist/commands/test.js +0 -33
- package/dist/constants.d.ts +0 -7
- package/dist/constants.js +0 -21
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/tracer/terminal.d.ts +0 -62
- package/dist/tracer/terminal.js +0 -404
- package/dist/type.d.ts +0 -5
- package/dist/type.js +0 -1
- package/dist/ui/utils/terminal-input.d.ts +0 -19
- package/dist/ui/utils/terminal-input.js +0 -123
- package/dist/ui/utils/text-buffer.d.ts +0 -87
- package/dist/ui/utils/text-buffer.js +0 -1059
- package/dist/ui/utils/text-utils.d.ts +0 -37
- package/dist/ui/utils/text-utils.js +0 -185
- package/dist/utils/agent-v1.d.ts +0 -134
- package/dist/utils/agent-v1.js +0 -213
- package/dist/utils/aigne-hub/constants.d.ts +0 -6
- package/dist/utils/aigne-hub/constants.js +0 -12
- package/dist/utils/aigne-hub/credential.d.ts +0 -20
- package/dist/utils/aigne-hub/credential.js +0 -182
- package/dist/utils/aigne-hub/crypto.d.ts +0 -4
- package/dist/utils/aigne-hub/crypto.js +0 -30
- package/dist/utils/aigne-hub/model.d.ts +0 -13
- package/dist/utils/aigne-hub/model.js +0 -122
- package/dist/utils/aigne-hub/store/file.d.ts +0 -15
- package/dist/utils/aigne-hub/store/file.js +0 -69
- package/dist/utils/aigne-hub/store/index.d.ts +0 -5
- package/dist/utils/aigne-hub/store/index.js +0 -43
- package/dist/utils/aigne-hub/store/keytar.d.ts +0 -15
- package/dist/utils/aigne-hub/store/keytar.js +0 -67
- package/dist/utils/aigne-hub/store/migrate.d.ts +0 -2
- package/dist/utils/aigne-hub/store/migrate.js +0 -57
- package/dist/utils/aigne-hub/type.d.ts +0 -38
- package/dist/utils/aigne-hub/type.js +0 -1
- package/dist/utils/aigne-hub-user.d.ts +0 -16
- package/dist/utils/aigne-hub-user.js +0 -10
- package/dist/utils/ascii-logo.d.ts +0 -1
- package/dist/utils/download.d.ts +0 -3
- package/dist/utils/download.js +0 -19
- package/dist/utils/evaluation/core.d.ts +0 -8
- package/dist/utils/evaluation/core.js +0 -83
- package/dist/utils/evaluation/dataset.d.ts +0 -15
- package/dist/utils/evaluation/dataset.js +0 -61
- package/dist/utils/evaluation/evaluator.d.ts +0 -9
- package/dist/utils/evaluation/reporter.d.ts +0 -28
- package/dist/utils/evaluation/reporter.js +0 -221
- package/dist/utils/evaluation/runner.d.ts +0 -16
- package/dist/utils/evaluation/runner.js +0 -129
- package/dist/utils/evaluation/type.d.ts +0 -69
- package/dist/utils/evaluation/type.js +0 -1
- package/dist/utils/get-url-origin.d.ts +0 -1
- package/dist/utils/get-url-origin.js +0 -8
- package/dist/utils/inquirer/checkbox.d.ts +0 -55
- package/dist/utils/inquirer/checkbox.js +0 -319
- package/dist/utils/listr.d.ts +0 -64
- package/dist/utils/listr.js +0 -265
- package/dist/utils/load-aigne.d.ts +0 -18
- package/dist/utils/load-aigne.js +0 -80
- package/dist/utils/run-chat-loop.d.ts +0 -15
- package/dist/utils/run-chat-loop.js +0 -87
- package/dist/utils/run-with-aigne.d.ts +0 -27
- package/dist/utils/run-with-aigne.js +0 -157
- package/dist/utils/serve-mcp.d.ts +0 -9
- package/dist/utils/serve-mcp.js +0 -93
- package/dist/utils/spinner.d.ts +0 -1
- package/dist/utils/spinner.js +0 -14
- package/dist/utils/string-utils.d.ts +0 -1
- package/dist/utils/string-utils.js +0 -4
- package/dist/utils/time.d.ts +0 -1
- package/dist/utils/time.js +0 -12
- package/dist/utils/url.d.ts +0 -1
- package/dist/utils/url.js +0 -3
- package/dist/utils/yargs.d.ts +0 -94
- package/dist/utils/yargs.js +0 -210
package/dist/utils/serve-mcp.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { AIAgent } from "@aigne/core";
|
|
2
|
-
import { promiseWithResolvers } from "@aigne/core/utils/promise.js";
|
|
3
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5
|
-
import express, { json, Router } from "express";
|
|
6
|
-
import { ZodObject } from "zod";
|
|
7
|
-
import { AIGNE_CLI_VERSION } from "../constants.js";
|
|
8
|
-
export async function serveMCPServer({ pathname = "/mcp", aigne, host = "localhost", port, }) {
|
|
9
|
-
const app = express();
|
|
10
|
-
app.use(json());
|
|
11
|
-
const router = Router();
|
|
12
|
-
app.use(router);
|
|
13
|
-
router.post(pathname, async (req, res) => {
|
|
14
|
-
try {
|
|
15
|
-
const server = createMcpServer(aigne);
|
|
16
|
-
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
|
17
|
-
await server.connect(transport);
|
|
18
|
-
await transport.handleRequest(req, res, req.body);
|
|
19
|
-
res.on("close", async () => {
|
|
20
|
-
await transport.close();
|
|
21
|
-
await server.close();
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
console.error("Error handling MCP request:", error);
|
|
26
|
-
if (!res.headersSent) {
|
|
27
|
-
res.status(500).json({
|
|
28
|
-
jsonrpc: "2.0",
|
|
29
|
-
error: {
|
|
30
|
-
code: -32603,
|
|
31
|
-
message: error.message,
|
|
32
|
-
},
|
|
33
|
-
id: null,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
router.get(pathname, async (_, res) => {
|
|
39
|
-
res.writeHead(405).end(JSON.stringify({
|
|
40
|
-
jsonrpc: "2.0",
|
|
41
|
-
error: {
|
|
42
|
-
code: -32000,
|
|
43
|
-
message: "Method not allowed.",
|
|
44
|
-
},
|
|
45
|
-
id: null,
|
|
46
|
-
}));
|
|
47
|
-
});
|
|
48
|
-
router.delete(pathname, async (_, res) => {
|
|
49
|
-
res.writeHead(405).end(JSON.stringify({
|
|
50
|
-
jsonrpc: "2.0",
|
|
51
|
-
error: {
|
|
52
|
-
code: -32000,
|
|
53
|
-
message: "Method not allowed.",
|
|
54
|
-
},
|
|
55
|
-
id: null,
|
|
56
|
-
}));
|
|
57
|
-
});
|
|
58
|
-
const { promise, resolve, reject } = promiseWithResolvers();
|
|
59
|
-
const httpServer = app.listen(port, host, (error) => {
|
|
60
|
-
if (error)
|
|
61
|
-
reject(error);
|
|
62
|
-
resolve();
|
|
63
|
-
});
|
|
64
|
-
await promise;
|
|
65
|
-
return httpServer;
|
|
66
|
-
}
|
|
67
|
-
export function createMcpServer(aigne) {
|
|
68
|
-
const server = new McpServer({
|
|
69
|
-
name: aigne.name || "aigne-mcp-server",
|
|
70
|
-
version: AIGNE_CLI_VERSION,
|
|
71
|
-
}, {
|
|
72
|
-
capabilities: { tools: {} },
|
|
73
|
-
instructions: aigne.description,
|
|
74
|
-
});
|
|
75
|
-
for (const agent of aigne.mcpServer?.agents ?? []) {
|
|
76
|
-
const schema = agent.inputSchema;
|
|
77
|
-
if (!(schema instanceof ZodObject))
|
|
78
|
-
throw new Error("Agent input schema must be a ZodObject");
|
|
79
|
-
server.tool(agent.name, agent.description || "", schema.shape, async (input) => {
|
|
80
|
-
const result = await aigne.invoke(agent, input);
|
|
81
|
-
return {
|
|
82
|
-
content: [
|
|
83
|
-
{
|
|
84
|
-
type: "text",
|
|
85
|
-
text: (agent instanceof AIAgent && result[agent.outputKey]) ||
|
|
86
|
-
JSON.stringify(result),
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return server;
|
|
93
|
-
}
|
package/dist/utils/spinner.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function withSpinner<T>(message: string, fn: () => Promise<T>): Promise<T>;
|
package/dist/utils/spinner.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Spinner } from "@aigne/listr2";
|
|
2
|
-
export async function withSpinner(message, fn) {
|
|
3
|
-
const spinner = new Spinner();
|
|
4
|
-
spinner.start(() => {
|
|
5
|
-
process.stdout.write(`\r\x1b[K${spinner.fetch()} ${message}`);
|
|
6
|
-
});
|
|
7
|
-
try {
|
|
8
|
-
return await fn();
|
|
9
|
-
}
|
|
10
|
-
finally {
|
|
11
|
-
spinner.stop();
|
|
12
|
-
process.stdout.write("\r\x1b[K"); // Clear the spinner line
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function highlightUrl(str: string): string;
|
package/dist/utils/time.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function parseDuration(duration: number): string;
|
package/dist/utils/time.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export function parseDuration(duration) {
|
|
2
|
-
const milliseconds = duration % 1000;
|
|
3
|
-
const seconds = Math.floor(duration / 1000);
|
|
4
|
-
const minutes = Math.floor(seconds / 60);
|
|
5
|
-
const ms = Math.round(milliseconds / 10)
|
|
6
|
-
.toString()
|
|
7
|
-
.padStart(2, "0");
|
|
8
|
-
const s = `${Number.parseFloat(`${seconds % 60}.${ms}`)}s`;
|
|
9
|
-
if (minutes === 0)
|
|
10
|
-
return s;
|
|
11
|
-
return `${minutes}m${s}`;
|
|
12
|
-
}
|
package/dist/utils/url.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isUrl(s: string): boolean;
|
package/dist/utils/url.js
DELETED
package/dist/utils/yargs.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { type Agent, type Message } from "@aigne/core";
|
|
2
|
-
import { LogLevel } from "@aigne/core/utils/logger.js";
|
|
3
|
-
import type { Argv } from "yargs";
|
|
4
|
-
import { ZodType } from "zod";
|
|
5
|
-
export type InferArgv<T> = T extends Argv<infer U> ? U : never;
|
|
6
|
-
export declare const withRunAgentCommonOptions: (yargs: Argv) => Argv<{
|
|
7
|
-
interactive: boolean;
|
|
8
|
-
} & {
|
|
9
|
-
"session-id": string | undefined;
|
|
10
|
-
} & {
|
|
11
|
-
model: string | undefined;
|
|
12
|
-
} & {
|
|
13
|
-
"image-model": string | undefined;
|
|
14
|
-
} & {
|
|
15
|
-
temperature: number | undefined;
|
|
16
|
-
} & {
|
|
17
|
-
"top-p": number | undefined;
|
|
18
|
-
} & {
|
|
19
|
-
"presence-penalty": number | undefined;
|
|
20
|
-
} & {
|
|
21
|
-
"frequency-penalty": number | undefined;
|
|
22
|
-
} & {
|
|
23
|
-
input: string[] | undefined;
|
|
24
|
-
} & {
|
|
25
|
-
"input-file": string[] | undefined;
|
|
26
|
-
} & {
|
|
27
|
-
format: string | undefined;
|
|
28
|
-
} & {
|
|
29
|
-
output: string | undefined;
|
|
30
|
-
} & {
|
|
31
|
-
"output-key": string;
|
|
32
|
-
} & {
|
|
33
|
-
force: boolean;
|
|
34
|
-
} & {
|
|
35
|
-
"log-level": LogLevel;
|
|
36
|
-
} & {
|
|
37
|
-
"aigne-hub-url": string | undefined;
|
|
38
|
-
}>;
|
|
39
|
-
type _AgentRunCommonOptions = Partial<InferArgv<ReturnType<typeof withAgentInputSchema>>>;
|
|
40
|
-
/** Convert literal string types like 'foo-bar' to 'FooBar' */
|
|
41
|
-
type PascalCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${Capitalize<T>}${PascalCase<U>}` : Capitalize<S>;
|
|
42
|
-
/** Convert literal string types like 'foo-bar' to 'fooBar' */
|
|
43
|
-
type CamelCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${T}${PascalCase<U>}` : S;
|
|
44
|
-
/** Convert literal string types like 'foo-bar' to 'fooBar', allowing all `PropertyKey` types */
|
|
45
|
-
type CamelCaseKey<K extends PropertyKey> = K extends string ? Exclude<CamelCase<K>, ""> : K;
|
|
46
|
-
export type AgentRunCommonOptions = {
|
|
47
|
-
[key in keyof _AgentRunCommonOptions as CamelCaseKey<key>]: _AgentRunCommonOptions[key];
|
|
48
|
-
};
|
|
49
|
-
export declare function inferZodType(type: ZodType, opts?: {
|
|
50
|
-
array?: boolean;
|
|
51
|
-
optional?: boolean;
|
|
52
|
-
}): {
|
|
53
|
-
type: "string" | "number" | "boolean";
|
|
54
|
-
array?: boolean;
|
|
55
|
-
optional?: boolean;
|
|
56
|
-
};
|
|
57
|
-
export declare function withAgentInputSchema(yargs: Argv, options: Pick<Agent, "inputSchema"> & {
|
|
58
|
-
optionalInputs?: string[];
|
|
59
|
-
}): Argv<{
|
|
60
|
-
interactive: boolean;
|
|
61
|
-
} & {
|
|
62
|
-
"session-id": string | undefined;
|
|
63
|
-
} & {
|
|
64
|
-
model: string | undefined;
|
|
65
|
-
} & {
|
|
66
|
-
"image-model": string | undefined;
|
|
67
|
-
} & {
|
|
68
|
-
temperature: number | undefined;
|
|
69
|
-
} & {
|
|
70
|
-
"top-p": number | undefined;
|
|
71
|
-
} & {
|
|
72
|
-
"presence-penalty": number | undefined;
|
|
73
|
-
} & {
|
|
74
|
-
"frequency-penalty": number | undefined;
|
|
75
|
-
} & {
|
|
76
|
-
input: string[] | undefined;
|
|
77
|
-
} & {
|
|
78
|
-
"input-file": string[] | undefined;
|
|
79
|
-
} & {
|
|
80
|
-
format: string | undefined;
|
|
81
|
-
} & {
|
|
82
|
-
output: string | undefined;
|
|
83
|
-
} & {
|
|
84
|
-
"output-key": string;
|
|
85
|
-
} & {
|
|
86
|
-
force: boolean;
|
|
87
|
-
} & {
|
|
88
|
-
"log-level": LogLevel;
|
|
89
|
-
} & {
|
|
90
|
-
"aigne-hub-url": string | undefined;
|
|
91
|
-
}>;
|
|
92
|
-
export declare function parseAgentInput(i: Message & AgentRunCommonOptions, agent: Agent): Promise<any>;
|
|
93
|
-
export declare function stdinHasData(): Promise<boolean>;
|
|
94
|
-
export {};
|
package/dist/utils/yargs.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { fstat } from "node:fs";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { basename, extname } from "node:path";
|
|
4
|
-
import { isatty } from "node:tty";
|
|
5
|
-
import { promisify } from "node:util";
|
|
6
|
-
import { availableImageModels, availableModels, } from "@aigne/aigne-hub";
|
|
7
|
-
import { AIAgent, ChatModel, DEFAULT_OUTPUT_KEY, readAllString, } from "@aigne/core";
|
|
8
|
-
import { getLevelFromEnv, LogLevel, logger } from "@aigne/core/utils/logger.js";
|
|
9
|
-
import { flat, pick, tryOrThrow } from "@aigne/core/utils/type-utils.js";
|
|
10
|
-
import { parse } from "yaml";
|
|
11
|
-
import z, { ZodAny, ZodArray, ZodBoolean, ZodError, ZodNumber, ZodObject, ZodString, ZodType, ZodUnknown, } from "zod";
|
|
12
|
-
const MODEL_OPTIONS_GROUP_NAME = "Model Options";
|
|
13
|
-
export const withRunAgentCommonOptions = (yargs) => yargs
|
|
14
|
-
.option("interactive", {
|
|
15
|
-
describe: "Run in interactive chat mode",
|
|
16
|
-
type: "boolean",
|
|
17
|
-
default: false,
|
|
18
|
-
alias: ["chat"],
|
|
19
|
-
})
|
|
20
|
-
.option("session-id", {
|
|
21
|
-
describe: "Session ID for chat-based agents to maintain context across interactions",
|
|
22
|
-
type: "string",
|
|
23
|
-
})
|
|
24
|
-
.option("model", {
|
|
25
|
-
group: MODEL_OPTIONS_GROUP_NAME,
|
|
26
|
-
describe: `AI model to use in format 'provider[/model]' where model is optional. Examples: 'openai' or 'openai/gpt-4o-mini'. Available providers: ${formatModelsName(availableModels())} (default: openai)`,
|
|
27
|
-
type: "string",
|
|
28
|
-
})
|
|
29
|
-
.option("image-model", {
|
|
30
|
-
group: MODEL_OPTIONS_GROUP_NAME,
|
|
31
|
-
describe: `Image model to use in format 'provider[/model]' where model is optional. Examples: 'openai' or 'openai/gpt-image-1'. Available providers: ${formatModelsName(availableImageModels())} (default: openai)`,
|
|
32
|
-
type: "string",
|
|
33
|
-
})
|
|
34
|
-
.option("temperature", {
|
|
35
|
-
group: MODEL_OPTIONS_GROUP_NAME,
|
|
36
|
-
describe: "Temperature for the model (controls randomness, higher values produce more random outputs). Range: 0.0-2.0",
|
|
37
|
-
type: "number",
|
|
38
|
-
coerce: customZodError("--temperature", (s) => z.coerce.number().min(0).max(2).parse(s)),
|
|
39
|
-
})
|
|
40
|
-
.option("top-p", {
|
|
41
|
-
group: MODEL_OPTIONS_GROUP_NAME,
|
|
42
|
-
describe: "Top P (nucleus sampling) parameter for the model (controls diversity). Range: 0.0-1.0",
|
|
43
|
-
type: "number",
|
|
44
|
-
coerce: customZodError("--top-p", (s) => z.coerce.number().min(0).max(1).parse(s)),
|
|
45
|
-
})
|
|
46
|
-
.option("presence-penalty", {
|
|
47
|
-
group: MODEL_OPTIONS_GROUP_NAME,
|
|
48
|
-
describe: "Presence penalty for the model (penalizes repeating the same tokens). Range: -2.0 to 2.0",
|
|
49
|
-
type: "number",
|
|
50
|
-
coerce: customZodError("--presence-penalty", (s) => z.coerce.number().min(-2).max(2).parse(s)),
|
|
51
|
-
})
|
|
52
|
-
.option("frequency-penalty", {
|
|
53
|
-
group: MODEL_OPTIONS_GROUP_NAME,
|
|
54
|
-
describe: "Frequency penalty for the model (penalizes frequency of token usage). Range: -2.0 to 2.0",
|
|
55
|
-
type: "number",
|
|
56
|
-
coerce: customZodError("--frequency-penalty", (s) => z.coerce.number().min(-2).max(2).parse(s)),
|
|
57
|
-
})
|
|
58
|
-
.option("input", {
|
|
59
|
-
describe: "Input to the agent, use @<file> to read from a file",
|
|
60
|
-
type: "string",
|
|
61
|
-
array: true,
|
|
62
|
-
alias: "i",
|
|
63
|
-
})
|
|
64
|
-
.option("input-file", {
|
|
65
|
-
describe: "Input files to the agent",
|
|
66
|
-
type: "string",
|
|
67
|
-
array: true,
|
|
68
|
-
})
|
|
69
|
-
.option("format", {
|
|
70
|
-
describe: "Input format for the agent (available: text, json, yaml default: text)",
|
|
71
|
-
type: "string",
|
|
72
|
-
choices: ["text", "json", "yaml"],
|
|
73
|
-
})
|
|
74
|
-
.option("output", {
|
|
75
|
-
describe: "Output file to save the result (default: stdout)",
|
|
76
|
-
type: "string",
|
|
77
|
-
alias: "o",
|
|
78
|
-
})
|
|
79
|
-
.option("output-key", {
|
|
80
|
-
describe: "Key in the result to save to the output file",
|
|
81
|
-
type: "string",
|
|
82
|
-
default: DEFAULT_OUTPUT_KEY,
|
|
83
|
-
})
|
|
84
|
-
.option("force", {
|
|
85
|
-
describe: "Truncate the output file if it exists, and create directory if the output path does not exists",
|
|
86
|
-
type: "boolean",
|
|
87
|
-
default: false,
|
|
88
|
-
})
|
|
89
|
-
.option("log-level", {
|
|
90
|
-
describe: `Log level for detailed debugging information. Values: ${Object.values(LogLevel).join(", ")}`,
|
|
91
|
-
type: "string",
|
|
92
|
-
default: getLevelFromEnv(logger.options.ns) || LogLevel.SILENT,
|
|
93
|
-
coerce: customZodError("--log-level", (s) => z.nativeEnum(LogLevel).parse(s)),
|
|
94
|
-
})
|
|
95
|
-
.option("aigne-hub-url", {
|
|
96
|
-
group: MODEL_OPTIONS_GROUP_NAME,
|
|
97
|
-
describe: "Custom AIGNE Hub service URL. Used to fetch remote agent definitions or models.",
|
|
98
|
-
type: "string",
|
|
99
|
-
});
|
|
100
|
-
function formatModelsName(models) {
|
|
101
|
-
return models
|
|
102
|
-
.map((i) => {
|
|
103
|
-
if (typeof i.name === "string") {
|
|
104
|
-
return i.name.toLowerCase().replace(/ChatModel$/i, "");
|
|
105
|
-
}
|
|
106
|
-
return i.name.map((n) => n.toLowerCase().replace(/ChatModel$/i, ""));
|
|
107
|
-
})
|
|
108
|
-
.join(", ");
|
|
109
|
-
}
|
|
110
|
-
export function inferZodType(type, opts = {}) {
|
|
111
|
-
if (type instanceof ZodUnknown || type instanceof ZodAny) {
|
|
112
|
-
return { type: "string", optional: true };
|
|
113
|
-
}
|
|
114
|
-
opts.optional ??= type.isNullable() || type.isOptional();
|
|
115
|
-
if ("innerType" in type._def && type._def.innerType instanceof ZodType) {
|
|
116
|
-
return inferZodType(type._def.innerType, opts);
|
|
117
|
-
}
|
|
118
|
-
if (type instanceof ZodArray) {
|
|
119
|
-
return inferZodType(type.element, { ...opts, array: true });
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
...opts,
|
|
123
|
-
array: opts.array || undefined,
|
|
124
|
-
optional: opts.optional || undefined,
|
|
125
|
-
type: type instanceof ZodBoolean ? "boolean" : type instanceof ZodNumber ? "number" : "string",
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
export function withAgentInputSchema(yargs, options) {
|
|
129
|
-
const inputSchema = options.inputSchema instanceof ZodObject ? options.inputSchema.shape : {};
|
|
130
|
-
for (const [option, config] of Object.entries(inputSchema)) {
|
|
131
|
-
const type = inferZodType(config);
|
|
132
|
-
yargs.option(option, {
|
|
133
|
-
group: "Agent Parameters",
|
|
134
|
-
type: type.type,
|
|
135
|
-
description: config.description,
|
|
136
|
-
array: type.array,
|
|
137
|
-
});
|
|
138
|
-
if (!type.optional && !options.optionalInputs?.includes(option)) {
|
|
139
|
-
yargs.demandOption(option);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return withRunAgentCommonOptions(yargs);
|
|
143
|
-
}
|
|
144
|
-
export async function parseAgentInput(i, agent) {
|
|
145
|
-
const inputSchema = agent.inputSchema instanceof ZodObject ? agent.inputSchema.shape : {};
|
|
146
|
-
const input = Object.fromEntries(await Promise.all(Object.entries(pick(i, Object.keys(inputSchema))).map(async ([key, val]) => {
|
|
147
|
-
if (typeof val === "string" && val.startsWith("@")) {
|
|
148
|
-
const schema = inputSchema[key];
|
|
149
|
-
val = await readFileAsInput(val, {
|
|
150
|
-
format: schema instanceof ZodString ? "raw" : undefined,
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
return [key, val];
|
|
154
|
-
})));
|
|
155
|
-
if (agent instanceof AIAgent && agent.inputFileKey) {
|
|
156
|
-
const files = [];
|
|
157
|
-
for (const file of flat(i.inputFile, i[agent.inputFileKey]) ?? []) {
|
|
158
|
-
const raw = await readFile(file.replace(/^@/, ""), "base64");
|
|
159
|
-
const filename = basename(file);
|
|
160
|
-
const mimeType = (await ChatModel.getMimeType(filename)) || "application/octet-stream";
|
|
161
|
-
files.push({ type: "file", data: raw, filename, mimeType });
|
|
162
|
-
}
|
|
163
|
-
Object.assign(input, { [agent.inputFileKey]: files });
|
|
164
|
-
}
|
|
165
|
-
const rawInput = i.input ||
|
|
166
|
-
(isatty(process.stdin.fd) || !(await stdinHasData())
|
|
167
|
-
? null
|
|
168
|
-
: [await readAllString(process.stdin)].filter(Boolean));
|
|
169
|
-
if (rawInput) {
|
|
170
|
-
for (const raw of rawInput) {
|
|
171
|
-
const parsed = raw.startsWith("@") ? await readFileAsInput(raw, { format: i.format }) : raw;
|
|
172
|
-
if (typeof parsed !== "string") {
|
|
173
|
-
Object.assign(input, parsed);
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
const inputKey = agent instanceof AIAgent ? agent.inputKey : undefined;
|
|
177
|
-
if (inputKey) {
|
|
178
|
-
Object.assign(input, { [inputKey]: parsed });
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return input;
|
|
184
|
-
}
|
|
185
|
-
async function readFileAsInput(value, { format } = {}) {
|
|
186
|
-
if (value.startsWith("@")) {
|
|
187
|
-
const ext = extname(value);
|
|
188
|
-
value = await readFile(value.slice(1), "utf8");
|
|
189
|
-
if (!format) {
|
|
190
|
-
if (ext === ".json")
|
|
191
|
-
format = "json";
|
|
192
|
-
else if (ext === ".yaml" || ext === ".yml")
|
|
193
|
-
format = "yaml";
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
if (format === "json") {
|
|
197
|
-
return JSON.parse(value);
|
|
198
|
-
}
|
|
199
|
-
else if (format === "yaml") {
|
|
200
|
-
return parse(value);
|
|
201
|
-
}
|
|
202
|
-
return value;
|
|
203
|
-
}
|
|
204
|
-
export async function stdinHasData() {
|
|
205
|
-
const stats = await promisify(fstat)(0);
|
|
206
|
-
return stats.isFIFO() || stats.isFile();
|
|
207
|
-
}
|
|
208
|
-
function customZodError(label, fn) {
|
|
209
|
-
return ((...args) => tryOrThrow(() => fn(...args), (e) => new Error(`${label} ${e instanceof ZodError ? e.issues[0]?.message : e.message}`)));
|
|
210
|
-
}
|