agent-inspect 6.19.0 → 6.20.0

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 (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +3 -1
  3. package/SECURITY.md +2 -0
  4. package/docs/ARCHITECTURE.md +28 -16
  5. package/docs/KNOWN-ISSUES.md +3 -3
  6. package/docs/LIMITATIONS.md +5 -4
  7. package/docs/PERFORMANCE.md +1 -1
  8. package/docs/SUPPORT-LEVELS.md +2 -1
  9. package/docs/TRACE-CONTRACTS.md +64 -52
  10. package/package.json +3 -2
  11. package/packages/cli/dist/{chunk-R7Y5SGH5.mjs → chunk-QPRJUVLH.mjs} +57 -17
  12. package/packages/cli/dist/chunk-QPRJUVLH.mjs.map +1 -0
  13. package/packages/cli/dist/index.cjs +69 -18
  14. package/packages/cli/dist/index.cjs.map +1 -1
  15. package/packages/cli/dist/index.mjs +9 -6
  16. package/packages/cli/dist/index.mjs.map +1 -1
  17. package/packages/cli/dist/{src-T4EZERCX.mjs → src-6W5ZR3I7.mjs} +3 -3
  18. package/packages/cli/dist/{src-T4EZERCX.mjs.map → src-6W5ZR3I7.mjs.map} +1 -1
  19. package/packages/core/dist/advanced.cjs +118 -18
  20. package/packages/core/dist/advanced.cjs.map +1 -1
  21. package/packages/core/dist/advanced.d.cts +2 -2
  22. package/packages/core/dist/advanced.d.ts +2 -2
  23. package/packages/core/dist/advanced.mjs +8 -8
  24. package/packages/core/dist/checks.cjs +443 -9
  25. package/packages/core/dist/checks.cjs.map +1 -1
  26. package/packages/core/dist/checks.d.cts +78 -16
  27. package/packages/core/dist/checks.d.ts +78 -16
  28. package/packages/core/dist/checks.mjs +3 -3
  29. package/packages/core/dist/{chunk-VFO76UH3.mjs → chunk-3XS5O4JI.mjs} +3 -3
  30. package/packages/core/dist/{chunk-VFO76UH3.mjs.map → chunk-3XS5O4JI.mjs.map} +1 -1
  31. package/packages/core/dist/{chunk-ZWA5RWMV.mjs → chunk-5YFJJFXU.mjs} +4 -4
  32. package/packages/core/dist/{chunk-ZWA5RWMV.mjs.map → chunk-5YFJJFXU.mjs.map} +1 -1
  33. package/packages/core/dist/{chunk-NABMW5DX.mjs → chunk-G47KQB42.mjs} +445 -13
  34. package/packages/core/dist/chunk-G47KQB42.mjs.map +1 -0
  35. package/packages/core/dist/{chunk-SGL4JGCD.mjs → chunk-JBNRJLIV.mjs} +58 -18
  36. package/packages/core/dist/chunk-JBNRJLIV.mjs.map +1 -0
  37. package/packages/core/dist/{chunk-ULCGIRTC.mjs → chunk-U25RHRSU.mjs} +65 -5
  38. package/packages/core/dist/chunk-U25RHRSU.mjs.map +1 -0
  39. package/packages/core/dist/{context-Ca5yK8Cs.d.cts → context-C5ye_xcS.d.cts} +0 -4
  40. package/packages/core/dist/{context-D6cS4XIL.d.ts → context-CNsNSgE2.d.ts} +0 -4
  41. package/packages/core/dist/exporters.cjs +55 -15
  42. package/packages/core/dist/exporters.cjs.map +1 -1
  43. package/packages/core/dist/exporters.mjs +3 -3
  44. package/packages/core/dist/{index-DKwuGSe-.d.ts → index-Bg9ZdsdS.d.ts} +10 -0
  45. package/packages/core/dist/{index-DCR816Yt.d.cts → index-rVpX5PPh.d.cts} +10 -0
  46. package/packages/core/dist/index.cjs +63 -3
  47. package/packages/core/dist/index.cjs.map +1 -1
  48. package/packages/core/dist/index.d.cts +1 -1
  49. package/packages/core/dist/index.d.ts +1 -1
  50. package/packages/core/dist/index.mjs +4 -4
  51. package/packages/core/dist/writers.cjs +33 -2
  52. package/packages/core/dist/writers.cjs.map +1 -1
  53. package/packages/core/dist/writers.mjs +1 -1
  54. package/packages/cli/dist/chunk-R7Y5SGH5.mjs.map +0 -1
  55. package/packages/core/dist/chunk-NABMW5DX.mjs.map +0 -1
  56. package/packages/core/dist/chunk-SGL4JGCD.mjs.map +0 -1
  57. package/packages/core/dist/chunk-ULCGIRTC.mjs.map +0 -1
@@ -1455,9 +1455,63 @@ function formatTimestamp(timestamp) {
1455
1455
  function isFiniteNumber(v) {
1456
1456
  return typeof v === "number" && Number.isFinite(v);
1457
1457
  }
1458
+ var ROOT_STEP_DEPTH = 0;
1459
+ var MAX_RUN_SUMMARY_DEPTH = 1e3;
1458
1460
  function isNonNegativeFiniteNumber(value) {
1459
1461
  return typeof value === "number" && Number.isFinite(value) && value >= 0;
1460
1462
  }
1463
+ function resolveParentStepId(step, steps) {
1464
+ const parentId = step.parentId;
1465
+ if (typeof parentId !== "string" || parentId.trim() === "") {
1466
+ return void 0;
1467
+ }
1468
+ return steps.has(parentId) ? parentId : void 0;
1469
+ }
1470
+ function computeStepDepth(stepId, steps, depthCache) {
1471
+ const cached = depthCache.get(stepId);
1472
+ if (cached !== void 0) return cached;
1473
+ const ancestry = [];
1474
+ const ancestryIndexes = /* @__PURE__ */ new Map();
1475
+ let currentStepId = stepId;
1476
+ let resolvedDepth;
1477
+ while (resolvedDepth === void 0) {
1478
+ const cachedDepth = depthCache.get(currentStepId);
1479
+ if (cachedDepth !== void 0) {
1480
+ resolvedDepth = cachedDepth;
1481
+ continue;
1482
+ }
1483
+ const cycleStart = ancestryIndexes.get(currentStepId);
1484
+ if (cycleStart !== void 0) {
1485
+ const cycleStepIds = ancestry.splice(cycleStart);
1486
+ for (const cycleStepId of cycleStepIds) {
1487
+ depthCache.set(cycleStepId, ROOT_STEP_DEPTH);
1488
+ }
1489
+ resolvedDepth = ROOT_STEP_DEPTH;
1490
+ continue;
1491
+ }
1492
+ const currentStep = steps.get(currentStepId);
1493
+ if (!currentStep) {
1494
+ resolvedDepth = ROOT_STEP_DEPTH;
1495
+ continue;
1496
+ }
1497
+ ancestryIndexes.set(currentStepId, ancestry.length);
1498
+ ancestry.push(currentStepId);
1499
+ const parentStepId = resolveParentStepId(currentStep, steps);
1500
+ if (parentStepId === void 0) {
1501
+ ancestry.pop();
1502
+ depthCache.set(currentStepId, ROOT_STEP_DEPTH);
1503
+ resolvedDepth = ROOT_STEP_DEPTH;
1504
+ continue;
1505
+ }
1506
+ currentStepId = parentStepId;
1507
+ }
1508
+ ancestry.reverse();
1509
+ for (const ancestorStepId of ancestry) {
1510
+ resolvedDepth = Math.min(MAX_RUN_SUMMARY_DEPTH, resolvedDepth + 1);
1511
+ depthCache.set(ancestorStepId, resolvedDepth);
1512
+ }
1513
+ return depthCache.get(stepId) ?? ROOT_STEP_DEPTH;
1514
+ }
1461
1515
  function buildRunSummary(events) {
1462
1516
  const started = events.find(
1463
1517
  (e) => e.event === "run_started"
@@ -1511,27 +1565,13 @@ function buildRunSummary(events) {
1511
1565
  let stepsWithKnownTotal = 0;
1512
1566
  let hasCachedTokens = false;
1513
1567
  const depthCache = /* @__PURE__ */ new Map();
1514
- const computeDepth = (stepId) => {
1515
- const cached = depthCache.get(stepId);
1516
- if (cached !== void 0) return cached;
1517
- const node = steps.get(stepId);
1518
- if (!node) return 0;
1519
- const parent = node.parentId;
1520
- if (typeof parent !== "string" || parent.trim() === "" || !steps.has(parent)) {
1521
- depthCache.set(stepId, 0);
1522
- return 0;
1523
- }
1524
- const d = Math.min(1e3, computeDepth(parent) + 1);
1525
- depthCache.set(stepId, d);
1526
- return d;
1527
- };
1528
1568
  for (const [id, s] of steps.entries()) {
1529
1569
  totalSteps += 1;
1530
1570
  if (s.type === "llm") llmSteps += 1;
1531
1571
  else if (s.type === "tool") toolSteps += 1;
1532
1572
  else logicSteps += 1;
1533
1573
  if (s.status === "error") errorSteps += 1;
1534
- const depth = computeDepth(id);
1574
+ const depth = computeStepDepth(id, steps, depthCache);
1535
1575
  if (depth > maxDepth) maxDepth = depth;
1536
1576
  if (typeof s.durationMs === "number" && Number.isFinite(s.durationMs)) {
1537
1577
  if (!longestStep || s.durationMs > longestStep.durationMs) {