@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/commands/hub.js
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { AIGNE_HUB_URL } from "@aigne/aigne-hub";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import Table from "cli-table3";
|
|
4
|
-
import inquirer from "inquirer";
|
|
5
|
-
import { isTest } from "../utils/aigne-hub/constants.js";
|
|
6
|
-
import { connectToAIGNEHub } from "../utils/aigne-hub/credential.js";
|
|
7
|
-
import getSecretStore from "../utils/aigne-hub/store/index.js";
|
|
8
|
-
import { getUserInfo } from "../utils/aigne-hub-user.js";
|
|
9
|
-
import { getUrlOrigin } from "../utils/get-url-origin.js";
|
|
10
|
-
export const formatNumber = (balance) => {
|
|
11
|
-
const cleanNumber = String(balance).replace(/[^\d.-]/g, "");
|
|
12
|
-
const balanceNum = cleanNumber.split(".")[0];
|
|
13
|
-
if (!balanceNum) {
|
|
14
|
-
return "0";
|
|
15
|
-
}
|
|
16
|
-
return (balanceNum || "").trim().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
17
|
-
};
|
|
18
|
-
const formatNumberWithColor = (balance) => {
|
|
19
|
-
return chalk.yellow(formatNumber(balance));
|
|
20
|
-
};
|
|
21
|
-
function formatHubInfoName(name) {
|
|
22
|
-
return chalk.bold(`${name}:`.padEnd(10));
|
|
23
|
-
}
|
|
24
|
-
function printHubStatus(data) {
|
|
25
|
-
const divider = "─".repeat(46);
|
|
26
|
-
console.log(chalk.bold("AIGNE Hub Connection"));
|
|
27
|
-
console.log(chalk.gray(divider));
|
|
28
|
-
console.log(`${chalk.bold("Hub:".padEnd(10))} ${data.hub}`);
|
|
29
|
-
console.log(`${chalk.bold("Status:".padEnd(10))} ${data.status === "Connected" ? chalk.green(`${data.status} ✅`) : `${data.status}`}`);
|
|
30
|
-
console.log("");
|
|
31
|
-
console.log(chalk.bold("User:"));
|
|
32
|
-
console.log(` ${formatHubInfoName("Name")} ${data.user.name}`);
|
|
33
|
-
console.log(` ${formatHubInfoName("DID")} ${data.user.did}`);
|
|
34
|
-
console.log(` ${formatHubInfoName("Email")} ${data.user.email}`);
|
|
35
|
-
console.log("");
|
|
36
|
-
if (data.enableCredit) {
|
|
37
|
-
console.log(chalk.bold("Credits:"));
|
|
38
|
-
console.log(` ${formatHubInfoName("Total")} ${formatNumberWithColor(data.credits.total)}`);
|
|
39
|
-
console.log(` ${formatHubInfoName("Used")} ${formatNumberWithColor(data.credits.used)}`);
|
|
40
|
-
console.log(` ${formatHubInfoName("Available")} ${formatNumberWithColor(data.credits.available)}`);
|
|
41
|
-
console.log("");
|
|
42
|
-
console.log(chalk.bold("Links:"));
|
|
43
|
-
if (data.links.payment) {
|
|
44
|
-
console.log(` ${formatHubInfoName("Payment")} ${data.links.payment}`);
|
|
45
|
-
}
|
|
46
|
-
if (data.links.profile) {
|
|
47
|
-
console.log(` ${formatHubInfoName("Credits")} ${data.links.profile}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async function getHubs() {
|
|
52
|
-
try {
|
|
53
|
-
const secretStore = await getSecretStore();
|
|
54
|
-
const hosts = await secretStore.listHosts();
|
|
55
|
-
const statusList = [];
|
|
56
|
-
for (const host of hosts) {
|
|
57
|
-
statusList.push({
|
|
58
|
-
host: new URL(host.AIGNE_HUB_API_URL).host,
|
|
59
|
-
apiUrl: host.AIGNE_HUB_API_URL,
|
|
60
|
-
apiKey: host.AIGNE_HUB_API_KEY || "",
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return statusList;
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return [];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const getDefaultHub = async () => {
|
|
70
|
-
try {
|
|
71
|
-
const secretStore = await getSecretStore();
|
|
72
|
-
const defaultHost = await secretStore.getDefault();
|
|
73
|
-
return defaultHost?.AIGNE_HUB_API_URL || AIGNE_HUB_URL;
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
return AIGNE_HUB_URL;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
async function formatHubsList(statusList) {
|
|
80
|
-
if (statusList?.length === 0) {
|
|
81
|
-
console.log(chalk.yellow("No AIGNE Hub connected."));
|
|
82
|
-
console.log("Use 'aigne hub connect' to connect to a hub.");
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const defaultHub = await getDefaultHub();
|
|
86
|
-
const table = new Table({
|
|
87
|
-
head: ["URL", "ACTIVE"],
|
|
88
|
-
colWidths: [70, 10],
|
|
89
|
-
style: {
|
|
90
|
-
head: ["cyan"],
|
|
91
|
-
border: ["grey"],
|
|
92
|
-
},
|
|
93
|
-
});
|
|
94
|
-
console.log(chalk.blue("Connected AIGNE Hubs:\n"));
|
|
95
|
-
for (const status of statusList) {
|
|
96
|
-
const isConnected = getUrlOrigin(status.apiUrl) === getUrlOrigin(defaultHub);
|
|
97
|
-
table.push([getUrlOrigin(status.apiUrl), isConnected ? "YES" : "NO"]);
|
|
98
|
-
}
|
|
99
|
-
console.log(table.toString());
|
|
100
|
-
console.log(chalk.blue("Use 'aigne hub use' to switch to a different hub."));
|
|
101
|
-
}
|
|
102
|
-
export function createHubCommand() {
|
|
103
|
-
return {
|
|
104
|
-
command: "hub <command>",
|
|
105
|
-
describe: "Manage AIGNE Hub connections",
|
|
106
|
-
builder: (yargs) => yargs
|
|
107
|
-
.command(["list", "ls"], "List all connected AIGNE Hubs", listHubs)
|
|
108
|
-
.command({
|
|
109
|
-
command: "connect [url]",
|
|
110
|
-
describe: "Connect to an AIGNE Hub",
|
|
111
|
-
builder: (yargs) => yargs.positional("url", {
|
|
112
|
-
type: "string",
|
|
113
|
-
describe: "The URL of the AIGNE Hub to connect to",
|
|
114
|
-
default: null,
|
|
115
|
-
}),
|
|
116
|
-
handler: (args) => {
|
|
117
|
-
if (args.url) {
|
|
118
|
-
saveAndConnect(args.url);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
connectHub();
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
})
|
|
125
|
-
.command("use", "Switch to a different AIGNE Hub", useHub)
|
|
126
|
-
.command(["status", "st"], "Show details of a connected hub", showInfo)
|
|
127
|
-
.command(["remove", "rm"], "Remove a connected hub", removeHub)
|
|
128
|
-
.demandCommand(1, "Please provide a valid hub command"),
|
|
129
|
-
handler: () => { },
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
const listHubs = async () => {
|
|
133
|
-
const list = await getHubs();
|
|
134
|
-
await formatHubsList(list);
|
|
135
|
-
};
|
|
136
|
-
async function connectHub() {
|
|
137
|
-
const defaultUrl = "https://hub.aigne.io";
|
|
138
|
-
const { isOfficial } = await inquirer.prompt({
|
|
139
|
-
type: "select",
|
|
140
|
-
name: "isOfficial",
|
|
141
|
-
message: `Choose a hub to connect:`,
|
|
142
|
-
choices: [
|
|
143
|
-
{ name: `Official Hub (${defaultUrl})`, value: true },
|
|
144
|
-
{ name: `Custom Hub URL`, value: false },
|
|
145
|
-
],
|
|
146
|
-
default: true,
|
|
147
|
-
});
|
|
148
|
-
let currentUrl = defaultUrl;
|
|
149
|
-
if (!isOfficial) {
|
|
150
|
-
const { customUrl } = await inquirer.prompt({
|
|
151
|
-
type: "input",
|
|
152
|
-
name: "customUrl",
|
|
153
|
-
message: "Enter the URL of your AIGNE Hub:",
|
|
154
|
-
validate: validateUrl,
|
|
155
|
-
});
|
|
156
|
-
currentUrl = customUrl;
|
|
157
|
-
}
|
|
158
|
-
await saveAndConnect(currentUrl);
|
|
159
|
-
}
|
|
160
|
-
async function useHub() {
|
|
161
|
-
const hubs = await getHubs();
|
|
162
|
-
if (!hubs.length) {
|
|
163
|
-
console.log(chalk.yellow("No AIGNE Hub connected."));
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
const { hubApiKey } = await inquirer.prompt({
|
|
167
|
-
type: "select",
|
|
168
|
-
name: "hubApiKey",
|
|
169
|
-
message: `Choose a hub to switch to:`,
|
|
170
|
-
choices: hubs.map((h) => ({
|
|
171
|
-
name: getUrlOrigin(h.apiUrl),
|
|
172
|
-
value: h.apiUrl,
|
|
173
|
-
})),
|
|
174
|
-
});
|
|
175
|
-
await setDefaultHub(hubApiKey);
|
|
176
|
-
}
|
|
177
|
-
async function removeHub() {
|
|
178
|
-
const hubs = await getHubs();
|
|
179
|
-
if (!hubs.length) {
|
|
180
|
-
console.log(chalk.yellow("No AIGNE Hub connected."));
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
const { hubApiKey } = await inquirer.prompt({
|
|
184
|
-
type: "select",
|
|
185
|
-
name: "hubApiKey",
|
|
186
|
-
message: `Choose a hub to remove:`,
|
|
187
|
-
choices: hubs.map((h) => ({
|
|
188
|
-
name: getUrlOrigin(h.apiUrl),
|
|
189
|
-
value: h.apiUrl,
|
|
190
|
-
})),
|
|
191
|
-
});
|
|
192
|
-
await deleteHub(hubApiKey);
|
|
193
|
-
}
|
|
194
|
-
async function showInfo() {
|
|
195
|
-
const hubs = await getHubs();
|
|
196
|
-
if (!hubs.length) {
|
|
197
|
-
console.log(chalk.yellow("No AIGNE Hub connected."));
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
const defaultHub = await getDefaultHub();
|
|
201
|
-
const defaultHubIndex = hubs.findIndex((h) => getUrlOrigin(h.apiUrl) === getUrlOrigin(defaultHub));
|
|
202
|
-
const { hubApiKey } = await inquirer.prompt({
|
|
203
|
-
type: "select",
|
|
204
|
-
name: "hubApiKey",
|
|
205
|
-
message: `Choose a hub to view info:`,
|
|
206
|
-
choices: hubs.map((h, index) => ({
|
|
207
|
-
name: `${getUrlOrigin(h.apiUrl)} ${defaultHubIndex === index ? "(connected)" : ""}`,
|
|
208
|
-
value: h.apiUrl,
|
|
209
|
-
})),
|
|
210
|
-
});
|
|
211
|
-
try {
|
|
212
|
-
await printHubDetails(hubApiKey);
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
console.error(chalk.red("✗ Failed to print hub details:"), error.message);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
function validateUrl(input) {
|
|
219
|
-
try {
|
|
220
|
-
const url = new URL(input);
|
|
221
|
-
return url.protocol.startsWith("http") ? true : "Must be http or https";
|
|
222
|
-
}
|
|
223
|
-
catch {
|
|
224
|
-
return "Invalid URL";
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
async function saveAndConnect(url) {
|
|
228
|
-
const secretStore = await getSecretStore();
|
|
229
|
-
const currentKey = await secretStore.getKey(url);
|
|
230
|
-
if (currentKey?.AIGNE_HUB_API_URL) {
|
|
231
|
-
await setDefaultHub(currentKey.AIGNE_HUB_API_URL);
|
|
232
|
-
console.log(chalk.green(`✓ Hub ${getUrlOrigin(currentKey.AIGNE_HUB_API_URL)} connected successfully.`));
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
try {
|
|
236
|
-
if (isTest) {
|
|
237
|
-
await secretStore.setKey("https://hub.aigne.io/ai-kit", "test-key");
|
|
238
|
-
await secretStore.setDefault("https://hub.aigne.io/ai-kit");
|
|
239
|
-
console.log(chalk.green(`✓ Hub https://hub.aigne.io/ai-kit connected successfully.`));
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
await connectToAIGNEHub(url);
|
|
243
|
-
console.log(chalk.green(`✓ Hub ${getUrlOrigin(url)} connected successfully.`));
|
|
244
|
-
}
|
|
245
|
-
catch (error) {
|
|
246
|
-
console.error(chalk.red("✗ Failed to connect:"), error.message);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
async function setDefaultHub(url) {
|
|
250
|
-
try {
|
|
251
|
-
const secretStore = await getSecretStore();
|
|
252
|
-
const key = await secretStore.getKey(url);
|
|
253
|
-
if (!key) {
|
|
254
|
-
console.error(chalk.red("✗ Hub not found"));
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
await secretStore.setDefault(key.AIGNE_HUB_API_URL);
|
|
258
|
-
console.log(chalk.green(`✓ Switched active hub to ${getUrlOrigin(url)}`));
|
|
259
|
-
}
|
|
260
|
-
catch {
|
|
261
|
-
console.error(chalk.red("✗ Failed to set default hub"));
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
async function deleteHub(url) {
|
|
265
|
-
try {
|
|
266
|
-
const secretStore = await getSecretStore();
|
|
267
|
-
const key = await secretStore.getKey(url);
|
|
268
|
-
if (!key) {
|
|
269
|
-
console.error(chalk.red("✗ Hub not found"));
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
const defaultHub = await getDefaultHub();
|
|
273
|
-
await secretStore.deleteKey(url);
|
|
274
|
-
if (!defaultHub) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
const isDefaultHub = getUrlOrigin(url) === getUrlOrigin(defaultHub);
|
|
278
|
-
if (isDefaultHub) {
|
|
279
|
-
await secretStore.deleteDefault();
|
|
280
|
-
const remainingHubs = await getHubs();
|
|
281
|
-
const nextHub = remainingHubs[0];
|
|
282
|
-
if (nextHub) {
|
|
283
|
-
await secretStore.setDefault(nextHub?.apiUrl);
|
|
284
|
-
console.log(chalk.green(`✓ Hub ${getUrlOrigin(url)} removed, switched to ${getUrlOrigin(nextHub?.apiUrl)}`));
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
console.log(chalk.green(`✓ Hub ${getUrlOrigin(url)} removed`));
|
|
289
|
-
}
|
|
290
|
-
catch {
|
|
291
|
-
console.error(chalk.red("✗ Failed to delete hub"));
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
async function printHubDetails(url) {
|
|
295
|
-
const secretStore = await getSecretStore();
|
|
296
|
-
const key = await secretStore.getKey(url);
|
|
297
|
-
const defaultHub = await getDefaultHub();
|
|
298
|
-
const isDefault = getUrlOrigin(url) === getUrlOrigin(defaultHub);
|
|
299
|
-
const userInfo = await getUserInfo({
|
|
300
|
-
baseUrl: key?.AIGNE_HUB_API_URL || "",
|
|
301
|
-
apiKey: key?.AIGNE_HUB_API_KEY || "",
|
|
302
|
-
}).catch(() => null);
|
|
303
|
-
printHubStatus({
|
|
304
|
-
hub: getUrlOrigin(url),
|
|
305
|
-
status: isDefault ? "Connected" : "Not Used",
|
|
306
|
-
user: {
|
|
307
|
-
name: userInfo?.user.fullName || "",
|
|
308
|
-
did: userInfo?.user.did || "",
|
|
309
|
-
email: userInfo?.user.email || "",
|
|
310
|
-
},
|
|
311
|
-
credits: {
|
|
312
|
-
available: userInfo?.creditBalance?.balance || "0",
|
|
313
|
-
total: userInfo?.creditBalance?.total || "0",
|
|
314
|
-
used: String(parseFloat(userInfo?.creditBalance?.total || "0") -
|
|
315
|
-
parseFloat(userInfo?.creditBalance?.balance || "0")),
|
|
316
|
-
},
|
|
317
|
-
links: {
|
|
318
|
-
payment: userInfo?.paymentLink || "",
|
|
319
|
-
profile: userInfo?.profileLink || "",
|
|
320
|
-
},
|
|
321
|
-
enableCredit: userInfo?.enableCredit || false,
|
|
322
|
-
});
|
|
323
|
-
}
|
package/dist/commands/observe.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { tryOrThrow } from "@aigne/core/utils/type-utils.js";
|
|
2
|
-
import { startObservabilityCLIServer } from "@aigne/observability-api/cli";
|
|
3
|
-
import getObservabilityDbPath from "@aigne/observability-api/db-path";
|
|
4
|
-
import chalk from "chalk";
|
|
5
|
-
import detectPort from "detect-port";
|
|
6
|
-
const DEFAULT_PORT = () => tryOrThrow(() => {
|
|
7
|
-
const { PORT } = process.env;
|
|
8
|
-
if (!PORT)
|
|
9
|
-
return 7890;
|
|
10
|
-
const port = Number.parseInt(PORT, 10);
|
|
11
|
-
if (!port || !Number.isInteger(port))
|
|
12
|
-
throw new Error(`Invalid PORT: ${PORT}`);
|
|
13
|
-
return port;
|
|
14
|
-
}, (error) => new Error(`parse PORT error ${error.message}`));
|
|
15
|
-
export function createObservabilityCommand() {
|
|
16
|
-
return {
|
|
17
|
-
command: "observe",
|
|
18
|
-
describe: "Start the observability server",
|
|
19
|
-
builder: (yargs) => {
|
|
20
|
-
return yargs
|
|
21
|
-
.option("host", {
|
|
22
|
-
type: "string",
|
|
23
|
-
describe: "Host to run the observability server on, use 0.0.0.0 to publicly expose the server",
|
|
24
|
-
default: "localhost",
|
|
25
|
-
})
|
|
26
|
-
.option("port", {
|
|
27
|
-
type: "number",
|
|
28
|
-
describe: "Port to run the observability server on",
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
handler: async (options) => {
|
|
32
|
-
const port = await detectPort(options.port || DEFAULT_PORT());
|
|
33
|
-
const dbUrl = getObservabilityDbPath();
|
|
34
|
-
process.once("SIGINT", async () => {
|
|
35
|
-
process.exit(0);
|
|
36
|
-
});
|
|
37
|
-
console.log("Observability database path:", chalk.greenBright(dbUrl));
|
|
38
|
-
await startObservabilityCLIServer({ port, dbUrl });
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { basename, resolve } from "node:path";
|
|
2
|
-
import { AFSHistory } from "@aigne/afs-history";
|
|
3
|
-
import { LocalFS } from "@aigne/afs-local-fs";
|
|
4
|
-
import AgentSkillManager from "@aigne/agent-library/agent-skill-manager";
|
|
5
|
-
import AskUserQuestion from "@aigne/agent-library/ask-user-question";
|
|
6
|
-
import BashAgent from "@aigne/agent-library/bash";
|
|
7
|
-
import { AIGNE, FunctionAgent } from "@aigne/core";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
import { loadChatModel } from "../utils/aigne-hub/model.js";
|
|
10
|
-
import { withAgentInputSchema } from "../utils/yargs.js";
|
|
11
|
-
import { invokeAgent } from "./app/agent.js";
|
|
12
|
-
export function createRunSkillCommand() {
|
|
13
|
-
return {
|
|
14
|
-
command: ["run-skill"],
|
|
15
|
-
describe: "Run Agent Skill for the specified path",
|
|
16
|
-
builder: async (yargs) => {
|
|
17
|
-
return withAgentInputSchema(yargs
|
|
18
|
-
.option("skill", {
|
|
19
|
-
array: true,
|
|
20
|
-
type: "string",
|
|
21
|
-
describe: "Path to the Agent Skill directory",
|
|
22
|
-
})
|
|
23
|
-
.option("interactive", {
|
|
24
|
-
describe: "Run in interactive chat mode",
|
|
25
|
-
type: "boolean",
|
|
26
|
-
default: false,
|
|
27
|
-
alias: ["chat"],
|
|
28
|
-
})
|
|
29
|
-
.demandOption("skill"), {
|
|
30
|
-
inputSchema: z.object({
|
|
31
|
-
message: z.string(),
|
|
32
|
-
}),
|
|
33
|
-
optionalInputs: ["message"],
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
handler: async (options) => {
|
|
37
|
-
if (!Array.isArray(options.skill) || options.skill.length === 0) {
|
|
38
|
-
throw new Error("At least one skill path must be provided.");
|
|
39
|
-
}
|
|
40
|
-
const model = await loadChatModel({
|
|
41
|
-
model: options.model || "aignehub/anthropic/claude-sonnet-4-5",
|
|
42
|
-
});
|
|
43
|
-
const aigne = new AIGNE({ model });
|
|
44
|
-
const approvedCmds = new Set();
|
|
45
|
-
const agent = new AgentSkillManager({
|
|
46
|
-
inputKey: "message",
|
|
47
|
-
taskRenderMode: "collapse",
|
|
48
|
-
skills: [
|
|
49
|
-
new BashAgent({
|
|
50
|
-
sandbox: false,
|
|
51
|
-
permissions: {
|
|
52
|
-
defaultMode: "ask",
|
|
53
|
-
guard: FunctionAgent.from(async (input, options) => {
|
|
54
|
-
if (approvedCmds.has(input.script || "")) {
|
|
55
|
-
return {
|
|
56
|
-
approved: true,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const confirm = options.prompts?.confirm;
|
|
60
|
-
if (!confirm)
|
|
61
|
-
throw new Error("No confirm prompt available for permission guard.");
|
|
62
|
-
const approved = await confirm({ message: `Run command ${input.script}?` });
|
|
63
|
-
if (approved && input.script) {
|
|
64
|
-
approvedCmds.add(input.script);
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
approved,
|
|
68
|
-
};
|
|
69
|
-
}),
|
|
70
|
-
},
|
|
71
|
-
}),
|
|
72
|
-
new AskUserQuestion(),
|
|
73
|
-
],
|
|
74
|
-
afs: {
|
|
75
|
-
modules: [
|
|
76
|
-
new AFSHistory({}),
|
|
77
|
-
new LocalFS({
|
|
78
|
-
name: "workspace",
|
|
79
|
-
localPath: process.cwd(),
|
|
80
|
-
description: `\
|
|
81
|
-
Current working directory. All temporary files should be written here using absolute AFS paths (e.g., /modules/workspace/temp.py).
|
|
82
|
-
Note: Bash is already running in this directory, so do NOT use 'cd /modules/workspace' in scripts. Use relative paths directly (e.g., python temp.py).`,
|
|
83
|
-
}),
|
|
84
|
-
...options.skill.map((path) => new LocalFS({
|
|
85
|
-
name: basename(resolve(path)),
|
|
86
|
-
localPath: path,
|
|
87
|
-
description: "Contains Agent Skills. Use 'Skill' tool to invoke skills from this module.",
|
|
88
|
-
agentSkills: true,
|
|
89
|
-
})),
|
|
90
|
-
],
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
await invokeAgent({
|
|
94
|
-
aigne,
|
|
95
|
-
agent,
|
|
96
|
-
input: {
|
|
97
|
-
...options,
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
}
|
package/dist/commands/run.d.ts
DELETED
package/dist/commands/run.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { cp, mkdir, rm } from "node:fs/promises";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
4
|
-
import { exists } from "@aigne/agent-library/utils/fs.js";
|
|
5
|
-
import { findAIGNEFile } from "@aigne/core/loader/index.js";
|
|
6
|
-
import { logger } from "@aigne/core/utils/logger.js";
|
|
7
|
-
import { flat, isNonNullable, pick } from "@aigne/core/utils/type-utils.js";
|
|
8
|
-
import { Listr, PRESET_TIMER } from "@aigne/listr2";
|
|
9
|
-
import { config } from "dotenv-flow";
|
|
10
|
-
import yargs from "yargs";
|
|
11
|
-
import { AIGNE_CLI_VERSION, CHAT_MODEL_OPTIONS } from "../constants.js";
|
|
12
|
-
import { isV1Package, toAIGNEPackage } from "../utils/agent-v1.js";
|
|
13
|
-
import { downloadAndExtract } from "../utils/download.js";
|
|
14
|
-
import { loadAIGNE } from "../utils/load-aigne.js";
|
|
15
|
-
import { isUrl } from "../utils/url.js";
|
|
16
|
-
import { withRunAgentCommonOptions } from "../utils/yargs.js";
|
|
17
|
-
import { agentCommandModule, cliAgentCommandModule } from "./app/agent.js";
|
|
18
|
-
let yargsInstance = null;
|
|
19
|
-
export function createRunCommand({ aigneFilePath, } = {}) {
|
|
20
|
-
return {
|
|
21
|
-
// $0 must place after 'run' to make positional args work correctly
|
|
22
|
-
command: ["run [path] [entry-agent]", "$0"],
|
|
23
|
-
describe: "Run AIGNE for the specified path",
|
|
24
|
-
builder: async (yargs) => {
|
|
25
|
-
yargsInstance = yargs;
|
|
26
|
-
return yargs
|
|
27
|
-
.positional("path", {
|
|
28
|
-
type: "string",
|
|
29
|
-
describe: "Path to the agents directory or URL to an aigne project",
|
|
30
|
-
default: ".",
|
|
31
|
-
})
|
|
32
|
-
.positional("entry-agent", {
|
|
33
|
-
type: "string",
|
|
34
|
-
describe: "Name of the agent to run (defaults to the entry agent if not specified)",
|
|
35
|
-
})
|
|
36
|
-
.option("version", {
|
|
37
|
-
type: "boolean",
|
|
38
|
-
alias: "v",
|
|
39
|
-
describe: "Show version number",
|
|
40
|
-
})
|
|
41
|
-
.option("interactive", {
|
|
42
|
-
describe: "Run in interactive chat mode",
|
|
43
|
-
type: "boolean",
|
|
44
|
-
default: false,
|
|
45
|
-
alias: ["chat"],
|
|
46
|
-
})
|
|
47
|
-
.help(false)
|
|
48
|
-
.version(false)
|
|
49
|
-
.strict(false);
|
|
50
|
-
},
|
|
51
|
-
handler: async (options) => {
|
|
52
|
-
if (options.version) {
|
|
53
|
-
console.log(AIGNE_CLI_VERSION);
|
|
54
|
-
process.exit(0);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (!options.entryAgent && options.path) {
|
|
58
|
-
if (!(await exists(options.path)) && !isUrl(options.path)) {
|
|
59
|
-
options.entryAgent = options.path;
|
|
60
|
-
options.path = undefined;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const path = aigneFilePath || options.path || ".";
|
|
64
|
-
if (!isUrl(path) &&
|
|
65
|
-
!(await findAIGNEFile(path).catch((error) => {
|
|
66
|
-
if (options._[0] !== "run") {
|
|
67
|
-
yargsInstance?.showHelp();
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
return false;
|
|
73
|
-
}))) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
// Parse model options for loading application
|
|
77
|
-
const opts = withRunAgentCommonOptions(yargs(process.argv).help(false).version(false).strict(false)).parseSync();
|
|
78
|
-
logger.level = opts.logLevel;
|
|
79
|
-
const { aigne } = await loadApplication(path, {
|
|
80
|
-
modelOptions: pick(opts, CHAT_MODEL_OPTIONS),
|
|
81
|
-
imageModelOptions: { model: opts.imageModel },
|
|
82
|
-
});
|
|
83
|
-
const subYargs = yargs().scriptName("").usage("aigne run <path> <agent> [...options]");
|
|
84
|
-
if (aigne.cli.chat) {
|
|
85
|
-
subYargs.command({
|
|
86
|
-
...agentCommandModule({ aigne, agent: aigne.cli.chat, interactive: true }),
|
|
87
|
-
command: "$0",
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
// Allow user to run all of agents in the AIGNE instances
|
|
91
|
-
const allAgents = flat(aigne.agents, aigne.skills, aigne.cli.chat, aigne.mcpServer.agents);
|
|
92
|
-
for (const agent of allAgents) {
|
|
93
|
-
subYargs.command(agentCommandModule({ aigne, agent, interactive: options.interactive }));
|
|
94
|
-
}
|
|
95
|
-
for (const cliAgent of aigne.cli.agents ?? []) {
|
|
96
|
-
subYargs.command(cliAgentCommandModule({
|
|
97
|
-
aigne,
|
|
98
|
-
cliAgent,
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
101
|
-
const argv = process.argv.slice(aigneFilePath ? 3 : 2);
|
|
102
|
-
if (argv[0] === "run")
|
|
103
|
-
argv.shift(); // remove 'run' command
|
|
104
|
-
// For compatibility with old `run` command like: `aigne run --path /xx/xx --entry-agent xx --xx`
|
|
105
|
-
if (argv[0] === "--path" || argv[0] === "--url")
|
|
106
|
-
argv.shift(); // remove --path flag
|
|
107
|
-
if (argv[0] === options.path)
|
|
108
|
-
argv.shift(); // remove path/url args
|
|
109
|
-
if (argv[0] === "--entry-agent")
|
|
110
|
-
argv.shift();
|
|
111
|
-
const firstAgent = aigne.agents[0]?.name;
|
|
112
|
-
if (!options.entryAgent && firstAgent && !argv.some((i) => ["-h", "--help"].includes(i))) {
|
|
113
|
-
argv.unshift(firstAgent);
|
|
114
|
-
}
|
|
115
|
-
await subYargs
|
|
116
|
-
.strict()
|
|
117
|
-
.demandCommand()
|
|
118
|
-
.alias("h", "help")
|
|
119
|
-
.alias("v", "version")
|
|
120
|
-
.fail((message, error, yargs) => {
|
|
121
|
-
// We catch all errors below, here just print the help message non-error case like demandCommand
|
|
122
|
-
if (!error) {
|
|
123
|
-
yargs.showHelp();
|
|
124
|
-
console.error(`\n${message}`);
|
|
125
|
-
process.exit(1);
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
.parseAsync(argv);
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
async function loadApplication(path, options = {}) {
|
|
133
|
-
const { cacheDir, dir } = prepareDirs(path);
|
|
134
|
-
if (cacheDir) {
|
|
135
|
-
await new Listr([
|
|
136
|
-
{
|
|
137
|
-
title: "Download package",
|
|
138
|
-
task: () => downloadPackage(path, cacheDir),
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
title: "Extract package",
|
|
142
|
-
task: () => extractPackage(cacheDir, dir),
|
|
143
|
-
},
|
|
144
|
-
], {
|
|
145
|
-
rendererOptions: {
|
|
146
|
-
collapseSubtasks: false,
|
|
147
|
-
showErrorMessage: false,
|
|
148
|
-
timer: PRESET_TIMER,
|
|
149
|
-
},
|
|
150
|
-
}).run();
|
|
151
|
-
}
|
|
152
|
-
// Load env files in the aigne directory
|
|
153
|
-
config({ path: dir, silent: true });
|
|
154
|
-
const aigne = await loadAIGNE({ ...options, path: dir });
|
|
155
|
-
return { aigne, path: dir };
|
|
156
|
-
}
|
|
157
|
-
async function downloadPackage(url, cacheDir) {
|
|
158
|
-
await rm(cacheDir, { recursive: true, force: true });
|
|
159
|
-
await mkdir(cacheDir, { recursive: true });
|
|
160
|
-
await downloadAndExtract(url, cacheDir);
|
|
161
|
-
}
|
|
162
|
-
async function extractPackage(cacheDir, dir) {
|
|
163
|
-
await mkdir(dir, { recursive: true });
|
|
164
|
-
if (await isV1Package(cacheDir)) {
|
|
165
|
-
await toAIGNEPackage(cacheDir, dir);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
await cp(cacheDir, dir, { recursive: true, force: true });
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function prepareDirs(path) {
|
|
172
|
-
let dir;
|
|
173
|
-
let cacheDir;
|
|
174
|
-
if (!path.startsWith("http")) {
|
|
175
|
-
dir = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
dir = getLocalPackagePathFromUrl(path);
|
|
179
|
-
cacheDir = getLocalPackagePathFromUrl(path, { subdir: ".download" });
|
|
180
|
-
}
|
|
181
|
-
return { cacheDir, dir };
|
|
182
|
-
}
|
|
183
|
-
function getLocalPackagePathFromUrl(url, { subdir } = {}) {
|
|
184
|
-
const root = [homedir(), ".aigne", subdir].filter(isNonNullable);
|
|
185
|
-
const u = new URL(url);
|
|
186
|
-
return join(...root, u.hostname, u.pathname);
|
|
187
|
-
}
|