@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.
package/dist/cli.cjs CHANGED
@@ -7592,6 +7592,51 @@ function genAiOperationName(kind) {
7592
7592
  return void 0;
7593
7593
  }
7594
7594
  }
7595
+ var STRUCTURAL_IDENTITY_KEYS = [
7596
+ "operationId",
7597
+ "attemptId",
7598
+ "retryOf",
7599
+ "attemptNumber",
7600
+ "attempt"
7601
+ ];
7602
+ function pickBoundedIdentityString(bag, key, maxLen) {
7603
+ if (!bag || typeof bag !== "object") return void 0;
7604
+ const direct = bag[key];
7605
+ if (typeof direct === "string" && direct.trim() !== "") {
7606
+ return direct.trim().slice(0, maxLen);
7607
+ }
7608
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
7609
+ if (typeof nested === "string" && nested.trim() !== "") {
7610
+ return nested.trim().slice(0, maxLen);
7611
+ }
7612
+ return void 0;
7613
+ }
7614
+ function pickBoundedIdentityNumber(bag, key) {
7615
+ if (!bag || typeof bag !== "object") return void 0;
7616
+ const direct = bag[key];
7617
+ if (typeof direct === "number" && Number.isFinite(direct)) return direct;
7618
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
7619
+ if (typeof nested === "number" && Number.isFinite(nested)) return nested;
7620
+ return void 0;
7621
+ }
7622
+ function appendStructuralIdentityAttrs(attrs2, meta, maxLen) {
7623
+ const operationId = pickBoundedIdentityString(meta, "operationId", maxLen);
7624
+ if (operationId !== void 0) {
7625
+ attrs2.push(stringAttr2("agent_inspect.operation_id", operationId));
7626
+ }
7627
+ const attemptId = pickBoundedIdentityString(meta, "attemptId", maxLen);
7628
+ if (attemptId !== void 0) {
7629
+ attrs2.push(stringAttr2("agent_inspect.attempt_id", attemptId));
7630
+ }
7631
+ const retryOf = pickBoundedIdentityString(meta, "retryOf", maxLen);
7632
+ if (retryOf !== void 0) {
7633
+ attrs2.push(stringAttr2("agent_inspect.retry_of", retryOf));
7634
+ }
7635
+ const attemptNumber = pickBoundedIdentityNumber(meta, "attemptNumber") ?? pickBoundedIdentityNumber(meta, "attempt");
7636
+ if (attemptNumber !== void 0) {
7637
+ attrs2.push(intAttr("agent_inspect.attempt_number", attemptNumber));
7638
+ }
7639
+ }
7595
7640
  function resolveSpanTimes(ev) {
7596
7641
  const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
7597
7642
  const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
@@ -7612,7 +7657,8 @@ function exportOtlpJson(tree, options) {
7612
7657
  const warnings = [
7613
7658
  "OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
7614
7659
  "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)."
7660
+ "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
7661
+ "When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
7616
7662
  ];
7617
7663
  const traceId = hexFrom2(`trace:${tree.runId}`, 16);
7618
7664
  const includeAttributes = options?.includeAttributes ?? false;
@@ -7660,6 +7706,11 @@ function exportOtlpJson(tree, options) {
7660
7706
  if (typeof inp === "number") attrs2.push(intAttr("gen_ai.usage.input_tokens", inp));
7661
7707
  if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
7662
7708
  }
7709
+ appendStructuralIdentityAttrs(
7710
+ attrs2,
7711
+ meta && typeof meta === "object" ? meta : void 0,
7712
+ maxLen
7713
+ );
7663
7714
  if (includeAttributes && meta && typeof meta === "object") {
7664
7715
  const skipKeys = /* @__PURE__ */ new Set([
7665
7716
  "tokens",
@@ -7668,7 +7719,8 @@ function exportOtlpJson(tree, options) {
7668
7719
  "responseModel",
7669
7720
  "responseModelId",
7670
7721
  "provider",
7671
- "originalSourceType"
7722
+ "originalSourceType",
7723
+ ...STRUCTURAL_IDENTITY_KEYS
7672
7724
  ]);
7673
7725
  for (const [k, v] of Object.entries(meta)) {
7674
7726
  if (skipKeys.has(k)) continue;