@agent-inspect/mcp-server 6.31.28 → 6.31.30

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
@@ -7505,6 +7505,96 @@ function redactRunTreeForExport(tree, options) {
7505
7505
  return clone;
7506
7506
  }
7507
7507
 
7508
+ // packages/core/src/exporters/presentation-lifecycle.ts
7509
+ function stepIdOf2(event) {
7510
+ const value = event.attributes?.stepId;
7511
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
7512
+ }
7513
+ function lifecycleKey(event) {
7514
+ if (event.kind === "RUN") return `run:${event.runId}`;
7515
+ const stepId = stepIdOf2(event);
7516
+ if (stepId !== void 0) return `step:${stepId}`;
7517
+ return `event:${event.eventId}`;
7518
+ }
7519
+ function isTerminal(status) {
7520
+ return status === "ok" || status === "error";
7521
+ }
7522
+ function cloneNode(node) {
7523
+ return {
7524
+ event: {
7525
+ ...node.event,
7526
+ ...node.event.attributes !== void 0 ? { attributes: { ...node.event.attributes } } : {}
7527
+ },
7528
+ children: node.children.map(cloneNode),
7529
+ depth: node.depth
7530
+ };
7531
+ }
7532
+ function joinSiblingGroup(group) {
7533
+ 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");
7536
+ const terminalStatuses = new Set(terminals.map((n) => n.event.status));
7537
+ if (terminalStatuses.size > 1) {
7538
+ return group;
7539
+ }
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);
7547
+ }
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
7559
+ }
7560
+ ];
7561
+ }
7562
+ return group;
7563
+ }
7564
+ function presentSiblingNodes(nodes) {
7565
+ const prepared = nodes.map((n) => ({
7566
+ ...cloneNode(n),
7567
+ children: presentSiblingNodes(n.children)
7568
+ }));
7569
+ const order = [];
7570
+ const groups = /* @__PURE__ */ new Map();
7571
+ for (const node of prepared) {
7572
+ const key = lifecycleKey(node.event);
7573
+ if (!groups.has(key)) {
7574
+ groups.set(key, []);
7575
+ order.push(key);
7576
+ }
7577
+ groups.get(key).push(node);
7578
+ }
7579
+ const out = [];
7580
+ for (const key of order) {
7581
+ out.push(...joinSiblingGroup(groups.get(key)));
7582
+ }
7583
+ return out;
7584
+ }
7585
+ function presentLifecycleJoinedTree(tree) {
7586
+ return {
7587
+ ...tree,
7588
+ children: presentSiblingNodes(tree.children),
7589
+ metadata: {
7590
+ ...tree.metadata,
7591
+ confidenceBreakdown: { ...tree.metadata.confidenceBreakdown },
7592
+ kinds: { ...tree.metadata.kinds },
7593
+ ...tree.metadata.relationshipSummary !== void 0 ? { relationshipSummary: { ...tree.metadata.relationshipSummary } } : {}
7594
+ }
7595
+ };
7596
+ }
7597
+
7508
7598
  // packages/core/src/exporters/html-exporter.ts
