@agent-inspect/mcp-server 6.31.30 → 6.31.31

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.
@@ -7500,6 +7500,16 @@ function stepIdOf2(event) {
7500
7500
  const value = event.attributes?.stepId;
7501
7501
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
7502
7502
  }
7503
+ function attemptIdOf(event) {
7504
+ const direct = event.attributes?.attemptId;
7505
+ if (typeof direct === "string" && direct.trim() !== "") return direct;
7506
+ const meta = event.attributes?.metadata;
7507
+ if (meta && typeof meta === "object" && !Array.isArray(meta)) {
7508
+ const nested = meta.attemptId;
7509
+ if (typeof nested === "string" && nested.trim() !== "") return nested;
7510
+ }
7511
+ return void 0;
7512
+ }
7503
7513
  function lifecycleKey(event) {
7504
7514
  if (event.kind === "RUN") return `run:${event.runId}`;
7505
7515
  const stepId = stepIdOf2(event);
@@ -7509,6 +7519,9 @@ function lifecycleKey(event) {
7509
7519
  function isTerminal(status) {
7510
7520
  return status === "ok" || status === "error";
7511
7521
  }
7522
+ function eventTime(event) {
7523
+ return typeof event.timestamp === "number" ? event.timestamp : 0;
7524
+ }
7512
7525
  function cloneNode(node) {
7513
7526
  return {
7514
7527
  event: {
@@ -7519,37 +7532,87 @@ function cloneNode(node) {
7519
7532
  depth: node.depth
7520
7533
  };
7521
7534
  }
7535
+ function joinOnePair(start, terminal) {
7536
+ const childMap = /* @__PURE__ */ new Map();
7537
+ if (start) {
7538
+ for (const child of start.children) {
7539
+ childMap.set(child.event.eventId, child);
7540
+ }
7541
+ }
7542
+ for (const child of terminal.children) {
7543
+ childMap.set(child.event.eventId, child);
7544
+ }
7545
+ return {
7546
+ event: {
7547
+ ...terminal.event,
7548
+ name: start?.event.name ?? terminal.event.name,
7549
+ kind: start?.event.kind ?? terminal.event.kind,
7550
+ ...start && attemptIdOf(terminal.event) === void 0 && attemptIdOf(start.event) ? {
7551
+ attributes: {
7552
+ ...terminal.event.attributes,
7553
+ attemptId: attemptIdOf(start.event)
7554
+ }
7555
+ } : {}
7556
+ },
7557
+ children: presentSiblingNodes([...childMap.values()]),
7558
+ depth: terminal.depth
7559
+ };
7560
+ }
7522
7561
  function joinSiblingGroup(group) {
7523
7562
  if (group.length <= 1) return group;
7524
- const terminals = group.filter((n) => isTerminal(n.event.status));
7525
- const runnings = group.filter((n) => n.event.status === "running");
7563
+ const terminals = group.filter((n) => isTerminal(n.event.status)).sort((a, b) => eventTime(a.event) - eventTime(b.event));
7564
+ const runnings = group.filter((n) => n.event.status === "running").sort((a, b) => eventTime(a.event) - eventTime(b.event));
7565
+ const others = group.filter(
7566
+ (n) => !isTerminal(n.event.status) && n.event.status !== "running"
7567
+ );
7526
7568
  const terminalStatuses = new Set(terminals.map((n) => n.event.status));
7527
7569
  if (terminalStatuses.size > 1) {
7528
7570
  return group;
7529
7571
  }
7530
- if (terminals.length >= 1) {
7531
- const terminal = terminals[terminals.length - 1];
7532
- const start = runnings[0];
7533
- const childMap = /* @__PURE__ */ new Map();
7534
- for (const n of group) {
7535
- for (const child of n.children) {
7536
- childMap.set(child.event.eventId, child);
7572
+ if (terminals.length > 1 && terminals.every((t) => attemptIdOf(t.event) === void 0) && runnings.every((r) => attemptIdOf(r.event) === void 0)) {
7573
+ return group;
7574
+ }
7575
+ const usedRunning = /* @__PURE__ */ new Set();
7576
+ const out = [];
7577
+ for (const terminal of terminals) {
7578
+ const terminalAttempt = attemptIdOf(terminal.event);
7579
+ const terminalTs = eventTime(terminal.event);
7580
+ const candidate = runnings.find((r) => {
7581
+ if (usedRunning.has(r.event.eventId)) return false;
7582
+ if (eventTime(r.event) > terminalTs) return false;
7583
+ const runningAttempt = attemptIdOf(r.event);
7584
+ if (terminalAttempt !== void 0) {
7585
+ return runningAttempt === terminalAttempt;
7537
7586
  }
7538
- }
7539
- return [
7540
- {
7541
- event: {
7542
- ...terminal.event,
7543
- name: start?.event.name ?? terminal.event.name,
7544
- kind: start?.event.kind ?? terminal.event.kind,
7545
- ...start?.event.timestamp !== void 0 && terminal.event.durationMs === void 0 ? {} : {}
7546
- },
7547
- children: presentSiblingNodes([...childMap.values()]),
7548
- depth: terminal.depth
7587
+ if (runningAttempt !== void 0) {
7588
+ return true;
7549
7589
  }
7550
- ];
7590
+ return true;
7591
+ });
7592
+ if (candidate) {
7593
+ usedRunning.add(candidate.event.eventId);
7594
+ out.push(joinOnePair(candidate, terminal));
7595
+ } else {
7596
+ out.push({
7597
+ ...terminal,
7598
+ children: presentSiblingNodes(terminal.children)
7599
+ });
7600
+ }
7601
+ }
7602
+ for (const running of runnings) {
7603
+ if (usedRunning.has(running.event.eventId)) continue;
7604
+ out.push({
7605
+ ...running,
7606
+ children: presentSiblingNodes(running.children)
7607
+ });
7551
7608
  }
7552
- return group;
7609
+ for (const other of others) {
7610
+ out.push({
7611
+ ...other,
7612
+ children: presentSiblingNodes(other.children)
7613
+ });
7614
+ }
7615
+ return out;
7553
7616
  }
7554
7617
  function presentSiblingNodes(nodes) {
7555
7618
  const prepared = nodes.map((n) => ({
@@ -9909,5 +9972,5 @@ async function runReadOnlyMcpServer(options = {}) {
9909
9972
  }
9910
9973
 
9911
9974
  export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
9912
- //# sourceMappingURL=chunk-PN5KPAGV.mjs.map
9913
- //# sourceMappingURL=chunk-PN5KPAGV.mjs.map
9975
+ //# sourceMappingURL=chunk-W5KI3MNP.mjs.map
9976
+ //# sourceMappingURL=chunk-W5KI3MNP.mjs.map