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