@agent-inspect/mcp-server 6.31.29 → 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/{chunk-S7SI3WG6.mjs → chunk-W5KI3MNP.mjs} +185 -30
- package/dist/chunk-W5KI3MNP.mjs.map +1 -0
- package/dist/cli.cjs +183 -28
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +183 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-S7SI3WG6.mjs.map +0 -1
|
@@ -7495,6 +7495,159 @@ 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 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
|
+
}
|
|
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 eventTime(event) {
|
|
7523
|
+
return typeof event.timestamp === "number" ? event.timestamp : 0;
|
|
7524
|
+
}
|
|
7525
|
+
function cloneNode(node) {
|
|
7526
|
+
return {
|
|
7527
|
+
event: {
|
|
7528
|
+
...node.event,
|
|
7529
|
+
...node.event.attributes !== void 0 ? { attributes: { ...node.event.attributes } } : {}
|
|
7530
|
+
},
|
|
7531
|
+
children: node.children.map(cloneNode),
|
|
7532
|
+
depth: node.depth
|
|
7533
|
+
};
|
|
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
|
+
}
|
|
7561
|
+
function joinSiblingGroup(group) {
|
|
7562
|
+
if (group.length <= 1) return group;
|
|
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
|
+
);
|
|
7568
|
+
const terminalStatuses = new Set(terminals.map((n) => n.event.status));
|
|
7569
|
+
if (terminalStatuses.size > 1) {
|
|
7570
|
+
return group;
|
|
7571
|
+
}
|
|
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;
|
|
7586
|
+
}
|
|
7587
|
+
if (runningAttempt !== void 0) {
|
|
7588
|
+
return true;
|
|
7589
|
+
}
|
|
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
|
+
});
|
|
7608
|
+
}
|
|
7609
|
+
for (const other of others) {
|
|
7610
|
+
out.push({
|
|
7611
|
+
...other,
|
|
7612
|
+
children: presentSiblingNodes(other.children)
|
|
7613
|
+
});
|
|
7614
|
+
}
|
|
7615
|
+
return out;
|
|
7616
|
+
}
|
|
7617
|
+
function presentSiblingNodes(nodes) {
|
|
7618
|
+
const prepared = nodes.map((n) => ({
|
|
7619
|
+
...cloneNode(n),
|
|
7620
|
+
children: presentSiblingNodes(n.children)
|
|
7621
|
+
}));
|
|
7622
|
+
const order = [];
|
|
7623
|
+
const groups = /* @__PURE__ */ new Map();
|
|
7624
|
+
for (const node of prepared) {
|
|
7625
|
+
const key = lifecycleKey(node.event);
|
|
7626
|
+
if (!groups.has(key)) {
|
|
7627
|
+
groups.set(key, []);
|
|
7628
|
+
order.push(key);
|
|
7629
|
+
}
|
|
7630
|
+
groups.get(key).push(node);
|
|
7631
|
+
}
|
|
7632
|
+
const out = [];
|
|
7633
|
+
for (const key of order) {
|
|
7634
|
+
out.push(...joinSiblingGroup(groups.get(key)));
|
|
7635
|
+
}
|
|
7636
|
+
return out;
|
|
7637
|
+
}
|
|
7638
|
+
function presentLifecycleJoinedTree(tree) {
|
|
7639
|
+
return {
|
|
7640
|
+
...tree,
|
|
7641
|
+
children: presentSiblingNodes(tree.children),
|
|
7642
|
+
metadata: {
|
|
7643
|
+
...tree.metadata,
|
|
7644
|
+
confidenceBreakdown: { ...tree.metadata.confidenceBreakdown },
|
|
7645
|
+
kinds: { ...tree.metadata.kinds },
|
|
7646
|
+
...tree.metadata.relationshipSummary !== void 0 ? { relationshipSummary: { ...tree.metadata.relationshipSummary } } : {}
|
|
7647
|
+
}
|
|
7648
|
+
};
|
|
7649
|
+
}
|
|
7650
|
+
|
|
7498
7651
|
// packages/core/src/exporters/html-exporter.ts
|
|
7499
7652
|
function renderTreeHtml(nodes, ulClass = "tree") {
|
|
7500
7653
|
if (nodes.length === 0) return "";
|
|
@@ -7522,32 +7675,33 @@ function exportHtml(tree, options) {
|
|
|
7522
7675
|
const includeErrors = options?.includeErrors ?? true;
|
|
7523
7676
|
const maxLen = options?.maxAttributeLength ?? 500;
|
|
7524
7677
|
const redacted = options?.redacted;
|
|
7525
|
-
const
|
|
7678
|
+
const view = presentLifecycleJoinedTree(tree);
|
|
7679
|
+
const titleName = escapeHtml(view.name ?? view.runId);
|
|
7526
7680
|
const summaryRows = [];
|
|
7527
7681
|
summaryRows.push(
|
|
7528
|
-
`<tr><th scope="row">runId</th><td><code>${escapeHtml(
|
|
7682
|
+
`<tr><th scope="row">runId</th><td><code>${escapeHtml(view.runId)}</code></td></tr>`
|
|
7529
7683
|
);
|
|
7530
|
-
if (
|
|
7531
|
-
summaryRows.push(`<tr><th scope="row">name</th><td>${escapeHtml(
|
|
7684
|
+
if (view.name !== void 0) {
|
|
7685
|
+
summaryRows.push(`<tr><th scope="row">name</th><td>${escapeHtml(view.name)}</td></tr>`);
|
|
7532
7686
|
}
|
|
7533
7687
|
summaryRows.push(
|
|
7534
|
-
`<tr><th scope="row">status</th><td>${escapeHtml(String(
|
|
7688
|
+
`<tr><th scope="row">status</th><td>${escapeHtml(String(view.status ?? "unknown"))}</td></tr>`
|
|
7535
7689
|
);
|
|
7536
7690
|
summaryRows.push(
|
|
7537
|
-
`<tr><th scope="row">durationMs</th><td>${
|
|
7691
|
+
`<tr><th scope="row">durationMs</th><td>${view.durationMs !== void 0 ? escapeHtml(String(view.durationMs)) : "\u2014"}</td></tr>`
|
|
7538
7692
|
);
|
|
7539
7693
|
summaryRows.push(
|
|
7540
|
-
`<tr><th scope="row">startedAt</th><td>${
|
|
7694
|
+
`<tr><th scope="row">startedAt</th><td>${view.startedAt !== void 0 ? escapeHtml(String(view.startedAt)) : "\u2014"}</td></tr>`
|
|
7541
7695
|
);
|
|
7542
7696
|
summaryRows.push(
|
|
7543
|
-
`<tr><th scope="row">endedAt</th><td>${
|
|
7697
|
+
`<tr><th scope="row">endedAt</th><td>${view.endedAt !== void 0 ? escapeHtml(String(view.endedAt)) : "\u2014"}</td></tr>`
|
|
7544
7698
|
);
|
|
7545
7699
|
summaryRows.push(
|
|
7546
|
-
`<tr><th scope="row">totalEvents</th><td>${escapeHtml(String(
|
|
7700
|
+
`<tr><th scope="row">totalEvents</th><td>${escapeHtml(String(view.metadata.totalEvents))}</td></tr>`
|
|
7547
7701
|
);
|
|
7548
7702
|
let confidenceHtml = "";
|
|
7549
7703
|
if (includeMetadata) {
|
|
7550
|
-
const cb =
|
|
7704
|
+
const cb = view.metadata.confidenceBreakdown;
|
|
7551
7705
|
confidenceHtml += "<h3>Confidence breakdown</h3><table><thead><tr><th>bucket</th><th>count</th></tr></thead><tbody>";
|
|
7552
7706
|
for (const k of Object.keys(cb).sort()) {
|
|
7553
7707
|
const key = k;
|
|
@@ -7555,14 +7709,14 @@ function exportHtml(tree, options) {
|
|
|
7555
7709
|
}
|
|
7556
7710
|
confidenceHtml += "</tbody></table>";
|
|
7557
7711
|
confidenceHtml += "<h3>Kind breakdown</h3><table><thead><tr><th>kind</th><th>count</th></tr></thead><tbody>";
|
|
7558
|
-
for (const k of Object.keys(
|
|
7712
|
+
for (const k of Object.keys(view.metadata.kinds).sort()) {
|
|
7559
7713
|
const key = k;
|
|
7560
|
-
const c =
|
|
7714
|
+
const c = view.metadata.kinds[key];
|
|
7561
7715
|
if (c > 0) confidenceHtml += `<tr><td>${escapeHtml(key)}</td><td>${c}</td></tr>`;
|
|
7562
7716
|
}
|
|
7563
7717
|
confidenceHtml += "</tbody></table>";
|
|
7564
7718
|
}
|
|
7565
|
-
const flat = flattenTree(
|
|
7719
|
+
const flat = flattenTree(view);
|
|
7566
7720
|
const errors = flat.filter((n) => n.event.status === "error");
|
|
7567
7721
|
let errorsHtml = "";
|
|
7568
7722
|
if (includeErrors && errors.length > 0) {
|
|
@@ -7617,7 +7771,7 @@ footer{margin-top:2rem;font-size:0.85rem;color:#555}
|
|
|
7617
7771
|
<header><h1>AgentInspect Run: ${titleName}</h1></header>
|
|
7618
7772
|
<p class="note">Generated locally by AgentInspect.</p>
|
|
7619
7773
|
${includeMetadata ? `<section class="summary"><h2>Summary</h2><table>${summaryRows.join("")}</table>${confidenceHtml}</section>` : ""}
|
|
7620
|
-
<section class="tree"><h2>Execution tree</h2>${
|
|
7774
|
+
<section class="tree"><h2>Execution tree</h2>${view.children.length > 0 ? renderTreeHtml(view.children) : "<p>No steps recorded.</p>"}</section>
|
|
7621
7775
|
${errorsHtml}
|
|
7622
7776
|
${attrsHtml}
|
|
7623
7777
|
<footer>Generated locally by AgentInspect. Review for sensitive data before sharing.</footer>
|
|
@@ -7658,7 +7812,8 @@ function exportMarkdown(tree, options) {
|
|
|
7658
7812
|
const includeErrors = options?.includeErrors ?? true;
|
|
7659
7813
|
const maxLen = options?.maxAttributeLength ?? 500;
|
|
7660
7814
|
const redacted = options?.redacted ?? true;
|
|
7661
|
-
const
|
|
7815
|
+
const view = presentLifecycleJoinedTree(tree);
|
|
7816
|
+
const titleName = view.name ?? view.runId;
|
|
7662
7817
|
const lines = [];
|
|
7663
7818
|
lines.push(`# AgentInspect Run: ${escapeMarkdown(titleName)}`);
|
|
7664
7819
|
lines.push("");
|
|
@@ -7667,28 +7822,28 @@ function exportMarkdown(tree, options) {
|
|
|
7667
7822
|
if (includeMetadata) {
|
|
7668
7823
|
lines.push("## Summary");
|
|
7669
7824
|
lines.push("");
|
|
7670
|
-
lines.push(`- **runId**: ${escapeMarkdown(
|
|
7671
|
-
if (
|
|
7672
|
-
lines.push(`- **status**: ${escapeMarkdown(String(
|
|
7825
|
+
lines.push(`- **runId**: ${escapeMarkdown(view.runId)}`);
|
|
7826
|
+
if (view.name !== void 0) lines.push(`- **name**: ${escapeMarkdown(view.name)}`);
|
|
7827
|
+
lines.push(`- **status**: ${escapeMarkdown(String(view.status ?? "unknown"))}`);
|
|
7673
7828
|
lines.push(
|
|
7674
|
-
`- **durationMs**: ${
|
|
7829
|
+
`- **durationMs**: ${view.durationMs !== void 0 ? escapeMarkdown(String(view.durationMs)) : "-"}`
|
|
7675
7830
|
);
|
|
7676
7831
|
lines.push(
|
|
7677
|
-
`- **startedAt**: ${
|
|
7832
|
+
`- **startedAt**: ${view.startedAt !== void 0 ? escapeMarkdown(String(view.startedAt)) : "-"}`
|
|
7678
7833
|
);
|
|
7679
7834
|
lines.push(
|
|
7680
|
-
`- **endedAt**: ${
|
|
7835
|
+
`- **endedAt**: ${view.endedAt !== void 0 ? escapeMarkdown(String(view.endedAt)) : "-"}`
|
|
7681
7836
|
);
|
|
7682
|
-
lines.push(`- **totalEvents**: ${
|
|
7837
|
+
lines.push(`- **totalEvents**: ${view.metadata.totalEvents}`);
|
|
7683
7838
|
lines.push("");
|
|
7684
7839
|
lines.push("### Confidence breakdown");
|
|
7685
7840
|
lines.push("");
|
|
7686
7841
|
lines.push("| bucket | count |");
|
|
7687
7842
|
lines.push("| --- | --- |");
|
|
7688
|
-
for (const k of Object.keys(
|
|
7843
|
+
for (const k of Object.keys(view.metadata.confidenceBreakdown).sort()) {
|
|
7689
7844
|
const key = k;
|
|
7690
7845
|
lines.push(
|
|
7691
|
-
`| ${escapeMarkdown(key)} | ${
|
|
7846
|
+
`| ${escapeMarkdown(key)} | ${view.metadata.confidenceBreakdown[key]} |`
|
|
7692
7847
|
);
|
|
7693
7848
|
}
|
|
7694
7849
|
lines.push("");
|
|
@@ -7696,9 +7851,9 @@ function exportMarkdown(tree, options) {
|
|
|
7696
7851
|
lines.push("");
|
|
7697
7852
|
lines.push("| kind | count |");
|
|
7698
7853
|
lines.push("| --- | --- |");
|
|
7699
|
-
for (const k of Object.keys(
|
|
7854
|
+
for (const k of Object.keys(view.metadata.kinds).sort()) {
|
|
7700
7855
|
const key = k;
|
|
7701
|
-
const c =
|
|
7856
|
+
const c = view.metadata.kinds[key];
|
|
7702
7857
|
if (c > 0) lines.push(`| ${escapeMarkdown(key)} | ${c} |`);
|
|
7703
7858
|
}
|
|
7704
7859
|
lines.push("");
|
|
@@ -7707,11 +7862,11 @@ function exportMarkdown(tree, options) {
|
|
|
7707
7862
|
lines.push("");
|
|
7708
7863
|
lines.push("```text");
|
|
7709
7864
|
lines.push(
|
|
7710
|
-
|
|
7865
|
+
view.children.length > 0 ? renderTreeAscii(view.children) : "(no steps)"
|
|
7711
7866
|
);
|
|
7712
7867
|
lines.push("```");
|
|
7713
7868
|
lines.push("");
|
|
7714
|
-
const flat = flattenTree(
|
|
7869
|
+
const flat = flattenTree(view);
|
|
7715
7870
|
const errors = flat.filter((n) => n.event.status === "error");
|
|
7716
7871
|
if (includeErrors && errors.length > 0) {
|
|
7717
7872
|
lines.push("## Errors");
|
|
@@ -9817,5 +9972,5 @@ async function runReadOnlyMcpServer(options = {}) {
|
|
|
9817
9972
|
}
|
|
9818
9973
|
|
|
9819
9974
|
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-
|
|
9821
|
-
//# sourceMappingURL=chunk-
|
|
9975
|
+
//# sourceMappingURL=chunk-W5KI3MNP.mjs.map
|
|
9976
|
+
//# sourceMappingURL=chunk-W5KI3MNP.mjs.map
|