agent-inspect 6.17.0 → 6.17.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.
@@ -7036,6 +7036,18 @@ function stringAttr(event, keys) {
7036
7036
  }
7037
7037
  return void 0;
7038
7038
  }
7039
+ function metadataStringAttr(event, keys) {
7040
+ const metadata = event.attributes?.metadata;
7041
+ if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata)) {
7042
+ return void 0;
7043
+ }
7044
+ const record = metadata;
7045
+ for (const key of keys) {
7046
+ const value = record[key];
7047
+ if (typeof value === "string" && value.trim() !== "") return value;
7048
+ }
7049
+ return void 0;
7050
+ }
7039
7051
  function numericAttr(event, keys) {
7040
7052
  for (const key of keys) {
7041
7053
  const value = event.attributes?.[key];
@@ -7094,13 +7106,16 @@ function semanticEvents(context) {
7094
7106
  return context.logicalEvents ?? context.events;
7095
7107
  }
7096
7108
  function llmModel(event) {
7097
- return stringAttr(event, ["model", "modelId", "responseModelId", "modelName", "model_name"]) ?? stripPrefix(event.name, ["llm:", "generation:", "transcription:", "speech:"]);
7109
+ const keys = ["model", "modelId", "responseModelId", "modelName", "model_name"];
7110
+ return stringAttr(event, keys) ?? metadataStringAttr(event, keys) ?? stripPrefix(event.name, ["llm:", "generation:", "transcription:", "speech:"]);
7098
7111
  }
7099
7112
  function llmProvider(event) {
7100
- return stringAttr(event, ["provider", "providerName", "provider_name"]);
7113
+ const keys = ["provider", "providerName", "provider_name"];
7114
+ return stringAttr(event, keys) ?? metadataStringAttr(event, keys);
7101
7115
  }
7102
7116
  function llmFinishReason(event) {
7103
- return stringAttr(event, ["finishReason", "rawFinishReason", "finish_reason"]);
7117
+ const keys = ["finishReason", "rawFinishReason", "finish_reason"];
7118
+ return stringAttr(event, keys) ?? metadataStringAttr(event, keys);
7104
7119
  }
7105
7120
  function retryCount(event) {
7106
7121
  return numericAttr(event, ["retryCount", "retryAttempt", "retry_attempt", "attempt"]);
@@ -12486,7 +12501,7 @@ var init_src = __esm({
12486
12501
  });
12487
12502
 
12488
12503
  // package.json
12489
- var version = "6.17.0";
12504
+ var version = "6.17.2";
12490
12505
 
12491
12506
  // packages/cli/src/list.ts
12492
12507
  init_advanced();
@@ -18347,6 +18362,58 @@ function mergeSafetyExtensions(result, read, options) {
18347
18362
  }
18348
18363
 
18349
18364
  // packages/cli/src/check.ts
18365
+ var DEFAULT_SELECT = ["run.status"];
18366
+ function uniqueSelectIds(ids) {
18367
+ const seen = /* @__PURE__ */ new Set();
18368
+ const out = [];
18369
+ for (const id of ids) {
18370
+ const trimmed = id.trim();
18371
+ if (trimmed === "" || seen.has(trimmed)) continue;
18372
+ seen.add(trimmed);
18373
+ out.push(trimmed);
18374
+ }
18375
+ return out;
18376
+ }
18377
+ function cliShorthandSelectIds(options) {
18378
+ const ids = [];
18379
+ if (options.failOnObservation !== void 0 && options.failOnObservation.trim() !== "") {
18380
+ ids.push("outcome.status");
18381
+ }
18382
+ if ((options.requiredTool?.length ?? 0) > 0 || (options.forbiddenTool?.length ?? 0) > 0) {
18383
+ ids.push("tool.usage");
18384
+ }
18385
+ if ((options.allowedModel?.length ?? 0) > 0 || options.maxTotalTokens !== void 0) {
18386
+ ids.push("llm.usage");
18387
+ }
18388
+ if (options.maxDurationMs !== void 0) {
18389
+ ids.push("run.duration");
18390
+ }
18391
+ if (options.maxStepDuration !== void 0) {
18392
+ ids.push("run.maxStepDuration");
18393
+ }
18394
+ if (options.detectStalls === true) {
18395
+ ids.push("run.stall");
18396
+ }
18397
+ return ids;
18398
+ }
18399
+ function unionCheckSelect(input3) {
18400
+ const explicit = uniqueSelectIds([
18401
+ ...input3.presetSelect ?? [],
18402
+ ...input3.explicitRules ?? [],
18403
+ ...input3.configSelect ?? []
18404
+ ]);
18405
+ if (explicit.length === 0) {
18406
+ return uniqueSelectIds([
18407
+ ...DEFAULT_SELECT,
18408
+ ...(input3.constructedRuleIds ?? []).filter((id) => id !== "run.status")
18409
+ ]);
18410
+ }
18411
+ const constructed = new Set(input3.constructedRuleIds ?? []);
18412
+ const shorthand = (input3.shorthandIds ?? []).filter(
18413
+ (id) => constructed.size === 0 || constructed.has(id)
18414
+ );
18415
+ return uniqueSelectIds([...explicit, ...shorthand]);
18416
+ }
18350
18417
  function resolvePreset(preset, context = {}) {
18351
18418
  if (preset === void 0 || preset.trim() === "") return void 0;
18352
18419
  const name = preset.trim().toLowerCase();
@@ -18395,7 +18462,6 @@ function resolvePreset(preset, context = {}) {
18395
18462
  select
18396
18463
  };
18397
18464
  }
18398
- var DEFAULT_SELECT = ["run.status"];
18399
18465
  var CONFIG_EXTENSIONS2 = /* @__PURE__ */ new Set([".json", ".js", ".mjs", ".cjs"]);
18400
18466
  var TS_CONFIG_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".mts", ".cts"]);
18401
18467
  function diagnostic5(code, message, severity = "error") {
@@ -18487,12 +18553,11 @@ function applyResolvedPreset(config, options, resolved) {
18487
18553
  config: { checks: checks2 },
18488
18554
  options: {
18489
18555
  ...options,
18490
- ...resolved.requireCompleted ? { requireCompleted: true } : {},
18491
- rule: [...resolved.select, ...options.rule ?? []]
18556
+ ...resolved.requireCompleted ? { requireCompleted: true } : {}
18492
18557
  }
18493
18558
  };
18494
18559
  }
18495
- function buildRules(config, options) {
18560
+ function buildRules(config, options, presetSelect = []) {
18496
18561
  const diagnostics = [];
18497
18562
  const checks2 = normalizeConfig(config);
18498
18563
  const run = checks2.run ?? {};
@@ -18582,21 +18647,15 @@ function buildRules(config, options) {
18582
18647
  if (safety.maxStringLength !== void 0 || safety.maxArrayLength !== void 0 || safety.maxObjectKeys !== void 0 || safety.maxSerializedBytes !== void 0) {
18583
18648
  rules.push(createSafetyOversizedAttributeRule(safety));
18584
18649
  }
18585
- const select = [
18586
- ...asStringArray2(checks2.select) ?? [],
18587
- ...options.rule ?? []
18588
- ];
18589
- if (select.length === 0) {
18590
- const auto = new Set(DEFAULT_SELECT);
18591
- for (const rule of rules) {
18592
- if (rule.id !== "run.status") auto.add(rule.id);
18593
- }
18594
- return {
18595
- rules,
18596
- select: [...auto],
18597
- diagnostics
18598
- };
18599
- }
18650
+ const constructedRuleIds = rules.map((rule) => rule.id);
18651
+ const shorthandIds = cliShorthandSelectIds(options);
18652
+ const select = unionCheckSelect({
18653
+ presetSelect,
18654
+ explicitRules: options.rule ?? [],
18655
+ configSelect: asStringArray2(checks2.select) ?? [],
18656
+ shorthandIds,
18657
+ constructedRuleIds
18658
+ });
18600
18659
  return {
18601
18660
  rules,
18602
18661
  select,
@@ -18725,7 +18784,7 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
18725
18784
  config = applied.config;
18726
18785
  effectiveOptions = applied.options;
18727
18786
  }
18728
- const built = buildRules(config, effectiveOptions);
18787
+ const built = buildRules(config, effectiveOptions, resolved?.select ?? []);
18729
18788
  if (built.diagnostics.some((item) => item.severity === "error")) {
18730
18789
  result = errorResult2("AI_CHECK_INVALID_CONFIG", "Invalid check configuration.");
18731
18790
  result.diagnostics = [...built.diagnostics];
@@ -24834,11 +24893,17 @@ function createCliProgram() {
24834
24893
  });
24835
24894
  bundleCmd.command("verify").description("Verify Evidence v2 integrity (manifest, hashes, presence)").argument("<path>", "evidence/bundle directory containing evidence.json").addOption(
24836
24895
  new commander.Option("--unexpected <mode>", "policy for files not listed in the manifest").choices(["fail", "warn", "ignore"]).default("fail")
24837
- ).option("--json", "print deterministic JSON verify result").action((targetPath, opts) => {
24838
- runCommand(() => bundleVerifyCommand(targetPath, opts));
24896
+ ).option("--json", "print deterministic JSON verify result").action((targetPath, opts, command) => {
24897
+ const merged = {
24898
+ ...opts,
24899
+ ...command.optsWithGlobals?.() ?? {}
24900
+ };
24901
+ const json = opts.json === true || merged.json === true || process.argv.includes("--json");
24902
+ runCommand(() => bundleVerifyCommand(targetPath, { ...opts, json }));
24839
24903
  });
24840
24904
  bundleCmd.command("open").description("Verify then open local Evidence HTML in the platform browser (no network)").argument("<path>", "evidence/bundle directory or evidence.html path").option("--skip-verify", "skip integrity verify before open (not recommended)").option("--json", "print deterministic JSON open result").action((targetPath, opts) => {
24841
- runCommand(() => bundleOpenCommand(targetPath, opts));
24905
+ const json = opts.json === true || process.argv.includes("--json");
24906
+ runCommand(() => bundleOpenCommand(targetPath, { ...opts, json }));
24842
24907
  });
24843
24908
  program.command("ci-summary").description("Summarize local reporter artifact manifests for CI").argument("<manifest...>", "reporter artifact manifest JSON files").option("-o, --output <path>", "write Markdown summary to a local file").option("--github-summary <path>", "append Markdown summary to this local file, e.g. GITHUB_STEP_SUMMARY").option("--json", "print deterministic JSON summary").action((manifest, opts) => {
24844
24909
  runCommand(() => ciSummaryCommand(manifest, opts));