@aigne/cli 1.51.0 → 1.52.0-beta.1
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 +52 -0
- package/dist/commands/app.d.ts +6 -2
- package/dist/commands/app.js +50 -9
- package/dist/commands/serve-mcp.d.ts +2 -0
- package/dist/commands/serve-mcp.js +1 -0
- package/dist/ui/utils/terminal-input.d.ts +14 -1
- package/dist/ui/utils/terminal-input.js +47 -11
- package/dist/utils/aigne-hub/model.d.ts +0 -4
- package/dist/utils/aigne-hub/model.js +3 -8
- package/dist/utils/evaluation/type.d.ts +1 -0
- package/dist/utils/load-aigne.d.ts +3 -1
- package/dist/utils/load-aigne.js +7 -3
- package/dist/utils/workers/run-aigne-in-child-process-worker.d.ts +2 -0
- package/dist/utils/workers/run-aigne-in-child-process-worker.js +2 -3
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.52.0-beta.1](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.52.0-beta...cli-v1.52.0-beta.1) (2025-10-22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* add validate/required support for terminal input ([#651](https://github.com/AIGNE-io/aigne-framework/issues/651)) ([3d7f94c](https://github.com/AIGNE-io/aigne-framework/commit/3d7f94c32c8ec7bebb8f71fb16ddd3dd74a2d255))
|
|
9
|
+
* improve model name parsing to handle complex model identifiers ([#654](https://github.com/AIGNE-io/aigne-framework/issues/654)) ([4b7faea](https://github.com/AIGNE-io/aigne-framework/commit/4b7faea97f33db34a51c49dde3d6c1cf2679f0cd))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Dependencies
|
|
13
|
+
|
|
14
|
+
* The following workspace dependencies were updated
|
|
15
|
+
* dependencies
|
|
16
|
+
* @aigne/afs-system-fs bumped to 1.0.2-beta.1
|
|
17
|
+
* @aigne/agent-library bumped to 1.21.49-beta.1
|
|
18
|
+
* @aigne/agentic-memory bumped to 1.0.49-beta.1
|
|
19
|
+
* @aigne/aigne-hub bumped to 0.10.3-beta.1
|
|
20
|
+
* @aigne/core bumped to 1.64.0-beta.1
|
|
21
|
+
* @aigne/default-memory bumped to 1.2.12-beta.1
|
|
22
|
+
* @aigne/openai bumped to 0.16.3-beta.1
|
|
23
|
+
* devDependencies
|
|
24
|
+
* @aigne/test-utils bumped to 0.5.56-beta.1
|
|
25
|
+
|
|
26
|
+
## [1.52.0-beta](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.51.0...cli-v1.52.0-beta) (2025-10-21)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* **cli:** add metadata traces including CLI version, app name, and version ([#646](https://github.com/AIGNE-io/aigne-framework/issues/646)) ([c64bd76](https://github.com/AIGNE-io/aigne-framework/commit/c64bd761ba4c9f3854be5feee208c711bff7a170))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* **cli:** prevent potential crashes when environment configurations are incomplete ([#645](https://github.com/AIGNE-io/aigne-framework/issues/645)) ([8ab3a1e](https://github.com/AIGNE-io/aigne-framework/commit/8ab3a1e208a2774987d5d23c7239971c41edfd25))
|
|
37
|
+
* **observability:** support time line as background ([#642](https://github.com/AIGNE-io/aigne-framework/issues/642)) ([6f47870](https://github.com/AIGNE-io/aigne-framework/commit/6f478702090e8106ddcfe318a4766e1246257503))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Dependencies
|
|
41
|
+
|
|
42
|
+
* The following workspace dependencies were updated
|
|
43
|
+
* dependencies
|
|
44
|
+
* @aigne/afs-system-fs bumped to 1.0.2-beta
|
|
45
|
+
* @aigne/agent-library bumped to 1.21.49-beta
|
|
46
|
+
* @aigne/agentic-memory bumped to 1.0.49-beta
|
|
47
|
+
* @aigne/aigne-hub bumped to 0.10.3-beta
|
|
48
|
+
* @aigne/core bumped to 1.64.0-beta
|
|
49
|
+
* @aigne/default-memory bumped to 1.2.12-beta
|
|
50
|
+
* @aigne/observability-api bumped to 0.11.3-beta
|
|
51
|
+
* @aigne/openai bumped to 0.16.3-beta
|
|
52
|
+
* devDependencies
|
|
53
|
+
* @aigne/test-utils bumped to 0.5.56-beta
|
|
54
|
+
|
|
3
55
|
## [1.51.0](https://github.com/AIGNE-io/aigne-framework/compare/cli-v1.51.0-beta.14...cli-v1.51.0) (2025-10-19)
|
|
4
56
|
|
|
5
57
|
|
package/dist/commands/app.d.ts
CHANGED
|
@@ -4,15 +4,19 @@ import { type AgentRunCommonOptions } from "../utils/yargs.js";
|
|
|
4
4
|
export declare function createAppCommands({ argv }?: {
|
|
5
5
|
argv?: string[];
|
|
6
6
|
}): CommandModule[];
|
|
7
|
-
export declare const agentCommandModule: ({ dir, agent, chat, }: {
|
|
7
|
+
export declare const agentCommandModule: ({ dir, agent, chat, version, packageName, }: {
|
|
8
8
|
dir: string;
|
|
9
9
|
agent: AgentInChildProcess;
|
|
10
10
|
chat?: boolean;
|
|
11
|
+
version?: string;
|
|
12
|
+
packageName?: string;
|
|
11
13
|
}) => CommandModule<unknown, AgentRunCommonOptions>;
|
|
12
|
-
export declare const cliAgentCommandModule: ({ dir, parent, cliAgent, }: {
|
|
14
|
+
export declare const cliAgentCommandModule: ({ dir, parent, cliAgent, version, packageName, }: {
|
|
13
15
|
dir: string;
|
|
14
16
|
parent?: string[];
|
|
15
17
|
cliAgent: CLIAgentInChildProcess;
|
|
18
|
+
version?: string;
|
|
19
|
+
packageName?: string;
|
|
16
20
|
}) => CommandModule<unknown, AgentRunCommonOptions>;
|
|
17
21
|
interface LoadApplicationOptions {
|
|
18
22
|
packageName: string;
|
package/dist/commands/app.js
CHANGED
|
@@ -7,6 +7,7 @@ import { logger } from "@aigne/core/utils/logger.js";
|
|
|
7
7
|
import { jsonSchemaToZod } from "@aigne/json-schema-to-zod";
|
|
8
8
|
import { Listr, PRESET_TIMER } from "@aigne/listr2";
|
|
9
9
|
import { joinURL } from "ufo";
|
|
10
|
+
import { AIGNE_CLI_VERSION } from "../constants.js";
|
|
10
11
|
import { downloadAndExtract } from "../utils/download.js";
|
|
11
12
|
import { withSpinner } from "../utils/spinner.js";
|
|
12
13
|
import { runAIGNEInChildProcess, } from "../utils/workers/run-aigne-in-child-process.js";
|
|
@@ -50,17 +51,23 @@ export function createAppCommands({ argv } = {}) {
|
|
|
50
51
|
});
|
|
51
52
|
if (aigne.cli?.chat) {
|
|
52
53
|
y.command({
|
|
53
|
-
...agentCommandModule({
|
|
54
|
+
...agentCommandModule({
|
|
55
|
+
dir,
|
|
56
|
+
agent: aigne.cli.chat,
|
|
57
|
+
chat: true,
|
|
58
|
+
version,
|
|
59
|
+
packageName: app.name,
|
|
60
|
+
}),
|
|
54
61
|
command: "$0",
|
|
55
62
|
});
|
|
56
63
|
}
|
|
57
64
|
for (const cliAgent of aigne.cli?.agents ?? []) {
|
|
58
|
-
y.command(cliAgentCommandModule({ dir, cliAgent }));
|
|
65
|
+
y.command(cliAgentCommandModule({ dir, cliAgent, version, packageName: app.name }));
|
|
59
66
|
}
|
|
60
67
|
y.option("model", {
|
|
61
68
|
type: "string",
|
|
62
69
|
description: "Model to use for the application, example: openai:gpt-4.1 or google:gemini-2.5-flash",
|
|
63
|
-
}).command(serveMcpCommandModule({ name: app.name, dir }));
|
|
70
|
+
}).command(serveMcpCommandModule({ name: app.name, version, dir }));
|
|
64
71
|
y.version(`${app.name} v${version}`).alias("version", "v");
|
|
65
72
|
}
|
|
66
73
|
return y.demandCommand();
|
|
@@ -68,7 +75,7 @@ export function createAppCommands({ argv } = {}) {
|
|
|
68
75
|
handler: () => { },
|
|
69
76
|
}));
|
|
70
77
|
}
|
|
71
|
-
const serveMcpCommandModule = ({ name, dir, }) => ({
|
|
78
|
+
const serveMcpCommandModule = ({ name, dir, version, }) => ({
|
|
72
79
|
command: "serve-mcp",
|
|
73
80
|
describe: `Serve ${name} a MCP server (streamable http)`,
|
|
74
81
|
builder: (yargs) => {
|
|
@@ -89,7 +96,14 @@ const serveMcpCommandModule = ({ name, dir, }) => ({
|
|
|
89
96
|
});
|
|
90
97
|
},
|
|
91
98
|
handler: async (options) => {
|
|
92
|
-
await serveMCPServerFromDir({
|
|
99
|
+
await serveMCPServerFromDir({
|
|
100
|
+
...options,
|
|
101
|
+
dir,
|
|
102
|
+
metadata: {
|
|
103
|
+
appName: name,
|
|
104
|
+
appVersion: version,
|
|
105
|
+
},
|
|
106
|
+
});
|
|
93
107
|
},
|
|
94
108
|
});
|
|
95
109
|
function isUpgradeCommand(argv) {
|
|
@@ -133,7 +147,7 @@ const upgradeCommandModule = ({ packageName, dir, }) => ({
|
|
|
133
147
|
console.log(`\n✅ ${packageName} is already at the latest version (${app.version})`);
|
|
134
148
|
},
|
|
135
149
|
});
|
|
136
|
-
export const agentCommandModule = ({ dir, agent, chat, }) => {
|
|
150
|
+
export const agentCommandModule = ({ dir, agent, chat, version, packageName, }) => {
|
|
137
151
|
return {
|
|
138
152
|
command: agent.name,
|
|
139
153
|
aliases: agent.alias || [],
|
|
@@ -148,12 +162,17 @@ export const agentCommandModule = ({ dir, agent, chat, }) => {
|
|
|
148
162
|
dir,
|
|
149
163
|
agent: agent.name,
|
|
150
164
|
input: { ...options, chat: chat ?? options.chat },
|
|
165
|
+
metadata: {
|
|
166
|
+
cliVersion: AIGNE_CLI_VERSION,
|
|
167
|
+
appName: packageName,
|
|
168
|
+
appVersion: version,
|
|
169
|
+
},
|
|
151
170
|
});
|
|
152
171
|
process.exit(0);
|
|
153
172
|
},
|
|
154
173
|
};
|
|
155
174
|
};
|
|
156
|
-
export const cliAgentCommandModule = ({ dir, parent, cliAgent, }) => {
|
|
175
|
+
export const cliAgentCommandModule = ({ dir, parent, cliAgent, version, packageName, }) => {
|
|
157
176
|
const { agent, agents } = cliAgent;
|
|
158
177
|
const name = cliAgent.name || agent?.name;
|
|
159
178
|
assert(name, "CLI agent must have a name");
|
|
@@ -167,7 +186,13 @@ export const cliAgentCommandModule = ({ dir, parent, cliAgent, }) => {
|
|
|
167
186
|
}
|
|
168
187
|
if (agents?.length) {
|
|
169
188
|
for (const cmd of agents) {
|
|
170
|
-
yargs.command(cliAgentCommandModule({
|
|
189
|
+
yargs.command(cliAgentCommandModule({
|
|
190
|
+
dir,
|
|
191
|
+
parent: (parent ?? []).concat(name),
|
|
192
|
+
cliAgent: cmd,
|
|
193
|
+
version,
|
|
194
|
+
packageName,
|
|
195
|
+
}));
|
|
171
196
|
}
|
|
172
197
|
}
|
|
173
198
|
if (!agent)
|
|
@@ -184,6 +209,11 @@ export const cliAgentCommandModule = ({ dir, parent, cliAgent, }) => {
|
|
|
184
209
|
parent,
|
|
185
210
|
agent: name,
|
|
186
211
|
input: options,
|
|
212
|
+
metadata: {
|
|
213
|
+
cliVersion: AIGNE_CLI_VERSION,
|
|
214
|
+
appName: packageName,
|
|
215
|
+
appVersion: version,
|
|
216
|
+
},
|
|
187
217
|
});
|
|
188
218
|
process.exit(0);
|
|
189
219
|
},
|
|
@@ -196,6 +226,10 @@ export async function loadApplication(options) {
|
|
|
196
226
|
const aigne = await runAIGNEInChildProcess("loadAIGNE", {
|
|
197
227
|
path: dir,
|
|
198
228
|
skipModelLoading: true,
|
|
229
|
+
metadata: {
|
|
230
|
+
appName: packageName,
|
|
231
|
+
appVersion: check?.version,
|
|
232
|
+
},
|
|
199
233
|
}).catch(async (error) => {
|
|
200
234
|
logger.error(`⚠️ Failed to load ${packageName}, trying to reinstall:`, error.message);
|
|
201
235
|
await withSpinner("", async () => {
|
|
@@ -211,7 +245,14 @@ export async function loadApplication(options) {
|
|
|
211
245
|
return null;
|
|
212
246
|
const result = await installApp({ dir, packageName, beta: check?.version?.includes("beta") });
|
|
213
247
|
return {
|
|
214
|
-
aigne: await runAIGNEInChildProcess("loadAIGNE", {
|
|
248
|
+
aigne: await runAIGNEInChildProcess("loadAIGNE", {
|
|
249
|
+
path: dir,
|
|
250
|
+
skipModelLoading: true,
|
|
251
|
+
metadata: {
|
|
252
|
+
appName: packageName,
|
|
253
|
+
appVersion: result.version,
|
|
254
|
+
},
|
|
255
|
+
}),
|
|
215
256
|
version: result.version,
|
|
216
257
|
};
|
|
217
258
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AIGNEMetadata } from "@aigne/core/aigne/type.js";
|
|
1
2
|
import type { CommandModule } from "yargs";
|
|
2
3
|
interface ServeMCPOptions {
|
|
3
4
|
path: string;
|
|
@@ -15,5 +16,6 @@ export declare function serveMCPServerFromDir(options: {
|
|
|
15
16
|
port?: number;
|
|
16
17
|
pathname: string;
|
|
17
18
|
aigneHubUrl?: string;
|
|
19
|
+
metadata?: AIGNEMetadata;
|
|
18
20
|
}): Promise<void>;
|
|
19
21
|
export {};
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { render } from "ink";
|
|
2
|
+
export declare function terminalInput({ render: r, ...options }?: {
|
|
2
3
|
message?: string;
|
|
3
4
|
default?: string;
|
|
4
5
|
inline?: boolean;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
validate?: (input: string) => string | boolean | Promise<string | boolean>;
|
|
8
|
+
render?: typeof render;
|
|
5
9
|
}): Promise<string>;
|
|
10
|
+
export declare function TerminalInput(props: {
|
|
11
|
+
message?: string;
|
|
12
|
+
default?: string;
|
|
13
|
+
inline?: boolean;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
validate?: (input: string) => string | boolean | Promise<string | boolean>;
|
|
16
|
+
onSubmit: (input: string) => void;
|
|
17
|
+
onError: (error: Error) => void;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,30 +2,37 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { ExitPromptError } from "@inquirer/core";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { Box, render, Text, useInput } from "ink";
|
|
5
|
-
import { useState } from "react";
|
|
5
|
+
import { useRef, useState } from "react";
|
|
6
6
|
import { useTextBuffer } from "./text-buffer.js";
|
|
7
|
-
export async function terminalInput(options = {}) {
|
|
7
|
+
export async function terminalInput({ render: r = render, ...options } = {}) {
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
|
-
|
|
9
|
+
const handleSigInt = () => {
|
|
10
10
|
reject(new Error("Input aborted"));
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
};
|
|
12
|
+
process.addListener("SIGINT", handleSigInt);
|
|
13
|
+
const clean = () => process.removeListener("SIGINT", handleSigInt);
|
|
14
|
+
const app = r(_jsx(TerminalInput, { ...options, onSubmit: (value) => {
|
|
13
15
|
app.unmount();
|
|
14
16
|
resolve(value);
|
|
17
|
+
clean();
|
|
15
18
|
}, onError: (error) => {
|
|
16
19
|
app.unmount();
|
|
17
20
|
reject(error);
|
|
21
|
+
clean();
|
|
18
22
|
} }), { exitOnCtrlC: false });
|
|
19
23
|
});
|
|
20
24
|
}
|
|
21
|
-
function
|
|
25
|
+
export function TerminalInput(props) {
|
|
22
26
|
const buffer = useTextBuffer({
|
|
23
27
|
initialText: props.default || "",
|
|
24
28
|
initialCursorOffset: props.default?.length || 0,
|
|
25
29
|
isValidPath: () => false,
|
|
26
30
|
viewport: { width: 80, height: 1 },
|
|
27
31
|
});
|
|
32
|
+
const textRef = useRef(buffer.text);
|
|
33
|
+
textRef.current = buffer.text;
|
|
28
34
|
const [status, setStatus] = useState("input");
|
|
35
|
+
const [errorMessage, setErrorMessage] = useState();
|
|
29
36
|
useInput((character, key) => {
|
|
30
37
|
if (character === "c" && key.ctrl) {
|
|
31
38
|
setStatus("error");
|
|
@@ -35,10 +42,37 @@ function Input(props) {
|
|
|
35
42
|
return;
|
|
36
43
|
}
|
|
37
44
|
if (key.return) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
const input = textRef.current || props.default || "";
|
|
46
|
+
setStatus("validating");
|
|
47
|
+
setErrorMessage(undefined);
|
|
48
|
+
// Handle validation
|
|
49
|
+
const validateInput = async () => {
|
|
50
|
+
try {
|
|
51
|
+
// Check required validation first
|
|
52
|
+
if (props.required && !input.trim()) {
|
|
53
|
+
setErrorMessage("You must provide a value");
|
|
54
|
+
setStatus("input");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// Run custom validation if provided
|
|
58
|
+
if (props.validate) {
|
|
59
|
+
const result = await props.validate(input);
|
|
60
|
+
if (result !== true) {
|
|
61
|
+
setErrorMessage(typeof result === "string" ? result : "You must provide a valid value");
|
|
62
|
+
setStatus("input");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Validation passed
|
|
67
|
+
setStatus("success");
|
|
68
|
+
props.onSubmit(input);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
setErrorMessage(error instanceof Error ? error.message : "Validation error");
|
|
72
|
+
setStatus("input");
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
validateInput();
|
|
42
76
|
return;
|
|
43
77
|
}
|
|
44
78
|
else if (key.backspace)
|
|
@@ -59,6 +93,7 @@ function Input(props) {
|
|
|
59
93
|
buffer.move("end");
|
|
60
94
|
else {
|
|
61
95
|
buffer.handleInput({ ...key, name: character, sequence: character, paste: false });
|
|
96
|
+
setErrorMessage(undefined);
|
|
62
97
|
}
|
|
63
98
|
});
|
|
64
99
|
const lines = [...buffer.lines];
|
|
@@ -72,10 +107,11 @@ function Input(props) {
|
|
|
72
107
|
}
|
|
73
108
|
const label = props.message && chalk.bold(props.message);
|
|
74
109
|
const inline = props.inline !== false;
|
|
75
|
-
return (_jsxs(Box, { flexDirection: inline ? "row" : "column", children: [_jsxs(Text, { children: [PREFIX[status], " ", !inline && label] }), _jsx(Box, { flexShrink: 1, flexGrow: 1, marginLeft: inline ? 0 : 2, marginRight: 1, children: _jsxs(Text, { children: [!!label && inline && `${label} `, lines.join("\n")] }) })] }));
|
|
110
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { flexDirection: inline ? "row" : "column", children: [_jsxs(Text, { children: [PREFIX[status], " ", !inline && label] }), _jsx(Box, { flexShrink: 1, flexGrow: 1, marginLeft: inline ? 0 : 2, marginRight: 1, children: _jsxs(Text, { children: [!!label && inline && `${label} `, lines.join("\n")] }) })] }), errorMessage && (_jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: errorMessage }) }))] }));
|
|
76
111
|
}
|
|
77
112
|
const PREFIX = {
|
|
78
113
|
input: chalk.blue("?"),
|
|
114
|
+
validating: chalk.yellow("⋯"),
|
|
79
115
|
success: chalk.green("✔"),
|
|
80
116
|
error: chalk.red("✘"),
|
|
81
117
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ChatModel, ChatModelInputOptions, ImageModel, ImageModelInputOptions } from "@aigne/core";
|
|
2
2
|
import type { LoadCredentialOptions } from "./type.js";
|
|
3
3
|
export declare function maskApiKey(apiKey?: string): string | undefined;
|
|
4
|
-
export declare const parseModelOption: (model: string) => {
|
|
5
|
-
provider: string | undefined;
|
|
6
|
-
model: string | undefined;
|
|
7
|
-
};
|
|
8
4
|
export declare const formatModelName: (model: string, inquirerPrompt: NonNullable<LoadCredentialOptions["inquirerPromptFn"]>) => Promise<{
|
|
9
5
|
provider: string;
|
|
10
6
|
model?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import { AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_URL, findImageModel, findModel, } from "@aigne/aigne-hub";
|
|
2
|
+
import { AIGNE_HUB_DEFAULT_MODEL, AIGNE_HUB_URL, findImageModel, findModel, parseModel, } from "@aigne/aigne-hub";
|
|
3
3
|
import { flat, omit } from "@aigne/core/utils/type-utils.js";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import inquirer from "inquirer";
|
|
@@ -13,13 +13,8 @@ export function maskApiKey(apiKey) {
|
|
|
13
13
|
const end = apiKey.slice(-4);
|
|
14
14
|
return `${start}${"*".repeat(8)}${end}`;
|
|
15
15
|
}
|
|
16
|
-
export const parseModelOption = (model) => {
|
|
17
|
-
model = model.replace(":", "/");
|
|
18
|
-
const { provider, name } = model.match(/(?<provider>[^/]*)(\/(?<name>.*))?/)?.groups ?? {};
|
|
19
|
-
return { provider: provider?.replace(/-/g, ""), model: name };
|
|
20
|
-
};
|
|
21
16
|
export const formatModelName = async (model, inquirerPrompt) => {
|
|
22
|
-
let { provider, model: name } =
|
|
17
|
+
let { provider, model: name } = parseModel(model);
|
|
23
18
|
provider ||= AIGNE_HUB_PROVIDER;
|
|
24
19
|
const { match, all } = findModel(provider);
|
|
25
20
|
if (!match) {
|
|
@@ -56,7 +51,7 @@ export const formatModelName = async (model, inquirerPrompt) => {
|
|
|
56
51
|
console.log(chalk.yellow(`You can use command "export ${requireEnvs[0]}=xxx" to set API Key in your shell. Or you can set environment variables in .env file.`));
|
|
57
52
|
process.exit(0);
|
|
58
53
|
}
|
|
59
|
-
if (!envs.default?.AIGNE_HUB_API_URL) {
|
|
54
|
+
if (envs && Object.keys(envs).length > 0 && !envs.default?.AIGNE_HUB_API_URL) {
|
|
60
55
|
const host = new URL(AIGNE_HUB_URL).host;
|
|
61
56
|
const defaultEnv = envs[host]?.AIGNE_HUB_API_URL
|
|
62
57
|
? envs[host]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AIGNE, type ChatModelInputOptions, type ImageModelInputOptions } from "@aigne/core";
|
|
2
|
+
import type { AIGNEMetadata } from "@aigne/core/aigne/type.js";
|
|
2
3
|
import type { LoadCredentialOptions } from "./aigne-hub/type.js";
|
|
3
4
|
import type { AgentRunCommonOptions } from "./yargs.js";
|
|
4
5
|
export interface RunOptions extends AgentRunCommonOptions {
|
|
@@ -7,10 +8,11 @@ export interface RunOptions extends AgentRunCommonOptions {
|
|
|
7
8
|
cacheDir?: string;
|
|
8
9
|
aigneHubUrl?: string;
|
|
9
10
|
}
|
|
10
|
-
export declare function loadAIGNE({ path, modelOptions, imageModelOptions, printTips, skipModelLoading, }: {
|
|
11
|
+
export declare function loadAIGNE({ path, modelOptions, imageModelOptions, printTips, skipModelLoading, metadata, }: {
|
|
11
12
|
path?: string;
|
|
12
13
|
modelOptions?: ChatModelInputOptions & LoadCredentialOptions;
|
|
13
14
|
imageModelOptions?: ImageModelInputOptions & LoadCredentialOptions;
|
|
14
15
|
printTips?: boolean;
|
|
15
16
|
skipModelLoading?: boolean;
|
|
17
|
+
metadata?: AIGNEMetadata;
|
|
16
18
|
}): Promise<AIGNE<import("@aigne/core").UserContext>>;
|
package/dist/utils/load-aigne.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AIGNE, } from "@aigne/core";
|
|
|
2
2
|
import { isNil, omitBy } from "@aigne/core/utils/type-utils.js";
|
|
3
3
|
import boxen from "boxen";
|
|
4
4
|
import chalk from "chalk";
|
|
5
|
-
import { availableMemories } from "../constants.js";
|
|
5
|
+
import { AIGNE_CLI_VERSION, availableMemories } from "../constants.js";
|
|
6
6
|
import { loadChatModel, loadImageModel, maskApiKey } from "./aigne-hub/model.js";
|
|
7
7
|
import { getUrlOrigin } from "./get-url-origin.js";
|
|
8
8
|
let printed = false;
|
|
@@ -21,7 +21,7 @@ async function printChatModelInfoBox(model) {
|
|
|
21
21
|
console.log(boxen(lines.join("\n"), { padding: 1, borderStyle: "classic", borderColor: "cyan" }));
|
|
22
22
|
console.log("");
|
|
23
23
|
}
|
|
24
|
-
export async function loadAIGNE({ path, modelOptions, imageModelOptions, printTips = false, skipModelLoading = false, }) {
|
|
24
|
+
export async function loadAIGNE({ path, modelOptions, imageModelOptions, printTips = false, skipModelLoading = false, metadata, }) {
|
|
25
25
|
let aigne;
|
|
26
26
|
if (path) {
|
|
27
27
|
aigne = await AIGNE.load(path, {
|
|
@@ -52,11 +52,15 @@ export async function loadAIGNE({ path, modelOptions, imageModelOptions, printTi
|
|
|
52
52
|
},
|
|
53
53
|
],
|
|
54
54
|
},
|
|
55
|
+
metadata: { ...metadata, cliVersion: AIGNE_CLI_VERSION },
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
59
|
const chatModel = await loadChatModel({ ...modelOptions });
|
|
59
|
-
aigne = new AIGNE({
|
|
60
|
+
aigne = new AIGNE({
|
|
61
|
+
model: chatModel,
|
|
62
|
+
metadata: { ...metadata, cliVersion: AIGNE_CLI_VERSION },
|
|
63
|
+
});
|
|
60
64
|
}
|
|
61
65
|
if (printTips && !printed) {
|
|
62
66
|
printed = true;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Message } from "@aigne/core";
|
|
2
|
+
import type { AIGNEMetadata } from "@aigne/core/aigne/type.js";
|
|
2
3
|
import { loadAIGNE } from "../load-aigne.js";
|
|
3
4
|
import { type AgentRunCommonOptions } from "../yargs.js";
|
|
4
5
|
import { type AgentInChildProcess, type CLIAgentInChildProcess } from "./run-aigne-in-child-process.js";
|
|
@@ -17,4 +18,5 @@ export declare function invokeCLIAgentFromDirInChildProcess(options: {
|
|
|
17
18
|
parent?: string[];
|
|
18
19
|
agent: string;
|
|
19
20
|
input: Message & AgentRunCommonOptions;
|
|
21
|
+
metadata?: AIGNEMetadata;
|
|
20
22
|
}): Promise<void>;
|
|
@@ -53,9 +53,8 @@ export async function invokeCLIAgentFromDirInChildProcess(options) {
|
|
|
53
53
|
path: options.dir,
|
|
54
54
|
modelOptions: options.input,
|
|
55
55
|
printTips: true,
|
|
56
|
-
imageModelOptions: {
|
|
57
|
-
|
|
58
|
-
},
|
|
56
|
+
imageModelOptions: { model: options.input.imageModel },
|
|
57
|
+
metadata: options.metadata,
|
|
59
58
|
});
|
|
60
59
|
try {
|
|
61
60
|
const { chat } = aigne.cli;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.52.0-beta.1",
|
|
4
4
|
"description": "Your command center for agent development",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -89,14 +89,14 @@
|
|
|
89
89
|
"yoctocolors-cjs": "^2.1.3",
|
|
90
90
|
"zod": "^3.25.67",
|
|
91
91
|
"zod-to-json-schema": "^3.24.6",
|
|
92
|
-
"@aigne/afs-system-fs": "^1.0.1",
|
|
93
|
-
"@aigne/agent-library": "^1.21.
|
|
94
|
-
"@aigne/
|
|
95
|
-
"@aigne/
|
|
96
|
-
"@aigne/
|
|
97
|
-
"@aigne/default-memory": "^1.2.
|
|
98
|
-
"@aigne/
|
|
99
|
-
"@aigne/
|
|
92
|
+
"@aigne/afs-system-fs": "^1.0.2-beta.1",
|
|
93
|
+
"@aigne/agent-library": "^1.21.49-beta.1",
|
|
94
|
+
"@aigne/agentic-memory": "^1.0.49-beta.1",
|
|
95
|
+
"@aigne/core": "^1.64.0-beta.1",
|
|
96
|
+
"@aigne/aigne-hub": "^0.10.3-beta.1",
|
|
97
|
+
"@aigne/default-memory": "^1.2.12-beta.1",
|
|
98
|
+
"@aigne/openai": "^0.16.3-beta.1",
|
|
99
|
+
"@aigne/observability-api": "^0.11.3-beta"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@inquirer/testing": "^2.1.50",
|
|
@@ -109,11 +109,12 @@
|
|
|
109
109
|
"@types/yargs": "^17.0.33",
|
|
110
110
|
"archiver": "^7.0.1",
|
|
111
111
|
"hono": "4.8.4",
|
|
112
|
+
"ink-testing-library": "^4.0.0",
|
|
112
113
|
"npm-run-all": "^4.1.5",
|
|
113
114
|
"rimraf": "^6.0.1",
|
|
114
115
|
"typescript": "^5.9.2",
|
|
115
116
|
"ufo": "^1.6.1",
|
|
116
|
-
"@aigne/test-utils": "^0.5.
|
|
117
|
+
"@aigne/test-utils": "^0.5.56-beta.1"
|
|
117
118
|
},
|
|
118
119
|
"scripts": {
|
|
119
120
|
"lint": "tsc --noEmit",
|