agent-inspect 6.31.16 → 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.
Files changed (42) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/SECURITY.md +1 -0
  4. package/docs/COMPARE.md +11 -0
  5. package/package.json +2 -2
  6. package/packages/cli/dist/{chunk-ZAYVAHIH.mjs → chunk-AHARYDFO.mjs} +62 -28
  7. package/packages/cli/dist/chunk-AHARYDFO.mjs.map +1 -0
  8. package/packages/cli/dist/index.cjs +122 -32
  9. package/packages/cli/dist/index.cjs.map +1 -1
  10. package/packages/cli/dist/index.mjs +64 -9
  11. package/packages/cli/dist/index.mjs.map +1 -1
  12. package/packages/cli/dist/{src-KP4UIFK5.mjs → src-YNZZ2KYR.mjs} +3 -3
  13. package/packages/cli/dist/{src-KP4UIFK5.mjs.map → src-YNZZ2KYR.mjs.map} +1 -1
  14. package/packages/core/dist/advanced.cjs +1 -1
  15. package/packages/core/dist/advanced.cjs.map +1 -1
  16. package/packages/core/dist/advanced.mjs +9 -9
  17. package/packages/core/dist/checks.cjs +59 -25
  18. package/packages/core/dist/checks.cjs.map +1 -1
  19. package/packages/core/dist/checks.mjs +3 -3
  20. package/packages/core/dist/{chunk-SSG3ICI4.mjs → chunk-6C244CAV.mjs} +4 -4
  21. package/packages/core/dist/{chunk-SSG3ICI4.mjs.map → chunk-6C244CAV.mjs.map} +1 -1
  22. package/packages/core/dist/{chunk-N5PZAI6Q.mjs → chunk-77UZIMMD.mjs} +3 -3
  23. package/packages/core/dist/{chunk-N5PZAI6Q.mjs.map → chunk-77UZIMMD.mjs.map} +1 -1
  24. package/packages/core/dist/{chunk-DK3OW6UI.mjs → chunk-EOXUEQB6.mjs} +3 -3
  25. package/packages/core/dist/chunk-EOXUEQB6.mjs.map +1 -0
  26. package/packages/core/dist/{chunk-CCYKNAOD.mjs → chunk-FRBBZUEP.mjs} +62 -28
  27. package/packages/core/dist/chunk-FRBBZUEP.mjs.map +1 -0
  28. package/packages/core/dist/{chunk-M3RJD3BP.mjs → chunk-NX25C7JZ.mjs} +3 -3
  29. package/packages/core/dist/{chunk-M3RJD3BP.mjs.map → chunk-NX25C7JZ.mjs.map} +1 -1
  30. package/packages/core/dist/exporters.cjs +55 -3
  31. package/packages/core/dist/exporters.cjs.map +1 -1
  32. package/packages/core/dist/exporters.mjs +57 -5
  33. package/packages/core/dist/exporters.mjs.map +1 -1
  34. package/packages/core/dist/index.cjs +1 -1
  35. package/packages/core/dist/index.cjs.map +1 -1
  36. package/packages/core/dist/index.mjs +4 -4
  37. package/packages/core/dist/writers.cjs +1 -1
  38. package/packages/core/dist/writers.cjs.map +1 -1
  39. package/packages/core/dist/writers.mjs +1 -1
  40. package/packages/cli/dist/chunk-ZAYVAHIH.mjs.map +0 -1
  41. package/packages/core/dist/chunk-CCYKNAOD.mjs.map +0 -1
  42. package/packages/core/dist/chunk-DK3OW6UI.mjs.map +0 -1
