@agent-inspect/mcp-server 6.31.17 → 6.31.18

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.
@@ -7582,6 +7582,51 @@ function genAiOperationName(kind) {
7582
7582
  return void 0;
7583
7583
  }
7584
7584
  }
7585
+ var STRUCTURAL_IDENTITY_KEYS = [
7586
+ "operationId",
7587
+ "attemptId",
7588
+ "retryOf",
7589
+ "attemptNumber",
7590
+ "attempt"
7591
+ ];
7592
+ function pickBoundedIdentityString(bag, key, maxLen) {
7593
+ if (!bag || typeof bag !== "object") return void 0;
7594
+ const direct = bag[key];
7595
+ if (typeof direct === "string" && direct.trim() !== "") {
7596
+ return direct.trim().slice(0, maxLen);
7597
+ }
7598
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
7599
+ if (typeof nested === "string" && nested.trim() !== "") {
7600
+ return nested.trim().slice(0, maxLen);
7601
+ }
7602
+ return void 0;
7603
+ }
7604
+ function pickBoundedIdentityNumber(bag, key) {
7605
+ if (!bag || typeof bag !== "object") return void 0;
7606
+ const direct = bag[key];
7607
+ if (typeof direct === "number" && Number.isFinite(direct)) return direct;
7608
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
7609
+ if (typeof nested === "number" && Number.isFinite(nested)) return nested;
7610
+ return void 0;
7611
+ }
7612
+ function appendStructuralIdentityAttrs(attrs2, meta, maxLen) {
7613
+ const operationId = pickBoundedIdentityString(meta, "operationId", maxLen);
7614
+ if (operationId !== void 0) {
7615
+ attrs2.push(stringAttr2("agent_inspect.operation_id", operationId));
7616
+ }
7617
+ const attemptId = pickBoundedIdentityString(meta, "attemptId", maxLen);
7618
+ if (attemptId !== void 0) {
7619
+ attrs2.push(stringAttr2("agent_inspect.attempt_id", attemptId));
7620
+ }
7621
+ const retryOf = pickBoundedIdentityString(meta, "retryOf", maxLen);
7622
+ if (retryOf !== void 0) {
7623
+ attrs2.push(stringAttr2("agent_inspect.retry_of", retryOf));
7624
+ }
7625
+ const attemptNumber = pickBoundedIdentityNumber(meta, "attemptNumber") ?? pickBoundedIdentityNumber(meta, "attempt");
7626
+ if (attemptNumber !== void 0) {
7627
+ attrs2.push(intAttr("agent_inspect.attempt_number", attemptNumber));
7628
+ }
7629
+ }
7585
7630
  function resolveSpanTimes(ev) {
7586
7631
  const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
7587
7632
  const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
@@ -7602,7 +7647,8 @@ function exportOtlpJson(tree, options) {
7602
7647
  const warnings = [
7603
7648
  "OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
7604
7649
  "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)."
7650
+ "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
7651
+ "When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
7606
7652
  ];
7607
7653
  const traceId = hexFrom2(`trace:${tree.runId}`, 16);
7608
7654
  const includeAttributes = options?.includeAttributes ?? false;
@@ -7650,6 +7696,11 @@ function exportOtlpJson(tree, options) {
7650
7696
  if (typeof inp === "number") attrs2.push(intAttr("gen_ai.usage.input_tokens", inp));
7651
7697
  if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
7652
7698
  }
7699
+ appendStructuralIdentityAttrs(
7700
+ attrs2,
7701
+ meta && typeof meta === "object" ? meta : void 0,
7702
+ maxLen
7703
+ );
7653
7704
  if (includeAttributes && meta && typeof meta === "object") {
7654
7705
  const skipKeys = /* @__PURE__ */ new Set([
7655
7706
  "tokens",
@@ -7658,7 +7709,8 @@ function exportOtlpJson(tree, options) {
7658
7709
  "responseModel",
7659
7710
  "responseModelId",
7660
7711
  "provider",
7661
- "originalSourceType"
7712
+ "originalSourceType",
7713
+ ...STRUCTURAL_IDENTITY_KEYS
7662
7714
  ]);
7663
7715
  for (const [k, v] of Object.entries(meta)) {
7664
7716
  if (skipKeys.has(k)) continue;
@@ -9360,5 +9412,5 @@ async function runReadOnlyMcpServer(options = {}) {
9360
9412
  }
9361
9413
 
9362
9414
  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
9415
+ //# sourceMappingURL=chunk-X4QXIQSR.mjs.map
9416
+ //# sourceMappingURL=chunk-X4QXIQSR.mjs.map