@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.
package/dist/cli.cjs CHANGED
@@ -7510,6 +7510,16 @@ function stepIdOf2(event) {
7510
7510
  const value = event.attributes?.stepId;
7511
7511
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
7512
7512
  }
7513
+ function attemptIdOf(event) {
7514
+ const direct = event.attributes?.attemptId;
7515
+ if (typeof direct === "string" && direct.trim() !== "") return direct;
7516
+ const meta = event.attributes?.metadata;
7517
+ if (meta && typeof meta === "object" && !Array.isArray(meta)) {
7518
+ const nested = meta.attemptId;
7519
+ if (typeof nested === "string" && nested.trim() !== "") return nested;
7520
+ }
7521
+ return void 0;
7522
+ }
7513
7523
  function lifecycleKey(event) {
7514
7524
  if (event.kind === "RUN") return `run:${event.runId}`;
7515
7525
  const stepId = stepIdOf2(event);
@@ -7519,6 +7529,9 @@ function lifecycleKey(event) {
7519
7529
  function isTerminal(status) {
7520
7530
  return status === "ok" || status === "error";
7521
7531
  }
7532
+ function eventTime(event) {
7533
+ return typeof event.timestamp === "number" ? event.timestamp : 0;
7534
+ }
7522
7535
  function cloneNode(node) {
7523
7536
  return {
7524
7537
  event: {
@@ -7529,37 +7542,87 @@ function cloneNode(node) {
7529
7542
  depth: node.depth
7530
7543
  };
7531
7544
  }
7545
+ function joinOnePair(start, terminal) {
7546
+ const childMap = /* @__PURE__ */ new Map();
7547
+ if (start) {
7548
+ for (const child of start.children) {
7549
+ childMap.set(child.event.eventId, child);
7550
+ }
7551
+ }
7552
+ for (const child of terminal.children) {
7553
+ childMap.set(child.event.eventId, child);
7554
+ }
7555
+ return {
7556
+ event: {
7557
+ ...terminal.event,
7558
+ name: start?.event.name ?? terminal.event.name,
7559
+ kind: start?.event.kind ?? terminal.event.kind,
7560
+ ...start && attemptIdOf(terminal.event) === void 0 && attemptIdOf(start.event) ? {
7561
+ attributes: {
7562
+ ...terminal.event.attributes,
7563
+ attemptId: attemptIdOf(start.event)
7564
+ }
7565
+ } : {}
7566
+ },
7567
+ children: presentSiblingNodes([...childMap.values()]),
7568
+ depth: terminal.depth
7569
+ };
7570
+ }
7532
7571
  function joinSiblingGroup(group) {
7533
7572
  if (group.length <= 1) return group;
7534
- const terminals = group.filter((n) => isTerminal(n.event.status));
7535
- const runnings = group.filter((n) => n.event.status === "running");
7573
+ const terminals = group.filter((n) => isTerminal(n.event.status)).sort((a, b) => eventTime(a.event) - eventTime(b.event));
7574
+ const runnings = group.filter((n) => n.event.status === "running").sort((a, b) => eventTime(a.event) - eventTime(b.event));
7575
+ const others = group.filter(
7576
+ (n) => !isTerminal(n.event.status) && n.event.status !== "running"
7577
+ );
7536
7578
  const terminalStatuses = new Set(terminals.map((n) => n.event.status));
7537
7579
  if (terminalStatuses.size > 1) {
7538
7580
  return group;
7539
7581
  }
7540
- if (terminals.length >= 1) {
7541
- const terminal = terminals[terminals.length - 1];
7542
- const start = runnings[0];
7543
- const childMap = /* @__PURE__ */ new Map();
7544
- for (const n of group) {
7545
- for (const child of n.children) {
7546
- childMap.set(child.event.eventId, child);
7582
+ if (terminals.length > 1 && terminals.every((t) => attemptIdOf(t.event) === void 0) && runnings.every((r) => attemptIdOf(r.event) === void 0)) {
7583
+ return group;
7584
+ }
7585
+ const usedRunning = /* @__PURE__ */ new Set();
7586
+ const out = [];
7587
+ for (const terminal of terminals) {
7588
+ const terminalAttempt = attemptIdOf(terminal.event);
7589
+ const terminalTs = eventTime(terminal.event);
7590
+ const candidate = runnings.find((r) => {
7591
+ if (usedRunning.has(r.event.eventId)) return false;
7592
+ if (eventTime(r.event) > terminalTs) return false;
7593
+ const runningAttempt = attemptIdOf(r.event);
7594
+ if (terminalAttempt !== void 0) {
7595
+ return runningAttempt === terminalAttempt;
7547
7596
  }
7548
- }
7549
- return [
7550
- {
7551
- event: {
7552
- ...terminal.event,
7553
- name: start?.event.name ?? terminal.event.name,
7554
- kind: start?.event.kind ?? terminal.event.kind,
7555
- ...start?.event.timestamp !== void 0 && terminal.event.durationMs === void 0 ? {} : {}
7556
- },
7557
- children: presentSiblingNodes([...childMap.values()]),
7558
- depth: terminal.depth
7597
+ if (runningAttempt !== void 0) {
7598
+ return true;
7559
7599
  }
7560
- ];
7600
+ return true;
7601
+ });
7602
+ if (candidate) {
7603
+ usedRunning.add(candidate.event.eventId);
7604
+ out.push(joinOnePair(candidate, terminal));
7605
+ } else {
7606
+ out.push({
7607
+ ...terminal,
7608
+ children: presentSiblingNodes(terminal.children)
7609
+ });
7610
+ }
7611
+ }
7612
+ for (const running of runnings) {
7613
+ if (usedRunning.has(running.event.eventId)) continue;
7614
+ out.push({
7615
+ ...running,
7616
+ children: presentSiblingNodes(running.children)
7617
+ });
7561
7618
  }
7562
- return group;
7619
+ for (const other of others) {
7620
+ out.push({
7621
+ ...other,
7622
+ children: presentSiblingNodes(other.children)
7623
+ });
7624
+ }
7625
+ return out;
7563
7626
  }
7564
7627
  function presentSiblingNodes(nodes) {
7565
7628
  const prepared = nodes.map((n) => ({