@agent-inspect/mcp-server 6.19.0 → 6.19.1

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
@@ -1160,9 +1160,63 @@ async function extractMetadata(filePath, _quickScan) {
1160
1160
  createdAt: stats.birthtime
1161
1161
  };
1162
1162
  }
1163
+ var ROOT_STEP_DEPTH = 0;
1164
+ var MAX_RUN_SUMMARY_DEPTH = 1e3;
1163
1165
  function isNonNegativeFiniteNumber(value) {
1164
1166
  return typeof value === "number" && Number.isFinite(value) && value >= 0;
1165
1167
  }
1168
+ function resolveParentStepId(step, steps) {
1169
+ const parentId = step.parentId;
1170
+ if (typeof parentId !== "string" || parentId.trim() === "") {
1171
+ return void 0;
1172
+ }
1173
+ return steps.has(parentId) ? parentId : void 0;
1174
+ }
1175
+ function computeStepDepth(stepId, steps, depthCache) {
1176
+ const cached = depthCache.get(stepId);
1177
+ if (cached !== void 0) return cached;
1178
+ const ancestry = [];
1179
+ const ancestryIndexes = /* @__PURE__ */ new Map();
1180
+ let currentStepId = stepId;
1181
+ let resolvedDepth;
1182
+ while (resolvedDepth === void 0) {
1183
+ const cachedDepth = depthCache.get(currentStepId);
1184
+ if (cachedDepth !== void 0) {
1185
+ resolvedDepth = cachedDepth;
1186
+ continue;
1187
+ }
1188
+ const cycleStart = ancestryIndexes.get(currentStepId);
1189
+ if (cycleStart !== void 0) {
1190
+ const cycleStepIds = ancestry.splice(cycleStart);
1191
+ for (const cycleStepId of cycleStepIds) {
1192
+ depthCache.set(cycleStepId, ROOT_STEP_DEPTH);
1193
+ }
1194
+ resolvedDepth = ROOT_STEP_DEPTH;
1195
+ continue;
1196
+ }
1197
+ const currentStep = steps.get(currentStepId);
1198
+ if (!currentStep) {
1199
+ resolvedDepth = ROOT_STEP_DEPTH;
1200
+ continue;
1201
+ }
1202
+ ancestryIndexes.set(currentStepId, ancestry.length);
1203
+ ancestry.push(currentStepId);
1204
+ const parentStepId = resolveParentStepId(currentStep, steps);
1205
+ if (parentStepId === void 0) {
1206
+ ancestry.pop();
1207
+ depthCache.set(currentStepId, ROOT_STEP_DEPTH);
1208
+ resolvedDepth = ROOT_STEP_DEPTH;
1209
+ continue;
1210
+ }
1211
+ currentStepId = parentStepId;
1212
+ }
1213
+ ancestry.reverse();
1214
+ for (const ancestorStepId of ancestry) {
1215
+ resolvedDepth = Math.min(MAX_RUN_SUMMARY_DEPTH, resolvedDepth + 1);
1216
+ depthCache.set(ancestorStepId, resolvedDepth);
1217
+ }
1218
+ return depthCache.get(stepId) ?? ROOT_STEP_DEPTH;
1219
+ }
1166
1220
  function buildRunSummary(events) {
1167
1221
  const started = events.find(
1168
1222
  (e) => e.event === "run_started"
@@ -1216,27 +1270,13 @@ function buildRunSummary(events) {
1216
1270
  let stepsWithKnownTotal = 0;
1217
1271
  let hasCachedTokens = false;
1218
1272
  const depthCache = /* @__PURE__ */ new Map();
1219
- const computeDepth = (stepId) => {
1220
- const cached = depthCache.get(stepId);
1221
- if (cached !== void 0) return cached;
1222
- const node = steps.get(stepId);
1223
- if (!node) return 0;
1224
- const parent = node.parentId;
1225
- if (typeof parent !== "string" || parent.trim() === "" || !steps.has(parent)) {
1226
- depthCache.set(stepId, 0);
1227
- return 0;
1228
- }
1229
- const d = Math.min(1e3, computeDepth(parent) + 1);
1230
- depthCache.set(stepId, d);
1231
- return d;
1232
- };
1233
1273
  for (const [id, s] of steps.entries()) {
1234
1274
  totalSteps += 1;
1235
1275
  if (s.type === "llm") llmSteps += 1;
1236
1276
  else if (s.type === "tool") toolSteps += 1;
1237
1277
  else logicSteps += 1;
1238
1278
  if (s.status === "error") errorSteps += 1;
1239
- const depth = computeDepth(id);
1279
+ const depth = computeStepDepth(id, steps, depthCache);
1240
1280
  if (depth > maxDepth) maxDepth = depth;
1241
1281
  if (typeof s.durationMs === "number" && Number.isFinite(s.durationMs)) {
1242
1282
  if (!longestStep || s.durationMs > longestStep.durationMs) {