@agent-inspect/mcp-server 6.31.17 → 6.31.19

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.
@@ -2558,7 +2558,7 @@ function extractSessionWorkflowMetadata(record) {
2558
2558
  assignString("conversationId", record.conversationId);
2559
2559
  assignString("groupId", record.groupId);
2560
2560
  assignString("parentGroupId", record.parentGroupId);
2561
- assignString("retryOf", record.retryOf);
2561
+ assignString("retryOf", record.retryOf ?? record["agent_inspect.retry_of"]);
2562
2562
  assignString("retryReason", record.retryReason);
2563
2563
  assignString("handoffFrom", record.handoffFrom);
2564
2564
  assignString("handoffTo", record.handoffTo);
@@ -2571,8 +2571,8 @@ function extractSessionWorkflowMetadata(record) {
2571
2571
  assignString("toolCallId", record.toolCallId);
2572
2572
  assignString("mcpToolCallId", record.mcpToolCallId);
2573
2573
  assignString("linkedStepId", record.linkedStepId);
2574
- assignString("operationId", record.operationId);
2575
- assignString("attemptId", record.attemptId);
2574
+ assignString("operationId", record.operationId ?? record["agent_inspect.operation_id"]);
2575
+ assignString("attemptId", record.attemptId ?? record["agent_inspect.attempt_id"]);
2576
2576
  assignString("fallbackOf", record.fallbackOf);
2577
2577
  assignString("idempotencyKey", record.idempotencyKey);
2578
2578
  assignString("correlationId", record.correlationId);
@@ -2583,7 +2583,9 @@ function extractSessionWorkflowMetadata(record) {
2583
2583
  out.attempt = attempt;
2584
2584
  found = true;
2585
2585
  }
2586
- const attemptNumber = finitePositiveInt(record.attemptNumber);
2586
+ const attemptNumber = finitePositiveInt(
2587
+ record.attemptNumber ?? record["agent_inspect.attempt_number"]
2588
+ );
2587
2589
  if (attemptNumber !== void 0) {
2588
2590
  out.attemptNumber = attemptNumber;
2589
2591
  found = true;
@@ -6410,6 +6412,70 @@ function mapOtlpEvents(value, pathPrefix) {
6410
6412
  unsupportedFields
6411
6413
  };
6412
6414
  }
6415
+ function promoteAgentInspectWorkflowIdentity(attributes, pathPrefix) {
6416
+ const warnings = [];
6417
+ const mapping = [
6418
+ ["agent_inspect.operation_id", "operationId", "string"],
6419
+ ["agent_inspect.attempt_id", "attemptId", "string"],
6420
+ ["agent_inspect.retry_of", "retryOf", "string"],
6421
+ ["agent_inspect.attempt_number", "attemptNumber", "int"]
6422
+ ];
6423
+ const metadata = attributes.metadata && typeof attributes.metadata === "object" && !Array.isArray(attributes.metadata) ? { ...attributes.metadata } : {};
6424
+ for (const [dotted, camel, kind] of mapping) {
6425
+ const raw = attributes[dotted];
6426
+ if (raw === void 0 || raw === null) continue;
6427
+ let promoted;
6428
+ if (kind === "int") {
6429
+ const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
6430
+ if (!Number.isFinite(n) || n < 1) {
6431
+ warnings.push({
6432
+ code: "otlp_identity_invalid",
6433
+ message: `Ignoring invalid ${dotted} identity value.`,
6434
+ severity: "warning",
6435
+ field: `${pathPrefix}.${dotted}`
6436
+ });
6437
+ continue;
6438
+ }
6439
+ promoted = Math.trunc(n);
6440
+ } else if (typeof raw === "string" && raw.trim() !== "") {
6441
+ promoted = raw.trim();
6442
+ } else {
6443
+ warnings.push({
6444
+ code: "otlp_identity_invalid",
6445
+ message: `Ignoring non-string ${dotted} identity value.`,
6446
+ severity: "warning",
6447
+ field: `${pathPrefix}.${dotted}`
6448
+ });
6449
+ continue;
6450
+ }
6451
+ const direct = attributes[camel];
6452
+ const nested = metadata[camel];
6453
+ if (direct !== void 0 && direct !== promoted) {
6454
+ warnings.push({
6455
+ code: "otlp_identity_conflict",
6456
+ message: `Conflicting ${camel}: attributes.${camel} vs ${dotted}; keeping camelCase.`,
6457
+ severity: "warning",
6458
+ field: `${pathPrefix}.${dotted}`
6459
+ });
6460
+ continue;
6461
+ }
6462
+ if (nested !== void 0 && nested !== promoted && direct === void 0) {
6463
+ warnings.push({
6464
+ code: "otlp_identity_conflict",
6465
+ message: `Conflicting ${camel}: attributes.metadata.${camel} vs ${dotted}; keeping nested.`,
6466
+ severity: "warning",
6467
+ field: `${pathPrefix}.${dotted}`
6468
+ });
6469
+ continue;
6470
+ }
6471
+ if (direct === void 0) attributes[camel] = promoted;
6472
+ if (nested === void 0) metadata[camel] = promoted;
6473
+ }
6474
+ if (Object.keys(metadata).length > 0) {
6475
+ attributes.metadata = metadata;
6476
+ }
6477
+ return warnings;
6478
+ }
6413
6479
  function mapOtlpSpan(context) {
6414
6480
  const { span, pathPrefix } = context;
6415
6481
  const warnings = [];
@@ -6441,6 +6507,7 @@ function mapOtlpSpan(context) {
6441
6507
  if (context.scopeVersion !== void 0) {
6442
6508
  attributes["scope.version"] = context.scopeVersion;
6443
6509
  }
6510
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
6444
6511
  for (const [key, value] of Object.entries(span)) {
6445
6512
  if (OTLP_SPAN_KEYS.has(key)) continue;
6446
6513
  unsupportedFields.push(`${pathPrefix}.${key}`);
@@ -6478,6 +6545,7 @@ function mapOtlpSpan(context) {
6478
6545
  if (events.events !== void 0) {
6479
6546
  attributes["otlp.events"] = events.events;
6480
6547
  }
6548
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
6481
6549
  const traceId = readStringField(span, ["traceId"]) ?? "trace-unknown";
6482
6550
  const spanId = readStringField(span, ["spanId"]) ?? "span-unknown";
6483
6551
  const parentSpanId = readStringField(span, ["parentSpanId"]);
@@ -7582,6 +7650,51 @@ function genAiOperationName(kind) {
7582
7650
  return void 0;
7583
7651
  }
7584
7652
  }
7653
+ var STRUCTURAL_IDENTITY_KEYS = [
7654
+ "operationId",
7655
+ "attemptId",
7656
+ "retryOf",
7657
+ "attemptNumber",
7658
+ "attempt"
7659
+ ];
7660
+ function pickBoundedIdentityString(bag, key, maxLen) {
7661
+ if (!bag || typeof bag !== "object") return void 0;
7662
+ const direct = bag[key];
7663
+ if (typeof direct === "string" && direct.trim() !== "") {
7664
+ return direct.trim().slice(0, maxLen);
7665
+ }
7666
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
7667
+ if (typeof nested === "string" && nested.trim() !== "") {
7668
+ return nested.trim().slice(0, maxLen);
7669
+ }
7670
+ return void 0;
7671
+ }
7672
+ function pickBoundedIdentityNumber(bag, key) {
7673
+ if (!bag || typeof bag !== "object") return void 0;
7674
+ const direct = bag[key];
7675
+ if (typeof direct === "number" && Number.isFinite(direct)) return direct;
7676
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
7677
+ if (typeof nested === "number" && Number.isFinite(nested)) return nested;
7678
+ return void 0;
7679
+ }
7680
+ function appendStructuralIdentityAttrs(attrs2, meta, maxLen) {
7681
+ const operationId = pickBoundedIdentityString(meta, "operationId", maxLen);
7682
+ if (operationId !== void 0) {
7683
+ attrs2.push(stringAttr2("agent_inspect.operation_id", operationId));
7684
+ }
7685
+ const attemptId = pickBoundedIdentityString(meta, "attemptId", maxLen);
7686
+ if (attemptId !== void 0) {
7687
+ attrs2.push(stringAttr2("agent_inspect.attempt_id", attemptId));
7688
+ }
7689
+ const retryOf = pickBoundedIdentityString(meta, "retryOf", maxLen);
7690
+ if (retryOf !== void 0) {
7691
+ attrs2.push(stringAttr2("agent_inspect.retry_of", retryOf));
7692
+ }
7693
+ const attemptNumber = pickBoundedIdentityNumber(meta, "attemptNumber") ?? pickBoundedIdentityNumber(meta, "attempt");
7694
+ if (attemptNumber !== void 0) {
7695
+ attrs2.push(intAttr("agent_inspect.attempt_number", attemptNumber));
7696
+ }
7697
+ }
7585
7698
  function resolveSpanTimes(ev) {
7586
7699
  const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
7587
7700
  const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
@@ -7602,7 +7715,8 @@ function exportOtlpJson(tree, options) {
7602
7715
  const warnings = [
7603
7716
  "OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
7604
7717
  "Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
7605
- "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1)."
7718
+ "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
7719
+ "When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
7606
7720
  ];
7607
7721
  const traceId = hexFrom2(`trace:${tree.runId}`, 16);
7608
7722
  const includeAttributes = options?.includeAttributes ?? false;
@@ -7650,6 +7764,11 @@ function exportOtlpJson(tree, options) {
7650
7764
  if (typeof inp === "number") attrs2.push(intAttr("gen_ai.usage.input_tokens", inp));
7651
7765
  if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
7652
7766
  }
7767
+ appendStructuralIdentityAttrs(
7768
+ attrs2,
7769
+ meta && typeof meta === "object" ? meta : void 0,
7770
+ maxLen
7771
+ );
7653
7772
  if (includeAttributes && meta && typeof meta === "object") {
7654
7773
  const skipKeys = /* @__PURE__ */ new Set([
7655
7774
  "tokens",
@@ -7658,7 +7777,8 @@ function exportOtlpJson(tree, options) {
7658
7777
  "responseModel",
7659
7778
  "responseModelId",
7660
7779
  "provider",
7661
- "originalSourceType"
7780
+ "originalSourceType",
7781
+ ...STRUCTURAL_IDENTITY_KEYS
7662
7782
  ]);
7663
7783
  for (const [k, v] of Object.entries(meta)) {
7664
7784
  if (skipKeys.has(k)) continue;
@@ -9360,5 +9480,5 @@ async function runReadOnlyMcpServer(options = {}) {
9360
9480
  }
9361
9481
 
9362
9482
  export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
9363
- //# sourceMappingURL=chunk-Z4YKTU4Y.mjs.map
9364
- //# sourceMappingURL=chunk-Z4YKTU4Y.mjs.map
9483
+ //# sourceMappingURL=chunk-L5YP42Q6.mjs.map
9484
+ //# sourceMappingURL=chunk-L5YP42Q6.mjs.map