@@ -261,7 +261,7 @@ function stringContainsHighConfidenceCredential(value) {
261
261
  var KEY_VALUE_SECRET_PATTERN, HIGH_CONFIDENCE_CREDENTIAL_PATTERNS;
262
262
  var init_credential_value_patterns = __esm({
263
263
  "packages/core/src/safety/credential-value-patterns.ts"() {
264
- KEY_VALUE_SECRET_PATTERN = /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?]))([^\s"'\\]{8,})/i;
264
+ KEY_VALUE_SECRET_PATTERN = /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED|HASH:(?:[0-9a-f]{8}|unknown))\](?![^\s"'\\&#?]))([^\s"'\\]{8,})/i;
265
265
  HIGH_CONFIDENCE_CREDENTIAL_PATTERNS = [
266
266
  /^(?:basic|bearer|digest|apikey)\s+[a-z0-9._~+/=-]+$/i,
267
267
  /\bbearer\s+[a-z0-9._~+/=-]{12,}\b/i,
@@ -5994,8 +5994,8 @@ function isFullyRedactedValue(value, markers = ["[REDACTED]", "[REDACTED:"]) {
5994
5994
  if (typeof value !== "string") return false;
5995
5995
  const trimmed = value.trim();
5996
5996
  if (trimmed.length === 0) return false;
5997
- if (/^\[HASH:[A-Za-z0-9_-]+\]$/.test(trimmed)) return true;
5998
- if (/^\[REDACTED:[^\]]*\]$/.test(trimmed)) return true;
5997
+ if (trimmed === "[HASH:unknown]") return true;
5998
+ if (/^\[HASH:[0-9a-f]{8}\]$/.test(trimmed)) return true;
5999
5999
  for (const marker of markers) {
6000
6000
  if (marker.endsWith(":")) continue;
6001
6001
  if (trimmed === marker) return true;
@@ -7540,7 +7540,7 @@ var init_checks2 = __esm({
7540
7540
  // Keep in sync with packages/redact/src/key-value-secret.ts (KEY_VALUE_SECRET_PATTERN_SOURCE).
7541
7541
  {
7542
7542
  id: "key-value-secret",
7543
- pattern: /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?]))([^\s"'\\]{8,})/i
7543
+ pattern: /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED|HASH:(?:[0-9a-f]{8}|unknown))\](?![^\s"'\\&#?]))([^\s"'\\]{8,})/i
7544
7544
  }
7545
7545
  ];
7546
7546
  }
@@ -8166,24 +8166,26 @@ function attemptIdOf(event) {
8166
8166
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
8167
8167
  }
8168
8168
  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;
8169
+ const identified = /* @__PURE__ */ new Set();
8170
+ let unidentified = 0;
8171
+ for (const event of members) {
8172
+ if (event.kind !== "TOOL" && event.kind !== "LLM") continue;
8173
+ const id = attemptIdOf(event);
8174
+ if (id !== void 0) {
8175
+ identified.add(id);
8176
+ continue;
8177
+ }
8178
+ unidentified += 1;
8179
+ }
8180
+ if (identified.size > 0) {
8181
+ return identified.size + unidentified;
8174
8182
  }
8175
8183
  const numbers = members.map((event) => attemptNumberOf(event)).filter((value) => value !== void 0).sort((a, b) => a - b);
8176
8184
  if (numbers.length > 0) {
8177
8185
  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;
8183
- }
8184
8186
  return unique.length;
8185
8187
  }
8186
- return members.filter((event) => event.kind === "TOOL" || event.kind === "LLM").length;
8188
+ return unidentified;
8187
8189
  }
8188
8190
  function classifyRetryAttempt(event, priorOrdered, allMembers) {
8189
8191
  const workflow = workflowFor(event);
@@ -8464,8 +8466,30 @@ function eventEvidence3(event) {
8464
8466
  function eventTime2(event) {
8465
8467
  return event.startedAt ?? event.timestamp ?? "";
8466
8468
  }
8469
+ function parseComparableMs(value) {
8470
+ if (!value) return void 0;
8471
+ const parsed = Date.parse(value);
8472
+ return Number.isFinite(parsed) ? parsed : void 0;
8473
+ }
8474
+ function consumerStartMs(event) {
8475
+ return parseComparableMs(event.startedAt) ?? parseComparableMs(event.timestamp);
8476
+ }
8477
+ function resultAvailableMs(event) {
8478
+ const ended = parseComparableMs(event.endedAt);
8479
+ if (ended !== void 0) return ended;
8480
+ const started = parseComparableMs(event.startedAt) ?? parseComparableMs(event.timestamp);
8481
+ if (started !== void 0 && event.durationMs !== void 0 && Number.isFinite(event.durationMs)) {
8482
+ return started + event.durationMs;
8483
+ }
8484
+ return parseComparableMs(event.timestamp);
8485
+ }
8467
8486
  function sortByTime2(events) {
8468
- return [...events].sort((a, b) => eventTime2(a).localeCompare(eventTime2(b)));
8487
+ return [...events].sort((a, b) => {
8488
+ const aMs = consumerStartMs(a) ?? 0;
8489
+ const bMs = consumerStartMs(b) ?? 0;
8490
+ if (aMs !== bMs) return aMs - bMs;
8491
+ return eventTime2(a).localeCompare(eventTime2(b));
8492
+ });
8469
8493
  }
8470
8494
  function errorCodeOf(event) {
8471
8495
  if (typeof event.error?.code === "string" && event.error.code.trim() !== "") {
@@ -8537,9 +8561,10 @@ function isUnevaluableWriteCompletion(event) {
8537
8561
  if (event.status === "running" || event.status === "unknown") return true;
8538
8562
  const attrs = event.attributes ?? {};
8539
8563
  if (attrs.timeout === true) return true;
8564
+ if (attrs.unknownCompletion === true) return true;
8540
8565
  if (attrs.completionState === "unknown" || attrs.completionState === "timeout") return true;
8541
8566
  const code = errorCodeOf(event)?.toUpperCase();
8542
- if (code === "TIMEOUT" || code === "UNKNOWN_COMPLETION" || code === "DEADLINE_EXCEEDED") {
8567
+ if (code && UNEVALUABLE_WRITE_ERROR_CODES.has(code)) {
8543
8568
  return true;
8544
8569
  }
8545
8570
  return false;
@@ -8587,14 +8612,17 @@ function collectExplicitReferences(event) {
8587
8612
  return refs;
8588
8613
  }
8589
8614
  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;
8615
+ if (llm.runId !== toolEvent.runId) return false;
8616
+ if (requireExplicit) {
8617
+ const refs = collectExplicitReferences(llm);
8618
+ const toolCallId = workflowFor2(toolEvent).toolCallId;
8619
+ const hasRef = refs.has(toolEvent.eventId) || toolCallId !== void 0 && refs.has(toolCallId);
8620
+ if (!hasRef) return false;
8621
+ }
8622
+ const resultMs = resultAvailableMs(toolEvent);
8623
+ const consumerMs = consumerStartMs(llm);
8624
+ if (resultMs === void 0 || consumerMs === void 0) return false;
8625
+ return resultMs <= consumerMs;
8598
8626
  }
8599
8627
  function attemptIdOf2(event) {
8600
8628
  const value = workflowFor2(event).attemptId;
@@ -8906,6 +8934,7 @@ function evaluateRecoveryOperations(events, operations) {
8906
8934
  }
8907
8935
  return findings;
8908
8936
  }
8937
+ var UNEVALUABLE_WRITE_ERROR_CODES;
8909
8938
  var init_recovery_operations = __esm({
8910
8939
  "packages/core/src/checks/recovery-operations.ts"() {
8911
8940
  init_canonical_equality();
@@ -8913,6 +8942,12 @@ var init_recovery_operations = __esm({
8913
8942
  init_tool_arguments();
8914
8943
  init_retry_safety();
8915
8944
  init_metadata();
8945
+ UNEVALUABLE_WRITE_ERROR_CODES = /* @__PURE__ */ new Set([
8946
+ "TIMEOUT",
8947
+ "ETIMEDOUT",
8948
+ "UNKNOWN_COMPLETION",
8949
+ "DEADLINE_EXCEEDED"
8950
+ ]);
8916
8951
  }
8917
8952
  });
8918
8953
 
@@ -16829,7 +16864,7 @@ var init_src = __esm({
16829
16864
  });
16830
16865
 
16831
16866
  // package.json
16832
- var version = "6.31.16";
16867
+ var version = "6.31.18";
16833
16868
 
16834
16869
  // packages/cli/src/list.ts
16835
16870
  init_advanced();
@@ -19480,6 +19515,51 @@ function genAiOperationName(kind) {
19480
19515
  return void 0;
19481
19516
  }
19482
19517
  }
19518
+ var STRUCTURAL_IDENTITY_KEYS = [
19519
+ "operationId",
19520
+ "attemptId",
19521
+ "retryOf",
19522
+ "attemptNumber",
19523
+ "attempt"
19524
+ ];
19525
+ function pickBoundedIdentityString(bag, key, maxLen) {
19526
+ if (!bag || typeof bag !== "object") return void 0;
19527
+ const direct = bag[key];
19528
+ if (typeof direct === "string" && direct.trim() !== "") {
19529
+ return direct.trim().slice(0, maxLen);
19530
+ }
19531
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
19532
+ if (typeof nested === "string" && nested.trim() !== "") {
19533
+ return nested.trim().slice(0, maxLen);
19534
+ }
19535
+ return void 0;
19536
+ }
19537
+ function pickBoundedIdentityNumber(bag, key) {
19538
+ if (!bag || typeof bag !== "object") return void 0;
19539
+ const direct = bag[key];
19540
+ if (typeof direct === "number" && Number.isFinite(direct)) return direct;
19541
+ const nested = bag.metadata && typeof bag.metadata === "object" ? bag.metadata[key] : void 0;
19542
+ if (typeof nested === "number" && Number.isFinite(nested)) return nested;
19543
+ return void 0;
19544
+ }
19545
+ function appendStructuralIdentityAttrs(attrs, meta2, maxLen) {
19546
+ const operationId = pickBoundedIdentityString(meta2, "operationId", maxLen);
19547
+ if (operationId !== void 0) {
19548
+ attrs.push(stringAttr2("agent_inspect.operation_id", operationId));
19549
+ }
19550
+ const attemptId = pickBoundedIdentityString(meta2, "attemptId", maxLen);
19551
+ if (attemptId !== void 0) {
19552
+ attrs.push(stringAttr2("agent_inspect.attempt_id", attemptId));
19553
+ }
19554
+ const retryOf = pickBoundedIdentityString(meta2, "retryOf", maxLen);
19555
+ if (retryOf !== void 0) {
19556
+ attrs.push(stringAttr2("agent_inspect.retry_of", retryOf));
19557
+ }
19558
+ const attemptNumber2 = pickBoundedIdentityNumber(meta2, "attemptNumber") ?? pickBoundedIdentityNumber(meta2, "attempt");
19559
+ if (attemptNumber2 !== void 0) {
19560
+ attrs.push(intAttr("agent_inspect.attempt_number", attemptNumber2));
19561
+ }
19562
+ }
19483
19563
  function resolveSpanTimes(ev) {
19484
19564
  const startedAtMs = typeof ev.attributes?.startedAtMs === "number" && Number.isFinite(ev.attributes.startedAtMs) ? ev.attributes.startedAtMs : void 0;
19485
19565
  const endedAtMs = typeof ev.attributes?.endedAtMs === "number" && Number.isFinite(ev.attributes.endedAtMs) ? ev.attributes.endedAtMs : void 0;
@@ -19500,7 +19580,8 @@ function exportOtlpJson(tree, options) {
19500
19580
  const warnings = [
19501
19581
  "OTLP JSON export uses OTel GenAI-aligned attributes where applicable; experimental until verified against specific collectors.",
19502
19582
  "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)."
19583
+ "Status and span kind use OTLP numeric enums (StatusCode 0/1/2, SpanKind INTERNAL=1).",
19584
+ "When present on source events, operationId/attemptId/retryOf/attemptNumber are emitted as bounded agent_inspect.* identity attributes (not a broad attribute dump)."
19504
19585
  ];
19505
19586
  const traceId = hexFrom2(`trace:${tree.runId}`, 16);
19506
19587
  const includeAttributes = options?.includeAttributes ?? false;
@@ -19548,6 +19629,11 @@ function exportOtlpJson(tree, options) {
19548
19629
  if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
19549
19630
  if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
19550
19631
  }
19632
+ appendStructuralIdentityAttrs(
19633
+ attrs,
19634
+ meta2 && typeof meta2 === "object" ? meta2 : void 0,
19635
+ maxLen
19636
+ );
19551
19637
  if (includeAttributes && meta2 && typeof meta2 === "object") {
19552
19638
  const skipKeys = /* @__PURE__ */ new Set([
19553
19639
  "tokens",
@@ -19556,7 +19642,8 @@ function exportOtlpJson(tree, options) {
19556
19642
  "responseModel",
19557
19643
  "responseModelId",
19558
19644
  "provider",
19559
- "originalSourceType"
19645
+ "originalSourceType",
19646
+ ...STRUCTURAL_IDENTITY_KEYS
19560
19647
  ]);
19561
19648
  for (const [k, v] of Object.entries(meta2)) {
19562
19649
  if (skipKeys.has(k)) continue;
@@ -21415,7 +21502,7 @@ function isCredentialSensitiveKey2(key, sensitiveKeys) {
21415
21502
  }
21416
21503
 
21417
21504
  // packages/redact/src/key-value-secret.ts
21418
- var KEY_VALUE_SECRET_PATTERN_SOURCE = String.raw`\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED(?::[^\]]*)?|HASH:[0-9a-f]{8})\](?![^\s"'\\&#?]))([^\s"'\\]{8,})`;
21505
+ var KEY_VALUE_SECRET_PATTERN_SOURCE = String.raw`\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED|HASH:(?:[0-9a-f]{8}|unknown))\](?![^\s"'\\&#?]))([^\s"'\\]{8,})`;
21419
21506
  var KEY_VALUE_SECRET_PATTERN2 = new RegExp(
21420
21507
  KEY_VALUE_SECRET_PATTERN_SOURCE,
21421
21508
  "i"
@@ -21872,8 +21959,8 @@ function isCompleteRedactionMarker(value, replacement = "[REDACTED]") {
21872
21959
  const trimmed = value.trim();
21873
21960
  if (trimmed.length === 0) return false;
21874
21961
  if (trimmed === replacement) return true;
21875
- if (/^\[HASH:[A-Za-z0-9_-]+\]$/.test(trimmed)) return true;
21876
- if (/^\[REDACTED:[^\]]*\]$/.test(trimmed)) return true;
21962
+ if (trimmed === "[HASH:unknown]") return true;
21963
+ if (/^\[HASH:[0-9a-f]{8}\]$/.test(trimmed)) return true;
21877
21964
  return false;
21878
21965
  }
21879
21966
  function applyRule(rule, value, replacement) {
@@ -22106,6 +22193,9 @@ function isRecord18(value) {
22106
22193
  }
22107
22194
  function rejectRemotePolicyPath(policyPath) {
22108
22195
  const trimmed = policyPath.trim();
22196
+ if (/^[a-z]:[\\/]/i.test(trimmed)) {
22197
+ return;
22198
+ }
22109
22199
  if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed)) {
22110
22200
  throw new Error(
22111
22201
  `--policy must be a local JSON file path (got a URL-like value). Remote policy fetch is not supported.`