@agent-inspect/mcp-server 6.21.0 → 6.22.0

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
@@ -482,16 +482,16 @@ function pickRunMetadata(attributes) {
482
482
  return Object.keys(metadata).length > 0 ? metadata : void 0;
483
483
  }
484
484
  function resolveStepId(event) {
485
- const attrs = event.attributes;
486
- if (attrs && typeof attrs.stepId === "string" && attrs.stepId.trim() !== "") {
487
- return attrs.stepId;
485
+ const attrs2 = event.attributes;
486
+ if (attrs2 && typeof attrs2.stepId === "string" && attrs2.stepId.trim() !== "") {
487
+ return attrs2.stepId;
488
488
  }
489
489
  return event.eventId;
490
490
  }
491
491
  function resolveStepType(event) {
492
- const attrs = event.attributes;
493
- if (attrs && typeof attrs.stepType === "string") {
494
- const t = attrs.stepType;
492
+ const attrs2 = event.attributes;
493
+ if (attrs2 && typeof attrs2.stepType === "string") {
494
+ const t = attrs2.stepType;
495
495
  if (t === "run" || t === "llm" || t === "tool" || t === "decision" || t === "logic" || t === "state" || t === "custom") {
496
496
  return t;
497
497
  }
@@ -572,26 +572,26 @@ function fromLegacyStepCompleted(event) {
572
572
  return out;
573
573
  }
574
574
  function fromLegacyOutcomeObserved(event) {
575
- const attrs = event.attributes ?? {};
576
- const observedAtRaw = attrs.observedAt;
575
+ const attrs2 = event.attributes ?? {};
576
+ const observedAtRaw = attrs2.observedAt;
577
577
  const observedAt = typeof observedAtRaw === "string" ? Date.parse(observedAtRaw) : typeof observedAtRaw === "number" && Number.isFinite(observedAtRaw) ? observedAtRaw : resolveTimes(event).timestamp;
578
- const status = attrs.outcomeStatus;
578
+ const status = attrs2.outcomeStatus;
579
579
  const out = {
580
580
  schemaVersion: "0.1",
581
581
  event: "outcome_observed",
582
582
  timestamp: observedAt,
583
583
  runId: event.runId,
584
- outcomeId: typeof attrs.outcomeId === "string" ? attrs.outcomeId : event.eventId,
584
+ outcomeId: typeof attrs2.outcomeId === "string" ? attrs2.outcomeId : event.eventId,
585
585
  name: event.name,
586
- expectation: typeof attrs.expectation === "string" ? attrs.expectation : event.name,
586
+ expectation: typeof attrs2.expectation === "string" ? attrs2.expectation : event.name,
587
587
  status: status === "passed" || status === "failed" || status === "unknown" || status === "skipped" ? status : "unknown",
588
588
  observedAt
589
589
  };
590
590
  if (event.parentId !== void 0) out.parentId = event.parentId;
591
- if (typeof attrs.method === "string") out.method = attrs.method;
592
- if (attrs.actual !== void 0) out.actual = attrs.actual;
591
+ if (typeof attrs2.method === "string") out.method = attrs2.method;
592
+ if (attrs2.actual !== void 0) out.actual = attrs2.actual;
593
593
  if (event.outputSummary !== void 0) out.actual = event.outputSummary;
594
- if (attrs.evidence !== void 0) out.evidence = attrs.evidence;
594
+ if (attrs2.evidence !== void 0) out.evidence = attrs2.evidence;
595
595
  return out;
596
596
  }
597
597
  function fromNativeOutcome(event) {
@@ -1999,6 +1999,63 @@ async function loadTraceMetadataList(_traceDir, fileNames, getPath) {
1999
1999
  return metas;
2000
2000
  }
2001
2001
 
2002
+ // packages/core/src/sessions/metadata.ts
2003
+ function isNonEmptyString3(value) {
2004
+ return typeof value === "string" && value.trim() !== "";
2005
+ }
2006
+ function finitePositiveInt(value) {
2007
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 1) {
2008
+ return void 0;
2009
+ }
2010
+ return Math.trunc(value);
2011
+ }
2012
+ function extractSessionWorkflowMetadata(record) {
2013
+ if (!record) return void 0;
2014
+ const out = {};
2015
+ let found = false;
2016
+ const assignString = (key, value) => {
2017
+ if (isNonEmptyString3(value)) {
2018
+ out[key] = value.trim();
2019
+ found = true;
2020
+ }
2021
+ };
2022
+ assignString("sessionId", record.sessionId);
2023
+ assignString("conversationId", record.conversationId);
2024
+ assignString("groupId", record.groupId);
2025
+ assignString("parentGroupId", record.parentGroupId);
2026
+ assignString("retryOf", record.retryOf);
2027
+ assignString("retryReason", record.retryReason);
2028
+ assignString("handoffFrom", record.handoffFrom);
2029
+ assignString("handoffTo", record.handoffTo);
2030
+ assignString("subAgentId", record.subAgentId);
2031
+ assignString("subAgentName", record.subAgentName);
2032
+ assignString("jobId", record.jobId);
2033
+ assignString("queueName", record.queueName);
2034
+ assignString("workflowName", record.workflowName);
2035
+ assignString("workflowStep", record.workflowStep);
2036
+ assignString("toolCallId", record.toolCallId);
2037
+ assignString("mcpToolCallId", record.mcpToolCallId);
2038
+ assignString("linkedStepId", record.linkedStepId);
2039
+ assignString("operationId", record.operationId);
2040
+ assignString("attemptId", record.attemptId);
2041
+ assignString("fallbackOf", record.fallbackOf);
2042
+ assignString("idempotencyKey", record.idempotencyKey);
2043
+ assignString("correlationId", record.correlationId);
2044
+ assignString("requestId", record.requestId);
2045
+ assignString("decisionId", record.decisionId);
2046
+ const attempt = finitePositiveInt(record.attempt);
2047
+ if (attempt !== void 0) {
2048
+ out.attempt = attempt;
2049
+ found = true;
2050
+ }
2051
+ const attemptNumber = finitePositiveInt(record.attemptNumber);
2052
+ if (attemptNumber !== void 0) {
2053
+ out.attemptNumber = attemptNumber;
2054
+ found = true;
2055
+ }
2056
+ return found ? out : void 0;
2057
+ }
2058
+
2002
2059
  // packages/core/src/bundle/safety-status.ts
2003
2060
  function aggregateBundleSafeStatus(statuses) {
2004
2061
  if (statuses.length === 0) return "UNKNOWN";
@@ -2211,17 +2268,17 @@ function stableJson(value, pretty) {
2211
2268
  const sorted = sortKeysDeep(value);
2212
2269
  return pretty === true ? JSON.stringify(sorted, null, 2) : JSON.stringify(sorted);
2213
2270
  }
2214
- function compactAttributes(attrs, options) {
2215
- if (attrs === void 0) return {};
2271
+ function compactAttributes(attrs2, options) {
2272
+ if (attrs2 === void 0) return {};
2216
2273
  const maxLen = options?.maxLength ?? 500;
2217
2274
  const redacted = options?.redacted ?? true;
2218
2275
  const out = {};
2219
- for (const key of Object.keys(attrs).sort()) {
2276
+ for (const key of Object.keys(attrs2).sort()) {
2220
2277
  if (redacted && shouldRedactKey(key)) {
2221
2278
  out[key] = "[REDACTED]";
2222
2279
  continue;
2223
2280
  }
2224
- const v = attrs[key];
2281
+ const v = attrs2[key];
2225
2282
  out[key] = compactValue(v, maxLen, redacted);
2226
2283
  }
2227
2284
  return out;
@@ -3032,10 +3089,10 @@ function projectLogicalEvents(events) {
3032
3089
  };
3033
3090
  }
3034
3091
  function resolveCanonicalToolName(event) {
3035
- const attrs = event.attributes;
3036
- const direct = pickString(attrs, ["toolName", "tool"]);
3092
+ const attrs2 = event.attributes;
3093
+ const direct = pickString(attrs2, ["toolName", "tool"]);
3037
3094
  if (direct) return direct;
3038
- const metadata = attrs?.metadata;
3095
+ const metadata = attrs2?.metadata;
3039
3096
  if (isRecord6(metadata)) {
3040
3097
  const nested = pickString(metadata, ["toolName", "tool"]);
3041
3098
  if (nested) return nested;
@@ -3077,10 +3134,10 @@ function pickNumber(record, keys) {
3077
3134
  return void 0;
3078
3135
  }
3079
3136
  function eventMetadata(event) {
3080
- const attrs = isRecord7(event.attributes) ? event.attributes : void 0;
3081
- const nested = attrs !== void 0 && isRecord7(attrs.metadata) ? attrs.metadata : void 0;
3137
+ const attrs2 = isRecord7(event.attributes) ? event.attributes : void 0;
3138
+ const nested = attrs2 !== void 0 && isRecord7(attrs2.metadata) ? attrs2.metadata : void 0;
3082
3139
  return {
3083
- ...attrs ?? {},
3140
+ ...attrs2 ?? {},
3084
3141
  ...nested ?? {}
3085
3142
  };
3086
3143
  }
@@ -3373,6 +3430,151 @@ function deriveFailureFacts(logicalEvents) {
3373
3430
  };
3374
3431
  }
3375
3432
 
3433
+ // packages/core/src/checks/relationship-facts.ts
3434
+ function attrs(event) {
3435
+ return event.attributes && typeof event.attributes === "object" ? event.attributes : {};
3436
+ }
3437
+ function stringAttr(record, key) {
3438
+ const value = record[key];
3439
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
3440
+ }
3441
+ function deriveRelationshipFacts(events) {
3442
+ const relationships = [];
3443
+ const diagnostics = [];
3444
+ const byId = new Map(events.map((event) => [event.eventId, event]));
3445
+ const seen = /* @__PURE__ */ new Set();
3446
+ const push = (edge) => {
3447
+ const key = `${edge.type}:${edge.fromEventId}:${edge.toEventId ?? ""}:${edge.externalRef ?? ""}`;
3448
+ if (seen.has(key)) return;
3449
+ seen.add(key);
3450
+ relationships.push(edge);
3451
+ };
3452
+ for (const event of events) {
3453
+ if (event.parentId) {
3454
+ push({
3455
+ type: "parent-child",
3456
+ fromEventId: event.parentId,
3457
+ toEventId: event.eventId,
3458
+ confidence: byId.has(event.parentId) ? "explicit" : "unknown",
3459
+ basis: ["persisted.parentId"]
3460
+ });
3461
+ if (!byId.has(event.parentId)) {
3462
+ diagnostics.push({
3463
+ code: "AI_RELATIONSHIP_PARENT_MISSING",
3464
+ message: `parentId ${event.parentId} is not present in the event set.`,
3465
+ eventId: event.eventId
3466
+ });
3467
+ }
3468
+ }
3469
+ const bag = attrs(event);
3470
+ const meta = extractSessionWorkflowMetadata(bag) ?? {};
3471
+ const nested = bag.metadata && typeof bag.metadata === "object" ? extractSessionWorkflowMetadata(bag.metadata) : void 0;
3472
+ const workflow = { ...meta, ...nested };
3473
+ if (workflow.retryOf) {
3474
+ const target = events.find((candidate) => candidate.runId === workflow.retryOf);
3475
+ push({
3476
+ type: "retry-of",
3477
+ fromEventId: event.eventId,
3478
+ ...target ? { toEventId: target.eventId } : {},
3479
+ externalRef: workflow.retryOf,
3480
+ confidence: target ? "explicit" : "correlated",
3481
+ basis: ["attributes.retryOf"]
3482
+ });
3483
+ }
3484
+ const attemptOf = stringAttr(bag, "attemptOf") ?? stringAttr(bag, "operationId");
3485
+ if (attemptOf && workflow.attempt !== void 0) {
3486
+ push({
3487
+ type: "attempt-of",
3488
+ fromEventId: event.eventId,
3489
+ externalRef: attemptOf,
3490
+ confidence: "explicit",
3491
+ basis: workflow.attempt !== void 0 ? ["attributes.attempt", "attributes.operationId"] : ["attributes.operationId"]
3492
+ });
3493
+ }
3494
+ const fallbackOf = stringAttr(bag, "fallbackOf");
3495
+ if (fallbackOf) {
3496
+ push({
3497
+ type: "fallback-of",
3498
+ fromEventId: event.eventId,
3499
+ externalRef: fallbackOf,
3500
+ confidence: "explicit",
3501
+ basis: ["attributes.fallbackOf"]
3502
+ });
3503
+ }
3504
+ const remediationOf = stringAttr(bag, "remediationOf");
3505
+ if (remediationOf) {
3506
+ push({
3507
+ type: "remediation-of",
3508
+ fromEventId: event.eventId,
3509
+ externalRef: remediationOf,
3510
+ confidence: "explicit",
3511
+ basis: ["attributes.remediationOf"]
3512
+ });
3513
+ }
3514
+ const evidenceFor = stringAttr(bag, "evidenceFor");
3515
+ if (evidenceFor) {
3516
+ push({
3517
+ type: "evidence-for",
3518
+ fromEventId: event.eventId,
3519
+ ...byId.has(evidenceFor) ? { toEventId: evidenceFor } : { externalRef: evidenceFor },
3520
+ confidence: byId.has(evidenceFor) ? "explicit" : "correlated",
3521
+ basis: ["attributes.evidenceFor"]
3522
+ });
3523
+ }
3524
+ const acceptedBy = stringAttr(bag, "acceptedBy");
3525
+ if (acceptedBy) {
3526
+ push({
3527
+ type: "accepted-by",
3528
+ fromEventId: event.eventId,
3529
+ ...byId.has(acceptedBy) ? { toEventId: acceptedBy } : { externalRef: acceptedBy },
3530
+ confidence: byId.has(acceptedBy) ? "explicit" : "correlated",
3531
+ basis: ["attributes.acceptedBy"]
3532
+ });
3533
+ }
3534
+ const supersedes = stringAttr(bag, "supersedes");
3535
+ if (supersedes) {
3536
+ push({
3537
+ type: "supersedes",
3538
+ fromEventId: event.eventId,
3539
+ ...byId.has(supersedes) ? { toEventId: supersedes } : { externalRef: supersedes },
3540
+ confidence: byId.has(supersedes) ? "explicit" : "correlated",
3541
+ basis: ["attributes.supersedes"]
3542
+ });
3543
+ }
3544
+ const sourceLineage = stringAttr(bag, "sourceLineage") ?? stringAttr(bag, "sourceEventId");
3545
+ if (sourceLineage) {
3546
+ push({
3547
+ type: "source-lineage",
3548
+ fromEventId: event.eventId,
3549
+ externalRef: sourceLineage,
3550
+ confidence: "explicit",
3551
+ basis: ["attributes.sourceLineage"]
3552
+ });
3553
+ }
3554
+ const unsupported = stringAttr(bag, "relationshipType");
3555
+ if (unsupported && unsupported !== "parent-child" && ![
3556
+ "source-lineage",
3557
+ "attempt-of",
3558
+ "retry-of",
3559
+ "fallback-of",
3560
+ "remediation-of",
3561
+ "evidence-for",
3562
+ "accepted-by",
3563
+ "supersedes"
3564
+ ].includes(unsupported)) {
3565
+ diagnostics.push({
3566
+ code: "AI_RELATIONSHIP_UNSUPPORTED_TYPE",
3567
+ message: `Unsupported relationshipType ${unsupported} was reported without flattening.`,
3568
+ eventId: event.eventId
3569
+ });
3570
+ }
3571
+ }
3572
+ return {
3573
+ relationships: Object.freeze(relationships),
3574
+ diagnostics: Object.freeze(diagnostics)
3575
+ };
3576
+ }
3577
+
3376
3578
  // packages/core/src/checks/trace-facts.ts
3377
3579
  function summarizeSemanticParity(events) {
3378
3580
  const projection = projectLogicalEvents(events);
@@ -3459,6 +3661,7 @@ function buildTraceFacts(input) {
3459
3661
  toolsByName.set(name, Object.freeze([...list]));
3460
3662
  }
3461
3663
  const derived = deriveFailureFacts(projection.logicalEvents);
3664
+ const relationship = deriveRelationshipFacts(events);
3462
3665
  const summary = summarizeSemanticParity(events);
3463
3666
  return {
3464
3667
  rawEvents: Object.freeze([...events]),
@@ -3472,7 +3675,9 @@ function buildTraceFacts(input) {
3472
3675
  failureRoleCounts: derived.failureRoleCounts
3473
3676
  },
3474
3677
  failureFacts: derived.failureFacts,
3475
- failuresByRole: derived.failuresByRole
3678
+ failuresByRole: derived.failuresByRole,
3679
+ relationships: relationship.relationships,
3680
+ relationshipDiagnostics: relationship.diagnostics
3476
3681
  };
3477
3682
  }
3478
3683
 
@@ -4654,20 +4859,20 @@ function parseIsoToMs3(iso) {
4654
4859
  return { ms: parsed, invalidTimestamp: false };
4655
4860
  }
4656
4861
  function mapPersistedSourceToInspect(event) {
4657
- const attrs = event.attributes ?? {};
4862
+ const attrs2 = event.attributes ?? {};
4658
4863
  const sourceName = event.source.name;
4659
4864
  if (sourceName === "pino") {
4660
4865
  return {
4661
4866
  type: "pino",
4662
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4663
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4867
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4868
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4664
4869
  };
4665
4870
  }
4666
4871
  if (sourceName === "winston") {
4667
4872
  return {
4668
4873
  type: "winston",
4669
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4670
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4874
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4875
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4671
4876
  };
4672
4877
  }
4673
4878
  const mapType = (t) => {
@@ -4688,55 +4893,55 @@ function mapPersistedSourceToInspect(event) {
4688
4893
  };
4689
4894
  return {
4690
4895
  type: mapType(event.source.type),
4691
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4692
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4896
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4897
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4693
4898
  };
4694
4899
  }
4695
4900
  function buildInspectAttributes(event) {
4696
- const attrs = event.attributes !== void 0 ? { ...event.attributes } : {};
4901
+ const attrs2 = event.attributes !== void 0 ? { ...event.attributes } : {};
4697
4902
  if (event.inputSummary !== void 0) {
4698
- attrs.inputSummary = event.inputSummary;
4903
+ attrs2.inputSummary = event.inputSummary;
4699
4904
  }
4700
4905
  if (event.outputSummary !== void 0) {
4701
- attrs.outputSummary = event.outputSummary;
4906
+ attrs2.outputSummary = event.outputSummary;
4702
4907
  }
4703
4908
  if (event.error) {
4704
4909
  if (event.error.name !== void 0) {
4705
- attrs.errorName = event.error.name;
4910
+ attrs2.errorName = event.error.name;
4706
4911
  }
4707
- attrs.errorMessage = event.error.message;
4912
+ attrs2.errorMessage = event.error.message;
4708
4913
  if (event.error.code !== void 0) {
4709
- attrs.errorCode = event.error.code;
4914
+ attrs2.errorCode = event.error.code;
4710
4915
  }
4711
4916
  }
4712
4917
  if (event.tokenUsage) {
4713
- attrs.tokens = { ...event.tokenUsage };
4918
+ attrs2.tokens = { ...event.tokenUsage };
4714
4919
  }
4715
4920
  if (event.source.type === "ai-sdk" || event.source.type === "otel") {
4716
- attrs.originalSourceType = event.source.type;
4921
+ attrs2.originalSourceType = event.source.type;
4717
4922
  }
4718
4923
  if (event.source.name !== void 0) {
4719
- attrs.sourceName = event.source.name;
4924
+ attrs2.sourceName = event.source.name;
4720
4925
  }
4721
4926
  if (event.source.version !== void 0) {
4722
- attrs.sourceVersion = event.source.version;
4927
+ attrs2.sourceVersion = event.source.version;
4723
4928
  }
4724
- return attrs;
4929
+ return attrs2;
4725
4930
  }
4726
4931
  function persistedInspectEventToInspectEvent(event) {
4727
4932
  if (!isPersistedInspectEvent(event)) {
4728
4933
  throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
4729
4934
  }
4730
4935
  const ts = parseIsoToMs3(event.timestamp);
4731
- const attrs = buildInspectAttributes(event);
4936
+ const attrs2 = buildInspectAttributes(event);
4732
4937
  if (ts.invalidTimestamp) {
4733
- attrs.invalidTimestamp = true;
4938
+ attrs2.invalidTimestamp = true;
4734
4939
  }
4735
4940
  let status;
4736
4941
  if (event.status === "running" || event.status === "ok" || event.status === "error") {
4737
4942
  status = event.status;
4738
4943
  } else if (event.status === "unknown") {
4739
- attrs.persistedStatus = "unknown";
4944
+ attrs2.persistedStatus = "unknown";
4740
4945
  }
4741
4946
  const out = {
4742
4947
  eventId: event.eventId,
@@ -4746,7 +4951,7 @@ function persistedInspectEventToInspectEvent(event) {
4746
4951
  timestamp: ts.ms,
4747
4952
  confidence: event.confidence,
4748
4953
  source: mapPersistedSourceToInspect(event),
4749
- attributes: compactAttributes3(attrs)
4954
+ attributes: compactAttributes3(attrs2)
4750
4955
  };
4751
4956
  if (event.parentId !== void 0) {
4752
4957
  out.parentId = event.parentId;
@@ -5089,13 +5294,13 @@ function persistedEventsForParsedTrace(parsed) {
5089
5294
  function isRecord10(value) {
5090
5295
  return typeof value === "object" && value !== null && !Array.isArray(value);
5091
5296
  }
5092
- function isNonEmptyString3(value) {
5297
+ function isNonEmptyString4(value) {
5093
5298
  return typeof value === "string" && value.trim() !== "";
5094
5299
  }
5095
5300
  function readStringField(record, keys) {
5096
5301
  for (const key of keys) {
5097
5302
  const value = record[key];
5098
- if (isNonEmptyString3(value)) return value;
5303
+ if (isNonEmptyString4(value)) return value;
5099
5304
  }
5100
5305
  return void 0;
5101
5306
  }
@@ -5229,7 +5434,7 @@ function parseUnixNanoToIso(value) {
5229
5434
  return void 0;
5230
5435
  }
5231
5436
  function parseIsoTime(value) {
5232
- if (!isNonEmptyString3(value)) return void 0;
5437
+ if (!isNonEmptyString4(value)) return void 0;
5233
5438
  const ms = Date.parse(value);
5234
5439
  if (!Number.isFinite(ms)) return void 0;
5235
5440
  return new Date(ms).toISOString();
@@ -6457,11 +6662,11 @@ function boundValue(value, key, maxMetadataValueLength, maxPreviewLength, seen,
6457
6662
  depth + 1
6458
6663
  );
6459
6664
  }
6460
- function redactEventAttributes(attrs, redactor, maxMetadataValueLength, maxPreviewLength) {
6461
- if (!attrs || Object.keys(attrs).length === 0) {
6462
- return attrs;
6665
+ function redactEventAttributes(attrs2, redactor, maxMetadataValueLength, maxPreviewLength) {
6666
+ if (!attrs2 || Object.keys(attrs2).length === 0) {
6667
+ return attrs2;
6463
6668
  }
6464
- const redacted = redactor.redactRecord(attrs);
6669
+ const redacted = redactor.redactRecord(attrs2);
6465
6670
  const seen = /* @__PURE__ */ new WeakSet();
6466
6671
  const bounded = boundAttributeValues(
6467
6672
  redacted,
@@ -6847,7 +7052,7 @@ function exportOpenInference(tree, options) {
6847
7052
  endNs = startNs + unixNano(ev.durationMs);
6848
7053
  }
6849
7054
  const { openInferenceKind } = mapInspectKindToOI(ev.kind, warnings);
6850
- const attrs = {
7055
+ const attrs2 = {
6851
7056
  "openinference.span.kind": openInferenceKind,
6852
7057
  "agent_inspect.kind": ev.kind,
6853
7058
  "agent_inspect.confidence": ev.confidence,
@@ -6857,24 +7062,24 @@ function exportOpenInference(tree, options) {
6857
7062
  "agent_inspect.status": ev.status ?? "unset"
6858
7063
  };
6859
7064
  if (ev.durationMs !== void 0) {
6860
- attrs["agent_inspect.duration_ms"] = ev.durationMs;
7065
+ attrs2["agent_inspect.duration_ms"] = ev.durationMs;
6861
7066
  }
6862
7067
  const meta = ev.attributes;
6863
7068
  if (meta?.model !== void 0 && typeof meta.model === "string") {
6864
- attrs["llm.model_name"] = meta.model;
7069
+ attrs2["llm.model_name"] = meta.model;
6865
7070
  }
6866
7071
  const tokens = meta?.tokens;
6867
7072
  if (tokens && typeof tokens === "object" && tokens !== null) {
6868
7073
  const inp = tokens.input;
6869
7074
  const outp = tokens.output;
6870
- if (typeof inp === "number") attrs["llm.token_count.prompt"] = inp;
6871
- if (typeof outp === "number") attrs["llm.token_count.completion"] = outp;
7075
+ if (typeof inp === "number") attrs2["llm.token_count.prompt"] = inp;
7076
+ if (typeof outp === "number") attrs2["llm.token_count.completion"] = outp;
6872
7077
  }
6873
7078
  if (includeAttributes && meta && typeof meta === "object") {
6874
7079
  for (const [k, v] of Object.entries(meta)) {
6875
7080
  if (k === "tokens" || k === "model") continue;
6876
7081
  if (v !== void 0 && v !== null && typeof v !== "object") {
6877
- attrs[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
7082
+ attrs2[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
6878
7083
  }
6879
7084
  }
6880
7085
  }
@@ -6894,7 +7099,7 @@ function exportOpenInference(tree, options) {
6894
7099
  name: ev.name,
6895
7100
  start_time_unix_nano: startNs.toString(),
6896
7101
  end_time_unix_nano: endNs?.toString(),
6897
- attributes: attrs,
7102
+ attributes: attrs2,
6898
7103
  status
6899
7104
  });
6900
7105
  }
@@ -6918,7 +7123,7 @@ function exportOpenInference(tree, options) {
6918
7123
  function hexFrom2(seed, byteLen) {
6919
7124
  return crypto__default.default.createHash("sha256").update(seed, "utf8").digest("hex").slice(0, byteLen * 2);
6920
7125
  }
6921
- function stringAttr(key, value) {
7126
+ function stringAttr2(key, value) {
6922
7127
  return { key, value: { stringValue: value } };
6923
7128
  }
6924
7129
  function intAttr(key, value) {
@@ -6956,38 +7161,38 @@ function exportOtlpJson(tree, options) {
6956
7161
  if (ev.durationMs !== void 0 && Number.isFinite(ev.durationMs)) {
6957
7162
  endNs = String(Math.round(ev.timestamp * 1e6 + ev.durationMs * 1e6));
6958
7163
  }
6959
- const attrs = [
6960
- stringAttr("agent_inspect.kind", ev.kind),
6961
- stringAttr("agent_inspect.confidence", ev.confidence),
6962
- stringAttr("agent_inspect.source.type", ev.source.type),
6963
- stringAttr("agent_inspect.run_id", tree.runId),
6964
- stringAttr("agent_inspect.event_id", ev.eventId),
6965
- stringAttr("agent_inspect.status", ev.status ?? "unset")
7164
+ const attrs2 = [
7165
+ stringAttr2("agent_inspect.kind", ev.kind),
7166
+ stringAttr2("agent_inspect.confidence", ev.confidence),
7167
+ stringAttr2("agent_inspect.source.type", ev.source.type),
7168
+ stringAttr2("agent_inspect.run_id", tree.runId),
7169
+ stringAttr2("agent_inspect.event_id", ev.eventId),
7170
+ stringAttr2("agent_inspect.status", ev.status ?? "unset")
6966
7171
  ];
6967
7172
  if (ev.durationMs !== void 0) {
6968
- attrs.push(intAttr("agent_inspect.duration_ms", ev.durationMs));
7173
+ attrs2.push(intAttr("agent_inspect.duration_ms", ev.durationMs));
6969
7174
  }
6970
7175
  const op = genAiOperationName(ev.kind);
6971
7176
  if (op !== void 0) {
6972
- attrs.push(stringAttr("gen_ai.operation.name", op));
7177
+ attrs2.push(stringAttr2("gen_ai.operation.name", op));
6973
7178
  }
6974
7179
  const meta = ev.attributes;
6975
7180
  if (meta?.model !== void 0 && typeof meta.model === "string") {
6976
- attrs.push(stringAttr("gen_ai.request.model", meta.model.slice(0, maxLen)));
7181
+ attrs2.push(stringAttr2("gen_ai.request.model", meta.model.slice(0, maxLen)));
6977
7182
  }
6978
7183
  const tokens = meta?.tokens;
6979
7184
  if (tokens && typeof tokens === "object" && tokens !== null) {
6980
7185
  const inp = tokens.input;
6981
7186
  const outp = tokens.output;
6982
- if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
6983
- if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
7187
+ if (typeof inp === "number") attrs2.push(intAttr("gen_ai.usage.input_tokens", inp));
7188
+ if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
6984
7189
  }
6985
7190
  if (includeAttributes && meta && typeof meta === "object") {
6986
7191
  for (const [k, v] of Object.entries(meta)) {
6987
7192
  if (k === "tokens" || k === "model") continue;
6988
7193
  if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
6989
- attrs.push(
6990
- stringAttr(
7194
+ attrs2.push(
7195
+ stringAttr2(
6991
7196
  `agent_inspect.preview.${k}`,
6992
7197
  typeof v === "string" ? v.slice(0, maxLen) : String(v)
6993
7198
  )
@@ -7009,7 +7214,7 @@ function exportOtlpJson(tree, options) {
7009
7214
  name: ev.name,
7010
7215
  kind: "SPAN_KIND_INTERNAL",
7011
7216
  startTimeUnixNano: startNs,
7012
- attributes: attrs,
7217
+ attributes: attrs2,
7013
7218
  status: {
7014
7219
  code: statusCode,
7015
7220
  ...statusMessage !== void 0 ? { message: statusMessage } : {}
@@ -7027,7 +7232,7 @@ function exportOtlpJson(tree, options) {
7027
7232
  resourceSpans: [
7028
7233
  {
7029
7234
  resource: {
7030
- attributes: [stringAttr("service.name", "agent-inspect")]
7235
+ attributes: [stringAttr2("service.name", "agent-inspect")]
7031
7236
  },
7032
7237
  scopeSpans: [
7033
7238
  {