@aigne/cli 1.74.0-beta → 1.74.0-beta.2
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 +153 -14
- package/dist/commands/aigne.cjs +3 -4
- package/dist/commands/aigne.mjs +3 -4
- package/dist/commands/aigne.mjs.map +1 -1
- package/dist/commands/app/agent.cjs +2 -27
- package/dist/commands/app/agent.mjs +2 -26
- package/dist/commands/app/agent.mjs.map +1 -1
- package/dist/commands/create.cjs +1 -1
- package/dist/commands/create.mjs +1 -1
- package/dist/commands/eval.cjs +42 -3
- package/dist/commands/eval.mjs +43 -4
- package/dist/commands/eval.mjs.map +1 -1
- package/dist/commands/explain.cjs +340 -0
- package/dist/commands/explain.mjs +340 -0
- package/dist/commands/explain.mjs.map +1 -0
- package/dist/commands/hub.cjs +111 -14
- package/dist/commands/hub.mjs +111 -14
- package/dist/commands/hub.mjs.map +1 -1
- package/dist/commands/observe.cjs +44 -1
- package/dist/commands/observe.mjs +44 -1
- package/dist/commands/observe.mjs.map +1 -1
- package/dist/commands/run-skill.cjs +29 -13
- package/dist/commands/run-skill.mjs +29 -13
- package/dist/commands/run-skill.mjs.map +1 -1
- package/dist/commands/run.cjs +5 -4
- package/dist/commands/run.mjs +5 -4
- package/dist/commands/run.mjs.map +1 -1
- package/dist/commands/serve-mcp.cjs +49 -4
- package/dist/commands/serve-mcp.mjs +49 -3
- package/dist/commands/serve-mcp.mjs.map +1 -1
- package/dist/commands/shell.cjs +106 -0
- package/dist/commands/shell.mjs +105 -0
- package/dist/commands/shell.mjs.map +1 -0
- package/dist/shell/repl.cjs +544 -0
- package/dist/shell/repl.mjs +543 -0
- package/dist/shell/repl.mjs.map +1 -0
- package/dist/shell/tools/ask-user.cjs +191 -0
- package/dist/shell/tools/ask-user.mjs +187 -0
- package/dist/shell/tools/ask-user.mjs.map +1 -0
- package/dist/shell/tools/index.cjs +2 -0
- package/dist/shell/tools/index.mjs +4 -0
- package/dist/shell/tools/render.cjs +189 -0
- package/dist/shell/tools/render.mjs +186 -0
- package/dist/shell/tools/render.mjs.map +1 -0
- package/dist/tracer/terminal.cjs +120 -133
- package/dist/tracer/terminal.mjs +121 -134
- package/dist/tracer/terminal.mjs.map +1 -1
- package/dist/ui/utils/terminal-select.cjs +73 -0
- package/dist/ui/utils/terminal-select.mjs +72 -0
- package/dist/ui/utils/terminal-select.mjs.map +1 -0
- package/dist/utils/agent-v1.cjs +2 -2
- package/dist/utils/agent-v1.mjs +2 -2
- package/dist/utils/aigne-hub/credential.cjs +3 -3
- package/dist/utils/aigne-hub/credential.mjs +3 -3
- package/dist/utils/aigne-hub/model.cjs +2 -2
- package/dist/utils/aigne-hub/model.mjs +1 -1
- package/dist/utils/ascii-logo.cjs +12 -13
- package/dist/utils/ascii-logo.d.cts.map +1 -1
- package/dist/utils/ascii-logo.d.mts.map +1 -1
- package/dist/utils/ascii-logo.mjs +12 -13
- package/dist/utils/ascii-logo.mjs.map +1 -1
- package/dist/utils/evaluation/evaluator.cjs +1 -1
- package/dist/utils/evaluation/evaluator.mjs +1 -1
- package/dist/utils/evaluation/reporter.cjs +78 -1
- package/dist/utils/evaluation/reporter.mjs +76 -1
- package/dist/utils/evaluation/reporter.mjs.map +1 -1
- package/dist/utils/exit-codes.cjs +73 -0
- package/dist/utils/exit-codes.d.cts +52 -0
- package/dist/utils/exit-codes.d.cts.map +1 -0
- package/dist/utils/exit-codes.d.mts +52 -0
- package/dist/utils/exit-codes.d.mts.map +1 -0
- package/dist/utils/exit-codes.mjs +71 -0
- package/dist/utils/exit-codes.mjs.map +1 -0
- package/dist/utils/output.cjs +61 -0
- package/dist/utils/output.d.cts +43 -0
- package/dist/utils/output.d.cts.map +1 -0
- package/dist/utils/output.d.mts +43 -0
- package/dist/utils/output.d.mts.map +1 -0
- package/dist/utils/output.mjs +56 -0
- package/dist/utils/output.mjs.map +1 -0
- package/dist/utils/run-chat-loop.cjs +1 -1
- package/dist/utils/run-chat-loop.mjs +1 -1
- package/dist/utils/run-with-aigne.cjs +10 -3
- package/dist/utils/run-with-aigne.d.cts.map +1 -1
- package/dist/utils/run-with-aigne.d.mts.map +1 -1
- package/dist/utils/run-with-aigne.mjs +10 -3
- package/dist/utils/run-with-aigne.mjs.map +1 -1
- package/dist/utils/serve-mcp.cjs +1 -1
- package/dist/utils/serve-mcp.mjs +1 -1
- package/dist/utils/view.cjs +34 -0
- package/dist/utils/view.d.cts +47 -0
- package/dist/utils/view.d.cts.map +1 -0
- package/dist/utils/view.d.mts +47 -0
- package/dist/utils/view.d.mts.map +1 -0
- package/dist/utils/view.mjs +33 -0
- package/dist/utils/view.mjs.map +1 -0
- package/dist/utils/yargs.cjs +27 -5
- package/dist/utils/yargs.d.cts +13 -0
- package/dist/utils/yargs.d.cts.map +1 -1
- package/dist/utils/yargs.d.mts +14 -1
- package/dist/utils/yargs.d.mts.map +1 -1
- package/dist/utils/yargs.mjs +32 -10
- package/dist/utils/yargs.mjs.map +1 -1
- package/package.json +20 -16
- package/dist/commands/app/app.cjs +0 -92
- package/dist/commands/app/app.mjs +0 -90
- package/dist/commands/app/app.mjs.map +0 -1
- package/dist/commands/app/cli.cjs +0 -6
- package/dist/commands/app/cli.d.cts +0 -1
- package/dist/commands/app/cli.d.mts +0 -1
- package/dist/commands/app/cli.mjs +0 -8
- package/dist/commands/app/cli.mjs.map +0 -1
- package/dist/commands/app/upgrade.cjs +0 -243
- package/dist/commands/app/upgrade.mjs +0 -240
- package/dist/commands/app/upgrade.mjs.map +0 -1
- package/dist/commands/app.cjs +0 -53
- package/dist/commands/app.mjs +0 -53
- package/dist/commands/app.mjs.map +0 -1
- package/dist/commands/deploy.cjs +0 -237
- package/dist/commands/deploy.mjs +0 -237
- package/dist/commands/deploy.mjs.map +0 -1
- package/dist/utils/listr.cjs +0 -226
- package/dist/utils/listr.d.cts +0 -71
- package/dist/utils/listr.d.cts.map +0 -1
- package/dist/utils/listr.d.mts +0 -71
- package/dist/utils/listr.d.mts.map +0 -1
- package/dist/utils/listr.mjs +0 -222
- package/dist/utils/listr.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ Command-line tool for [AIGNE Framework](https://github.com/ArcBlock/aigne-framew
|
|
|
32
32
|
|
|
33
33
|
* **Project Creation**: Quickly create new AIGNE projects with predefined file structures and configurations
|
|
34
34
|
* **Agent Running**: Easily run and test AIGNE agents
|
|
35
|
+
* **Interactive Shell**: Full-featured REPL for LLM conversations with agent loading, session management, and built-in tools
|
|
35
36
|
* **Testing Support**: Built-in test command for unit testing and integration testing
|
|
36
37
|
* **MCP Services**: Support for launching agents as MCP servers for integration with external systems
|
|
37
38
|
* **Interactive Interface**: Beautiful command-line interface providing an intuitive user experience
|
|
@@ -68,17 +69,32 @@ aigne --help
|
|
|
68
69
|
# Create a new project
|
|
69
70
|
aigne create [path]
|
|
70
71
|
|
|
72
|
+
# Start interactive shell
|
|
73
|
+
aigne shell
|
|
74
|
+
|
|
71
75
|
# Run an agent
|
|
72
|
-
aigne run
|
|
76
|
+
aigne run [path]
|
|
77
|
+
|
|
78
|
+
# Run agent skills
|
|
79
|
+
aigne skill <paths..>
|
|
73
80
|
|
|
74
81
|
# Run tests
|
|
75
|
-
aigne test
|
|
82
|
+
aigne test
|
|
83
|
+
|
|
84
|
+
# Evaluate an agent
|
|
85
|
+
aigne eval [path]
|
|
76
86
|
|
|
77
87
|
# Start MCP server
|
|
78
|
-
aigne serve-mcp
|
|
88
|
+
aigne serve-mcp [path]
|
|
79
89
|
|
|
80
90
|
# Start observability server
|
|
81
|
-
aigne observe
|
|
91
|
+
aigne observe
|
|
92
|
+
|
|
93
|
+
# Manage AIGNE Hub connections
|
|
94
|
+
aigne hub <command>
|
|
95
|
+
|
|
96
|
+
# Get command documentation
|
|
97
|
+
aigne explain [command]
|
|
82
98
|
```
|
|
83
99
|
|
|
84
100
|
## Create Command
|
|
@@ -98,30 +114,118 @@ The interactive creation process will ask for:
|
|
|
98
114
|
* Project name
|
|
99
115
|
* Project template (currently supports the default template)
|
|
100
116
|
|
|
117
|
+
## Shell Command
|
|
118
|
+
|
|
119
|
+
Start an interactive shell for LLM conversations with full agent support.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Start shell with default model
|
|
123
|
+
aigne shell
|
|
124
|
+
|
|
125
|
+
# Start shell with specific model
|
|
126
|
+
aigne shell --model gpt-4
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Shell Features
|
|
130
|
+
|
|
131
|
+
* **Direct Mode**: Chat directly with LLM without loading agents
|
|
132
|
+
* **Agent Mode**: Load and interact with AIGNE agents
|
|
133
|
+
* **Conversation Context**: Maintains conversation history within session
|
|
134
|
+
* **Built-in Tools**: `ask_user` for user input, `render` for rich output
|
|
135
|
+
|
|
136
|
+
### Slash Commands
|
|
137
|
+
|
|
138
|
+
| Command | Description |
|
|
139
|
+
|---------|-------------|
|
|
140
|
+
| `/help` | Show available commands |
|
|
141
|
+
| `/exit`, `/quit` | Exit the shell |
|
|
142
|
+
| `/load <path>` | Load an agent from a path |
|
|
143
|
+
| `/list` | List loaded agents |
|
|
144
|
+
| `/switch <name>` | Switch to a different agent |
|
|
145
|
+
| `/unload <name>` | Unload an agent |
|
|
146
|
+
| `/info` | Show current agent info |
|
|
147
|
+
| `/mode [direct\|agent]` | Show or switch mode |
|
|
148
|
+
| `/run <path>` | Run an agent (single execution) |
|
|
149
|
+
| `/clear` | Clear conversation history |
|
|
150
|
+
| `/model` | Show current model info |
|
|
151
|
+
| `/explain <cmd>` | Explain CLI command |
|
|
152
|
+
|
|
153
|
+
### Example Session
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
$ aigne shell
|
|
157
|
+
aigne> Hello, what can you do?
|
|
158
|
+
I'm a helpful AI assistant...
|
|
159
|
+
|
|
160
|
+
aigne> /load ./my-agent
|
|
161
|
+
Loaded: my-agent
|
|
162
|
+
|
|
163
|
+
aigne [my-agent]> Process this data
|
|
164
|
+
Processing...
|
|
165
|
+
|
|
166
|
+
aigne [my-agent]> /mode direct
|
|
167
|
+
Switched to direct mode.
|
|
168
|
+
|
|
169
|
+
aigne> /exit
|
|
170
|
+
Goodbye!
|
|
171
|
+
```
|
|
172
|
+
|
|
101
173
|
## Run Command
|
|
102
174
|
|
|
103
|
-
Launch
|
|
175
|
+
Launch an agent or start an interactive chat session.
|
|
104
176
|
|
|
105
177
|
```bash
|
|
106
178
|
# Run the agent in the current directory
|
|
107
179
|
aigne run
|
|
108
180
|
|
|
109
181
|
# Run the agent at the specified path
|
|
110
|
-
aigne run
|
|
182
|
+
aigne run path/to/agents
|
|
111
183
|
|
|
112
184
|
# Run the agent from a remote URL
|
|
113
|
-
aigne run
|
|
185
|
+
aigne run https://example.com/aigne-project
|
|
114
186
|
|
|
115
187
|
# Run a specific agent
|
|
116
|
-
aigne run
|
|
188
|
+
aigne run path/to/agents myAgent
|
|
189
|
+
|
|
190
|
+
# Run with input message
|
|
191
|
+
aigne run -m "Hello, agent!"
|
|
117
192
|
```
|
|
118
193
|
|
|
119
194
|
Available options:
|
|
120
195
|
|
|
121
|
-
*
|
|
122
|
-
* `--cache-dir <dir>` - Specify the directory to download the package to (used in URL mode)
|
|
196
|
+
* `[entry-agent]` - Specify the agent name to run (defaults to the first agent found)
|
|
123
197
|
* `--model <provider[:model]>` - Specify the AI model in format 'provider\[:model]' where model is optional (e.g., 'openai' or 'openai:gpt-4o-mini')
|
|
124
|
-
*
|
|
198
|
+
* `-m, --input <message>` - Input message to send to the agent
|
|
199
|
+
* `-f, --input-file <file>` - Input file to send to the agent
|
|
200
|
+
* `--interactive, --chat` - Run in interactive chat mode
|
|
201
|
+
* `--json` - Output in JSON format
|
|
202
|
+
* `--view <type>` - Output view type (default|json|llm|human)
|
|
203
|
+
* `--log-level <level>` - Log level (silent|error|warn|info|debug)
|
|
204
|
+
|
|
205
|
+
## Skill Command
|
|
206
|
+
|
|
207
|
+
Run Agent Skills from specified directories.
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Run a single skill
|
|
211
|
+
aigne skill ./my-skill
|
|
212
|
+
|
|
213
|
+
# Run multiple skills
|
|
214
|
+
aigne skill ./skill1 ./skill2
|
|
215
|
+
|
|
216
|
+
# Run skill with input
|
|
217
|
+
aigne skill ./skill -m "Process this data"
|
|
218
|
+
|
|
219
|
+
# Run skill in interactive mode
|
|
220
|
+
aigne skill ./skill --interactive
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Available options:
|
|
224
|
+
|
|
225
|
+
* `<paths..>` - One or more paths to Agent Skill directories (required)
|
|
226
|
+
* `-m, --input <message>` - Input message for the skill
|
|
227
|
+
* `--interactive, --chat` - Run in interactive chat mode
|
|
228
|
+
* `--model <provider[:model]>` - Specify the AI model
|
|
125
229
|
|
|
126
230
|
## Test Command
|
|
127
231
|
|
|
@@ -150,18 +254,53 @@ aigne serve-mcp --port 3001
|
|
|
150
254
|
aigne serve-mcp --path path/to/agents
|
|
151
255
|
```
|
|
152
256
|
|
|
153
|
-
##
|
|
257
|
+
## Observe Command
|
|
154
258
|
|
|
155
|
-
Start the
|
|
259
|
+
Start the observability server for monitoring and debugging agents.
|
|
156
260
|
|
|
157
261
|
```bash
|
|
158
|
-
# Start observability server on default port
|
|
262
|
+
# Start observability server on default port
|
|
159
263
|
aigne observe
|
|
160
264
|
|
|
161
265
|
# Start observability server on specified port
|
|
162
266
|
aigne observe --port 3001
|
|
163
267
|
```
|
|
164
268
|
|
|
269
|
+
## Hub Command
|
|
270
|
+
|
|
271
|
+
Manage AIGNE Hub connections for accessing AI models.
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# List all connected hubs
|
|
275
|
+
aigne hub list
|
|
276
|
+
|
|
277
|
+
# Connect to an AIGNE Hub
|
|
278
|
+
aigne hub connect
|
|
279
|
+
|
|
280
|
+
# Show connection status
|
|
281
|
+
aigne hub status
|
|
282
|
+
|
|
283
|
+
# Switch active hub
|
|
284
|
+
aigne hub use
|
|
285
|
+
|
|
286
|
+
# Remove a hub connection
|
|
287
|
+
aigne hub remove
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Explain Command
|
|
291
|
+
|
|
292
|
+
Get machine-readable documentation for commands (useful for LLMs and agents).
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# List all available commands
|
|
296
|
+
aigne explain
|
|
297
|
+
|
|
298
|
+
# Get documentation for a specific command
|
|
299
|
+
aigne explain run
|
|
300
|
+
aigne explain skill
|
|
301
|
+
aigne explain hub list
|
|
302
|
+
```
|
|
303
|
+
|
|
165
304
|
## License
|
|
166
305
|
|
|
167
306
|
Elastic-2.0
|
package/dist/commands/aigne.cjs
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_constants = require('../constants.cjs');
|
|
3
3
|
const require_utils_ascii_logo = require('../utils/ascii-logo.cjs');
|
|
4
|
-
const require_app = require('./app.cjs');
|
|
5
4
|
const require_create = require('./create.cjs');
|
|
6
|
-
const require_deploy = require('./deploy.cjs');
|
|
7
5
|
const require_eval = require('./eval.cjs');
|
|
6
|
+
const require_explain = require('./explain.cjs');
|
|
8
7
|
const require_hub = require('./hub.cjs');
|
|
9
8
|
const require_observe = require('./observe.cjs');
|
|
10
9
|
const require_serve_mcp = require('./serve-mcp.cjs');
|
|
11
10
|
const require_run = require('./run.cjs');
|
|
12
|
-
const
|
|
11
|
+
const require_shell = require('./shell.cjs');
|
|
13
12
|
const require_test = require('./test.cjs');
|
|
14
13
|
let yargs = require("yargs");
|
|
15
14
|
yargs = require_rolldown_runtime.__toESM(yargs);
|
|
16
15
|
|
|
17
16
|
//#region src/commands/aigne.ts
|
|
18
17
|
function createAIGNECommand(options) {
|
|
19
|
-
return (0, yargs.default)().scriptName("aigne").usage(`${require_utils_ascii_logo.asciiLogo}\n$0 <command> [options]`).version(require_constants.AIGNE_CLI_VERSION).command(require_run.createRunCommand(options)).command(
|
|
18
|
+
return (0, yargs.default)().scriptName("aigne").usage(`${require_utils_ascii_logo.asciiLogo}\n$0 <command> [options]`).version(require_constants.AIGNE_CLI_VERSION).command(require_run.createRunCommand(options)).command(require_eval.createEvalCommand(options)).command(require_test.createTestCommand(options)).command(require_create.createCreateCommand()).command(require_serve_mcp.createServeMCPCommand(options)).command(require_observe.createObservabilityCommand()).command(require_hub.createHubCommand()).command(require_explain.createExplainCommand()).command(require_shell.createShellCommand()).demandCommand().version(false).alias("help", "h").wrap(null).strict();
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
//#endregion
|
package/dist/commands/aigne.mjs
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { AIGNE_CLI_VERSION } from "../constants.mjs";
|
|
2
2
|
import { asciiLogo } from "../utils/ascii-logo.mjs";
|
|
3
|
-
import { createAppCommands } from "./app.mjs";
|
|
4
3
|
import { createCreateCommand } from "./create.mjs";
|
|
5
|
-
import { createDeployCommands } from "./deploy.mjs";
|
|
6
4
|
import { createEvalCommand } from "./eval.mjs";
|
|
5
|
+
import { createExplainCommand } from "./explain.mjs";
|
|
7
6
|
import { createHubCommand } from "./hub.mjs";
|
|
8
7
|
import { createObservabilityCommand } from "./observe.mjs";
|
|
9
8
|
import { createServeMCPCommand } from "./serve-mcp.mjs";
|
|
10
9
|
import { createRunCommand } from "./run.mjs";
|
|
11
|
-
import {
|
|
10
|
+
import { createShellCommand } from "./shell.mjs";
|
|
12
11
|
import { createTestCommand } from "./test.mjs";
|
|
13
12
|
import yargs from "yargs";
|
|
14
13
|
|
|
15
14
|
//#region src/commands/aigne.ts
|
|
16
15
|
function createAIGNECommand(options) {
|
|
17
|
-
return yargs().scriptName("aigne").usage(`${asciiLogo}\n$0 <command> [options]`).version(AIGNE_CLI_VERSION).command(createRunCommand(options)).command(
|
|
16
|
+
return yargs().scriptName("aigne").usage(`${asciiLogo}\n$0 <command> [options]`).version(AIGNE_CLI_VERSION).command(createRunCommand(options)).command(createEvalCommand(options)).command(createTestCommand(options)).command(createCreateCommand()).command(createServeMCPCommand(options)).command(createObservabilityCommand()).command(createHubCommand()).command(createExplainCommand()).command(createShellCommand()).demandCommand().version(false).alias("help", "h").wrap(null).strict();
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aigne.mjs","names":[],"sources":["../../src/commands/aigne.ts"],"sourcesContent":["import yargs from \"yargs\";\nimport { AIGNE_CLI_VERSION } from \"../constants.js\";\nimport { asciiLogo } from \"../utils/ascii-logo.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"aigne.mjs","names":[],"sources":["../../src/commands/aigne.ts"],"sourcesContent":["import yargs from \"yargs\";\nimport { AIGNE_CLI_VERSION } from \"../constants.js\";\nimport { asciiLogo } from \"../utils/ascii-logo.js\";\nimport { createCreateCommand } from \"./create.js\";\nimport { createEvalCommand } from \"./eval.js\";\nimport { createExplainCommand } from \"./explain.js\";\nimport { createHubCommand } from \"./hub.js\";\nimport { createObservabilityCommand } from \"./observe.js\";\nimport { createRunCommand } from \"./run.js\";\nimport { createServeMCPCommand } from \"./serve-mcp.js\";\nimport { createShellCommand } from \"./shell.js\";\nimport { createTestCommand } from \"./test.js\";\n\nexport function createAIGNECommand(options?: { argv?: string[]; aigneFilePath?: string }) {\n return (\n yargs()\n .scriptName(\"aigne\")\n .usage(`${asciiLogo}\\n$0 <command> [options]`)\n .version(AIGNE_CLI_VERSION)\n // default command: when user runs `aigne` without subcommand, behave like `aigne run`\n .command(createRunCommand(options))\n .command(createEvalCommand(options))\n .command(createTestCommand(options))\n .command(createCreateCommand())\n .command(createServeMCPCommand(options))\n .command(createObservabilityCommand())\n .command(createHubCommand())\n .command(createExplainCommand())\n .command(createShellCommand())\n .demandCommand()\n .version(false)\n .alias(\"help\", \"h\")\n .wrap(null)\n .strict()\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAgB,mBAAmB,SAAuD;AACxF,QACE,OAAO,CACJ,WAAW,QAAQ,CACnB,MAAM,GAAG,UAAU,0BAA0B,CAC7C,QAAQ,kBAAkB,CAE1B,QAAQ,iBAAiB,QAAQ,CAAC,CAClC,QAAQ,kBAAkB,QAAQ,CAAC,CACnC,QAAQ,kBAAkB,QAAQ,CAAC,CACnC,QAAQ,qBAAqB,CAAC,CAC9B,QAAQ,sBAAsB,QAAQ,CAAC,CACvC,QAAQ,4BAA4B,CAAC,CACrC,QAAQ,kBAAkB,CAAC,CAC3B,QAAQ,sBAAsB,CAAC,CAC/B,QAAQ,oBAAoB,CAAC,CAC7B,eAAe,CACf,QAAQ,MAAM,CACd,MAAM,QAAQ,IAAI,CAClB,KAAK,KAAK,CACV,QAAQ"}
|
|
@@ -2,37 +2,13 @@ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
|
2
2
|
const require_constants = require('../../constants.cjs');
|
|
3
3
|
const require_utils_yargs = require('../../utils/yargs.cjs');
|
|
4
4
|
const require_utils_run_with_aigne = require('../../utils/run-with-aigne.cjs');
|
|
5
|
-
|
|
5
|
+
require('../serve-mcp.cjs');
|
|
6
6
|
let _aigne_core_utils_logger = require("@aigne/core/utils/logger");
|
|
7
7
|
let node_assert = require("node:assert");
|
|
8
8
|
node_assert = require_rolldown_runtime.__toESM(node_assert);
|
|
9
9
|
let _aigne_uuid = require("@aigne/uuid");
|
|
10
10
|
|
|
11
11
|
//#region src/commands/app/agent.ts
|
|
12
|
-
const serveMcpCommandModule = ({ aigne, name }) => ({
|
|
13
|
-
command: "serve-mcp",
|
|
14
|
-
describe: `Serve ${name} a MCP server (streamable http)`,
|
|
15
|
-
builder: (yargs) => {
|
|
16
|
-
return yargs.option("host", {
|
|
17
|
-
describe: "Host to run the MCP server on, use 0.0.0.0 to publicly expose the server",
|
|
18
|
-
type: "string",
|
|
19
|
-
default: "localhost"
|
|
20
|
-
}).option("port", {
|
|
21
|
-
describe: "Port to run the MCP server on",
|
|
22
|
-
type: "number"
|
|
23
|
-
}).option("pathname", {
|
|
24
|
-
describe: "Pathname to the service",
|
|
25
|
-
type: "string",
|
|
26
|
-
default: "/mcp"
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
handler: async (options) => {
|
|
30
|
-
await require_serve_mcp.serveMCPServerFromDir({
|
|
31
|
-
...options,
|
|
32
|
-
aigne
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
12
|
const agentCommandModule = ({ aigne, agent, interactive }) => {
|
|
37
13
|
return {
|
|
38
14
|
command: agent.name,
|
|
@@ -113,5 +89,4 @@ async function invokeAgent(options) {
|
|
|
113
89
|
//#endregion
|
|
114
90
|
exports.agentCommandModule = agentCommandModule;
|
|
115
91
|
exports.cliAgentCommandModule = cliAgentCommandModule;
|
|
116
|
-
exports.invokeAgent = invokeAgent;
|
|
117
|
-
exports.serveMcpCommandModule = serveMcpCommandModule;
|
|
92
|
+
exports.invokeAgent = invokeAgent;
|
|
@@ -1,36 +1,12 @@
|
|
|
1
1
|
import { DEFAULT_USER_ID } from "../../constants.mjs";
|
|
2
2
|
import { parseAgentInput, withAgentInputSchema } from "../../utils/yargs.mjs";
|
|
3
3
|
import { runAgentWithAIGNE } from "../../utils/run-with-aigne.mjs";
|
|
4
|
-
import
|
|
4
|
+
import "../serve-mcp.mjs";
|
|
5
5
|
import { logger } from "@aigne/core/utils/logger";
|
|
6
6
|
import assert from "node:assert";
|
|
7
7
|
import { v7 } from "@aigne/uuid";
|
|
8
8
|
|
|
9
9
|
//#region src/commands/app/agent.ts
|
|
10
|
-
const serveMcpCommandModule = ({ aigne, name }) => ({
|
|
11
|
-
command: "serve-mcp",
|
|
12
|
-
describe: `Serve ${name} a MCP server (streamable http)`,
|
|
13
|
-
builder: (yargs) => {
|
|
14
|
-
return yargs.option("host", {
|
|
15
|
-
describe: "Host to run the MCP server on, use 0.0.0.0 to publicly expose the server",
|
|
16
|
-
type: "string",
|
|
17
|
-
default: "localhost"
|
|
18
|
-
}).option("port", {
|
|
19
|
-
describe: "Port to run the MCP server on",
|
|
20
|
-
type: "number"
|
|
21
|
-
}).option("pathname", {
|
|
22
|
-
describe: "Pathname to the service",
|
|
23
|
-
type: "string",
|
|
24
|
-
default: "/mcp"
|
|
25
|
-
});
|
|
26
|
-
},
|
|
27
|
-
handler: async (options) => {
|
|
28
|
-
await serveMCPServerFromDir({
|
|
29
|
-
...options,
|
|
30
|
-
aigne
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
10
|
const agentCommandModule = ({ aigne, agent, interactive }) => {
|
|
35
11
|
return {
|
|
36
12
|
command: agent.name,
|
|
@@ -109,5 +85,5 @@ async function invokeAgent(options) {
|
|
|
109
85
|
}
|
|
110
86
|
|
|
111
87
|
//#endregion
|
|
112
|
-
export { agentCommandModule, cliAgentCommandModule, invokeAgent
|
|
88
|
+
export { agentCommandModule, cliAgentCommandModule, invokeAgent };
|
|
113
89
|
//# sourceMappingURL=agent.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.mjs","names":[],"sources":["../../../src/commands/app/agent.ts"],"sourcesContent":["import assert from \"node:assert\";\nimport { DEFAULT_USER_ID } from \"@aigne/cli/constants.js\";\nimport type { Agent, AIGNE, Message } from \"@aigne/core\";\nimport type { CLIAgent } from \"@aigne/core/utils/agent-utils\";\nimport { logger } from \"@aigne/core/utils/logger\";\nimport { v7 } from \"@aigne/uuid\";\nimport type { CommandModule } from \"yargs\";\nimport { runAgentWithAIGNE } from \"../../utils/run-with-aigne.js\";\nimport {\n type AgentRunCommonOptions,\n parseAgentInput,\n withAgentInputSchema,\n} from \"../../utils/yargs.js\";\nimport { serveMCPServerFromDir } from \"../serve-mcp.js\";\n\nexport const serveMcpCommandModule = ({\n aigne,\n name,\n}: {\n aigne: AIGNE;\n name: string;\n}): CommandModule<unknown, { host: string; port?: number; pathname: string }> => ({\n command: \"serve-mcp\",\n describe: `Serve ${name} a MCP server (streamable http)`,\n builder: (yargs) => {\n return yargs\n .option(\"host\", {\n describe: \"Host to run the MCP server on, use 0.0.0.0 to publicly expose the server\",\n type: \"string\",\n default: \"localhost\",\n })\n .option(\"port\", {\n describe: \"Port to run the MCP server on\",\n type: \"number\",\n })\n .option(\"pathname\", {\n describe: \"Pathname to the service\",\n type: \"string\",\n default: \"/mcp\",\n });\n },\n handler: async (options) => {\n await serveMCPServerFromDir({\n ...options,\n aigne,\n });\n },\n});\n\nexport const agentCommandModule = ({\n aigne,\n agent,\n interactive,\n}: {\n aigne: AIGNE;\n agent: Agent;\n interactive?: boolean;\n}): CommandModule<unknown, AgentRunCommonOptions> => {\n return {\n command: agent.name,\n aliases: agent.alias || [],\n describe: agent.description || \"\",\n builder: async (yargs) => {\n return withAgentInputSchema(yargs, {\n inputSchema: agent.inputSchema,\n optionalInputs:\n interactive && \"inputKey\" in agent && typeof agent.inputKey === \"string\"\n ? [agent.inputKey]\n : [],\n });\n },\n handler: async (options) => {\n if (options.logLevel) logger.level = options.logLevel;\n\n await invokeAgent({\n aigne,\n agent,\n input: { ...options, interactive: interactive ?? options.interactive },\n });\n },\n };\n};\n\nexport const cliAgentCommandModule = ({\n aigne,\n cliAgent,\n}: {\n aigne: AIGNE;\n cliAgent: CLIAgent<Agent>;\n}): CommandModule<unknown, AgentRunCommonOptions> => {\n const { agent, agents } = cliAgent;\n\n const name = cliAgent.name || agent?.name;\n assert(name, \"CLI agent must have a name\");\n\n return {\n command: name,\n aliases: cliAgent.alias || agent?.alias || [],\n describe: cliAgent.description || agent?.description || \"\",\n builder: async (yargs) => {\n if (agent) {\n withAgentInputSchema(yargs, { inputSchema: agent.inputSchema });\n }\n if (agents?.length) {\n for (const cmd of agents) {\n yargs.command(\n cliAgentCommandModule({\n aigne,\n cliAgent: cmd,\n }),\n );\n }\n }\n\n if (!agent) yargs.demandCommand();\n\n return yargs;\n },\n handler: async (options) => {\n if (!agent) throw new Error(\"CLI agent is not defined\");\n\n if (options.logLevel) logger.level = options.logLevel;\n\n await invokeAgent({\n aigne,\n agent,\n input: options,\n });\n },\n };\n};\n\nexport async function invokeAgent(options: {\n aigne: AIGNE;\n agent: Agent;\n input: Message & AgentRunCommonOptions;\n}) {\n const { agent, aigne } = options;\n\n try {\n const input = await parseAgentInput(options.input, agent);\n\n const sessionId = options.input.sessionId || v7();\n const userId = DEFAULT_USER_ID;\n\n if (aigne.cli.init) {\n await runAgentWithAIGNE(aigne, aigne.cli.init, {\n ...options.input,\n input,\n interactive: false,\n sessionId,\n userId,\n });\n }\n\n await runAgentWithAIGNE(aigne, agent, {\n ...options.input,\n input,\n interactive: options.input.interactive,\n sessionId,\n userId,\n });\n } finally {\n await aigne.shutdown();\n }\n}\n"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"agent.mjs","names":[],"sources":["../../../src/commands/app/agent.ts"],"sourcesContent":["import assert from \"node:assert\";\nimport { DEFAULT_USER_ID } from \"@aigne/cli/constants.js\";\nimport type { Agent, AIGNE, Message } from \"@aigne/core\";\nimport type { CLIAgent } from \"@aigne/core/utils/agent-utils\";\nimport { logger } from \"@aigne/core/utils/logger\";\nimport { v7 } from \"@aigne/uuid\";\nimport type { CommandModule } from \"yargs\";\nimport { runAgentWithAIGNE } from \"../../utils/run-with-aigne.js\";\nimport {\n type AgentRunCommonOptions,\n parseAgentInput,\n withAgentInputSchema,\n} from \"../../utils/yargs.js\";\nimport { serveMCPServerFromDir } from \"../serve-mcp.js\";\n\nexport const serveMcpCommandModule = ({\n aigne,\n name,\n}: {\n aigne: AIGNE;\n name: string;\n}): CommandModule<unknown, { host: string; port?: number; pathname: string }> => ({\n command: \"serve-mcp\",\n describe: `Serve ${name} a MCP server (streamable http)`,\n builder: (yargs) => {\n return yargs\n .option(\"host\", {\n describe: \"Host to run the MCP server on, use 0.0.0.0 to publicly expose the server\",\n type: \"string\",\n default: \"localhost\",\n })\n .option(\"port\", {\n describe: \"Port to run the MCP server on\",\n type: \"number\",\n })\n .option(\"pathname\", {\n describe: \"Pathname to the service\",\n type: \"string\",\n default: \"/mcp\",\n });\n },\n handler: async (options) => {\n await serveMCPServerFromDir({\n ...options,\n aigne,\n });\n },\n});\n\nexport const agentCommandModule = ({\n aigne,\n agent,\n interactive,\n}: {\n aigne: AIGNE;\n agent: Agent;\n interactive?: boolean;\n}): CommandModule<unknown, AgentRunCommonOptions> => {\n return {\n command: agent.name,\n aliases: agent.alias || [],\n describe: agent.description || \"\",\n builder: async (yargs) => {\n return withAgentInputSchema(yargs, {\n inputSchema: agent.inputSchema,\n optionalInputs:\n interactive && \"inputKey\" in agent && typeof agent.inputKey === \"string\"\n ? [agent.inputKey]\n : [],\n });\n },\n handler: async (options) => {\n if (options.logLevel) logger.level = options.logLevel;\n\n await invokeAgent({\n aigne,\n agent,\n input: { ...options, interactive: interactive ?? options.interactive },\n });\n },\n };\n};\n\nexport const cliAgentCommandModule = ({\n aigne,\n cliAgent,\n}: {\n aigne: AIGNE;\n cliAgent: CLIAgent<Agent>;\n}): CommandModule<unknown, AgentRunCommonOptions> => {\n const { agent, agents } = cliAgent;\n\n const name = cliAgent.name || agent?.name;\n assert(name, \"CLI agent must have a name\");\n\n return {\n command: name,\n aliases: cliAgent.alias || agent?.alias || [],\n describe: cliAgent.description || agent?.description || \"\",\n builder: async (yargs) => {\n if (agent) {\n withAgentInputSchema(yargs, { inputSchema: agent.inputSchema });\n }\n if (agents?.length) {\n for (const cmd of agents) {\n yargs.command(\n cliAgentCommandModule({\n aigne,\n cliAgent: cmd,\n }),\n );\n }\n }\n\n if (!agent) yargs.demandCommand();\n\n return yargs;\n },\n handler: async (options) => {\n if (!agent) throw new Error(\"CLI agent is not defined\");\n\n if (options.logLevel) logger.level = options.logLevel;\n\n await invokeAgent({\n aigne,\n agent,\n input: options,\n });\n },\n };\n};\n\nexport async function invokeAgent(options: {\n aigne: AIGNE;\n agent: Agent;\n input: Message & AgentRunCommonOptions;\n}) {\n const { agent, aigne } = options;\n\n try {\n const input = await parseAgentInput(options.input, agent);\n\n const sessionId = options.input.sessionId || v7();\n const userId = DEFAULT_USER_ID;\n\n if (aigne.cli.init) {\n await runAgentWithAIGNE(aigne, aigne.cli.init, {\n ...options.input,\n input,\n interactive: false,\n sessionId,\n userId,\n });\n }\n\n await runAgentWithAIGNE(aigne, agent, {\n ...options.input,\n input,\n interactive: options.input.interactive,\n sessionId,\n userId,\n });\n } finally {\n await aigne.shutdown();\n }\n}\n"],"mappings":";;;;;;;;;AAiDA,MAAa,sBAAsB,EACjC,OACA,OACA,kBAKmD;AACnD,QAAO;EACL,SAAS,MAAM;EACf,SAAS,MAAM,SAAS,EAAE;EAC1B,UAAU,MAAM,eAAe;EAC/B,SAAS,OAAO,UAAU;AACxB,UAAO,qBAAqB,OAAO;IACjC,aAAa,MAAM;IACnB,gBACE,eAAe,cAAc,SAAS,OAAO,MAAM,aAAa,WAC5D,CAAC,MAAM,SAAS,GAChB,EAAE;IACT,CAAC;;EAEJ,SAAS,OAAO,YAAY;AAC1B,OAAI,QAAQ,SAAU,QAAO,QAAQ,QAAQ;AAE7C,SAAM,YAAY;IAChB;IACA;IACA,OAAO;KAAE,GAAG;KAAS,aAAa,eAAe,QAAQ;KAAa;IACvE,CAAC;;EAEL;;AAGH,MAAa,yBAAyB,EACpC,OACA,eAImD;CACnD,MAAM,EAAE,OAAO,WAAW;CAE1B,MAAM,OAAO,SAAS,QAAQ,OAAO;AACrC,QAAO,MAAM,6BAA6B;AAE1C,QAAO;EACL,SAAS;EACT,SAAS,SAAS,SAAS,OAAO,SAAS,EAAE;EAC7C,UAAU,SAAS,eAAe,OAAO,eAAe;EACxD,SAAS,OAAO,UAAU;AACxB,OAAI,MACF,sBAAqB,OAAO,EAAE,aAAa,MAAM,aAAa,CAAC;AAEjE,OAAI,QAAQ,OACV,MAAK,MAAM,OAAO,OAChB,OAAM,QACJ,sBAAsB;IACpB;IACA,UAAU;IACX,CAAC,CACH;AAIL,OAAI,CAAC,MAAO,OAAM,eAAe;AAEjC,UAAO;;EAET,SAAS,OAAO,YAAY;AAC1B,OAAI,CAAC,MAAO,OAAM,IAAI,MAAM,2BAA2B;AAEvD,OAAI,QAAQ,SAAU,QAAO,QAAQ,QAAQ;AAE7C,SAAM,YAAY;IAChB;IACA;IACA,OAAO;IACR,CAAC;;EAEL;;AAGH,eAAsB,YAAY,SAI/B;CACD,MAAM,EAAE,OAAO,UAAU;AAEzB,KAAI;EACF,MAAM,QAAQ,MAAM,gBAAgB,QAAQ,OAAO,MAAM;EAEzD,MAAM,YAAY,QAAQ,MAAM,aAAa,IAAI;EACjD,MAAM,SAAS;AAEf,MAAI,MAAM,IAAI,KACZ,OAAM,kBAAkB,OAAO,MAAM,IAAI,MAAM;GAC7C,GAAG,QAAQ;GACX;GACA,aAAa;GACb;GACA;GACD,CAAC;AAGJ,QAAM,kBAAkB,OAAO,OAAO;GACpC,GAAG,QAAQ;GACX;GACA,aAAa,QAAQ,MAAM;GAC3B;GACA;GACD,CAAC;WACM;AACR,QAAM,MAAM,UAAU"}
|
package/dist/commands/create.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
let node_fs = require("node:fs");
|
|
3
|
+
let node_fs_promises = require("node:fs/promises");
|
|
3
4
|
let node_path = require("node:path");
|
|
4
5
|
let node_url = require("node:url");
|
|
5
|
-
let node_fs_promises = require("node:fs/promises");
|
|
6
6
|
let inquirer = require("inquirer");
|
|
7
7
|
inquirer = require_rolldown_runtime.__toESM(inquirer);
|
|
8
8
|
|
package/dist/commands/create.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readdirSync } from "node:fs";
|
|
2
|
+
import { cp } from "node:fs/promises";
|
|
2
3
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { cp } from "node:fs/promises";
|
|
5
5
|
import inquirer from "inquirer";
|
|
6
6
|
|
|
7
7
|
//#region src/commands/create.ts
|
package/dist/commands/eval.cjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_utils_load_aigne = require('../utils/load-aigne.cjs');
|
|
3
2
|
const require_reporter = require('../utils/evaluation/reporter.cjs');
|
|
4
3
|
const require_core = require('../utils/evaluation/core.cjs');
|
|
5
4
|
const require_dataset = require('../utils/evaluation/dataset.cjs');
|
|
6
5
|
const require_evaluator = require('../utils/evaluation/evaluator.cjs');
|
|
7
6
|
const require_runner = require('../utils/evaluation/runner.cjs');
|
|
7
|
+
const require_utils_load_aigne = require('../utils/load-aigne.cjs');
|
|
8
|
+
const require_utils_view = require('../utils/view.cjs');
|
|
8
9
|
let node_path = require("node:path");
|
|
9
10
|
let _aigne_agent_library_utils_fs = require("@aigne/agent-library/utils/fs");
|
|
10
11
|
let _aigne_core_utils_agent_utils = require("@aigne/core/utils/agent-utils");
|
|
@@ -17,7 +18,14 @@ const schema = zod.z.object({
|
|
|
17
18
|
dataset: zod.z.string(),
|
|
18
19
|
evaluator: zod.z.string().optional(),
|
|
19
20
|
concurrency: zod.z.number().optional(),
|
|
20
|
-
output: zod.z.string().optional()
|
|
21
|
+
output: zod.z.string().optional(),
|
|
22
|
+
json: zod.z.boolean().optional(),
|
|
23
|
+
view: zod.z.enum([
|
|
24
|
+
"default",
|
|
25
|
+
"json",
|
|
26
|
+
"llm",
|
|
27
|
+
"human"
|
|
28
|
+
]).optional()
|
|
21
29
|
});
|
|
22
30
|
const getResolvePath = (path) => {
|
|
23
31
|
return (0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(process.cwd(), path);
|
|
@@ -48,6 +56,19 @@ function createEvalCommand({ aigneFilePath } = {}) {
|
|
|
48
56
|
type: "number",
|
|
49
57
|
describe: "Concurrency level",
|
|
50
58
|
default: 1
|
|
59
|
+
}).option("json", {
|
|
60
|
+
type: "boolean",
|
|
61
|
+
describe: "Output in JSON format",
|
|
62
|
+
default: false
|
|
63
|
+
}).option("view", {
|
|
64
|
+
type: "string",
|
|
65
|
+
describe: "Output view type (human, json, llm, default)",
|
|
66
|
+
choices: [
|
|
67
|
+
"default",
|
|
68
|
+
"json",
|
|
69
|
+
"llm",
|
|
70
|
+
"human"
|
|
71
|
+
]
|
|
51
72
|
}).help(false).version(false).strict(false);
|
|
52
73
|
},
|
|
53
74
|
handler: async (options) => {
|
|
@@ -65,10 +86,28 @@ function createEvalCommand({ aigneFilePath } = {}) {
|
|
|
65
86
|
let evaluatorAgent;
|
|
66
87
|
if (evaluatorName) evaluatorAgent = (0, _aigne_core_utils_agent_utils.findCliAgent)(aigne.cli, "*", evaluatorName) || aigne.agents[evaluatorName] || aigne.skills[evaluatorName] || aigne.mcpServer.agents[evaluatorName];
|
|
67
88
|
if (evaluatorAgent) evaluatorAgent.model = evaluatorAgent.model ?? aigne.model;
|
|
89
|
+
const view = require_utils_view.detectView({
|
|
90
|
+
view: parsedOptions.data.view,
|
|
91
|
+
json: parsedOptions.data.json
|
|
92
|
+
}, {}, require_utils_view.createViewContext());
|
|
68
93
|
const dataset = new require_dataset.FileDataset(resolvedDatasetPath);
|
|
69
94
|
const runner = new require_runner.DefaultRunnerWithConcurrency(agent, aigne);
|
|
70
95
|
const evaluator = new require_evaluator.LLMEvaluator(aigne, evaluatorAgent);
|
|
71
|
-
const reporters = [
|
|
96
|
+
const reporters = [];
|
|
97
|
+
switch (view) {
|
|
98
|
+
case "json":
|
|
99
|
+
reporters.push(new require_reporter.JsonReporter());
|
|
100
|
+
break;
|
|
101
|
+
case "llm":
|
|
102
|
+
reporters.push(new require_reporter.LLMReporter());
|
|
103
|
+
break;
|
|
104
|
+
case "default":
|
|
105
|
+
reporters.push(new require_reporter.LLMReporter());
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
reporters.push(new require_reporter.ConsoleReporter());
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
72
111
|
if (options.output) {
|
|
73
112
|
const reporter = new require_reporter.CsvReporter(getResolvePath(options.output));
|
|
74
113
|
reporters.push(reporter);
|
package/dist/commands/eval.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConsoleReporter, CsvReporter } from "../utils/evaluation/reporter.mjs";
|
|
1
|
+
import { ConsoleReporter, CsvReporter, JsonReporter, LLMReporter } from "../utils/evaluation/reporter.mjs";
|
|
3
2
|
import { runEvaluationPipeline } from "../utils/evaluation/core.mjs";
|
|
4
3
|
import { FileDataset } from "../utils/evaluation/dataset.mjs";
|
|
5
4
|
import { LLMEvaluator } from "../utils/evaluation/evaluator.mjs";
|
|
6
5
|
import { DefaultRunnerWithConcurrency } from "../utils/evaluation/runner.mjs";
|
|
6
|
+
import { loadAIGNE } from "../utils/load-aigne.mjs";
|
|
7
|
+
import { createViewContext, detectView } from "../utils/view.mjs";
|
|
7
8
|
import { isAbsolute, resolve } from "node:path";
|
|
8
9
|
import { exists } from "@aigne/agent-library/utils/fs";
|
|
9
10
|
import { findCliAgent } from "@aigne/core/utils/agent-utils";
|
|
@@ -16,7 +17,14 @@ const schema = z$1.object({
|
|
|
16
17
|
dataset: z$1.string(),
|
|
17
18
|
evaluator: z$1.string().optional(),
|
|
18
19
|
concurrency: z$1.number().optional(),
|
|
19
|
-
output: z$1.string().optional()
|
|
20
|
+
output: z$1.string().optional(),
|
|
21
|
+
json: z$1.boolean().optional(),
|
|
22
|
+
view: z$1.enum([
|
|
23
|
+
"default",
|
|
24
|
+
"json",
|
|
25
|
+
"llm",
|
|
26
|
+
"human"
|
|
27
|
+
]).optional()
|
|
20
28
|
});
|
|
21
29
|
const getResolvePath = (path$1) => {
|
|
22
30
|
return isAbsolute(path$1) ? path$1 : resolve(process.cwd(), path$1);
|
|
@@ -47,6 +55,19 @@ function createEvalCommand({ aigneFilePath } = {}) {
|
|
|
47
55
|
type: "number",
|
|
48
56
|
describe: "Concurrency level",
|
|
49
57
|
default: 1
|
|
58
|
+
}).option("json", {
|
|
59
|
+
type: "boolean",
|
|
60
|
+
describe: "Output in JSON format",
|
|
61
|
+
default: false
|
|
62
|
+
}).option("view", {
|
|
63
|
+
type: "string",
|
|
64
|
+
describe: "Output view type (human, json, llm, default)",
|
|
65
|
+
choices: [
|
|
66
|
+
"default",
|
|
67
|
+
"json",
|
|
68
|
+
"llm",
|
|
69
|
+
"human"
|
|
70
|
+
]
|
|
50
71
|
}).help(false).version(false).strict(false);
|
|
51
72
|
},
|
|
52
73
|
handler: async (options) => {
|
|
@@ -64,10 +85,28 @@ function createEvalCommand({ aigneFilePath } = {}) {
|
|
|
64
85
|
let evaluatorAgent;
|
|
65
86
|
if (evaluatorName) evaluatorAgent = findCliAgent(aigne.cli, "*", evaluatorName) || aigne.agents[evaluatorName] || aigne.skills[evaluatorName] || aigne.mcpServer.agents[evaluatorName];
|
|
66
87
|
if (evaluatorAgent) evaluatorAgent.model = evaluatorAgent.model ?? aigne.model;
|
|
88
|
+
const view = detectView({
|
|
89
|
+
view: parsedOptions.data.view,
|
|
90
|
+
json: parsedOptions.data.json
|
|
91
|
+
}, {}, createViewContext());
|
|
67
92
|
const dataset = new FileDataset(resolvedDatasetPath);
|
|
68
93
|
const runner = new DefaultRunnerWithConcurrency(agent, aigne);
|
|
69
94
|
const evaluator = new LLMEvaluator(aigne, evaluatorAgent);
|
|
70
|
-
const reporters = [
|
|
95
|
+
const reporters = [];
|
|
96
|
+
switch (view) {
|
|
97
|
+
case "json":
|
|
98
|
+
reporters.push(new JsonReporter());
|
|
99
|
+
break;
|
|
100
|
+
case "llm":
|
|
101
|
+
reporters.push(new LLMReporter());
|
|
102
|
+
break;
|
|
103
|
+
case "default":
|
|
104
|
+
reporters.push(new LLMReporter());
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
reporters.push(new ConsoleReporter());
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
71
110
|
if (options.output) {
|
|
72
111
|
const reporter = new CsvReporter(getResolvePath(options.output));
|
|
73
112
|
reporters.push(reporter);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eval.mjs","names":["z","path"],"sources":["../../src/commands/eval.ts"],"sourcesContent":["import { isAbsolute, resolve } from \"node:path\";\nimport { exists } from \"@aigne/agent-library/utils/fs\";\nimport type { Agent } from \"@aigne/core\";\nimport { findCliAgent } from \"@aigne/core/utils/agent-utils\";\nimport type { CommandModule } from \"yargs\";\nimport { z } from \"zod\";\nimport { runEvaluationPipeline } from \"../utils/evaluation/core.js\";\nimport { FileDataset } from \"../utils/evaluation/dataset.js\";\nimport { LLMEvaluator } from \"../utils/evaluation/evaluator.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"eval.mjs","names":["z","path"],"sources":["../../src/commands/eval.ts"],"sourcesContent":["import { isAbsolute, resolve } from \"node:path\";\nimport { exists } from \"@aigne/agent-library/utils/fs\";\nimport type { Agent } from \"@aigne/core\";\nimport { findCliAgent } from \"@aigne/core/utils/agent-utils\";\nimport type { CommandModule } from \"yargs\";\nimport { z } from \"zod\";\nimport { runEvaluationPipeline } from \"../utils/evaluation/core.js\";\nimport { FileDataset } from \"../utils/evaluation/dataset.js\";\nimport { LLMEvaluator } from \"../utils/evaluation/evaluator.js\";\nimport {\n ConsoleReporter,\n CsvReporter,\n JsonReporter,\n LLMReporter,\n} from \"../utils/evaluation/reporter.js\";\nimport { DefaultRunnerWithConcurrency } from \"../utils/evaluation/runner.js\";\nimport { loadAIGNE } from \"../utils/load-aigne.js\";\nimport { createViewContext, detectView, type ViewType } from \"../utils/view.js\";\n\nconst schema = z.object({\n path: z.string().optional(),\n agent: z.string(),\n dataset: z.string(),\n evaluator: z.string().optional(),\n concurrency: z.number().optional(),\n output: z.string().optional(),\n json: z.boolean().optional(),\n view: z.enum([\"default\", \"json\", \"llm\", \"human\"]).optional(),\n});\n\nconst getResolvePath = (path: string) => {\n return isAbsolute(path) ? path : resolve(process.cwd(), path);\n};\n\nexport function createEvalCommand({\n aigneFilePath,\n}: {\n aigneFilePath?: string;\n} = {}): CommandModule<\n unknown,\n {\n path?: string;\n agent?: string;\n dataset?: string;\n evaluator?: string;\n concurrency?: number;\n output?: string;\n }\n> {\n return {\n command: \"eval [path] [agent]\",\n describe: \"Evaluate AIGNE for the specified path\",\n builder: async (yargs) => {\n return yargs\n .positional(\"path\", {\n type: \"string\",\n describe: \"Path to the agents directory or URL to an aigne project\",\n default: \".\",\n })\n .positional(\"agent\", {\n type: \"string\",\n describe: \"Name of the agent to evaluate\",\n })\n .positional(\"dataset\", {\n type: \"string\",\n describe: \"Path to the dataset file\",\n })\n .positional(\"evaluator\", {\n type: \"string\",\n describe: \"Name of the evaluator to use\",\n })\n .positional(\"output\", {\n alias: \"o\",\n type: \"string\",\n describe: \"Path to the output file\",\n })\n .positional(\"concurrency\", {\n type: \"number\",\n describe: \"Concurrency level\",\n default: 1,\n })\n .option(\"json\", {\n type: \"boolean\",\n describe: \"Output in JSON format\",\n default: false,\n })\n .option(\"view\", {\n type: \"string\",\n describe: \"Output view type (human, json, llm, default)\",\n choices: [\"default\", \"json\", \"llm\", \"human\"] as const,\n })\n .help(false)\n .version(false)\n .strict(false);\n },\n handler: async (options) => {\n const parsedOptions = await schema.safeParseAsync(options);\n if (!parsedOptions.success) {\n throw new Error(`Invalid options: ${JSON.stringify(parsedOptions.error.format())}`);\n }\n\n const {\n agent: entryAgent,\n dataset: datasetPath,\n evaluator: evaluatorName,\n concurrency,\n } = parsedOptions.data;\n\n const path = parsedOptions.data?.path;\n const aigne = await loadAIGNE({ path: aigneFilePath || path || \".\" });\n\n const resolvedDatasetPath = getResolvePath(datasetPath);\n if (!(await exists(resolvedDatasetPath))) {\n throw new Error(\"Dataset file does not exist\");\n }\n\n const { chat } = aigne.cli;\n const agent =\n chat && chat.name === entryAgent\n ? chat\n : findCliAgent(aigne.cli, \"*\", entryAgent) ||\n aigne.agents[entryAgent] ||\n aigne.skills[entryAgent] ||\n aigne.mcpServer.agents[entryAgent];\n\n if (!agent) throw new Error(\"Entry agent does not exist\");\n agent.model = agent.model ?? aigne.model;\n\n let evaluatorAgent: Agent | undefined;\n if (evaluatorName) {\n evaluatorAgent =\n findCliAgent(aigne.cli, \"*\", evaluatorName) ||\n aigne.agents[evaluatorName] ||\n aigne.skills[evaluatorName] ||\n aigne.mcpServer.agents[evaluatorName];\n }\n\n if (evaluatorAgent) {\n evaluatorAgent.model = evaluatorAgent.model ?? aigne.model;\n }\n\n // Detect view based on options and context\n const view = detectView(\n { view: parsedOptions.data.view as ViewType, json: parsedOptions.data.json },\n {},\n createViewContext(),\n );\n\n const dataset = new FileDataset(resolvedDatasetPath);\n const runner = new DefaultRunnerWithConcurrency(agent, aigne);\n const evaluator = new LLMEvaluator(aigne, evaluatorAgent);\n\n // Select reporter based on view mode\n const reporters = [];\n switch (view) {\n case \"json\":\n reporters.push(new JsonReporter());\n break;\n case \"llm\":\n reporters.push(new LLMReporter());\n break;\n case \"default\":\n // Machine truth: use LLM reporter for pipe-safe output\n reporters.push(new LLMReporter());\n break;\n default:\n reporters.push(new ConsoleReporter());\n break;\n }\n\n if (options.output) {\n const resolvedReporterPath = getResolvePath(options.output);\n const reporter = new CsvReporter(resolvedReporterPath);\n reporters.push(reporter);\n }\n\n await runEvaluationPipeline({\n dataset,\n runner,\n evaluators: [evaluator],\n reporters: reporters,\n options: { concurrency },\n });\n },\n };\n}\n"],"mappings":"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"}
|