agent-inspect 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.
Files changed (32) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/docs/COMPARE.md +1 -1
  4. package/package.json +2 -2
  5. package/packages/cli/dist/{chunk-USZJEEME.mjs → chunk-NALE36AJ.mjs} +154 -31
  6. package/packages/cli/dist/chunk-NALE36AJ.mjs.map +1 -0
  7. package/packages/cli/dist/index.cjs +208 -32
  8. package/packages/cli/dist/index.cjs.map +1 -1
  9. package/packages/cli/dist/index.mjs +58 -6
  10. package/packages/cli/dist/index.mjs.map +1 -1
  11. package/packages/cli/dist/{src-EY4EY456.mjs → src-IZIVBMCO.mjs} +3 -3
  12. package/packages/cli/dist/{src-EY4EY456.mjs.map → src-IZIVBMCO.mjs.map} +1 -1
  13. package/packages/core/dist/advanced.cjs +72 -4
  14. package/packages/core/dist/advanced.cjs.map +1 -1
  15. package/packages/core/dist/advanced.mjs +3 -3
  16. package/packages/core/dist/checks.cjs +86 -29
  17. package/packages/core/dist/checks.cjs.map +1 -1
  18. package/packages/core/dist/checks.mjs +1 -1
  19. package/packages/core/dist/{chunk-GTA6SNDK.mjs → chunk-2RSTU3OZ.mjs} +88 -31
  20. package/packages/core/dist/chunk-2RSTU3OZ.mjs.map +1 -0
  21. package/packages/core/dist/{chunk-NJUSSJX3.mjs → chunk-EIP5CNEL.mjs} +68 -2
  22. package/packages/core/dist/chunk-EIP5CNEL.mjs.map +1 -0
  23. package/packages/core/dist/exporters.cjs +54 -2
  24. package/packages/core/dist/exporters.cjs.map +1 -1
  25. package/packages/core/dist/exporters.mjs +54 -2
  26. package/packages/core/dist/exporters.mjs.map +1 -1
  27. package/packages/core/dist/readers.cjs +66 -0
  28. package/packages/core/dist/readers.cjs.map +1 -1
  29. package/packages/core/dist/readers.mjs +1 -1
  30. package/packages/cli/dist/chunk-USZJEEME.mjs.map +0 -1
  31. package/packages/core/dist/chunk-GTA6SNDK.mjs.map +0 -1
  32. package/packages/core/dist/chunk-NJUSSJX3.mjs.map +0 -1
