@aigne/cli 1.59.0-beta.3 → 1.59.0-beta.30
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 +556 -0
- package/dist/commands/aigne.js +2 -0
- package/dist/commands/app/agent.d.ts +2 -2
- package/dist/commands/app/agent.js +10 -4
- package/dist/commands/app/app.js +1 -1
- package/dist/commands/run-skill.d.ts +6 -0
- package/dist/commands/run-skill.js +102 -0
- package/dist/commands/run.d.ts +1 -1
- package/dist/commands/run.js +15 -13
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/tracer/terminal.js +18 -0
- package/dist/ui/utils/terminal-input.d.ts +1 -0
- package/dist/ui/utils/terminal-input.js +4 -0
- package/dist/utils/aigne-hub/credential.d.ts +0 -3
- package/dist/utils/aigne-hub/credential.js +17 -24
- package/dist/utils/aigne-hub/crypto.js +22 -1
- package/dist/utils/aigne-hub/store/index.d.ts +1 -0
- package/dist/utils/aigne-hub/store/index.js +5 -2
- package/dist/utils/inquirer/checkbox.js +0 -1
- package/dist/utils/listr.d.ts +3 -1
- package/dist/utils/listr.js +59 -8
- package/dist/utils/load-aigne.d.ts +2 -1
- package/dist/utils/load-aigne.js +6 -11
- package/dist/utils/run-chat-loop.d.ts +2 -0
- package/dist/utils/run-chat-loop.js +2 -3
- package/dist/utils/run-with-aigne.d.ts +3 -1
- package/dist/utils/run-with-aigne.js +33 -4
- package/dist/utils/yargs.d.ts +6 -2
- package/dist/utils/yargs.js +7 -2
- package/package.json +19 -16
- package/templates/default/README.md +1 -1
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { mkdir, stat, writeFile } from "node:fs/promises";
|
|
2
2
|
import { dirname, isAbsolute, join } from "node:path";
|
|
3
3
|
import { isatty } from "node:tty";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { startExplorer } from "@aigne/afs-explorer";
|
|
4
6
|
import { exists } from "@aigne/agent-library/utils/fs.js";
|
|
5
7
|
import { AIAgent, DEFAULT_OUTPUT_KEY, UserAgent, } from "@aigne/core";
|
|
6
8
|
import { logger } from "@aigne/core/utils/logger.js";
|
|
7
9
|
import { isEmpty, isNil, omitBy, pick } from "@aigne/core/utils/type-utils.js";
|
|
10
|
+
import { v7 } from "@aigne/uuid";
|
|
8
11
|
import chalk from "chalk";
|
|
12
|
+
import { detect } from "detect-port";
|
|
9
13
|
import yargs from "yargs";
|
|
10
14
|
import { hideBin } from "yargs/helpers";
|
|
15
|
+
import { DEFAULT_AFS_EXPLORER_PORT, DEFAULT_USER_ID } from "../constants.js";
|
|
11
16
|
import { TerminalTracer } from "../tracer/terminal.js";
|
|
12
|
-
import { loadAIGNE } from "./load-aigne.js";
|
|
17
|
+
import { loadAIGNE, printChatModelInfoBox } from "./load-aigne.js";
|
|
13
18
|
import { DEFAULT_CHAT_INPUT_KEY, runChatLoopInTerminal, } from "./run-chat-loop.js";
|
|
14
19
|
import { parseAgentInput, withAgentInputSchema, withRunAgentCommonOptions, } from "./yargs.js";
|
|
15
20
|
export async function parseAgentInputByCommander(agent, options = {}) {
|
|
@@ -52,6 +57,8 @@ export async function runWithAIGNE(agentCreator, { aigne, argv = process.argv, c
|
|
|
52
57
|
...omitBy(pick(options, "model", "temperature", "topP", "presencePenalty", "frequencyPenalty"), (v) => isNil(v)),
|
|
53
58
|
},
|
|
54
59
|
});
|
|
60
|
+
let explorerServer;
|
|
61
|
+
let explorerServerURL;
|
|
55
62
|
try {
|
|
56
63
|
const agent = typeof agentCreator === "function" ? await agentCreator(aigne) : agentCreator;
|
|
57
64
|
const input = await parseAgentInputByCommander(agent, {
|
|
@@ -59,14 +66,34 @@ export async function runWithAIGNE(agentCreator, { aigne, argv = process.argv, c
|
|
|
59
66
|
inputKey: chatLoopOptions?.inputKey,
|
|
60
67
|
defaultInput: chatLoopOptions?.initialCall || chatLoopOptions?.defaultQuestion,
|
|
61
68
|
});
|
|
69
|
+
if (agent.afs) {
|
|
70
|
+
const port = await detect(DEFAULT_AFS_EXPLORER_PORT);
|
|
71
|
+
explorerServer = await startExplorer(agent.afs, {
|
|
72
|
+
port,
|
|
73
|
+
distPath: dirname(fileURLToPath(import.meta.resolve("@aigne/afs-explorer/index.html"))),
|
|
74
|
+
});
|
|
75
|
+
explorerServerURL = `http://localhost:${port}`;
|
|
76
|
+
}
|
|
77
|
+
if (aigne.model) {
|
|
78
|
+
const lines = [];
|
|
79
|
+
if (explorerServerURL) {
|
|
80
|
+
lines.push(`${chalk.cyan("AFS Explorer")}: ${chalk.green(explorerServerURL)}`);
|
|
81
|
+
}
|
|
82
|
+
await printChatModelInfoBox(aigne.model, lines);
|
|
83
|
+
}
|
|
84
|
+
if (chatLoopOptions?.welcome)
|
|
85
|
+
console.log(chatLoopOptions.welcome);
|
|
62
86
|
await runAgentWithAIGNE(aigne, agent, {
|
|
63
87
|
...options,
|
|
64
88
|
outputKey: outputKey || options.outputKey,
|
|
65
89
|
chatLoopOptions,
|
|
66
90
|
input,
|
|
91
|
+
sessionId: chatLoopOptions?.sessionId || v7(),
|
|
92
|
+
userId: DEFAULT_USER_ID,
|
|
67
93
|
});
|
|
68
94
|
}
|
|
69
95
|
finally {
|
|
96
|
+
await explorerServer?.stop();
|
|
70
97
|
await aigne.shutdown();
|
|
71
98
|
}
|
|
72
99
|
})
|
|
@@ -84,7 +111,7 @@ export async function runWithAIGNE(agentCreator, { aigne, argv = process.argv, c
|
|
|
84
111
|
process.exit(1);
|
|
85
112
|
});
|
|
86
113
|
}
|
|
87
|
-
export async function runAgentWithAIGNE(aigne, agent, { outputKey, outputFileKey, chatLoopOptions, ...options } = {}) {
|
|
114
|
+
export async function runAgentWithAIGNE(aigne, agent, { userId, sessionId, outputKey, outputFileKey, chatLoopOptions, ...options } = {}) {
|
|
88
115
|
if (options.output) {
|
|
89
116
|
const outputPath = isAbsolute(options.output)
|
|
90
117
|
? options.output
|
|
@@ -102,9 +129,9 @@ export async function runAgentWithAIGNE(aigne, agent, { outputKey, outputFileKey
|
|
|
102
129
|
}
|
|
103
130
|
await writeFile(outputPath, "", "utf8");
|
|
104
131
|
}
|
|
105
|
-
if (options.
|
|
132
|
+
if (options.interactive) {
|
|
106
133
|
if (!isatty(process.stdout.fd)) {
|
|
107
|
-
throw new Error("--
|
|
134
|
+
throw new Error("--interactive mode requires a TTY terminal");
|
|
108
135
|
}
|
|
109
136
|
const userAgent = agent instanceof UserAgent ? agent : aigne.invoke(agent);
|
|
110
137
|
await runChatLoopInTerminal(userAgent, {
|
|
@@ -112,6 +139,8 @@ export async function runAgentWithAIGNE(aigne, agent, { outputKey, outputFileKey
|
|
|
112
139
|
outputKey,
|
|
113
140
|
inputFileKey: agent instanceof AIAgent ? agent.inputFileKey : undefined,
|
|
114
141
|
input: options.input,
|
|
142
|
+
sessionId,
|
|
143
|
+
userId,
|
|
115
144
|
});
|
|
116
145
|
return;
|
|
117
146
|
}
|
package/dist/utils/yargs.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ import type { Argv } from "yargs";
|
|
|
4
4
|
import { ZodType } from "zod";
|
|
5
5
|
export type InferArgv<T> = T extends Argv<infer U> ? U : never;
|
|
6
6
|
export declare const withRunAgentCommonOptions: (yargs: Argv) => Argv<{
|
|
7
|
-
|
|
7
|
+
interactive: boolean;
|
|
8
|
+
} & {
|
|
9
|
+
"session-id": string | undefined;
|
|
8
10
|
} & {
|
|
9
11
|
model: string | undefined;
|
|
10
12
|
} & {
|
|
@@ -55,7 +57,9 @@ export declare function inferZodType(type: ZodType, opts?: {
|
|
|
55
57
|
export declare function withAgentInputSchema(yargs: Argv, options: Pick<Agent, "inputSchema"> & {
|
|
56
58
|
optionalInputs?: string[];
|
|
57
59
|
}): Argv<{
|
|
58
|
-
|
|
60
|
+
interactive: boolean;
|
|
61
|
+
} & {
|
|
62
|
+
"session-id": string | undefined;
|
|
59
63
|
} & {
|
|
60
64
|
model: string | undefined;
|
|
61
65
|
} & {
|
package/dist/utils/yargs.js
CHANGED
|
@@ -11,10 +11,15 @@ import { parse } from "yaml";
|
|
|
11
11
|
import z, { ZodAny, ZodArray, ZodBoolean, ZodError, ZodNumber, ZodObject, ZodString, ZodType, ZodUnknown, } from "zod";
|
|
12
12
|
const MODEL_OPTIONS_GROUP_NAME = "Model Options";
|
|
13
13
|
export const withRunAgentCommonOptions = (yargs) => yargs
|
|
14
|
-
.option("
|
|
15
|
-
describe: "Run
|
|
14
|
+
.option("interactive", {
|
|
15
|
+
describe: "Run in interactive chat mode",
|
|
16
16
|
type: "boolean",
|
|
17
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",
|
|
18
23
|
})
|
|
19
24
|
.option("model", {
|
|
20
25
|
group: MODEL_OPTIONS_GROUP_NAME,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/cli",
|
|
3
|
-
"version": "1.59.0-beta.
|
|
3
|
+
"version": "1.59.0-beta.30",
|
|
4
4
|
"description": "Your command center for agent development",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@aigne/json-schema-to-zod": "^1.3.3",
|
|
49
49
|
"@aigne/listr2": "^1.0.10",
|
|
50
50
|
"@aigne/marked-terminal": "^7.3.2",
|
|
51
|
+
"@aigne/uuid": "^13.0.1",
|
|
51
52
|
"@fast-csv/format": "^5.0.5",
|
|
52
53
|
"@inquirer/core": "^10.2.2",
|
|
53
54
|
"@inquirer/figures": "^1.0.13",
|
|
@@ -55,13 +56,13 @@
|
|
|
55
56
|
"@inquirer/type": "^3.0.8",
|
|
56
57
|
"@listr2/prompt-adapter-inquirer": "^3.0.4",
|
|
57
58
|
"@modelcontextprotocol/sdk": "^1.18.0",
|
|
58
|
-
"@ocap/mcrypto": "^1.27.14",
|
|
59
59
|
"@smithy/node-http-handler": "^4.2.1",
|
|
60
60
|
"ansi-escapes": "^7.1.0",
|
|
61
61
|
"ansi-regex": "^6.2.2",
|
|
62
62
|
"boxen": "^8.0.1",
|
|
63
63
|
"chalk": "^5.6.2",
|
|
64
64
|
"cli-table3": "^0.6.5",
|
|
65
|
+
"crypto-js": "^4.2.0",
|
|
65
66
|
"detect-port": "^2.1.0",
|
|
66
67
|
"dotenv-flow": "^4.1.0",
|
|
67
68
|
"express": "^5.1.0",
|
|
@@ -89,22 +90,24 @@
|
|
|
89
90
|
"yoctocolors-cjs": "^2.1.3",
|
|
90
91
|
"zod": "^3.25.67",
|
|
91
92
|
"zod-to-json-schema": "^3.24.6",
|
|
92
|
-
"@aigne/afs
|
|
93
|
-
"@aigne/afs-
|
|
94
|
-
"@aigne/afs": "^1.
|
|
95
|
-
"@aigne/
|
|
96
|
-
"@aigne/
|
|
97
|
-
"@aigne/
|
|
98
|
-
"@aigne/
|
|
99
|
-
"@aigne/
|
|
100
|
-
"@aigne/
|
|
101
|
-
"@aigne/
|
|
102
|
-
"@aigne/
|
|
93
|
+
"@aigne/afs": "^1.4.0-beta.10",
|
|
94
|
+
"@aigne/afs-explorer": "^1.0.0",
|
|
95
|
+
"@aigne/afs-history": "^1.2.0-beta.11",
|
|
96
|
+
"@aigne/afs-local-fs": "^1.4.0-beta.25",
|
|
97
|
+
"@aigne/agent-library": "^1.24.0-beta.26",
|
|
98
|
+
"@aigne/agentic-memory": "^1.1.6-beta.24",
|
|
99
|
+
"@aigne/aigne-hub": "^0.10.16-beta.30",
|
|
100
|
+
"@aigne/core": "^1.72.0-beta.24",
|
|
101
|
+
"@aigne/observability-api": "^0.11.14-beta.6",
|
|
102
|
+
"@aigne/openai": "^0.16.16-beta.24",
|
|
103
|
+
"@aigne/secrets": "^0.1.6-beta.24",
|
|
104
|
+
"@aigne/default-memory": "^1.4.0-beta.23"
|
|
103
105
|
},
|
|
104
106
|
"devDependencies": {
|
|
105
107
|
"@inquirer/testing": "^2.1.50",
|
|
106
108
|
"@types/archiver": "^6.0.3",
|
|
107
109
|
"@types/bun": "^1.2.22",
|
|
110
|
+
"@types/crypto-js": "^4.2.2",
|
|
108
111
|
"@types/express": "^5.0.3",
|
|
109
112
|
"@types/gradient-string": "^1.1.6",
|
|
110
113
|
"@types/node": "^24.5.1",
|
|
@@ -116,14 +119,14 @@
|
|
|
116
119
|
"rimraf": "^6.0.1",
|
|
117
120
|
"typescript": "^5.9.2",
|
|
118
121
|
"ufo": "^1.6.1",
|
|
119
|
-
"@aigne/test-utils": "^0.5.69-beta.
|
|
122
|
+
"@aigne/test-utils": "^0.5.69-beta.24"
|
|
120
123
|
},
|
|
121
124
|
"scripts": {
|
|
122
125
|
"lint": "tsc --noEmit",
|
|
123
126
|
"build": "tsc --build tsconfig.build.json",
|
|
124
127
|
"clean": "rimraf dist test/coverage templates/coverage",
|
|
125
|
-
"test": "run
|
|
126
|
-
"test:coverage": "run
|
|
128
|
+
"test": "npm run test:src && npm run test:templates",
|
|
129
|
+
"test:coverage": "npm run test:src:coverage && npm run test:templates:coverage",
|
|
127
130
|
"test:src": "bun --cwd test test",
|
|
128
131
|
"test:src:coverage": "bun --cwd test test --coverage --coverage-reporter=lcov --coverage-reporter=text",
|
|
129
132
|
"test:templates": "cd templates && node --test",
|