agent-inspect 6.17.1 → 6.17.3

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.
@@ -2765,7 +2765,12 @@ function countErrorNodes(nodes) {
2765
2765
  return nodes.filter((entry) => entry.node.event.status === "error").length;
2766
2766
  }
2767
2767
  function slowestNode(nodes) {
2768
- return nodes.filter((entry) => entry.node.event.durationMs !== void 0).sort((a, b) => {
2768
+ return nodes.filter(
2769
+ (entry) => entry.node.event.durationMs !== void 0 && // The RUN boundary spans the whole run, so its duration always dominates
2770
+ // and shadows every real step. Rank actual work nodes only, matching the
2771
+ // stats slowest-step ranking, which never counts the run envelope.
2772
+ entry.node.event.kind !== "RUN"
2773
+ ).sort((a, b) => {
2769
2774
  const delta = (b.node.event.durationMs ?? 0) - (a.node.event.durationMs ?? 0);
2770
2775
  return delta !== 0 ? delta : a.index - b.index;
2771
2776
  })[0];
@@ -7036,6 +7041,18 @@ function stringAttr(event, keys) {
7036
7041
  }
7037
7042
  return void 0;
7038
7043
  }
7044
+ function metadataStringAttr(event, keys) {
7045
+ const metadata = event.attributes?.metadata;
7046
+ if (typeof metadata !== "object" || metadata === null || Array.isArray(metadata)) {
7047
+ return void 0;
7048
+ }
7049
+ const record = metadata;
7050
+ for (const key of keys) {
7051
+ const value = record[key];
7052
+ if (typeof value === "string" && value.trim() !== "") return value;
7053
+ }
7054
+ return void 0;
7055
+ }
7039
7056
  function numericAttr(event, keys) {
7040
7057
  for (const key of keys) {
7041
7058
  const value = event.attributes?.[key];
@@ -7094,13 +7111,16 @@ function semanticEvents(context) {
7094
7111
  return context.logicalEvents ?? context.events;
7095
7112
  }
7096
7113
  function llmModel(event) {
7097
- return stringAttr(event, ["model", "modelId", "responseModelId", "modelName", "model_name"]) ?? stripPrefix(event.name, ["llm:", "generation:", "transcription:", "speech:"]);
7114
+ const keys = ["model", "modelId", "responseModelId", "modelName", "model_name"];
7115
+ return stringAttr(event, keys) ?? metadataStringAttr(event, keys) ?? stripPrefix(event.name, ["llm:", "generation:", "transcription:", "speech:"]);
7098
7116
  }
7099
7117
  function llmProvider(event) {
7100
- return stringAttr(event, ["provider", "providerName", "provider_name"]);
7118
+ const keys = ["provider", "providerName", "provider_name"];
7119
+ return stringAttr(event, keys) ?? metadataStringAttr(event, keys);
7101
7120
  }
7102
7121
  function llmFinishReason(event) {
7103
- return stringAttr(event, ["finishReason", "rawFinishReason", "finish_reason"]);
7122
+ const keys = ["finishReason", "rawFinishReason", "finish_reason"];
7123
+ return stringAttr(event, keys) ?? metadataStringAttr(event, keys);
7104
7124
  }
7105
7125
  function retryCount(event) {
7106
7126
  return numericAttr(event, ["retryCount", "retryAttempt", "retry_attempt", "attempt"]);
@@ -12486,7 +12506,7 @@ var init_src = __esm({
12486
12506
  });
12487
12507
 
12488
12508
  // package.json
12489
- var version = "6.17.1";
12509
+ var version = "6.17.3";
12490
12510
 
12491
12511
  // packages/cli/src/list.ts
12492
12512
  init_advanced();
@@ -18347,6 +18367,58 @@ function mergeSafetyExtensions(result, read, options) {
18347
18367
  }
18348
18368
 
18349
18369
  // packages/cli/src/check.ts
18370
+ var DEFAULT_SELECT = ["run.status"];
18371
+ function uniqueSelectIds(ids) {
18372
+ const seen = /* @__PURE__ */ new Set();
18373
+ const out = [];
18374
+ for (const id of ids) {
18375
+ const trimmed = id.trim();
18376
+ if (trimmed === "" || seen.has(trimmed)) continue;
18377
+ seen.add(trimmed);
18378
+ out.push(trimmed);
18379
+ }
18380
+ return out;
18381
+ }
18382
+ function cliShorthandSelectIds(options) {
18383
+ const ids = [];
18384
+ if (options.failOnObservation !== void 0 && options.failOnObservation.trim() !== "") {
18385
+ ids.push("outcome.status");
18386
+ }
18387
+ if ((options.requiredTool?.length ?? 0) > 0 || (options.forbiddenTool?.length ?? 0) > 0) {
18388
+ ids.push("tool.usage");
18389
+ }
18390
+ if ((options.allowedModel?.length ?? 0) > 0 || options.maxTotalTokens !== void 0) {
18391
+ ids.push("llm.usage");
18392
+ }
18393
+ if (options.maxDurationMs !== void 0) {
18394
+ ids.push("run.duration");
18395
+ }
18396
+ if (options.maxStepDuration !== void 0) {
18397
+ ids.push("run.maxStepDuration");
18398
+ }
18399
+ if (options.detectStalls === true) {
18400
+ ids.push("run.stall");
18401
+ }
18402
+ return ids;
18403
+ }
18404
+ function unionCheckSelect(input3) {
18405
+ const explicit = uniqueSelectIds([
18406
+ ...input3.presetSelect ?? [],
18407
+ ...input3.explicitRules ?? [],
18408
+ ...input3.configSelect ?? []
18409
+ ]);
18410
+ if (explicit.length === 0) {
18411
+ return uniqueSelectIds([
18412
+ ...DEFAULT_SELECT,
18413
+ ...(input3.constructedRuleIds ?? []).filter((id) => id !== "run.status")
18414
+ ]);
18415
+ }
18416
+ const constructed = new Set(input3.constructedRuleIds ?? []);
18417
+ const shorthand = (input3.shorthandIds ?? []).filter(
18418
+ (id) => constructed.size === 0 || constructed.has(id)
18419
+ );
18420
+ return uniqueSelectIds([...explicit, ...shorthand]);
18421
+ }
18350
18422
  function resolvePreset(preset, context = {}) {
18351
18423
  if (preset === void 0 || preset.trim() === "") return void 0;
18352
18424
  const name = preset.trim().toLowerCase();
@@ -18395,7 +18467,6 @@ function resolvePreset(preset, context = {}) {
18395
18467
  select
18396
18468
  };
18397
18469
  }
18398
- var DEFAULT_SELECT = ["run.status"];
18399
18470
  var CONFIG_EXTENSIONS2 = /* @__PURE__ */ new Set([".json", ".js", ".mjs", ".cjs"]);
18400
18471
  var TS_CONFIG_EXTENSIONS2 = /* @__PURE__ */ new Set([".ts", ".mts", ".cts"]);
18401
18472
  function diagnostic5(code, message, severity = "error") {
@@ -18487,12 +18558,11 @@ function applyResolvedPreset(config, options, resolved) {
18487
18558
  config: { checks: checks2 },
18488
18559
  options: {
18489
18560
  ...options,
18490
- ...resolved.requireCompleted ? { requireCompleted: true } : {},
18491
- rule: [...resolved.select, ...options.rule ?? []]
18561
+ ...resolved.requireCompleted ? { requireCompleted: true } : {}
18492
18562
  }
18493
18563
  };
18494
18564
  }
18495
- function buildRules(config, options) {
18565
+ function buildRules(config, options, presetSelect = []) {
18496
18566
  const diagnostics = [];
18497
18567
  const checks2 = normalizeConfig(config);
18498
18568
  const run = checks2.run ?? {};
@@ -18582,21 +18652,15 @@ function buildRules(config, options) {
18582
18652
  if (safety.maxStringLength !== void 0 || safety.maxArrayLength !== void 0 || safety.maxObjectKeys !== void 0 || safety.maxSerializedBytes !== void 0) {
18583
18653
  rules.push(createSafetyOversizedAttributeRule(safety));
18584
18654
  }
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
- }
18655
+ const constructedRuleIds = rules.map((rule) => rule.id);
18656
+ const shorthandIds = cliShorthandSelectIds(options);
18657
+ const select = unionCheckSelect({
18658
+ presetSelect,
18659
+ explicitRules: options.rule ?? [],
18660
+ configSelect: asStringArray2(checks2.select) ?? [],
18661
+ shorthandIds,
18662
+ constructedRuleIds
18663
+ });
18600
18664
  return {
18601
18665
  rules,
18602
18666
  select,
@@ -18725,7 +18789,7 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
18725
18789
  config = applied.config;
18726
18790
  effectiveOptions = applied.options;
18727
18791
  }
18728
- const built = buildRules(config, effectiveOptions);
18792
+ const built = buildRules(config, effectiveOptions, resolved?.select ?? []);
18729
18793
  if (built.diagnostics.some((item) => item.severity === "error")) {
18730
18794
  result = errorResult2("AI_CHECK_INVALID_CONFIG", "Invalid check configuration.");
18731
18795
  result.diagnostics = [...built.diagnostics];