@agent-inspect/mcp-server 6.12.1 → 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.
package/dist/cli.cjs CHANGED
@@ -679,12 +679,12 @@ function persistedInspectEventToTraceEvents(event) {
679
679
  if (!isPersistedInspectEvent(event)) {
680
680
  throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
681
681
  }
682
- const legacyEvent = event.attributes?.legacyEvent;
683
- if (legacyEvent === "run_started") return [fromLegacyRunStarted(event)];
684
- if (legacyEvent === "run_completed") return [fromLegacyRunCompleted(event)];
685
- if (legacyEvent === "step_started") return [fromLegacyStepStarted(event)];
686
- if (legacyEvent === "step_completed") return [fromLegacyStepCompleted(event)];
687
- if (legacyEvent === "outcome_observed") return [fromLegacyOutcomeObserved(event)];
682
+ const legacyEvent2 = event.attributes?.legacyEvent;
683
+ if (legacyEvent2 === "run_started") return [fromLegacyRunStarted(event)];
684
+ if (legacyEvent2 === "run_completed") return [fromLegacyRunCompleted(event)];
685
+ if (legacyEvent2 === "step_started") return [fromLegacyStepStarted(event)];
686
+ if (legacyEvent2 === "step_completed") return [fromLegacyStepCompleted(event)];
687
+ if (legacyEvent2 === "outcome_observed") return [fromLegacyOutcomeObserved(event)];
688
688
  if (event.kind === "RUN") {
689
689
  return fromNativeRun(event);
690
690
  }
@@ -2577,6 +2577,238 @@ function diffRuns(left, right, options) {
2577
2577
  return table;
2578
2578
  })();
2579
2579
 
