@agent-inspect/mcp-server 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.
@@ -1150,9 +1150,63 @@ async function extractMetadata(filePath, _quickScan) {
1150
1150
  createdAt: stats.birthtime
1151
1151
  };
1152
1152
  }
1153
+ var ROOT_STEP_DEPTH = 0;
1154
+ var MAX_RUN_SUMMARY_DEPTH = 1e3;
1153
1155
  function isNonNegativeFiniteNumber(value) {
1154
1156
  return typeof value === "number" && Number.isFinite(value) && value >= 0;
1155
1157
  }
1158
+ function resolveParentStepId(step, steps) {
1159
+ const parentId = step.parentId;
1160
+ if (typeof parentId !== "string" || parentId.trim() === "") {
1161
+ return void 0;
1162
+ }
1163
+ return steps.has(parentId) ? parentId : void 0;
1164
+ }
1165
+ function computeStepDepth(stepId, steps, depthCache) {
1166
+ const cached = depthCache.get(stepId);
1167
+ if (cached !== void 0) return cached;
1168
+ const ancestry = [];
1169
+ const ancestryIndexes = /* @__PURE__ */ new Map();
1170
+ let currentStepId = stepId;
1171
+ let resolvedDepth;
1172
+ while (resolvedDepth === void 0) {
1173
+ const cachedDepth = depthCache.get(currentStepId);
1174
+ if (cachedDepth !== void 0) {
1175
+ resolvedDepth = cachedDepth;
1176
+ continue;
1177
+ }
1178
+ const cycleStart = ancestryIndexes.get(currentStepId);
1179
+ if (cycleStart !== void 0) {
1180
+ const cycleStepIds = ancestry.splice(cycleStart);
1181
+ for (const cycleStepId of cycleStepIds) {
1182
+ depthCache.set(cycleStepId, ROOT_STEP_DEPTH);
1183
+ }
1184
+ resolvedDepth = ROOT_STEP_DEPTH;
1185
+ continue;
1186
+ }
1187
+ const currentStep = steps.get(currentStepId);
1188
+ if (!currentStep) {
1189
+ resolvedDepth = ROOT_STEP_DEPTH;
1190
+ continue;
1191
+ }
1192
+ ancestryIndexes.set(currentStepId, ancestry.length);
1193
+ ancestry.push(currentStepId);
1194
+ const parentStepId = resolveParentStepId(currentStep, steps);
1195
+ if (parentStepId === void 0) {
1196
+ ancestry.pop();
1197
+ depthCache.set(currentStepId, ROOT_STEP_DEPTH);
1198
+ resolvedDepth = ROOT_STEP_DEPTH;
1199
+ continue;
1200
+ }
1201
+ currentStepId = parentStepId;
1202
+ }
1203
+ ancestry.reverse();
1204
+ for (const ancestorStepId of ancestry) {
1205
+ resolvedDepth = Math.min(MAX_RUN_SUMMARY_DEPTH, resolvedDepth + 1);
1206
+ depthCache.set(ancestorStepId, resolvedDepth);
1207
+ }
1208
+ return depthCache.get(stepId) ?? ROOT_STEP_DEPTH;
1209
+ }
1156
1210
  function buildRunSummary(events) {
1157
1211
  const started = events.find(
1158
1212
  (e) => e.event === "run_started"
@@ -1206,27 +1260,13 @@ function buildRunSummary(events) {
1206
1260
  let stepsWithKnownTotal = 0;
1207
1261
  let hasCachedTokens = false;
1208
1262
  const depthCache = /* @__PURE__ */ new Map();
1209
- const computeDepth = (stepId) => {
1210
- const cached = depthCache.get(stepId);
1211
- if (cached !== void 0) return cached;
1212
- const node = steps.get(stepId);
1213
- if (!node) return 0;
1214
- const parent = node.parentId;
1215
- if (typeof parent !== "string" || parent.trim() === "" || !steps.has(parent)) {
1216
- depthCache.set(stepId, 0);
1217
- return 0;
1218
- }
1219
- const d = Math.min(1e3, computeDepth(parent) + 1);
1220
- depthCache.set(stepId, d);
1221
- return d;
1222
- };
1223
1263
  for (const [id, s] of steps.entries()) {
1224
1264
  totalSteps += 1;
1225
1265
  if (s.type === "llm") llmSteps += 1;
1226
1266
  else if (s.type === "tool") toolSteps += 1;
1227
1267
  else logicSteps += 1;
1228
1268
  if (s.status === "error") errorSteps += 1;
1229
- const depth = computeDepth(id);
1269
+ const depth = computeStepDepth(id, steps, depthCache);
1230
1270
  if (depth > maxDepth) maxDepth = depth;
1231
1271
  if (typeof s.durationMs === "number" && Number.isFinite(s.durationMs)) {
1232
1272
  if (!longestStep || s.durationMs > longestStep.durationMs) {
@@ -8392,5 +8432,5 @@ async function runReadOnlyMcpServer(options = {}) {
8392
8432
  }
8393
8433
 
8394
8434
  export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
8395
- //# sourceMappingURL=chunk-O66SXMBQ.mjs.map
8396
- //# sourceMappingURL=chunk-O66SXMBQ.mjs.map
8435
+ //# sourceMappingURL=chunk-4FSMUSWK.mjs.map
8436
+ //# sourceMappingURL=chunk-4FSMUSWK.mjs.map