agent-inspect 6.12.0 → 6.12.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +27 -6
  3. package/docs/ADOPTION.md +1 -1
  4. package/docs/DEMO-SCRIPT.md +30 -25
  5. package/docs/DESIGN-PARTNER-GUIDE.md +23 -10
  6. package/docs/FIRST-TRACE-IN-5-MINUTES.md +5 -2
  7. package/docs/GOLDEN-PATH.md +2 -2
  8. package/docs/KNOWN-ISSUES.md +1 -0
  9. package/docs/PRE-V7-PILOT-KIT.md +41 -15
  10. package/docs/SUPPORT-LEVELS.md +1 -1
  11. package/docs/TEAM-WORKFLOWS.md +1 -1
  12. package/docs/TECHNICAL-GUIDE.md +2 -2
  13. package/docs/USE-CASES.md +34 -10
  14. package/package.json +2 -2
  15. package/packages/cli/dist/{chunk-XTAA733P.mjs → chunk-4WA7DQCM.mjs} +316 -55
  16. package/packages/cli/dist/chunk-4WA7DQCM.mjs.map +1 -0
  17. package/packages/cli/dist/index.cjs +337 -70
  18. package/packages/cli/dist/index.cjs.map +1 -1
  19. package/packages/cli/dist/index.mjs +4 -4
  20. package/packages/cli/dist/index.mjs.map +1 -1
  21. package/packages/cli/dist/{src-G7PM24W2.mjs → src-YAASTXGE.mjs} +3 -3
  22. package/packages/cli/dist/{src-G7PM24W2.mjs.map → src-YAASTXGE.mjs.map} +1 -1
  23. package/packages/core/dist/advanced.cjs +290 -30
  24. package/packages/core/dist/advanced.cjs.map +1 -1
  25. package/packages/core/dist/advanced.d.cts +1 -1
  26. package/packages/core/dist/advanced.d.ts +1 -1
  27. package/packages/core/dist/advanced.mjs +1 -1
  28. package/packages/core/dist/checks.cjs +295 -30
  29. package/packages/core/dist/checks.cjs.map +1 -1
  30. package/packages/core/dist/checks.d.cts +2 -2
  31. package/packages/core/dist/checks.d.ts +2 -2
  32. package/packages/core/dist/checks.mjs +1 -1
  33. package/packages/core/dist/{chunk-QT6CQ2XA.mjs → chunk-KJICERSD.mjs} +296 -33
  34. package/packages/core/dist/chunk-KJICERSD.mjs.map +1 -0
  35. package/packages/core/dist/{index-mdFcxSOR.d.cts → index-BOP33T4O.d.cts} +72 -1
  36. package/packages/core/dist/{index-BO7l0iAe.d.ts → index-CgCH8NE9.d.ts} +72 -1
  37. package/packages/cli/dist/chunk-XTAA733P.mjs.map +0 -1
  38. package/packages/core/dist/chunk-QT6CQ2XA.mjs.map +0 -1
@@ -603,12 +603,12 @@ function persistedInspectEventToTraceEvents(event) {
603
603
  if (!isPersistedInspectEvent(event)) {
604
604
  throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
605
605
  }
606
- const legacyEvent = event.attributes?.legacyEvent;
607
- if (legacyEvent === "run_started") return [fromLegacyRunStarted(event)];
608
- if (legacyEvent === "run_completed") return [fromLegacyRunCompleted(event)];
609
- if (legacyEvent === "step_started") return [fromLegacyStepStarted(event)];
610
- if (legacyEvent === "step_completed") return [fromLegacyStepCompleted(event)];
611
- if (legacyEvent === "outcome_observed") return [fromLegacyOutcomeObserved(event)];
606
+ const legacyEvent2 = event.attributes?.legacyEvent;
607
+ if (legacyEvent2 === "run_started") return [fromLegacyRunStarted(event)];
608
+ if (legacyEvent2 === "run_completed") return [fromLegacyRunCompleted(event)];
609
+ if (legacyEvent2 === "step_started") return [fromLegacyStepStarted(event)];
610
+ if (legacyEvent2 === "step_completed") return [fromLegacyStepCompleted(event)];
611
+ if (legacyEvent2 === "outcome_observed") return [fromLegacyOutcomeObserved(event)];
612
612
  if (event.kind === "RUN") {
613
613
  return fromNativeRun(event);
614
614
  }
@@ -5850,6 +5850,260 @@ function defaultSuiteConfigTemplate() {
5850
5850
  };
5851
5851
  }
5852
5852
 