2580
+ // packages/core/src/checks/logical-events.ts
2581
+ function isRecord6(value) {
2582
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2583
+ }
2584
+ function legacyEvent(event) {
2585
+ const value = event.attributes?.legacyEvent;
2586
+ return typeof value === "string" ? value : void 0;
2587
+ }
2588
+ function stepIdOf(event) {
2589
+ const value = event.attributes?.stepId;
2590
+ if (typeof value === "string" && value.trim() !== "") return value;
2591
+ return void 0;
2592
+ }
2593
+ function cloneEvent(event) {
2594
+ return {
2595
+ ...event,
2596
+ ...event.attributes !== void 0 ? { attributes: { ...event.attributes } } : {},
2597
+ ...event.error !== void 0 ? { error: { ...event.error } } : {},
2598
+ ...event.tokenUsage !== void 0 ? { tokenUsage: { ...event.tokenUsage } } : {},
2599
+ ...event.source !== void 0 ? { source: { ...event.source } } : {}
2600
+ };
2601
+ }
2602
+ function mergeAttributes(start, complete) {
2603
+ const merged = {
2604
+ ...isRecord6(complete.attributes) ? complete.attributes : {},
2605
+ ...isRecord6(start.attributes) ? start.attributes : {}
2606
+ };
2607
+ merged.legacyEvent = start.attributes?.legacyEvent ?? complete.attributes?.legacyEvent;
2608
+ merged.legacyCompleteEvent = complete.attributes?.legacyEvent;
2609
+ if (complete.attributes?.errorStack !== void 0) {
2610
+ merged.errorStack = complete.attributes.errorStack;
2611
+ }
2612
+ return Object.keys(merged).length > 0 ? merged : void 0;
2613
+ }
2614
+ function pairStartComplete(start, complete) {
2615
+ const attributes = mergeAttributes(start, complete);
2616
+ const paired = {
2617
+ ...cloneEvent(start),
2618
+ status: complete.status,
2619
+ timestamp: complete.timestamp ?? start.timestamp,
2620
+ ...complete.endedAt !== void 0 ? { endedAt: complete.endedAt } : {},
2621
+ ...complete.durationMs !== void 0 ? { durationMs: complete.durationMs } : {},
2622
+ ...complete.error !== void 0 ? { error: { ...complete.error } } : {},
2623
+ ...complete.tokenUsage !== void 0 && start.tokenUsage === void 0 ? { tokenUsage: { ...complete.tokenUsage } } : {},
2624
+ ...attributes !== void 0 ? { attributes } : {}
2625
+ };
2626
+ return {
2627
+ ...paired,
2628
+ sourceEventIds: Object.freeze([start.eventId, complete.eventId]),
2629
+ projection: {
2630
+ paired: true,
2631
+ absorbedEventIds: Object.freeze([complete.eventId]),
2632
+ parentNormalized: false,
2633
+ ...start.parentId !== void 0 ? { originalParentId: start.parentId } : {}
2634
+ }
2635
+ };
2636
+ }
2637
+ function asLogical(event, extras) {
2638
+ return {
2639
+ ...cloneEvent(event),
2640
+ sourceEventIds: Object.freeze([event.eventId]),
2641
+ projection: {
2642
+ paired: false,
2643
+ absorbedEventIds: Object.freeze([]),
2644
+ parentNormalized: extras?.parentNormalized === true,
2645
+ ...{}
2646
+ }
2647
+ };
2648
+ }
2649
+ function projectLogicalEvents(events) {
2650
+ const diagnostics = [];
2651
+ const byRun = /* @__PURE__ */ new Map();
2652
+ for (const event of events) {
2653
+ const list = byRun.get(event.runId) ?? [];
2654
+ list.push(event);
2655
+ byRun.set(event.runId, list);
2656
+ }
2657
+ const absorbedIds = /* @__PURE__ */ new Set();
2658
+ const logicalByRawId = /* @__PURE__ */ new Map();
2659
+ const stepIdToLogicalId = /* @__PURE__ */ new Map();
2660
+ const logical = [];
2661
+ const orderedRuns = [...byRun.keys()].sort((a, b) => a.localeCompare(b));
2662
+ for (const runId of orderedRuns) {
2663
+ const runEvents = byRun.get(runId) ?? [];
2664
+ const starts = [];
2665
+ const completes = [];
2666
+ const others = [];
2667
+ for (const event of runEvents) {
2668
+ const legacy = legacyEvent(event);
2669
+ if (legacy === "step_started" || legacy === "run_started" && event.status === "running") {
2670
+ starts.push(event);
2671
+ } else if (legacy === "step_completed" || legacy === "run_completed") {
2672
+ completes.push(event);
2673
+ } else {
2674
+ others.push(event);
2675
+ }
2676
+ }
2677
+ const usedCompletes = /* @__PURE__ */ new Set();
2678
+ for (const start of starts) {
2679
+ const stepId = stepIdOf(start);
2680
+ let match;
2681
+ if (legacyEvent(start) === "run_started") {
2682
+ const candidates = completes.filter(
2683
+ (c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "run_completed"
2684
+ );
2685
+ if (candidates.length > 1) {
2686
+ diagnostics.push({
2687
+ code: "AI_LOGICAL_PAIR_AMBIGUOUS",
2688
+ message: `Multiple run_completed rows for run ${runId}; using first by eventId.`,
2689
+ eventIds: candidates.map((c) => c.eventId)
2690
+ });
2691
+ candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
2692
+ }
2693
+ match = candidates[0];
2694
+ } else if (stepId) {
2695
+ const candidates = completes.filter(
2696
+ (c) => !usedCompletes.has(c.eventId) && legacyEvent(c) === "step_completed" && stepIdOf(c) === stepId
2697
+ );
2698
+ if (candidates.length > 1) {
2699
+ diagnostics.push({
2700
+ code: "AI_LOGICAL_PAIR_AMBIGUOUS",
2701
+ message: `Multiple step_completed rows for stepId ${stepId}; using first by eventId.`,
2702
+ eventIds: candidates.map((c) => c.eventId)
2703
+ });
2704
+ candidates.sort((a, b) => a.eventId.localeCompare(b.eventId));
2705
+ }
2706
+ match = candidates[0];
2707
+ }
2708
+ if (match) {
2709
+ usedCompletes.add(match.eventId);
2710
+ absorbedIds.add(match.eventId);
2711
+ const paired = pairStartComplete(start, match);
2712
+ logical.push(paired);
2713
+ logicalByRawId.set(start.eventId, paired);
2714
+ logicalByRawId.set(match.eventId, paired);
2715
+ if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, paired.eventId);
2716
+ } else {
2717
+ diagnostics.push({
2718
+ code: "AI_LOGICAL_PAIR_UNMATCHED_START",
2719
+ message: `No matching complete for start ${start.eventId}.`,
2720
+ eventIds: [start.eventId]
2721
+ });
2722
+ const alone = asLogical(start);
2723
+ logical.push(alone);
2724
+ logicalByRawId.set(start.eventId, alone);
2725
+ if (stepId) stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
2726
+ }
2727
+ }
2728
+ for (const complete of completes) {
2729
+ if (usedCompletes.has(complete.eventId)) continue;
2730
+ diagnostics.push({
2731
+ code: "AI_LOGICAL_PAIR_UNMATCHED_COMPLETE",
2732
+ message: `No matching start for complete ${complete.eventId}.`,
2733
+ eventIds: [complete.eventId]
2734
+ });
2735
+ const alone = asLogical(complete);
2736
+ logical.push(alone);
2737
+ logicalByRawId.set(complete.eventId, alone);
2738
+ const stepId = stepIdOf(complete);
2739
+ if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
2740
+ stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
2741
+ }
2742
+ }
2743
+ for (const event of others) {
2744
+ const alone = asLogical(event);
2745
+ logical.push(alone);
2746
+ logicalByRawId.set(event.eventId, alone);
2747
+ const stepId = stepIdOf(event);
2748
+ if (stepId && !stepIdToLogicalId.has(`${runId}:${stepId}`)) {
2749
+ stepIdToLogicalId.set(`${runId}:${stepId}`, alone.eventId);
2750
+ }
2751
+ }
2752
+ }
2753
+ const logicalById = new Map(logical.map((e) => [e.eventId, e]));
2754
+ const normalized = [];
2755
+ for (const event of logical) {
2756
+ const originalParentId = event.parentId;
2757
+ if (!originalParentId) {
2758
+ normalized.push(event);
2759
+ continue;
2760
+ }
2761
+ let nextParent = originalParentId;
2762
+ let remapped = false;
2763
+ const viaAbsorbed = logicalByRawId.get(originalParentId);
2764
+ if (viaAbsorbed && viaAbsorbed.eventId !== originalParentId) {
2765
+ nextParent = viaAbsorbed.eventId;
2766
+ remapped = true;
2767
+ } else if (!logicalById.has(originalParentId)) {
2768
+ const viaStep = stepIdToLogicalId.get(`${event.runId}:${originalParentId}`);
2769
+ if (viaStep) {
2770
+ nextParent = viaStep;
2771
+ remapped = true;
2772
+ }
2773
+ }
2774
+ if (!remapped) {
2775
+ if (!logicalById.has(originalParentId) && !logicalByRawId.has(originalParentId)) {
2776
+ diagnostics.push({
2777
+ code: "AI_LOGICAL_PARENT_UNRESOLVED",
2778
+ message: `Parent ${originalParentId} unresolved for ${event.eventId}.`,
2779
+ eventIds: [event.eventId]
2780
+ });
2781
+ }
2782
+ normalized.push(event);
2783
+ continue;
2784
+ }
2785
+ diagnostics.push({
2786
+ code: "AI_LOGICAL_PARENT_REMAPPED",
2787
+ message: `Remapped parent ${originalParentId} \u2192 ${nextParent} for ${event.eventId}.`,
2788
+ eventIds: [event.eventId]
2789
+ });
2790
+ normalized.push({
2791
+ ...event,
2792
+ parentId: nextParent,
2793
+ projection: {
2794
+ ...event.projection,
2795
+ parentNormalized: true,
2796
+ originalParentId
2797
+ }
2798
+ });
2799
+ }
2800
+ const rawIndex = new Map(events.map((e, i) => [e.eventId, i]));
2801
+ normalized.sort((a, b) => {
2802
+ const ai = rawIndex.get(a.sourceEventIds[0]) ?? 0;
2803
+ const bi = rawIndex.get(b.sourceEventIds[0]) ?? 0;
2804
+ return ai - bi || a.eventId.localeCompare(b.eventId);
2805
+ });
2806
+ return {
2807
+ logicalEvents: Object.freeze(normalized),
2808
+ diagnostics: Object.freeze(diagnostics)
2809
+ };
2810
+ }
2811
+
2580
2812
  // packages/core/src/checks/index.ts
