axiom 0.33.0 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  import { ZodObject, ZodDefault, z } from 'zod';
2
- import { $ZodObject } from 'zod/v4/core';
3
2
 
4
3
  type ValidChars =
5
4
  | 'a'
@@ -88,7 +87,7 @@ type HasDefaults<S> = S extends {
88
87
  defaultValue: unknown;
89
88
  };
90
89
  };
91
- } ? true : S extends $ZodObject<infer Shape> | ZodObject<infer Shape> ? {
90
+ } ? true : S extends ZodObject<infer Shape> ? {
92
91
  [K in keyof Shape]: HasDefaults<Shape[K]>;
93
92
  } extends Record<keyof Shape, true> ? true : false : false;
94
93
  type UnwrapSchema<T> = T extends ZodDefault<infer U> ? U : T;
@@ -1,5 +1,4 @@
1
1
  import { ZodObject, ZodDefault, z } from 'zod';
2
- import { $ZodObject } from 'zod/v4/core';
3
2
 
4
3
  type ValidChars =
5
4
  | 'a'
@@ -88,7 +87,7 @@ type HasDefaults<S> = S extends {
88
87
  defaultValue: unknown;
89
88
  };
90
89
  };
91
- } ? true : S extends $ZodObject<infer Shape> | ZodObject<infer Shape> ? {
90
+ } ? true : S extends ZodObject<infer Shape> ? {
92
91
  [K in keyof Shape]: HasDefaults<Shape[K]>;
93
92
  } extends Record<keyof Shape, true> ? true : false : false;
94
93
  type UnwrapSchema<T> = T extends ZodDefault<infer U> ? U : T;