5853
+ // packages/core/src/checks/logical-events.ts
5854
+ function isRecord7(value) {
5855
+ return typeof value === "object" && value !== null && !Array.isArray(value);
5856
+ }
5857
+ function legacyEvent(event) {
5858
+ const value = event.attributes?.legacyEvent;
5859
+ return typeof value === "string" ? value : void 0;
5860
+ }
5861
+ function stepIdOf(event) {
5862
+ const value = event.attributes?.stepId;
5863
+ if (typeof value === "string" && value.trim() !== "") return value;
5864
+ return void 0;
5865
+ }
5866
+ function cloneEvent(event) {
5867
+ return {
5868
+ ...event,
5869
+ ...event.attributes !== void 0 ? { attributes: { ...event.attributes } } : {},
5870
+ ...event.error !== void 0 ? { error: { ...event.error } } : {},
5871
+ ...event.tokenUsage !== void 0 ? { tokenUsage: { ...event.tokenUsage } } : {},
5872
+ ...event.source !== void 0 ? { source: { ...event.source } } : {}
5873
+ };
5874
+ }
5875
+ function mergeAttributes(start, complete) {
5876
+ const merged = {
5877
+ ...isRecord7(complete.attributes) ? complete.attributes : {},
5878
+ ...isRecord7(start.attributes) ? start.attributes : {}
5879
+ };
5880
+ merged.legacyEvent = start.attributes?.legacyEvent ?? complete.attributes?.legacyEvent;
5881
+ merged.legacyCompleteEvent = complete.attributes?.legacyEvent;
5882
+ if (complete.attributes?.errorStack !== void 0) {
5883
+ merged.errorStack = complete.attributes.errorStack;
5884
+ }
5885
+ return Object.keys(merged).length > 0 ? merged : void 0;
5886
+ }
5887
+ function pairStartComplete(start, complete) {
5888
+ const attributes = mergeAttributes(start, complete);
5889
+ const paired = {
5890
+ ...cloneEvent(start),
5891
+ status: complete.status,
5892
+ timestamp: complete.timestamp ?? start.timestamp,
5893
+ ...complete.endedAt !== void 0 ? { endedAt: complete.endedAt } : {},
5894
+ ...complete.durationMs !== void 0 ? { durationMs: complete.durationMs } : {},
5895
+ ...complete.error !== void 0 ? { error: { ...complete.error } } : {},
5896
+ ...complete.tokenUsage !== void 0 && start.tokenUsage === void 0 ? { tokenUsage: { ...complete.tokenUsage } } : {},
5897
+ ...attributes !== void 0 ? { attributes } : {}
5898
+ };
5899
+ return {
5900
+ ...paired,
5901
+ sourceEventIds: Object.freeze([start.eventId, complete.eventId]),
5902
+ projection: {
5903
+ paired: true,
5904
+ absorbedEventIds: Object.freeze([complete.eventId]),
5905
+ parentNormalized: false,
5906
+ ...start.parentId !== void 0 ? { originalParentId: start.parentId } : {}
5907
+ }
5908
+ };
5909
+ }
5910
+ function asLogical(event, extras) {
5911
+ return {
5912
+ ...cloneEvent(event),
5913
+ sourceEventIds: Object.freeze([event.eventId]),
5914
+ projection: {
5915
+ paired: false,
5916
+ absorbedEventIds: Object.freeze([]),
5917
+ parentNormalized: extras?.parentNormalized === true,
5918
+ ...{}
5919
+ }
5920
+ };
5921
+ }
5922
+ function projectLogicalEvents(events) {
5923
+ const diagnostics = [];
5924
+ const byRun = /* @__PURE__ */ new Map();
5925
+ for (const event of events) {
5926
+ const list = byRun.get(event.runId) ?? [];
5927
+ list.push(event);
5928
+ byRun.set(event.runId, list);
5929
+ }
5930
+ const absorbedIds = /* @__PURE__ */ new Set();
5931
+ const logicalByRawId = /* @__PURE__ */ new Map();
5932
+ const stepIdToLogicalId = /* @__PURE__ */ new Map();
5933
+ const logical = [];
5934
+ const orderedRuns = [...byRun.keys()].sort((a, b) => a.localeCompare(b));
5935
+ for (const runId of orderedRuns) {
5936
+ const runEvents = byRun.get(runId) ?? [];
5937
+ const starts = [];
5938
+ const completes = [];
5939
+ const others = [];
5940
+ for (const event of runEvents) {
5941
+ const legacy = legacyEvent(event);
5942
+ if (legacy === "step_started" || legacy === "run_started" && event.status === "running") {
5943
+ starts.push(event);
5944
+ } else if (legacy === "step_completed" || legacy === "run_completed") {
5945
+ completes.push(event);
5946
+ } else {
5947
+ others.push(event);
5948
+ }
5949
+ }
5950
+ const usedCompletes = /* @__PURE__ */ new Set();
5951
+ for (const start of starts) {
5952
+ const stepId = stepIdOf(start);
5953
+ let match;
5954
+ if (legacyEvent(start) === "run_started") {
5955
+ const candidates = completes.filter(
5956
+ (c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "run_completed"
5957
+ );
5958
+ if (candidates.length > 1) {
5959
+ diagnostics.push({
5960
+ code: "AI_LOGICAL_PAIR_AMBIGUOUS",
5961
+ message: `Multiple run_completed rows for run ${runId}; using first by eventId.`,
5962
+ eventIds: candidates.map((c) => c.eventId)
5963
+ });
5964
+ candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
5965
+ }
5966
+ match = candidates[0];
5967
+ } else if (stepId) {
5968
+ const candidates = completes.filter(
5969
+ (c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "step_completed" && stepIdOf(c) === stepId
5970
+ );
5971
+ if (candidates.length > 1) {
5972
+ diagnostics.push({
5973
+ code: "AI_LOGICAL_PAIR_AMBIGUOUS",
5974
+ message: `Multiple step_completed rows for stepId ${stepId}; using first by eventId.`,
5975
+ eventIds: candidates.map((c) => c.eventId)
5976
+ });
5977
+ candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
5978
+ }
5979
+ match = candidates[0];
5980
+ }
5981
+ if (match) {
5982
+ usedCompletes.add(match.eventId);
5983
+ absorbedIds.add(match.eventId);
5984
+ const paired = pairStartComplete(start, match);
5985
+ logical.push(paired);
5986
+ logicalByRawId.set(start.eventId, paired);
5987
+ logicalByRawId.set(match.eventId, paired);
5988
+ if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, paired.eventId);
5989
+ } else {
5990
+ diagnostics.push({
5991
+ code: "AI_LOGICAL_PAIR_UNMATCHED_START",
5992
+ message: `No matching complete for start ${start.eventId}.`,
5993
+ eventIds: [start.eventId]
5994
+ });
5995
+ const alone = asLogical(start);
5996
+ logical.push(alone);
5997
+ logicalByRawId.set(start.eventId, alone);
5998
+ if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
5999
+ }
6000
+ }
6001
+ for (const complete of completes) {
6002
+ if (usedCompletes.has(complete.eventId)) continue;
6003
+ diagnostics.push({
6004
+ code: "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE",
6005
+ message: `No matching start for complete ${complete.eventId}.`,
6006
+ eventIds: [complete.eventId]
6007
+ });
6008
+ const alone = asLogical(complete);
6009
+ logical.push(alone);
6010
+ logicalByRawId.set(complete.eventId, alone);
6011
+ const stepId = stepIdOf(complete);
6012
+ if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
6013
+ stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
6014
+ }
6015
+ }
6016
+ for (const event of others) {
6017
+ const alone = asLogical(event);
6018
+ logical.push(alone);
6019
+ logicalByRawId.set(event.eventId, alone);
6020
+ const stepId = stepIdOf(event);
6021
+ if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
6022
+ stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
6023
+ }
6024
+ }
6025
+ }
6026
+ const logicalById = new Map(logical.map((e) => [e.eventId, e]));
6027
+ const normalized = [];
6028
+ for (const event of logical) {
6029
+ const originalParentId = event.parentId;
6030
+ if (!originalParentId) {
6031
+ normalized.push(event);
6032
+ continue;
6033
+ }
6034
+ let nextParent = originalParentId;
6035
+ let remapped = false;
6036
+ const viaAbsorbed = logicalByRawId.get(originalParentId);
6037
+ if (viaAbsorbed && viaAbsorbed.eventId !== originalParentId) {
6038
+ nextParent = viaAbsorbed.eventId;
6039
+ remapped = true;
6040
+ } else if (!logicalById.has(originalParentId)) {
6041
+ const viaStep = stepIdToLogicalId.get(`${event.runId}:${originalParentId}`);
6042
+ if (viaStep) {
6043
+ nextParent = viaStep;
6044
+ remapped = true;
6045
+ }
6046
+ }
6047
+ if (!remapped) {
6048
+ if (!logicalById.has(originalParentId) && !logicalByRawId.has(originalParentId)) {
6049
+ diagnostics.push({
6050
+ code: "AI_LOGICAL_PARENT_UNRESOLVED",
6051
+ message: `Parent ${originalParentId} unresolved for ${event.eventId}.`,
6052
+ eventIds: [event.eventId]
6053
+ });
6054
+ }
6055
+ normalized.push(event);
6056
+ continue;
6057
+ }
6058
+ diagnostics.push({
6059
+ code: "AI_LOGICAL_PARENT_REMAPPED",
6060
+ message: `Remapped parent ${originalParentId} \u2192 ${nextParent} for ${event.eventId}.`,
6061
+ eventIds: [event.eventId]
6062
+ });
6063
+ normalized.push({
6064
+ ...event,
6065
+ parentId: nextParent,
6066
+ projection: {
6067
+ ...event.projection,
6068
+ parentNormalized: true,
6069
+ originalParentId
6070
+ }
6071
+ });
6072
+ }
6073
+ const rawIndex = new Map(events.map((e, i) => [e.eventId, i]));
6074
+ normalized.sort((a, b) => {
6075
+ const ai = rawIndex.get(a.sourceEventIds[0]) ?? 0;
6076
+ const bi = rawIndex.get(b.sourceEventIds[0]) ?? 0;
6077
+ return ai - bi || a.eventId.localeCompare(b.eventId);
6078
+ });
6079
+ return {
6080
+ logicalEvents: Object.freeze(normalized),
6081
+ diagnostics: Object.freeze(diagnostics)
6082
+ };
6083
+ }
6084
+ function resolveCanonicalToolName(event) {
6085
+ const attrs = event.attributes;
6086
+ const direct = pickString(attrs, ["toolName", "tool"]);
6087
+ if (direct) return direct;
6088
+ const metadata = attrs?.metadata;
6089
+ if (isRecord7(metadata)) {
6090
+ const nested = pickString(metadata, ["toolName", "tool"]);
6091
+ if (nested) return nested;
6092
+ }
6093
+ for (const prefix of ["tool:", "function:", "mcp-tools:"]) {
6094
+ if (event.name.startsWith(prefix)) return event.name.slice(prefix.length);
6095
+ }
6096
+ return event.name;
6097
+ }
6098
+ function pickString(record, keys) {
6099
+ if (!record) return void 0;
6100
+ for (const key of keys) {
6101
+ const value = record[key];
6102
+ if (typeof value === "string" && value.trim() !== "") return value.trim();
6103
+ }
6104
+ return void 0;
6105
+ }
6106
+
5853
6107
  // packages/core/src/checks/index.ts