2581
2813
  var SEVERITY_RANK = {
2582
2814
  error: 0,
@@ -2629,7 +2861,11 @@ var DEFAULT_RAW_CONTENT_KEYS = [
2629
2861
  "conversationtext",
2630
2862
  "conversation_text"
2631
2863
  ];
2632
- var DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES = ["tokenUsage", "usage"];
2864
+ var DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES = [
2865
+ "tokenUsage",
2866
+ "usage",
2867
+ "tokens"
2868
+ ];
2633
2869
  var SAFE_USAGE_LEAF_KEYS = /* @__PURE__ */ new Set([
2634
2870
  "input",
2635
2871
  "output",
@@ -2705,10 +2941,13 @@ function buildFacts(input, selectedRun) {
2705
2941
  childrenByParentId.set(parentId, children);
2706
2942
  }
2707
2943
  }
2944
+ const projection = projectLogicalEvents(scopedEvents);
2708
2945
  return {
2709
2946
  format: input.read.format,
2710
2947
  runs: Object.freeze([...input.read.runs]),
2711
2948
  events: Object.freeze([...scopedEvents]),
2949
+ logicalEvents: projection.logicalEvents,
2950
+ logicalProjectionDiagnostics: projection.diagnostics,
2712
2951
  readerWarnings: Object.freeze([...input.read.warnings]),
2713
2952
  unsupportedFields: Object.freeze([...input.read.unsupportedFields]),
2714
2953
  sourceFiles: Object.freeze([...input.read.sourceFiles]),
@@ -2873,7 +3112,10 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
2873
3112
  ...meta?.action !== void 0 ? { action: meta.action } : {}
2874
3113
  };
2875
3114
  }
2876
- function isRecord6(value) {
3115
+ function semanticEvents(context) {
3116
+ return context.logicalEvents ?? context.events;
3117
+ }
3118
+ function isRecord7(value) {
2877
3119
  return typeof value === "object" && value !== null && !Array.isArray(value);
2878
3120
  }
2879
3121
  function normalizedKey(value) {
@@ -2904,7 +3146,7 @@ function pushValueEntries(entries, event, value, path17, key, depth = 0) {
2904
3146
  }
2905
3147
  return;
2906
3148
  }
2907
- if (!isRecord6(value)) return;
3149
+ if (!isRecord7(value)) return;
2908
3150
  for (const nestedKey of Object.keys(value).sort((a, b) => a.localeCompare(b))) {
2909
3151
  pushValueEntries(
2910
3152
  entries,
@@ -2986,7 +3228,7 @@ function createRunStatusRule(options = {}) {
2986
3228
  );
2987
3229
  }
2988
3230
  if (!allowIncomplete) {
2989
- const running = context.events.filter((event) => event.status === "running");
3231
+ const running = semanticEvents(context).filter((event) => event.status === "running");
2990
3232
  if (running.length > 0) {
2991
3233
  findings.push(
2992
3234
  failFinding(
@@ -3154,7 +3396,7 @@ function createSafetyOversizedAttributeRule(options) {
3154
3396
  )
3155
3397
  );
3156
3398
  }
3157
- if (isRecord6(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
3399
+ if (isRecord7(entry.value) && options.maxObjectKeys !== void 0 && Object.keys(entry.value).length > options.maxObjectKeys) {
3158
3400
  findings.push(
3159
3401
  failFinding(
3160
3402
  "safety.oversizedAttribute",
@@ -3243,14 +3485,14 @@ function runTraceChecks(input, options = {}) {
3243
3485
  }
3244
3486
 
3245
3487
  // packages/core/src/persisted/token-usage.ts
3246
- function isRecord7(value) {
3488
+ function isRecord8(value) {
3247
3489
  return typeof value === "object" && value !== null && !Array.isArray(value);
3248
3490
  }
3249
3491
  function nonNegativeFinite(value) {
3250
3492
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : void 0;
3251
3493
  }
3252
3494
  function normalizeTokenUsage(value) {
3253
- if (!isRecord7(value)) return void 0;
3495
+ if (!isRecord8(value)) return void 0;
3254
3496
  const input = nonNegativeFinite(value.input);
3255
3497
  const output = nonNegativeFinite(value.output);
3256
3498
  const suppliedTotal = nonNegativeFinite(value.total);
@@ -4019,7 +4261,7 @@ function persistedEventsForParsedTrace(parsed) {
4019
4261
  sourceName: "agent-inspect-jsonl-reader"
4020
4262
  });
4021
4263
  }
4022
- function isRecord8(value) {
4264
+ function isRecord9(value) {
4023
4265
  return typeof value === "object" && value !== null && !Array.isArray(value);
4024
4266
  }
4025
4267
  function isNonEmptyString3(value) {
@@ -4034,13 +4276,13 @@ function readStringField(record, keys) {
4034
4276
  }
4035
4277
  function readRecordField(record, key) {
4036
4278
  const value = record[key];
4037
- return isRecord8(value) ? value : void 0;
4279
+ return isRecord9(value) ? value : void 0;
4038
4280
  }
4039
4281
  function parseJsonDocument(content) {
4040
4282
  return JSON.parse(content);
4041
4283
  }
4042
4284
  function looksLikeOpenInferenceSpan(value) {
4043
- if (!isRecord8(value)) return false;
4285
+ if (!isRecord9(value)) return false;
4044
4286
  const attributes = readRecordField(value, "attributes");
4045
4287
  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);
4046
4288
  }
@@ -4065,7 +4307,7 @@ function extractOpenInferenceDocument(root) {
4065
4307
  unsupportedFields
4066
4308
  };
4067
4309
  }
4068
- if (!isRecord8(root)) return void 0;
4310
+ if (!isRecord9(root)) return void 0;
4069
4311
  const rootFormat = root.format;
4070
4312
  const rootCompatibility = root.compatibility;
4071
4313
  const version = typeof root.version === "string" && root.version.trim() !== "" ? root.version : void 0;
@@ -4205,7 +4447,7 @@ function summarizeAttributeValue(value) {
4205
4447
  if (Array.isArray(value)) {
4206
4448
  return { type: "array", length: value.length };
4207
4449
  }
4208
- if (isRecord8(value)) {
4450
+ if (isRecord9(value)) {
4209
4451
  return { type: "object", keyCount: Object.keys(value).length };
4210
4452
  }
4211
4453
  if (value === null) {
@@ -4292,7 +4534,7 @@ function mapOpenInferenceKind(span, attributes, pathPrefix) {
4292
4534
  }
4293
4535
  }
4294
4536
  function mapOpenInferenceStatus(status) {
4295
- if (!isRecord8(status)) return void 0;
4537
+ if (!isRecord9(status)) return void 0;
4296
4538
  const rawCode = status.code;
4297
4539
  if (typeof rawCode !== "string") return void 0;
4298
4540
  switch (rawCode.toUpperCase()) {
@@ -4392,7 +4634,7 @@ function mapOpenInferenceSpan(span, index, version) {
4392
4634
  warnings.push(...kindWarnings);
4393
4635
  const status = mapOpenInferenceStatus(span.status);
4394
4636
  const tokenUsage = readOpenInferenceTokenUsage(rawAttributes);
4395
- const errorMessage = isRecord8(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
4637
+ const errorMessage = isRecord9(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
4396
4638
  const event = {
4397
4639
  schemaVersion: "0.2",
4398
4640
  eventId: typeof rawAttributes["agent_inspect.event_id"] === "string" ? rawAttributes["agent_inspect.event_id"] : spanId,
@@ -4538,7 +4780,7 @@ var openInferenceJsonReader = {
4538
4780
  }
4539
4781
  };
4540
4782
  function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
4541
- if (!isRecord8(value)) {
4783
+ if (!isRecord9(value)) {
4542
4784
  unsupportedFields.push(field);
4543
4785
  warnings.push({
4544
4786
  code: "otlp_attribute_value_invalid",
@@ -4560,15 +4802,15 @@ function parseOtlpAnyValue(value, field, warnings, unsupportedFields) {
4560
4802
  if (typeof value.doubleValue === "number" && Number.isFinite(value.doubleValue)) {
4561
4803
  return value.doubleValue;
4562
4804
  }
4563
- if (isRecord8(value.arrayValue) && Array.isArray(value.arrayValue.values)) {
4805
+ if (isRecord9(value.arrayValue) && Array.isArray(value.arrayValue.values)) {
4564
4806
  return value.arrayValue.values.map(
4565
4807
  (item, index) => parseOtlpAnyValue(item, `${field}.arrayValue.values[${index}]`, warnings, unsupportedFields)
4566
4808
  );
4567
4809
  }
4568
- if (isRecord8(value.kvlistValue) && Array.isArray(value.kvlistValue.values)) {
4810
+ if (isRecord9(value.kvlistValue) && Array.isArray(value.kvlistValue.values)) {
4569
4811
  const out = {};
4570
4812
  for (const [index, item] of value.kvlistValue.values.entries()) {
4571
- if (!isRecord8(item) || typeof item.key !== "string") {
4813
+ if (!isRecord9(item) || typeof item.key !== "string") {
4572
4814
  unsupportedFields.push(`${field}.kvlistValue.values[${index}]`);
4573
4815
  continue;
4574
4816
  }
@@ -4619,7 +4861,7 @@ function parseOtlpAttributes(value, pathPrefix) {
4619
4861
  }
4620
4862
  for (const [index, item] of value.entries()) {
4621
4863
  const field = `${pathPrefix}[${index}]`;
4622
- if (!isRecord8(item) || typeof item.key !== "string") {
4864
+ if (!isRecord9(item) || typeof item.key !== "string") {
4623
4865
  unsupportedFields.push(field);
4624
4866
  warnings.push({
4625
4867
  code: "otlp_attribute_invalid",
@@ -4642,16 +4884,16 @@ function parseOtlpAttributes(value, pathPrefix) {
4642
4884
  return { attributes, warnings, unsupportedFields };
4643
4885
  }
4644
4886
  function looksLikeOtlpSpan(value) {
4645
- return isRecord8(value) && readStringField(value, ["traceId"]) !== void 0 && readStringField(value, ["spanId"]) !== void 0 && readStringField(value, ["name"]) !== void 0;
4887
+ return isRecord9(value) && readStringField(value, ["traceId"]) !== void 0 && readStringField(value, ["spanId"]) !== void 0 && readStringField(value, ["name"]) !== void 0;
4646
4888
  }
4647
4889
  function extractOtlpDocument(root) {
4648
- if (!isRecord8(root) || !Array.isArray(root.resourceSpans)) return void 0;
4890
+ if (!isRecord9(root) || !Array.isArray(root.resourceSpans)) return void 0;
4649
4891
  const spans = [];
4650
4892
  const warnings = [];
4651
4893
  const unsupportedFields = [];
4652
4894
  for (const [resourceIndex, resourceSpan] of root.resourceSpans.entries()) {
4653
4895
  const resourcePath = `resourceSpans[${resourceIndex}]`;
4654
- if (!isRecord8(resourceSpan)) {
4896
+ if (!isRecord9(resourceSpan)) {
4655
4897
  unsupportedFields.push(resourcePath);
4656
4898
  continue;
4657
4899
  }
@@ -4674,7 +4916,7 @@ function extractOtlpDocument(root) {
4674
4916
  }
4675
4917
  for (const [scopeIndex, scopeSpan] of resourceSpan.scopeSpans.entries()) {
4676
4918
  const scopePath = `${resourcePath}.scopeSpans[${scopeIndex}]`;
4677
- if (!isRecord8(scopeSpan)) {
4919
+ if (!isRecord9(scopeSpan)) {
4678
4920
  unsupportedFields.push(scopePath);
4679
4921
  continue;
4680
4922
  }
@@ -4741,7 +4983,7 @@ function extractOtlpDocument(root) {
4741
4983
  };
4742
4984
  }
4743
4985
  function mapOtlpStatus(status) {
4744
- if (!isRecord8(status)) return void 0;
4986
+ if (!isRecord9(status)) return void 0;
4745
4987
  const rawCode = status.code;
4746
4988
  if (typeof rawCode !== "string") return void 0;
4747
4989
  switch (rawCode.toUpperCase()) {
@@ -4841,7 +5083,7 @@ function mapOtlpEvents(value, pathPrefix) {
4841
5083
  const events = [];
4842
5084
  for (const [index, event] of value.entries()) {
4843
5085
  const eventPath = `${pathPrefix}[${index}]`;
4844
- if (!isRecord8(event)) {
5086
+ if (!isRecord9(event)) {
4845
5087
  unsupportedFields.push(eventPath);
4846
5088
  continue;
4847
5089
  }
@@ -4979,7 +5221,7 @@ function mapOtlpSpan(context) {
4979
5221
  warnings.push(...kindWarnings);
4980
5222
  const status = mapOtlpStatus(span.status);
4981
5223
  const tokenUsage = readOtlpTokenUsage(parsedSpanAttributes.attributes);
4982
- const errorMessage = isRecord8(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
5224
+ const errorMessage = isRecord9(span.status) && typeof span.status.message === "string" ? span.status.message : void 0;
4983
5225
  const event = {
4984
5226
  schemaVersion: "0.2",
4985
5227
  eventId: typeof parsedSpanAttributes.attributes["agent_inspect.event_id"] === "string" ? parsedSpanAttributes.attributes["agent_inspect.event_id"] : spanId,
@@ -5325,7 +5567,7 @@ function openTrace(input, options = {}) {
5325
5567
  var EXPORT_PAYLOAD_VERSION = "0.1.2";
5326
5568
 
5327
5569
  // packages/core/src/exporters/redact-export.ts
5328
- function isRecord9(value) {
5570
+ function isRecord10(value) {
5329
5571
  return typeof value === "object" && value !== null && !Array.isArray(value);
5330
5572
  }
5331
5573
  function deepClone(value) {
@@ -5399,7 +5641,7 @@ function redactEventAttributes(attrs, redactor, maxMetadataValueLength, maxPrevi
5399
5641
  0
5400
5642
  );
5401
5643
  const err = bounded.error;
5402
- if (isRecord9(err) && typeof err.message === "string") {
5644
+ if (isRecord10(err) && typeof err.message === "string") {
5403
5645
  bounded.error = {
5404
5646
  ...err,
5405
5647
  message: truncateStringForProfile(
@@ -6061,7 +6303,7 @@ var STRICT_PROFILE_EXTRA_KEYS2 = [
6061
6303
  "retrieval",
6062
6304
  "query"
6063
6305
  ];
6064
- function isRecord10(value) {
6306
+ function isRecord11(value) {
6065
6307
  return typeof value === "object" && value !== null && !Array.isArray(value);
6066
6308
  }
6067
6309
  function toKey2(key) {
@@ -6426,7 +6668,7 @@ var Redactor2 = class {
6426
6668
  });
6427
6669
  return out;
6428
6670
  }
6429
- if (isRecord10(value)) {
6671
+ if (isRecord11(value)) {
6430
6672
  if (state.seen.has(value)) return state.seen.get(value);
6431
6673
  const out = {};
6432
6674
  state.seen.set(value, out);