@aigne/cli 1.60.0-beta → 1.74.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/bunwrapper.cjs +22 -0
- package/dist/bunwrapper.d.cts +1 -0
- package/dist/bunwrapper.d.mts +1 -0
- package/dist/bunwrapper.mjs +23 -0
- package/dist/bunwrapper.mjs.map +1 -0
- package/dist/cli.cjs +42 -0
- package/dist/cli.d.cts +9 -0
- package/dist/cli.d.cts.map +1 -0
- package/dist/cli.d.mts +10 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +41 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/commands/aigne.cjs +23 -0
- package/dist/commands/aigne.mjs +22 -0
- package/dist/commands/aigne.mjs.map +1 -0
- package/dist/commands/app/agent.cjs +117 -0
- package/dist/commands/app/agent.mjs +113 -0
- package/dist/commands/app/agent.mjs.map +1 -0
- package/dist/commands/app/app.cjs +92 -0
- package/dist/commands/app/app.mjs +90 -0
- package/dist/commands/app/app.mjs.map +1 -0
- package/dist/commands/app/cli.cjs +6 -0
- package/dist/commands/app/cli.d.cts +1 -0
- package/dist/commands/app/cli.d.mts +1 -0
- package/dist/commands/app/cli.mjs +8 -0
- package/dist/commands/app/cli.mjs.map +1 -0
- package/dist/commands/app/upgrade.cjs +243 -0
- package/dist/commands/app/upgrade.mjs +240 -0
- package/dist/commands/app/upgrade.mjs.map +1 -0
- package/dist/commands/app.cjs +53 -0
- package/dist/commands/app.mjs +53 -0
- package/dist/commands/app.mjs.map +1 -0
- package/dist/commands/create.cjs +66 -0
- package/dist/commands/create.mjs +65 -0
- package/dist/commands/create.mjs.map +1 -0
- package/dist/commands/deploy.cjs +237 -0
- package/dist/commands/deploy.mjs +237 -0
- package/dist/commands/deploy.mjs.map +1 -0
- package/dist/commands/eval.cjs +88 -0
- package/dist/commands/eval.mjs +88 -0
- package/dist/commands/eval.mjs.map +1 -0
- package/dist/commands/hub.cjs +297 -0
- package/dist/commands/hub.mjs +294 -0
- package/dist/commands/hub.mjs.map +1 -0
- package/dist/commands/observe.cjs +49 -0
- package/dist/commands/observe.mjs +46 -0
- package/dist/commands/observe.mjs.map +1 -0
- package/dist/commands/run-skill.cjs +84 -0
- package/dist/commands/run-skill.mjs +81 -0
- package/dist/commands/run-skill.mjs.map +1 -0
- package/dist/commands/run.cjs +172 -0
- package/dist/commands/run.mjs +171 -0
- package/dist/commands/run.mjs.map +1 -0
- package/dist/commands/serve-mcp.cjs +68 -0
- package/dist/commands/serve-mcp.mjs +67 -0
- package/dist/commands/serve-mcp.mjs.map +1 -0
- package/dist/commands/test.cjs +40 -0
- package/dist/commands/test.mjs +39 -0
- package/dist/commands/test.mjs.map +1 -0
- package/dist/constants.cjs +28 -0
- package/dist/constants.d.cts +9 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +9 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +24 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/global.d.cjs +0 -0
- package/dist/global.d.cts +6 -0
- package/dist/global.d.cts.map +1 -0
- package/dist/global.d.mts +6 -0
- package/dist/global.d.mts.map +1 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/tracer/terminal.cjs +336 -0
- package/dist/tracer/terminal.mjs +332 -0
- package/dist/tracer/terminal.mjs.map +1 -0
- package/dist/type.cjs +0 -0
- package/dist/type.d.cts +10 -0
- package/dist/type.d.cts.map +1 -0
- package/dist/type.d.mts +10 -0
- package/dist/type.d.mts.map +1 -0
- package/dist/type.mjs +1 -0
- package/dist/ui/utils/terminal-input.cjs +145 -0
- package/dist/ui/utils/terminal-input.mjs +144 -0
- package/dist/ui/utils/terminal-input.mjs.map +1 -0
- package/dist/ui/utils/text-buffer.cjs +865 -0
- package/dist/ui/utils/text-buffer.mjs +865 -0
- package/dist/ui/utils/text-buffer.mjs.map +1 -0
- package/dist/ui/utils/text-utils.cjs +85 -0
- package/dist/ui/utils/text-utils.mjs +78 -0
- package/dist/ui/utils/text-utils.mjs.map +1 -0
- package/dist/utils/agent-v1.cjs +180 -0
- package/dist/utils/agent-v1.d.cts +138 -0
- package/dist/utils/agent-v1.d.cts.map +1 -0
- package/dist/utils/agent-v1.d.mts +138 -0
- package/dist/utils/agent-v1.d.mts.map +1 -0
- package/dist/utils/agent-v1.mjs +179 -0
- package/dist/utils/agent-v1.mjs.map +1 -0
- package/dist/utils/aigne-hub/constants.cjs +22 -0
- package/dist/utils/aigne-hub/constants.mjs +18 -0
- package/dist/utils/aigne-hub/constants.mjs.map +1 -0
- package/dist/utils/aigne-hub/credential.cjs +179 -0
- package/dist/utils/aigne-hub/credential.mjs +175 -0
- package/dist/utils/aigne-hub/credential.mjs.map +1 -0
- package/dist/utils/aigne-hub/crypto.cjs +41 -0
- package/dist/utils/aigne-hub/crypto.mjs +33 -0
- package/dist/utils/aigne-hub/crypto.mjs.map +1 -0
- package/dist/utils/aigne-hub/model.cjs +112 -0
- package/dist/utils/aigne-hub/model.d.cts +19 -0
- package/dist/utils/aigne-hub/model.d.cts.map +1 -0
- package/dist/utils/aigne-hub/model.d.mts +19 -0
- package/dist/utils/aigne-hub/model.d.mts.map +1 -0
- package/dist/utils/aigne-hub/model.mjs +106 -0
- package/dist/utils/aigne-hub/model.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/file.cjs +64 -0
- package/dist/utils/aigne-hub/store/file.mjs +64 -0
- package/dist/utils/aigne-hub/store/file.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/index.cjs +37 -0
- package/dist/utils/aigne-hub/store/index.mjs +37 -0
- package/dist/utils/aigne-hub/store/index.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/keytar.cjs +61 -0
- package/dist/utils/aigne-hub/store/keytar.mjs +61 -0
- package/dist/utils/aigne-hub/store/keytar.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/migrate.cjs +46 -0
- package/dist/utils/aigne-hub/store/migrate.mjs +45 -0
- package/dist/utils/aigne-hub/store/migrate.mjs.map +1 -0
- package/dist/utils/aigne-hub/type.d.cts +18 -0
- package/dist/utils/aigne-hub/type.d.cts.map +1 -0
- package/dist/utils/aigne-hub/type.d.mts +18 -0
- package/dist/utils/aigne-hub/type.d.mts.map +1 -0
- package/dist/utils/aigne-hub-user.cjs +11 -0
- package/dist/utils/aigne-hub-user.d.cts +23 -0
- package/dist/utils/aigne-hub-user.d.cts.map +1 -0
- package/dist/utils/aigne-hub-user.d.mts +23 -0
- package/dist/utils/aigne-hub-user.d.mts.map +1 -0
- package/dist/utils/aigne-hub-user.mjs +11 -0
- package/dist/utils/aigne-hub-user.mjs.map +1 -0
- package/dist/utils/ascii-logo.cjs +30 -0
- package/dist/utils/ascii-logo.d.cts +5 -0
- package/dist/utils/ascii-logo.d.cts.map +1 -0
- package/dist/utils/ascii-logo.d.mts +5 -0
- package/dist/utils/ascii-logo.d.mts.map +1 -0
- package/dist/utils/{ascii-logo.js → ascii-logo.mjs} +13 -3
- package/dist/utils/ascii-logo.mjs.map +1 -0
- package/dist/utils/download.cjs +25 -0
- package/dist/utils/download.d.cts +7 -0
- package/dist/utils/download.d.cts.map +1 -0
- package/dist/utils/download.d.mts +7 -0
- package/dist/utils/download.d.mts.map +1 -0
- package/dist/utils/download.mjs +25 -0
- package/dist/utils/download.mjs.map +1 -0
- package/dist/utils/evaluation/core.cjs +84 -0
- package/dist/utils/evaluation/core.mjs +84 -0
- package/dist/utils/evaluation/core.mjs.map +1 -0
- package/dist/utils/evaluation/dataset.cjs +47 -0
- package/dist/utils/evaluation/dataset.mjs +46 -0
- package/dist/utils/evaluation/dataset.mjs.map +1 -0
- package/dist/utils/evaluation/evaluator.cjs +109 -0
- package/dist/utils/evaluation/{evaluator.js → evaluator.mjs} +48 -45
- package/dist/utils/evaluation/evaluator.mjs.map +1 -0
- package/dist/utils/evaluation/reporter.cjs +225 -0
- package/dist/utils/evaluation/reporter.mjs +220 -0
- package/dist/utils/evaluation/reporter.mjs.map +1 -0
- package/dist/utils/evaluation/runner.cjs +85 -0
- package/dist/utils/evaluation/runner.mjs +85 -0
- package/dist/utils/evaluation/runner.mjs.map +1 -0
- package/dist/utils/get-url-origin.cjs +12 -0
- package/dist/utils/get-url-origin.d.cts +5 -0
- package/dist/utils/get-url-origin.d.cts.map +1 -0
- package/dist/utils/get-url-origin.d.mts +5 -0
- package/dist/utils/get-url-origin.d.mts.map +1 -0
- package/dist/utils/get-url-origin.mjs +12 -0
- package/dist/utils/get-url-origin.mjs.map +1 -0
- package/dist/utils/inquirer/checkbox.cjs +265 -0
- package/dist/utils/inquirer/checkbox.mjs +262 -0
- package/dist/utils/inquirer/checkbox.mjs.map +1 -0
- package/dist/utils/listr.cjs +226 -0
- package/dist/utils/listr.d.cts +71 -0
- package/dist/utils/listr.d.cts.map +1 -0
- package/dist/utils/listr.d.mts +71 -0
- package/dist/utils/listr.d.mts.map +1 -0
- package/dist/utils/listr.mjs +222 -0
- package/dist/utils/listr.mjs.map +1 -0
- package/dist/utils/load-aigne.cjs +77 -0
- package/dist/utils/load-aigne.d.cts +29 -0
- package/dist/utils/load-aigne.d.cts.map +1 -0
- package/dist/utils/load-aigne.d.mts +29 -0
- package/dist/utils/load-aigne.d.mts.map +1 -0
- package/dist/utils/load-aigne.mjs +74 -0
- package/dist/utils/load-aigne.mjs.map +1 -0
- package/dist/utils/run-chat-loop.cjs +90 -0
- package/dist/utils/run-chat-loop.d.cts +20 -0
- package/dist/utils/run-chat-loop.d.cts.map +1 -0
- package/dist/utils/run-chat-loop.d.mts +20 -0
- package/dist/utils/run-chat-loop.d.mts.map +1 -0
- package/dist/utils/run-chat-loop.mjs +89 -0
- package/dist/utils/run-chat-loop.mjs.map +1 -0
- package/dist/utils/run-with-aigne.cjs +131 -0
- package/dist/utils/run-with-aigne.d.cts +46 -0
- package/dist/utils/run-with-aigne.d.cts.map +1 -0
- package/dist/utils/run-with-aigne.d.mts +46 -0
- package/dist/utils/run-with-aigne.d.mts.map +1 -0
- package/dist/utils/run-with-aigne.mjs +126 -0
- package/dist/utils/run-with-aigne.mjs.map +1 -0
- package/dist/utils/serve-mcp.cjs +91 -0
- package/dist/utils/serve-mcp.d.cts +20 -0
- package/dist/utils/serve-mcp.d.cts.map +1 -0
- package/dist/utils/serve-mcp.d.mts +20 -0
- package/dist/utils/serve-mcp.d.mts.map +1 -0
- package/dist/utils/serve-mcp.mjs +89 -0
- package/dist/utils/serve-mcp.mjs.map +1 -0
- package/dist/utils/spinner.cjs +19 -0
- package/dist/utils/spinner.d.cts +5 -0
- package/dist/utils/spinner.d.cts.map +1 -0
- package/dist/utils/spinner.d.mts +5 -0
- package/dist/utils/spinner.d.mts.map +1 -0
- package/dist/utils/spinner.mjs +19 -0
- package/dist/utils/spinner.mjs.map +1 -0
- package/dist/utils/string-utils.cjs +11 -0
- package/dist/utils/string-utils.d.cts +5 -0
- package/dist/utils/string-utils.d.cts.map +1 -0
- package/dist/utils/string-utils.d.mts +5 -0
- package/dist/utils/string-utils.d.mts.map +1 -0
- package/dist/utils/string-utils.mjs +10 -0
- package/dist/utils/string-utils.mjs.map +1 -0
- package/dist/utils/time.cjs +14 -0
- package/dist/utils/time.d.cts +5 -0
- package/dist/utils/time.d.cts.map +1 -0
- package/dist/utils/time.d.mts +5 -0
- package/dist/utils/time.d.mts.map +1 -0
- package/dist/utils/time.mjs +14 -0
- package/dist/utils/time.mjs.map +1 -0
- package/dist/utils/url.cjs +8 -0
- package/dist/utils/url.d.cts +5 -0
- package/dist/utils/url.d.cts.map +1 -0
- package/dist/utils/url.d.mts +5 -0
- package/dist/utils/url.d.mts.map +1 -0
- package/dist/utils/url.mjs +8 -0
- package/dist/utils/url.mjs.map +1 -0
- package/dist/utils/yargs.cjs +191 -0
- package/dist/utils/yargs.d.cts +96 -0
- package/dist/utils/yargs.d.cts.map +1 -0
- package/dist/utils/yargs.d.mts +96 -0
- package/dist/utils/yargs.d.mts.map +1 -0
- package/dist/utils/yargs.mjs +186 -0
- package/dist/utils/yargs.mjs.map +1 -0
- package/package.json +122 -45
- package/CHANGELOG.md +0 -5019
- package/dist/bunwrapper.d.ts +0 -2
- package/dist/bunwrapper.js +0 -18
- package/dist/cli.d.ts +0 -7
- package/dist/cli.js +0 -42
- package/dist/commands/aigne.d.ts +0 -4
- package/dist/commands/aigne.js +0 -35
- package/dist/commands/app/agent.d.ts +0 -26
- package/dist/commands/app/agent.js +0 -122
- package/dist/commands/app/app.d.ts +0 -7
- package/dist/commands/app/app.js +0 -92
- package/dist/commands/app/cli.d.ts +0 -1
- package/dist/commands/app/cli.js +0 -2
- package/dist/commands/app/upgrade.d.ts +0 -54
- package/dist/commands/app/upgrade.js +0 -236
- package/dist/commands/app.d.ts +0 -4
- package/dist/commands/app.js +0 -54
- package/dist/commands/create.d.ts +0 -6
- package/dist/commands/create.js +0 -74
- package/dist/commands/deploy.d.ts +0 -11
- package/dist/commands/deploy.js +0 -255
- package/dist/commands/eval.d.ts +0 -11
- package/dist/commands/eval.js +0 -110
- package/dist/commands/hub.d.ts +0 -3
- package/dist/commands/hub.js +0 -323
- package/dist/commands/observe.d.ts +0 -7
- package/dist/commands/observe.js +0 -41
- package/dist/commands/run-skill.d.ts +0 -6
- package/dist/commands/run-skill.js +0 -102
- package/dist/commands/run.d.ts +0 -9
- package/dist/commands/run.js +0 -187
- package/dist/commands/serve-mcp.d.ts +0 -20
- package/dist/commands/serve-mcp.js +0 -67
- package/dist/commands/test.d.ts +0 -9
- package/dist/commands/test.js +0 -33
- package/dist/constants.d.ts +0 -7
- package/dist/constants.js +0 -21
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/tracer/terminal.d.ts +0 -62
- package/dist/tracer/terminal.js +0 -404
- package/dist/type.d.ts +0 -5
- package/dist/type.js +0 -1
- package/dist/ui/utils/terminal-input.d.ts +0 -19
- package/dist/ui/utils/terminal-input.js +0 -123
- package/dist/ui/utils/text-buffer.d.ts +0 -87
- package/dist/ui/utils/text-buffer.js +0 -1059
- package/dist/ui/utils/text-utils.d.ts +0 -37
- package/dist/ui/utils/text-utils.js +0 -185
- package/dist/utils/agent-v1.d.ts +0 -134
- package/dist/utils/agent-v1.js +0 -213
- package/dist/utils/aigne-hub/constants.d.ts +0 -6
- package/dist/utils/aigne-hub/constants.js +0 -12
- package/dist/utils/aigne-hub/credential.d.ts +0 -20
- package/dist/utils/aigne-hub/credential.js +0 -182
- package/dist/utils/aigne-hub/crypto.d.ts +0 -4
- package/dist/utils/aigne-hub/crypto.js +0 -30
- package/dist/utils/aigne-hub/model.d.ts +0 -13
- package/dist/utils/aigne-hub/model.js +0 -122
- package/dist/utils/aigne-hub/store/file.d.ts +0 -15
- package/dist/utils/aigne-hub/store/file.js +0 -69
- package/dist/utils/aigne-hub/store/index.d.ts +0 -5
- package/dist/utils/aigne-hub/store/index.js +0 -43
- package/dist/utils/aigne-hub/store/keytar.d.ts +0 -15
- package/dist/utils/aigne-hub/store/keytar.js +0 -67
- package/dist/utils/aigne-hub/store/migrate.d.ts +0 -2
- package/dist/utils/aigne-hub/store/migrate.js +0 -57
- package/dist/utils/aigne-hub/type.d.ts +0 -38
- package/dist/utils/aigne-hub/type.js +0 -1
- package/dist/utils/aigne-hub-user.d.ts +0 -16
- package/dist/utils/aigne-hub-user.js +0 -10
- package/dist/utils/ascii-logo.d.ts +0 -1
- package/dist/utils/download.d.ts +0 -3
- package/dist/utils/download.js +0 -19
- package/dist/utils/evaluation/core.d.ts +0 -8
- package/dist/utils/evaluation/core.js +0 -83
- package/dist/utils/evaluation/dataset.d.ts +0 -15
- package/dist/utils/evaluation/dataset.js +0 -61
- package/dist/utils/evaluation/evaluator.d.ts +0 -9
- package/dist/utils/evaluation/reporter.d.ts +0 -28
- package/dist/utils/evaluation/reporter.js +0 -221
- package/dist/utils/evaluation/runner.d.ts +0 -16
- package/dist/utils/evaluation/runner.js +0 -129
- package/dist/utils/evaluation/type.d.ts +0 -69
- package/dist/utils/evaluation/type.js +0 -1
- package/dist/utils/get-url-origin.d.ts +0 -1
- package/dist/utils/get-url-origin.js +0 -8
- package/dist/utils/inquirer/checkbox.d.ts +0 -55
- package/dist/utils/inquirer/checkbox.js +0 -319
- package/dist/utils/listr.d.ts +0 -64
- package/dist/utils/listr.js +0 -265
- package/dist/utils/load-aigne.d.ts +0 -18
- package/dist/utils/load-aigne.js +0 -80
- package/dist/utils/run-chat-loop.d.ts +0 -15
- package/dist/utils/run-chat-loop.js +0 -87
- package/dist/utils/run-with-aigne.d.ts +0 -27
- package/dist/utils/run-with-aigne.js +0 -157
- package/dist/utils/serve-mcp.d.ts +0 -9
- package/dist/utils/serve-mcp.js +0 -93
- package/dist/utils/spinner.d.ts +0 -1
- package/dist/utils/spinner.js +0 -14
- package/dist/utils/string-utils.d.ts +0 -1
- package/dist/utils/string-utils.js +0 -4
- package/dist/utils/time.d.ts +0 -1
- package/dist/utils/time.js +0 -12
- package/dist/utils/url.d.ts +0 -1
- package/dist/utils/url.js +0 -3
- package/dist/utils/yargs.d.ts +0 -94
- package/dist/utils/yargs.js +0 -210
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
node_fs = require_rolldown_runtime.__toESM(node_fs);
|
|
4
|
+
let chalk = require("chalk");
|
|
5
|
+
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
node_path = require_rolldown_runtime.__toESM(node_path);
|
|
8
|
+
let _fast_csv_format = require("@fast-csv/format");
|
|
9
|
+
let cli_table3 = require("cli-table3");
|
|
10
|
+
cli_table3 = require_rolldown_runtime.__toESM(cli_table3);
|
|
11
|
+
|
|
12
|
+
//#region src/utils/evaluation/reporter.ts
|
|
13
|
+
const borderColor = chalk.default.green;
|
|
14
|
+
const chars = {
|
|
15
|
+
top: borderColor("─"),
|
|
16
|
+
"top-mid": borderColor("┬"),
|
|
17
|
+
"top-left": borderColor("┌"),
|
|
18
|
+
"top-right": borderColor("┐"),
|
|
19
|
+
bottom: borderColor("─"),
|
|
20
|
+
"bottom-mid": borderColor("┴"),
|
|
21
|
+
"bottom-left": borderColor("└"),
|
|
22
|
+
"bottom-right": borderColor("┘"),
|
|
23
|
+
left: borderColor("│"),
|
|
24
|
+
"left-mid": borderColor("├"),
|
|
25
|
+
mid: borderColor("─"),
|
|
26
|
+
"mid-mid": borderColor("┼"),
|
|
27
|
+
right: borderColor("│"),
|
|
28
|
+
"right-mid": borderColor("┤"),
|
|
29
|
+
middle: borderColor("│")
|
|
30
|
+
};
|
|
31
|
+
const MAX_CELL_LENGTH = 300;
|
|
32
|
+
function renderPagedTable(list, { maxCols = 6, chars }) {
|
|
33
|
+
if (!list.length) return [];
|
|
34
|
+
const tables = [];
|
|
35
|
+
const head = list[0]?.map((h) => h.header) ?? [];
|
|
36
|
+
const widths = list[0]?.map((h) => h.width ?? 20) ?? [];
|
|
37
|
+
for (let i = 0; i < head.length; i += maxCols) {
|
|
38
|
+
const table = new cli_table3.default({
|
|
39
|
+
head: head.slice(i, i + maxCols),
|
|
40
|
+
colWidths: widths.slice(i, i + maxCols),
|
|
41
|
+
wordWrap: true,
|
|
42
|
+
chars
|
|
43
|
+
});
|
|
44
|
+
for (const row of list) table.push(row.slice(i, i + maxCols).map((h) => String(h.value).length > MAX_CELL_LENGTH ? `${String(h.value).slice(0, MAX_CELL_LENGTH)}...` : h.value));
|
|
45
|
+
tables.push(table.toString());
|
|
46
|
+
}
|
|
47
|
+
return tables;
|
|
48
|
+
}
|
|
49
|
+
var BaseReporter = class {
|
|
50
|
+
name = "base";
|
|
51
|
+
async report(_report) {
|
|
52
|
+
throw new Error("Not implemented");
|
|
53
|
+
}
|
|
54
|
+
formatReport(report) {
|
|
55
|
+
return report.results.map((r) => {
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
header: "ID",
|
|
59
|
+
key: "ID",
|
|
60
|
+
width: 10,
|
|
61
|
+
value: r.id
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
header: "Input",
|
|
65
|
+
key: "Input",
|
|
66
|
+
width: 40,
|
|
67
|
+
value: JSON.stringify(r.input)
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
header: "Output",
|
|
71
|
+
key: "Output",
|
|
72
|
+
width: 40,
|
|
73
|
+
value: r.output ? JSON.stringify(r.output) : "-"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
header: "Expected",
|
|
77
|
+
key: "Expected",
|
|
78
|
+
width: 40,
|
|
79
|
+
value: r.expected ? JSON.stringify(r.expected) : "-"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
header: "Evaluations",
|
|
83
|
+
key: "Evaluations",
|
|
84
|
+
width: 30,
|
|
85
|
+
value: r.evaluations.map((e) => `${e.name}:${e.score}`).join(", ")
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
header: "Rating",
|
|
89
|
+
key: "Rating",
|
|
90
|
+
width: 20,
|
|
91
|
+
value: r.evaluations.map((e) => `${e.rating}`).join(", ")
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
header: "Error",
|
|
95
|
+
key: "Error",
|
|
96
|
+
width: 20,
|
|
97
|
+
value: r.error ?? "-"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
header: "Reason",
|
|
101
|
+
key: "Reason",
|
|
102
|
+
width: 50,
|
|
103
|
+
value: r.evaluations.map((e) => e.reason ?? "").filter(Boolean).join(" | ")
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
header: "Latency",
|
|
107
|
+
key: "Latency",
|
|
108
|
+
width: 15,
|
|
109
|
+
value: r.latency ? `${r.latency.toFixed(2)}s` : "-"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
header: "Tokens",
|
|
113
|
+
key: "Tokens",
|
|
114
|
+
width: 40,
|
|
115
|
+
value: r.usage ? `${(r.usage.inputTokens || 0) + (r.usage.outputTokens || 0)} (input:${r.usage.inputTokens || 0}, output:${r.usage.outputTokens || 0})` : "-"
|
|
116
|
+
}
|
|
117
|
+
];
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
formatSummary(summary) {
|
|
121
|
+
return [
|
|
122
|
+
{
|
|
123
|
+
header: "Total",
|
|
124
|
+
key: "Total",
|
|
125
|
+
width: 10,
|
|
126
|
+
value: summary.total
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
header: "Success Rate",
|
|
130
|
+
key: "SuccessRate",
|
|
131
|
+
width: 15,
|
|
132
|
+
value: summary.successRate
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
header: "Total Duration",
|
|
136
|
+
key: "Duration",
|
|
137
|
+
width: 15,
|
|
138
|
+
value: summary.duration ? `${summary.duration.toFixed(3)}s` : "-"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
header: "Avg Latency",
|
|
142
|
+
key: "AvgLatency",
|
|
143
|
+
width: 15,
|
|
144
|
+
value: summary.avgLatency ? `${summary.avgLatency.toFixed(3)}s` : "-"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
header: "Total Tokens",
|
|
148
|
+
key: "TotalTokens",
|
|
149
|
+
width: 15,
|
|
150
|
+
value: summary.totalTokens ?? "-"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
header: "Errors",
|
|
154
|
+
key: "Errors",
|
|
155
|
+
width: 8,
|
|
156
|
+
value: summary.errorCount ?? 0
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var ConsoleReporter = class extends BaseReporter {
|
|
162
|
+
name = "console";
|
|
163
|
+
async report(report) {
|
|
164
|
+
const summary = report.summary;
|
|
165
|
+
console.log("\n=== 📊 Evaluation Summary ===");
|
|
166
|
+
const summaryList = this.formatSummary(summary);
|
|
167
|
+
const summaryTable = new cli_table3.default({
|
|
168
|
+
head: summaryList.map((h) => h.header),
|
|
169
|
+
colWidths: summaryList.map((h) => h.width),
|
|
170
|
+
chars
|
|
171
|
+
});
|
|
172
|
+
summaryTable.push(summaryList.map((h) => h.value));
|
|
173
|
+
console.log(summaryTable.toString());
|
|
174
|
+
const list = this.formatReport(report);
|
|
175
|
+
if (!list.length) return;
|
|
176
|
+
console.log("\n=== 📋 Detailed Results ===");
|
|
177
|
+
const pages = renderPagedTable(list, {
|
|
178
|
+
maxCols: 5,
|
|
179
|
+
chars
|
|
180
|
+
});
|
|
181
|
+
for (const page of pages) console.log(page);
|
|
182
|
+
const failed = report.results.filter((r) => r.error);
|
|
183
|
+
if (failed.length) {
|
|
184
|
+
console.log(chalk.default.red("\n=== ❌ Failed Cases ==="));
|
|
185
|
+
for (const f of failed) console.log(`#${f.id} Input: ${JSON.stringify(f.input)}\n Expected: ${f.expected ? JSON.stringify(f.expected) : "-"}\n Output: ${f.output ? JSON.stringify(f.output) : "-"}\n Error: ${f.error ?? "-"}\n`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var CsvReporter = class extends BaseReporter {
|
|
190
|
+
name = "csv";
|
|
191
|
+
constructor(filePath) {
|
|
192
|
+
super();
|
|
193
|
+
this.filePath = filePath;
|
|
194
|
+
}
|
|
195
|
+
async writeCsv(filePath, data, headers) {
|
|
196
|
+
node_fs.default.mkdirSync(node_path.default.dirname(filePath), { recursive: true });
|
|
197
|
+
const stream = (0, _fast_csv_format.format)({ headers });
|
|
198
|
+
const writeStream = node_fs.default.createWriteStream(filePath);
|
|
199
|
+
stream.pipe(writeStream);
|
|
200
|
+
for (const row of data) stream.write(row);
|
|
201
|
+
stream.end();
|
|
202
|
+
await new Promise((resolve, reject) => {
|
|
203
|
+
writeStream.on("finish", resolve);
|
|
204
|
+
writeStream.on("error", reject);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
async report(report) {
|
|
208
|
+
const list = this.formatReport(report);
|
|
209
|
+
if (list.length > 0) {
|
|
210
|
+
const resultsHeaders = list[0]?.map((h) => h.header) ?? [];
|
|
211
|
+
const resultsRows = list.map((row) => {
|
|
212
|
+
const record = {};
|
|
213
|
+
for (const item of row) record[item.header] = item.value;
|
|
214
|
+
return record;
|
|
215
|
+
});
|
|
216
|
+
const outputFile = node_path.default.extname(this.filePath).toLowerCase() ? this.filePath : `${this.filePath}.csv`;
|
|
217
|
+
await this.writeCsv(outputFile, resultsRows, resultsHeaders);
|
|
218
|
+
console.log(`✅ Results CSV saved to ${outputFile}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
//#endregion
|
|
224
|
+
exports.ConsoleReporter = ConsoleReporter;
|
|
225
|
+
exports.CsvReporter = CsvReporter;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { format } from "@fast-csv/format";
|
|
5
|
+
import Table from "cli-table3";
|
|
6
|
+
|
|
7
|
+
//#region src/utils/evaluation/reporter.ts
|
|
8
|
+
const borderColor = chalk.green;
|
|
9
|
+
const chars = {
|
|
10
|
+
top: borderColor("─"),
|
|
11
|
+
"top-mid": borderColor("┬"),
|
|
12
|
+
"top-left": borderColor("┌"),
|
|
13
|
+
"top-right": borderColor("┐"),
|
|
14
|
+
bottom: borderColor("─"),
|
|
15
|
+
"bottom-mid": borderColor("┴"),
|
|
16
|
+
"bottom-left": borderColor("└"),
|
|
17
|
+
"bottom-right": borderColor("┘"),
|
|
18
|
+
left: borderColor("│"),
|
|
19
|
+
"left-mid": borderColor("├"),
|
|
20
|
+
mid: borderColor("─"),
|
|
21
|
+
"mid-mid": borderColor("┼"),
|
|
22
|
+
right: borderColor("│"),
|
|
23
|
+
"right-mid": borderColor("┤"),
|
|
24
|
+
middle: borderColor("│")
|
|
25
|
+
};
|
|
26
|
+
const MAX_CELL_LENGTH = 300;
|
|
27
|
+
function renderPagedTable(list, { maxCols = 6, chars }) {
|
|
28
|
+
if (!list.length) return [];
|
|
29
|
+
const tables = [];
|
|
30
|
+
const head = list[0]?.map((h) => h.header) ?? [];
|
|
31
|
+
const widths = list[0]?.map((h) => h.width ?? 20) ?? [];
|
|
32
|
+
for (let i = 0; i < head.length; i += maxCols) {
|
|
33
|
+
const table = new Table({
|
|
34
|
+
head: head.slice(i, i + maxCols),
|
|
35
|
+
colWidths: widths.slice(i, i + maxCols),
|
|
36
|
+
wordWrap: true,
|
|
37
|
+
chars
|
|
38
|
+
});
|
|
39
|
+
for (const row of list) table.push(row.slice(i, i + maxCols).map((h) => String(h.value).length > MAX_CELL_LENGTH ? `${String(h.value).slice(0, MAX_CELL_LENGTH)}...` : h.value));
|
|
40
|
+
tables.push(table.toString());
|
|
41
|
+
}
|
|
42
|
+
return tables;
|
|
43
|
+
}
|
|
44
|
+
var BaseReporter = class {
|
|
45
|
+
name = "base";
|
|
46
|
+
async report(_report) {
|
|
47
|
+
throw new Error("Not implemented");
|
|
48
|
+
}
|
|
49
|
+
formatReport(report) {
|
|
50
|
+
return report.results.map((r) => {
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
header: "ID",
|
|
54
|
+
key: "ID",
|
|
55
|
+
width: 10,
|
|
56
|
+
value: r.id
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
header: "Input",
|
|
60
|
+
key: "Input",
|
|
61
|
+
width: 40,
|
|
62
|
+
value: JSON.stringify(r.input)
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
header: "Output",
|
|
66
|
+
key: "Output",
|
|
67
|
+
width: 40,
|
|
68
|
+
value: r.output ? JSON.stringify(r.output) : "-"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
header: "Expected",
|
|
72
|
+
key: "Expected",
|
|
73
|
+
width: 40,
|
|
74
|
+
value: r.expected ? JSON.stringify(r.expected) : "-"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
header: "Evaluations",
|
|
78
|
+
key: "Evaluations",
|
|
79
|
+
width: 30,
|
|
80
|
+
value: r.evaluations.map((e) => `${e.name}:${e.score}`).join(", ")
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
header: "Rating",
|
|
84
|
+
key: "Rating",
|
|
85
|
+
width: 20,
|
|
86
|
+
value: r.evaluations.map((e) => `${e.rating}`).join(", ")
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
header: "Error",
|
|
90
|
+
key: "Error",
|
|
91
|
+
width: 20,
|
|
92
|
+
value: r.error ?? "-"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
header: "Reason",
|
|
96
|
+
key: "Reason",
|
|
97
|
+
width: 50,
|
|
98
|
+
value: r.evaluations.map((e) => e.reason ?? "").filter(Boolean).join(" | ")
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
header: "Latency",
|
|
102
|
+
key: "Latency",
|
|
103
|
+
width: 15,
|
|
104
|
+
value: r.latency ? `${r.latency.toFixed(2)}s` : "-"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
header: "Tokens",
|
|
108
|
+
key: "Tokens",
|
|
109
|
+
width: 40,
|
|
110
|
+
value: r.usage ? `${(r.usage.inputTokens || 0) + (r.usage.outputTokens || 0)} (input:${r.usage.inputTokens || 0}, output:${r.usage.outputTokens || 0})` : "-"
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
formatSummary(summary) {
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
header: "Total",
|
|
119
|
+
key: "Total",
|
|
120
|
+
width: 10,
|
|
121
|
+
value: summary.total
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
header: "Success Rate",
|
|
125
|
+
key: "SuccessRate",
|
|
126
|
+
width: 15,
|
|
127
|
+
value: summary.successRate
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
header: "Total Duration",
|
|
131
|
+
key: "Duration",
|
|
132
|
+
width: 15,
|
|
133
|
+
value: summary.duration ? `${summary.duration.toFixed(3)}s` : "-"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
header: "Avg Latency",
|
|
137
|
+
key: "AvgLatency",
|
|
138
|
+
width: 15,
|
|
139
|
+
value: summary.avgLatency ? `${summary.avgLatency.toFixed(3)}s` : "-"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
header: "Total Tokens",
|
|
143
|
+
key: "TotalTokens",
|
|
144
|
+
width: 15,
|
|
145
|
+
value: summary.totalTokens ?? "-"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
header: "Errors",
|
|
149
|
+
key: "Errors",
|
|
150
|
+
width: 8,
|
|
151
|
+
value: summary.errorCount ?? 0
|
|
152
|
+
}
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var ConsoleReporter = class extends BaseReporter {
|
|
157
|
+
name = "console";
|
|
158
|
+
async report(report) {
|
|
159
|
+
const summary = report.summary;
|
|
160
|
+
console.log("\n=== 📊 Evaluation Summary ===");
|
|
161
|
+
const summaryList = this.formatSummary(summary);
|
|
162
|
+
const summaryTable = new Table({
|
|
163
|
+
head: summaryList.map((h) => h.header),
|
|
164
|
+
colWidths: summaryList.map((h) => h.width),
|
|
165
|
+
chars
|
|
166
|
+
});
|
|
167
|
+
summaryTable.push(summaryList.map((h) => h.value));
|
|
168
|
+
console.log(summaryTable.toString());
|
|
169
|
+
const list = this.formatReport(report);
|
|
170
|
+
if (!list.length) return;
|
|
171
|
+
console.log("\n=== 📋 Detailed Results ===");
|
|
172
|
+
const pages = renderPagedTable(list, {
|
|
173
|
+
maxCols: 5,
|
|
174
|
+
chars
|
|
175
|
+
});
|
|
176
|
+
for (const page of pages) console.log(page);
|
|
177
|
+
const failed = report.results.filter((r) => r.error);
|
|
178
|
+
if (failed.length) {
|
|
179
|
+
console.log(chalk.red("\n=== ❌ Failed Cases ==="));
|
|
180
|
+
for (const f of failed) console.log(`#${f.id} Input: ${JSON.stringify(f.input)}\n Expected: ${f.expected ? JSON.stringify(f.expected) : "-"}\n Output: ${f.output ? JSON.stringify(f.output) : "-"}\n Error: ${f.error ?? "-"}\n`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
var CsvReporter = class extends BaseReporter {
|
|
185
|
+
name = "csv";
|
|
186
|
+
constructor(filePath) {
|
|
187
|
+
super();
|
|
188
|
+
this.filePath = filePath;
|
|
189
|
+
}
|
|
190
|
+
async writeCsv(filePath, data, headers) {
|
|
191
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
192
|
+
const stream = format({ headers });
|
|
193
|
+
const writeStream = fs.createWriteStream(filePath);
|
|
194
|
+
stream.pipe(writeStream);
|
|
195
|
+
for (const row of data) stream.write(row);
|
|
196
|
+
stream.end();
|
|
197
|
+
await new Promise((resolve$1, reject) => {
|
|
198
|
+
writeStream.on("finish", resolve$1);
|
|
199
|
+
writeStream.on("error", reject);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
async report(report) {
|
|
203
|
+
const list = this.formatReport(report);
|
|
204
|
+
if (list.length > 0) {
|
|
205
|
+
const resultsHeaders = list[0]?.map((h) => h.header) ?? [];
|
|
206
|
+
const resultsRows = list.map((row) => {
|
|
207
|
+
const record = {};
|
|
208
|
+
for (const item of row) record[item.header] = item.value;
|
|
209
|
+
return record;
|
|
210
|
+
});
|
|
211
|
+
const outputFile = path.extname(this.filePath).toLowerCase() ? this.filePath : `${this.filePath}.csv`;
|
|
212
|
+
await this.writeCsv(outputFile, resultsRows, resultsHeaders);
|
|
213
|
+
console.log(`✅ Results CSV saved to ${outputFile}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
//#endregion
|
|
219
|
+
export { ConsoleReporter, CsvReporter };
|
|
220
|
+
//# sourceMappingURL=reporter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reporter.mjs","names":["resolve"],"sources":["../../../src/utils/evaluation/reporter.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { format } from \"@fast-csv/format\";\nimport chalk from \"chalk\";\nimport Table from \"cli-table3\";\nimport type { Report, Reporter } from \"./type.js\";\n\nconst borderColor = chalk.green;\nconst chars = {\n top: borderColor(\"─\"),\n \"top-mid\": borderColor(\"┬\"),\n \"top-left\": borderColor(\"┌\"),\n \"top-right\": borderColor(\"┐\"),\n bottom: borderColor(\"─\"),\n \"bottom-mid\": borderColor(\"┴\"),\n \"bottom-left\": borderColor(\"└\"),\n \"bottom-right\": borderColor(\"┘\"),\n left: borderColor(\"│\"),\n \"left-mid\": borderColor(\"├\"),\n mid: borderColor(\"─\"),\n \"mid-mid\": borderColor(\"┼\"),\n right: borderColor(\"│\"),\n \"right-mid\": borderColor(\"┤\"),\n middle: borderColor(\"│\"),\n};\n\nconst MAX_CELL_LENGTH = 300;\n\nfunction renderPagedTable(\n list: { header: string; width?: number; value: any }[][],\n { maxCols = 6, chars }: { maxCols?: number; chars: Record<string, string> },\n) {\n if (!list.length) return [];\n\n const tables: string[] = [];\n const head = list[0]?.map((h) => h.header) ?? [];\n const widths = list[0]?.map((h) => h.width ?? 20) ?? [];\n\n for (let i = 0; i < head.length; i += maxCols) {\n const subHead = head.slice(i, i + maxCols);\n const subWidths = widths.slice(i, i + maxCols);\n\n const table = new Table({\n head: subHead,\n colWidths: subWidths,\n wordWrap: true,\n chars,\n });\n\n for (const row of list) {\n table.push(\n row\n .slice(i, i + maxCols)\n .map((h) =>\n String(h.value).length > MAX_CELL_LENGTH\n ? `${String(h.value).slice(0, MAX_CELL_LENGTH)}...`\n : h.value,\n ),\n );\n }\n\n tables.push(table.toString());\n }\n\n return tables;\n}\n\nexport class BaseReporter implements Reporter {\n name = \"base\";\n\n async report(_report: Report): Promise<void> {\n throw new Error(\"Not implemented\");\n }\n\n protected formatReport(\n report: Report,\n ): { header: string; key: string; width: number; value: string | number }[][] {\n return report.results.map((r) => {\n return [\n { header: \"ID\", key: \"ID\", width: 10, value: r.id },\n { header: \"Input\", key: \"Input\", width: 40, value: JSON.stringify(r.input) },\n {\n header: \"Output\",\n key: \"Output\",\n width: 40,\n value: r.output ? JSON.stringify(r.output) : \"-\",\n },\n {\n header: \"Expected\",\n key: \"Expected\",\n width: 40,\n value: r.expected ? JSON.stringify(r.expected) : \"-\",\n },\n {\n header: \"Evaluations\",\n key: \"Evaluations\",\n width: 30,\n value: r.evaluations.map((e) => `${e.name}:${e.score}`).join(\", \"),\n },\n {\n header: \"Rating\",\n key: \"Rating\",\n width: 20,\n value: r.evaluations.map((e) => `${e.rating}`).join(\", \"),\n },\n { header: \"Error\", key: \"Error\", width: 20, value: r.error ?? \"-\" },\n {\n header: \"Reason\",\n key: \"Reason\",\n width: 50,\n value: r.evaluations\n .map((e) => e.reason ?? \"\")\n .filter(Boolean)\n .join(\" | \"),\n },\n {\n header: \"Latency\",\n key: \"Latency\",\n width: 15,\n value: r.latency ? `${r.latency.toFixed(2)}s` : \"-\",\n },\n {\n header: \"Tokens\",\n key: \"Tokens\",\n width: 40,\n value: r.usage\n ? `${(r.usage.inputTokens || 0) + (r.usage.outputTokens || 0)} (input:${r.usage.inputTokens || 0}, output:${r.usage.outputTokens || 0})`\n : \"-\",\n },\n ];\n });\n }\n\n protected formatSummary(\n summary: Report[\"summary\"],\n ): { header: string; key: string; width: number; value: string | number }[] {\n return [\n {\n header: \"Total\",\n key: \"Total\",\n width: 10,\n value: summary.total,\n },\n {\n header: \"Success Rate\",\n key: \"SuccessRate\",\n width: 15,\n value: summary.successRate,\n },\n {\n header: \"Total Duration\",\n key: \"Duration\",\n width: 15,\n value: summary.duration ? `${summary.duration.toFixed(3)}s` : \"-\",\n },\n {\n header: \"Avg Latency\",\n key: \"AvgLatency\",\n width: 15,\n value: summary.avgLatency ? `${summary.avgLatency.toFixed(3)}s` : \"-\",\n },\n {\n header: \"Total Tokens\",\n key: \"TotalTokens\",\n width: 15,\n value: summary.totalTokens ?? \"-\",\n },\n {\n header: \"Errors\",\n key: \"Errors\",\n width: 8,\n value: summary.errorCount ?? 0,\n },\n ];\n }\n}\n\nexport class ConsoleReporter extends BaseReporter {\n override name = \"console\";\n\n override async report(report: Report): Promise<void> {\n const summary = report.summary;\n\n console.log(\"\\n=== 📊 Evaluation Summary ===\");\n const summaryList = this.formatSummary(summary);\n const summaryTable = new Table({\n head: summaryList.map((h) => h.header),\n colWidths: summaryList.map((h) => h.width),\n chars,\n });\n\n summaryTable.push(summaryList.map((h) => h.value));\n console.log(summaryTable.toString());\n\n const list = this.formatReport(report);\n if (!list.length) return;\n\n console.log(\"\\n=== 📋 Detailed Results ===\");\n const pages = renderPagedTable(list, { maxCols: 5, chars });\n for (const page of pages) {\n console.log(page);\n }\n\n const failed = report.results.filter((r) => r.error);\n if (failed.length) {\n console.log(chalk.red(\"\\n=== ❌ Failed Cases ===\"));\n for (const f of failed) {\n console.log(\n `#${f.id} Input: ${JSON.stringify(f.input)}\\n Expected: ${\n f.expected ? JSON.stringify(f.expected) : \"-\"\n }\\n Output: ${f.output ? JSON.stringify(f.output) : \"-\"}\\n Error: ${f.error ?? \"-\"}\\n`,\n );\n }\n }\n }\n}\n\nexport class CsvReporter extends BaseReporter {\n override name = \"csv\";\n\n constructor(private filePath: string) {\n super();\n }\n\n private async writeCsv(filePath: string, data: Record<string, any>[], headers: string[]) {\n fs.mkdirSync(path.dirname(filePath), { recursive: true });\n\n const stream = format({ headers });\n const writeStream = fs.createWriteStream(filePath);\n stream.pipe(writeStream);\n\n for (const row of data) {\n stream.write(row);\n }\n\n stream.end();\n\n await new Promise<void>((resolve, reject) => {\n writeStream.on(\"finish\", resolve);\n writeStream.on(\"error\", reject);\n });\n }\n\n override async report(report: Report): Promise<void> {\n const list = this.formatReport(report);\n if (list.length > 0) {\n const resultsHeaders = list[0]?.map((h) => h.header) ?? [];\n const resultsRows = list.map((row) => {\n const record: Record<string, string | number> = {};\n for (const item of row) {\n record[item.header] = item.value;\n }\n return record;\n });\n\n const ext = path.extname(this.filePath).toLowerCase();\n const outputFile = ext ? this.filePath : `${this.filePath}.csv`;\n\n await this.writeCsv(outputFile, resultsRows, resultsHeaders);\n\n console.log(`✅ Results CSV saved to ${outputFile}`);\n }\n }\n}\n"],"mappings":";;;;;;;AAOA,MAAM,cAAc,MAAM;AAC1B,MAAM,QAAQ;CACZ,KAAK,YAAY,IAAI;CACrB,WAAW,YAAY,IAAI;CAC3B,YAAY,YAAY,IAAI;CAC5B,aAAa,YAAY,IAAI;CAC7B,QAAQ,YAAY,IAAI;CACxB,cAAc,YAAY,IAAI;CAC9B,eAAe,YAAY,IAAI;CAC/B,gBAAgB,YAAY,IAAI;CAChC,MAAM,YAAY,IAAI;CACtB,YAAY,YAAY,IAAI;CAC5B,KAAK,YAAY,IAAI;CACrB,WAAW,YAAY,IAAI;CAC3B,OAAO,YAAY,IAAI;CACvB,aAAa,YAAY,IAAI;CAC7B,QAAQ,YAAY,IAAI;CACzB;AAED,MAAM,kBAAkB;AAExB,SAAS,iBACP,MACA,EAAE,UAAU,GAAG,SACf;AACA,KAAI,CAAC,KAAK,OAAQ,QAAO,EAAE;CAE3B,MAAM,SAAmB,EAAE;CAC3B,MAAM,OAAO,KAAK,IAAI,KAAK,MAAM,EAAE,OAAO,IAAI,EAAE;CAChD,MAAM,SAAS,KAAK,IAAI,KAAK,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE;AAEvD,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,SAAS;EAI7C,MAAM,QAAQ,IAAI,MAAM;GACtB,MAJc,KAAK,MAAM,GAAG,IAAI,QAAQ;GAKxC,WAJgB,OAAO,MAAM,GAAG,IAAI,QAAQ;GAK5C,UAAU;GACV;GACD,CAAC;AAEF,OAAK,MAAM,OAAO,KAChB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MAAM,cAAc,KAAK,KAAK,QAAQ;IACpC,MAAM,SAA0C,EAAE;AAClD,SAAK,MAAM,QAAQ,IACjB,QAAO,KAAK,UAAU,KAAK;AAE7B,WAAO;KACP;GAGF,MAAM,aADM,KAAK,QAAQ,KAAK,SAAS,CAAC,aAAa,GAC5B,KAAK,WAAW,GAAG,KAAK,SAAS;AAE1D,SAAM,KAAK,SAAS,YAAY,aAAa,eAAe;AAE5D,WAAQ,IAAI,0BAA0B,aAAa"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let _aigne_core = require("@aigne/core");
|
|
3
|
+
|
|
4
|
+
//#region src/utils/evaluation/runner.ts
|
|
5
|
+
function withTimeout(promise, ms, id) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const timer = setTimeout(() => {
|
|
8
|
+
reject(/* @__PURE__ */ new Error(`Task ${id} timed out after ${ms}ms`));
|
|
9
|
+
}, ms);
|
|
10
|
+
promise.then((res) => {
|
|
11
|
+
clearTimeout(timer);
|
|
12
|
+
resolve(res);
|
|
13
|
+
}).catch((err) => {
|
|
14
|
+
clearTimeout(timer);
|
|
15
|
+
reject(err);
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
var DefaultRunnerWithConcurrency = class {
|
|
20
|
+
name = "default-runner-with-concurrency";
|
|
21
|
+
constructor(agent, aigne = new _aigne_core.AIGNE()) {
|
|
22
|
+
this.agent = agent;
|
|
23
|
+
this.aigne = aigne;
|
|
24
|
+
}
|
|
25
|
+
async *run(dataset, options) {
|
|
26
|
+
const concurrency = options?.concurrency ?? 1;
|
|
27
|
+
const timeoutMs = options?.timeoutMs ?? 0;
|
|
28
|
+
let index = 0;
|
|
29
|
+
const yieldQueue = [];
|
|
30
|
+
let waitingResolve = null;
|
|
31
|
+
let activeWorkers = 0;
|
|
32
|
+
const runTask = async (item) => {
|
|
33
|
+
const start = Date.now();
|
|
34
|
+
options?.hooks?.onBeforeRun?.(item);
|
|
35
|
+
try {
|
|
36
|
+
const execPromise = this.aigne.invoke(this.agent, item.input, { returnMetadata: true });
|
|
37
|
+
const result = timeoutMs > 0 ? await withTimeout(execPromise, timeoutMs, item.id) : await execPromise;
|
|
38
|
+
const { $meta, ...output } = result;
|
|
39
|
+
options?.hooks?.onAfterRun?.(result);
|
|
40
|
+
return {
|
|
41
|
+
...item,
|
|
42
|
+
output,
|
|
43
|
+
latency: (Date.now() - start) / 1e3,
|
|
44
|
+
usage: $meta?.usage || {}
|
|
45
|
+
};
|
|
46
|
+
} catch (err) {
|
|
47
|
+
options?.hooks?.onError?.(err);
|
|
48
|
+
return {
|
|
49
|
+
...item,
|
|
50
|
+
error: err.message
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const worker = async () => {
|
|
55
|
+
activeWorkers++;
|
|
56
|
+
try {
|
|
57
|
+
while (true) {
|
|
58
|
+
const currentIndex = index++;
|
|
59
|
+
if (currentIndex >= dataset.length) break;
|
|
60
|
+
const item = dataset[currentIndex];
|
|
61
|
+
if (!item) continue;
|
|
62
|
+
const res = await runTask(item);
|
|
63
|
+
yieldQueue.push(res);
|
|
64
|
+
waitingResolve?.();
|
|
65
|
+
}
|
|
66
|
+
} finally {
|
|
67
|
+
activeWorkers--;
|
|
68
|
+
waitingResolve?.();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
Array.from({ length: Math.min(concurrency, dataset.length) }, () => worker());
|
|
72
|
+
while (yieldQueue.length > 0 || activeWorkers > 0) if (yieldQueue.length > 0) {
|
|
73
|
+
const result = yieldQueue.shift();
|
|
74
|
+
if (result) yield result;
|
|
75
|
+
} else {
|
|
76
|
+
await new Promise((resolve) => {
|
|
77
|
+
waitingResolve = resolve;
|
|
78
|
+
});
|
|
79
|
+
waitingResolve = null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
exports.DefaultRunnerWithConcurrency = DefaultRunnerWithConcurrency;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { AIGNE } from "@aigne/core";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/evaluation/runner.ts
|
|
4
|
+
function withTimeout(promise, ms, id) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const timer = setTimeout(() => {
|
|
7
|
+
reject(/* @__PURE__ */ new Error(`Task ${id} timed out after ${ms}ms`));
|
|
8
|
+
}, ms);
|
|
9
|
+
promise.then((res) => {
|
|
10
|
+
clearTimeout(timer);
|
|
11
|
+
resolve(res);
|
|
12
|
+
}).catch((err) => {
|
|
13
|
+
clearTimeout(timer);
|
|
14
|
+
reject(err);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
var DefaultRunnerWithConcurrency = class {
|
|
19
|
+
name = "default-runner-with-concurrency";
|
|
20
|
+
constructor(agent, aigne = new AIGNE()) {
|
|
21
|
+
this.agent = agent;
|
|
22
|
+
this.aigne = aigne;
|
|
23
|
+
}
|
|
24
|
+
async *run(dataset, options) {
|
|
25
|
+
const concurrency = options?.concurrency ?? 1;
|
|
26
|
+
const timeoutMs = options?.timeoutMs ?? 0;
|
|
27
|
+
let index = 0;
|
|
28
|
+
const yieldQueue = [];
|
|
29
|
+
let waitingResolve = null;
|
|
30
|
+
let activeWorkers = 0;
|
|
31
|
+
const runTask = async (item) => {
|
|
32
|
+
const start = Date.now();
|
|
33
|
+
options?.hooks?.onBeforeRun?.(item);
|
|
34
|
+
try {
|
|
35
|
+
const execPromise = this.aigne.invoke(this.agent, item.input, { returnMetadata: true });
|
|
36
|
+
const result = timeoutMs > 0 ? await withTimeout(execPromise, timeoutMs, item.id) : await execPromise;
|
|
37
|
+
const { $meta, ...output } = result;
|
|
38
|
+
options?.hooks?.onAfterRun?.(result);
|
|
39
|
+
return {
|
|
40
|
+
...item,
|
|
41
|
+
output,
|
|
42
|
+
latency: (Date.now() - start) / 1e3,
|
|
43
|
+
usage: $meta?.usage || {}
|
|
44
|
+
};
|
|
45
|
+
} catch (err) {
|
|
46
|
+
options?.hooks?.onError?.(err);
|
|
47
|
+
return {
|
|
48
|
+
...item,
|
|
49
|
+
error: err.message
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const worker = async () => {
|
|
54
|
+
activeWorkers++;
|
|
55
|
+
try {
|
|
56
|
+
while (true) {
|
|
57
|
+
const currentIndex = index++;
|
|
58
|
+
if (currentIndex >= dataset.length) break;
|
|
59
|
+
const item = dataset[currentIndex];
|
|
60
|
+
if (!item) continue;
|
|
61
|
+
const res = await runTask(item);
|
|
62
|
+
yieldQueue.push(res);
|
|
63
|
+
waitingResolve?.();
|
|
64
|
+
}
|
|
65
|
+
} finally {
|
|
66
|
+
activeWorkers--;
|
|
67
|
+
waitingResolve?.();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
Array.from({ length: Math.min(concurrency, dataset.length) }, () => worker());
|
|
71
|
+
while (yieldQueue.length > 0 || activeWorkers > 0) if (yieldQueue.length > 0) {
|
|
72
|
+
const result = yieldQueue.shift();
|
|
73
|
+
if (result) yield result;
|
|
74
|
+
} else {
|
|
75
|
+
await new Promise((resolve) => {
|
|
76
|
+
waitingResolve = resolve;
|
|
77
|
+
});
|
|
78
|
+
waitingResolve = null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
export { DefaultRunnerWithConcurrency };
|
|
85
|
+
//# sourceMappingURL=runner.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.mjs","names":[],"sources":["../../../src/utils/evaluation/runner.ts"],"sourcesContent":["import { type Agent, AIGNE } from \"@aigne/core\";\nimport type { DatasetItem, Runner, RunOptions, RunResult } from \"./type.js\";\n\nexport class DefaultRunner implements Runner {\n name = \"default-runner\";\n\n constructor(\n private agent: Agent,\n private aigne: AIGNE = new AIGNE(),\n ) {}\n\n async *run(dataset: DatasetItem[], options?: RunOptions): AsyncGenerator<RunResult> {\n const timeoutMs = options?.timeoutMs ?? 0;\n\n const runTask = async (item: DatasetItem): Promise<RunResult> => {\n const start = Date.now();\n options?.hooks?.onBeforeRun?.(item);\n\n try {\n const execPromise = this.aigne.invoke(this.agent, item.input, { returnMetadata: true });\n const result =\n timeoutMs > 0 ? await withTimeout(execPromise, timeoutMs, item.id) : await execPromise;\n const { $meta, ...output } = result;\n\n options?.hooks?.onAfterRun?.(result);\n\n return {\n ...item,\n output,\n latency: (Date.now() - start) / 1000,\n usage: $meta?.usage || {},\n };\n } catch (err: any) {\n options?.hooks?.onError?.(err);\n\n return {\n ...item,\n error: err.message,\n };\n }\n };\n\n for (const item of dataset) {\n yield await runTask(item);\n }\n }\n}\n\nfunction withTimeout<T>(promise: Promise<T>, ms: number, id: string | number): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n const timer = setTimeout(() => {\n reject(new Error(`Task ${id} timed out after ${ms}ms`));\n }, ms);\n\n promise\n .then((res) => {\n clearTimeout(timer);\n resolve(res);\n })\n .catch((err) => {\n clearTimeout(timer);\n reject(err);\n });\n });\n}\n\nexport class DefaultRunnerWithConcurrency implements Runner {\n name = \"default-runner-with-concurrency\";\n\n constructor(\n private agent: Agent,\n private aigne: AIGNE = new AIGNE(),\n ) {}\n\n async *run(dataset: DatasetItem[], options?: RunOptions): AsyncGenerator<RunResult> {\n const concurrency = options?.concurrency ?? 1;\n const timeoutMs = options?.timeoutMs ?? 0;\n\n let index = 0;\n const yieldQueue: RunResult[] = [];\n let waitingResolve: (() => void) | null = null;\n let activeWorkers = 0;\n\n const runTask = async (item: DatasetItem): Promise<RunResult> => {\n const start = Date.now();\n options?.hooks?.onBeforeRun?.(item);\n\n try {\n const execPromise = this.aigne.invoke(this.agent, item.input, { returnMetadata: true });\n const result =\n timeoutMs > 0 ? await withTimeout(execPromise, timeoutMs, item.id) : await execPromise;\n const { $meta, ...output } = result;\n\n options?.hooks?.onAfterRun?.(result);\n\n return {\n ...item,\n output,\n latency: (Date.now() - start) / 1000,\n usage: $meta?.usage || {},\n };\n } catch (err: any) {\n options?.hooks?.onError?.(err);\n\n return {\n ...item,\n error: err.message,\n };\n }\n };\n\n const worker = async () => {\n activeWorkers++;\n try {\n while (true) {\n const currentIndex = index++;\n if (currentIndex >= dataset.length) break;\n\n const item = dataset[currentIndex];\n if (!item) continue;\n const res = await runTask(item);\n\n yieldQueue.push(res);\n waitingResolve?.();\n }\n } finally {\n activeWorkers--;\n waitingResolve?.();\n }\n };\n\n Array.from({ length: Math.min(concurrency, dataset.length) }, () => worker());\n\n while (yieldQueue.length > 0 || activeWorkers > 0) {\n if (yieldQueue.length > 0) {\n const result = yieldQueue.shift();\n if (result) yield result;\n } else {\n await new Promise<void>((resolve) => {\n waitingResolve = resolve;\n });\n waitingResolve = null;\n }\n }\n }\n}\n"],"mappings":";;;AAgDA,SAAS,YAAe,SAAqB,IAAY,IAAiC;AACxF,QAAO,IAAI,SAAY,SAAS,WAAW;EACzC,MAAM,QAAQ,iBAAiB;AAC7B,0BAAO,IAAI,MAAM,QAAQ,GAAG,mBAAmB,GAAG,IAAI,CAAC;KACtD,GAAG;AAEN,UACG,MAAM,QAAQ;AACb,gBAAa,MAAM;AACnB,WAAQ,IAAI;IACZ,CACD,OAAO,QAAQ;AACd,gBAAa,MAAM;AACnB,UAAO,IAAI;IACX;GACJ;;AAGJ,IAAa,+BAAb,MAA4D;CAC1D,OAAO;CAEP,YACE,AAAQ,OACR,AAAQ,QAAe,IAAI,OAAO,EAClC;EAFQ;EACA;;CAGV,OAAO,IAAI,SAAwB,SAAiD;EAClF,MAAM,cAAc,SAAS,eAAe;EAC5C,MAAM,YAAY,SAAS,aAAa;EAExC,IAAI,QAAQ;EACZ,MAAM,aAA0B,EAAE;EAClC,IAAI,iBAAsC;EAC1C,IAAI,gBAAgB;EAEpB,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
1
|
+
{"version":3,"file":"get-url-origin.d.mts","names":[],"sources":["../../src/utils/get-url-origin.ts"],"mappings":";cAAa,YAAA,GAAA,GAAA"}
|