7509
7599
  function renderTreeHtml(nodes, ulClass = "tree") {
7510
7600
  if (nodes.length === 0) return "";
@@ -7532,32 +7622,33 @@ function exportHtml(tree, options) {
7532
7622
  const includeErrors = options?.includeErrors ?? true;
7533
7623
  const maxLen = options?.maxAttributeLength ?? 500;
7534
7624
  const redacted = options?.redacted;
7535
- const titleName = escapeHtml(tree.name ?? tree.runId);
7625
+ const view = presentLifecycleJoinedTree(tree);
7626
+ const titleName = escapeHtml(view.name ?? view.runId);
7536
7627
  const summaryRows = [];
7537
7628
  summaryRows.push(
7538
- `<tr><th scope="row">runId</th><td><code>${escapeHtml(tree.runId)}</code></td></tr>`
7629
+ `<tr><th scope="row">runId</th><td><code>${escapeHtml(view.runId)}</code></td></tr>`
7539
7630
  );
7540
- if (tree.name !== void 0) {
7541
- summaryRows.push(`<tr><th scope="row">name</th><td>${escapeHtml(tree.name)}</td></tr>`);
7631
+ if (view.name !== void 0) {
7632
+ summaryRows.push(`<tr><th scope="row">name</th><td>${escapeHtml(view.name)}</td></tr>`);
7542
7633
  }
7543
7634
  summaryRows.push(
7544
- `<tr><th scope="row">status</th><td>${escapeHtml(String(tree.status ?? "unknown"))}</td></tr>`
7635
+ `<tr><th scope="row">status</th><td>${escapeHtml(String(view.status ?? "unknown"))}</td></tr>`
7545
7636
  );
7546
7637
  summaryRows.push(
7547
- `<tr><th scope="row">durationMs</th><td>${tree.durationMs !== void 0 ? escapeHtml(String(tree.durationMs)) : "\u2014"}</td></tr>`
7638
+ `<tr><th scope="row">durationMs</th><td>${view.durationMs !== void 0 ? escapeHtml(String(view.durationMs)) : "\u2014"}</td></tr>`
7548
7639
  );
7549
7640
  summaryRows.push(
7550
- `<tr><th scope="row">startedAt</th><td>${tree.startedAt !== void 0 ? escapeHtml(String(tree.startedAt)) : "\u2014"}</td></tr>`
7641
+ `<tr><th scope="row">startedAt</th><td>${view.startedAt !== void 0 ? escapeHtml(String(view.startedAt)) : "\u2014"}</td></tr>`
7551
7642
  );
7552
7643
  summaryRows.push(
7553
- `<tr><th scope="row">endedAt</th><td>${tree.endedAt !== void 0 ? escapeHtml(String(tree.endedAt)) : "\u2014"}</td></tr>`
7644
+ `<tr><th scope="row">endedAt</th><td>${view.endedAt !== void 0 ? escapeHtml(String(view.endedAt)) : "\u2014"}</td></tr>`
7554
7645
  );
7555
7646
  summaryRows.push(
7556
- `<tr><th scope="row">totalEvents</th><td>${escapeHtml(String(tree.metadata.totalEvents))}</td></tr>`
7647
+ `<tr><th scope="row">totalEvents</th><td>${escapeHtml(String(view.metadata.totalEvents))}</td></tr>`
7557
7648
  );
7558
7649
  let confidenceHtml = "";
7559
7650
  if (includeMetadata) {
7560
- const cb = tree.metadata.confidenceBreakdown;
7651
+ const cb = view.metadata.confidenceBreakdown;
7561
7652
  confidenceHtml += "<h3>Confidence breakdown</h3><table><thead><tr><th>bucket</th><th>count</th></tr></thead><tbody>";
7562
7653
  for (const k of Object.keys(cb).sort()) {
7563
7654
  const key = k;
@@ -7565,14 +7656,14 @@ function exportHtml(tree, options) {
7565
7656
  }
7566
7657
  confidenceHtml += "</tbody></table>";
7567
7658
  confidenceHtml += "<h3>Kind breakdown</h3><table><thead><tr><th>kind</th><th>count</th></tr></thead><tbody>";
7568
- for (const k of Object.keys(tree.metadata.kinds).sort()) {
7659
+ for (const k of Object.keys(view.metadata.kinds).sort()) {
7569
7660
  const key = k;
7570
- const c = tree.metadata.kinds[key];
7661
+ const c = view.metadata.kinds[key];
7571
7662
  if (c > 0) confidenceHtml += `<tr><td>${escapeHtml(key)}</td><td>${c}</td></tr>`;
7572
7663
  }
7573
7664
  confidenceHtml += "</tbody></table>";
7574
7665
  }
7575
- const flat = flattenTree(tree);
7666
+ const flat = flattenTree(view);
7576
7667
  const errors = flat.filter((n) => n.event.status === "error");
7577
7668
  let errorsHtml = "";
7578
7669
  if (includeErrors && errors.length > 0) {
@@ -7627,7 +7718,7 @@ footer{margin-top:2rem;font-size:0.85rem;color:#555}
7627
7718
  <header><h1>AgentInspect Run: ${titleName}</h1></header>
7628
7719
  <p class="note">Generated locally by AgentInspect.</p>
7629
7720
  ${includeMetadata ? `<section class="summary"><h2>Summary</h2><table>${summaryRows.join("")}</table>${confidenceHtml}</section>` : ""}
7630
- <section class="tree"><h2>Execution tree</h2>${tree.children.length > 0 ? renderTreeHtml(tree.children) : "<p>No steps recorded.</p>"}</section>
7721
+ <section class="tree"><h2>Execution tree</h2>${view.children.length > 0 ? renderTreeHtml(view.children) : "<p>No steps recorded.</p>"}</section>
7631
7722
  ${errorsHtml}
7632
7723
  ${attrsHtml}
7633
7724
  <footer>Generated locally by AgentInspect. Review for sensitive data before sharing.</footer>
@@ -7668,7 +7759,8 @@ function exportMarkdown(tree, options) {
7668
7759
  const includeErrors = options?.includeErrors ?? true;
7669
7760
  const maxLen = options?.maxAttributeLength ?? 500;
7670
7761
  const redacted = options?.redacted ?? true;
7671
- const titleName = tree.name ?? tree.runId;
7762
+ const view = presentLifecycleJoinedTree(tree);
7763
+ const titleName = view.name ?? view.runId;
7672
7764
  const lines = [];
7673
7765
  lines.push(`# AgentInspect Run: ${escapeMarkdown(titleName)}`);
7674
7766
  lines.push("");
@@ -7677,28 +7769,28 @@ function exportMarkdown(tree, options) {
7677
7769
  if (includeMetadata) {
7678
7770
  lines.push("## Summary");
7679
7771
  lines.push("");
7680
- lines.push(`- **runId**: ${escapeMarkdown(tree.runId)}`);
7681
- if (tree.name !== void 0) lines.push(`- **name**: ${escapeMarkdown(tree.name)}`);
7682
- lines.push(`- **status**: ${escapeMarkdown(String(tree.status ?? "unknown"))}`);
7772
+ lines.push(`- **runId**: ${escapeMarkdown(view.runId)}`);
7773
+ if (view.name !== void 0) lines.push(`- **name**: ${escapeMarkdown(view.name)}`);
7774
+ lines.push(`- **status**: ${escapeMarkdown(String(view.status ?? "unknown"))}`);
7683
7775
  lines.push(
7684
- `- **durationMs**: ${tree.durationMs !== void 0 ? escapeMarkdown(String(tree.durationMs)) : "-"}`
7776
+ `- **durationMs**: ${view.durationMs !== void 0 ? escapeMarkdown(String(view.durationMs)) : "-"}`
7685
7777
  );
7686
7778
  lines.push(
7687
- `- **startedAt**: ${tree.startedAt !== void 0 ? escapeMarkdown(String(tree.startedAt)) : "-"}`
7779
+ `- **startedAt**: ${view.startedAt !== void 0 ? escapeMarkdown(String(view.startedAt)) : "-"}`
7688
7780
  );
7689
7781
  lines.push(
7690
- `- **endedAt**: ${tree.endedAt !== void 0 ? escapeMarkdown(String(tree.endedAt)) : "-"}`
7782
+ `- **endedAt**: ${view.endedAt !== void 0 ? escapeMarkdown(String(view.endedAt)) : "-"}`
7691
7783
  );
7692
- lines.push(`- **totalEvents**: ${tree.metadata.totalEvents}`);
7784
+ lines.push(`- **totalEvents**: ${view.metadata.totalEvents}`);
7693
7785
  lines.push("");
7694
7786
  lines.push("### Confidence breakdown");
7695
7787
  lines.push("");
7696
7788
  lines.push("| bucket | count |");
7697
7789
  lines.push("| --- | --- |");
7698
- for (const k of Object.keys(tree.metadata.confidenceBreakdown).sort()) {
7790
+ for (const k of Object.keys(view.metadata.confidenceBreakdown).sort()) {
7699
7791
  const key = k;
7700
7792
  lines.push(
7701
- `| ${escapeMarkdown(key)} | ${tree.metadata.confidenceBreakdown[key]} |`
7793
+ `| ${escapeMarkdown(key)} | ${view.metadata.confidenceBreakdown[key]} |`
7702
7794
  );
7703
7795
  }
7704
7796
  lines.push("");
@@ -7706,9 +7798,9 @@ function exportMarkdown(tree, options) {
7706
7798
  lines.push("");
7707
7799
  lines.push("| kind | count |");
7708
7800
  lines.push("| --- | --- |");
7709
- for (const k of Object.keys(tree.metadata.kinds).sort()) {
7801
+ for (const k of Object.keys(view.metadata.kinds).sort()) {
7710
7802
  const key = k;
7711
- const c = tree.metadata.kinds[key];
7803
+ const c = view.metadata.kinds[key];
7712
7804
  if (c > 0) lines.push(`| ${escapeMarkdown(key)} | ${c} |`);
7713
7805
  }
7714
7806
  lines.push("");
@@ -7717,11 +7809,11 @@ function exportMarkdown(tree, options) {
7717
7809
  lines.push("");
7718
7810
  lines.push("```text");
7719
7811
  lines.push(
7720
- tree.children.length > 0 ? renderTreeAscii(tree.children) : "(no steps)"
7812
+ view.children.length > 0 ? renderTreeAscii(view.children) : "(no steps)"
7721
7813
  );
7722
7814
  lines.push("```");
7723
7815
  lines.push("");
7724
- const flat = flattenTree(tree);
7816
+ const flat = flattenTree(view);
7725
7817
  const errors = flat.filter((n) => n.event.status === "error");
7726
7818
  if (includeErrors && errors.length > 0) {
7727
7819
  lines.push("## Errors");