@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.
package/dist/cli.cjs CHANGED
@@ -2568,7 +2568,7 @@ function extractSessionWorkflowMetadata(record) {
2568
2568
  assignString("conversationId", record.conversationId);
2569
2569
  assignString("groupId", record.groupId);
2570
2570
  assignString("parentGroupId", record.parentGroupId);
2571
- assignString("retryOf", record.retryOf);
2571
+ assignString("retryOf", record.retryOf ?? record["agent_inspect.retry_of"]);
2572
2572
  assignString("retryReason", record.retryReason);
2573
2573
  assignString("handoffFrom", record.handoffFrom);
2574
2574
  assignString("handoffTo", record.handoffTo);
@@ -2581,8 +2581,8 @@ function extractSessionWorkflowMetadata(record) {
2581
2581
  assignString("toolCallId", record.toolCallId);
2582
2582
  assignString("mcpToolCallId", record.mcpToolCallId);
2583
2583
  assignString("linkedStepId", record.linkedStepId);
2584
- assignString("operationId", record.operationId);
2585
- assignString("attemptId", record.attemptId);
2584
+ assignString("operationId", record.operationId ?? record["agent_inspect.operation_id"]);
2585
+ assignString("attemptId", record.attemptId ?? record["agent_inspect.attempt_id"]);
2586
2586
  assignString("fallbackOf", record.fallbackOf);
2587
2587
  assignString("idempotencyKey", record.idempotencyKey);
2588
2588
  assignString("correlationId", record.correlationId);
@@ -2593,7 +2593,9 @@ function extractSessionWorkflowMetadata(record) {
2593
2593
  out.attempt = attempt;
2594
2594
  found = true;
2595
2595
  }
2596
- const attemptNumber = finitePositiveInt(record.attemptNumber);
2596
+ const attemptNumber = finitePositiveInt(
2597
+ record.attemptNumber ?? record["agent_inspect.attempt_number"]
2598
+ );
2597
2599
  if (attemptNumber !== void 0) {
2598
2600
  out.attemptNumber = attemptNumber;
2599
2601
  found = true;
@@ -6420,6 +6422,70 @@ function mapOtlpEvents(value, pathPrefix) {
6420
6422
  unsupportedFields
6421
6423
  };
6422
6424
  }
6425
+ function promoteAgentInspectWorkflowIdentity(attributes, pathPrefix) {
6426
+ const warnings = [];
6427
+ const mapping = [
6428
+ ["agent_inspect.operation_id", "operationId", "string"],
6429
+ ["agent_inspect.attempt_id", "attemptId", "string"],
6430
+ ["agent_inspect.retry_of", "retryOf", "string"],
6431
+ ["agent_inspect.attempt_number", "attemptNumber", "int"]
6432
+ ];
6433
+ const metadata = attributes.metadata && typeof attributes.metadata === "object" && !Array.isArray(attributes.metadata) ? { ...attributes.metadata } : {};
6434
+ for (const [dotted, camel, kind] of mapping) {
6435
+ const raw = attributes[dotted];
6436
+ if (raw === void 0 || raw === null) continue;
6437
+ let promoted;
6438
+ if (kind === "int") {
6439
+ const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
6440
+ if (!Number.isFinite(n) || n < 1) {
6441
+ warnings.push({
6442
+ code: "otlp_identity_invalid",
6443
+ message: `Ignoring invalid ${dotted} identity value.`,
6444
+ severity: "warning",
6445
+ field: `${pathPrefix}.${dotted}`
6446
+ });
6447
+ continue;
6448
+ }
6449
+ promoted = Math.trunc(n);
6450
+ } else if (typeof raw === "string" && raw.trim() !== "") {
6451
+ promoted = raw.trim();
6452
+ } else {
6453
+ warnings.push({
6454
+ code: "otlp_identity_invalid",
6455
+ message: `Ignoring non-string ${dotted} identity value.`,
6456
+ severity: "warning",
6457
+ field: `${pathPrefix}.${dotted}`
6458
+ });
6459
+ continue;
6460
+ }
6461
+ const direct = attributes[camel];
6462
+ const nested = metadata[camel];
6463
+ if (direct !== void 0 && direct !== promoted) {
6464
+ warnings.push({
6465
+ code: "otlp_identity_conflict",
6466
+ message: `Conflicting ${camel}: attributes.${camel} vs ${dotted}; keeping camelCase.`,
6467
+ severity: "warning",
6468
+ field: `${pathPrefix}.${dotted}`
6469
+ });
6470
+ continue;
6471
+ }
6472
+ if (nested !== void 0 && nested !== promoted && direct === void 0) {
6473
+ warnings.push({
6474
+ code: "otlp_identity_conflict",
6475
+ message: `Conflicting ${camel}: attributes.metadata.${camel} vs ${dotted}; keeping nested.`,
6476
+ severity: "warning",
6477
+ field: `${pathPrefix}.${dotted}`
6478
+ });
6479
+ continue;
6480
+ }
6481
+ if (direct === void 0) attributes[camel] = promoted;
6482
+ if (nested === void 0) metadata[camel] = promoted;
6483
+ }
6484
+ if (Object.keys(metadata).length > 0) {
6485
+ attributes.metadata = metadata;
6486
+ }
6487
+ return warnings;
6488
+ }
6423
6489
  function mapOtlpSpan(context) {
6424
6490
  const { span, pathPrefix } = context;
6425
6491
  const warnings = [];
@@ -6451,6 +6517,7 @@ function mapOtlpSpan(context) {
6451
6517
  if (context.scopeVersion !== void 0) {
6452
6518
  attributes["scope.version"] = context.scopeVersion;
6453
6519
  }
6520
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
6454
6521
  for (const [key, value] of Object.entries(span)) {
6455
6522
  if (OTLP_SPAN_KEYS.has(key)) continue;
6456
6523
  unsupportedFields.push(`${pathPrefix}.${key}`);
@@ -6488,6 +6555,7 @@ function mapOtlpSpan(context) {
6488
6555
  if (events.events !== void 0) {
6489
6556
  attributes["otlp.events"] = events.events;
6490
6557
  }
6558
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
6491
6559
  const traceId = readStringField(span, ["traceId"]) ?? "trace-unknown";
6492
6560
  const spanId = readStringField(span, ["spanId"]) ?? "span-unknown";
6493
6561
  const parentSpanId = readStringField(span, ["parentSpanId"]);
@@ -7592,6 +7660,51 @@ function genAiOperationName(kind) {
7592
7660
  return void 0;
7593
7661
  }
7594
7662
  }
7663
+ var STRUCTURAL_IDENTITY_KEYS = [
7664
+ "operationId",
7665
+ "attemptId",
7666
+ "retryOf",
7667
+ "attemptNumber",
7668
+ "attempt"
7669
+ ];
7670
+ function pickBoundedIdentityString(bag, key, maxLen) {
7671
+ if (!bag || typeof bag !== "object") return void 0;
7672
+ const direct = bag[key];
7673
+ if (typeof direct === "string" && direct.trim() !== "") {
7674
+ return direct.trim().slice(0, maxLen);
7675
+ }
7676
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
7677
+ if (typeof nested === "string" && nested.trim() !== "") {
7678
+ return nested.trim().slice(0, maxLen);
7679
+ }
7680
+ return void 0;
7681
+ }
7682
+ function pickBoundedIdentityNumber(bag, key) {
7683
+ if (!bag || typeof bag !== "object") return void 0;
7684
+ const direct = bag[key];
7685
+ if (typeof direct === "number" && Number.isFinite(direct)) return direct;
7686
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
7687
+ if (typeof nested === "number" && Number.isFinite(nested)) return nested;
7688
+ return void 0;
7689
+ }
7690
+ function appendStructuralIdentityAttrs(attrs2, meta, maxLen) {
7691
+ const operationId = pickBoundedIdentityString(meta, "operationId", maxLen);
7692
+ if (operationId !== void 0) {
7693
+ attrs2.push(stringAttr2("agent_inspect.operation_id", operationId));
7694
+ }
7695
+ const attemptId = pickBoundedIdentityString(meta, "attemptId", maxLen);
7696
+ if (attemptId !== void 0) {
7697
+ attrs2.push(stringAttr2("agent_inspect.attempt_id", attemptId));
7698
+ }
7699
+ const retryOf = pickBoundedIdentityString(meta, "retryOf", maxLen);
7700
+ if (retryOf !== void 0) {
7701
+ attrs2.push(stringAttr2("agent_inspect.retry_of", retryOf));
7702
+ }
7703
+ const attemptNumber = pickBoundedIdentityNumber(meta, "attemptNumber") ?? pickBoundedIdentityNumber(meta, "attempt");
7704
+ if (attemptNumber !== void 0) {
7705
+ attrs2.push(intAttr("agent_inspect.attempt_number", attemptNumber));
7706
+ }
7707
+ }
7595
7708
  function resolveSpanTimes(ev) {
7596
7709
  const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
7597
7710
  const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
@@ -7612,7 +7725,8 @@ function exportOtlpJson(tree, options) {
7612
7725
  const warnings = [
7613
7726
  "OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
7614
7727
  "Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
7615
- "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1)."
7728
+ "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
7729
+ "When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
7616
7730
  ];
7617
7731
  const traceId = hexFrom2(`trace:${tree.runId}`, 16);
7618
7732
  const includeAttributes = options?.includeAttributes ?? false;
@@ -7660,6 +7774,11 @@ function exportOtlpJson(tree, options) {
7660
7774
  if (typeof inp === "number") attrs2.push(intAttr("gen_ai.usage.input_tokens", inp));
7661
7775
  if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
7662
7776
  }
7777
+ appendStructuralIdentityAttrs(
7778
+ attrs2,
7779
+ meta && typeof meta === "object" ? meta : void 0,
7780
+ maxLen
7781
+ );
7663
7782
  if (includeAttributes && meta && typeof meta === "object") {
7664
7783
  const skipKeys = /* @__PURE__ */ new Set([
7665
7784
  "tokens",
@@ -7668,7 +7787,8 @@ function exportOtlpJson(tree, options) {
7668
7787
  "responseModel",
7669
7788
  "responseModelId",
7670
7789
  "provider",
7671
- "originalSourceType"
7790
+ "originalSourceType",
7791
+ ...STRUCTURAL_IDENTITY_KEYS
7672
7792
  ]);
7673
7793
  for (const [k, v] of Object.entries(meta)) {
7674
7794
  if (skipKeys.has(k)) continue;