@aigne/cli 1.26.1-0 → 1.27.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 +20 -0
- package/LICENSE.md +93 -0
- package/dist/bunwrapper.js +0 -0
- package/dist/cli.js +1 -2
- package/dist/commands/aigne.d.ts +2 -2
- package/dist/commands/aigne.js +12 -17
- package/dist/commands/connect.d.ts +2 -6
- package/dist/commands/connect.js +28 -33
- package/dist/commands/create.d.ts +2 -6
- package/dist/commands/create.js +58 -62
- package/dist/commands/observe.d.ts +2 -7
- package/dist/commands/observe.js +13 -22
- package/dist/commands/run.d.ts +3 -6
- package/dist/commands/run.js +81 -96
- package/dist/commands/serve-mcp.d.ts +3 -10
- package/dist/commands/serve-mcp.js +23 -41
- package/dist/commands/test.d.ts +3 -7
- package/dist/commands/test.js +14 -20
- package/dist/utils/aigne-hub-user.d.ts +16 -0
- package/dist/utils/aigne-hub-user.js +12 -0
- package/dist/utils/download.d.ts +1 -3
- package/dist/utils/download.js +2 -2
- package/dist/utils/run-with-aigne.d.ts +2 -26
- package/dist/utils/run-with-aigne.js +56 -79
- package/package.json +29 -32
- package/dist/commands/app.d.ts +0 -2
- package/dist/commands/app.js +0 -98
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.27.0",
|
|
4
4
|
"description": "cli for AIGNE framework",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -41,36 +41,9 @@
|
|
|
41
41
|
]
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
|
-
"scripts": {
|
|
45
|
-
"lint": "tsc --noEmit",
|
|
46
|
-
"build": "tsc --build tsconfig.build.json",
|
|
47
|
-
"clean": "rimraf dist test/coverage templates/coverage",
|
|
48
|
-
"prepublishOnly": "run-s clean build",
|
|
49
|
-
"test": "run-s test:src test:templates",
|
|
50
|
-
"test:coverage": "run-s test:src:coverage test:templates:coverage",
|
|
51
|
-
"test:src": "bun --cwd test test",
|
|
52
|
-
"test:src:coverage": "bun --cwd test test --coverage --coverage-reporter=lcov --coverage-reporter=text",
|
|
53
|
-
"test:templates": "cd templates && node --test",
|
|
54
|
-
"test:templates:coverage": "cd templates && mkdir -p coverage && node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-reporter=spec --test-reporter-destination=stdout"
|
|
55
|
-
},
|
|
56
44
|
"dependencies": {
|
|
57
|
-
"@aigne/agent-library": "workspace:^",
|
|
58
|
-
"@aigne/agentic-memory": "workspace:^",
|
|
59
|
-
"@aigne/aigne-hub": "workspace:^",
|
|
60
|
-
"@aigne/anthropic": "workspace:^",
|
|
61
|
-
"@aigne/bedrock": "workspace:^",
|
|
62
|
-
"@aigne/core": "workspace:^",
|
|
63
|
-
"@aigne/deepseek": "workspace:^",
|
|
64
|
-
"@aigne/default-memory": "workspace:^",
|
|
65
|
-
"@aigne/gemini": "workspace:^",
|
|
66
45
|
"@aigne/listr2": "^1.0.10",
|
|
67
46
|
"@aigne/marked-terminal": "^7.3.2",
|
|
68
|
-
"@aigne/observability-api": "workspace:^",
|
|
69
|
-
"@aigne/ollama": "workspace:^",
|
|
70
|
-
"@aigne/open-router": "workspace:^",
|
|
71
|
-
"@aigne/openai": "workspace:^",
|
|
72
|
-
"@aigne/xai": "workspace:^",
|
|
73
|
-
"@blocklet/aigne-hub": "^0.2.17",
|
|
74
47
|
"@inquirer/prompts": "^7.6.0",
|
|
75
48
|
"@inquirer/type": "^3.0.8",
|
|
76
49
|
"@listr2/prompt-adapter-inquirer": "^3.0.1",
|
|
@@ -78,6 +51,7 @@
|
|
|
78
51
|
"@ocap/mcrypto": "^1.21.0",
|
|
79
52
|
"@smithy/node-http-handler": "^4.1.0",
|
|
80
53
|
"chalk": "^5.4.1",
|
|
54
|
+
"commander": "^14.0.0",
|
|
81
55
|
"crypto": "^1.0.1",
|
|
82
56
|
"detect-port": "^2.1.0",
|
|
83
57
|
"dotenv-flow": "^4.1.0",
|
|
@@ -95,8 +69,21 @@
|
|
|
95
69
|
"tar": "^7.4.3",
|
|
96
70
|
"wrap-ansi": "^9.0.0",
|
|
97
71
|
"yaml": "^2.8.0",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
72
|
+
"zod": "^3.25.67",
|
|
73
|
+
"@aigne/agent-library": "^1.21.6",
|
|
74
|
+
"@aigne/aigne-hub": "^0.3.0",
|
|
75
|
+
"@aigne/agentic-memory": "^1.0.6",
|
|
76
|
+
"@aigne/anthropic": "^0.10.2",
|
|
77
|
+
"@aigne/bedrock": "^0.8.6",
|
|
78
|
+
"@aigne/deepseek": "^0.7.6",
|
|
79
|
+
"@aigne/default-memory": "^1.0.6",
|
|
80
|
+
"@aigne/gemini": "^0.8.6",
|
|
81
|
+
"@aigne/observability-api": "^0.8.2",
|
|
82
|
+
"@aigne/open-router": "^0.7.6",
|
|
83
|
+
"@aigne/ollama": "^0.7.6",
|
|
84
|
+
"@aigne/core": "^1.39.0",
|
|
85
|
+
"@aigne/openai": "^0.10.6",
|
|
86
|
+
"@aigne/xai": "^0.7.6"
|
|
100
87
|
},
|
|
101
88
|
"devDependencies": {
|
|
102
89
|
"@types/archiver": "^6.0.3",
|
|
@@ -105,12 +92,22 @@
|
|
|
105
92
|
"@types/glob": "^9.0.0",
|
|
106
93
|
"@types/gradient-string": "^1.1.6",
|
|
107
94
|
"@types/node": "^24.0.12",
|
|
108
|
-
"@types/yargs": "^17.0.33",
|
|
109
95
|
"archiver": "^7.0.1",
|
|
110
96
|
"hono": "4.8.4",
|
|
111
97
|
"npm-run-all": "^4.1.5",
|
|
112
98
|
"rimraf": "^6.0.1",
|
|
113
99
|
"typescript": "^5.8.3",
|
|
114
100
|
"ufo": "^1.6.1"
|
|
101
|
+
},
|
|
102
|
+
"scripts": {
|
|
103
|
+
"lint": "tsc --noEmit",
|
|
104
|
+
"build": "tsc --build tsconfig.build.json",
|
|
105
|
+
"clean": "rimraf dist test/coverage templates/coverage",
|
|
106
|
+
"test": "run-s test:src test:templates",
|
|
107
|
+
"test:coverage": "run-s test:src:coverage test:templates:coverage",
|
|
108
|
+
"test:src": "bun --cwd test test",
|
|
109
|
+
"test:src:coverage": "bun --cwd test test --coverage --coverage-reporter=lcov --coverage-reporter=text",
|
|
110
|
+
"test:templates": "cd templates && node --test",
|
|
111
|
+
"test:templates:coverage": "cd templates && mkdir -p coverage && node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-reporter=spec --test-reporter-destination=stdout"
|
|
115
112
|
}
|
|
116
|
-
}
|
|
113
|
+
}
|
package/dist/commands/app.d.ts
DELETED
package/dist/commands/app.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert";
|
|
2
|
-
import { spawnSync } from "node:child_process";
|
|
3
|
-
import { mkdir, readFile, stat } from "node:fs/promises";
|
|
4
|
-
import { homedir } from "node:os";
|
|
5
|
-
import { join } from "node:path";
|
|
6
|
-
import { AIGNE } from "@aigne/core";
|
|
7
|
-
import { joinURL } from "ufo";
|
|
8
|
-
import { ZodObject, ZodString } from "zod";
|
|
9
|
-
import { availableModels } from "../constants.js";
|
|
10
|
-
import { downloadAndExtract } from "../utils/download.js";
|
|
11
|
-
import { runAgentWithAIGNE } from "../utils/run-with-aigne.js";
|
|
12
|
-
const NPM_PACKAGE_CACHE_TIME_MS = 1000 * 60 * 60 * 24; // 1 day
|
|
13
|
-
export function createAppCommands() {
|
|
14
|
-
return [
|
|
15
|
-
{
|
|
16
|
-
command: "doc-smith",
|
|
17
|
-
describe: "Generate professional documents by doc-smith",
|
|
18
|
-
aliases: ["docsmith", "doc"],
|
|
19
|
-
builder: async (yargs) => {
|
|
20
|
-
const aigne = await loadApplication({ name: "doc-smith" });
|
|
21
|
-
for (const agent of aigne.agents) {
|
|
22
|
-
yargs.command(agent.name, agent.description || "", (yargs) => {
|
|
23
|
-
const options = Object.entries(agent.inputSchema instanceof ZodObject ? agent.inputSchema.shape : {});
|
|
24
|
-
for (const [option, config] of options) {
|
|
25
|
-
yargs.option(option, {
|
|
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: () => { },
|
|
47
|
-
},
|
|
48
|
-
];
|
|
49
|
-
}
|
|
50
|
-
async function loadApplication({ name }) {
|
|
51
|
-
const info = await shouldDownloadNewVersion(name);
|
|
52
|
-
if (info.shouldDownload) {
|
|
53
|
-
assert(info.url, "Package URL should be defined when downloading");
|
|
54
|
-
// TODO: clean up old versions
|
|
55
|
-
await mkdir(info.dir, { recursive: true });
|
|
56
|
-
await downloadAndExtract(info.url.toString(), info.dir, { strip: 1 });
|
|
57
|
-
spawnSync("npm", ["install", "--omit", "dev"], { cwd: info.dir, stdio: "inherit" });
|
|
58
|
-
}
|
|
59
|
-
return AIGNE.load(info.dir, { models: availableModels() });
|
|
60
|
-
}
|
|
61
|
-
async function shouldDownloadNewVersion(name, { cacheTimeMs = NPM_PACKAGE_CACHE_TIME_MS } = {}) {
|
|
62
|
-
const nameWithOrg = `@aigne/${name}`;
|
|
63
|
-
const dir = join(homedir(), ".aigne", "registry.npmjs.org", nameWithOrg);
|
|
64
|
-
const s = await stat(join(dir, "package.json")).catch((error) => {
|
|
65
|
-
if (error.code === "ENOENT") {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
throw error;
|
|
69
|
-
});
|
|
70
|
-
if (!s)
|
|
71
|
-
return {
|
|
72
|
-
shouldDownload: true,
|
|
73
|
-
dir,
|
|
74
|
-
url: await getNpmTgzInfo(nameWithOrg).then((info) => info.tarballUrl),
|
|
75
|
-
};
|
|
76
|
-
const lastModified = s.mtimeMs;
|
|
77
|
-
const now = Date.now();
|
|
78
|
-
if (now - lastModified > cacheTimeMs) {
|
|
79
|
-
const version = JSON.parse(await readFile(join(dir, "package.json"), "utf-8")).version;
|
|
80
|
-
const latest = await getNpmTgzInfo(`@aigne/${name}`);
|
|
81
|
-
if (version !== latest.version) {
|
|
82
|
-
return { shouldDownload: true, url: latest.tarballUrl, dir };
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return { shouldDownload: false, dir };
|
|
86
|
-
}
|
|
87
|
-
async function getNpmTgzInfo(name) {
|
|
88
|
-
const res = await fetch(joinURL("https://registry.npmjs.org", name));
|
|
89
|
-
if (!res.ok)
|
|
90
|
-
throw new Error(`Failed to fetch package info for ${name}: ${res.statusText}`);
|
|
91
|
-
const data = await res.json();
|
|
92
|
-
const latestVersion = data["dist-tags"].latest;
|
|
93
|
-
const tarballUrl = data.versions[latestVersion].dist.tarball;
|
|
94
|
-
return {
|
|
95
|
-
version: latestVersion,
|
|
96
|
-
tarballUrl,
|
|
97
|
-
};
|
|
98
|
-
}
|