package/dist/bin.cjs CHANGED
@@ -245,7 +245,7 @@ function setGlobalFlagOverrides(overrides2) {
245
245
 
246
246
  // src/validate-flags.ts
247
247
  init_cjs_shims();
248
- var import_zod3 = require("zod");
248
+ var import_zod4 = require("zod");
249
249
 
250
250
  // src/cli/utils/format-zod-errors.ts
251
251
  init_cjs_shims();
@@ -349,6 +349,113 @@ function generateExampleForIssue(issue, path3) {
349
349
  // src/util/dot-path.ts
350
350
  init_cjs_shims();
351
351
  var import_zod2 = require("zod");
352
+
353
+ // src/util/zod-internals.ts
354
+ init_cjs_shims();
355
+ function isZodV4Schema(schema) {
356
+ if (!schema || typeof schema !== "object") return false;
357
+ const s2 = schema;
358
+ return "_zod" in s2;
359
+ }
360
+ function assertZodV4(schema, context5) {
361
+ if (!isZodV4Schema(schema)) {
362
+ throw new Error(
363
+ `[AxiomAI] Zod v4 schemas are required (detected in ${context5}). Found unsupported Zod version.`
364
+ );
365
+ }
366
+ }
367
+ function getDef(schema) {
368
+ if (!schema || typeof schema !== "object") return void 0;
369
+ const s2 = schema;
370
+ if (s2._zod && typeof s2._zod === "object") {
371
+ const zod = s2._zod;
372
+ if (zod.def && typeof zod.def === "object") {
373
+ return zod.def;
374
+ }
375
+ }
376
+ return void 0;
377
+ }
378
+ function getDefRawType(def) {
379
+ if (!def) return void 0;
380
+ const raw = def.type;
381
+ if (raw == null) return void 0;
382
+ return typeof raw === "string" ? raw : String(raw);
383
+ }
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
+ function getKind(schemaOrDef) {
399
+ const def = schemaOrDef && typeof schemaOrDef === "object" && "type" in schemaOrDef ? schemaOrDef : getDef(schemaOrDef);
400
+ const raw = getDefRawType(def);
401
+ if (!raw) return void 0;
402
+ const normalized = raw.toLowerCase();
403
+ return KNOWN_KINDS.has(normalized) ? normalized : "other";
404
+ }
405
+ function isObjectSchema(schema) {
406
+ if (!schema || typeof schema !== "object") return false;
407
+ if ("shape" in schema && typeof schema.shape === "object") {
408
+ return true;
409
+ }
410
+ return getKind(schema) === "object";
411
+ }
412
+ function getInnerType(schema) {
413
+ const def = getDef(schema);
414
+ return def?.innerType;
415
+ }
416
+ function getArrayElement(schema) {
417
+ const def = getDef(schema);
418
+ return def?.element;
419
+ }
420
+ function getShape(schema) {
421
+ if (!schema || typeof schema !== "object") return void 0;
422
+ const s2 = schema;
423
+ if (s2.shape && typeof s2.shape === "object") {
424
+ return s2.shape;
425
+ }
426
+ return void 0;
427
+ }
428
+ function getDefaultValue(schema) {
429
+ const def = getDef(schema);
430
+ return def?.defaultValue;
431
+ }
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
+ function unwrapTransparent(schema) {
443
+ let current = schema;
444
+ for (let i = 0; i < 10; i++) {
445
+ const kind = getKind(current);
446
+ if (!kind) break;
447
+ if (TRANSPARENT_WRAPPERS.includes(kind)) {
448
+ const inner = getInnerType(current);
449
+ if (!inner) break;
450
+ current = inner;
451
+ continue;
452
+ }
453
+ break;
454
+ }
455
+ return current;
456
+ }
457
+
458
+ // src/util/dot-path.ts
352
459
  function parsePath(path3) {
353
460
  return path3.split(".");
354
461
  }
@@ -387,16 +494,14 @@ function isValidPath(schema, segments) {
387
494
  let currentSchema = schema;
388
495
  for (let i = 0; i < segments.length; i++) {
389
496
  const segment = segments[i];
390
- if (!currentSchema.shape || !(segment in currentSchema.shape)) {
497
+ const shape = getShape(currentSchema);
498
+ if (!shape || !(segment in shape)) {
391
499
  return false;
392
500
  }
393
501
  if (i < segments.length - 1) {
394
- const nextSchema = currentSchema.shape[segment];
395
- let unwrappedSchema = nextSchema;
396
- while (unwrappedSchema?._def?.innerType || unwrappedSchema?._def?.schema) {
397
- unwrappedSchema = unwrappedSchema._def.innerType || unwrappedSchema._def.schema;
398
- }
399
- if (!unwrappedSchema || unwrappedSchema._def?.type !== "object") {
502
+ const nextSchema = shape[segment];
503
+ const unwrappedSchema = unwrapTransparent(nextSchema);
504
+ if (!isObjectSchema(unwrappedSchema)) {
400
505
  return false;
401
506
  }
402
507
  currentSchema = unwrappedSchema;
@@ -405,9 +510,62 @@ function isValidPath(schema, segments) {
405
510
  return true;
406
511
  }
407
512
 
513
+ // src/util/deep-partial-schema.ts
514
+ init_cjs_shims();
515
+ var import_zod3 = require("zod");
516
+ function makeDeepPartial(schema) {
517
+ const shape = schema.shape;
518
+ const newShape = {};
519
+ for (const [key, value] of Object.entries(shape)) {
520
+ newShape[key] = makeDeepPartialField(value);
521
+ }
522
+ return import_zod3.z.object(newShape);
523
+ }
524
+ function makeDeepPartialField(fieldSchema) {
525
+ const kind = getKind(fieldSchema);
526
+ if (isObjectSchema(fieldSchema)) {
527
+ const partialObject = makeDeepPartial(fieldSchema);
528
+ return partialObject.optional();
529
+ }
530
+ if (kind === "optional") {
531
+ const inner = getInnerType(fieldSchema);
532
+ if (inner && isObjectSchema(inner)) {
533
+ const partialInner = makeDeepPartial(inner);
534
+ return partialInner.optional();
535
+ }
536
+ return fieldSchema;
537
+ }
538
+ if (kind === "nullable") {
539
+ const inner = getInnerType(fieldSchema);
540
+ if (inner && isObjectSchema(inner)) {
541
+ const partialInner = makeDeepPartial(inner);
542
+ return partialInner.nullable().optional();
543
+ }
544
+ return fieldSchema.optional();
545
+ }
546
+ if (kind === "default") {
547
+ const inner = getInnerType(fieldSchema);
548
+ const defaultValue = getDefaultValue(fieldSchema);
549
+ if (inner && isObjectSchema(inner)) {
550
+ const partialInner = makeDeepPartial(inner);
551
+ return partialInner.default(defaultValue);
552
+ }
553
+ return fieldSchema.optional();
554
+ }
555
+ if (kind === "array") {
556
+ const element = getArrayElement(fieldSchema);
557
+ if (element && isObjectSchema(element)) {
558
+ const partialElement = makeDeepPartial(element);
559
+ return import_zod3.z.array(partialElement).optional();
560
+ }
561
+ return fieldSchema.optional();
562
+ }
563
+ return fieldSchema.optional();
564
+ }
565
+
408
566
  // src/app-scope.ts
409
567
  var import_api8 = require("@opentelemetry/api");
410
- var import_zod4 = require("zod");
568
+ var import_zod5 = require("zod");
411
569
 
412
570
  // src/otel/utils/to-otel-attribute.ts
413
571
  init_cjs_shims();
@@ -448,7 +606,7 @@ var import_api4 = require("@opentelemetry/api");
448
606
  // package.json
449
607
  var package_default = {
450
608
  name: "axiom",
451
- version: "0.33.0",
609
+ version: "0.34.1",
452
610
  type: "module",
453
611
  author: "Axiom, Inc.",
454
612
  contributors: [
@@ -687,104 +845,6 @@ function withEvalContext(options = {}, fn) {
687
845
 
688
846
  // src/evals/reporter.console-utils.ts
689
847
  init_cjs_shims();
690
-
691
- // src/util/deep-equal.ts
692
- init_cjs_shims();
693
- function deepEqual(data, other) {
694
- if (data === other) {
695
- return true;
696
- }
697
- if (Object.is(data, other)) {
698
- return true;
699
- }
700
- if (typeof data !== "object" || typeof other !== "object") {
701
- return false;
702
- }
703
- if (data === null || other === null) {
704
- return false;
705
- }
706
- if (Object.getPrototypeOf(data) !== Object.getPrototypeOf(other)) {
707
- return false;
708
- }
709
- if (Array.isArray(data)) {
710
- return isDeepEqualArrays(data, other);
711
- }
712
- if (data instanceof Map) {
713
- return isDeepEqualMaps(data, other);
714
- }
715
- if (data instanceof Set) {
716
- return isDeepEqualSets(data, other);
717
- }
718
- if (data instanceof Date) {
719
- return data.getTime() === other.getTime();
720
- }
721
- if (data instanceof RegExp) {
722
- return data.toString() === other.toString();
723
- }
724
- if (Object.keys(data).length !== Object.keys(other).length) {
725
- return false;
726
- }
727
- for (const [key, value] of Object.entries(data)) {
728
- if (!(key in other)) {
729
- return false;
730
- }
731
- if (!deepEqual(
732
- value,
733
- // @ts-expect-error [ts7053] - We already checked that `other` has `key`
734
- other[key]
735
- )) {
736
- return false;
737
- }
738
- }
739
- return true;
740
- }
741
- function isDeepEqualArrays(data, other) {
742
- if (data.length !== other.length) {
743
- return false;
744
- }
745
- for (const [index, item] of data.entries()) {
746
- if (!deepEqual(item, other[index])) {
747
- return false;
748
- }
749
- }
750
- return true;
751
- }
752
- function isDeepEqualMaps(data, other) {
753
- if (data.size !== other.size) {
754
- return false;
755
- }
756
- for (const [key, value] of data.entries()) {
757
- if (!other.has(key)) {
758
- return false;
759
- }
760
- if (!deepEqual(value, other.get(key))) {
761
- return false;
762
- }
763
- }
764
- return true;
765
- }
766
- function isDeepEqualSets(data, other) {
767
- if (data.size !== other.size) {
768
- return false;
769
- }
770
- const otherCopy = [...other];
771
- for (const dataItem of data) {
772
- let isFound = false;
773
- for (const [index, otherItem] of otherCopy.entries()) {
774
- if (deepEqual(dataItem, otherItem)) {
775
- isFound = true;
776
- otherCopy.splice(index, 1);
777
- break;
778
- }
779
- }
780
- if (!isFound) {
781
- return false;
782
- }
783
- }
784
- return true;
785
- }
786
-
787
- // src/evals/reporter.console-utils.ts
788
848
  function formatPercentage(value) {
789
849
  if (!Number.isFinite(value)) {
790
850
  return "N/A";
@@ -971,47 +1031,6 @@ function printOrphanedBaselineCases(baseline, matchedIndices, logger = console.l
971
1031
  }
972
1032
  }
973
1033
  }
974
- function printConfigHeader(logger = console.log) {
975
- logger("");
976
- logger(" ", u.bgWhite(u.blackBright(" Config ")));
977
- }
978
- function printConfigEnd(configEnd, logger = console.log) {
979
- printConfigHeader(logger);
980
- maybePrintFlags(configEnd, logger);
981
- }
982
- function maybePrintFlags(configEnd, logger = console.log) {
983
- const defaults = configEnd?.flags ?? {};
984
- const overrides2 = configEnd?.overrides ?? {};
985
- const defaultKeys = Object.keys(defaults);
986
- const overrideKeys = Object.keys(overrides2);
987
- const allKeys = Array.from(/* @__PURE__ */ new Set([...defaultKeys, ...overrideKeys])).sort();
988
- if (allKeys.length === 0) {
989
- return;
990
- }
991
- for (const key of allKeys) {
992
- const hasDefault = key in defaults;
993
- const hasOverride = key in overrides2;
994
- if (hasDefault && hasOverride) {
995
- const defVal = defaults[key];
996
- const ovVal = overrides2[key];
997
- const changed = !deepEqual(ovVal, defVal);
998
- const ovText = truncate(stringify(ovVal), 80);
999
- const defText = truncate(stringify(defVal), 80);
1000
- if (changed) {
1001
- logger(" ", `${key}: ${ovText} ${u.dim(`(overridden by CLI, original: ${defText})`)}`);
1002
- } else {
1003
- logger(" ", `${key}: ${defText}`);
1004
- }
1005
- } else if (hasOverride) {
1006
- const ovText = truncate(stringify(overrides2[key]), 80);
1007
- logger(" ", `${key}: ${ovText} ${u.dim("(added by CLI)")}`);
1008
- } else if (hasDefault) {
1009
- const defText = truncate(stringify(defaults[key]), 80);
1010
- logger(" ", `${key}: ${defText}`);
1011
- }
1012
- }
1013
- logger("");
1014
- }
1015
1034
  var reporterDate = (d) => {
1016
1035
  const date = d.toISOString().slice(0, 10);
1017
1036
  const hours = d.getUTCHours().toString().padStart(2, "0");
@@ -1364,16 +1383,13 @@ var AxiomReporter = class {
1364
1383
  registered: suite.registrationStatus?.status === "success",
1365
1384
  error: suite.registrationStatus?.status === "failed" ? suite.registrationStatus.error : void 0
1366
1385
  }));
1367
- const DEBUG = process.env.AXIOM_DEBUG === "true";
1386
+ const isDebug = process.env.AXIOM_DEBUG === "true";
1368
1387
  printFinalReport({
1369
1388
  suiteData: this._suiteData,
1370
1389
  config: this._config,
1371
1390
  registrationStatus,
1372
- isDebug: DEBUG
1391
+ isDebug
1373
1392
  });
1374
- if (DEBUG && this._endOfRunConfigEnd) {
1375
- printConfigEnd(this._endOfRunConfigEnd);
1376
- }
1377
1393
  }
1378
1394
  };
1379
1395
 
@@ -1433,7 +1449,7 @@ var import_defu = require("defu");
1433
1449
 
1434
1450
  // src/config/index.ts
1435
1451
  init_cjs_shims();
1436
- var import_zod5 = require("zod");
1452
+ var import_zod6 = require("zod");
1437
1453
 
1438
1454
  // src/cli/auth/index.ts
1439
1455
  init_cjs_shims();
@@ -1795,20 +1811,23 @@ function createPartialDefaults() {
1795
1811
  }
1796
1812
  function validateConfig(config) {
1797
1813
  const errors = [];
1798
- if (!config.eval?.token) {
1799
- errors.push(
1800
- "eval.token is required (set in axiom.config.ts or AXIOM_TOKEN environment variable)"
1801
- );
1802
- }
1803
- if (!config.eval?.dataset) {
1804
- errors.push(
1805
- "eval.dataset is required (set in axiom.config.ts or AXIOM_DATASET environment variable)"
1806
- );
1807
- }
1808
- if (!config.eval?.url) {
1809
- console.log(
1810
- "eval.url was not specified. Defaulting to `https://api.axiom.co`. Please set it in axiom.config.ts or AXIOM_URL environment variable if you want to use a different endpoint."
1811
- );
1814
+ const isDebug = process.env.AXIOM_DEBUG === "true";
1815
+ if (!isDebug) {
1816
+ if (!config.eval?.token) {
1817
+ errors.push(
1818
+ "eval.token is required (set in axiom.config.ts or AXIOM_TOKEN environment variable)"
1819
+ );
1820
+ }
1821
+ if (!config.eval?.dataset) {
1822
+ errors.push(
1823
+ "eval.dataset is required (set in axiom.config.ts or AXIOM_DATASET environment variable)"
1824
+ );
1825
+ }
1826
+ if (!config.eval?.url) {
1827
+ console.log(
1828
+ "eval.url was not specified. Defaulting to `https://api.axiom.co`. Please set it in axiom.config.ts or AXIOM_URL environment variable if you want to use a different endpoint."
1829
+ );
1830
+ }
1812
1831
  }
1813
1832
  const instrumentation = config.eval?.instrumentation;
1814
1833
  if (instrumentation !== null && instrumentation !== void 0 && typeof instrumentation !== "function") {
@@ -1911,11 +1930,11 @@ function setupEvalProvider(connection) {
1911
1930
  axiomProvider = new import_sdk_trace_node.NodeTracerProvider({
1912
1931
  resource: (0, import_resources.resourceFromAttributes)({
1913
1932
  ["service.name"]: "axiom",
1914
- ["service.version"]: "0.33.0"
1933
+ ["service.version"]: "0.34.1"
1915
1934
  }),
1916
1935
  spanProcessors: [processor]
1917
1936
  });
1918
- axiomTracer = axiomProvider.getTracer("axiom", "0.33.0");
1937
+ axiomTracer = axiomProvider.getTracer("axiom", "0.34.1");
1919
1938
  }
1920
1939
  async function initInstrumentation(config) {
1921
1940
  if (initialized) {
@@ -1927,7 +1946,7 @@ async function initInstrumentation(config) {
1927
1946
  }
1928
1947
  initializationPromise = (async () => {
1929
1948
  if (!config.enabled) {
1930
- axiomTracer = import_api10.trace.getTracer("axiom", "0.33.0");
1949
+ axiomTracer = import_api10.trace.getTracer("axiom", "0.34.1");
1931
1950
  initialized = true;
1932
1951
  return;
1933
1952
  }
@@ -2147,7 +2166,7 @@ async function runEvalWithContext(overrides2, runFn) {
2147
2166
 
2148
2167
  // src/cli/utils/parse-flag-overrides.ts
2149
2168
  init_cjs_shims();
2150
- var import_zod6 = require("zod");
2169
+ var import_zod7 = require("zod");
2151
2170
  var import_node_fs2 = require("fs");
2152
2171
  var import_node_path3 = require("path");
2153
2172
  var FLAG_RE = /^--flag\.([^=]+)(?:=(.*))?$/;
@@ -2169,6 +2188,7 @@ function collectFlagValidationErrors(overrides2, flagSchema) {
2169
2188
  if (!flagSchema || Object.keys(overrides2).length === 0) {
2170
2189
  return { success: true, errors: [] };
2171
2190
  }
2191
+ assertZodV4(flagSchema, "flagSchema");
2172
2192
  const schema = flagSchema;
2173
2193
  const errors = [];
2174
2194
  for (const dotPath of Object.keys(overrides2)) {
@@ -2181,7 +2201,8 @@ function collectFlagValidationErrors(overrides2, flagSchema) {
2181
2201
  return { success: false, errors };
2182
2202
  }
2183
2203
  const nestedObject = dotNotationToNested(overrides2);
2184
- const result = schema.strict().partial().safeParse(nestedObject);
2204
+ const deepPartialSchema = makeDeepPartial(schema);
2205
+ const result = deepPartialSchema.safeParse(nestedObject);
2185
2206
  if (!result.success) {
2186
2207
  errors.push({ type: "invalid_value", zodError: result.error });
2187
2208
  }
@@ -2330,7 +2351,7 @@ var loadEvalCommand = (program2, flagOverrides = {}) => {
2330
2351
  ".",
2331
2352
  "any *.eval.ts file in current directory"
2332
2353
  )
2333
- ).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 sending to Axiom or loading baselines", 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) => {
2354
+ ).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) => {
2334
2355
  try {
2335
2356
  if (options.debug) {
2336
2357
  process.env.AXIOM_DEBUG = "true";
@@ -2775,7 +2796,7 @@ var import_commander2 = require("commander");
2775
2796
  var loadVersionCommand = (program2) => {
2776
2797
  return program2.addCommand(
2777
2798
  new import_commander2.Command("version").description("cli version").action(() => {
2778
- console.log("0.33.0");
2799
+ console.log("0.34.1");
2779
2800
  })
2780
2801
  );
2781
2802
  };
@@ -2785,7 +2806,7 @@ var { loadEnvConfig } = import_env.default;
2785
2806
  loadEnvConfig(process.cwd());
2786
2807
  var { cleanedArgv, overrides } = extractOverrides(process.argv.slice(2));
2787
2808
  var program = new import_commander3.Command();
2788
- program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.33.0");
2809
+ program.name("axiom").description("Axiom's CLI to manage your objects and run evals").version("0.34.1");
2789
2810
  program.hook("preAction", async (_, actionCommand) => {
2790
2811
  const commandName = actionCommand.name();
2791
2812
  const parentCommand = actionCommand.parent;