@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.
@@ -472,16 +472,16 @@ function pickRunMetadata(attributes) {
472
472
  return Object.keys(metadata).length > 0 ? metadata : void 0;
473
473
  }
474
474
  function resolveStepId(event) {
475
- const attrs = event.attributes;
476
- if (attrs && typeof attrs.stepId === "string" && attrs.stepId.trim() !== "") {
477
- return attrs.stepId;
475
+ const attrs2 = event.attributes;
476
+ if (attrs2 && typeof attrs2.stepId === "string" && attrs2.stepId.trim() !== "") {
477
+ return attrs2.stepId;
478
478
  }
479
479
  return event.eventId;
480
480
  }
481
481
  function resolveStepType(event) {
482
- const attrs = event.attributes;
483
- if (attrs && typeof attrs.stepType === "string") {
484
- const t = attrs.stepType;
482
+ const attrs2 = event.attributes;
483
+ if (attrs2 && typeof attrs2.stepType === "string") {
484
+ const t = attrs2.stepType;
485
485
  if (t === "run" || t === "llm" || t === "tool" || t === "decision" || t === "logic" || t === "state" || t === "custom") {
486
486
  return t;
487
487
  }
@@ -562,26 +562,26 @@ function fromLegacyStepCompleted(event) {
562
562
  return out;
563
563
  }
564
564
  function fromLegacyOutcomeObserved(event) {
565
- const attrs = event.attributes ?? {};
566
- const observedAtRaw = attrs.observedAt;
565
+ const attrs2 = event.attributes ?? {};
566
+ const observedAtRaw = attrs2.observedAt;
567
567
  const observedAt = typeof observedAtRaw === "string" ? Date.parse(observedAtRaw) : typeof observedAtRaw === "number" && Number.isFinite(observedAtRaw) ? observedAtRaw : resolveTimes(event).timestamp;
568
- const status = attrs.outcomeStatus;
568
+ const status = attrs2.outcomeStatus;
569
569
  const out = {
570
570
  schemaVersion: "0.1",
571
571
  event: "outcome_observed",
572
572
  timestamp: observedAt,
573
573
  runId: event.runId,
574
- outcomeId: typeof attrs.outcomeId === "string" ? attrs.outcomeId : event.eventId,
574
+ outcomeId: typeof attrs2.outcomeId === "string" ? attrs2.outcomeId : event.eventId,
575
575
  name: event.name,
576
- expectation: typeof attrs.expectation === "string" ? attrs.expectation : event.name,
576
+ expectation: typeof attrs2.expectation === "string" ? attrs2.expectation : event.name,
577
577
  status: status === "passed" || status === "failed" || status === "unknown" || status === "skipped" ? status : "unknown",
578
578
  observedAt
579
579
  };
580
580
  if (event.parentId !== void 0) out.parentId = event.parentId;
581
- if (typeof attrs.method === "string") out.method = attrs.method;
582
- if (attrs.actual !== void 0) out.actual = attrs.actual;
581
+ if (typeof attrs2.method === "string") out.method = attrs2.method;
582
+ if (attrs2.actual !== void 0) out.actual = attrs2.actual;
583
583
  if (event.outputSummary !== void 0) out.actual = event.outputSummary;
584
- if (attrs.evidence !== void 0) out.evidence = attrs.evidence;
584
+ if (attrs2.evidence !== void 0) out.evidence = attrs2.evidence;
585
585
  return out;
586
586
  }
587
587
  function fromNativeOutcome(event) {
@@ -1989,6 +1989,63 @@ async function loadTraceMetadataList(_traceDir, fileNames, getPath) {
1989
1989
  return metas;
1990
1990
  }
1991
1991
 
1992
+ // packages/core/src/sessions/metadata.ts
1993
+ function isNonEmptyString3(value) {
1994
+ return typeof value === "string" && value.trim() !== "";
1995
+ }
1996
+ function finitePositiveInt(value) {
1997
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 1) {
1998
+ return void 0;
1999
+ }
2000
+ return Math.trunc(value);
2001
+ }
2002
+ function extractSessionWorkflowMetadata(record) {
2003
+ if (!record) return void 0;
2004
+ const out = {};
2005
+ let found = false;
2006
+ const assignString = (key, value) => {
2007
+ if (isNonEmptyString3(value)) {
2008
+ out[key] = value.trim();
2009
+ found = true;
2010
+ }
2011
+ };
2012
+ assignString("sessionId", record.sessionId);
2013
+ assignString("conversationId", record.conversationId);
2014
+ assignString("groupId", record.groupId);
2015
+ assignString("parentGroupId", record.parentGroupId);
2016
+ assignString("retryOf", record.retryOf);
2017
+ assignString("retryReason", record.retryReason);
2018
+ assignString("handoffFrom", record.handoffFrom);
2019
+ assignString("handoffTo", record.handoffTo);
2020
+ assignString("subAgentId", record.subAgentId);
2021
+ assignString("subAgentName", record.subAgentName);
2022
+ assignString("jobId", record.jobId);
2023
+ assignString("queueName", record.queueName);
2024
+ assignString("workflowName", record.workflowName);
2025
+ assignString("workflowStep", record.workflowStep);
2026
+ assignString("toolCallId", record.toolCallId);
2027
+ assignString("mcpToolCallId", record.mcpToolCallId);
2028
+ assignString("linkedStepId", record.linkedStepId);
2029
+ assignString("operationId", record.operationId);
2030
+ assignString("attemptId", record.attemptId);
2031
+ assignString("fallbackOf", record.fallbackOf);
2032
+ assignString("idempotencyKey", record.idempotencyKey);
2033
+ assignString("correlationId", record.correlationId);
2034
+ assignString("requestId", record.requestId);
2035
+ assignString("decisionId", record.decisionId);
2036
+ const attempt = finitePositiveInt(record.attempt);
2037
+ if (attempt !== void 0) {
2038
+ out.attempt = attempt;
2039
+ found = true;
2040
+ }
2041
+ const attemptNumber = finitePositiveInt(record.attemptNumber);
2042
+ if (attemptNumber !== void 0) {
2043
+ out.attemptNumber = attemptNumber;
2044
+ found = true;
2045
+ }
2046
+ return found ? out : void 0;
2047
+ }
2048
+
1992
2049
  // packages/core/src/bundle/safety-status.ts
1993
2050
  function aggregateBundleSafeStatus(statuses) {
1994
2051
  if (statuses.length === 0) return "UNKNOWN";
@@ -2201,17 +2258,17 @@ function stableJson(value, pretty) {
2201
2258
  const sorted = sortKeysDeep(value);
2202
2259
  return pretty === true ? JSON.stringify(sorted, null, 2) : JSON.stringify(sorted);
2203
2260
  }
2204
- function compactAttributes(attrs, options) {
2205
- if (attrs === void 0) return {};
2261
+ function compactAttributes(attrs2, options) {
2262
+ if (attrs2 === void 0) return {};
2206
2263
  const maxLen = options?.maxLength ?? 500;
2207
2264
  const redacted = options?.redacted ?? true;
2208
2265
  const out = {};
2209
- for (const key of Object.keys(attrs).sort()) {
2266
+ for (const key of Object.keys(attrs2).sort()) {
2210
2267
  if (redacted && shouldRedactKey(key)) {
2211
2268
  out[key] = "[REDACTED]";
2212
2269
  continue;
2213
2270
  }
2214
- const v = attrs[key];
2271
+ const v = attrs2[key];
2215
2272
  out[key] = compactValue(v, maxLen, redacted);
2216
2273
  }
2217
2274
  return out;
@@ -3022,10 +3079,10 @@ function projectLogicalEvents(events) {
3022
3079
  };
3023
3080
  }
3024
3081
  function resolveCanonicalToolName(event) {
3025
- const attrs = event.attributes;
3026
- const direct = pickString(attrs, ["toolName", "tool"]);
3082
+ const attrs2 = event.attributes;
3083
+ const direct = pickString(attrs2, ["toolName", "tool"]);
3027
3084
  if (direct) return direct;
3028
- const metadata = attrs?.metadata;
3085
+ const metadata = attrs2?.metadata;
3029
3086
  if (isRecord6(metadata)) {
3030
3087
  const nested = pickString(metadata, ["toolName", "tool"]);
3031
3088
  if (nested) return nested;
@@ -3067,10 +3124,10 @@ function pickNumber(record, keys) {
3067
3124
  return void 0;
3068
3125
  }
3069
3126
  function eventMetadata(event) {
3070
- const attrs = isRecord7(event.attributes) ? event.attributes : void 0;
3071
- const nested = attrs !== void 0 && isRecord7(attrs.metadata) ? attrs.metadata : void 0;
3127
+ const attrs2 = isRecord7(event.attributes) ? event.attributes : void 0;
3128
+ const nested = attrs2 !== void 0 && isRecord7(attrs2.metadata) ? attrs2.metadata : void 0;
3072
3129
  return {
3073
- ...attrs ?? {},
3130
+ ...attrs2 ?? {},
3074
3131
  ...nested ?? {}
3075
3132
  };
3076
3133
  }
@@ -3363,6 +3420,151 @@ function deriveFailureFacts(logicalEvents) {
3363
3420
  };
3364
3421
  }
3365
3422
 
3423
+ // packages/core/src/checks/relationship-facts.ts
3424
+ function attrs(event) {
3425
+ return event.attributes && typeof event.attributes === "object" ? event.attributes : {};
3426
+ }
3427
+ function stringAttr(record, key) {
3428
+ const value = record[key];
3429
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
3430
+ }
3431
+ function deriveRelationshipFacts(events) {
3432
+ const relationships = [];
3433
+ const diagnostics = [];
3434
+ const byId = new Map(events.map((event) => [event.eventId, event]));
3435
+ const seen = /* @__PURE__ */ new Set();
3436
+ const push = (edge) => {
3437
+ const key = `${edge.type}:${edge.fromEventId}:${edge.toEventId ?? ""}:${edge.externalRef ?? ""}`;
3438
+ if (seen.has(key)) return;
3439
+ seen.add(key);
3440
+ relationships.push(edge);
3441
+ };
3442
+ for (const event of events) {
3443
+ if (event.parentId) {
3444
+ push({
3445
+ type: "parent-child",
3446
+ fromEventId: event.parentId,
3447
+ toEventId: event.eventId,
3448
+ confidence: byId.has(event.parentId) ? "explicit" : "unknown",
3449
+ basis: ["persisted.parentId"]
3450
+ });
3451
+ if (!byId.has(event.parentId)) {
3452
+ diagnostics.push({
3453
+ code: "AI_RELATIONSHIP_PARENT_MISSING",
3454
+ message: `parentId ${event.parentId} is not present in the event set.`,
3455
+ eventId: event.eventId
3456
+ });
3457
+ }
3458
+ }
3459
+ const bag = attrs(event);
3460
+ const meta = extractSessionWorkflowMetadata(bag) ?? {};
3461
+ const nested = bag.metadata && typeof bag.metadata === "object" ? extractSessionWorkflowMetadata(bag.metadata) : void 0;
3462
+ const workflow = { ...meta, ...nested };
3463
+ if (workflow.retryOf) {
3464
+ const target = events.find((candidate) => candidate.runId === workflow.retryOf);
3465
+ push({
3466
+ type: "retry-of",
3467
+ fromEventId: event.eventId,
3468
+ ...target ? { toEventId: target.eventId } : {},
3469
+ externalRef: workflow.retryOf,
3470
+ confidence: target ? "explicit" : "correlated",
3471
+ basis: ["attributes.retryOf"]
3472
+ });
3473
+ }
3474
+ const attemptOf = stringAttr(bag, "attemptOf") ?? stringAttr(bag, "operationId");
3475
+ if (attemptOf && workflow.attempt !== void 0) {
3476
+ push({
3477
+ type: "attempt-of",
3478
+ fromEventId: event.eventId,
3479
+ externalRef: attemptOf,
3480
+ confidence: "explicit",
3481
+ basis: workflow.attempt !== void 0 ? ["attributes.attempt", "attributes.operationId"] : ["attributes.operationId"]
3482
+ });
3483
+ }
3484
+ const fallbackOf = stringAttr(bag, "fallbackOf");
3485
+ if (fallbackOf) {
3486
+ push({
3487
+ type: "fallback-of",
3488
+ fromEventId: event.eventId,
3489
+ externalRef: fallbackOf,
3490
+ confidence: "explicit",
3491
+ basis: ["attributes.fallbackOf"]
3492
+ });
3493
+ }
3494
+ const remediationOf = stringAttr(bag, "remediationOf");
3495
+ if (remediationOf) {
3496
+ push({
3497
+ type: "remediation-of",
3498
+ fromEventId: event.eventId,
3499
+ externalRef: remediationOf,
3500
+ confidence: "explicit",
3501
+ basis: ["attributes.remediationOf"]
3502
+ });
3503
+ }
3504
+ const evidenceFor = stringAttr(bag, "evidenceFor");
3505
+ if (evidenceFor) {
3506
+ push({
3507
+ type: "evidence-for",
3508
+ fromEventId: event.eventId,
3509
+ ...byId.has(evidenceFor) ? { toEventId: evidenceFor } : { externalRef: evidenceFor },
3510
+ confidence: byId.has(evidenceFor) ? "explicit" : "correlated",
3511
+ basis: ["attributes.evidenceFor"]
3512
+ });
3513
+ }
3514
+ const acceptedBy = stringAttr(bag, "acceptedBy");
3515
+ if (acceptedBy) {
3516
+ push({
3517
+ type: "accepted-by",
3518
+ fromEventId: event.eventId,
3519
+ ...byId.has(acceptedBy) ? { toEventId: acceptedBy } : { externalRef: acceptedBy },
3520
+ confidence: byId.has(acceptedBy) ? "explicit" : "correlated",
3521
+ basis: ["attributes.acceptedBy"]
3522
+ });
3523
+ }
3524
+ const supersedes = stringAttr(bag, "supersedes");
3525
+ if (supersedes) {
3526
+ push({
3527
+ type: "supersedes",
3528
+ fromEventId: event.eventId,
3529
+ ...byId.has(supersedes) ? { toEventId: supersedes } : { externalRef: supersedes },
3530
+ confidence: byId.has(supersedes) ? "explicit" : "correlated",
3531
+ basis: ["attributes.supersedes"]
3532
+ });
3533
+ }
3534
+ const sourceLineage = stringAttr(bag, "sourceLineage") ?? stringAttr(bag, "sourceEventId");
3535
+ if (sourceLineage) {
3536
+ push({
3537
+ type: "source-lineage",
3538
+ fromEventId: event.eventId,
3539
+ externalRef: sourceLineage,
3540
+ confidence: "explicit",
3541
+ basis: ["attributes.sourceLineage"]
3542
+ });
3543
+ }
3544
+ const unsupported = stringAttr(bag, "relationshipType");
3545
+ if (unsupported && unsupported !== "parent-child" && ![
3546
+ "source-lineage",
3547
+ "attempt-of",
3548
+ "retry-of",
3549
+ "fallback-of",
3550
+ "remediation-of",
3551
+ "evidence-for",
3552
+ "accepted-by",
3553
+ "supersedes"
3554
+ ].includes(unsupported)) {
3555
+ diagnostics.push({
3556
+ code: "AI_RELATIONSHIP_UNSUPPORTED_TYPE",
3557
+ message: `Unsupported relationshipType ${unsupported} was reported without flattening.`,
3558
+ eventId: event.eventId
3559
+ });
3560
+ }
3561
+ }
3562
+ return {
3563
+ relationships: Object.freeze(relationships),
3564
+ diagnostics: Object.freeze(diagnostics)
3565
+ };
3566
+ }
3567
+
3366
3568
  // packages/core/src/checks/trace-facts.ts
3367
3569
  function summarizeSemanticParity(events) {
3368
3570
  const projection = projectLogicalEvents(events);
@@ -3449,6 +3651,7 @@ function buildTraceFacts(input) {
3449
3651
  toolsByName.set(name, Object.freeze([...list]));
3450
3652
  }
3451
3653
  const derived = deriveFailureFacts(projection.logicalEvents);
3654
+ const relationship = deriveRelationshipFacts(events);
3452
3655
  const summary = summarizeSemanticParity(events);
3453
3656
  return {
3454
3657
  rawEvents: Object.freeze([...events]),
@@ -3462,7 +3665,9 @@ function buildTraceFacts(input) {
3462
3665
  failureRoleCounts: derived.failureRoleCounts
3463
3666
  },
3464
3667
  failureFacts: derived.failureFacts,
3465
- failuresByRole: derived.failuresByRole
3668
+ failuresByRole: derived.failuresByRole,
3669
+ relationships: relationship.relationships,
3670
+ relationshipDiagnostics: relationship.diagnostics
3466
3671
  };
3467
3672
  }
3468
3673
 
@@ -4644,20 +4849,20 @@ function parseIsoToMs3(iso) {
4644
4849
  return { ms: parsed, invalidTimestamp: false };
4645
4850
  }
4646
4851
  function mapPersistedSourceToInspect(event) {
4647
- const attrs = event.attributes ?? {};
4852
+ const attrs2 = event.attributes ?? {};
4648
4853
  const sourceName = event.source.name;
4649
4854
  if (sourceName === "pino") {
4650
4855
  return {
4651
4856
  type: "pino",
4652
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4653
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4857
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4858
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4654
4859
  };
4655
4860
  }
4656
4861
  if (sourceName === "winston") {
4657
4862
  return {
4658
4863
  type: "winston",
4659
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4660
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4864
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4865
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4661
4866
  };
4662
4867
  }
4663
4868
  const mapType = (t) => {
@@ -4678,55 +4883,55 @@ function mapPersistedSourceToInspect(event) {
4678
4883
  };
4679
4884
  return {
4680
4885
  type: mapType(event.source.type),
4681
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4682
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4886
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4887
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4683
4888
  };
4684
4889
  }
4685
4890
  function buildInspectAttributes(event) {
4686
- const attrs = event.attributes !== void 0 ? { ...event.attributes } : {};
4891
+ const attrs2 = event.attributes !== void 0 ? { ...event.attributes } : {};
4687
4892
  if (event.inputSummary !== void 0) {
4688
- attrs.inputSummary = event.inputSummary;
4893
+ attrs2.inputSummary = event.inputSummary;
4689
4894
  }
4690
4895
  if (event.outputSummary !== void 0) {
4691
- attrs.outputSummary = event.outputSummary;
4896
+ attrs2.outputSummary = event.outputSummary;
4692
4897
  }
4693
4898
  if (event.error) {
4694
4899
  if (event.error.name !== void 0) {
4695
- attrs.errorName = event.error.name;
4900
+ attrs2.errorName = event.error.name;
4696
4901
  }
4697
- attrs.errorMessage = event.error.message;
4902
+ attrs2.errorMessage = event.error.message;
4698
4903
  if (event.error.code !== void 0) {
4699
- attrs.errorCode = event.error.code;
4904
+ attrs2.errorCode = event.error.code;
4700
4905
  }
4701
4906
  }
4702
4907
  if (event.tokenUsage) {
4703
- attrs.tokens = { ...event.tokenUsage };
4908
+ attrs2.tokens = { ...event.tokenUsage };
4704
4909
  }
4705
4910
  if (event.source.type === "ai-sdk" || event.source.type === "otel") {
4706
- attrs.originalSourceType = event.source.type;
4911
+ attrs2.originalSourceType = event.source.type;
4707
4912
  }
4708
4913
  if (event.source.name !== void 0) {
4709
- attrs.sourceName = event.source.name;
4914
+ attrs2.sourceName = event.source.name;
4710
4915
  }
4711
4916
  if (event.source.version !== void 0) {
4712
- attrs.sourceVersion = event.source.version;
4917
+ attrs2.sourceVersion = event.source.version;
4713
4918
  }
4714
- return attrs;
4919
+ return attrs2;
4715
4920
  }
4716
4921
  function persistedInspectEventToInspectEvent(event) {
4717
4922
  if (!isPersistedInspectEvent(event)) {
4718
4923
  throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
4719
4924
  }
4720
4925
  const ts = parseIsoToMs3(event.timestamp);
4721
- const attrs = buildInspectAttributes(event);
4926
+ const attrs2 = buildInspectAttributes(event);
4722
4927
  if (ts.invalidTimestamp) {
4723
- attrs.invalidTimestamp = true;
4928
+ attrs2.invalidTimestamp = true;
4724
4929
  }
4725
4930
  let status;
4726
4931
  if (event.status === "running" || event.status === "ok" || event.status === "error") {
4727
4932
  status = event.status;
4728
4933
  } else if (event.status === "unknown") {
4729
- attrs.persistedStatus = "unknown";
4934
+ attrs2.persistedStatus = "unknown";
4730
4935
  }
4731
4936
  const out = {
4732
4937
  eventId: event.eventId,
@@ -4736,7 +4941,7 @@ function persistedInspectEventToInspectEvent(event) {
4736
4941
  timestamp: ts.ms,
4737
4942
  confidence: event.confidence,
4738
4943
  source: mapPersistedSourceToInspect(event),
4739
- attributes: compactAttributes3(attrs)
4944
+ attributes: compactAttributes3(attrs2)
4740
4945
  };
4741
4946
  if (event.parentId !== void 0) {
4742
4947
  out.parentId = event.parentId;
@@ -5079,13 +5284,13 @@ function persistedEventsForParsedTrace(parsed) {
5079
5284
  function isRecord10(value) {
5080
5285
  return typeof value === "object" && value !== null && !Array.isArray(value);
5081
5286
  }
5082
- function isNonEmptyString3(value) {
5287
+ function isNonEmptyString4(value) {
5083
5288
  return typeof value === "string" && value.trim() !== "";
5084
5289
  }
5085
5290
  function readStringField(record, keys) {
5086
5291
  for (const key of keys) {
5087
5292
  const value = record[key];
5088
- if (isNonEmptyString3(value)) return value;
5293
+ if (isNonEmptyString4(value)) return value;
5089
5294
  }
5090
5295
  return void 0;
5091
5296
  }
@@ -5219,7 +5424,7 @@ function parseUnixNanoToIso(value) {
5219
5424
  return void 0;
5220
5425
  }
5221
5426
  function parseIsoTime(value) {
5222
- if (!isNonEmptyString3(value)) return void 0;
5427
+ if (!isNonEmptyString4(value)) return void 0;
5223
5428
  const ms = Date.parse(value);
5224
5429
  if (!Number.isFinite(ms)) return void 0;
5225
5430
  return new Date(ms).toISOString();
@@ -6447,11 +6652,11 @@ function boundValue(value, key, maxMetadataValueLength, maxPreviewLength, seen,
6447
6652
  depth + 1
6448
6653
  );
6449
6654
  }
6450
- function redactEventAttributes(attrs, redactor, maxMetadataValueLength, maxPreviewLength) {
6451
- if (!attrs || Object.keys(attrs).length === 0) {
6452
- return attrs;
6655
+ function redactEventAttributes(attrs2, redactor, maxMetadataValueLength, maxPreviewLength) {
6656
+ if (!attrs2 || Object.keys(attrs2).length === 0) {
6657
+ return attrs2;
6453
6658
  }
6454
- const redacted = redactor.redactRecord(attrs);
6659
+ const redacted = redactor.redactRecord(attrs2);
6455
6660
  const seen = /* @__PURE__ */ new WeakSet();
6456
6661
  const bounded = boundAttributeValues(
6457
6662
  redacted,
@@ -6837,7 +7042,7 @@ function exportOpenInference(tree, options) {
6837
7042
  endNs = startNs + unixNano(ev.durationMs);
6838
7043
  }
6839
7044
  const { openInferenceKind } = mapInspectKindToOI(ev.kind, warnings);
6840
- const attrs = {
7045
+ const attrs2 = {
6841
7046
  "openinference.span.kind": openInferenceKind,
6842
7047
  "agent_inspect.kind": ev.kind,
6843
7048
  "agent_inspect.confidence": ev.confidence,
@@ -6847,24 +7052,24 @@ function exportOpenInference(tree, options) {
6847
7052
  "agent_inspect.status": ev.status ?? "unset"
6848
7053
  };
6849
7054
  if (ev.durationMs !== void 0) {
6850
- attrs["agent_inspect.duration_ms"] = ev.durationMs;
7055
+ attrs2["agent_inspect.duration_ms"] = ev.durationMs;
6851
7056
  }
6852
7057
  const meta = ev.attributes;
6853
7058
  if (meta?.model !== void 0 && typeof meta.model === "string") {
6854
- attrs["llm.model_name"] = meta.model;
7059
+ attrs2["llm.model_name"] = meta.model;
6855
7060
  }
6856
7061
  const tokens = meta?.tokens;
6857
7062
  if (tokens && typeof tokens === "object" && tokens !== null) {
6858
7063
  const inp = tokens.input;
6859
7064
  const outp = tokens.output;
6860
- if (typeof inp === "number") attrs["llm.token_count.prompt"] = inp;
6861
- if (typeof outp === "number") attrs["llm.token_count.completion"] = outp;
7065
+ if (typeof inp === "number") attrs2["llm.token_count.prompt"] = inp;
7066
+ if (typeof outp === "number") attrs2["llm.token_count.completion"] = outp;
6862
7067
  }
6863
7068
  if (includeAttributes && meta && typeof meta === "object") {
6864
7069
  for (const [k, v] of Object.entries(meta)) {
6865
7070
  if (k === "tokens" || k === "model") continue;
6866
7071
  if (v !== void 0 && v !== null && typeof v !== "object") {
6867
- attrs[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
7072
+ attrs2[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
6868
7073
  }
6869
7074
  }
6870
7075
  }
@@ -6884,7 +7089,7 @@ function exportOpenInference(tree, options) {
6884
7089
  name: ev.name,
6885
7090
  start_time_unix_nano: startNs.toString(),
6886
7091
  end_time_unix_nano: endNs?.toString(),
6887
- attributes: attrs,
7092
+ attributes: attrs2,
6888
7093
  status
6889
7094
  });
6890
7095
  }
@@ -6908,7 +7113,7 @@ function exportOpenInference(tree, options) {
6908
7113
  function hexFrom2(seed, byteLen) {
6909
7114
  return crypto.createHash("sha256").update(seed, "utf8").digest("hex").slice(0, byteLen * 2);
6910
7115
  }
6911
- function stringAttr(key, value) {
7116
+ function stringAttr2(key, value) {
6912
7117
  return { key, value: { stringValue: value } };
6913
7118
  }
6914
7119
  function intAttr(key, value) {
@@ -6946,38 +7151,38 @@ function exportOtlpJson(tree, options) {
6946
7151
  if (ev.durationMs !== void 0 && Number.isFinite(ev.durationMs)) {
6947
7152
  endNs = String(Math.round(ev.timestamp * 1e6 + ev.durationMs * 1e6));
6948
7153
  }
6949
- const attrs = [
6950
- stringAttr("agent_inspect.kind", ev.kind),
6951
- stringAttr("agent_inspect.confidence", ev.confidence),
6952
- stringAttr("agent_inspect.source.type", ev.source.type),
6953
- stringAttr("agent_inspect.run_id", tree.runId),
6954
- stringAttr("agent_inspect.event_id", ev.eventId),
6955
- stringAttr("agent_inspect.status", ev.status ?? "unset")
7154
+ const attrs2 = [
7155
+ stringAttr2("agent_inspect.kind", ev.kind),
7156
+ stringAttr2("agent_inspect.confidence", ev.confidence),
7157
+ stringAttr2("agent_inspect.source.type", ev.source.type),
7158
+ stringAttr2("agent_inspect.run_id", tree.runId),
7159
+ stringAttr2("agent_inspect.event_id", ev.eventId),
7160
+ stringAttr2("agent_inspect.status", ev.status ?? "unset")
6956
7161
  ];
6957
7162
  if (ev.durationMs !== void 0) {
6958
- attrs.push(intAttr("agent_inspect.duration_ms", ev.durationMs));
7163
+ attrs2.push(intAttr("agent_inspect.duration_ms", ev.durationMs));
6959
7164
  }
6960
7165
  const op = genAiOperationName(ev.kind);
6961
7166
  if (op !== void 0) {
6962
- attrs.push(stringAttr("gen_ai.operation.name", op));
7167
+ attrs2.push(stringAttr2("gen_ai.operation.name", op));
6963
7168
  }
6964
7169
  const meta = ev.attributes;
6965
7170
  if (meta?.model !== void 0 && typeof meta.model === "string") {
6966
- attrs.push(stringAttr("gen_ai.request.model", meta.model.slice(0, maxLen)));
7171
+ attrs2.push(stringAttr2("gen_ai.request.model", meta.model.slice(0, maxLen)));
6967
7172
  }
6968
7173
  const tokens = meta?.tokens;
6969
7174
  if (tokens && typeof tokens === "object" && tokens !== null) {
6970
7175
  const inp = tokens.input;
6971
7176
  const outp = tokens.output;
6972
- if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
6973
- if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
7177
+ if (typeof inp === "number") attrs2.push(intAttr("gen_ai.usage.input_tokens", inp));
7178
+ if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
6974
7179
  }
6975
7180
  if (includeAttributes && meta && typeof meta === "object") {
6976
7181
  for (const [k, v] of Object.entries(meta)) {
6977
7182
  if (k === "tokens" || k === "model") continue;
6978
7183
  if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
6979
- attrs.push(
6980
- stringAttr(
7184
+ attrs2.push(
7185
+ stringAttr2(
6981
7186
  `agent_inspect.preview.${k}`,
6982
7187
  typeof v === "string" ? v.slice(0, maxLen) : String(v)
6983
7188
  )
@@ -6999,7 +7204,7 @@ function exportOtlpJson(tree, options) {
6999
7204
  name: ev.name,
7000
7205
  kind: "SPAN_KIND_INTERNAL",
7001
7206
  startTimeUnixNano: startNs,
7002
- attributes: attrs,
7207
+ attributes: attrs2,
7003
7208
  status: {
7004
7209
  code: statusCode,
7005
7210
  ...statusMessage !== void 0 ? { message: statusMessage } : {}
@@ -7017,7 +7222,7 @@ function exportOtlpJson(tree, options) {
7017
7222
  resourceSpans: [
7018
7223
  {
7019
7224
  resource: {
7020
- attributes: [stringAttr("service.name", "agent-inspect")]
7225
+ attributes: [stringAttr2("service.name", "agent-inspect")]
7021
7226
  },
7022
7227
  scopeSpans: [
7023
7228
  {
@@ -8446,5 +8651,5 @@ async function runReadOnlyMcpServer(options = {}) {
8446
8651
  }
8447
8652
 
8448
8653
  export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
8449
- //# sourceMappingURL=chunk-WRRQTBGF.mjs.map
8450
- //# sourceMappingURL=chunk-WRRQTBGF.mjs.map
8654
+ //# sourceMappingURL=chunk-URVZD6JW.mjs.map
8655
+ //# sourceMappingURL=chunk-URVZD6JW.mjs.map