@@ -3851,7 +3851,7 @@ function extractSessionWorkflowMetadata(record) {
3851
3851
  assignString("conversationId", record.conversationId);
3852
3852
  assignString("groupId", record.groupId);
3853
3853
  assignString("parentGroupId", record.parentGroupId);
3854
- assignString("retryOf", record.retryOf);
3854
+ assignString("retryOf", record.retryOf ?? record["agent_inspect.retry_of"]);
3855
3855
  assignString("retryReason", record.retryReason);
3856
3856
  assignString("handoffFrom", record.handoffFrom);
3857
3857
  assignString("handoffTo", record.handoffTo);
@@ -3864,8 +3864,8 @@ function extractSessionWorkflowMetadata(record) {
3864
3864
  assignString("toolCallId", record.toolCallId);
3865
3865
  assignString("mcpToolCallId", record.mcpToolCallId);
3866
3866
  assignString("linkedStepId", record.linkedStepId);
3867
- assignString("operationId", record.operationId);
3868
- assignString("attemptId", record.attemptId);
3867
+ assignString("operationId", record.operationId ?? record["agent_inspect.operation_id"]);
3868
+ assignString("attemptId", record.attemptId ?? record["agent_inspect.attempt_id"]);
3869
3869
  assignString("fallbackOf", record.fallbackOf);
3870
3870
  assignString("idempotencyKey", record.idempotencyKey);
3871
3871
  assignString("correlationId", record.correlationId);
@@ -3876,7 +3876,9 @@ function extractSessionWorkflowMetadata(record) {
3876
3876
  out.attempt = attempt;
3877
3877
  found = true;
3878
3878
  }
3879
- const attemptNumber2 = finitePositiveInt(record.attemptNumber);
3879
+ const attemptNumber2 = finitePositiveInt(
3880
+ record.attemptNumber ?? record["agent_inspect.attempt_number"]
3881
+ );
3880
3882
  if (attemptNumber2 !== void 0) {
3881
3883
  out.attemptNumber = attemptNumber2;
3882
3884
  found = true;
@@ -8166,24 +8168,35 @@ function attemptIdOf(event) {
8166
8168
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
8167
8169
  }
8168
8170
  function countOperationAttempts(members) {
8169
- const attemptIds = new Set(
8170
- members.map((event) => attemptIdOf(event)).filter((value) => value !== void 0)
8171
- );
8172
- if (attemptIds.size > 0) {
8173
- return attemptIds.size;
8171
+ const identified = /* @__PURE__ */ new Set();
8172
+ let unidentified = 0;
8173
+ for (const event of members) {
8174
+ if (event.kind !== "TOOL" && event.kind !== "LLM") continue;
8175
+ const id = attemptIdOf(event);
8176
+ if (id !== void 0) {
8177
+ identified.add(id);
8178
+ continue;
8179
+ }
8180
+ unidentified += 1;
8181
+ }
8182
+ if (identified.size > 0) {
8183
+ return identified.size + unidentified;
8174
8184
  }
8175
- const numbers = members.map((event) => attemptNumberOf(event)).filter((value) => value !== void 0).sort((a, b) => a - b);
8176
- if (numbers.length > 0) {
8177
- const unique = [...new Set(numbers)];
8178
- const min = unique[0];
8179
- const max = unique[unique.length - 1];
8180
- const contiguous = unique.length === max - min + 1 && unique.every((value, index) => value === min + index);
8181
- if (contiguous) {
8182
- return unique.length;
8185
+ const numbered = /* @__PURE__ */ new Set();
8186
+ let unnumbered = 0;
8187
+ for (const event of members) {
8188
+ if (event.kind !== "TOOL" && event.kind !== "LLM") continue;
8189
+ const num2 = attemptNumberOf(event);
8190
+ if (num2 !== void 0) {
8191
+ numbered.add(num2);
8192
+ continue;
8183
8193
  }
8184
- return unique.length;
8194
+ unnumbered += 1;
8185
8195
  }
8186
- return members.filter((event) => event.kind === "TOOL" || event.kind === "LLM").length;
8196
+ if (numbered.size > 0) {
8197
+ return numbered.size + unnumbered;
8198
+ }
8199
+ return unnumbered;
8187
8200
  }
8188
8201
  function classifyRetryAttempt(event, priorOrdered, allMembers) {
8189
8202
  const workflow = workflowFor(event);
@@ -8464,8 +8477,42 @@ function eventEvidence3(event) {
8464
8477
  function eventTime2(event) {
8465
8478
  return event.startedAt ?? event.timestamp ?? "";
8466
8479
  }
8480
+ function parseComparableMs(value) {
8481
+ if (!value) return void 0;
8482
+ const parsed = Date.parse(value);
8483
+ return Number.isFinite(parsed) ? parsed : void 0;
8484
+ }
8485
+ function consumerStartMs(event) {
8486
+ return parseComparableMs(event.startedAt) ?? parseComparableMs(event.timestamp);
8487
+ }
8488
+ function resultAvailableMs(event) {
8489
+ const started = parseComparableMs(event.startedAt) ?? parseComparableMs(event.timestamp);
8490
+ const endedRaw = event.endedAt;
8491
+ const endedPresent = endedRaw !== void 0 && endedRaw !== null && String(endedRaw).trim() !== "";
8492
+ if (endedPresent) {
8493
+ const ended = parseComparableMs(typeof endedRaw === "string" ? endedRaw : String(endedRaw));
8494
+ if (ended === void 0) return void 0;
8495
+ if (started !== void 0 && ended < started) return void 0;
8496
+ return ended;
8497
+ }
8498
+ if (event.durationMs !== void 0) {
8499
+ if (!Number.isFinite(event.durationMs) || event.durationMs < 0) {
8500
+ return void 0;
8501
+ }
8502
+ if (started !== void 0) {
8503
+ return started + event.durationMs;
8504
+ }
8505
+ return void 0;
8506
+ }
8507
+ return parseComparableMs(event.timestamp);
8508
+ }
8467
8509
  function sortByTime2(events) {
8468
- return [...events].sort((a, b) => eventTime2(a).localeCompare(eventTime2(b)));
8510
+ return [...events].sort((a, b) => {
8511
+ const aMs = consumerStartMs(a) ?? 0;
8512
+ const bMs = consumerStartMs(b) ?? 0;
8513
+ if (aMs !== bMs) return aMs - bMs;
8514
+ return eventTime2(a).localeCompare(eventTime2(b));
8515
+ });
8469
8516
  }
8470
8517
  function errorCodeOf(event) {
8471
8518
  if (typeof event.error?.code === "string" && event.error.code.trim() !== "") {
@@ -8537,9 +8584,10 @@ function isUnevaluableWriteCompletion(event) {
8537
8584
  if (event.status === "running" || event.status === "unknown") return true;
8538
8585
  const attrs = event.attributes ?? {};
8539
8586
  if (attrs.timeout === true) return true;
8587
+ if (attrs.unknownCompletion === true) return true;
8540
8588
  if (attrs.completionState === "unknown" || attrs.completionState === "timeout") return true;
8541
8589
  const code = errorCodeOf(event)?.toUpperCase();
8542
- if (code === "TIMEOUT" || code === "UNKNOWN_COMPLETION" || code === "DEADLINE_EXCEEDED") {
8590
+ if (code && UNEVALUABLE_WRITE_ERROR_CODES.has(code)) {
8543
8591
  return true;
8544
8592
  }
8545
8593
  return false;
@@ -8587,14 +8635,17 @@ function collectExplicitReferences(event) {
8587
8635
  return refs;
8588
8636
  }
8589
8637
  function llmReferencesTool(llm, toolEvent, requireExplicit) {
8590
- if (!requireExplicit) {
8591
- return eventTime2(llm) >= eventTime2(toolEvent);
8592
- }
8593
- const refs = collectExplicitReferences(llm);
8594
- if (refs.has(toolEvent.eventId)) return true;
8595
- const toolCallId = workflowFor2(toolEvent).toolCallId;
8596
- if (toolCallId && refs.has(toolCallId)) return true;
8597
- return false;
8638
+ if (llm.runId !== toolEvent.runId) return false;
8639
+ if (requireExplicit) {
8640
+ const refs = collectExplicitReferences(llm);
8641
+ const toolCallId = workflowFor2(toolEvent).toolCallId;
8642
+ const hasRef = refs.has(toolEvent.eventId) || toolCallId !== void 0 && refs.has(toolCallId);
8643
+ if (!hasRef) return false;
8644
+ }
8645
+ const resultMs = resultAvailableMs(toolEvent);
8646
+ const consumerMs = consumerStartMs(llm);
8647
+ if (resultMs === void 0 || consumerMs === void 0) return false;
8648
+ return resultMs <= consumerMs;
8598
8649
  }
8599
8650
  function attemptIdOf2(event) {
8600
8651
  const value = workflowFor2(event).attemptId;
@@ -8906,6 +8957,7 @@ function evaluateRecoveryOperations(events, operations) {
8906
8957
  }
8907
8958
  return findings;
8908
8959
  }
8960
+ var UNEVALUABLE_WRITE_ERROR_CODES;
8909
8961
  var init_recovery_operations = __esm({
8910
8962
  "packages/core/src/checks/recovery-operations.ts"() {
8911
8963
  init_canonical_equality();
@@ -8913,6 +8965,12 @@ var init_recovery_operations = __esm({
8913
8965
  init_tool_arguments();
8914
8966
  init_retry_safety();
8915
8967
  init_metadata();
8968
+ UNEVALUABLE_WRITE_ERROR_CODES = /* @__PURE__ */ new Set([
8969
+ "TIMEOUT",
8970
+ "ETIMEDOUT",
8971
+ "UNKNOWN_COMPLETION",
8972
+ "DEADLINE_EXCEEDED"
8973
+ ]);
8916
8974
  }
8917
8975
  });
8918
8976
 
@@ -14097,6 +14155,70 @@ function mapOtlpEvents(value, pathPrefix) {
14097
14155
  unsupportedFields
14098
14156
  };
14099
14157
  }
14158
+ function promoteAgentInspectWorkflowIdentity(attributes, pathPrefix) {
14159
+ const warnings = [];
14160
+ const mapping = [
14161
+ ["agent_inspect.operation_id", "operationId", "string"],
14162
+ ["agent_inspect.attempt_id", "attemptId", "string"],
14163
+ ["agent_inspect.retry_of", "retryOf", "string"],
14164
+ ["agent_inspect.attempt_number", "attemptNumber", "int"]
14165
+ ];
14166
+ const metadata = attributes.metadata && typeof attributes.metadata === "object" && !Array.isArray(attributes.metadata) ? { ...attributes.metadata } : {};
14167
+ for (const [dotted, camel, kind] of mapping) {
14168
+ const raw = attributes[dotted];
14169
+ if (raw === void 0 || raw === null) continue;
14170
+ let promoted;
14171
+ if (kind === "int") {
14172
+ const n = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
14173
+ if (!Number.isFinite(n) || n < 1) {
14174
+ warnings.push({
14175
+ code: "otlp_identity_invalid",
14176
+ message: `Ignoring invalid ${dotted} identity value.`,
14177
+ severity: "warning",
14178
+ field: `${pathPrefix}.${dotted}`
14179
+ });
14180
+ continue;
14181
+ }
14182
+ promoted = Math.trunc(n);
14183
+ } else if (typeof raw === "string" && raw.trim() !== "") {
14184
+ promoted = raw.trim();
14185
+ } else {
14186
+ warnings.push({
14187
+ code: "otlp_identity_invalid",
14188
+ message: `Ignoring non-string ${dotted} identity value.`,
14189
+ severity: "warning",
14190
+ field: `${pathPrefix}.${dotted}`
14191
+ });
14192
+ continue;
14193
+ }
14194
+ const direct = attributes[camel];
14195
+ const nested = metadata[camel];
14196
+ if (direct !== void 0 && direct !== promoted) {
14197
+ warnings.push({
14198
+ code: "otlp_identity_conflict",
14199
+ message: `Conflicting ${camel}: attributes.${camel} vs ${dotted}; keeping camelCase.`,
14200
+ severity: "warning",
14201
+ field: `${pathPrefix}.${dotted}`
14202
+ });
14203
+ continue;
14204
+ }
14205
+ if (nested !== void 0 && nested !== promoted && direct === void 0) {
14206
+ warnings.push({
14207
+ code: "otlp_identity_conflict",
14208
+ message: `Conflicting ${camel}: attributes.metadata.${camel} vs ${dotted}; keeping nested.`,
14209
+ severity: "warning",
14210
+ field: `${pathPrefix}.${dotted}`
14211
+ });
14212
+ continue;
14213
+ }
14214
+ if (direct === void 0) attributes[camel] = promoted;
14215
+ if (nested === void 0) metadata[camel] = promoted;
14216
+ }
14217
+ if (Object.keys(metadata).length > 0) {
14218
+ attributes.metadata = metadata;
14219
+ }
14220
+ return warnings;
14221
+ }
14100
14222
  function mapOtlpSpan(context) {
14101
14223
  const { span, pathPrefix } = context;
14102
14224
  const warnings = [];
@@ -14128,6 +14250,7 @@ function mapOtlpSpan(context) {
14128
14250
  if (context.scopeVersion !== void 0) {
14129
14251
  attributes["scope.version"] = context.scopeVersion;
14130
14252
  }
14253
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
14131
14254
  for (const [key, value] of Object.entries(span)) {
14132
14255
  if (OTLP_SPAN_KEYS.has(key)) continue;
14133
14256
  unsupportedFields.push(`${pathPrefix}.${key}`);
@@ -14165,6 +14288,7 @@ function mapOtlpSpan(context) {
14165
14288
  if (events.events !== void 0) {
14166
14289
  attributes["otlp.events"] = events.events;
14167
14290
  }
14291
+ warnings.push(...promoteAgentInspectWorkflowIdentity(attributes, pathPrefix));
14168
14292
  const traceId = readStringField(span, ["traceId"]) ?? "trace-unknown";
14169
14293
  const spanId = readStringField(span, ["spanId"]) ?? "span-unknown";
14170
14294
  const parentSpanId = readStringField(span, ["parentSpanId"]);
@@ -16829,7 +16953,7 @@ var init_src = __esm({
16829
16953
  });
16830
16954
 
16831
16955
  // package.json
16832
- var version = "6.31.17";
16956
+ var version = "6.31.19";
16833
16957
 
16834
16958
  // packages/cli/src/list.ts
16835
16959
  init_advanced();
@@ -19480,6 +19604,51 @@ function genAiOperationName(kind) {
19480
19604
  return void 0;
19481
19605
  }
19482
19606
  }
19607
+ var STRUCTURAL_IDENTITY_KEYS = [
19608
+ "operationId",
19609
+ "attemptId",
19610
+ "retryOf",
19611
+ "attemptNumber",
19612
+ "attempt"
19613
+ ];
19614
+ function pickBoundedIdentityString(bag, key, maxLen) {
19615
+ if (!bag || typeof bag !== "object") return void 0;
19616
+ const direct = bag[key];
19617
+ if (typeof direct === "string" && direct.trim() !== "") {
19618
+ return direct.trim().slice(0, maxLen);
19619
+ }
19620
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
19621
+ if (typeof nested === "string" && nested.trim() !== "") {
19622
+ return nested.trim().slice(0, maxLen);
19623
+ }
19624
+ return void 0;
19625
+ }
19626
+ function pickBoundedIdentityNumber(bag, key) {
19627
+ if (!bag || typeof bag !== "object") return void 0;
19628
+ const direct = bag[key];
19629
+ if (typeof direct === "number" && Number.isFinite(direct)) return direct;
19630
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
19631
+ if (typeof nested === "number" && Number.isFinite(nested)) return nested;
19632
+ return void 0;
19633
+ }
19634
+ function appendStructuralIdentityAttrs(attrs, meta2, maxLen) {
19635
+ const operationId = pickBoundedIdentityString(meta2, "operationId", maxLen);
19636
+ if (operationId !== void 0) {
19637
+ attrs.push(stringAttr2("agent_inspect.operation_id", operationId));
19638
+ }
19639
+ const attemptId = pickBoundedIdentityString(meta2, "attemptId", maxLen);
19640
+ if (attemptId !== void 0) {
19641
+ attrs.push(stringAttr2("agent_inspect.attempt_id", attemptId));
19642
+ }
19643
+ const retryOf = pickBoundedIdentityString(meta2, "retryOf", maxLen);
19644
+ if (retryOf !== void 0) {
19645
+ attrs.push(stringAttr2("agent_inspect.retry_of", retryOf));
19646
+ }
19647
+ const attemptNumber2 = pickBoundedIdentityNumber(meta2, "attemptNumber") ?? pickBoundedIdentityNumber(meta2, "attempt");
19648
+ if (attemptNumber2 !== void 0) {
19649
+ attrs.push(intAttr("agent_inspect.attempt_number", attemptNumber2));
19650
+ }
19651
+ }
19483
19652
  function resolveSpanTimes(ev) {
19484
19653
  const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
19485
19654
  const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
@@ -19500,7 +19669,8 @@ function exportOtlpJson(tree, options) {
19500
19669
  const warnings = [
19501
19670
  "OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
19502
19671
  "Not OTLP gRPC/protobuf \u2014 JSON mapping only. Generated locally; no network upload.",
19503
- "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1)."
19672
+ "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
19673
+ "When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
19504
19674
  ];
19505
19675
  const traceId = hexFrom2(`trace:${tree.runId}`, 16);
19506
19676
  const includeAttributes = options?.includeAttributes ?? false;
@@ -19548,6 +19718,11 @@ function exportOtlpJson(tree, options) {
19548
19718
  if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
19549
19719
  if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
19550
19720
  }
19721
+ appendStructuralIdentityAttrs(
19722
+ attrs,
19723
+ meta2 && typeof meta2 === "object" ? meta2 : void 0,
19724
+ maxLen
19725
+ );
19551
19726
  if (includeAttributes && meta2 && typeof meta2 === "object") {
19552
19727
  const skipKeys = /* @__PURE__ */ new Set([
19553
19728
  "tokens",
@@ -19556,7 +19731,8 @@ function exportOtlpJson(tree, options) {
19556
19731
  "responseModel",
19557
19732
  "responseModelId",
19558
19733
  "provider",
19559
- "originalSourceType"
19734
+ "originalSourceType",
19735
+ ...STRUCTURAL_IDENTITY_KEYS
19560
19736
  ]);
19561
19737
  for (const [k, v] of Object.entries(meta2)) {
19562
19738
  if (skipKeys.has(k)) continue;