axiom 0.34.1 → 0.34.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/dist/bin.cjs +1818 -1437
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +4 -4
- package/dist/{chunk-AAEGYMAU.js → chunk-64ND72U5.js} +4 -3
- package/dist/chunk-64ND72U5.js.map +1 -0
- package/dist/chunk-BEIUSCMN.js +483 -0
- package/dist/chunk-BEIUSCMN.js.map +1 -0
- package/dist/{chunk-4G7GDQ6Q.js → chunk-T3E7TIPT.js} +145 -724
- package/dist/chunk-T3E7TIPT.js.map +1 -0
- package/dist/evals.cjs +2420 -2075
- package/dist/evals.cjs.map +1 -1
- package/dist/evals.js +6 -5
- package/dist/evals.js.map +1 -1
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/run-vitest-HFPOTVUA.js +141 -0
- package/dist/run-vitest-HFPOTVUA.js.map +1 -0
- package/package.json +3 -2
- package/dist/chunk-4G7GDQ6Q.js.map +0 -1
- package/dist/chunk-AAEGYMAU.js.map +0 -1
package/dist/bin.cjs
CHANGED
|
@@ -43,137 +43,13 @@ var init_cjs_shims = __esm({
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
// src/bin.ts
|
|
47
|
-
var bin_exports = {};
|
|
48
|
-
__export(bin_exports, {
|
|
49
|
-
program: () => program
|
|
50
|
-
});
|
|
51
|
-
module.exports = __toCommonJS(bin_exports);
|
|
52
|
-
init_cjs_shims();
|
|
53
|
-
var import_commander3 = require("commander");
|
|
54
|
-
|
|
55
|
-
// src/cli/commands/eval.command.ts
|
|
56
|
-
init_cjs_shims();
|
|
57
|
-
var import_commander = require("commander");
|
|
58
|
-
var import_nanoid = require("nanoid");
|
|
59
|
-
|
|
60
|
-
// src/evals/run-vitest.ts
|
|
61
|
-
init_cjs_shims();
|
|
62
|
-
|
|
63
|
-
// ../../node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js
|
|
64
|
-
init_cjs_shims();
|
|
65
|
-
|
|
66
|
-
// ../../node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js
|
|
67
|
-
init_cjs_shims();
|
|
68
|
-
var f = {
|
|
69
|
-
reset: [0, 0],
|
|
70
|
-
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
71
|
-
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
72
|
-
italic: [3, 23],
|
|
73
|
-
underline: [4, 24],
|
|
74
|
-
inverse: [7, 27],
|
|
75
|
-
hidden: [8, 28],
|
|
76
|
-
strikethrough: [9, 29],
|
|
77
|
-
black: [30, 39],
|
|
78
|
-
red: [31, 39],
|
|
79
|
-
green: [32, 39],
|
|
80
|
-
yellow: [33, 39],
|
|
81
|
-
blue: [34, 39],
|
|
82
|
-
magenta: [35, 39],
|
|
83
|
-
cyan: [36, 39],
|
|
84
|
-
white: [37, 39],
|
|
85
|
-
gray: [90, 39],
|
|
86
|
-
bgBlack: [40, 49],
|
|
87
|
-
bgRed: [41, 49],
|
|
88
|
-
bgGreen: [42, 49],
|
|
89
|
-
bgYellow: [43, 49],
|
|
90
|
-
bgBlue: [44, 49],
|
|
91
|
-
bgMagenta: [45, 49],
|
|
92
|
-
bgCyan: [46, 49],
|
|
93
|
-
bgWhite: [47, 49],
|
|
94
|
-
blackBright: [90, 39],
|
|
95
|
-
redBright: [91, 39],
|
|
96
|
-
greenBright: [92, 39],
|
|
97
|
-
yellowBright: [93, 39],
|
|
98
|
-
blueBright: [94, 39],
|
|
99
|
-
magentaBright: [95, 39],
|
|
100
|
-
cyanBright: [96, 39],
|
|
101
|
-
whiteBright: [97, 39],
|
|
102
|
-
bgBlackBright: [100, 49],
|
|
103
|
-
bgRedBright: [101, 49],
|
|
104
|
-
bgGreenBright: [102, 49],
|
|
105
|
-
bgYellowBright: [103, 49],
|
|
106
|
-
bgBlueBright: [104, 49],
|
|
107
|
-
bgMagentaBright: [105, 49],
|
|
108
|
-
bgCyanBright: [106, 49],
|
|
109
|
-
bgWhiteBright: [107, 49]
|
|
110
|
-
};
|
|
111
|
-
var h = Object.entries(f);
|
|
112
|
-
function a(n) {
|
|
113
|
-
return String(n);
|
|
114
|
-
}
|
|
115
|
-
a.open = "";
|
|
116
|
-
a.close = "";
|
|
117
|
-
function C(n = false) {
|
|
118
|
-
let e = typeof process != "undefined" ? process : void 0, i = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
|
|
119
|
-
return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
|
|
120
|
-
}
|
|
121
|
-
function p(n = false) {
|
|
122
|
-
let e = C(n), i = (r2, t, c, o) => {
|
|
123
|
-
let l = "", s2 = 0;
|
|
124
|
-
do
|
|
125
|
-
l += r2.substring(s2, o) + c, s2 = o + t.length, o = r2.indexOf(t, s2);
|
|
126
|
-
while (~o);
|
|
127
|
-
return l + r2.substring(s2);
|
|
128
|
-
}, g = (r2, t, c = r2) => {
|
|
129
|
-
let o = (l) => {
|
|
130
|
-
let s2 = String(l), b = s2.indexOf(t, r2.length);
|
|
131
|
-
return ~b ? r2 + i(s2, t, c, b) + t : r2 + s2 + t;
|
|
132
|
-
};
|
|
133
|
-
return o.open = r2, o.close = t, o;
|
|
134
|
-
}, u2 = {
|
|
135
|
-
isColorSupported: e
|
|
136
|
-
}, d = (r2) => `\x1B[${r2}m`;
|
|
137
|
-
for (let [r2, t] of h)
|
|
138
|
-
u2[r2] = e ? g(
|
|
139
|
-
d(t[0]),
|
|
140
|
-
d(t[1]),
|
|
141
|
-
t[2]
|
|
142
|
-
) : a;
|
|
143
|
-
return u2;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// ../../node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js
|
|
147
|
-
var import_tty = require("tty");
|
|
148
|
-
var r = process.env.FORCE_TTY !== void 0 || (0, import_tty.isatty)(1);
|
|
149
|
-
var u = p(r);
|
|
150
|
-
|
|
151
|
-
// src/evals/run-vitest.ts
|
|
152
|
-
var import_node_path = require("path");
|
|
153
|
-
var import_node_fs = require("fs");
|
|
154
|
-
var import_node_os = require("os");
|
|
155
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
156
|
-
var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
|
|
157
|
-
var import_node = require("vitest/node");
|
|
158
|
-
|
|
159
|
-
// src/evals/reporter.ts
|
|
160
|
-
init_cjs_shims();
|
|
161
|
-
|
|
162
|
-
// src/evals/context/storage.ts
|
|
163
|
-
init_cjs_shims();
|
|
164
|
-
var import_api9 = require("@opentelemetry/api");
|
|
165
|
-
|
|
166
46
|
// src/evals/context/manager.ts
|
|
167
|
-
init_cjs_shims();
|
|
168
|
-
var import_node_module = require("module");
|
|
169
|
-
var CONTEXT_MANAGER_SYMBOL = Symbol.for("axiom.context_manager");
|
|
170
47
|
function getGlobalContextManager() {
|
|
171
48
|
return globalThis[CONTEXT_MANAGER_SYMBOL];
|
|
172
49
|
}
|
|
173
50
|
function setGlobalContextManager(manager) {
|
|
174
51
|
globalThis[CONTEXT_MANAGER_SYMBOL] = manager;
|
|
175
52
|
}
|
|
176
|
-
var isNodeJS = typeof process !== "undefined" && !!process.versions?.node;
|
|
177
53
|
function getContextManager() {
|
|
178
54
|
const existing = getGlobalContextManager();
|
|
179
55
|
if (existing) return existing;
|
|
@@ -229,27 +105,34 @@ function createAsyncHook(_name) {
|
|
|
229
105
|
}
|
|
230
106
|
};
|
|
231
107
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
108
|
+
var import_node_module, CONTEXT_MANAGER_SYMBOL, isNodeJS;
|
|
109
|
+
var init_manager = __esm({
|
|
110
|
+
"src/evals/context/manager.ts"() {
|
|
111
|
+
"use strict";
|
|
112
|
+
init_cjs_shims();
|
|
113
|
+
import_node_module = require("module");
|
|
114
|
+
CONTEXT_MANAGER_SYMBOL = Symbol.for("axiom.context_manager");
|
|
115
|
+
isNodeJS = typeof process !== "undefined" && !!process.versions?.node;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
235
118
|
|
|
236
119
|
// src/evals/context/global-flags.ts
|
|
237
|
-
init_cjs_shims();
|
|
238
|
-
var GLOBAL_OVERRIDES_SYMBOL = Symbol.for("axiom.global_flag_overrides");
|
|
239
120
|
function setRoot(val) {
|
|
240
121
|
globalThis[GLOBAL_OVERRIDES_SYMBOL] = val;
|
|
241
122
|
}
|
|
242
123
|
function setGlobalFlagOverrides(overrides2) {
|
|
243
124
|
setRoot(overrides2);
|
|
244
125
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
126
|
+
var GLOBAL_OVERRIDES_SYMBOL;
|
|
127
|
+
var init_global_flags = __esm({
|
|
128
|
+
"src/evals/context/global-flags.ts"() {
|
|
129
|
+
"use strict";
|
|
130
|
+
init_cjs_shims();
|
|
131
|
+
GLOBAL_OVERRIDES_SYMBOL = Symbol.for("axiom.global_flag_overrides");
|
|
132
|
+
}
|
|
133
|
+
});
|
|
249
134
|
|
|
250
135
|
// src/cli/utils/format-zod-errors.ts
|
|
251
|
-
init_cjs_shims();
|
|
252
|
-
var import_zod = require("zod");
|
|
253
136
|
function formatZodErrors(error) {
|
|
254
137
|
const issues = error.issues;
|
|
255
138
|
const messages = [];
|
|
@@ -345,13 +228,16 @@ function generateExampleForIssue(issue, path3) {
|
|
|
345
228
|
}
|
|
346
229
|
return null;
|
|
347
230
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
231
|
+
var import_zod;
|
|
232
|
+
var init_format_zod_errors = __esm({
|
|
233
|
+
"src/cli/utils/format-zod-errors.ts"() {
|
|
234
|
+
"use strict";
|
|
235
|
+
init_cjs_shims();
|
|
236
|
+
import_zod = require("zod");
|
|
237
|
+
}
|
|
238
|
+
});
|
|
352
239
|
|
|
353
240
|
// src/util/zod-internals.ts
|
|
354
|
-
init_cjs_shims();
|
|
355
241
|
function isZodV4Schema(schema) {
|
|
356
242
|
if (!schema || typeof schema !== "object") return false;
|
|
357
243
|
const s2 = schema;
|
|
@@ -381,20 +267,6 @@ function getDefRawType(def) {
|
|
|
381
267
|
if (raw == null) return void 0;
|
|
382
268
|
return typeof raw === "string" ? raw : String(raw);
|
|
383
269
|
}
|
|
384
|
-
var KNOWN_KINDS = /* @__PURE__ */ new Set([
|
|
385
|
-
"object",
|
|
386
|
-
"optional",
|
|
387
|
-
"default",
|
|
388
|
-
"nullable",
|
|
389
|
-
"readonly",
|
|
390
|
-
"prefault",
|
|
391
|
-
"nonoptional",
|
|
392
|
-
"catch",
|
|
393
|
-
"array",
|
|
394
|
-
"record",
|
|
395
|
-
"union",
|
|
396
|
-
"discriminatedunion"
|
|
397
|
-
]);
|
|
398
270
|
function getKind(schemaOrDef) {
|
|
399
271
|
const def = schemaOrDef && typeof schemaOrDef === "object" && "type" in schemaOrDef ? schemaOrDef : getDef(schemaOrDef);
|
|
400
272
|
const raw = getDefRawType(def);
|
|
@@ -429,16 +301,6 @@ function getDefaultValue(schema) {
|
|
|
429
301
|
const def = getDef(schema);
|
|
430
302
|
return def?.defaultValue;
|
|
431
303
|
}
|
|
432
|
-
var TRANSPARENT_WRAPPERS = [
|
|
433
|
-
"optional",
|
|
434
|
-
"nullable",
|
|
435
|
-
"default",
|
|
436
|
-
"readonly",
|
|
437
|
-
"prefault",
|
|
438
|
-
"nonoptional",
|
|
439
|
-
"catch"
|
|
440
|
-
// transparent for schema structure, but alters error behavior
|
|
441
|
-
];
|
|
442
304
|
function unwrapTransparent(schema) {
|
|
443
305
|
let current = schema;
|
|
444
306
|
for (let i = 0; i < 10; i++) {
|
|
@@ -454,6 +316,37 @@ function unwrapTransparent(schema) {
|
|
|
454
316
|
}
|
|
455
317
|
return current;
|
|
456
318
|
}
|
|
319
|
+
var KNOWN_KINDS, TRANSPARENT_WRAPPERS;
|
|
320
|
+
var init_zod_internals = __esm({
|
|
321
|
+
"src/util/zod-internals.ts"() {
|
|
322
|
+
"use strict";
|
|
323
|
+
init_cjs_shims();
|
|
324
|
+
KNOWN_KINDS = /* @__PURE__ */ new Set([
|
|
325
|
+
"object",
|
|
326
|
+
"optional",
|
|
327
|
+
"default",
|
|
328
|
+
"nullable",
|
|
329
|
+
"readonly",
|
|
330
|
+
"prefault",
|
|
331
|
+
"nonoptional",
|
|
332
|
+
"catch",
|
|
333
|
+
"array",
|
|
334
|
+
"record",
|
|
335
|
+
"union",
|
|
336
|
+
"discriminatedunion"
|
|
337
|
+
]);
|
|
338
|
+
TRANSPARENT_WRAPPERS = [
|
|
339
|
+
"optional",
|
|
340
|
+
"nullable",
|
|
341
|
+
"default",
|
|
342
|
+
"readonly",
|
|
343
|
+
"prefault",
|
|
344
|
+
"nonoptional",
|
|
345
|
+
"catch"
|
|
346
|
+
// transparent for schema structure, but alters error behavior
|
|
347
|
+
];
|
|
348
|
+
}
|
|
349
|
+
});
|
|
457
350
|
|
|
458
351
|
// src/util/dot-path.ts
|
|
459
352
|
function parsePath(path3) {
|
|
@@ -509,10 +402,17 @@ function isValidPath(schema, segments) {
|
|
|
509
402
|
}
|
|
510
403
|
return true;
|
|
511
404
|
}
|
|
405
|
+
var import_zod2;
|
|
406
|
+
var init_dot_path = __esm({
|
|
407
|
+
"src/util/dot-path.ts"() {
|
|
408
|
+
"use strict";
|
|
409
|
+
init_cjs_shims();
|
|
410
|
+
import_zod2 = require("zod");
|
|
411
|
+
init_zod_internals();
|
|
412
|
+
}
|
|
413
|
+
});
|
|
512
414
|
|
|
513
415
|
// src/util/deep-partial-schema.ts
|
|
514
|
-
init_cjs_shims();
|
|
515
|
-
var import_zod3 = require("zod");
|
|
516
416
|
function makeDeepPartial(schema) {
|
|
517
417
|
const shape = schema.shape;
|
|
518
418
|
const newShape = {};
|
|
@@ -562,180 +462,224 @@ function makeDeepPartialField(fieldSchema) {
|
|
|
562
462
|
}
|
|
563
463
|
return fieldSchema.optional();
|
|
564
464
|
}
|
|
465
|
+
var import_zod3;
|
|
466
|
+
var init_deep_partial_schema = __esm({
|
|
467
|
+
"src/util/deep-partial-schema.ts"() {
|
|
468
|
+
"use strict";
|
|
469
|
+
init_cjs_shims();
|
|
470
|
+
import_zod3 = require("zod");
|
|
471
|
+
init_zod_internals();
|
|
472
|
+
}
|
|
473
|
+
});
|
|
565
474
|
|
|
566
|
-
// src/
|
|
567
|
-
var
|
|
568
|
-
var
|
|
475
|
+
// src/validate-flags.ts
|
|
476
|
+
var import_zod4;
|
|
477
|
+
var init_validate_flags = __esm({
|
|
478
|
+
"src/validate-flags.ts"() {
|
|
479
|
+
"use strict";
|
|
480
|
+
init_cjs_shims();
|
|
481
|
+
import_zod4 = require("zod");
|
|
482
|
+
init_global_flags();
|
|
483
|
+
init_format_zod_errors();
|
|
484
|
+
init_dot_path();
|
|
485
|
+
init_deep_partial_schema();
|
|
486
|
+
init_zod_internals();
|
|
487
|
+
}
|
|
488
|
+
});
|
|
569
489
|
|
|
570
490
|
// src/otel/utils/to-otel-attribute.ts
|
|
571
|
-
|
|
572
|
-
var
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
init_cjs_shims();
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
var import_api6 = require("@opentelemetry/api");
|
|
491
|
+
var import_api;
|
|
492
|
+
var init_to_otel_attribute = __esm({
|
|
493
|
+
"src/otel/utils/to-otel-attribute.ts"() {
|
|
494
|
+
"use strict";
|
|
495
|
+
init_cjs_shims();
|
|
496
|
+
import_api = require("@opentelemetry/api");
|
|
497
|
+
}
|
|
498
|
+
});
|
|
580
499
|
|
|
581
500
|
// src/otel/withSpanBaggageKey.ts
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
init_cjs_shims();
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
// src/otel/semconv/attributes.ts
|
|
589
|
-
init_cjs_shims();
|
|
590
|
-
var import_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
501
|
+
var init_withSpanBaggageKey = __esm({
|
|
502
|
+
"src/otel/withSpanBaggageKey.ts"() {
|
|
503
|
+
"use strict";
|
|
504
|
+
init_cjs_shims();
|
|
505
|
+
}
|
|
506
|
+
});
|
|
591
507
|
|
|
592
508
|
// src/otel/semconv/eval_proposal.ts
|
|
593
|
-
|
|
509
|
+
var init_eval_proposal = __esm({
|
|
510
|
+
"src/otel/semconv/eval_proposal.ts"() {
|
|
511
|
+
"use strict";
|
|
512
|
+
init_cjs_shims();
|
|
513
|
+
}
|
|
514
|
+
});
|
|
594
515
|
|
|
595
516
|
// src/otel/semconv/attributes.ts
|
|
596
|
-
var import_incubating
|
|
517
|
+
var import_semantic_conventions, import_incubating;
|
|
518
|
+
var init_attributes = __esm({
|
|
519
|
+
"src/otel/semconv/attributes.ts"() {
|
|
520
|
+
"use strict";
|
|
521
|
+
init_cjs_shims();
|
|
522
|
+
import_semantic_conventions = require("@opentelemetry/semantic-conventions");
|
|
523
|
+
init_eval_proposal();
|
|
524
|
+
import_incubating = require("@opentelemetry/semantic-conventions/incubating");
|
|
525
|
+
}
|
|
526
|
+
});
|
|
597
527
|
|
|
598
528
|
// src/otel/startActiveSpan.ts
|
|
599
|
-
|
|
600
|
-
var
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
init_cjs_shims();
|
|
604
|
-
|
|
529
|
+
var import_api2;
|
|
530
|
+
var init_startActiveSpan = __esm({
|
|
531
|
+
"src/otel/startActiveSpan.ts"() {
|
|
532
|
+
"use strict";
|
|
533
|
+
init_cjs_shims();
|
|
534
|
+
import_api2 = require("@opentelemetry/api");
|
|
535
|
+
}
|
|
536
|
+
});
|
|
605
537
|
|
|
606
538
|
// package.json
|
|
607
|
-
var package_default
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
module: "./dist/index.js",
|
|
631
|
-
bin: {
|
|
632
|
-
axiom: "./dist/bin.js"
|
|
633
|
-
},
|
|
634
|
-
exports: {
|
|
635
|
-
"./ai": {
|
|
636
|
-
import: {
|
|
637
|
-
types: "./dist/index.d.ts",
|
|
638
|
-
default: "./dist/index.js"
|
|
539
|
+
var package_default;
|
|
540
|
+
var init_package = __esm({
|
|
541
|
+
"package.json"() {
|
|
542
|
+
package_default = {
|
|
543
|
+
name: "axiom",
|
|
544
|
+
version: "0.34.2",
|
|
545
|
+
type: "module",
|
|
546
|
+
author: "Axiom, Inc.",
|
|
547
|
+
contributors: [
|
|
548
|
+
"Islam Shehata <islam@axiom.co>",
|
|
549
|
+
"Chris Ehrlich <chris@axiom.co>",
|
|
550
|
+
"Gabriel de Andrade <gabriel@axiom.co>"
|
|
551
|
+
],
|
|
552
|
+
scripts: {
|
|
553
|
+
dev: "tsup --watch",
|
|
554
|
+
build: "tsup && chmod +x dist/bin.js",
|
|
555
|
+
format: "prettier --write .",
|
|
556
|
+
"format:check": "prettier --check .",
|
|
557
|
+
lint: "eslint './**/*.{js,ts}'",
|
|
558
|
+
typecheck: "tsc --noEmit",
|
|
559
|
+
test: "vitest run",
|
|
560
|
+
"test:watch": "vitest --watch",
|
|
561
|
+
publint: "npx publint"
|
|
639
562
|
},
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
"./ai/evals": {
|
|
646
|
-
import: {
|
|
647
|
-
types: "./dist/evals.d.ts",
|
|
648
|
-
default: "./dist/evals.js"
|
|
563
|
+
types: "./dist/index.d.ts",
|
|
564
|
+
main: "./dist/index.cjs",
|
|
565
|
+
module: "./dist/index.js",
|
|
566
|
+
bin: {
|
|
567
|
+
axiom: "./dist/bin.js"
|
|
649
568
|
},
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
569
|
+
exports: {
|
|
570
|
+
"./ai": {
|
|
571
|
+
import: {
|
|
572
|
+
types: "./dist/index.d.ts",
|
|
573
|
+
default: "./dist/index.js"
|
|
574
|
+
},
|
|
575
|
+
require: {
|
|
576
|
+
types: "./dist/index.d.cts",
|
|
577
|
+
default: "./dist/index.cjs"
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
"./ai/evals": {
|
|
581
|
+
import: {
|
|
582
|
+
types: "./dist/evals.d.ts",
|
|
583
|
+
default: "./dist/evals.js"
|
|
584
|
+
},
|
|
585
|
+
require: {
|
|
586
|
+
types: "./dist/evals.d.cts",
|
|
587
|
+
default: "./dist/evals.cjs"
|
|
588
|
+
}
|
|
589
|
+
},
|
|
590
|
+
"./ai/config": {
|
|
591
|
+
import: {
|
|
592
|
+
types: "./dist/config.d.ts",
|
|
593
|
+
default: "./dist/config.js"
|
|
594
|
+
},
|
|
595
|
+
require: {
|
|
596
|
+
types: "./dist/config.d.cts",
|
|
597
|
+
default: "./dist/config.cjs"
|
|
598
|
+
}
|
|
599
|
+
}
|
|
659
600
|
},
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
],
|
|
729
|
-
packageManager: "pnpm@10.16.1"
|
|
730
|
-
};
|
|
601
|
+
keywords: [
|
|
602
|
+
"axiom",
|
|
603
|
+
"logging",
|
|
604
|
+
"ai",
|
|
605
|
+
"otel",
|
|
606
|
+
"opentelemetry"
|
|
607
|
+
],
|
|
608
|
+
repository: {
|
|
609
|
+
type: "git",
|
|
610
|
+
url: "git+https://github.com/axiomhq/ai.git",
|
|
611
|
+
directory: "packages/ai"
|
|
612
|
+
},
|
|
613
|
+
license: "MIT",
|
|
614
|
+
dependencies: {
|
|
615
|
+
"@next/env": "^15.4.2",
|
|
616
|
+
"@opentelemetry/auto-instrumentations-node": "^0.60.1",
|
|
617
|
+
"@opentelemetry/context-async-hooks": "^2.0.1",
|
|
618
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.202.0",
|
|
619
|
+
"@opentelemetry/resources": "^2.0.1",
|
|
620
|
+
"@opentelemetry/sdk-trace-node": "^2.0.1",
|
|
621
|
+
"@opentelemetry/semantic-conventions": "^1.37.0",
|
|
622
|
+
"@sinclair/typebox": "^0.34.37",
|
|
623
|
+
c12: "^2.0.4",
|
|
624
|
+
commander: "^14.0.0",
|
|
625
|
+
defu: "^6.1.4",
|
|
626
|
+
handlebars: "^4.7.8",
|
|
627
|
+
nanoid: "^5.1.5",
|
|
628
|
+
open: "^10.1.0",
|
|
629
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
630
|
+
vitest: "^4.0.0"
|
|
631
|
+
},
|
|
632
|
+
peerDependencies: {
|
|
633
|
+
"@opentelemetry/api": "^1.9.0",
|
|
634
|
+
zod: "^3.25.0 || ^4.0.0"
|
|
635
|
+
},
|
|
636
|
+
devDependencies: {
|
|
637
|
+
"@ai-sdk/anthropicv1": "npm:@ai-sdk/anthropic@^1.2.12",
|
|
638
|
+
"@ai-sdk/anthropicv2": "npm:@ai-sdk/anthropic@^2.0.44",
|
|
639
|
+
"@ai-sdk/openaiv1": "npm:@ai-sdk/openai@^1.3.24",
|
|
640
|
+
"@ai-sdk/openaiv2": "npm:@ai-sdk/openai@^2.0.67",
|
|
641
|
+
"@ai-sdk/providerv1": "npm:@ai-sdk/provider@^1.1.3",
|
|
642
|
+
"@ai-sdk/providerv2": "npm:@ai-sdk/provider@^2.0.0",
|
|
643
|
+
"@opentelemetry/api": "^1.9.0",
|
|
644
|
+
"@opentelemetry/core": "^2.0.1",
|
|
645
|
+
"@opentelemetry/sdk-trace-base": "^2.0.1",
|
|
646
|
+
"@opentelemetry/sdk-trace-node": "^2.0.1",
|
|
647
|
+
"@repo/eslint-config": "workspace:*",
|
|
648
|
+
"@types/node": "^22.15.29",
|
|
649
|
+
"@vitest/coverage-v8": "^4.0.0",
|
|
650
|
+
aiv4: "npm:ai@^4.3.19",
|
|
651
|
+
aiv5: "npm:ai@^5.0.93",
|
|
652
|
+
esbuild: "^0.25.8",
|
|
653
|
+
eslint: "catalog:",
|
|
654
|
+
msw: "^2.12.2",
|
|
655
|
+
prettier: "catalog:",
|
|
656
|
+
tinyrainbow: "^2.0.0",
|
|
657
|
+
tsup: "catalog:",
|
|
658
|
+
typescript: "catalog:",
|
|
659
|
+
vitest: "catalog:",
|
|
660
|
+
zod: "catalog:"
|
|
661
|
+
},
|
|
662
|
+
files: [
|
|
663
|
+
"dist"
|
|
664
|
+
],
|
|
665
|
+
packageManager: "pnpm@10.16.1"
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
});
|
|
731
669
|
|
|
732
670
|
// src/otel/utils/redaction.ts
|
|
733
|
-
|
|
734
|
-
var
|
|
735
|
-
|
|
671
|
+
var import_api3, AXIOM_AI_REDACTION_KEY;
|
|
672
|
+
var init_redaction = __esm({
|
|
673
|
+
"src/otel/utils/redaction.ts"() {
|
|
674
|
+
"use strict";
|
|
675
|
+
init_cjs_shims();
|
|
676
|
+
import_api3 = require("@opentelemetry/api");
|
|
677
|
+
init_withSpanBaggageKey();
|
|
678
|
+
AXIOM_AI_REDACTION_KEY = Symbol.for("__axiom_ai_redaction__");
|
|
679
|
+
}
|
|
680
|
+
});
|
|
736
681
|
|
|
737
682
|
// src/otel/initAxiomAI.ts
|
|
738
|
-
var AXIOM_AI_SCOPE_KEY = Symbol.for("__axiom_ai_scope__");
|
|
739
683
|
function extractTracerScope(tracer) {
|
|
740
684
|
const tracerAny = tracer;
|
|
741
685
|
const name = tracerAny._instrumentationScope?.name || tracerAny.instrumentationLibrary?.name || package_default.name;
|
|
@@ -758,51 +702,185 @@ function initAxiomAI(config) {
|
|
|
758
702
|
globalThis[AXIOM_AI_REDACTION_KEY] = config.redactionPolicy;
|
|
759
703
|
}
|
|
760
704
|
}
|
|
705
|
+
var import_api4, AXIOM_AI_SCOPE_KEY;
|
|
706
|
+
var init_initAxiomAI = __esm({
|
|
707
|
+
"src/otel/initAxiomAI.ts"() {
|
|
708
|
+
"use strict";
|
|
709
|
+
init_cjs_shims();
|
|
710
|
+
import_api4 = require("@opentelemetry/api");
|
|
711
|
+
init_package();
|
|
712
|
+
init_redaction();
|
|
713
|
+
AXIOM_AI_SCOPE_KEY = Symbol.for("__axiom_ai_scope__");
|
|
714
|
+
}
|
|
715
|
+
});
|
|
761
716
|
|
|
762
|
-
// src/
|
|
763
|
-
|
|
717
|
+
// src/otel/utils/wrapperUtils.ts
|
|
718
|
+
var import_api5;
|
|
719
|
+
var init_wrapperUtils = __esm({
|
|
720
|
+
"src/otel/utils/wrapperUtils.ts"() {
|
|
721
|
+
"use strict";
|
|
722
|
+
init_cjs_shims();
|
|
723
|
+
import_api5 = require("@opentelemetry/api");
|
|
724
|
+
init_attributes();
|
|
725
|
+
init_withSpanBaggageKey();
|
|
726
|
+
init_startActiveSpan();
|
|
727
|
+
init_initAxiomAI();
|
|
728
|
+
}
|
|
729
|
+
});
|
|
764
730
|
|
|
765
|
-
// src/
|
|
766
|
-
|
|
731
|
+
// src/util/name-validation-runtime.ts
|
|
732
|
+
var init_name_validation_runtime = __esm({
|
|
733
|
+
"src/util/name-validation-runtime.ts"() {
|
|
734
|
+
"use strict";
|
|
735
|
+
init_cjs_shims();
|
|
736
|
+
}
|
|
737
|
+
});
|
|
767
738
|
|
|
768
|
-
// src/otel/
|
|
769
|
-
|
|
739
|
+
// src/otel/withSpan.ts
|
|
740
|
+
var import_api6;
|
|
741
|
+
var init_withSpan = __esm({
|
|
742
|
+
"src/otel/withSpan.ts"() {
|
|
743
|
+
"use strict";
|
|
744
|
+
init_cjs_shims();
|
|
745
|
+
import_api6 = require("@opentelemetry/api");
|
|
746
|
+
init_withSpanBaggageKey();
|
|
747
|
+
init_wrapperUtils();
|
|
748
|
+
init_name_validation_runtime();
|
|
749
|
+
}
|
|
750
|
+
});
|
|
770
751
|
|
|
771
|
-
// src/otel/
|
|
772
|
-
|
|
773
|
-
|
|
752
|
+
// src/otel/utils/contentSanitizer.ts
|
|
753
|
+
var init_contentSanitizer = __esm({
|
|
754
|
+
"src/otel/utils/contentSanitizer.ts"() {
|
|
755
|
+
"use strict";
|
|
756
|
+
init_cjs_shims();
|
|
757
|
+
}
|
|
758
|
+
});
|
|
774
759
|
|
|
775
760
|
// src/otel/completionUtils.ts
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
init_cjs_shims();
|
|
761
|
+
var init_completionUtils = __esm({
|
|
762
|
+
"src/otel/completionUtils.ts"() {
|
|
763
|
+
"use strict";
|
|
764
|
+
init_cjs_shims();
|
|
765
|
+
init_contentSanitizer();
|
|
766
|
+
}
|
|
767
|
+
});
|
|
780
768
|
|
|
781
769
|
// src/util/promptUtils.ts
|
|
782
|
-
|
|
770
|
+
var init_promptUtils = __esm({
|
|
771
|
+
"src/util/promptUtils.ts"() {
|
|
772
|
+
"use strict";
|
|
773
|
+
init_cjs_shims();
|
|
774
|
+
}
|
|
775
|
+
});
|
|
783
776
|
|
|
784
777
|
// src/otel/utils/normalized.ts
|
|
785
|
-
|
|
778
|
+
var init_normalized = __esm({
|
|
779
|
+
"src/otel/utils/normalized.ts"() {
|
|
780
|
+
"use strict";
|
|
781
|
+
init_cjs_shims();
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
|
|
785
|
+
// src/util/currentUnixTime.ts
|
|
786
|
+
var init_currentUnixTime = __esm({
|
|
787
|
+
"src/util/currentUnixTime.ts"() {
|
|
788
|
+
"use strict";
|
|
789
|
+
init_cjs_shims();
|
|
790
|
+
}
|
|
791
|
+
});
|
|
786
792
|
|
|
787
793
|
// src/otel/streaming/aggregators.ts
|
|
788
|
-
|
|
794
|
+
var init_aggregators = __esm({
|
|
795
|
+
"src/otel/streaming/aggregators.ts"() {
|
|
796
|
+
"use strict";
|
|
797
|
+
init_cjs_shims();
|
|
798
|
+
init_currentUnixTime();
|
|
799
|
+
}
|
|
800
|
+
});
|
|
789
801
|
|
|
790
|
-
// src/
|
|
791
|
-
|
|
802
|
+
// src/otel/middleware.ts
|
|
803
|
+
var import_api7;
|
|
804
|
+
var init_middleware = __esm({
|
|
805
|
+
"src/otel/middleware.ts"() {
|
|
806
|
+
"use strict";
|
|
807
|
+
init_cjs_shims();
|
|
808
|
+
import_api7 = require("@opentelemetry/api");
|
|
809
|
+
init_attributes();
|
|
810
|
+
init_completionUtils();
|
|
811
|
+
init_promptUtils();
|
|
812
|
+
init_contentSanitizer();
|
|
813
|
+
init_wrapperUtils();
|
|
814
|
+
init_normalized();
|
|
815
|
+
init_aggregators();
|
|
816
|
+
init_redaction();
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
// src/otel/AxiomWrappedLanguageModelV1.ts
|
|
821
|
+
var init_AxiomWrappedLanguageModelV1 = __esm({
|
|
822
|
+
"src/otel/AxiomWrappedLanguageModelV1.ts"() {
|
|
823
|
+
"use strict";
|
|
824
|
+
init_cjs_shims();
|
|
825
|
+
init_middleware();
|
|
826
|
+
}
|
|
827
|
+
});
|
|
792
828
|
|
|
793
829
|
// src/otel/AxiomWrappedLanguageModelV2.ts
|
|
794
|
-
|
|
830
|
+
var init_AxiomWrappedLanguageModelV2 = __esm({
|
|
831
|
+
"src/otel/AxiomWrappedLanguageModelV2.ts"() {
|
|
832
|
+
"use strict";
|
|
833
|
+
init_cjs_shims();
|
|
834
|
+
init_middleware();
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
|
|
838
|
+
// src/otel/vercel.ts
|
|
839
|
+
var init_vercel = __esm({
|
|
840
|
+
"src/otel/vercel.ts"() {
|
|
841
|
+
"use strict";
|
|
842
|
+
init_cjs_shims();
|
|
843
|
+
init_AxiomWrappedLanguageModelV1();
|
|
844
|
+
init_AxiomWrappedLanguageModelV2();
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
// src/otel/index.ts
|
|
849
|
+
var init_otel = __esm({
|
|
850
|
+
"src/otel/index.ts"() {
|
|
851
|
+
"use strict";
|
|
852
|
+
init_cjs_shims();
|
|
853
|
+
init_withSpan();
|
|
854
|
+
init_vercel();
|
|
855
|
+
init_attributes();
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
// src/app-scope.ts
|
|
860
|
+
var import_api8, import_zod5;
|
|
861
|
+
var init_app_scope = __esm({
|
|
862
|
+
"src/app-scope.ts"() {
|
|
863
|
+
"use strict";
|
|
864
|
+
init_cjs_shims();
|
|
865
|
+
init_global_flags();
|
|
866
|
+
init_storage();
|
|
867
|
+
init_validate_flags();
|
|
868
|
+
init_dot_path();
|
|
869
|
+
init_zod_internals();
|
|
870
|
+
import_api8 = require("@opentelemetry/api");
|
|
871
|
+
import_zod5 = require("zod");
|
|
872
|
+
init_to_otel_attribute();
|
|
873
|
+
init_otel();
|
|
874
|
+
}
|
|
875
|
+
});
|
|
795
876
|
|
|
796
877
|
// src/evals/context/storage.ts
|
|
797
|
-
var CONFIG_SCOPE_SYMBOL = Symbol.for("axiom.eval.configScope");
|
|
798
|
-
var AXIOM_CONFIG_SYMBOL = Symbol.for("axiom.eval.config");
|
|
799
878
|
function getAxiomConfig() {
|
|
800
879
|
return globalThis[AXIOM_CONFIG_SYMBOL];
|
|
801
880
|
}
|
|
802
881
|
function setAxiomConfig(config) {
|
|
803
882
|
globalThis[AXIOM_CONFIG_SYMBOL] = config;
|
|
804
883
|
}
|
|
805
|
-
var EVAL_CONTEXT = createAsyncHook("eval-context");
|
|
806
884
|
function getEvalContext() {
|
|
807
885
|
const ctx = EVAL_CONTEXT.get();
|
|
808
886
|
if (!ctx) {
|
|
@@ -842,628 +920,297 @@ function withEvalContext(options = {}, fn) {
|
|
|
842
920
|
fn
|
|
843
921
|
);
|
|
844
922
|
}
|
|
923
|
+
var import_api9, CONFIG_SCOPE_SYMBOL, AXIOM_CONFIG_SYMBOL, EVAL_CONTEXT;
|
|
924
|
+
var init_storage = __esm({
|
|
925
|
+
"src/evals/context/storage.ts"() {
|
|
926
|
+
"use strict";
|
|
927
|
+
init_cjs_shims();
|
|
928
|
+
import_api9 = require("@opentelemetry/api");
|
|
929
|
+
init_manager();
|
|
930
|
+
init_app_scope();
|
|
931
|
+
CONFIG_SCOPE_SYMBOL = Symbol.for("axiom.eval.configScope");
|
|
932
|
+
AXIOM_CONFIG_SYMBOL = Symbol.for("axiom.eval.config");
|
|
933
|
+
EVAL_CONTEXT = createAsyncHook("eval-context");
|
|
934
|
+
}
|
|
935
|
+
});
|
|
845
936
|
|
|
846
|
-
// src/
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
if (!
|
|
850
|
-
|
|
937
|
+
// src/context.ts
|
|
938
|
+
function overrideFlags(partial) {
|
|
939
|
+
const current = getEvalContext();
|
|
940
|
+
if (!current) {
|
|
941
|
+
if (process.env.NODE_ENV !== "test") {
|
|
942
|
+
console.warn("overrideFlags called outside of evaluation context");
|
|
943
|
+
}
|
|
944
|
+
return;
|
|
851
945
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
946
|
+
const overlayContext = {
|
|
947
|
+
...current,
|
|
948
|
+
flags: { ...current.flags, ...partial },
|
|
949
|
+
// Merge for backwards compatibility
|
|
950
|
+
parent: current,
|
|
951
|
+
overrides: { ...partial }
|
|
952
|
+
};
|
|
953
|
+
const currentCtx = EVAL_CONTEXT.get();
|
|
954
|
+
if (currentCtx) {
|
|
955
|
+
Object.assign(currentCtx, overlayContext);
|
|
857
956
|
}
|
|
858
|
-
const
|
|
859
|
-
|
|
860
|
-
const color = diff > 0 ? u.green : diff < 0 ? u.red : u.dim;
|
|
861
|
-
return { text: diffText, color };
|
|
862
|
-
}
|
|
863
|
-
function truncate(str, max) {
|
|
864
|
-
return str.length > max ? str.slice(0, max) + "\u2026" : str;
|
|
865
|
-
}
|
|
866
|
-
function stringify(value) {
|
|
867
|
-
try {
|
|
868
|
-
if (typeof value === "string") return value;
|
|
869
|
-
return JSON.stringify(value);
|
|
870
|
-
} catch {
|
|
871
|
-
return String(value);
|
|
957
|
+
for (const [key, value] of Object.entries(partial)) {
|
|
958
|
+
putOnSpan("flag", key, value);
|
|
872
959
|
}
|
|
873
960
|
}
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
function printEvalNameAndFileName(testSuite, meta, logger = console.log) {
|
|
880
|
-
const cwd = process.cwd();
|
|
881
|
-
logger(
|
|
882
|
-
" ",
|
|
883
|
-
u.bgCyan(u.black(` ${testSuite.project.name} `)),
|
|
884
|
-
u.bgBlue(u.black(` ${meta.evaluation.name}-${meta.evaluation.version} `)),
|
|
885
|
-
u.dim(`(${testSuite.children.size} cases)`)
|
|
886
|
-
);
|
|
887
|
-
logger(" ", u.dim(testSuite.module.moduleId.replace(cwd, "")));
|
|
888
|
-
}
|
|
889
|
-
function printBaselineNameAndVersion(testMeta, logger = console.log) {
|
|
890
|
-
if (testMeta.evaluation.baseline) {
|
|
891
|
-
logger(
|
|
892
|
-
" ",
|
|
893
|
-
" baseline ",
|
|
894
|
-
u.bgMagenta(
|
|
895
|
-
u.black(` ${testMeta.evaluation.baseline.name}-${testMeta.evaluation.baseline.version} `)
|
|
896
|
-
)
|
|
897
|
-
);
|
|
898
|
-
} else {
|
|
899
|
-
logger(" ", u.bgWhite(u.blackBright(" baseline: ")), "none");
|
|
961
|
+
var init_context = __esm({
|
|
962
|
+
"src/context.ts"() {
|
|
963
|
+
"use strict";
|
|
964
|
+
init_cjs_shims();
|
|
965
|
+
init_storage();
|
|
900
966
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
case "replaced": {
|
|
910
|
-
const valText = truncate(stringify(v.value), 80);
|
|
911
|
-
const defText = truncate(stringify(v.default), 80);
|
|
912
|
-
logger(" ", `${k}: ${valText} (default: ${defText})`);
|
|
913
|
-
break;
|
|
914
|
-
}
|
|
915
|
-
case "introduced": {
|
|
916
|
-
const valText = truncate(stringify(v.value), 80);
|
|
917
|
-
logger(" ", `${k}: ${valText} (no default)`);
|
|
918
|
-
break;
|
|
919
|
-
}
|
|
920
|
-
}
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
// src/cli/utils/eval-context-runner.ts
|
|
970
|
+
async function runEvalWithContext(overrides2, runFn) {
|
|
971
|
+
setGlobalFlagOverrides(overrides2);
|
|
972
|
+
return withEvalContext({ initialFlags: overrides2 }, async () => {
|
|
973
|
+
if (Object.keys(overrides2).length > 0) {
|
|
974
|
+
overrideFlags(overrides2);
|
|
921
975
|
}
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
function printTestCaseCountStartDuration(testSuite, startTime, duration, logger = console.log) {
|
|
925
|
-
logger(" ");
|
|
926
|
-
logger(" ", u.dim("Cases"), testSuite.children.size);
|
|
927
|
-
logger(" ", u.dim("Start at"), new Date(startTime).toTimeString());
|
|
928
|
-
logger(" ", u.dim("Duration"), `${duration}s`);
|
|
976
|
+
return runFn();
|
|
977
|
+
});
|
|
929
978
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
979
|
+
var init_eval_context_runner = __esm({
|
|
980
|
+
"src/cli/utils/eval-context-runner.ts"() {
|
|
981
|
+
"use strict";
|
|
982
|
+
init_cjs_shims();
|
|
983
|
+
init_context();
|
|
984
|
+
init_storage();
|
|
985
|
+
init_global_flags();
|
|
986
|
+
}
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
// src/cli/utils/parse-flag-overrides.ts
|
|
990
|
+
function ensureNoSpaceSeparatedSyntax(flagName, value, nextToken, flagType) {
|
|
991
|
+
if (value === void 0 && nextToken !== void 0) {
|
|
992
|
+
if (flagType === "flag" && !nextToken.startsWith("-") && nextToken !== "true" && nextToken !== "false") {
|
|
993
|
+
console.error(`\u274C Invalid syntax: --flag.${flagName} ${nextToken}`);
|
|
994
|
+
console.error(`\u{1F4A1} Use: --flag.${flagName}=${nextToken}`);
|
|
995
|
+
process.exit(1);
|
|
996
|
+
} else if (flagType === "config" && !nextToken.startsWith("-")) {
|
|
997
|
+
console.error(`\u274C Invalid syntax: --flags-config ${nextToken}`);
|
|
998
|
+
console.error(`\u{1F4A1} Use: --flags-config=${nextToken}`);
|
|
999
|
+
process.exit(1);
|
|
938
1000
|
}
|
|
939
1001
|
}
|
|
940
1002
|
}
|
|
941
|
-
function
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
if (keys.length === 0) {
|
|
945
|
-
return;
|
|
1003
|
+
function collectFlagValidationErrors(overrides2, flagSchema) {
|
|
1004
|
+
if (!flagSchema || Object.keys(overrides2).length === 0) {
|
|
1005
|
+
return { success: true, errors: [] };
|
|
946
1006
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
const
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
const coloredCurrent = hasError ? u.dim(paddedCurrent) : u.magentaBright(paddedCurrent);
|
|
955
|
-
const paddedName = k.padEnd(maxNameLength);
|
|
956
|
-
if (baselineCase?.scores[k]) {
|
|
957
|
-
const baselineScoreValue = baselineCase.scores[k].value;
|
|
958
|
-
const rawBaseline = formatPercentage(baselineScoreValue);
|
|
959
|
-
const paddedBaseline = rawBaseline.padStart(7);
|
|
960
|
-
const coloredBaseline = u.blueBright(paddedBaseline);
|
|
961
|
-
const { text: diffText, color: diffColor } = formatDiff(v, baselineScoreValue);
|
|
962
|
-
const paddedDiff = diffText.padStart(8);
|
|
963
|
-
logger(
|
|
964
|
-
` ${paddedName} ${coloredBaseline} \u2192 ${coloredCurrent} ${hasError ? u.dim("(scorer not run)") : u.dim("(") + diffColor(paddedDiff) + u.dim(")")}`
|
|
965
|
-
);
|
|
966
|
-
} else {
|
|
967
|
-
logger(` ${paddedName} ${coloredCurrent} ${hasError ? u.dim("(scorer not run)") : ""}`);
|
|
1007
|
+
assertZodV4(flagSchema, "flagSchema");
|
|
1008
|
+
const schema = flagSchema;
|
|
1009
|
+
const errors = [];
|
|
1010
|
+
for (const dotPath of Object.keys(overrides2)) {
|
|
1011
|
+
const segments = parsePath(dotPath);
|
|
1012
|
+
if (!isValidPath(schema, segments)) {
|
|
1013
|
+
errors.push({ type: "invalid_path", path: dotPath });
|
|
968
1014
|
}
|
|
969
|
-
});
|
|
970
|
-
}
|
|
971
|
-
function printOutOfScopeFlags(testMeta, logger = console.log) {
|
|
972
|
-
if (testMeta.case.outOfScopeFlags && testMeta.case.outOfScopeFlags.length > 0) {
|
|
973
|
-
const pickedFlagsText = testMeta.case.pickedFlags ? `(picked: ${testMeta.case.pickedFlags.map((f2) => `'${f2}'`).join(", ")})` : "(none)";
|
|
974
|
-
logger(" ", u.yellow(`\u26A0 Out-of-scope flags: ${pickedFlagsText}`));
|
|
975
|
-
testMeta.case.outOfScopeFlags.forEach((flag) => {
|
|
976
|
-
const timeStr = new Date(flag.accessedAt).toLocaleTimeString();
|
|
977
|
-
logger(" ", `${flag.flagPath} (at ${timeStr})`);
|
|
978
|
-
if (flag.stackTrace && flag.stackTrace.length > 0) {
|
|
979
|
-
flag.stackTrace.forEach((frame, i) => {
|
|
980
|
-
const prefix = i === flag.stackTrace.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
981
|
-
logger(" ", u.dim(`${prefix} ${frame}`));
|
|
982
|
-
});
|
|
983
|
-
}
|
|
984
|
-
});
|
|
985
1015
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
const ok = test.ok();
|
|
989
|
-
const testMeta = test.meta();
|
|
990
|
-
if (!testMeta?.case) {
|
|
991
|
-
return;
|
|
1016
|
+
if (errors.length > 0) {
|
|
1017
|
+
return { success: false, errors };
|
|
992
1018
|
}
|
|
993
|
-
|
|
994
|
-
const
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
matchedIndices.add(baselineCase.index);
|
|
1019
|
+
const nestedObject = dotNotationToNested(overrides2);
|
|
1020
|
+
const deepPartialSchema = makeDeepPartial(schema);
|
|
1021
|
+
const result = deepPartialSchema.safeParse(nestedObject);
|
|
1022
|
+
if (!result.success) {
|
|
1023
|
+
errors.push({ type: "invalid_value", zodError: result.error });
|
|
999
1024
|
}
|
|
1000
|
-
|
|
1001
|
-
printRuntimeFlags(testMeta, logger);
|
|
1002
|
-
printOutOfScopeFlags(testMeta, logger);
|
|
1025
|
+
return { success: errors.length === 0, errors };
|
|
1003
1026
|
}
|
|
1004
|
-
function
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
JSON.stringify(orphanedCase.scores),
|
|
1017
|
-
50
|
|
1018
|
-
)})`
|
|
1019
|
-
)
|
|
1020
|
-
);
|
|
1021
|
-
const keys = Object.keys(orphanedCase.scores);
|
|
1022
|
-
if (keys.length > 0) {
|
|
1023
|
-
const maxNameLength = Math.max(...keys.map((k) => k.length));
|
|
1024
|
-
keys.forEach((k) => {
|
|
1025
|
-
const scoreData = orphanedCase.scores[k];
|
|
1026
|
-
const rawScore = formatPercentage(scoreData.value);
|
|
1027
|
-
const paddedName = k.padEnd(maxNameLength);
|
|
1028
|
-
const paddedScore = rawScore.padStart(7);
|
|
1029
|
-
logger(` ${paddedName} ${u.blueBright(paddedScore)}`);
|
|
1030
|
-
});
|
|
1027
|
+
function printFlagValidationErrorsAndExit(errors) {
|
|
1028
|
+
console.error("\u274C Invalid CLI flags:");
|
|
1029
|
+
for (const error of errors) {
|
|
1030
|
+
if (error.type === "invalid_path") {
|
|
1031
|
+
console.error(` \u2022 flag '${error.path}': Invalid flag path`);
|
|
1032
|
+
} else {
|
|
1033
|
+
console.error(formatZodErrors(error.zodError));
|
|
1034
|
+
const examples = generateFlagExamples(error.zodError);
|
|
1035
|
+
if (examples.length > 0) {
|
|
1036
|
+
console.error("\n\u{1F4A1} Valid examples:");
|
|
1037
|
+
examples.forEach((example) => console.error(` ${example}`));
|
|
1038
|
+
}
|
|
1031
1039
|
}
|
|
1032
1040
|
}
|
|
1041
|
+
process.exit(1);
|
|
1033
1042
|
}
|
|
1034
|
-
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
return `${date}, ${hours}:${minutes} UTC`;
|
|
1039
|
-
};
|
|
1040
|
-
function printGlobalFlagOverrides(overrides2, defaults, logger = console.log) {
|
|
1041
|
-
if (Object.keys(overrides2).length === 0) {
|
|
1042
|
-
logger("");
|
|
1043
|
-
logger(u.dim("Flag overrides: (none)"));
|
|
1044
|
-
logger("");
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
logger("");
|
|
1048
|
-
logger("Flag overrides:");
|
|
1049
|
-
for (const [key, value] of Object.entries(overrides2)) {
|
|
1050
|
-
const defaultValue = defaults[key];
|
|
1051
|
-
const valueStr = JSON.stringify(value);
|
|
1052
|
-
const defaultStr = defaultValue !== void 0 ? JSON.stringify(defaultValue) : "none";
|
|
1053
|
-
logger(` \u2022 ${key}: ${valueStr} ${u.dim(`(default: ${defaultStr})`)}`);
|
|
1043
|
+
function validateFlagOverrides(overrides2, flagSchema) {
|
|
1044
|
+
const result = collectFlagValidationErrors(overrides2, flagSchema);
|
|
1045
|
+
if (!result.success) {
|
|
1046
|
+
printFlagValidationErrorsAndExit(result.errors);
|
|
1054
1047
|
}
|
|
1055
|
-
logger("");
|
|
1056
1048
|
}
|
|
1057
|
-
function
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
}) {
|
|
1064
|
-
const filename = suite.file.split("/").pop();
|
|
1065
|
-
logger("\u250C\u2500");
|
|
1066
|
-
logger(`\u2502 ${u.blue(suite.name)} ${u.gray(`(${filename})`)}`);
|
|
1067
|
-
logger("\u251C\u2500");
|
|
1068
|
-
const scorerNames = Object.keys(scorerAverages);
|
|
1069
|
-
const maxNameLength = Math.max(...scorerNames.map((name) => name.length));
|
|
1070
|
-
const allCasesErrored = (scorerName) => {
|
|
1071
|
-
return suite.cases.every((caseData) => caseData.scores[scorerName]?.metadata?.error);
|
|
1072
|
-
};
|
|
1073
|
-
for (const scorerName of scorerNames) {
|
|
1074
|
-
const avg = scorerAverages[scorerName];
|
|
1075
|
-
const paddedName = scorerName.padEnd(maxNameLength);
|
|
1076
|
-
const hasAllErrors = allCasesErrored(scorerName);
|
|
1077
|
-
const baselineAvg = suite.baseline ? calculateBaselineScorerAverage2(suite.baseline, scorerName) : null;
|
|
1078
|
-
if (baselineAvg !== null) {
|
|
1079
|
-
const currentPercent = hasAllErrors ? u.dim("N/A") : formatPercentage(avg);
|
|
1080
|
-
const baselinePercent = formatPercentage(baselineAvg);
|
|
1081
|
-
const { text: diffText, color: diffColor } = formatDiff(avg, baselineAvg);
|
|
1082
|
-
const paddedBaseline = baselinePercent.padStart(7);
|
|
1083
|
-
const paddedCurrent = hasAllErrors ? currentPercent : currentPercent.padStart(7);
|
|
1084
|
-
const diffDisplay = hasAllErrors ? u.dim("all cases failed") : diffColor(diffText.padStart(8));
|
|
1085
|
-
logger(
|
|
1086
|
-
`\u2502 ${paddedName} ${u.blueBright(paddedBaseline)} \u2192 ${hasAllErrors ? paddedCurrent : u.magentaBright(paddedCurrent)} (${diffDisplay})`
|
|
1087
|
-
);
|
|
1088
|
-
} else {
|
|
1089
|
-
const currentPercent = hasAllErrors ? u.red("N/A (all cases failed)") : formatPercentage(avg);
|
|
1090
|
-
logger(`\u2502 \u2022 ${paddedName} ${currentPercent}`);
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
logger("\u251C\u2500");
|
|
1094
|
-
if (suite.baseline) {
|
|
1095
|
-
const baselineTimestamp = suite.baseline.runAt ? reporterDate(new Date(suite.baseline.runAt)) : "unknown time";
|
|
1096
|
-
logger(
|
|
1097
|
-
`\u2502 Baseline: ${suite.baseline.name}-${suite.baseline.version} ${u.gray(`(${baselineTimestamp})`)}`
|
|
1098
|
-
);
|
|
1099
|
-
} else {
|
|
1100
|
-
logger(`\u2502 Baseline: ${u.gray("(none)")}`);
|
|
1049
|
+
function coerceValue(raw) {
|
|
1050
|
+
if (raw === "true") return true;
|
|
1051
|
+
if (raw === "false") return false;
|
|
1052
|
+
const num = Number(raw);
|
|
1053
|
+
if (!Number.isNaN(num) && raw.trim() === num.toString()) {
|
|
1054
|
+
return num;
|
|
1101
1055
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
logger(`\u2502 \u2022 ${flag}: ${current ?? "<not set>"}`);
|
|
1107
|
-
if (defaultVal !== void 0) {
|
|
1108
|
-
logger(`\u2502 ${u.gray(`default: ${defaultVal}`)}`);
|
|
1109
|
-
}
|
|
1110
|
-
if (suite.baseline) {
|
|
1111
|
-
logger(`\u2502 ${u.gray(`baseline: ${baseline ?? "<not set>"}`)}`);
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1056
|
+
try {
|
|
1057
|
+
return JSON.parse(raw);
|
|
1058
|
+
} catch {
|
|
1059
|
+
return raw;
|
|
1114
1060
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
`\u2502 \u2022 ${flag.flagPath} ${u.gray(`at ${lastStackTraceFnName} (${lastStackTraceFile})`)}`
|
|
1061
|
+
}
|
|
1062
|
+
function loadConfigFile(path3) {
|
|
1063
|
+
const abs = (0, import_node_path.resolve)(process.cwd(), path3);
|
|
1064
|
+
try {
|
|
1065
|
+
const contents = (0, import_node_fs.readFileSync)(abs, "utf8");
|
|
1066
|
+
const parsed = JSON.parse(contents);
|
|
1067
|
+
if (typeof parsed !== "object" || Array.isArray(parsed) || parsed === null) {
|
|
1068
|
+
console.error(
|
|
1069
|
+
`\u274C Flags config must be a JSON object, got ${Array.isArray(parsed) ? "array" : typeof parsed}`
|
|
1125
1070
|
);
|
|
1071
|
+
process.exit(1);
|
|
1126
1072
|
}
|
|
1073
|
+
return parsed;
|
|
1074
|
+
} catch (err) {
|
|
1075
|
+
console.error(`\u274C Could not read or parse flags config "${path3}": ${err.message}`);
|
|
1076
|
+
process.exit(1);
|
|
1127
1077
|
}
|
|
1128
|
-
logger("\u2514\u2500");
|
|
1129
1078
|
}
|
|
1130
|
-
function
|
|
1131
|
-
const
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1079
|
+
function extractOverrides(argv) {
|
|
1080
|
+
const cleanedArgv2 = [];
|
|
1081
|
+
const overrides2 = {};
|
|
1082
|
+
let configPath = null;
|
|
1083
|
+
let hasCliFlags = false;
|
|
1084
|
+
let configPathCount = 0;
|
|
1085
|
+
for (let i = 0; i < argv.length; i++) {
|
|
1086
|
+
const token = argv[i];
|
|
1087
|
+
const configMatch = token.match(CONFIG_RE);
|
|
1088
|
+
const flagMatch = token.match(FLAG_RE);
|
|
1089
|
+
if (configMatch) {
|
|
1090
|
+
configPathCount++;
|
|
1091
|
+
if (configPathCount > 1) {
|
|
1092
|
+
console.error("\u274C Only one --flags-config can be supplied.");
|
|
1093
|
+
process.exit(1);
|
|
1136
1094
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1095
|
+
const value = configMatch[1];
|
|
1096
|
+
const nextToken = argv.length > i + 1 ? argv[i + 1] : void 0;
|
|
1097
|
+
ensureNoSpaceSeparatedSyntax("flags-config", value, nextToken, "config");
|
|
1098
|
+
if (!value) {
|
|
1099
|
+
console.error("\u274C --flags-config requires a file path");
|
|
1100
|
+
console.error("\u{1F4A1} Use: --flags-config=path/to/config.json");
|
|
1101
|
+
process.exit(1);
|
|
1140
1102
|
}
|
|
1103
|
+
configPath = value;
|
|
1104
|
+
} else if (flagMatch) {
|
|
1105
|
+
hasCliFlags = true;
|
|
1106
|
+
const key = flagMatch[1];
|
|
1107
|
+
const value = flagMatch[2];
|
|
1108
|
+
const nextToken = argv.length > i + 1 ? argv[i + 1] : void 0;
|
|
1109
|
+
ensureNoSpaceSeparatedSyntax(key, value, nextToken, "flag");
|
|
1110
|
+
const finalValue = value === void 0 ? "true" : value;
|
|
1111
|
+
overrides2[key] = coerceValue(finalValue);
|
|
1112
|
+
} else {
|
|
1113
|
+
cleanedArgv2.push(token);
|
|
1141
1114
|
}
|
|
1142
1115
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1116
|
+
if (configPath && hasCliFlags) {
|
|
1117
|
+
console.error("\u274C Cannot use both --flags-config and --flag.* arguments together.");
|
|
1118
|
+
console.error("Choose one approach:");
|
|
1119
|
+
console.error(" \u2022 Config file: --flags-config=my-flags.json");
|
|
1120
|
+
console.error(" \u2022 CLI flags: --flag.temperature=0.9 --flag.model=gpt-4o");
|
|
1121
|
+
process.exit(1);
|
|
1146
1122
|
}
|
|
1147
|
-
|
|
1123
|
+
if (configPath) {
|
|
1124
|
+
const configOverrides = loadConfigFile(configPath);
|
|
1125
|
+
return { cleanedArgv: cleanedArgv2, overrides: configOverrides };
|
|
1126
|
+
}
|
|
1127
|
+
return { cleanedArgv: cleanedArgv2, overrides: overrides2 };
|
|
1148
1128
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1129
|
+
var import_zod6, import_node_fs, import_node_path, FLAG_RE, CONFIG_RE;
|
|
1130
|
+
var init_parse_flag_overrides = __esm({
|
|
1131
|
+
"src/cli/utils/parse-flag-overrides.ts"() {
|
|
1132
|
+
"use strict";
|
|
1133
|
+
init_cjs_shims();
|
|
1134
|
+
import_zod6 = require("zod");
|
|
1135
|
+
init_format_zod_errors();
|
|
1136
|
+
import_node_fs = require("fs");
|
|
1137
|
+
import_node_path = require("path");
|
|
1138
|
+
init_dot_path();
|
|
1139
|
+
init_deep_partial_schema();
|
|
1140
|
+
init_zod_internals();
|
|
1141
|
+
FLAG_RE = /^--flag\.([^=]+)(?:=(.*))?$/;
|
|
1142
|
+
CONFIG_RE = /^--flags-config(?:=(.*))?$/;
|
|
1155
1143
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
// src/cli/utils/glob-utils.ts
|
|
1147
|
+
function isGlob(str) {
|
|
1148
|
+
return /[*?[\]{}!]/.test(str);
|
|
1159
1149
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1150
|
+
var init_glob_utils = __esm({
|
|
1151
|
+
"src/cli/utils/glob-utils.ts"() {
|
|
1152
|
+
"use strict";
|
|
1153
|
+
init_cjs_shims();
|
|
1163
1154
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
const
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
...Object.keys(baselineFlat),
|
|
1174
|
-
...Object.keys(defaultFlat)
|
|
1175
|
-
]);
|
|
1176
|
-
for (const key of allKeys) {
|
|
1177
|
-
const isInScope = suite.configFlags.some((pattern) => key.startsWith(pattern));
|
|
1178
|
-
if (!isInScope) continue;
|
|
1179
|
-
const currentValue = currentFlat[key];
|
|
1180
|
-
const baselineValue = baselineFlat[key];
|
|
1181
|
-
const defaultValue = defaultFlat[key];
|
|
1182
|
-
const currentStr = currentValue !== void 0 ? JSON.stringify(currentValue) : void 0;
|
|
1183
|
-
const baselineStr = baselineValue !== void 0 ? JSON.stringify(baselineValue) : void 0;
|
|
1184
|
-
const defaultStr = defaultValue !== void 0 ? JSON.stringify(defaultValue) : void 0;
|
|
1185
|
-
const diffFromBaseline = suite.baseline && currentStr !== baselineStr;
|
|
1186
|
-
const diffFromDefault = currentStr !== defaultStr;
|
|
1187
|
-
if (diffFromBaseline || diffFromDefault) {
|
|
1188
|
-
diffs.push({
|
|
1189
|
-
flag: key,
|
|
1190
|
-
current: currentStr,
|
|
1191
|
-
baseline: suite.baseline ? baselineStr : void 0,
|
|
1192
|
-
default: defaultStr
|
|
1193
|
-
});
|
|
1155
|
+
});
|
|
1156
|
+
|
|
1157
|
+
// src/util/errors.ts
|
|
1158
|
+
function getCircularReplacer() {
|
|
1159
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
1160
|
+
return (_k, v) => {
|
|
1161
|
+
if (typeof v === "object" && v !== null) {
|
|
1162
|
+
if (seen.has(v)) return "[Circular]";
|
|
1163
|
+
seen.add(v);
|
|
1194
1164
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1165
|
+
return v;
|
|
1166
|
+
};
|
|
1197
1167
|
}
|
|
1198
|
-
function
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
logger = console.log
|
|
1204
|
-
}) {
|
|
1205
|
-
logger("");
|
|
1206
|
-
logger(u.bgBlue(u.white(" FINAL EVALUATION REPORT ")));
|
|
1207
|
-
logger("");
|
|
1208
|
-
for (const suite of suiteData) {
|
|
1209
|
-
const scorerAverages = calculateScorerAverages(suite);
|
|
1210
|
-
const flagDiff = calculateFlagDiff(suite);
|
|
1211
|
-
printSuiteBox({ suite, scorerAverages, calculateBaselineScorerAverage, flagDiff, logger });
|
|
1212
|
-
logger("");
|
|
1168
|
+
function safeJson(x) {
|
|
1169
|
+
try {
|
|
1170
|
+
return JSON.stringify(x, getCircularReplacer());
|
|
1171
|
+
} catch {
|
|
1172
|
+
return String(x);
|
|
1213
1173
|
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
const suite = suiteData[0];
|
|
1221
|
-
const baselineParam = suite.baseline?.traceId ? `?baselineId=${suite.baseline.traceId}` : "";
|
|
1222
|
-
logger("View eval result:");
|
|
1223
|
-
logger(
|
|
1224
|
-
`${config.consoleEndpointUrl}/${orgId}/ai-engineering/evaluations/${suite.name}/${suite.version}${baselineParam}`
|
|
1225
|
-
);
|
|
1226
|
-
} else {
|
|
1227
|
-
logger("View full report:");
|
|
1228
|
-
logger(`${config.consoleEndpointUrl}/${orgId}/ai-engineering/evaluations?runId=${runId}`);
|
|
1174
|
+
}
|
|
1175
|
+
function errorToString(err) {
|
|
1176
|
+
try {
|
|
1177
|
+
if (typeof err === "string") return err;
|
|
1178
|
+
if (err instanceof Error) {
|
|
1179
|
+
return err.stack ?? err.message;
|
|
1229
1180
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1181
|
+
if (typeof err === "object" && err !== null) {
|
|
1182
|
+
const msg = err.message;
|
|
1183
|
+
const json = safeJson(err);
|
|
1184
|
+
return msg ? `${msg} (${json})` : json;
|
|
1185
|
+
}
|
|
1186
|
+
return String(err);
|
|
1187
|
+
} catch {
|
|
1188
|
+
return "[unserializable error]";
|
|
1234
1189
|
}
|
|
1235
|
-
if (anyFailed) {
|
|
1236
|
-
logger("");
|
|
1237
|
-
for (const status of registrationStatus) {
|
|
1238
|
-
if (!status.registered) {
|
|
1239
|
-
logger(u.yellow(`\u26A0\uFE0F Warning: Failed to register "${status.name}" with Axiom`));
|
|
1240
|
-
if (status.error) {
|
|
1241
|
-
logger(u.dim(` Error: ${status.error}`));
|
|
1242
|
-
}
|
|
1243
|
-
logger(u.dim(` Results for this evaluation will not be available in the Axiom UI.`));
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
// src/config/resolver.ts
|
|
1250
|
-
init_cjs_shims();
|
|
1251
|
-
var buildConsoleUrl = (urlString) => {
|
|
1252
|
-
const url = new URL(urlString);
|
|
1253
|
-
return `${url.protocol}//app.${url.host.split("api.").at(-1)}`;
|
|
1254
|
-
};
|
|
1255
|
-
function resolveAxiomConnection(config, consoleUrlOverride) {
|
|
1256
|
-
const consoleEndpointUrl = consoleUrlOverride ?? buildConsoleUrl(config.eval.url);
|
|
1257
|
-
return {
|
|
1258
|
-
url: config.eval.url,
|
|
1259
|
-
consoleEndpointUrl,
|
|
1260
|
-
token: config.eval.token,
|
|
1261
|
-
dataset: config.eval.dataset,
|
|
1262
|
-
orgId: config.eval.orgId
|
|
1263
|
-
};
|
|
1264
1190
|
}
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
__publicField(this, "_config");
|
|
1275
|
-
}
|
|
1276
|
-
onTestRunStart() {
|
|
1277
|
-
this.start = performance.now();
|
|
1278
|
-
this.startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1279
|
-
const config = getAxiomConfig();
|
|
1280
|
-
if (config) {
|
|
1281
|
-
this._config = resolveAxiomConnection(config, getConsoleUrl());
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
async onTestSuiteReady(_testSuite) {
|
|
1285
|
-
const meta = _testSuite.meta();
|
|
1286
|
-
if (_testSuite.state() === "skipped" || !meta?.evaluation) {
|
|
1287
|
-
return;
|
|
1288
|
-
}
|
|
1289
|
-
if (!this._printedFlagOverrides) {
|
|
1290
|
-
const defaultsFromConfigEnd = meta.evaluation.configEnd?.flags ?? {};
|
|
1291
|
-
const overridesFromConfigEnd = meta.evaluation.configEnd?.overrides ?? {};
|
|
1292
|
-
if (Object.keys(overridesFromConfigEnd).length > 0) {
|
|
1293
|
-
printGlobalFlagOverrides(overridesFromConfigEnd, defaultsFromConfigEnd);
|
|
1294
|
-
}
|
|
1295
|
-
this._printedFlagOverrides = true;
|
|
1296
|
-
}
|
|
1297
|
-
if (meta.evaluation.configEnd && !this._endOfRunConfigEnd) {
|
|
1298
|
-
this._endOfRunConfigEnd = meta.evaluation.configEnd;
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
onTestCaseReady(test) {
|
|
1302
|
-
const meta = test.meta();
|
|
1303
|
-
if (!meta.case) return;
|
|
1304
|
-
}
|
|
1305
|
-
async onTestSuiteResult(testSuite) {
|
|
1306
|
-
const meta = testSuite.meta();
|
|
1307
|
-
if (testSuite.state() === "skipped" || !meta?.evaluation) {
|
|
1308
|
-
return;
|
|
1309
|
-
}
|
|
1310
|
-
if (meta.evaluation.configEnd && !this._endOfRunConfigEnd) {
|
|
1311
|
-
this._endOfRunConfigEnd = meta.evaluation.configEnd;
|
|
1312
|
-
}
|
|
1313
|
-
const durationSeconds = Number((performance.now() - this.start) / 1e3).toFixed(2);
|
|
1314
|
-
const cases = [];
|
|
1315
|
-
for (const test of testSuite.children) {
|
|
1316
|
-
if (test.type !== "test") continue;
|
|
1317
|
-
const testMeta = test.meta();
|
|
1318
|
-
if (!testMeta?.case) continue;
|
|
1319
|
-
cases.push({
|
|
1320
|
-
index: testMeta.case.index,
|
|
1321
|
-
scores: testMeta.case.scores,
|
|
1322
|
-
outOfScopeFlags: testMeta.case.outOfScopeFlags,
|
|
1323
|
-
errors: testMeta.case.errors,
|
|
1324
|
-
runtimeFlags: testMeta.case.runtimeFlags
|
|
1325
|
-
});
|
|
1326
|
-
}
|
|
1327
|
-
const cwd = process.cwd();
|
|
1328
|
-
const relativePath = testSuite.module.moduleId.replace(cwd, "").replace(/^\//, "");
|
|
1329
|
-
let suiteBaseline = meta.evaluation.baseline;
|
|
1330
|
-
let flagConfig = meta.evaluation.flagConfig;
|
|
1331
|
-
if (meta.evaluation.configEnd) {
|
|
1332
|
-
const defaults = meta.evaluation.configEnd.flags ?? {};
|
|
1333
|
-
const overrides2 = meta.evaluation.configEnd.overrides ?? {};
|
|
1334
|
-
const defaultsFlat = flattenObject(defaults);
|
|
1335
|
-
const overridesFlat = flattenObject(overrides2);
|
|
1336
|
-
flagConfig = dotNotationToNested({ ...defaultsFlat, ...overridesFlat });
|
|
1337
|
-
}
|
|
1338
|
-
const defaultFlagConfig = meta.evaluation.configEnd?.flags;
|
|
1339
|
-
this._suiteData.push({
|
|
1340
|
-
version: meta.evaluation.version,
|
|
1341
|
-
name: meta.evaluation.name,
|
|
1342
|
-
file: relativePath,
|
|
1343
|
-
duration: durationSeconds + "s",
|
|
1344
|
-
baseline: suiteBaseline || null,
|
|
1345
|
-
configFlags: meta.evaluation.configFlags,
|
|
1346
|
-
flagConfig,
|
|
1347
|
-
defaultFlagConfig,
|
|
1348
|
-
runId: meta.evaluation.runId,
|
|
1349
|
-
orgId: meta.evaluation.orgId,
|
|
1350
|
-
cases,
|
|
1351
|
-
outOfScopeFlags: meta.evaluation.outOfScopeFlags,
|
|
1352
|
-
registrationStatus: meta.evaluation.registrationStatus
|
|
1353
|
-
});
|
|
1354
|
-
printEvalNameAndFileName(testSuite, meta);
|
|
1355
|
-
printBaselineNameAndVersion(meta);
|
|
1356
|
-
printTestCaseCountStartDuration(testSuite, this.startTime, durationSeconds);
|
|
1357
|
-
const matchedBaselineIndices = /* @__PURE__ */ new Set();
|
|
1358
|
-
const baselineCasesByFingerprint = /* @__PURE__ */ new Map();
|
|
1359
|
-
if (suiteBaseline) {
|
|
1360
|
-
for (const c of suiteBaseline.cases) {
|
|
1361
|
-
const fp = getCaseFingerprint(c.input, c.expected);
|
|
1362
|
-
const cases2 = baselineCasesByFingerprint.get(fp) || [];
|
|
1363
|
-
cases2.push(c);
|
|
1364
|
-
baselineCasesByFingerprint.set(fp, cases2);
|
|
1191
|
+
var AxiomCLIError;
|
|
1192
|
+
var init_errors = __esm({
|
|
1193
|
+
"src/util/errors.ts"() {
|
|
1194
|
+
"use strict";
|
|
1195
|
+
init_cjs_shims();
|
|
1196
|
+
AxiomCLIError = class extends Error {
|
|
1197
|
+
constructor(message) {
|
|
1198
|
+
super(message);
|
|
1199
|
+
this.name = "AxiomCLIError";
|
|
1365
1200
|
}
|
|
1366
|
-
}
|
|
1367
|
-
for (const test of testSuite.children) {
|
|
1368
|
-
if (test.type !== "test") continue;
|
|
1369
|
-
printCaseResult(test, baselineCasesByFingerprint, matchedBaselineIndices);
|
|
1370
|
-
}
|
|
1371
|
-
if (suiteBaseline) {
|
|
1372
|
-
printOrphanedBaselineCases(suiteBaseline, matchedBaselineIndices);
|
|
1373
|
-
}
|
|
1374
|
-
console.log("");
|
|
1375
|
-
}
|
|
1376
|
-
async onTestRunEnd(_testModules, _errors, _reason) {
|
|
1377
|
-
const shouldClear = !process.env.CI && process.stdout.isTTY !== false;
|
|
1378
|
-
if (shouldClear) {
|
|
1379
|
-
process.stdout.write("\x1B[2J\x1B[0f");
|
|
1380
|
-
}
|
|
1381
|
-
const registrationStatus = this._suiteData.map((suite) => ({
|
|
1382
|
-
name: suite.name,
|
|
1383
|
-
registered: suite.registrationStatus?.status === "success",
|
|
1384
|
-
error: suite.registrationStatus?.status === "failed" ? suite.registrationStatus.error : void 0
|
|
1385
|
-
}));
|
|
1386
|
-
const isDebug = process.env.AXIOM_DEBUG === "true";
|
|
1387
|
-
printFinalReport({
|
|
1388
|
-
suiteData: this._suiteData,
|
|
1389
|
-
config: this._config,
|
|
1390
|
-
registrationStatus,
|
|
1391
|
-
isDebug
|
|
1392
|
-
});
|
|
1393
|
-
}
|
|
1394
|
-
};
|
|
1395
|
-
|
|
1396
|
-
// src/evals/instrument.ts
|
|
1397
|
-
init_cjs_shims();
|
|
1398
|
-
var import_sdk_trace_node = require("@opentelemetry/sdk-trace-node");
|
|
1399
|
-
var import_resources = require("@opentelemetry/resources");
|
|
1400
|
-
var import_exporter_trace_otlp_http = require("@opentelemetry/exporter-trace-otlp-http");
|
|
1401
|
-
var import_api10 = require("@opentelemetry/api");
|
|
1402
|
-
|
|
1403
|
-
// src/util/errors.ts
|
|
1404
|
-
init_cjs_shims();
|
|
1405
|
-
var AxiomCLIError = class extends Error {
|
|
1406
|
-
constructor(message) {
|
|
1407
|
-
super(message);
|
|
1408
|
-
this.name = "AxiomCLIError";
|
|
1409
|
-
}
|
|
1410
|
-
};
|
|
1411
|
-
function getCircularReplacer() {
|
|
1412
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
1413
|
-
return (_k, v) => {
|
|
1414
|
-
if (typeof v === "object" && v !== null) {
|
|
1415
|
-
if (seen.has(v)) return "[Circular]";
|
|
1416
|
-
seen.add(v);
|
|
1417
|
-
}
|
|
1418
|
-
return v;
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
function safeJson(x) {
|
|
1422
|
-
try {
|
|
1423
|
-
return JSON.stringify(x, getCircularReplacer());
|
|
1424
|
-
} catch {
|
|
1425
|
-
return String(x);
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
function errorToString(err) {
|
|
1429
|
-
try {
|
|
1430
|
-
if (typeof err === "string") return err;
|
|
1431
|
-
if (err instanceof Error) {
|
|
1432
|
-
return err.stack ?? err.message;
|
|
1433
|
-
}
|
|
1434
|
-
if (typeof err === "object" && err !== null) {
|
|
1435
|
-
const msg = err.message;
|
|
1436
|
-
const json = safeJson(err);
|
|
1437
|
-
return msg ? `${msg} (${json})` : json;
|
|
1438
|
-
}
|
|
1439
|
-
return String(err);
|
|
1440
|
-
} catch {
|
|
1441
|
-
return "[unserializable error]";
|
|
1201
|
+
};
|
|
1442
1202
|
}
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
// src/config/loader.ts
|
|
1446
|
-
init_cjs_shims();
|
|
1447
|
-
var import_c12 = require("c12");
|
|
1448
|
-
var import_defu = require("defu");
|
|
1449
|
-
|
|
1450
|
-
// src/config/index.ts
|
|
1451
|
-
init_cjs_shims();
|
|
1452
|
-
var import_zod6 = require("zod");
|
|
1453
|
-
|
|
1454
|
-
// src/cli/auth/index.ts
|
|
1455
|
-
init_cjs_shims();
|
|
1203
|
+
});
|
|
1456
1204
|
|
|
1457
1205
|
// src/cli/auth/types.ts
|
|
1458
|
-
|
|
1206
|
+
var init_types = __esm({
|
|
1207
|
+
"src/cli/auth/types.ts"() {
|
|
1208
|
+
"use strict";
|
|
1209
|
+
init_cjs_shims();
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1459
1212
|
|
|
1460
1213
|
// src/cli/auth/config.ts
|
|
1461
|
-
init_cjs_shims();
|
|
1462
|
-
var import_fs = require("fs");
|
|
1463
|
-
var import_path = __toESM(require("path"), 1);
|
|
1464
|
-
var import_os = __toESM(require("os"), 1);
|
|
1465
|
-
var CONFIG_FILENAME = "config.json";
|
|
1466
|
-
var CONFIG_DIR_NAME = "axiom";
|
|
1467
1214
|
function getConfigDir() {
|
|
1468
1215
|
const platform = process.platform;
|
|
1469
1216
|
const homeDir = import_os.default.homedir();
|
|
@@ -1510,64 +1257,81 @@ function getActiveProfile(config) {
|
|
|
1510
1257
|
if (!profile) return null;
|
|
1511
1258
|
return profile;
|
|
1512
1259
|
}
|
|
1260
|
+
var import_fs, import_path, import_os, CONFIG_FILENAME, CONFIG_DIR_NAME;
|
|
1261
|
+
var init_config = __esm({
|
|
1262
|
+
"src/cli/auth/config.ts"() {
|
|
1263
|
+
"use strict";
|
|
1264
|
+
init_cjs_shims();
|
|
1265
|
+
import_fs = require("fs");
|
|
1266
|
+
import_path = __toESM(require("path"), 1);
|
|
1267
|
+
import_os = __toESM(require("os"), 1);
|
|
1268
|
+
CONFIG_FILENAME = "config.json";
|
|
1269
|
+
CONFIG_DIR_NAME = "axiom";
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1513
1272
|
|
|
1514
1273
|
// src/cli/auth/oauth.ts
|
|
1515
|
-
|
|
1516
|
-
var
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1274
|
+
var import_crypto, OAUTH_CLIENT_ID, OAUTH_AUTH_PATH, OAUTH_TOKEN_PATH, OAuth;
|
|
1275
|
+
var init_oauth = __esm({
|
|
1276
|
+
"src/cli/auth/oauth.ts"() {
|
|
1277
|
+
"use strict";
|
|
1278
|
+
init_cjs_shims();
|
|
1279
|
+
import_crypto = require("crypto");
|
|
1280
|
+
OAUTH_CLIENT_ID = "264d906a404efc209b027f6595e6b616";
|
|
1281
|
+
OAUTH_AUTH_PATH = "/oauth/authorize";
|
|
1282
|
+
OAUTH_TOKEN_PATH = "/oauth/token";
|
|
1283
|
+
OAuth = class {
|
|
1284
|
+
constructor(oauthBaseUrl) {
|
|
1285
|
+
this.oauthBaseUrl = oauthBaseUrl;
|
|
1286
|
+
}
|
|
1287
|
+
static generateCodeVerifier() {
|
|
1288
|
+
return (0, import_crypto.randomBytes)(32).toString("base64url");
|
|
1289
|
+
}
|
|
1290
|
+
static generateCodeChallenge(verifier) {
|
|
1291
|
+
return (0, import_crypto.createHash)("sha256").update(verifier).digest("base64url");
|
|
1292
|
+
}
|
|
1293
|
+
static generateState() {
|
|
1294
|
+
return (0, import_crypto.randomBytes)(16).toString("hex");
|
|
1295
|
+
}
|
|
1296
|
+
buildAuthUrl(params) {
|
|
1297
|
+
const url = new URL(OAUTH_AUTH_PATH, this.oauthBaseUrl);
|
|
1298
|
+
url.searchParams.set("client_id", OAUTH_CLIENT_ID);
|
|
1299
|
+
url.searchParams.set("redirect_uri", params.redirectUri);
|
|
1300
|
+
url.searchParams.set("response_type", "code");
|
|
1301
|
+
url.searchParams.set("state", params.state);
|
|
1302
|
+
url.searchParams.set("code_challenge", params.codeChallenge);
|
|
1303
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
1304
|
+
url.searchParams.set("scope", "*");
|
|
1305
|
+
return url.toString();
|
|
1306
|
+
}
|
|
1307
|
+
async exchangeCodeForToken(params) {
|
|
1308
|
+
const tokenUrl = new URL(OAUTH_TOKEN_PATH, this.oauthBaseUrl);
|
|
1309
|
+
const body = new URLSearchParams({
|
|
1310
|
+
grant_type: "authorization_code",
|
|
1311
|
+
client_id: OAUTH_CLIENT_ID,
|
|
1312
|
+
code: params.code,
|
|
1313
|
+
redirect_uri: params.redirectUri,
|
|
1314
|
+
code_verifier: params.codeVerifier
|
|
1315
|
+
});
|
|
1316
|
+
const response = await fetch(tokenUrl.toString(), {
|
|
1317
|
+
method: "POST",
|
|
1318
|
+
headers: {
|
|
1319
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1320
|
+
},
|
|
1321
|
+
body: body.toString()
|
|
1322
|
+
});
|
|
1323
|
+
if (!response.ok) {
|
|
1324
|
+
const errorText = await response.text();
|
|
1325
|
+
throw new Error(`Token exchange failed: ${response.status} ${errorText}`);
|
|
1326
|
+
}
|
|
1327
|
+
const data = await response.json();
|
|
1328
|
+
return data.access_token;
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1566
1331
|
}
|
|
1567
|
-
};
|
|
1332
|
+
});
|
|
1568
1333
|
|
|
1569
1334
|
// src/cli/auth/api.ts
|
|
1570
|
-
init_cjs_shims();
|
|
1571
1335
|
async function fetchOrganizations(token, apiBaseUrl) {
|
|
1572
1336
|
const response = await fetch(`${apiBaseUrl}/v2/orgs`, {
|
|
1573
1337
|
headers: {
|
|
@@ -1593,10 +1357,15 @@ async function verifyToken(token, orgId, apiBaseUrl) {
|
|
|
1593
1357
|
});
|
|
1594
1358
|
return response.ok;
|
|
1595
1359
|
}
|
|
1360
|
+
var init_api = __esm({
|
|
1361
|
+
"src/cli/auth/api.ts"() {
|
|
1362
|
+
"use strict";
|
|
1363
|
+
init_cjs_shims();
|
|
1364
|
+
init_errors();
|
|
1365
|
+
}
|
|
1366
|
+
});
|
|
1596
1367
|
|
|
1597
1368
|
// src/cli/auth/callback-server.ts
|
|
1598
|
-
init_cjs_shims();
|
|
1599
|
-
var import_http = __toESM(require("http"), 1);
|
|
1600
1369
|
function escapeHtml(text) {
|
|
1601
1370
|
const map = {
|
|
1602
1371
|
"&": "&",
|
|
@@ -1608,9 +1377,6 @@ function escapeHtml(text) {
|
|
|
1608
1377
|
};
|
|
1609
1378
|
return text.replace(/[&<>"']/g, (m2) => map[m2] || m2);
|
|
1610
1379
|
}
|
|
1611
|
-
var SVG_LOGO = `<svg width="124" height="24" viewBox="0 0 124 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="logo">
|
|
1612
|
-
<path d="M42.9919 16.8116H36.3696L35.5537 19.1572C35.4209 19.539 34.9714 19.8513 34.5548 19.8513H30.9779C30.5614 19.8513 30.3459 19.5449 30.499 19.1703L36.9816 3.31644C37.1346 2.9419 37.6009 2.63546 38.0174 2.63546H41.3718C41.7883 2.63546 42.2541 2.94207 42.4067 3.3168L48.8634 19.17C49.016 19.5447 48.8 19.8513 48.3835 19.8513H44.8067C44.3901 19.8513 43.9406 19.539 43.8078 19.1572L42.9919 16.8116ZM41.8232 13.4223L39.6807 7.18148L37.5383 13.4223H41.8232ZM64.1105 19.8513C63.694 19.8513 63.1767 19.5694 62.9611 19.2247L59.9029 14.3369L56.8447 19.2247C56.6291 19.5694 56.1119 19.8513 55.6953 19.8513H51.3392C50.9227 19.8513 50.7754 19.5801 51.0119 19.2486L56.8978 11.0013L51.5315 3.24414C51.2999 2.90937 51.4513 2.63546 51.8679 2.63546H55.89C56.3066 2.63546 56.8268 2.91563 57.0461 3.25807L59.9029 7.71959L62.7343 3.25955C62.9522 2.9163 63.4713 2.63546 63.8879 2.63546H67.938C68.3545 2.63546 68.5048 2.90868 68.272 3.24261L62.8801 10.9743L68.7935 19.2489C69.0303 19.5802 68.8832 19.8513 68.4666 19.8513H64.1105ZM76.525 19.119C76.525 19.5218 76.1841 19.8513 75.7675 19.8513H72.5522C72.1356 19.8513 71.7947 19.5218 71.7947 19.119V3.36771C71.7947 2.96498 72.1356 2.63546 72.5522 2.63546H75.7675C76.1841 2.63546 76.525 2.96498 76.525 3.36771V19.119ZM79.3736 11.1896C79.3736 6.18625 83.2688 2.15134 89.2511 2.15134C95.2334 2.15134 99.1289 6.18625 99.1289 11.1896C99.1289 16.2199 95.2334 20.2548 89.2511 20.2548C83.2688 20.2548 79.3736 16.2199 79.3736 11.1896ZM94.2873 11.1896C94.2873 8.58038 92.3953 6.21307 89.2511 6.21307C86.1349 6.21307 84.2149 8.58038 84.2149 11.1896C84.2149 13.7989 86.1349 16.2199 89.2511 16.2199C92.3675 16.2199 94.2873 13.7989 94.2873 11.1896ZM119.318 19.8513C118.902 19.8513 118.517 19.5245 118.463 19.1251L117.225 9.89847L113.65 19.1652C113.505 19.5426 113.045 19.8513 112.628 19.8513H111.055C110.638 19.8513 110.179 19.5423 110.034 19.1645L106.457 9.81766L105.218 19.125C105.165 19.5245 104.781 19.8513 104.364 19.8513H101.344C100.927 19.8513 100.633 19.5249 100.69 19.1259L102.932 3.3609C102.988 2.96191 103.376 2.63546 103.792 2.63546H106.59C107.007 2.63546 107.469 2.94351 107.617 3.32002L111.827 14.041L116.064 3.31949C116.213 2.94327 116.676 2.63546 117.092 2.63546H119.89C120.307 2.63546 120.694 2.96191 120.751 3.3609L122.993 19.1259C123.05 19.5249 122.755 19.8513 122.339 19.8513H119.318ZM23.9616 15.6531L18.8054 6.97021C18.5689 6.57115 17.9863 6.24465 17.5106 6.24465H14.2915C13.5433 6.24465 13.2365 5.73171 13.6097 5.1048L15.375 2.13986C15.5151 1.90455 15.5148 1.61487 15.3743 1.37981C15.2337 1.14476 14.9741 1 14.6933 1H10.2025C9.72681 1 9.14291 1.32577 8.90491 1.72395L0.17865 16.3217C-0.0594434 16.7199 -0.0595348 17.3715 0.178285 17.7698L2.42362 21.5297C2.79777 22.1561 3.41129 22.1569 3.78699 21.5313L5.54143 18.6103C5.91722 17.9847 6.53065 17.9854 6.9048 18.6119L8.49538 21.2754C8.7332 21.6737 9.317 21.9995 9.79273 21.9995H20.1698C20.6455 21.9995 21.2293 21.6737 21.4672 21.2754L23.959 17.1028C24.1968 16.7045 24.198 16.0521 23.9616 15.6531ZM16.9981 15.2352C17.3699 15.8629 17.0619 16.3765 16.3136 16.3765H8.24192C7.49372 16.3765 7.1876 15.864 7.56175 15.2375L11.6007 8.47417C11.9748 7.84772 12.5869 7.84774 12.9611 8.47421L16.9981 15.2352Z" fill="#121224"/>
|
|
1613
|
-
</svg>`;
|
|
1614
1380
|
function renderCallbackPage(error) {
|
|
1615
1381
|
const errorClass = error ? ' class="error"' : "";
|
|
1616
1382
|
const errorMessage = error ? escapeHtml(error) : "";
|
|
@@ -1757,10 +1523,19 @@ async function waitForCallback(server, expectedState) {
|
|
|
1757
1523
|
});
|
|
1758
1524
|
});
|
|
1759
1525
|
}
|
|
1526
|
+
var import_http, SVG_LOGO;
|
|
1527
|
+
var init_callback_server = __esm({
|
|
1528
|
+
"src/cli/auth/callback-server.ts"() {
|
|
1529
|
+
"use strict";
|
|
1530
|
+
init_cjs_shims();
|
|
1531
|
+
import_http = __toESM(require("http"), 1);
|
|
1532
|
+
SVG_LOGO = `<svg width="124" height="24" viewBox="0 0 124 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="logo">
|
|
1533
|
+
<path d="M42.9919 16.8116H36.3696L35.5537 19.1572C35.4209 19.539 34.9714 19.8513 34.5548 19.8513H30.9779C30.5614 19.8513 30.3459 19.5449 30.499 19.1703L36.9816 3.31644C37.1346 2.9419 37.6009 2.63546 38.0174 2.63546H41.3718C41.7883 2.63546 42.2541 2.94207 42.4067 3.3168L48.8634 19.17C49.016 19.5447 48.8 19.8513 48.3835 19.8513H44.8067C44.3901 19.8513 43.9406 19.539 43.8078 19.1572L42.9919 16.8116ZM41.8232 13.4223L39.6807 7.18148L37.5383 13.4223H41.8232ZM64.1105 19.8513C63.694 19.8513 63.1767 19.5694 62.9611 19.2247L59.9029 14.3369L56.8447 19.2247C56.6291 19.5694 56.1119 19.8513 55.6953 19.8513H51.3392C50.9227 19.8513 50.7754 19.5801 51.0119 19.2486L56.8978 11.0013L51.5315 3.24414C51.2999 2.90937 51.4513 2.63546 51.8679 2.63546H55.89C56.3066 2.63546 56.8268 2.91563 57.0461 3.25807L59.9029 7.71959L62.7343 3.25955C62.9522 2.9163 63.4713 2.63546 63.8879 2.63546H67.938C68.3545 2.63546 68.5048 2.90868 68.272 3.24261L62.8801 10.9743L68.7935 19.2489C69.0303 19.5802 68.8832 19.8513 68.4666 19.8513H64.1105ZM76.525 19.119C76.525 19.5218 76.1841 19.8513 75.7675 19.8513H72.5522C72.1356 19.8513 71.7947 19.5218 71.7947 19.119V3.36771C71.7947 2.96498 72.1356 2.63546 72.5522 2.63546H75.7675C76.1841 2.63546 76.525 2.96498 76.525 3.36771V19.119ZM79.3736 11.1896C79.3736 6.18625 83.2688 2.15134 89.2511 2.15134C95.2334 2.15134 99.1289 6.18625 99.1289 11.1896C99.1289 16.2199 95.2334 20.2548 89.2511 20.2548C83.2688 20.2548 79.3736 16.2199 79.3736 11.1896ZM94.2873 11.1896C94.2873 8.58038 92.3953 6.21307 89.2511 6.21307C86.1349 6.21307 84.2149 8.58038 84.2149 11.1896C84.2149 13.7989 86.1349 16.2199 89.2511 16.2199C92.3675 16.2199 94.2873 13.7989 94.2873 11.1896ZM119.318 19.8513C118.902 19.8513 118.517 19.5245 118.463 19.1251L117.225 9.89847L113.65 19.1652C113.505 19.5426 113.045 19.8513 112.628 19.8513H111.055C110.638 19.8513 110.179 19.5423 110.034 19.1645L106.457 9.81766L105.218 19.125C105.165 19.5245 104.781 19.8513 104.364 19.8513H101.344C100.927 19.8513 100.633 19.5249 100.69 19.1259L102.932 3.3609C102.988 2.96191 103.376 2.63546 103.792 2.63546H106.59C107.007 2.63546 107.469 2.94351 107.617 3.32002L111.827 14.041L116.064 3.31949C116.213 2.94327 116.676 2.63546 117.092 2.63546H119.89C120.307 2.63546 120.694 2.96191 120.751 3.3609L122.993 19.1259C123.05 19.5249 122.755 19.8513 122.339 19.8513H119.318ZM23.9616 15.6531L18.8054 6.97021C18.5689 6.57115 17.9863 6.24465 17.5106 6.24465H14.2915C13.5433 6.24465 13.2365 5.73171 13.6097 5.1048L15.375 2.13986C15.5151 1.90455 15.5148 1.61487 15.3743 1.37981C15.2337 1.14476 14.9741 1 14.6933 1H10.2025C9.72681 1 9.14291 1.32577 8.90491 1.72395L0.17865 16.3217C-0.0594434 16.7199 -0.0595348 17.3715 0.178285 17.7698L2.42362 21.5297C2.79777 22.1561 3.41129 22.1569 3.78699 21.5313L5.54143 18.6103C5.91722 17.9847 6.53065 17.9854 6.9048 18.6119L8.49538 21.2754C8.7332 21.6737 9.317 21.9995 9.79273 21.9995H20.1698C20.6455 21.9995 21.2293 21.6737 21.4672 21.2754L23.959 17.1028C24.1968 16.7045 24.198 16.0521 23.9616 15.6531ZM16.9981 15.2352C17.3699 15.8629 17.0619 16.3765 16.3136 16.3765H8.24192C7.49372 16.3765 7.1876 15.864 7.56175 15.2375L11.6007 8.47417C11.9748 7.84772 12.5869 7.84774 12.9611 8.47421L16.9981 15.2352Z" fill="#121224"/>
|
|
1534
|
+
</svg>`;
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1760
1537
|
|
|
1761
1538
|
// src/cli/auth/global-auth.ts
|
|
1762
|
-
init_cjs_shims();
|
|
1763
|
-
var authContext = null;
|
|
1764
1539
|
function getAuthContext() {
|
|
1765
1540
|
return authContext;
|
|
1766
1541
|
}
|
|
@@ -1776,9 +1551,31 @@ async function setupGlobalAuth() {
|
|
|
1776
1551
|
}
|
|
1777
1552
|
return authContext;
|
|
1778
1553
|
}
|
|
1554
|
+
var authContext;
|
|
1555
|
+
var init_global_auth = __esm({
|
|
1556
|
+
"src/cli/auth/global-auth.ts"() {
|
|
1557
|
+
"use strict";
|
|
1558
|
+
init_cjs_shims();
|
|
1559
|
+
init_config();
|
|
1560
|
+
authContext = null;
|
|
1561
|
+
}
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
// src/cli/auth/index.ts
|
|
1565
|
+
var init_auth = __esm({
|
|
1566
|
+
"src/cli/auth/index.ts"() {
|
|
1567
|
+
"use strict";
|
|
1568
|
+
init_cjs_shims();
|
|
1569
|
+
init_types();
|
|
1570
|
+
init_config();
|
|
1571
|
+
init_oauth();
|
|
1572
|
+
init_api();
|
|
1573
|
+
init_callback_server();
|
|
1574
|
+
init_global_auth();
|
|
1575
|
+
}
|
|
1576
|
+
});
|
|
1779
1577
|
|
|
1780
1578
|
// src/config/index.ts
|
|
1781
|
-
var DEFAULT_EVAL_INCLUDE = ["**/*.eval.{ts,js,mts,mjs,cts,cjs}"];
|
|
1782
1579
|
function createPartialDefaults() {
|
|
1783
1580
|
let token;
|
|
1784
1581
|
let url;
|
|
@@ -1841,6 +1638,17 @@ function validateConfig(config) {
|
|
|
1841
1638
|
}
|
|
1842
1639
|
return config;
|
|
1843
1640
|
}
|
|
1641
|
+
var import_zod7, DEFAULT_EVAL_INCLUDE;
|
|
1642
|
+
var init_config2 = __esm({
|
|
1643
|
+
"src/config/index.ts"() {
|
|
1644
|
+
"use strict";
|
|
1645
|
+
init_cjs_shims();
|
|
1646
|
+
import_zod7 = require("zod");
|
|
1647
|
+
init_errors();
|
|
1648
|
+
init_auth();
|
|
1649
|
+
DEFAULT_EVAL_INCLUDE = ["**/*.eval.{ts,js,mts,mjs,cts,cjs}"];
|
|
1650
|
+
}
|
|
1651
|
+
});
|
|
1844
1652
|
|
|
1845
1653
|
// src/config/loader.ts
|
|
1846
1654
|
function customMerger(target, source) {
|
|
@@ -1880,446 +1688,967 @@ async function loadConfig(cwd = process.cwd()) {
|
|
|
1880
1688
|
throw new AxiomCLIError(`Failed to load config file: ${errorToString(error)}`);
|
|
1881
1689
|
}
|
|
1882
1690
|
}
|
|
1691
|
+
var import_c12, import_defu;
|
|
1692
|
+
var init_loader = __esm({
|
|
1693
|
+
"src/config/loader.ts"() {
|
|
1694
|
+
"use strict";
|
|
1695
|
+
init_cjs_shims();
|
|
1696
|
+
import_c12 = require("c12");
|
|
1697
|
+
import_defu = require("defu");
|
|
1698
|
+
init_config2();
|
|
1699
|
+
init_errors();
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1883
1702
|
|
|
1884
|
-
//
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1703
|
+
// ../../node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js
|
|
1704
|
+
function a(n) {
|
|
1705
|
+
return String(n);
|
|
1706
|
+
}
|
|
1707
|
+
function C(n = false) {
|
|
1708
|
+
let e = typeof process != "undefined" ? process : void 0, i = (e == null ? void 0 : e.env) || {}, g = (e == null ? void 0 : e.argv) || [];
|
|
1709
|
+
return !("NO_COLOR" in i || g.includes("--no-color")) && ("FORCE_COLOR" in i || g.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || n && i.TERM !== "dumb" || "CI" in i) || typeof window != "undefined" && !!window.chrome;
|
|
1710
|
+
}
|
|
1711
|
+
function p(n = false) {
|
|
1712
|
+
let e = C(n), i = (r2, t, c, o) => {
|
|
1713
|
+
let l = "", s2 = 0;
|
|
1714
|
+
do
|
|
1715
|
+
l += r2.substring(s2, o) + c, s2 = o + t.length, o = r2.indexOf(t, s2);
|
|
1716
|
+
while (~o);
|
|
1717
|
+
return l + r2.substring(s2);
|
|
1718
|
+
}, g = (r2, t, c = r2) => {
|
|
1719
|
+
let o = (l) => {
|
|
1720
|
+
let s2 = String(l), b = s2.indexOf(t, r2.length);
|
|
1721
|
+
return ~b ? r2 + i(s2, t, c, b) + t : r2 + s2 + t;
|
|
1722
|
+
};
|
|
1723
|
+
return o.open = r2, o.close = t, o;
|
|
1724
|
+
}, u2 = {
|
|
1725
|
+
isColorSupported: e
|
|
1726
|
+
}, d = (r2) => `\x1B[${r2}m`;
|
|
1727
|
+
for (let [r2, t] of h)
|
|
1728
|
+
u2[r2] = e ? g(
|
|
1729
|
+
d(t[0]),
|
|
1730
|
+
d(t[1]),
|
|
1731
|
+
t[2]
|
|
1732
|
+
) : a;
|
|
1733
|
+
return u2;
|
|
1734
|
+
}
|
|
1735
|
+
var f, h;
|
|
1736
|
+
var init_chunk_BVHSVHOK = __esm({
|
|
1737
|
+
"../../node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js"() {
|
|
1738
|
+
"use strict";
|
|
1739
|
+
init_cjs_shims();
|
|
1740
|
+
f = {
|
|
1741
|
+
reset: [0, 0],
|
|
1742
|
+
bold: [1, 22, "\x1B[22m\x1B[1m"],
|
|
1743
|
+
dim: [2, 22, "\x1B[22m\x1B[2m"],
|
|
1744
|
+
italic: [3, 23],
|
|
1745
|
+
underline: [4, 24],
|
|
1746
|
+
inverse: [7, 27],
|
|
1747
|
+
hidden: [8, 28],
|
|
1748
|
+
strikethrough: [9, 29],
|
|
1749
|
+
black: [30, 39],
|
|
1750
|
+
red: [31, 39],
|
|
1751
|
+
green: [32, 39],
|
|
1752
|
+
yellow: [33, 39],
|
|
1753
|
+
blue: [34, 39],
|
|
1754
|
+
magenta: [35, 39],
|
|
1755
|
+
cyan: [36, 39],
|
|
1756
|
+
white: [37, 39],
|
|
1757
|
+
gray: [90, 39],
|
|
1758
|
+
bgBlack: [40, 49],
|
|
1759
|
+
bgRed: [41, 49],
|
|
1760
|
+
bgGreen: [42, 49],
|
|
1761
|
+
bgYellow: [43, 49],
|
|
1762
|
+
bgBlue: [44, 49],
|
|
1763
|
+
bgMagenta: [45, 49],
|
|
1764
|
+
bgCyan: [46, 49],
|
|
1765
|
+
bgWhite: [47, 49],
|
|
1766
|
+
blackBright: [90, 39],
|
|
1767
|
+
redBright: [91, 39],
|
|
1768
|
+
greenBright: [92, 39],
|
|
1769
|
+
yellowBright: [93, 39],
|
|
1770
|
+
blueBright: [94, 39],
|
|
1771
|
+
magentaBright: [95, 39],
|
|
1772
|
+
cyanBright: [96, 39],
|
|
1773
|
+
whiteBright: [97, 39],
|
|
1774
|
+
bgBlackBright: [100, 49],
|
|
1775
|
+
bgRedBright: [101, 49],
|
|
1776
|
+
bgGreenBright: [102, 49],
|
|
1777
|
+
bgYellowBright: [103, 49],
|
|
1778
|
+
bgBlueBright: [104, 49],
|
|
1779
|
+
bgMagentaBright: [105, 49],
|
|
1780
|
+
bgCyanBright: [106, 49],
|
|
1781
|
+
bgWhiteBright: [107, 49]
|
|
1782
|
+
};
|
|
1783
|
+
h = Object.entries(f);
|
|
1784
|
+
a.open = "";
|
|
1785
|
+
a.close = "";
|
|
1786
|
+
}
|
|
1787
|
+
});
|
|
1788
|
+
|
|
1789
|
+
// ../../node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js
|
|
1790
|
+
var import_tty, r, u;
|
|
1791
|
+
var init_node = __esm({
|
|
1792
|
+
"../../node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/node.js"() {
|
|
1793
|
+
"use strict";
|
|
1794
|
+
init_cjs_shims();
|
|
1795
|
+
init_chunk_BVHSVHOK();
|
|
1796
|
+
import_tty = require("tty");
|
|
1797
|
+
r = process.env.FORCE_TTY !== void 0 || (0, import_tty.isatty)(1);
|
|
1798
|
+
u = p(r);
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
|
|
1802
|
+
// src/evals/reporter.console-utils.ts
|
|
1803
|
+
function formatPercentage(value) {
|
|
1804
|
+
if (!Number.isFinite(value)) {
|
|
1805
|
+
return "N/A";
|
|
1806
|
+
}
|
|
1807
|
+
return Number(value * 100).toFixed(2) + "%";
|
|
1808
|
+
}
|
|
1809
|
+
function formatDiff(current, baseline) {
|
|
1810
|
+
if (!Number.isFinite(current) || !Number.isFinite(baseline)) {
|
|
1811
|
+
return { text: "N/A", color: u.dim };
|
|
1893
1812
|
}
|
|
1813
|
+
const diff = current - baseline;
|
|
1814
|
+
const diffText = (diff >= 0 ? "+" : "") + formatPercentage(diff);
|
|
1815
|
+
const color = diff > 0 ? u.green : diff < 0 ? u.red : u.dim;
|
|
1816
|
+
return { text: diffText, color };
|
|
1817
|
+
}
|
|
1818
|
+
function truncate(str, max) {
|
|
1819
|
+
return str.length > max ? str.slice(0, max) + "\u2026" : str;
|
|
1820
|
+
}
|
|
1821
|
+
function stringify(value) {
|
|
1894
1822
|
try {
|
|
1895
|
-
|
|
1896
|
-
return
|
|
1897
|
-
} catch
|
|
1898
|
-
|
|
1899
|
-
|
|
1823
|
+
if (typeof value === "string") return value;
|
|
1824
|
+
return JSON.stringify(value);
|
|
1825
|
+
} catch {
|
|
1826
|
+
return String(value);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
function getCaseFingerprint(input, expected) {
|
|
1830
|
+
const inputStr = typeof input === "string" ? input : JSON.stringify(input);
|
|
1831
|
+
const expectedStr = typeof expected === "string" ? expected : JSON.stringify(expected);
|
|
1832
|
+
return JSON.stringify({ input: inputStr, expected: expectedStr });
|
|
1833
|
+
}
|
|
1834
|
+
function printEvalNameAndFileName(testSuite, meta, logger = console.log) {
|
|
1835
|
+
const cwd = process.cwd();
|
|
1836
|
+
logger(
|
|
1837
|
+
" ",
|
|
1838
|
+
u.bgCyan(u.black(` ${testSuite.project.name} `)),
|
|
1839
|
+
u.bgBlue(u.black(` ${meta.evaluation.name}-${meta.evaluation.version} `)),
|
|
1840
|
+
u.dim(`(${testSuite.children.size} cases)`)
|
|
1841
|
+
);
|
|
1842
|
+
logger(" ", u.dim(testSuite.module.moduleId.replace(cwd, "")));
|
|
1843
|
+
}
|
|
1844
|
+
function printBaselineNameAndVersion(testMeta, logger = console.log) {
|
|
1845
|
+
if (testMeta.evaluation.baseline) {
|
|
1846
|
+
logger(
|
|
1847
|
+
" ",
|
|
1848
|
+
" baseline ",
|
|
1849
|
+
u.bgMagenta(
|
|
1850
|
+
u.black(` ${testMeta.evaluation.baseline.name}-${testMeta.evaluation.baseline.version} `)
|
|
1851
|
+
)
|
|
1900
1852
|
);
|
|
1853
|
+
} else {
|
|
1854
|
+
logger(" ", u.bgWhite(u.blackBright(" baseline: ")), "none");
|
|
1901
1855
|
}
|
|
1856
|
+
logger("");
|
|
1902
1857
|
}
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1858
|
+
function printRuntimeFlags(testMeta, logger = console.log) {
|
|
1859
|
+
if (testMeta.case.runtimeFlags && Object.keys(testMeta.case.runtimeFlags).length > 0) {
|
|
1860
|
+
const entries = Object.entries(testMeta.case.runtimeFlags);
|
|
1861
|
+
logger(" ", u.dim("runtime flags"));
|
|
1862
|
+
for (const [k, v] of entries) {
|
|
1863
|
+
switch (v.kind) {
|
|
1864
|
+
case "replaced": {
|
|
1865
|
+
const valText = truncate(stringify(v.value), 80);
|
|
1866
|
+
const defText = truncate(stringify(v.default), 80);
|
|
1867
|
+
logger(" ", `${k}: ${valText} (default: ${defText})`);
|
|
1868
|
+
break;
|
|
1869
|
+
}
|
|
1870
|
+
case "introduced": {
|
|
1871
|
+
const valText = truncate(stringify(v.value), 80);
|
|
1872
|
+
logger(" ", `${k}: ${valText} (no default)`);
|
|
1873
|
+
break;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1908
1877
|
}
|
|
1909
1878
|
}
|
|
1910
|
-
function
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
};
|
|
1915
|
-
|
|
1916
|
-
|
|
1879
|
+
function printTestCaseCountStartDuration(testSuite, startTime, duration, logger = console.log) {
|
|
1880
|
+
logger(" ");
|
|
1881
|
+
logger(" ", u.dim("Cases"), testSuite.children.size);
|
|
1882
|
+
logger(" ", u.dim("Start at"), new Date(startTime).toTimeString());
|
|
1883
|
+
logger(" ", u.dim("Duration"), `${duration}s`);
|
|
1884
|
+
}
|
|
1885
|
+
function printTestCaseSuccessOrFailed(testMeta, ok, logger = console.log) {
|
|
1886
|
+
const index = testMeta.case.index;
|
|
1887
|
+
if (ok) {
|
|
1888
|
+
logger(" ", u.yellow(` \u2714 case ${index}:`));
|
|
1889
|
+
} else {
|
|
1890
|
+
logger(" ", u.red(` \u2716 case ${index}: failed`));
|
|
1891
|
+
for (const e of testMeta.case.errors ?? []) {
|
|
1892
|
+
logger("", e.message);
|
|
1893
|
+
}
|
|
1917
1894
|
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1895
|
+
}
|
|
1896
|
+
function printTestCaseScores(testMeta, baselineCase, logger = console.log) {
|
|
1897
|
+
const scores = testMeta.case.scores;
|
|
1898
|
+
const keys = Object.keys(scores);
|
|
1899
|
+
if (keys.length === 0) {
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
const maxNameLength = Math.max(...keys.map((k) => k.length));
|
|
1903
|
+
keys.forEach((k) => {
|
|
1904
|
+
const scoreData = scores[k];
|
|
1905
|
+
const hasError = scoreData.metadata?.error;
|
|
1906
|
+
const v = scoreData.score ? scoreData.score : 0;
|
|
1907
|
+
const rawCurrent = hasError ? "N/A" : formatPercentage(v);
|
|
1908
|
+
const paddedCurrent = rawCurrent.padStart(7);
|
|
1909
|
+
const coloredCurrent = hasError ? u.dim(paddedCurrent) : u.magentaBright(paddedCurrent);
|
|
1910
|
+
const paddedName = k.padEnd(maxNameLength);
|
|
1911
|
+
if (baselineCase?.scores[k]) {
|
|
1912
|
+
const baselineScoreValue = baselineCase.scores[k].value;
|
|
1913
|
+
const rawBaseline = formatPercentage(baselineScoreValue);
|
|
1914
|
+
const paddedBaseline = rawBaseline.padStart(7);
|
|
1915
|
+
const coloredBaseline = u.blueBright(paddedBaseline);
|
|
1916
|
+
const { text: diffText, color: diffColor } = formatDiff(v, baselineScoreValue);
|
|
1917
|
+
const paddedDiff = diffText.padStart(8);
|
|
1918
|
+
logger(
|
|
1919
|
+
` ${paddedName} ${coloredBaseline} \u2192 ${coloredCurrent} ${hasError ? u.dim("(scorer not run)") : u.dim("(") + diffColor(paddedDiff) + u.dim(")")}`
|
|
1920
|
+
);
|
|
1921
|
+
} else {
|
|
1922
|
+
logger(` ${paddedName} ${coloredCurrent} ${hasError ? u.dim("(scorer not run)") : ""}`);
|
|
1923
|
+
}
|
|
1936
1924
|
});
|
|
1937
|
-
axiomTracer = axiomProvider.getTracer("axiom", "0.34.1");
|
|
1938
1925
|
}
|
|
1939
|
-
|
|
1940
|
-
if (
|
|
1926
|
+
function printOutOfScopeFlags(testMeta, logger = console.log) {
|
|
1927
|
+
if (testMeta.case.outOfScopeFlags && testMeta.case.outOfScopeFlags.length > 0) {
|
|
1928
|
+
const pickedFlagsText = testMeta.case.pickedFlags ? `(picked: ${testMeta.case.pickedFlags.map((f2) => `'${f2}'`).join(", ")})` : "(none)";
|
|
1929
|
+
logger(" ", u.yellow(`\u26A0 Out-of-scope flags: ${pickedFlagsText}`));
|
|
1930
|
+
testMeta.case.outOfScopeFlags.forEach((flag) => {
|
|
1931
|
+
const timeStr = new Date(flag.accessedAt).toLocaleTimeString();
|
|
1932
|
+
logger(" ", `${flag.flagPath} (at ${timeStr})`);
|
|
1933
|
+
if (flag.stackTrace && flag.stackTrace.length > 0) {
|
|
1934
|
+
flag.stackTrace.forEach((frame, i) => {
|
|
1935
|
+
const prefix = i === flag.stackTrace.length - 1 ? " \u2514\u2500" : " \u251C\u2500";
|
|
1936
|
+
logger(" ", u.dim(`${prefix} ${frame}`));
|
|
1937
|
+
});
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
function printCaseResult(test, baselineCasesByFingerprint, matchedIndices, logger = console.log) {
|
|
1943
|
+
const ok = test.ok();
|
|
1944
|
+
const testMeta = test.meta();
|
|
1945
|
+
if (!testMeta?.case) {
|
|
1941
1946
|
return;
|
|
1942
1947
|
}
|
|
1943
|
-
|
|
1944
|
-
|
|
1948
|
+
printTestCaseSuccessOrFailed(testMeta, ok, logger);
|
|
1949
|
+
const fingerprint = getCaseFingerprint(testMeta.case.input, testMeta.case.expected);
|
|
1950
|
+
const baselineCases = baselineCasesByFingerprint.get(fingerprint);
|
|
1951
|
+
const baselineCase = baselineCases?.shift();
|
|
1952
|
+
if (baselineCase) {
|
|
1953
|
+
matchedIndices.add(baselineCase.index);
|
|
1954
|
+
}
|
|
1955
|
+
printTestCaseScores(testMeta, baselineCase, logger);
|
|
1956
|
+
printRuntimeFlags(testMeta, logger);
|
|
1957
|
+
printOutOfScopeFlags(testMeta, logger);
|
|
1958
|
+
}
|
|
1959
|
+
function printOrphanedBaselineCases(baseline, matchedIndices, logger = console.log) {
|
|
1960
|
+
const orphanedCases = baseline.cases.filter((c) => !matchedIndices.has(c.index));
|
|
1961
|
+
if (orphanedCases.length === 0) {
|
|
1945
1962
|
return;
|
|
1946
1963
|
}
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1964
|
+
logger("");
|
|
1965
|
+
logger(" ", u.yellow("Orphaned baseline cases:"));
|
|
1966
|
+
for (const orphanedCase of orphanedCases) {
|
|
1967
|
+
logger(
|
|
1968
|
+
" ",
|
|
1969
|
+
u.dim(
|
|
1970
|
+
`case ${orphanedCase.index}: ${truncate(orphanedCase.input, 50)} (score: ${truncate(
|
|
1971
|
+
JSON.stringify(orphanedCase.scores),
|
|
1972
|
+
50
|
|
1973
|
+
)})`
|
|
1974
|
+
)
|
|
1975
|
+
);
|
|
1976
|
+
const keys = Object.keys(orphanedCase.scores);
|
|
1977
|
+
if (keys.length > 0) {
|
|
1978
|
+
const maxNameLength = Math.max(...keys.map((k) => k.length));
|
|
1979
|
+
keys.forEach((k) => {
|
|
1980
|
+
const scoreData = orphanedCase.scores[k];
|
|
1981
|
+
const rawScore = formatPercentage(scoreData.value);
|
|
1982
|
+
const paddedName = k.padEnd(maxNameLength);
|
|
1983
|
+
const paddedScore = rawScore.padStart(7);
|
|
1984
|
+
logger(` ${paddedName} ${u.blueBright(paddedScore)}`);
|
|
1963
1985
|
});
|
|
1964
|
-
userProvider = hookResult?.provider ?? userProvider;
|
|
1965
1986
|
}
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
function printGlobalFlagOverrides(overrides2, defaults, logger = console.log) {
|
|
1990
|
+
if (Object.keys(overrides2).length === 0) {
|
|
1991
|
+
logger("");
|
|
1992
|
+
logger(u.dim("Flag overrides: (none)"));
|
|
1993
|
+
logger("");
|
|
1994
|
+
return;
|
|
1995
|
+
}
|
|
1996
|
+
logger("");
|
|
1997
|
+
logger("Flag overrides:");
|
|
1998
|
+
for (const [key, value] of Object.entries(overrides2)) {
|
|
1999
|
+
const defaultValue = defaults[key];
|
|
2000
|
+
const valueStr = JSON.stringify(value);
|
|
2001
|
+
const defaultStr = defaultValue !== void 0 ? JSON.stringify(defaultValue) : "none";
|
|
2002
|
+
logger(` \u2022 ${key}: ${valueStr} ${u.dim(`(default: ${defaultStr})`)}`);
|
|
2003
|
+
}
|
|
2004
|
+
logger("");
|
|
2005
|
+
}
|
|
2006
|
+
function printSuiteBox({
|
|
2007
|
+
suite,
|
|
2008
|
+
scorerAverages,
|
|
2009
|
+
calculateBaselineScorerAverage: calculateBaselineScorerAverage2,
|
|
2010
|
+
flagDiff,
|
|
2011
|
+
logger = console.log
|
|
2012
|
+
}) {
|
|
2013
|
+
const filename = suite.file.split("/").pop();
|
|
2014
|
+
logger("\u250C\u2500");
|
|
2015
|
+
logger(`\u2502 ${u.blue(suite.name)} ${u.gray(`(${filename})`)}`);
|
|
2016
|
+
logger("\u251C\u2500");
|
|
2017
|
+
const scorerNames = Object.keys(scorerAverages);
|
|
2018
|
+
const maxNameLength = Math.max(...scorerNames.map((name) => name.length));
|
|
2019
|
+
const allCasesErrored = (scorerName) => {
|
|
2020
|
+
return suite.cases.every((caseData) => caseData.scores[scorerName]?.metadata?.error);
|
|
2021
|
+
};
|
|
2022
|
+
for (const scorerName of scorerNames) {
|
|
2023
|
+
const avg = scorerAverages[scorerName];
|
|
2024
|
+
const paddedName = scorerName.padEnd(maxNameLength);
|
|
2025
|
+
const hasAllErrors = allCasesErrored(scorerName);
|
|
2026
|
+
const baselineAvg = suite.baseline ? calculateBaselineScorerAverage2(suite.baseline, scorerName) : null;
|
|
2027
|
+
if (baselineAvg !== null) {
|
|
2028
|
+
const currentPercent = hasAllErrors ? u.dim("N/A") : formatPercentage(avg);
|
|
2029
|
+
const baselinePercent = formatPercentage(baselineAvg);
|
|
2030
|
+
const { text: diffText, color: diffColor } = formatDiff(avg, baselineAvg);
|
|
2031
|
+
const paddedBaseline = baselinePercent.padStart(7);
|
|
2032
|
+
const paddedCurrent = hasAllErrors ? currentPercent : currentPercent.padStart(7);
|
|
2033
|
+
const diffDisplay = hasAllErrors ? u.dim("all cases failed") : diffColor(diffText.padStart(8));
|
|
2034
|
+
logger(
|
|
2035
|
+
`\u2502 ${paddedName} ${u.blueBright(paddedBaseline)} \u2192 ${hasAllErrors ? paddedCurrent : u.magentaBright(paddedCurrent)} (${diffDisplay})`
|
|
2036
|
+
);
|
|
2037
|
+
} else {
|
|
2038
|
+
const currentPercent = hasAllErrors ? u.red("N/A (all cases failed)") : formatPercentage(avg);
|
|
2039
|
+
logger(`\u2502 \u2022 ${paddedName} ${currentPercent}`);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
logger("\u251C\u2500");
|
|
2043
|
+
if (suite.baseline) {
|
|
2044
|
+
const baselineTimestamp = suite.baseline.runAt ? reporterDate(new Date(suite.baseline.runAt)) : "unknown time";
|
|
2045
|
+
logger(
|
|
2046
|
+
`\u2502 Baseline: ${suite.baseline.name}-${suite.baseline.version} ${u.gray(`(${baselineTimestamp})`)}`
|
|
2047
|
+
);
|
|
2048
|
+
} else {
|
|
2049
|
+
logger(`\u2502 Baseline: ${u.gray("(none)")}`);
|
|
2050
|
+
}
|
|
2051
|
+
const hasConfigChanges = flagDiff.length > 0;
|
|
2052
|
+
logger("\u2502 Config changes:", hasConfigChanges ? "" : u.gray("(none)"));
|
|
2053
|
+
if (hasConfigChanges) {
|
|
2054
|
+
for (const { flag, current, baseline, default: defaultVal } of flagDiff) {
|
|
2055
|
+
logger(`\u2502 \u2022 ${flag}: ${current ?? "<not set>"}`);
|
|
2056
|
+
if (defaultVal !== void 0) {
|
|
2057
|
+
logger(`\u2502 ${u.gray(`default: ${defaultVal}`)}`);
|
|
1971
2058
|
}
|
|
2059
|
+
if (suite.baseline) {
|
|
2060
|
+
logger(`\u2502 ${u.gray(`baseline: ${baseline ?? "<not set>"}`)}`);
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
if (suite.outOfScopeFlags && suite.outOfScopeFlags.length > 0) {
|
|
2065
|
+
const pickedFlagsText = suite.configFlags && suite.configFlags.length > 0 ? suite.configFlags.map((f2) => `'${f2}'`).join(", ") : "none";
|
|
2066
|
+
logger("\u2502");
|
|
2067
|
+
logger(`\u2502 ${u.yellow("\u26A0 Out-of-scope flags")} ${u.gray(`(picked: ${pickedFlagsText})`)}:`);
|
|
2068
|
+
for (const flag of suite.outOfScopeFlags) {
|
|
2069
|
+
const lastStackTraceFrame = flag.stackTrace[0];
|
|
2070
|
+
const lastStackTraceFnName = lastStackTraceFrame.split(" ").shift();
|
|
2071
|
+
const lastStackTraceFile = lastStackTraceFrame.split("/").pop()?.slice(0, -1);
|
|
2072
|
+
logger(
|
|
2073
|
+
`\u2502 \u2022 ${flag.flagPath} ${u.gray(`at ${lastStackTraceFnName} (${lastStackTraceFile})`)}`
|
|
2074
|
+
);
|
|
1972
2075
|
}
|
|
1973
|
-
initialized = true;
|
|
1974
|
-
})();
|
|
1975
|
-
try {
|
|
1976
|
-
await initializationPromise;
|
|
1977
|
-
} finally {
|
|
1978
|
-
initializationPromise = null;
|
|
1979
2076
|
}
|
|
2077
|
+
logger("\u2514\u2500");
|
|
1980
2078
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
2079
|
+
function calculateScorerAverages(suite) {
|
|
2080
|
+
const scorerTotals = {};
|
|
2081
|
+
for (const caseData of suite.cases) {
|
|
2082
|
+
for (const [scorerName, score] of Object.entries(caseData.scores)) {
|
|
2083
|
+
if (!scorerTotals[scorerName]) {
|
|
2084
|
+
scorerTotals[scorerName] = { sum: 0, count: 0 };
|
|
2085
|
+
}
|
|
2086
|
+
if (!score.metadata?.error) {
|
|
2087
|
+
scorerTotals[scorerName].sum += score.score || 0;
|
|
2088
|
+
scorerTotals[scorerName].count += 1;
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
1984
2091
|
}
|
|
1985
|
-
const
|
|
1986
|
-
|
|
1987
|
-
|
|
2092
|
+
const averages = {};
|
|
2093
|
+
for (const [scorerName, totals] of Object.entries(scorerTotals)) {
|
|
2094
|
+
averages[scorerName] = totals.count > 0 ? totals.sum / totals.count : 0;
|
|
1988
2095
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2096
|
+
return averages;
|
|
2097
|
+
}
|
|
2098
|
+
function calculateBaselineScorerAverage(baseline, scorerName) {
|
|
2099
|
+
const scores = [];
|
|
2100
|
+
for (const caseData of baseline.cases) {
|
|
2101
|
+
if (caseData.scores[scorerName]) {
|
|
2102
|
+
scores.push(caseData.scores[scorerName].value);
|
|
2103
|
+
}
|
|
1992
2104
|
}
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
2105
|
+
if (scores.length === 0) return null;
|
|
2106
|
+
const sum = scores.reduce((acc, val) => acc + val, 0);
|
|
2107
|
+
return sum / scores.length;
|
|
2108
|
+
}
|
|
2109
|
+
function calculateFlagDiff(suite) {
|
|
2110
|
+
if (!suite.configFlags || suite.configFlags.length === 0) {
|
|
2111
|
+
return [];
|
|
1996
2112
|
}
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2113
|
+
const diffs = [];
|
|
2114
|
+
const currentConfig = suite.flagConfig || {};
|
|
2115
|
+
const baselineConfig = suite.baseline?.flagConfig || {};
|
|
2116
|
+
const defaultConfig = suite.defaultFlagConfig || {};
|
|
2117
|
+
const currentFlat = flattenObject(currentConfig);
|
|
2118
|
+
const baselineFlat = flattenObject(baselineConfig);
|
|
2119
|
+
const defaultFlat = flattenObject(defaultConfig);
|
|
2120
|
+
const allKeys = /* @__PURE__ */ new Set([
|
|
2121
|
+
...Object.keys(currentFlat),
|
|
2122
|
+
...Object.keys(baselineFlat),
|
|
2123
|
+
...Object.keys(defaultFlat)
|
|
2124
|
+
]);
|
|
2125
|
+
for (const key of allKeys) {
|
|
2126
|
+
const isInScope = suite.configFlags.some((pattern) => key.startsWith(pattern));
|
|
2127
|
+
if (!isInScope) continue;
|
|
2128
|
+
const currentValue = currentFlat[key];
|
|
2129
|
+
const baselineValue = baselineFlat[key];
|
|
2130
|
+
const defaultValue = defaultFlat[key];
|
|
2131
|
+
const currentStr = currentValue !== void 0 ? JSON.stringify(currentValue) : void 0;
|
|
2132
|
+
const baselineStr = baselineValue !== void 0 ? JSON.stringify(baselineValue) : void 0;
|
|
2133
|
+
const defaultStr = defaultValue !== void 0 ? JSON.stringify(defaultValue) : void 0;
|
|
2134
|
+
const diffFromBaseline = suite.baseline && currentStr !== baselineStr;
|
|
2135
|
+
const diffFromDefault = currentStr !== defaultStr;
|
|
2136
|
+
if (diffFromBaseline || diffFromDefault) {
|
|
2137
|
+
diffs.push({
|
|
2138
|
+
flag: key,
|
|
2139
|
+
current: currentStr,
|
|
2140
|
+
baseline: suite.baseline ? baselineStr : void 0,
|
|
2141
|
+
default: defaultStr
|
|
2142
|
+
});
|
|
2005
2143
|
}
|
|
2006
2144
|
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2145
|
+
return diffs;
|
|
2146
|
+
}
|
|
2147
|
+
function printFinalReport({
|
|
2148
|
+
suiteData,
|
|
2149
|
+
config,
|
|
2150
|
+
registrationStatus,
|
|
2151
|
+
isDebug,
|
|
2152
|
+
logger = console.log
|
|
2153
|
+
}) {
|
|
2154
|
+
logger("");
|
|
2155
|
+
logger(u.bgBlue(u.white(" FINAL EVALUATION REPORT ")));
|
|
2156
|
+
logger("");
|
|
2157
|
+
for (const suite of suiteData) {
|
|
2158
|
+
const scorerAverages = calculateScorerAverages(suite);
|
|
2159
|
+
const flagDiff = calculateFlagDiff(suite);
|
|
2160
|
+
printSuiteBox({ suite, scorerAverages, calculateBaselineScorerAverage, flagDiff, logger });
|
|
2161
|
+
logger("");
|
|
2017
2162
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
const
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2163
|
+
const runId = suiteData[0]?.runId;
|
|
2164
|
+
const orgId = suiteData[0]?.orgId;
|
|
2165
|
+
const anyRegistered = registrationStatus.some((s2) => s2.registered);
|
|
2166
|
+
const anyFailed = registrationStatus.some((s2) => !s2.registered);
|
|
2167
|
+
if (anyRegistered && orgId && config?.consoleEndpointUrl) {
|
|
2168
|
+
if (suiteData.length === 1) {
|
|
2169
|
+
const suite = suiteData[0];
|
|
2170
|
+
const baselineParam = suite.baseline?.traceId ? `?baselineId=${suite.baseline.traceId}` : "";
|
|
2171
|
+
logger("View eval result:");
|
|
2172
|
+
logger(
|
|
2173
|
+
`${config.consoleEndpointUrl}/${orgId}/ai-engineering/evaluations/${suite.name}/${suite.version}${baselineParam}`
|
|
2174
|
+
);
|
|
2175
|
+
} else {
|
|
2176
|
+
logger("View full report:");
|
|
2177
|
+
logger(`${config.consoleEndpointUrl}/${orgId}/ai-engineering/evaluations?runId=${runId}`);
|
|
2030
2178
|
}
|
|
2179
|
+
} else if (isDebug) {
|
|
2180
|
+
logger(u.dim("Results not uploaded to Axiom (debug mode)"));
|
|
2181
|
+
} else {
|
|
2182
|
+
logger("Results not available in Axiom UI (registration failed)");
|
|
2031
2183
|
}
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
const providedConfig = {
|
|
2042
|
-
...opts.config,
|
|
2043
|
-
eval: {
|
|
2044
|
-
...opts.config.eval,
|
|
2045
|
-
// These can't be serialized, so we need to remove them
|
|
2046
|
-
instrumentation: null,
|
|
2047
|
-
flagSchema: null
|
|
2048
|
-
}
|
|
2049
|
-
};
|
|
2050
|
-
if (opts.debug) {
|
|
2051
|
-
console.log(u.bgWhite(u.blackBright(" Debug mode enabled ")));
|
|
2052
|
-
}
|
|
2053
|
-
const tmpDir = (0, import_node_path.join)((0, import_node_os.tmpdir)(), "axiom-eval", opts.runId);
|
|
2054
|
-
(0, import_node_fs.mkdirSync)(tmpDir, { recursive: true });
|
|
2055
|
-
const nameRegistryFile = (0, import_node_path.join)(tmpDir, "names.jsonl");
|
|
2056
|
-
const abortFile = (0, import_node_path.join)(tmpDir, "abort.txt");
|
|
2057
|
-
(0, import_node_fs.writeFileSync)(nameRegistryFile, "", "utf8");
|
|
2058
|
-
if ((0, import_node_fs.existsSync)(abortFile)) {
|
|
2059
|
-
(0, import_node_fs.unlinkSync)(abortFile);
|
|
2060
|
-
}
|
|
2061
|
-
process.env.AXIOM_NAME_REGISTRY_FILE = nameRegistryFile;
|
|
2062
|
-
process.env.AXIOM_ABORT_FILE = abortFile;
|
|
2063
|
-
if (opts.list) {
|
|
2064
|
-
console.log(u.bgWhite(u.blackBright(" List mode ")));
|
|
2065
|
-
}
|
|
2066
|
-
const vi = await (0, import_node.createVitest)(
|
|
2067
|
-
"test",
|
|
2068
|
-
{
|
|
2069
|
-
root: dir ? dir : process.cwd(),
|
|
2070
|
-
mode: "test",
|
|
2071
|
-
include: opts.include,
|
|
2072
|
-
exclude: opts.exclude,
|
|
2073
|
-
testNamePattern: opts.testNamePattern,
|
|
2074
|
-
reporters: ["verbose", new AxiomReporter()],
|
|
2075
|
-
environment: "node",
|
|
2076
|
-
browser: void 0,
|
|
2077
|
-
watch: opts.watch,
|
|
2078
|
-
setupFiles: [],
|
|
2079
|
-
// ignore user vitest.config.ts etc
|
|
2080
|
-
name: "axiom:eval",
|
|
2081
|
-
printConsoleTrace: true,
|
|
2082
|
-
silent: false,
|
|
2083
|
-
disableConsoleIntercept: true,
|
|
2084
|
-
testTimeout: opts.config?.eval?.timeoutMs || 6e4,
|
|
2085
|
-
globals: true,
|
|
2086
|
-
runner: (0, import_node_path.resolve)(__dirname, "evals", "custom-runner.js"),
|
|
2087
|
-
provide: {
|
|
2088
|
-
baseline: opts.baseline,
|
|
2089
|
-
debug: opts.debug,
|
|
2090
|
-
list: opts.list,
|
|
2091
|
-
overrides: opts.overrides,
|
|
2092
|
-
axiomConfig: providedConfig,
|
|
2093
|
-
runId: opts.runId,
|
|
2094
|
-
consoleUrl: opts.consoleUrl
|
|
2184
|
+
if (anyFailed) {
|
|
2185
|
+
logger("");
|
|
2186
|
+
for (const status of registrationStatus) {
|
|
2187
|
+
if (!status.registered) {
|
|
2188
|
+
logger(u.yellow(`\u26A0\uFE0F Warning: Failed to register "${status.name}" with Axiom`));
|
|
2189
|
+
if (status.error) {
|
|
2190
|
+
logger(u.dim(` Error: ${status.error}`));
|
|
2191
|
+
}
|
|
2192
|
+
logger(u.dim(` Results for this evaluation will not be available in the Axiom UI.`));
|
|
2095
2193
|
}
|
|
2096
|
-
},
|
|
2097
|
-
{
|
|
2098
|
-
plugins: [(0, import_vite_tsconfig_paths.default)({ root: dir || process.cwd() })]
|
|
2099
2194
|
}
|
|
2100
|
-
);
|
|
2101
|
-
if (opts.list) {
|
|
2102
|
-
const result = await vi.collect();
|
|
2103
|
-
printCollectedEvals(result, dir || process.cwd());
|
|
2104
|
-
await vi.close();
|
|
2105
|
-
process.exit(0);
|
|
2106
|
-
}
|
|
2107
|
-
await vi.start();
|
|
2108
|
-
if ((0, import_node_fs.existsSync)(abortFile)) {
|
|
2109
|
-
const message = (0, import_node_fs.readFileSync)(abortFile, "utf8");
|
|
2110
|
-
console.error("\n" + message);
|
|
2111
|
-
await vi.close();
|
|
2112
|
-
process.exit(1);
|
|
2113
2195
|
}
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2196
|
+
}
|
|
2197
|
+
var reporterDate;
|
|
2198
|
+
var init_reporter_console_utils = __esm({
|
|
2199
|
+
"src/evals/reporter.console-utils.ts"() {
|
|
2200
|
+
"use strict";
|
|
2201
|
+
init_cjs_shims();
|
|
2202
|
+
init_node();
|
|
2203
|
+
init_dot_path();
|
|
2204
|
+
reporterDate = (d) => {
|
|
2205
|
+
const date = d.toISOString().slice(0, 10);
|
|
2206
|
+
const hours = d.getUTCHours().toString().padStart(2, "0");
|
|
2207
|
+
const minutes = d.getUTCMinutes().toString().padStart(2, "0");
|
|
2208
|
+
return `${date}, ${hours}:${minutes} UTC`;
|
|
2209
|
+
};
|
|
2120
2210
|
}
|
|
2121
|
-
|
|
2122
|
-
};
|
|
2123
|
-
|
|
2124
|
-
// src/cli/commands/eval.command.ts
|
|
2125
|
-
var import_node_fs3 = require("fs");
|
|
2126
|
-
|
|
2127
|
-
// src/cli/utils/eval-context-runner.ts
|
|
2128
|
-
init_cjs_shims();
|
|
2211
|
+
});
|
|
2129
2212
|
|
|
2130
|
-
// src/
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
}
|
|
2140
|
-
const overlayContext = {
|
|
2141
|
-
...current,
|
|
2142
|
-
flags: { ...current.flags, ...partial },
|
|
2143
|
-
// Merge for backwards compatibility
|
|
2144
|
-
parent: current,
|
|
2145
|
-
overrides: { ...partial }
|
|
2213
|
+
// src/config/resolver.ts
|
|
2214
|
+
function resolveAxiomConnection(config, consoleUrlOverride) {
|
|
2215
|
+
const consoleEndpointUrl = consoleUrlOverride ?? buildConsoleUrl(config.eval.url);
|
|
2216
|
+
return {
|
|
2217
|
+
url: config.eval.url,
|
|
2218
|
+
consoleEndpointUrl,
|
|
2219
|
+
token: config.eval.token,
|
|
2220
|
+
dataset: config.eval.dataset,
|
|
2221
|
+
orgId: config.eval.orgId
|
|
2146
2222
|
};
|
|
2147
|
-
const currentCtx = EVAL_CONTEXT.get();
|
|
2148
|
-
if (currentCtx) {
|
|
2149
|
-
Object.assign(currentCtx, overlayContext);
|
|
2150
|
-
}
|
|
2151
|
-
for (const [key, value] of Object.entries(partial)) {
|
|
2152
|
-
putOnSpan("flag", key, value);
|
|
2153
|
-
}
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2156
|
-
// src/cli/utils/eval-context-runner.ts
|
|
2157
|
-
async function runEvalWithContext(overrides2, runFn) {
|
|
2158
|
-
setGlobalFlagOverrides(overrides2);
|
|
2159
|
-
return withEvalContext({ initialFlags: overrides2 }, async () => {
|
|
2160
|
-
if (Object.keys(overrides2).length > 0) {
|
|
2161
|
-
overrideFlags(overrides2);
|
|
2162
|
-
}
|
|
2163
|
-
return runFn();
|
|
2164
|
-
});
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
|
-
// src/cli/utils/parse-flag-overrides.ts
|
|
2168
|
-
init_cjs_shims();
|
|
2169
|
-
var import_zod7 = require("zod");
|
|
2170
|
-
var import_node_fs2 = require("fs");
|
|
2171
|
-
var import_node_path3 = require("path");
|
|
2172
|
-
var FLAG_RE = /^--flag\.([^=]+)(?:=(.*))?$/;
|
|
2173
|
-
var CONFIG_RE = /^--flags-config(?:=(.*))?$/;
|
|
2174
|
-
function ensureNoSpaceSeparatedSyntax(flagName, value, nextToken, flagType) {
|
|
2175
|
-
if (value === void 0 && nextToken !== void 0) {
|
|
2176
|
-
if (flagType === "flag" && !nextToken.startsWith("-") && nextToken !== "true" && nextToken !== "false") {
|
|
2177
|
-
console.error(`\u274C Invalid syntax: --flag.${flagName} ${nextToken}`);
|
|
2178
|
-
console.error(`\u{1F4A1} Use: --flag.${flagName}=${nextToken}`);
|
|
2179
|
-
process.exit(1);
|
|
2180
|
-
} else if (flagType === "config" && !nextToken.startsWith("-")) {
|
|
2181
|
-
console.error(`\u274C Invalid syntax: --flags-config ${nextToken}`);
|
|
2182
|
-
console.error(`\u{1F4A1} Use: --flags-config=${nextToken}`);
|
|
2183
|
-
process.exit(1);
|
|
2184
|
-
}
|
|
2185
|
-
}
|
|
2186
2223
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2224
|
+
var buildConsoleUrl;
|
|
2225
|
+
var init_resolver = __esm({
|
|
2226
|
+
"src/config/resolver.ts"() {
|
|
2227
|
+
"use strict";
|
|
2228
|
+
init_cjs_shims();
|
|
2229
|
+
buildConsoleUrl = (urlString) => {
|
|
2230
|
+
const url = new URL(urlString);
|
|
2231
|
+
return `${url.protocol}//app.${url.host.split("api.").at(-1)}`;
|
|
2232
|
+
};
|
|
2190
2233
|
}
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2234
|
+
});
|
|
2235
|
+
|
|
2236
|
+
// src/evals/reporter.ts
|
|
2237
|
+
var AxiomReporter;
|
|
2238
|
+
var init_reporter = __esm({
|
|
2239
|
+
"src/evals/reporter.ts"() {
|
|
2240
|
+
"use strict";
|
|
2241
|
+
init_cjs_shims();
|
|
2242
|
+
init_storage();
|
|
2243
|
+
init_reporter_console_utils();
|
|
2244
|
+
init_resolver();
|
|
2245
|
+
init_eval_command();
|
|
2246
|
+
init_dot_path();
|
|
2247
|
+
AxiomReporter = class {
|
|
2248
|
+
constructor() {
|
|
2249
|
+
__publicField(this, "startTime", 0);
|
|
2250
|
+
__publicField(this, "start", 0);
|
|
2251
|
+
__publicField(this, "_endOfRunConfigEnd");
|
|
2252
|
+
__publicField(this, "_suiteData", []);
|
|
2253
|
+
__publicField(this, "_printedFlagOverrides", false);
|
|
2254
|
+
__publicField(this, "_config");
|
|
2255
|
+
}
|
|
2256
|
+
onTestRunStart() {
|
|
2257
|
+
this.start = performance.now();
|
|
2258
|
+
this.startTime = (/* @__PURE__ */ new Date()).getTime();
|
|
2259
|
+
const config = getAxiomConfig();
|
|
2260
|
+
if (config) {
|
|
2261
|
+
this._config = resolveAxiomConnection(config, getConsoleUrl());
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
async onTestSuiteReady(_testSuite) {
|
|
2265
|
+
const meta = _testSuite.meta();
|
|
2266
|
+
if (_testSuite.state() === "skipped" || !meta?.evaluation) {
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
if (!this._printedFlagOverrides) {
|
|
2270
|
+
const defaultsFromConfigEnd = meta.evaluation.configEnd?.flags ?? {};
|
|
2271
|
+
const overridesFromConfigEnd = meta.evaluation.configEnd?.overrides ?? {};
|
|
2272
|
+
if (Object.keys(overridesFromConfigEnd).length > 0) {
|
|
2273
|
+
printGlobalFlagOverrides(overridesFromConfigEnd, defaultsFromConfigEnd);
|
|
2274
|
+
}
|
|
2275
|
+
this._printedFlagOverrides = true;
|
|
2276
|
+
}
|
|
2277
|
+
if (meta.evaluation.configEnd && !this._endOfRunConfigEnd) {
|
|
2278
|
+
this._endOfRunConfigEnd = meta.evaluation.configEnd;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
onTestCaseReady(test) {
|
|
2282
|
+
const meta = test.meta();
|
|
2283
|
+
if (!meta.case) return;
|
|
2284
|
+
}
|
|
2285
|
+
async onTestSuiteResult(testSuite) {
|
|
2286
|
+
const meta = testSuite.meta();
|
|
2287
|
+
if (testSuite.state() === "skipped" || !meta?.evaluation) {
|
|
2288
|
+
return;
|
|
2289
|
+
}
|
|
2290
|
+
if (meta.evaluation.configEnd && !this._endOfRunConfigEnd) {
|
|
2291
|
+
this._endOfRunConfigEnd = meta.evaluation.configEnd;
|
|
2292
|
+
}
|
|
2293
|
+
const durationSeconds = Number((performance.now() - this.start) / 1e3).toFixed(2);
|
|
2294
|
+
const cases = [];
|
|
2295
|
+
for (const test of testSuite.children) {
|
|
2296
|
+
if (test.type !== "test") continue;
|
|
2297
|
+
const testMeta = test.meta();
|
|
2298
|
+
if (!testMeta?.case) continue;
|
|
2299
|
+
cases.push({
|
|
2300
|
+
index: testMeta.case.index,
|
|
2301
|
+
scores: testMeta.case.scores,
|
|
2302
|
+
outOfScopeFlags: testMeta.case.outOfScopeFlags,
|
|
2303
|
+
errors: testMeta.case.errors,
|
|
2304
|
+
runtimeFlags: testMeta.case.runtimeFlags
|
|
2305
|
+
});
|
|
2306
|
+
}
|
|
2307
|
+
const cwd = process.cwd();
|
|
2308
|
+
const relativePath = testSuite.module.moduleId.replace(cwd, "").replace(/^\//, "");
|
|
2309
|
+
let suiteBaseline = meta.evaluation.baseline;
|
|
2310
|
+
let flagConfig = meta.evaluation.flagConfig;
|
|
2311
|
+
if (meta.evaluation.configEnd) {
|
|
2312
|
+
const defaults = meta.evaluation.configEnd.flags ?? {};
|
|
2313
|
+
const overrides2 = meta.evaluation.configEnd.overrides ?? {};
|
|
2314
|
+
const defaultsFlat = flattenObject(defaults);
|
|
2315
|
+
const overridesFlat = flattenObject(overrides2);
|
|
2316
|
+
flagConfig = dotNotationToNested({ ...defaultsFlat, ...overridesFlat });
|
|
2317
|
+
}
|
|
2318
|
+
const defaultFlagConfig = meta.evaluation.configEnd?.flags;
|
|
2319
|
+
this._suiteData.push({
|
|
2320
|
+
version: meta.evaluation.version,
|
|
2321
|
+
name: meta.evaluation.name,
|
|
2322
|
+
file: relativePath,
|
|
2323
|
+
duration: durationSeconds + "s",
|
|
2324
|
+
baseline: suiteBaseline || null,
|
|
2325
|
+
configFlags: meta.evaluation.configFlags,
|
|
2326
|
+
flagConfig,
|
|
2327
|
+
defaultFlagConfig,
|
|
2328
|
+
runId: meta.evaluation.runId,
|
|
2329
|
+
orgId: meta.evaluation.orgId,
|
|
2330
|
+
cases,
|
|
2331
|
+
outOfScopeFlags: meta.evaluation.outOfScopeFlags,
|
|
2332
|
+
registrationStatus: meta.evaluation.registrationStatus
|
|
2333
|
+
});
|
|
2334
|
+
printEvalNameAndFileName(testSuite, meta);
|
|
2335
|
+
printBaselineNameAndVersion(meta);
|
|
2336
|
+
printTestCaseCountStartDuration(testSuite, this.startTime, durationSeconds);
|
|
2337
|
+
const matchedBaselineIndices = /* @__PURE__ */ new Set();
|
|
2338
|
+
const baselineCasesByFingerprint = /* @__PURE__ */ new Map();
|
|
2339
|
+
if (suiteBaseline) {
|
|
2340
|
+
for (const c of suiteBaseline.cases) {
|
|
2341
|
+
const fp = getCaseFingerprint(c.input, c.expected);
|
|
2342
|
+
const cases2 = baselineCasesByFingerprint.get(fp) || [];
|
|
2343
|
+
cases2.push(c);
|
|
2344
|
+
baselineCasesByFingerprint.set(fp, cases2);
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
for (const test of testSuite.children) {
|
|
2348
|
+
if (test.type !== "test") continue;
|
|
2349
|
+
printCaseResult(test, baselineCasesByFingerprint, matchedBaselineIndices);
|
|
2350
|
+
}
|
|
2351
|
+
if (suiteBaseline) {
|
|
2352
|
+
printOrphanedBaselineCases(suiteBaseline, matchedBaselineIndices);
|
|
2353
|
+
}
|
|
2354
|
+
console.log("");
|
|
2355
|
+
}
|
|
2356
|
+
async onTestRunEnd(_testModules, _errors, _reason) {
|
|
2357
|
+
const shouldClear = !process.env.CI && process.stdout.isTTY !== false;
|
|
2358
|
+
if (shouldClear) {
|
|
2359
|
+
process.stdout.write("\x1B[2J\x1B[0f");
|
|
2360
|
+
}
|
|
2361
|
+
const registrationStatus = this._suiteData.map((suite) => ({
|
|
2362
|
+
name: suite.name,
|
|
2363
|
+
registered: suite.registrationStatus?.status === "success",
|
|
2364
|
+
error: suite.registrationStatus?.status === "failed" ? suite.registrationStatus.error : void 0
|
|
2365
|
+
}));
|
|
2366
|
+
const isDebug = process.env.AXIOM_DEBUG === "true";
|
|
2367
|
+
printFinalReport({
|
|
2368
|
+
suiteData: this._suiteData,
|
|
2369
|
+
config: this._config,
|
|
2370
|
+
registrationStatus,
|
|
2371
|
+
isDebug
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2199
2375
|
}
|
|
2200
|
-
|
|
2201
|
-
|
|
2376
|
+
});
|
|
2377
|
+
|
|
2378
|
+
// src/evals/instrument.ts
|
|
2379
|
+
async function resolveInstrumentationHook(config) {
|
|
2380
|
+
if (config.eval.instrumentation) {
|
|
2381
|
+
return config.eval.instrumentation;
|
|
2202
2382
|
}
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2383
|
+
try {
|
|
2384
|
+
const { config: loadedConfig } = await loadConfig(process.cwd());
|
|
2385
|
+
return loadedConfig.eval.instrumentation ?? null;
|
|
2386
|
+
} catch (error) {
|
|
2387
|
+
throw new AxiomCLIError(
|
|
2388
|
+
`Failed to reload instrumentation from config: ${errorToString(error)}`
|
|
2389
|
+
);
|
|
2208
2390
|
}
|
|
2209
|
-
return { success: errors.length === 0, errors };
|
|
2210
2391
|
}
|
|
2211
|
-
function
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
} else {
|
|
2217
|
-
console.error(formatZodErrors(error.zodError));
|
|
2218
|
-
const examples = generateFlagExamples(error.zodError);
|
|
2219
|
-
if (examples.length > 0) {
|
|
2220
|
-
console.error("\n\u{1F4A1} Valid examples:");
|
|
2221
|
-
examples.forEach((example) => console.error(` ${example}`));
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2392
|
+
async function runInstrumentationHook(hook, options) {
|
|
2393
|
+
try {
|
|
2394
|
+
return await hook(options);
|
|
2395
|
+
} catch (error) {
|
|
2396
|
+
throw new AxiomCLIError(`Failed to execute instrumentation hook: ${errorToString(error)}`);
|
|
2224
2397
|
}
|
|
2225
|
-
process.exit(1);
|
|
2226
2398
|
}
|
|
2227
|
-
function
|
|
2228
|
-
const
|
|
2229
|
-
|
|
2230
|
-
|
|
2399
|
+
function setupEvalProvider(connection) {
|
|
2400
|
+
const headers = {
|
|
2401
|
+
"X-Axiom-Dataset": connection.dataset,
|
|
2402
|
+
...connection.orgId ? { "X-AXIOM-ORG-ID": connection.orgId } : {}
|
|
2403
|
+
};
|
|
2404
|
+
if (connection.token) {
|
|
2405
|
+
headers.Authorization = `Bearer ${connection.token}`;
|
|
2231
2406
|
}
|
|
2407
|
+
const collectorOptions = {
|
|
2408
|
+
url: `${connection.url}/v1/traces`,
|
|
2409
|
+
headers,
|
|
2410
|
+
concurrencyLimit: 10
|
|
2411
|
+
};
|
|
2412
|
+
const exporter = new import_exporter_trace_otlp_http.OTLPTraceExporter(collectorOptions);
|
|
2413
|
+
const processor = new import_sdk_trace_node.BatchSpanProcessor(exporter, {
|
|
2414
|
+
maxQueueSize: 2048,
|
|
2415
|
+
maxExportBatchSize: 512,
|
|
2416
|
+
scheduledDelayMillis: 5e3,
|
|
2417
|
+
exportTimeoutMillis: 3e4
|
|
2418
|
+
});
|
|
2419
|
+
axiomProvider = new import_sdk_trace_node.NodeTracerProvider({
|
|
2420
|
+
resource: (0, import_resources.resourceFromAttributes)({
|
|
2421
|
+
["service.name"]: "axiom",
|
|
2422
|
+
["service.version"]: "0.34.2"
|
|
2423
|
+
}),
|
|
2424
|
+
spanProcessors: [processor]
|
|
2425
|
+
});
|
|
2426
|
+
axiomTracer = axiomProvider.getTracer("axiom", "0.34.2");
|
|
2232
2427
|
}
|
|
2233
|
-
function
|
|
2234
|
-
if (
|
|
2235
|
-
|
|
2236
|
-
const num = Number(raw);
|
|
2237
|
-
if (!Number.isNaN(num) && raw.trim() === num.toString()) {
|
|
2238
|
-
return num;
|
|
2428
|
+
async function initInstrumentation(config) {
|
|
2429
|
+
if (initialized) {
|
|
2430
|
+
return;
|
|
2239
2431
|
}
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
return raw;
|
|
2432
|
+
if (initializationPromise) {
|
|
2433
|
+
await initializationPromise;
|
|
2434
|
+
return;
|
|
2244
2435
|
}
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
const parsed = JSON.parse(contents);
|
|
2251
|
-
if (typeof parsed !== "object" || Array.isArray(parsed) || parsed === null) {
|
|
2252
|
-
console.error(
|
|
2253
|
-
`\u274C Flags config must be a JSON object, got ${Array.isArray(parsed) ? "array" : typeof parsed}`
|
|
2254
|
-
);
|
|
2255
|
-
process.exit(1);
|
|
2436
|
+
initializationPromise = (async () => {
|
|
2437
|
+
if (!config.enabled) {
|
|
2438
|
+
axiomTracer = import_api10.trace.getTracer("axiom", "0.34.2");
|
|
2439
|
+
initialized = true;
|
|
2440
|
+
return;
|
|
2256
2441
|
}
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2442
|
+
const connection = resolveAxiomConnection(config.config);
|
|
2443
|
+
const hook = await resolveInstrumentationHook(config.config);
|
|
2444
|
+
let hookResult = void 0;
|
|
2445
|
+
if (hook) {
|
|
2446
|
+
config.config.eval.instrumentation = hook;
|
|
2447
|
+
hookResult = await runInstrumentationHook(hook, {
|
|
2448
|
+
dataset: connection.dataset,
|
|
2449
|
+
token: connection.token,
|
|
2450
|
+
url: connection.url,
|
|
2451
|
+
orgId: connection.orgId
|
|
2452
|
+
});
|
|
2453
|
+
userProvider = hookResult?.provider ?? userProvider;
|
|
2454
|
+
}
|
|
2455
|
+
setupEvalProvider(connection);
|
|
2456
|
+
if (!hook) {
|
|
2457
|
+
axiomProvider?.register();
|
|
2458
|
+
if (axiomTracer) {
|
|
2459
|
+
initAxiomAI({ tracer: axiomTracer });
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
initialized = true;
|
|
2463
|
+
})();
|
|
2464
|
+
try {
|
|
2465
|
+
await initializationPromise;
|
|
2466
|
+
} finally {
|
|
2467
|
+
initializationPromise = null;
|
|
2261
2468
|
}
|
|
2262
2469
|
}
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2470
|
+
var import_sdk_trace_node, import_resources, import_exporter_trace_otlp_http, import_api10, axiomProvider, axiomTracer, userProvider, initializationPromise, initialized, flush;
|
|
2471
|
+
var init_instrument = __esm({
|
|
2472
|
+
"src/evals/instrument.ts"() {
|
|
2473
|
+
"use strict";
|
|
2474
|
+
init_cjs_shims();
|
|
2475
|
+
import_sdk_trace_node = require("@opentelemetry/sdk-trace-node");
|
|
2476
|
+
import_resources = require("@opentelemetry/resources");
|
|
2477
|
+
import_exporter_trace_otlp_http = require("@opentelemetry/exporter-trace-otlp-http");
|
|
2478
|
+
import_api10 = require("@opentelemetry/api");
|
|
2479
|
+
init_initAxiomAI();
|
|
2480
|
+
init_resolver();
|
|
2481
|
+
init_errors();
|
|
2482
|
+
init_loader();
|
|
2483
|
+
initializationPromise = null;
|
|
2484
|
+
initialized = false;
|
|
2485
|
+
flush = async () => {
|
|
2486
|
+
if (initializationPromise) {
|
|
2487
|
+
await initializationPromise;
|
|
2278
2488
|
}
|
|
2279
|
-
const
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
if (!value) {
|
|
2283
|
-
console.error("\u274C --flags-config requires a file path");
|
|
2284
|
-
console.error("\u{1F4A1} Use: --flags-config=path/to/config.json");
|
|
2285
|
-
process.exit(1);
|
|
2489
|
+
const tasks = [];
|
|
2490
|
+
if (axiomProvider) {
|
|
2491
|
+
tasks.push(axiomProvider.forceFlush());
|
|
2286
2492
|
}
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
const
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
return { cleanedArgv: cleanedArgv2, overrides: configOverrides };
|
|
2493
|
+
const candidateProviders = /* @__PURE__ */ new Set();
|
|
2494
|
+
if (userProvider) {
|
|
2495
|
+
candidateProviders.add(userProvider);
|
|
2496
|
+
}
|
|
2497
|
+
const globalProvider = import_api10.trace.getTracerProvider();
|
|
2498
|
+
if (globalProvider) {
|
|
2499
|
+
candidateProviders.add(globalProvider);
|
|
2500
|
+
}
|
|
2501
|
+
for (const provider of candidateProviders) {
|
|
2502
|
+
const flushFn = provider.forceFlush;
|
|
2503
|
+
if (typeof flushFn === "function") {
|
|
2504
|
+
tasks.push(
|
|
2505
|
+
flushFn.call(provider).catch((error) => {
|
|
2506
|
+
console.warn("[AxiomAI] Failed to flush tracer provider:", errorToString(error));
|
|
2507
|
+
})
|
|
2508
|
+
);
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
if (tasks.length > 0) {
|
|
2512
|
+
await Promise.all(tasks);
|
|
2513
|
+
}
|
|
2514
|
+
};
|
|
2310
2515
|
}
|
|
2311
|
-
|
|
2312
|
-
}
|
|
2516
|
+
});
|
|
2313
2517
|
|
|
2314
|
-
// src/
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
}
|
|
2518
|
+
// src/evals/run-vitest.ts
|
|
2519
|
+
var run_vitest_exports = {};
|
|
2520
|
+
__export(run_vitest_exports, {
|
|
2521
|
+
runVitest: () => runVitest
|
|
2522
|
+
});
|
|
2523
|
+
var import_node_path2, import_node_fs2, import_node_os, import_node_path3, import_vite_tsconfig_paths, import_node, printCollectedEvals, runVitest;
|
|
2524
|
+
var init_run_vitest = __esm({
|
|
2525
|
+
"src/evals/run-vitest.ts"() {
|
|
2526
|
+
"use strict";
|
|
2527
|
+
init_cjs_shims();
|
|
2528
|
+
init_node();
|
|
2529
|
+
import_node_path2 = require("path");
|
|
2530
|
+
import_node_fs2 = require("fs");
|
|
2531
|
+
import_node_os = require("os");
|
|
2532
|
+
import_node_path3 = __toESM(require("path"), 1);
|
|
2533
|
+
import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
|
|
2534
|
+
import_node = require("vitest/node");
|
|
2535
|
+
init_reporter();
|
|
2536
|
+
init_instrument();
|
|
2537
|
+
init_storage();
|
|
2538
|
+
printCollectedEvals = (result, rootDir) => {
|
|
2539
|
+
if (!result.testModules || result.testModules.length === 0) {
|
|
2540
|
+
console.log(u.yellow("\nNo evaluations found\n"));
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
console.log(u.bold("\nFound evaluations:\n"));
|
|
2544
|
+
let totalEvals = 0;
|
|
2545
|
+
let totalCases = 0;
|
|
2546
|
+
for (const module2 of result.testModules) {
|
|
2547
|
+
const relativePath = import_node_path3.default.relative(rootDir, module2.moduleId);
|
|
2548
|
+
for (const suite of module2.children.suites()) {
|
|
2549
|
+
totalEvals++;
|
|
2550
|
+
const caseCount = suite.children.size;
|
|
2551
|
+
totalCases += caseCount;
|
|
2552
|
+
console.log(u.green(`\u2713 ${suite.name} (${caseCount} cases)`));
|
|
2553
|
+
console.log(u.dim(` ${relativePath}`));
|
|
2554
|
+
console.log("");
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
console.log(u.bold(`Total: ${totalEvals} evaluations, ${totalCases} test cases
|
|
2558
|
+
`));
|
|
2559
|
+
};
|
|
2560
|
+
runVitest = async (dir, opts) => {
|
|
2561
|
+
setAxiomConfig(opts.config);
|
|
2562
|
+
await initInstrumentation({
|
|
2563
|
+
enabled: !opts.debug && !opts.list,
|
|
2564
|
+
config: opts.config
|
|
2565
|
+
});
|
|
2566
|
+
const providedConfig = {
|
|
2567
|
+
...opts.config,
|
|
2568
|
+
eval: {
|
|
2569
|
+
...opts.config.eval,
|
|
2570
|
+
// These can't be serialized, so we need to remove them
|
|
2571
|
+
instrumentation: null,
|
|
2572
|
+
flagSchema: null
|
|
2573
|
+
}
|
|
2574
|
+
};
|
|
2575
|
+
if (opts.debug) {
|
|
2576
|
+
console.log(u.bgWhite(u.blackBright(" Debug mode enabled ")));
|
|
2577
|
+
}
|
|
2578
|
+
const tmpDir = (0, import_node_path2.join)((0, import_node_os.tmpdir)(), "axiom-eval", opts.runId);
|
|
2579
|
+
(0, import_node_fs2.mkdirSync)(tmpDir, { recursive: true });
|
|
2580
|
+
const nameRegistryFile = (0, import_node_path2.join)(tmpDir, "names.jsonl");
|
|
2581
|
+
const abortFile = (0, import_node_path2.join)(tmpDir, "abort.txt");
|
|
2582
|
+
(0, import_node_fs2.writeFileSync)(nameRegistryFile, "", "utf8");
|
|
2583
|
+
if ((0, import_node_fs2.existsSync)(abortFile)) {
|
|
2584
|
+
(0, import_node_fs2.unlinkSync)(abortFile);
|
|
2585
|
+
}
|
|
2586
|
+
process.env.AXIOM_NAME_REGISTRY_FILE = nameRegistryFile;
|
|
2587
|
+
process.env.AXIOM_ABORT_FILE = abortFile;
|
|
2588
|
+
if (opts.list) {
|
|
2589
|
+
console.log(u.bgWhite(u.blackBright(" List mode ")));
|
|
2590
|
+
}
|
|
2591
|
+
const vi = await (0, import_node.createVitest)(
|
|
2592
|
+
"test",
|
|
2593
|
+
{
|
|
2594
|
+
root: dir ? dir : process.cwd(),
|
|
2595
|
+
mode: "test",
|
|
2596
|
+
include: opts.include,
|
|
2597
|
+
exclude: opts.exclude,
|
|
2598
|
+
testNamePattern: opts.testNamePattern,
|
|
2599
|
+
reporters: ["verbose", new AxiomReporter()],
|
|
2600
|
+
environment: "node",
|
|
2601
|
+
browser: void 0,
|
|
2602
|
+
watch: opts.watch,
|
|
2603
|
+
setupFiles: [],
|
|
2604
|
+
// ignore user vitest.config.ts etc
|
|
2605
|
+
name: "axiom:eval",
|
|
2606
|
+
printConsoleTrace: true,
|
|
2607
|
+
silent: false,
|
|
2608
|
+
disableConsoleIntercept: true,
|
|
2609
|
+
testTimeout: opts.config?.eval?.timeoutMs || 6e4,
|
|
2610
|
+
globals: true,
|
|
2611
|
+
runner: (0, import_node_path2.resolve)(__dirname, "evals", "custom-runner.js"),
|
|
2612
|
+
provide: {
|
|
2613
|
+
baseline: opts.baseline,
|
|
2614
|
+
debug: opts.debug,
|
|
2615
|
+
list: opts.list,
|
|
2616
|
+
overrides: opts.overrides,
|
|
2617
|
+
axiomConfig: providedConfig,
|
|
2618
|
+
runId: opts.runId,
|
|
2619
|
+
consoleUrl: opts.consoleUrl
|
|
2620
|
+
}
|
|
2621
|
+
},
|
|
2622
|
+
{
|
|
2623
|
+
plugins: [(0, import_vite_tsconfig_paths.default)({ root: dir || process.cwd() })]
|
|
2624
|
+
}
|
|
2625
|
+
);
|
|
2626
|
+
if (opts.list) {
|
|
2627
|
+
const result = await vi.collect();
|
|
2628
|
+
printCollectedEvals(result, dir || process.cwd());
|
|
2629
|
+
await vi.close();
|
|
2630
|
+
process.exit(0);
|
|
2631
|
+
}
|
|
2632
|
+
await vi.start();
|
|
2633
|
+
if ((0, import_node_fs2.existsSync)(abortFile)) {
|
|
2634
|
+
const message = (0, import_node_fs2.readFileSync)(abortFile, "utf8");
|
|
2635
|
+
console.error("\n" + message);
|
|
2636
|
+
await vi.close();
|
|
2637
|
+
process.exit(1);
|
|
2638
|
+
}
|
|
2639
|
+
const dispose = (0, import_node.registerConsoleShortcuts)(vi, process.stdin, process.stdout);
|
|
2640
|
+
if (!vi.shouldKeepServer()) {
|
|
2641
|
+
dispose();
|
|
2642
|
+
await flush();
|
|
2643
|
+
await vi.close();
|
|
2644
|
+
process.exit(0);
|
|
2645
|
+
}
|
|
2646
|
+
await flush();
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
});
|
|
2319
2650
|
|
|
2320
2651
|
// src/cli/commands/eval.command.ts
|
|
2321
|
-
var createRunId = (0, import_nanoid.customAlphabet)("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 10);
|
|
2322
|
-
var consoleUrl;
|
|
2323
2652
|
function getConsoleUrl() {
|
|
2324
2653
|
return consoleUrl;
|
|
2325
2654
|
}
|
|
@@ -2344,93 +2673,136 @@ function getDefaultOrgId(value) {
|
|
|
2344
2673
|
const authContext2 = getAuthContext();
|
|
2345
2674
|
return authContext2?.orgId ?? process.env.AXIOM_ORG_ID;
|
|
2346
2675
|
}
|
|
2347
|
-
var
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
...options.dataset && { dataset: options.dataset },
|
|
2372
|
-
...options.orgId && { orgId: options.orgId }
|
|
2373
|
-
}
|
|
2374
|
-
};
|
|
2375
|
-
if (isGlobPattern) {
|
|
2376
|
-
include = [target];
|
|
2377
|
-
} else {
|
|
2676
|
+
var import_commander, import_nanoid, import_node_fs3, createRunId, consoleUrl, loadEvalCommand;
|
|
2677
|
+
var init_eval_command = __esm({
|
|
2678
|
+
"src/cli/commands/eval.command.ts"() {
|
|
2679
|
+
"use strict";
|
|
2680
|
+
init_cjs_shims();
|
|
2681
|
+
import_commander = require("commander");
|
|
2682
|
+
import_nanoid = require("nanoid");
|
|
2683
|
+
import_node_fs3 = require("fs");
|
|
2684
|
+
init_eval_context_runner();
|
|
2685
|
+
init_parse_flag_overrides();
|
|
2686
|
+
init_glob_utils();
|
|
2687
|
+
init_loader();
|
|
2688
|
+
init_errors();
|
|
2689
|
+
init_global_auth();
|
|
2690
|
+
init_node();
|
|
2691
|
+
createRunId = (0, import_nanoid.customAlphabet)("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", 10);
|
|
2692
|
+
loadEvalCommand = (program2, flagOverrides = {}) => {
|
|
2693
|
+
return program2.addCommand(
|
|
2694
|
+
new import_commander.Command("eval").description("run evals locally").addArgument(
|
|
2695
|
+
new import_commander.Argument("[target]", "file, directory, glob pattern, or eval name").default(
|
|
2696
|
+
".",
|
|
2697
|
+
"any *.eval.ts file in current directory"
|
|
2698
|
+
)
|
|
2699
|
+
).option("-w, --watch true", "keep server running and watch for changes", false).option("-t, --token <TOKEN>", "axiom token", getDefaultToken).option("-d, --dataset <DATASET>", "axiom dataset name", process.env.AXIOM_DATASET).option("-u, --url <AXIOM URL>", "axiom url", getDefaultUrl).option("-o, --org-id <ORG ID>", "axiom organization id", getDefaultOrgId).option("-b, --baseline <BASELINE ID>", "id of baseline evaluation to compare against").option("--debug", "run locally without any network operations", false).option("--list", "list evaluations and test cases without running them", false).addOption(new import_commander.Option("-c, --console-url <URL>", "console url override").hideHelp()).action(async (target, options) => {
|
|
2378
2700
|
try {
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2701
|
+
if (options.debug) {
|
|
2702
|
+
process.env.AXIOM_DEBUG = "true";
|
|
2703
|
+
}
|
|
2704
|
+
let include = [];
|
|
2705
|
+
let exclude;
|
|
2706
|
+
let testNamePattern;
|
|
2707
|
+
const isGlobPattern = isGlob(target);
|
|
2708
|
+
const { config: loadedConfig } = await loadConfig(".");
|
|
2709
|
+
validateFlagOverrides(flagOverrides, loadedConfig.eval.flagSchema);
|
|
2710
|
+
const config = {
|
|
2711
|
+
...loadedConfig,
|
|
2712
|
+
eval: {
|
|
2713
|
+
...loadedConfig.eval,
|
|
2714
|
+
...options.token && { token: options.token },
|
|
2715
|
+
...options.url && { url: options.url },
|
|
2716
|
+
...options.dataset && { dataset: options.dataset },
|
|
2717
|
+
...options.orgId && { orgId: options.orgId }
|
|
2718
|
+
}
|
|
2719
|
+
};
|
|
2720
|
+
if (isGlobPattern) {
|
|
2383
2721
|
include = [target];
|
|
2722
|
+
} else {
|
|
2723
|
+
try {
|
|
2724
|
+
const stat = (0, import_node_fs3.lstatSync)(target);
|
|
2725
|
+
if (stat.isDirectory()) {
|
|
2726
|
+
include = config?.eval?.include || [];
|
|
2727
|
+
} else {
|
|
2728
|
+
include = [target];
|
|
2729
|
+
}
|
|
2730
|
+
} catch {
|
|
2731
|
+
testNamePattern = new RegExp(target, "i");
|
|
2732
|
+
include = config?.eval?.include || [];
|
|
2733
|
+
}
|
|
2384
2734
|
}
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2735
|
+
exclude = config?.eval?.exclude;
|
|
2736
|
+
if (!config?.eval?.instrumentation) {
|
|
2737
|
+
console.warn(
|
|
2738
|
+
u.yellow(
|
|
2739
|
+
"\u26A0 App instrumentation (`eval.instrumentation` in `axiom.config.ts`) not configured. Using default provider."
|
|
2740
|
+
)
|
|
2741
|
+
);
|
|
2742
|
+
console.log("");
|
|
2743
|
+
}
|
|
2744
|
+
const runId = createRunId();
|
|
2745
|
+
consoleUrl = options.consoleUrl;
|
|
2746
|
+
let runVitestModule;
|
|
2747
|
+
try {
|
|
2748
|
+
runVitestModule = await Promise.resolve().then(() => (init_run_vitest(), run_vitest_exports));
|
|
2749
|
+
} catch (err) {
|
|
2750
|
+
if (err && typeof err === "object" && "code" in err && (err.code === "ERR_MODULE_NOT_FOUND" || err.code === "MODULE_NOT_FOUND")) {
|
|
2751
|
+
throw new AxiomCLIError("Failed to load vitest.");
|
|
2752
|
+
}
|
|
2753
|
+
throw err;
|
|
2754
|
+
}
|
|
2755
|
+
const { runVitest: runVitest2 } = runVitestModule;
|
|
2756
|
+
await runEvalWithContext(flagOverrides, async () => {
|
|
2757
|
+
return runVitest2(".", {
|
|
2758
|
+
watch: options.watch,
|
|
2759
|
+
baseline: options.baseline,
|
|
2760
|
+
include,
|
|
2761
|
+
exclude,
|
|
2762
|
+
testNamePattern,
|
|
2763
|
+
debug: options.debug,
|
|
2764
|
+
list: options.list,
|
|
2765
|
+
overrides: flagOverrides,
|
|
2766
|
+
config,
|
|
2767
|
+
runId,
|
|
2768
|
+
consoleUrl: options.consoleUrl
|
|
2769
|
+
});
|
|
2770
|
+
});
|
|
2771
|
+
} catch (error) {
|
|
2772
|
+
if (error instanceof AxiomCLIError) {
|
|
2773
|
+
console.error(`
|
|
2419
2774
|
\u274C ${error.message}
|
|
2420
2775
|
`);
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
};
|
|
2776
|
+
process.exit(1);
|
|
2777
|
+
}
|
|
2778
|
+
throw error;
|
|
2779
|
+
}
|
|
2780
|
+
})
|
|
2781
|
+
);
|
|
2782
|
+
};
|
|
2783
|
+
}
|
|
2784
|
+
});
|
|
2785
|
+
|
|
2786
|
+
// src/bin.ts
|
|
2787
|
+
var bin_exports = {};
|
|
2788
|
+
__export(bin_exports, {
|
|
2789
|
+
program: () => program
|
|
2790
|
+
});
|
|
2791
|
+
module.exports = __toCommonJS(bin_exports);
|
|
2792
|
+
init_cjs_shims();
|
|
2793
|
+
var import_commander3 = require("commander");
|
|
2794
|
+
init_eval_command();
|
|
2428
2795
|
|
|
2429
2796
|
// src/cli/commands/auth.command.ts
|
|
2430
2797
|
init_cjs_shims();
|
|
2431
2798
|
|
|
2432
2799
|
// src/cli/commands/auth-login.command.ts
|
|
2433
2800
|
init_cjs_shims();
|
|
2801
|
+
init_oauth();
|
|
2802
|
+
init_callback_server();
|
|
2803
|
+
init_config();
|
|
2804
|
+
init_api();
|
|
2805
|
+
init_errors();
|
|
2434
2806
|
var BASE_HOSTNAME = "axiom.co";
|
|
2435
2807
|
var getApiUrl = (hostname) => {
|
|
2436
2808
|
return `https://api.${hostname}`;
|
|
@@ -2583,6 +2955,8 @@ function loadAuthLoginCommand(auth, root) {
|
|
|
2583
2955
|
|
|
2584
2956
|
// src/cli/commands/auth-logout.command.ts
|
|
2585
2957
|
init_cjs_shims();
|
|
2958
|
+
init_config();
|
|
2959
|
+
init_errors();
|
|
2586
2960
|
async function logoutCommand(alias) {
|
|
2587
2961
|
const config = await loadGlobalConfig();
|
|
2588
2962
|
const profileToRemove = alias || config.active_profile;
|
|
@@ -2628,6 +3002,9 @@ function loadAuthLogoutCommand(auth, root) {
|
|
|
2628
3002
|
|
|
2629
3003
|
// src/cli/commands/auth-status.command.ts
|
|
2630
3004
|
init_cjs_shims();
|
|
3005
|
+
init_config();
|
|
3006
|
+
init_api();
|
|
3007
|
+
init_errors();
|
|
2631
3008
|
async function statusCommand() {
|
|
2632
3009
|
const config = await loadGlobalConfig();
|
|
2633
3010
|
if (Object.keys(config.profiles).length === 0) {
|
|
@@ -2693,6 +3070,8 @@ function loadAuthStatusCommand(auth, program2) {
|
|
|
2693
3070
|
|
|
2694
3071
|
// src/cli/commands/auth-switch.command.ts
|
|
2695
3072
|
init_cjs_shims();
|
|
3073
|
+
init_config();
|
|
3074
|
+
init_errors();
|
|
2696
3075
|
async function promptSelect2(message, choices) {
|
|
2697
3076
|
console.log(`
|
|
2698
3077
|
${message}`);
|
|
@@ -2788,6 +3167,8 @@ function loadAuthCommand(program2) {
|
|
|
2788
3167
|
}
|
|
2789
3168
|
|
|
2790
3169
|
// src/bin.ts
|
|
3170
|
+
init_parse_flag_overrides();
|
|
3171
|
+
init_global_auth();
|
|
2791
3172
|
var import_env = __toESM(require("@next/env"), 1);
|
|
2792
3173
|
|
|
2793
3174
|
// src/cli/commands/version.command.ts
|
|
@@ -2796,7 +3177,7 @@ var import_commander2 = require("commander");
|
|
|
2796
3177
|
var loadVersionCommand = (program2) => {
|
|
2797
3178
|
return program2.addCommand(
|
|
2798
3179
|
new import_commander2.Command("version").description("cli version").action(() => {
|
|
2799
|
-
console.log("0.34.
|
|
3180
|
+
console.log("0.34.2");
|
|
2800
3181
|
})
|
|
2801
3182
|
);
|
|
2802
3183
|
};
|
|
@@ -2806,7 +3187,7 @@ var { loadEnvConfig } = import_env.default;
|
|
|
2806
3187
|
loadEnvConfig(process.cwd());
|
|
2807
3188
|
var { cleanedArgv, overrides } = extractOverrides(process.argv.slice(2));
|
|
2808
3189
|
var program = new import_commander3.Command();
|
|
2809
|
-
program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.34.
|
|
3190
|
+
program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.34.2");
|
|
2810
3191
|
program.hook("preAction", async (_, actionCommand) => {
|
|
2811
3192
|
const commandName = actionCommand.name();
|
|
2812
3193
|
const parentCommand = actionCommand.parent;
|