5854
6108
  var SEVERITY_RANK = {
5855
6109
  error: 0,
@@ -5908,7 +6162,11 @@ var DEFAULT_RAW_CONTENT_KEYS = [
5908
6162
  "conversationtext",
5909
6163
  "conversation_text"
5910
6164
  ];
5911
- var DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES = ["tokenUsage", "usage"];
6165
+ var DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES = [
6166
+ "tokenUsage",
6167
+ "usage",
6168
+ "tokens"
6169
+ ];
5912
6170
  var SAFE_USAGE_LEAF_KEYS = /* @__PURE__ */ new Set([
5913
6171
  "input",
5914
6172
  "output",
@@ -5984,10 +6242,13 @@ function buildFacts2(input, selectedRun) {
5984
6242
  childrenByParentId.set(parentId, children);
5985
6243
  }
5986
6244
  }
6245
+ const projection = projectLogicalEvents(scopedEvents);
5987
6246
  return {
5988
6247
  format: input.read.format,
5989
6248
  runs: Object.freeze([...input.read.runs]),
5990
6249
  events: Object.freeze([...scopedEvents]),
6250
+ logicalEvents: projection.logicalEvents,
6251
+ logicalProjectionDiagnostics: projection.diagnostics,
5991
6252
  readerWarnings: Object.freeze([...input.read.warnings]),
5992
6253
  unsupportedFields: Object.freeze([...input.read.unsupportedFields]),
5993
6254
  sourceFiles: Object.freeze([...input.read.sourceFiles]),
@@ -6180,7 +6441,10 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
6180
6441
  };
6181
6442
  }
6182
6443
  function toolName(event) {
6183
- return stringAttr(event, ["toolName", "tool"]) ?? stripPrefix(event.name, ["tool:", "function:", "mcp-tools:"]);
6444
+ return resolveCanonicalToolName(event);
6445
+ }
6446
+ function semanticEvents(context) {
6447
+ return context.logicalEvents ?? context.events;
6184
6448
  }
6185
6449
  function llmModel(event) {
6186
6450
  return stringAttr(event, ["model", "modelId", "responseModelId", "modelName", "model_name"]) ?? stripPrefix(event.name, ["llm:", "generation:", "transcription:", "speech:"]);
@@ -6195,11 +6459,11 @@ function retryCount(event) {
6195
6459
  return numericAttr(event, ["retryCount", "retryAttempt", "retry_attempt", "attempt"]);
6196
6460
  }
6197
6461
  function finishedEvents(context, kind) {
6198
- return context.events.filter(
6462
+ return semanticEvents(context).filter(
6199
6463
  (event) => (kind === void 0 || event.kind === kind) && event.status !== "running"
6200
6464
  );
6201
6465
  }
6202
- function isRecord7(value) {
6466
+ function isRecord8(value) {
6203
6467
  return typeof value === "object" && value !== null && !Array.isArray(value);
6204
6468
  }
6205
6469
  function eventMap(events) {
@@ -6250,7 +6514,7 @@ function pushValueEntries(entries, event, value, path14, key, depth = 0) {
6250
6514
  }
6251
6515
  return;
6252
6516
  }
6253
- if (!isRecord7(value)) return;
6517
+ if (!isRecord8(value)) return;
6254
6518
  for (const nestedKey of Object.keys(value).sort((a, b) => a.localeCompare(b))) {
6255
6519
  pushValueEntries(
6256
6520
  entries,
@@ -6330,14 +6594,11 @@ function signalName(event, attributeKeys, prefixes) {
6330
6594
  return stringAttr(event, attributeKeys) ?? stripPrefix(event.name, prefixes);
6331
6595
  }
6332
6596
  function guardrailEvents(context) {
6333
- return finishedEvents2().filter((event) => {
6597
+ return finishedEvents(context).filter((event) => {
6334
6598
  const name = event.name.toLowerCase();
6335
6599
  if (name.startsWith("guardrail:") || name.includes(".guardrail.")) return true;
6336
6600
  return stringAttr(event, ["guardrailName", "guardrail", "guardrailId"]) !== void 0;
6337
6601
  });
6338
- function finishedEvents2() {
6339
- return context.events.filter((event) => event.status !== "running");
6340
- }
6341
6602
  }
6342
6603
  function retryValue(event) {
6343
6604
  return retryCount(event) ?? 0;
@@ -6358,7 +6619,7 @@ function treeShape(nodes) {
6358
6619
  return lines;
6359
6620
  }
6360
6621
  function statusShape(context) {
6361
- return context.events.map((event) => `${event.kind}:${event.name}:${event.status ?? "unknown"}`).sort((a, b) => a.localeCompare(b));
6622
+ return semanticEvents(context).map((event) => `${event.kind}:${event.name}:${event.status ?? "unknown"}`).sort((a, b) => a.localeCompare(b));
6362
6623
  }
6363
6624
  function toolShape(context) {
6364
6625
  return finishedEvents(context, "TOOL").map(
@@ -6384,7 +6645,7 @@ function llmShape(context) {
6384
6645
  );
6385
6646
  }
6386
6647
  function errorShape(context) {
6387
- return context.events.filter((event) => event.status === "error" || event.error !== void 0).map(
6648
+ return semanticEvents(context).filter((event) => event.status === "error" || event.error !== void 0).map(
6388
6649
  (event) => [
6389
6650
  event.kind,
6390
6651
  event.name,
@@ -6402,7 +6663,7 @@ function guardrailShape(context) {
6402
6663
  return guardrailEvents(context).map((event) => signalName(event, ["guardrailName", "guardrail", "guardrailId"], ["guardrail:"])).sort((a, b) => a.localeCompare(b));
6403
6664
  }
6404
6665
  function firstEvidenceForKind(context, kind, path14) {
6405
- const event = context.events.find((candidate) => candidate.kind === kind);
6666
+ const event = semanticEvents(context).find((candidate) => candidate.kind === kind);
6406
6667
  return event ? [eventEvidence(event, path14)] : runEvidence(context.selectedRun);
6407
6668
  }
6408
6669
  function baselineDiffFinding(message, evidence, expected, actual) {
@@ -6430,7 +6691,7 @@ function createRunStatusRule(options = {}) {
6430
6691
  );
6431
6692
  }
6432
6693
  if (!allowIncomplete) {
6433
- const running = context.events.filter((event) => event.status === "running");
6694
+ const running = semanticEvents(context).filter((event) => event.status === "running");
6434
6695
  if (running.length > 0) {
6435
6696
  findings.push(
6436
6697
  failFinding(
@@ -6473,7 +6734,7 @@ function createMaxStepDurationRule(options) {
6473
6734
  category: "run",
6474
6735
  defaultSeverity: "error",
6475
6736
  evaluate(context) {
6476
- const over = context.events.filter((event) => {
6737
+ const over = semanticEvents(context).filter((event) => {
6477
6738
  const duration = eventDurationMs(event);
6478
6739
  return duration !== void 0 && duration > options.maxDurationMs;
6479
6740
  });
@@ -6502,7 +6763,7 @@ function createStallDetectionRule(options = {}) {
6502
6763
  defaultSeverity: "warning",
6503
6764
  evaluate(context) {
6504
6765
  const findings = [];
6505
- const running = context.events.filter((event) => event.status === "running");
6766
+ const running = semanticEvents(context).filter((event) => event.status === "running");
6506
6767
  if (running.length > 0) {
6507
6768
  findings.push(
6508
6769
  failFinding(
@@ -6515,7 +6776,7 @@ function createStallDetectionRule(options = {}) {
6515
6776
  );
6516
6777
  }
6517
6778
  if (requireEndedAt) {
6518
- const incomplete = context.events.filter(
6779
+ const incomplete = semanticEvents(context).filter(
6519
6780
  (event) => event.startedAt !== void 0 && event.endedAt === void 0 && event.status !== "running"
6520
6781
  );
6521
6782
  if (incomplete.length > 0) {
@@ -6553,7 +6814,7 @@ function createRequireCompletedRule() {
6553
6814
  )
6554
6815
  );
6555
6816
  }
6556
- const running = context.events.filter((event) => event.status === "running");
6817
+ const running = semanticEvents(context).filter((event) => event.status === "running");
6557
6818
  if (running.length > 0) {
6558
6819
  findings.push(
6559
6820
  failFinding(
@@ -6725,8 +6986,8 @@ function createStructureOrphanRule(options = {}) {
6725
6986
  category: "structure",
6726
6987
  defaultSeverity: "error",
6727
6988
  evaluate(context) {
6728
- const byId = eventMap(context.events);
6729
- const orphans = context.events.filter((event) => {
6989
+ const byId = eventMap(semanticEvents(context));
6990
+ const orphans = semanticEvents(context).filter((event) => {
6730
6991
  if (!event.parentId || byId.has(event.parentId)) return false;
6731
6992
  return !(allowMarkedUnresolved && parentMarkedUnresolved(event));
6732
6993
  });
@@ -6749,10 +7010,10 @@ function createStructureCycleRule() {
6749
7010
  category: "structure",
6750
7011
  defaultSeverity: "error",
6751
7012
  evaluate(context) {
6752
- const byId = eventMap(context.events);
7013
+ const byId = eventMap(semanticEvents(context));
6753
7014
  const seenCycles = /* @__PURE__ */ new Set();
6754
7015
  const findings = [];
6755
- for (const event of [...context.events].sort((a, b) => a.eventId.localeCompare(b.eventId))) {
7016
+ for (const event of [...semanticEvents(context)].sort((a, b) => a.eventId.localeCompare(b.eventId))) {
6756
7017
  const path14 = [];
6757
7018
  const seenAt = /* @__PURE__ */ new Map();
6758
7019
  let current = event;
@@ -6790,10 +7051,10 @@ function createStructureRelationshipRule(options = {}) {
6790
7051
  category: "structure",
6791
7052
  defaultSeverity: "error",
6792
7053
  evaluate(context) {
6793
- const byId = eventMap(context.events);
7054
+ const byId = eventMap(semanticEvents(context));
6794
7055
  const findings = [];
6795
7056
  const minConfidence = options.minConfidence;
6796
- for (const event of context.events) {
7057
+ for (const event of semanticEvents(context)) {
6797
7058
  if (minConfidence && CONFIDENCE_RANK[event.confidence] < CONFIDENCE_RANK[minConfidence]) {
6798
7059
  findings.push(
6799
7060
  failFinding(
@@ -6861,7 +7122,7 @@ function createStructureParallelWidthRule(options) {
6861
7122
  defaultSeverity: "error",
6862
7123
  evaluate(context) {
6863
7124
  const findings = [];
6864
- const byId = eventMap(context.events);
7125
+ const byId = eventMap(semanticEvents(context));
6865
7126
  if (options.maxChildren !== void 0) {
6866
7127
  for (const [parentId, children] of context.childrenByParentId.entries()) {
6867
7128
  if (children.length <= options.maxChildren) continue;
@@ -6888,7 +7149,7 @@ function createStructureParallelWidthRule(options) {
6888
7149
  }
6889
7150
  }
6890
7151
  if (options.maxConcurrent !== void 0) {
6891
- const intervals = context.events.map((event) => ({ event, start: eventStartMs(event), end: eventEndMs(event) })).filter(
7152
+ const intervals = semanticEvents(context).map((event) => ({ event, start: eventStartMs(event), end: eventEndMs(event) })).filter(
6892
7153
  (item) => item.start !== void 0 && item.end !== void 0 && item.end > item.start
6893
7154
  );
6894
7155
  const points = intervals.flatMap((item) => [
@@ -7081,7 +7342,7 @@ function createSafetyOversizedAttributeRule(options) {
7081
7342
  )
7082
7343
  );
7083
7344
  }
7084
- if (isRecord7(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
7345
+ if (isRecord8(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
7085
7346
  findings.push(
7086
7347
  failFinding(
7087
7348
  "safety.oversizedAttribute",
@@ -7332,14 +7593,14 @@ function runTraceChecks(input, options = {}) {
7332
7593
  }
7333
7594
 
7334
7595
  // packages/core/src/persisted/token-usage.ts
7335
- function isRecord8(value) {
7596
+ function isRecord9(value) {
7336
7597
  return typeof value === "object" && value !== null && !Array.isArray(value);
7337
7598
  }
7338
7599
  function nonNegativeFinite(value) {
7339
7600
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
7340
7601
  }
7341
7602
  function normalizeTokenUsage(value) {
7342
- if (!isRecord8(value)) return void 0;
7603
+ if (!isRecord9(value)) return void 0;
7343
7604
  const input = nonNegativeFinite(value.input);
7344
7605
  const output = nonNegativeFinite(value.output);
7345
7606
  const suppliedTotal = nonNegativeFinite(value.total);
@@ -8108,7 +8369,7 @@ function persistedEventsForParsedTrace(parsed) {
8108
8369
  sourceName: "agent-inspect-jsonl-reader"
8109
8370
  });
8110
8371
  }
8111
- function isRecord9(value) {
8372
+ function isRecord10(value) {
8112
8373
  return typeof value === "object" && value !== null && !Array.isArray(value);
8113
8374
  }
8114
8375
  function isNonEmptyString4(value) {
@@ -8123,13 +8384,13 @@ function readStringField(record, keys) {
8123
8384
  }
8124
8385
  function readRecordField(record, key) {
8125
8386
  const value = record[key];
8126
- return isRecord9(value) ? value : void 0;
8387
+ return isRecord10(value) ? value : void 0;
8127
8388
  }
8128
8389
  function parseJsonDocument(content) {
8129
8390
  return JSON.parse(content);
8130
8391
  }
8131
8392
  function looksLikeOpenInferenceSpan(value) {
8132
- if (!isRecord9(value)) return false;
8393
+ if (!isRecord10(value)) return false;
8133
8394
  const attributes = readRecordField(value, "attributes");
8134
8395
  return readStringField(value, ["trace_id", "traceId"]) !== void 0 && readStringField(value, ["span_id", "spanId"]) !== void 0 && (readStringField(value, ["name"]) !== void 0 || attributes?.["openinference.span.kind"] !== void 0);
8135
8396
  }
@@ -8154,7 +8415,7 @@ function extractOpenInferenceDocument(root) {
8154
8415
  unsupportedFields
8155
8416
  };
8156
8417
  }
8157
- if (!isRecord9(root)) return void 0;
8418
+ if (!isRecord10(root)) return void 0;
8158
8419
  const rootFormat = root.format;
8159
8420
  const rootCompatibility = root.compatibility;
8160
8421
  const version = typeof root.version === "string" && root.version.trim() !== "" ? root.version : void 0;
@@ -8294,7 +8555,7 @@ function summarizeAttributeValue(value) {
8294
8555
  if (Array.isArray(value)) {
8295
8556
  return { type: "array", length: value.length };
8296
8557
  }
8297
- if (isRecord9(value)) {
8558
+ if (isRecord10(value)) {
8298
8559
  return { type: "object", keyCount: Object.keys(value).length };
8299
8560
  }
8300
8561
  if (value === null) {
@@ -8381,7 +8642,7 @@ function mapOpenInferenceKind(span, attributes, pathPrefix) {
8381
8642
  }
8382
8643
  }
8383
8644
  function mapOpenInferenceStatus(status) {
8384
- if (!isRecord9(status)) return void 0;
8645
+ if (!isRecord10(status)) return void 0;
8385
8646
  const rawCode = status.code;
8386
8647
  if (typeof rawCode !== "string") return void 0;
8387
8648
  switch (rawCode.toUpperCase()) {
@@ -8481,7 +8742,7 @@ function mapOpenInferenceSpan(span, index, version) {
8481
8742
  warnings.push(...kindWarnings);
8482
8743
  const status = mapOpenInferenceStatus(span.status);
8483
8744
  const tokenUsage = readOpenInferenceTokenUsage(rawAttributes);
8484
- const errorMessage = isRecord9(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
8745
+ const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
8485
8746
  const event = {
8486
8747
  schemaVersion: "0.2",
8487
8748
  eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId,
@@ -8627,7 +8888,7 @@ var openInferenceJsonReader = {
8627
8888
  }
8628
8889
  };
8629
8890
  function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
8630
- if (!isRecord9(value)) {
8891
+ if (!isRecord10(value)) {
8631
8892
  unsupportedFields.push(field);
8632
8893
  warnings.push({
8633
8894
  code: "otlp_attribute_value_invalid",
@@ -8649,15 +8910,15 @@ function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
8649
8910
  if (typeof value.doubleValue === "number" && Number.isFinite(value.doubleValue)) {
8650
8911
  return value.doubleValue;
8651
8912
  }
8652
- if (isRecord9(value.arrayValue) && Array.isArray(value.arrayValue.values)) {
8913
+ if (isRecord10(value.arrayValue) && Array.isArray(value.arrayValue.values)) {
8653
8914
  return value.arrayValue.values.map(
8654
8915
  (item, index) => parseOtlpAnyValue(item, `${field}.arrayValue.values[${index}]`, warnings, unsupportedFields)
8655
8916
  );
8656
8917
  }
8657
- if (isRecord9(value.kvlistValue) && Array.isArray(value.kvlistValue.values)) {
8918
+ if (isRecord10(value.kvlistValue) && Array.isArray(value.kvlistValue.values)) {
8658
8919
  const out = {};
8659
8920
  for (const [index, item] of value.kvlistValue.values.entries()) {
8660
- if (!isRecord9(item) || typeof item.key !== "string") {
8921
+ if (!isRecord10(item) || typeof item.key !== "string") {
8661
8922
  unsupportedFields.push(`${field}.kvlistValue.values[${index}]`);
8662
8923
  continue;
8663
8924
  }
@@ -8708,7 +8969,7 @@ function parseOtlpAttributes(value, pathPrefix) {
8708
8969
  }
8709
8970
  for (const [index, item] of value.entries()) {
8710
8971
  const field = `${pathPrefix}[${index}]`;
8711
- if (!isRecord9(item) || typeof item.key !== "string") {
8972
+ if (!isRecord10(item) || typeof item.key !== "string") {
8712
8973
  unsupportedFields.push(field);
8713
8974
  warnings.push({
8714
8975
  code: "otlp_attribute_invalid",
@@ -8731,16 +8992,16 @@ function parseOtlpAttributes(value, pathPrefix) {
8731
8992
  return { attributes, warnings, unsupportedFields };
8732
8993
  }
8733
8994
  function looksLikeOtlpSpan(value) {
8734
- return isRecord9(value) && readStringField(value, ["traceId"]) !== void 0 && readStringField(value, ["spanId"]) !== void 0 && readStringField(value, ["name"]) !== void 0;
8995
+ return isRecord10(value) && readStringField(value, ["traceId"]) !== void 0 && readStringField(value, ["spanId"]) !== void 0 && readStringField(value, ["name"]) !== void 0;
8735
8996
  }
8736
8997
  function extractOtlpDocument(root) {
8737
- if (!isRecord9(root) || !Array.isArray(root.resourceSpans)) return void 0;
8998
+ if (!isRecord10(root) || !Array.isArray(root.resourceSpans)) return void 0;
8738
8999
  const spans = [];
8739
9000
  const warnings = [];
8740
9001
  const unsupportedFields = [];
8741
9002
  for (const [resourceIndex, resourceSpan] of root.resourceSpans.entries()) {
8742
9003
  const resourcePath = `resourceSpans[${resourceIndex}]`;
8743
- if (!isRecord9(resourceSpan)) {
9004
+ if (!isRecord10(resourceSpan)) {
8744
9005
  unsupportedFields.push(resourcePath);
8745
9006
  continue;
8746
9007
  }
@@ -8763,7 +9024,7 @@ function extractOtlpDocument(root) {
8763
9024
  }
8764
9025
  for (const [scopeIndex, scopeSpan] of resourceSpan.scopeSpans.entries()) {
8765
9026
  const scopePath = `${resourcePath}.scopeSpans[${scopeIndex}]`;
8766
- if (!isRecord9(scopeSpan)) {
9027
+ if (!isRecord10(scopeSpan)) {
8767
9028
  unsupportedFields.push(scopePath);
8768
9029
  continue;
8769
9030
  }
@@ -8830,7 +9091,7 @@ function extractOtlpDocument(root) {
8830
9091
  };
8831
9092
  }
8832
9093
  function mapOtlpStatus(status) {
8833
- if (!isRecord9(status)) return void 0;
9094
+ if (!isRecord10(status)) return void 0;
8834
9095
  const rawCode = status.code;
8835
9096
  if (typeof rawCode !== "string") return void 0;
8836
9097
  switch (rawCode.toUpperCase()) {
@@ -8930,7 +9191,7 @@ function mapOtlpEvents(value, pathPrefix) {
8930
9191
  const events = [];
8931
9192
  for (const [index, event] of value.entries()) {
8932
9193
  const eventPath = `${pathPrefix}[${index}]`;
8933
- if (!isRecord9(event)) {
9194
+ if (!isRecord10(event)) {
8934
9195
  unsupportedFields.push(eventPath);
8935
9196
  continue;
8936
9197
  }
@@ -9068,7 +9329,7 @@ function mapOtlpSpan(context) {
9068
9329
  warnings.push(...kindWarnings);
9069
9330
  const status = mapOtlpStatus(span.status);
9070
9331
  const tokenUsage = readOtlpTokenUsage(parsedSpanAttributes.attributes);
9071
- const errorMessage = isRecord9(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
9332
+ const errorMessage = isRecord10(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
9072
9333
  const event = {
9073
9334
  schemaVersion: "0.2",
9074
9335
  eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId,
@@ -10754,5 +11015,5 @@ function renderGateReport(result, options = {}) {
10754
11015
  }
10755
11016
 
10756
11017
  export { COHORT_METRIC_IDS, DEFAULT_SUITE_ARTIFACTS_DIR, EVIDENCE_FORMAT_VERSION, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, Redactor, TraceDirectory, TraceReadError, TreeBuilder, aggregateBundleSafeStatus, aggregateSessionCheckResults, analyzeCohort, applyProfileMetadataCaps, assertBundlePathContained, assertEvidenceRelativePath, buildActivitySummary, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceCausalFailureViewHtml, buildEvidenceCiPackage, buildEvidenceCircuitViewHtml, buildEvidenceContractsViewHtml, buildEvidenceDiffViewHtml, buildEvidenceHtmlShell, buildEvidenceManifest, buildEvidenceOutcomesViewHtml, buildEvidenceProvenanceViewHtml, buildEvidenceSafetyViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceTreeViewHtml, buildLocalExplanation, buildPlaceholderArtifact, buildRunSummary, buildRunTimeline, buildRunWhatSummary, buildSessionIndex, buildTraceStats, buildZipArchive, bundleFailsOnSafety, bundleRunAssetRelativePath, collectTraceSchemaVersions, compactAttributes, createBaselineRegressionRule, createLlmUsageRule, createMaxStepDurationRule, createObservedOutcomeRule, createRequireCompletedRule, createRunDepthRule, createRunDurationRule, createRunStatusRule, createSafetyOversizedAttributeRule, createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createStallDetectionRule, createStructureCycleRule, createStructureOrphanRule, createStructureParallelWidthRule, createStructureRelationshipRule, createToolUsageRule, defaultBundleOutputPath, defaultSuiteConfigTemplate, diffRuns, diffTraceEvents, enrichSessionRunRecord, escapeHtml, escapeMarkdown, extractMetadata, extractOutcomesFromTraceEvents, filterMetasBySessionScope, filterTraces, flattenTree, formatDuration2 as formatDuration, formatTimestamp, gateHasThresholds, getIndent, getTraceFilePath, inferEvidenceFileRole, isAgentInspectTrace, isPersistedInspectEvent, loadSessionRunRecords, loadSuiteConfig, loadTraceMetadataList, manualTraceEventsToComparableRun, nanoid, normalizeBundleOutputPath, openTrace, parseCohortMetricList, parseDuration, parseDurationFilter, parseGateList, parseTraceJsonl, persistedInspectEventsToTraceEvents, renderActivitySummaryHuman, renderCohortReport, renderErrorLine, renderGateReport, renderObservedOutcomesHtml, renderObservedOutcomesMarkdown, renderRunDiff, renderRunWhat, renderStepLine, renderSuiteReport, renderTimeline, renderTraceStats, resolveBundleRunIds, resolveRedactionProfile, resolveSuiteTemplate, resolveTraceDir, runGate, runSuite, runTraceChecks, safeString, sanitizeBundleRunId, searchTraces, serializeEvidenceManifest, sha256Hex, stableJson, summarizeObservedOutcomes, traceEventToPersistedInspectEvent, truncateName, truncateStringForProfile, validateEvent, validateSuiteConfig, verifyEvidenceDirectory, zeroKinds };
10757
- //# sourceMappingURL=chunk-XTAA733P.mjs.map
10758
- //# sourceMappingURL=chunk-XTAA733P.mjs.map
11018
+ //# sourceMappingURL=chunk-4WA7DQCM.mjs.map
11019
+ //# sourceMappingURL=chunk-4WA7DQCM.mjs.map