agentfootprint-lens 0.1.0 → 0.2.0
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/index.cjs +234 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +122 -1
- package/dist/index.d.ts +122 -1
- package/dist/index.js +231 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,11 +22,13 @@ var src_exports = {};
|
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
AgentLens: () => AgentLens,
|
|
24
24
|
IterationStrip: () => IterationStrip,
|
|
25
|
+
LiveTimelineBuilder: () => LiveTimelineBuilder,
|
|
25
26
|
MessagesPanel: () => MessagesPanel,
|
|
26
27
|
ToolCallInspector: () => ToolCallInspector,
|
|
27
28
|
fromAgentSnapshot: () => fromAgentSnapshot,
|
|
28
29
|
resolveLensTheme: () => resolve,
|
|
29
|
-
useLensTheme: () => useLensTheme
|
|
30
|
+
useLensTheme: () => useLensTheme,
|
|
31
|
+
useLiveTimeline: () => useLiveTimeline
|
|
30
32
|
});
|
|
31
33
|
module.exports = __toCommonJS(src_exports);
|
|
32
34
|
|
|
@@ -921,14 +923,244 @@ function AgentLens({
|
|
|
921
923
|
}
|
|
922
924
|
);
|
|
923
925
|
}
|
|
926
|
+
|
|
927
|
+
// src/adapters/LiveTimelineBuilder.ts
|
|
928
|
+
var LiveTimelineBuilder = class {
|
|
929
|
+
constructor() {
|
|
930
|
+
this.turns = [];
|
|
931
|
+
this.currentTurn = null;
|
|
932
|
+
this.currentIter = null;
|
|
933
|
+
this.toolByCallId = /* @__PURE__ */ new Map();
|
|
934
|
+
this.messages = [];
|
|
935
|
+
this.finalDecision = {};
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Begin a new turn. Call this BEFORE `agent.run(userPrompt)` so the
|
|
939
|
+
* user's prompt appears alongside the iterations it produced. Safe to
|
|
940
|
+
* call even mid-conversation — it closes the previous turn cleanly.
|
|
941
|
+
*/
|
|
942
|
+
startTurn(userPrompt) {
|
|
943
|
+
if (this.currentTurn) this.commitCurrentTurn();
|
|
944
|
+
this.currentTurn = {
|
|
945
|
+
index: this.turns.length,
|
|
946
|
+
userPrompt,
|
|
947
|
+
iterations: [],
|
|
948
|
+
finalContent: "",
|
|
949
|
+
totalInputTokens: 0,
|
|
950
|
+
totalOutputTokens: 0,
|
|
951
|
+
totalDurationMs: 0,
|
|
952
|
+
startMs: Date.now()
|
|
953
|
+
};
|
|
954
|
+
this.messages.push({ role: "user", content: userPrompt });
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Optional — attach the system prompt so MessagesPanel can render it
|
|
958
|
+
* in the collapsible preamble. Usually set once at agent construction.
|
|
959
|
+
*/
|
|
960
|
+
setSystemPrompt(prompt) {
|
|
961
|
+
this.systemPrompt = prompt;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Feed one agent stream event. Safe to call for unknown events; we
|
|
965
|
+
* ignore anything we don't recognize.
|
|
966
|
+
*/
|
|
967
|
+
ingest(event) {
|
|
968
|
+
const e = event;
|
|
969
|
+
if (!e || typeof e.type !== "string") return;
|
|
970
|
+
switch (e.type) {
|
|
971
|
+
case "llm_start":
|
|
972
|
+
case "agentfootprint.stream.llm_start":
|
|
973
|
+
this.onLLMStart(e);
|
|
974
|
+
return;
|
|
975
|
+
case "llm_end":
|
|
976
|
+
case "agentfootprint.stream.llm_end":
|
|
977
|
+
this.onLLMEnd(e);
|
|
978
|
+
return;
|
|
979
|
+
case "tool_start":
|
|
980
|
+
case "agentfootprint.stream.tool_start":
|
|
981
|
+
this.onToolStart(e);
|
|
982
|
+
return;
|
|
983
|
+
case "tool_end":
|
|
984
|
+
case "agentfootprint.stream.tool_end":
|
|
985
|
+
this.onToolEnd(e);
|
|
986
|
+
return;
|
|
987
|
+
case "turn_end":
|
|
988
|
+
case "agentfootprint.agent.turn_complete":
|
|
989
|
+
this.commitCurrentTurn();
|
|
990
|
+
return;
|
|
991
|
+
default:
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
onLLMStart(e) {
|
|
996
|
+
if (!this.currentTurn) return;
|
|
997
|
+
const iterNum = e.iteration ?? this.currentTurn.iterations.length + 1;
|
|
998
|
+
this.currentIter = {
|
|
999
|
+
index: iterNum,
|
|
1000
|
+
assistantContent: "",
|
|
1001
|
+
toolCalls: [],
|
|
1002
|
+
decisionAtStart: {},
|
|
1003
|
+
visibleTools: [],
|
|
1004
|
+
startMs: Date.now()
|
|
1005
|
+
};
|
|
1006
|
+
this.currentTurn.iterations.push(this.currentIter);
|
|
1007
|
+
}
|
|
1008
|
+
onLLMEnd(e) {
|
|
1009
|
+
if (!this.currentIter || !this.currentTurn) return;
|
|
1010
|
+
this.currentIter.assistantContent = e.content ?? this.currentIter.assistantContent;
|
|
1011
|
+
if (e.model) this.currentIter.model = e.model;
|
|
1012
|
+
if (e.usage?.inputTokens !== void 0) this.currentIter.inputTokens = e.usage.inputTokens;
|
|
1013
|
+
if (e.usage?.outputTokens !== void 0) this.currentIter.outputTokens = e.usage.outputTokens;
|
|
1014
|
+
if (e.stopReason) this.currentIter.stopReason = e.stopReason;
|
|
1015
|
+
this.currentIter.durationMs = e.durationMs ?? Date.now() - this.currentIter.startMs;
|
|
1016
|
+
this.currentTurn.totalInputTokens += this.currentIter.inputTokens ?? 0;
|
|
1017
|
+
this.currentTurn.totalOutputTokens += this.currentIter.outputTokens ?? 0;
|
|
1018
|
+
this.currentTurn.totalDurationMs += this.currentIter.durationMs ?? 0;
|
|
1019
|
+
if (this.currentIter.assistantContent) {
|
|
1020
|
+
this.messages.push({ role: "assistant", content: this.currentIter.assistantContent });
|
|
1021
|
+
}
|
|
1022
|
+
if ((e.toolCallCount ?? 0) === 0) {
|
|
1023
|
+
this.currentTurn.finalContent = this.currentIter.assistantContent;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
onToolStart(e) {
|
|
1027
|
+
if (!this.currentIter || !this.currentTurn) return;
|
|
1028
|
+
const tool = {
|
|
1029
|
+
id: e.toolCallId ?? `tool-${this.currentIter.toolCalls.length}`,
|
|
1030
|
+
name: e.toolName ?? "unknown",
|
|
1031
|
+
arguments: e.args ?? {},
|
|
1032
|
+
result: "",
|
|
1033
|
+
iterationIndex: this.currentIter.index,
|
|
1034
|
+
turnIndex: this.currentTurn.index,
|
|
1035
|
+
startMs: Date.now()
|
|
1036
|
+
};
|
|
1037
|
+
this.currentIter.toolCalls.push(tool);
|
|
1038
|
+
this.toolByCallId.set(tool.id, tool);
|
|
1039
|
+
}
|
|
1040
|
+
onToolEnd(e) {
|
|
1041
|
+
const tool = this.toolByCallId.get(e.toolCallId ?? "");
|
|
1042
|
+
if (!tool) return;
|
|
1043
|
+
const r = e.result;
|
|
1044
|
+
if (typeof r === "string") {
|
|
1045
|
+
tool.result = r;
|
|
1046
|
+
} else if (r && typeof r === "object") {
|
|
1047
|
+
tool.result = r.content ?? "";
|
|
1048
|
+
if (r.error === true) tool.error = true;
|
|
1049
|
+
}
|
|
1050
|
+
tool.durationMs = e.durationMs ?? Date.now() - tool.startMs;
|
|
1051
|
+
this.messages.push({ role: "tool", content: tool.result, toolCallId: tool.id });
|
|
1052
|
+
}
|
|
1053
|
+
commitCurrentTurn() {
|
|
1054
|
+
if (!this.currentTurn) return;
|
|
1055
|
+
this.turns.push(this.currentTurn);
|
|
1056
|
+
this.currentTurn = null;
|
|
1057
|
+
this.currentIter = null;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Snapshot the current state as an immutable `AgentTimeline`. Safe to
|
|
1061
|
+
* call at any point — mid-run gives you the partial state so Lens can
|
|
1062
|
+
* live-update.
|
|
1063
|
+
*/
|
|
1064
|
+
getTimeline() {
|
|
1065
|
+
const allTurns = [...this.turns];
|
|
1066
|
+
if (this.currentTurn) allTurns.push(this.currentTurn);
|
|
1067
|
+
const tools = [];
|
|
1068
|
+
const frozenTurns = allTurns.map((t) => {
|
|
1069
|
+
const iterations = t.iterations.map((i) => {
|
|
1070
|
+
const tcs = i.toolCalls.map((tc) => ({ ...tc }));
|
|
1071
|
+
tools.push(...tcs);
|
|
1072
|
+
return { ...i, toolCalls: tcs };
|
|
1073
|
+
});
|
|
1074
|
+
return { ...t, iterations };
|
|
1075
|
+
});
|
|
1076
|
+
return {
|
|
1077
|
+
turns: frozenTurns,
|
|
1078
|
+
messages: [...this.messages],
|
|
1079
|
+
tools,
|
|
1080
|
+
finalDecision: { ...this.finalDecision },
|
|
1081
|
+
rawSnapshot: null
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Fold in a final `decision` scope after the run — useful when
|
|
1086
|
+
* the consumer wants the Decision Ribbon (phase-2) to reflect the
|
|
1087
|
+
* post-run state. Safe no-op during the run itself.
|
|
1088
|
+
*/
|
|
1089
|
+
setFinalDecision(decision) {
|
|
1090
|
+
this.finalDecision = decision;
|
|
1091
|
+
}
|
|
1092
|
+
/** Get the optional system prompt for the Messages preamble. */
|
|
1093
|
+
getSystemPrompt() {
|
|
1094
|
+
return this.systemPrompt;
|
|
1095
|
+
}
|
|
1096
|
+
/** Wipe state. Useful when the consumer starts a fresh conversation. */
|
|
1097
|
+
reset() {
|
|
1098
|
+
this.turns = [];
|
|
1099
|
+
this.currentTurn = null;
|
|
1100
|
+
this.currentIter = null;
|
|
1101
|
+
this.toolByCallId.clear();
|
|
1102
|
+
this.messages = [];
|
|
1103
|
+
this.finalDecision = {};
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
// src/adapters/useLiveTimeline.ts
|
|
1108
|
+
var import_react3 = require("react");
|
|
1109
|
+
function useLiveTimeline() {
|
|
1110
|
+
const builderRef = (0, import_react3.useRef)(null);
|
|
1111
|
+
if (!builderRef.current) builderRef.current = new LiveTimelineBuilder();
|
|
1112
|
+
const builder = builderRef.current;
|
|
1113
|
+
const [timeline, setTimeline] = (0, import_react3.useState)(() => builder.getTimeline());
|
|
1114
|
+
const sync = (0, import_react3.useCallback)(() => {
|
|
1115
|
+
setTimeline(builder.getTimeline());
|
|
1116
|
+
}, [builder]);
|
|
1117
|
+
const ingest = (0, import_react3.useCallback)(
|
|
1118
|
+
(event) => {
|
|
1119
|
+
builder.ingest(event);
|
|
1120
|
+
sync();
|
|
1121
|
+
},
|
|
1122
|
+
[builder, sync]
|
|
1123
|
+
);
|
|
1124
|
+
const startTurn = (0, import_react3.useCallback)(
|
|
1125
|
+
(userPrompt) => {
|
|
1126
|
+
builder.startTurn(userPrompt);
|
|
1127
|
+
sync();
|
|
1128
|
+
},
|
|
1129
|
+
[builder, sync]
|
|
1130
|
+
);
|
|
1131
|
+
const setSystemPrompt = (0, import_react3.useCallback)(
|
|
1132
|
+
(prompt) => {
|
|
1133
|
+
builder.setSystemPrompt(prompt);
|
|
1134
|
+
sync();
|
|
1135
|
+
},
|
|
1136
|
+
[builder, sync]
|
|
1137
|
+
);
|
|
1138
|
+
const setFinalDecision = (0, import_react3.useCallback)(
|
|
1139
|
+
(decision) => {
|
|
1140
|
+
builder.setFinalDecision(decision);
|
|
1141
|
+
sync();
|
|
1142
|
+
},
|
|
1143
|
+
[builder, sync]
|
|
1144
|
+
);
|
|
1145
|
+
const reset = (0, import_react3.useCallback)(() => {
|
|
1146
|
+
builder.reset();
|
|
1147
|
+
sync();
|
|
1148
|
+
}, [builder, sync]);
|
|
1149
|
+
return (0, import_react3.useMemo)(
|
|
1150
|
+
() => ({ timeline, ingest, startTurn, setSystemPrompt, setFinalDecision, reset, builder }),
|
|
1151
|
+
[timeline, ingest, startTurn, setSystemPrompt, setFinalDecision, reset, builder]
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
924
1154
|
// Annotate the CommonJS export names for ESM import in node:
|
|
925
1155
|
0 && (module.exports = {
|
|
926
1156
|
AgentLens,
|
|
927
1157
|
IterationStrip,
|
|
1158
|
+
LiveTimelineBuilder,
|
|
928
1159
|
MessagesPanel,
|
|
929
1160
|
ToolCallInspector,
|
|
930
1161
|
fromAgentSnapshot,
|
|
931
1162
|
resolveLensTheme,
|
|
932
|
-
useLensTheme
|
|
1163
|
+
useLensTheme,
|
|
1164
|
+
useLiveTimeline
|
|
933
1165
|
});
|
|
934
1166
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/AgentLens.tsx","../src/adapters/fromAgentSnapshot.ts","../src/panels/MessagesPanel.tsx","../src/theme/useLensTheme.ts","../src/panels/IterationStrip.tsx","../src/panels/ToolCallInspector.tsx"],"sourcesContent":["/**\n * agentfootprint-lens — public entry.\n *\n * See through your agent's decisions: messages, prompts, tool calls,\n * decision scope, cost — all in one timeline.\n */\n\n// Top-level shell — the 99% consumer entry point.\nexport { AgentLens } from \"./AgentLens\";\nexport type { AgentLensProps } from \"./AgentLens\";\n\n// Individual panels — for consumers who want to compose their own layout.\nexport { MessagesPanel } from \"./panels/MessagesPanel\";\nexport type { MessagesPanelProps } from \"./panels/MessagesPanel\";\nexport { IterationStrip } from \"./panels/IterationStrip\";\nexport type { IterationStripProps } from \"./panels/IterationStrip\";\nexport { ToolCallInspector } from \"./panels/ToolCallInspector\";\nexport type { ToolCallInspectorProps } from \"./panels/ToolCallInspector\";\n\n// Adapter — for consumers who want to transform snapshots upstream (e.g.\n// memoize across renders or feed multiple Lens instances from one run).\nexport { fromAgentSnapshot } from \"./adapters/fromAgentSnapshot\";\nexport type {\n AgentTimeline,\n AgentTurn,\n AgentIteration,\n AgentMessage,\n AgentToolInvocation,\n AgentToolCallStub,\n} from \"./adapters/types\";\n\n// Theme — the resolved palette the panels render against.\n// Consumers shouldn't need to use this directly; it's available for\n// custom panel authors who want to match the Lens look.\nexport { useLensTheme, resolve as resolveLensTheme } from \"./theme/useLensTheme\";\nexport type { LensTheme } from \"./theme/useLensTheme\";\n","/**\n * <AgentLens> — top-level shell.\n *\n * Composes the three v0.1 surfaces: IterationStrip (top), MessagesPanel\n * (center, primary), ToolCallInspector (right sidebar). Selection state\n * is internal; parent apps can hook into `onToolCallClick` to drive\n * external drill-downs (e.g. open a footprint-explainable-ui drawer\n * scoped to the tool's flowchart execution).\n *\n * ─────────────────────────────────────────────────────────────────────────\n * Usage (zero-boilerplate):\n *\n * import { AgentLens } from 'agentfootprint-lens';\n * import { FootprintTheme, coolDark, coolLight } from 'footprint-explainable-ui';\n *\n * <FootprintTheme tokens={dark ? coolDark : coolLight}>\n * <AgentLens runtimeSnapshot={agent.getSnapshot()} />\n * </FootprintTheme>\n *\n * No Lens-specific theme prop — tokens flow from the standard\n * FootprintTheme context. The drill-in drawer (explainable-ui) reads\n * the same context, so chat + trace stay in sync when the consumer\n * flips themes.\n * ─────────────────────────────────────────────────────────────────────────\n */\nimport { useMemo, useState } from \"react\";\nimport { fromAgentSnapshot } from \"./adapters/fromAgentSnapshot\";\nimport type {\n AgentToolInvocation,\n AgentTimeline,\n} from \"./adapters/types\";\nimport { MessagesPanel } from \"./panels/MessagesPanel\";\nimport { IterationStrip } from \"./panels/IterationStrip\";\nimport { ToolCallInspector } from \"./panels/ToolCallInspector\";\nimport { useLensTheme } from \"./theme/useLensTheme\";\n\nexport interface AgentLensProps {\n /**\n * Raw runtimeSnapshot from `agent.getSnapshot()`. Lens parses this\n * into an agent-shaped AgentTimeline internally. Pass `null` when a\n * run hasn't happened yet — Lens renders an empty state.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly runtimeSnapshot?: any | null;\n /**\n * Pre-parsed timeline, for callers who want to run the adapter once\n * upstream and share the result. Overrides `runtimeSnapshot` when set.\n */\n readonly timeline?: AgentTimeline;\n /**\n * Optional system prompt to render in the collapsible preamble of\n * MessagesPanel. Usually `runtimeSnapshot.sharedState.systemPrompt`\n * or the agent's configured base prompt.\n */\n readonly systemPrompt?: string;\n /**\n * Called when the user clicks a tool call in either the Inspector or\n * the inline Messages tool-call card. Parent can use this to open a\n * drawer rendering `<ExplainableShell>` from footprint-explainable-ui\n * scoped to that tool's internal flowchart execution — the\n * composition seam between Lens (agent view) and explainable-ui\n * (tool-internal view).\n */\n readonly onToolCallClick?: (invocation: AgentToolInvocation) => void;\n}\n\nexport function AgentLens({\n runtimeSnapshot,\n timeline: providedTimeline,\n systemPrompt,\n onToolCallClick,\n}: AgentLensProps) {\n const t = useLensTheme();\n const timeline = useMemo<AgentTimeline | null>(() => {\n if (providedTimeline) return providedTimeline;\n if (!runtimeSnapshot) return null;\n return fromAgentSnapshot(runtimeSnapshot);\n }, [providedTimeline, runtimeSnapshot]);\n\n const [selectedToolId, setSelectedToolId] = useState<string | null>(null);\n const [selectedIterKey, setSelectedIterKey] = useState<string | null>(null);\n\n function handleToolClick(inv: AgentToolInvocation) {\n setSelectedToolId(inv.id);\n setSelectedIterKey(`${inv.turnIndex}.${inv.iterationIndex}`);\n onToolCallClick?.(inv);\n }\n\n if (!timeline) {\n return (\n <div\n data-fp-lens=\"empty\"\n style={{\n padding: 32,\n color: t.textMuted,\n fontFamily: t.fontSans,\n textAlign: \"center\",\n background: t.bg,\n }}\n >\n No agent run to show yet. Pass <code>runtimeSnapshot</code> after the agent runs.\n </div>\n );\n }\n\n const derivedSystemPrompt =\n systemPrompt ??\n (typeof timeline.rawSnapshot?.sharedState?.systemPrompt === \"string\"\n ? (timeline.rawSnapshot.sharedState.systemPrompt as string)\n : undefined);\n\n return (\n <div\n data-fp-lens=\"shell\"\n style={{\n display: \"grid\",\n gridTemplateColumns: \"1fr 320px\",\n gridTemplateRows: \"auto 1fr\",\n gridTemplateAreas: '\"strip strip\" \"messages inspector\"',\n height: \"100%\",\n minHeight: 0,\n background: t.bg,\n color: t.text,\n fontFamily: t.fontSans,\n }}\n >\n <div style={{ gridArea: \"strip\" }}>\n <IterationStrip\n timeline={timeline}\n selectedKey={selectedIterKey}\n onSelect={setSelectedIterKey}\n />\n </div>\n <div style={{ gridArea: \"messages\", minHeight: 0, overflow: \"hidden\" }}>\n <MessagesPanel\n timeline={timeline}\n onToolCallClick={handleToolClick}\n {...(derivedSystemPrompt && { systemPrompt: derivedSystemPrompt })}\n />\n </div>\n <div\n style={{\n gridArea: \"inspector\",\n minHeight: 0,\n overflow: \"hidden\",\n borderLeft: `1px solid ${t.border}`,\n }}\n >\n <ToolCallInspector\n timeline={timeline}\n selectedId={selectedToolId}\n onSelect={handleToolClick}\n />\n </div>\n </div>\n );\n}\n","/**\n * fromAgentSnapshot — turn an agentfootprint runtimeSnapshot into the\n * agent-shaped AgentTimeline Lens renders against.\n *\n * ─────────────────────────────────────────────────────────────────────────\n * The raw snapshot is flowchart-shaped (stages, commitLog, subflowResults).\n * Lens needs agent-shape: turns[] → iterations[] → {messages, toolCalls,\n * decision, tokens, latency, visibleTools}. That's what this file does.\n *\n * Derivation strategy (all sources already present — no library change\n * needed):\n * • `sharedState.messages[]` — canonical conversation\n * • `commitLog` entries for `call-llm` / `streaming-call-llm` — per-iter\n * LLM request+response (model, tokens, duration, stop reason)\n * • `commitLog` entries for `execute-tool-calls` — per-iter tool outputs\n * and decision updates\n * • `sf-instructions-to-llm` snapshots — matched instruction ids +\n * injection counts per iter\n * • `sf-tools` snapshots — tool list visible to the LLM that iter\n *\n * Turn boundaries are inferred by walking `messages[]` and grouping\n * everything between user messages into one turn. Iteration boundaries\n * are the LLM call events within a turn.\n * ─────────────────────────────────────────────────────────────────────────\n */\n\nimport type {\n AgentIteration,\n AgentMessage,\n AgentTimeline,\n AgentToolInvocation,\n AgentTurn,\n} from \"./types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnySnapshot = any;\n\nexport function fromAgentSnapshot(runtime: AnySnapshot): AgentTimeline {\n const shared = runtime?.sharedState ?? {};\n const rawMessages: RawMessage[] = shared.messages ?? [];\n const messages = rawMessages.map(normalizeMessage);\n\n const commitLog = Array.isArray(runtime?.commitLog) ? runtime.commitLog : [];\n const llmCalls = extractLLMCalls(commitLog);\n const toolExecs = extractToolExecutions(commitLog);\n const instructionEvals = extractInstructionEvals(commitLog);\n const toolResolves = extractToolResolves(commitLog);\n\n const turns = assembleTurns(messages, llmCalls, toolExecs, instructionEvals, toolResolves);\n const allTools = turns.flatMap((t) => t.iterations.flatMap((i) => i.toolCalls));\n\n return {\n turns,\n messages,\n tools: allTools,\n finalDecision: (shared.decision as Record<string, unknown>) ?? {},\n rawSnapshot: runtime,\n };\n}\n\n// ── Normalize ─────────────────────────────────────────────────────────\n\ninterface RawMessage {\n role: string;\n content: string | unknown;\n toolCalls?: Array<{ id: string; name: string; arguments: Record<string, unknown> }>;\n toolCallId?: string;\n}\n\nfunction normalizeMessage(m: RawMessage): AgentMessage {\n const role = ((): AgentMessage[\"role\"] => {\n if (m.role === \"system\" || m.role === \"user\" || m.role === \"assistant\" || m.role === \"tool\")\n return m.role;\n return \"user\";\n })();\n const content = typeof m.content === \"string\" ? m.content : JSON.stringify(m.content);\n return {\n role,\n content,\n ...(m.toolCalls?.length ? { toolCalls: m.toolCalls } : {}),\n ...(m.toolCallId ? { toolCallId: m.toolCallId } : {}),\n };\n}\n\n// ── Extract from commitLog ────────────────────────────────────────────\n\ninterface RawCommit {\n stageId?: string;\n stage?: string;\n runtimeStageId?: string;\n updates?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n trace?: any;\n}\n\ninterface LLMCall {\n iterationIndex: number;\n model?: string;\n inputTokens?: number;\n outputTokens?: number;\n durationMs?: number;\n stopReason?: string;\n assistantContent: string;\n toolCallsRequested: Array<{ id: string; name: string; arguments: Record<string, unknown> }>;\n}\n\nfunction extractLLMCalls(commitLog: RawCommit[]): LLMCall[] {\n const out: LLMCall[] = [];\n let iter = 0;\n for (const entry of commitLog) {\n const id = entry.stageId ?? \"\";\n if (id !== \"call-llm\" && id !== \"streaming-call-llm\") continue;\n iter++;\n const u = (entry.updates ?? {}) as Record<string, unknown>;\n const rawResponse =\n (u[\"adapterRawResponse\"] as Record<string, unknown> | undefined) ??\n (u[\"llmResponse\"] as Record<string, unknown> | undefined);\n const usage = rawResponse?.usage as\n | { inputTokens?: number; outputTokens?: number }\n | undefined;\n out.push({\n iterationIndex: iter,\n model: rawResponse?.model as string | undefined,\n inputTokens: usage?.inputTokens,\n outputTokens: usage?.outputTokens,\n durationMs: (u[\"callDurationMs\"] as number | undefined) ?? undefined,\n stopReason: rawResponse?.stopReason as string | undefined,\n assistantContent: (rawResponse?.content as string | undefined) ?? \"\",\n toolCallsRequested:\n (rawResponse?.toolCalls as LLMCall[\"toolCallsRequested\"] | undefined) ?? [],\n });\n }\n return out;\n}\n\ninterface ToolExec {\n iterationIndex: number;\n toolCalls: AgentToolInvocation[];\n}\n\nfunction extractToolExecutions(commitLog: RawCommit[]): ToolExec[] {\n const out: ToolExec[] = [];\n let iter = 0;\n for (const entry of commitLog) {\n const id = entry.stageId ?? \"\";\n if (id !== \"execute-tool-calls\") continue;\n iter++;\n const u = (entry.updates ?? {}) as Record<string, unknown>;\n // agentfootprint stores parsed tool calls + their results via\n // tool-start / tool-end emit events + the tool-role messages appended\n // to `messages`. Simplest stable derivation: walk messages right\n // after this commit and collect the tool-result entries.\n // For v0.1 we emit the tool call stubs; full resolution happens at\n // the assembler step where we have both sides in hand.\n const rawCalls = u[\"toolCalls\"] as LLMCall[\"toolCallsRequested\"] | undefined;\n const stubs: AgentToolInvocation[] = (rawCalls ?? []).map((c) => ({\n id: c.id,\n name: c.name,\n arguments: c.arguments ?? {},\n result: \"\", // filled in during assembly\n iterationIndex: iter,\n turnIndex: 0, // reassigned during assembly\n decisionUpdate: u[\"updatedDecision\"] as Record<string, unknown> | undefined,\n }));\n out.push({ iterationIndex: iter, toolCalls: stubs });\n }\n return out;\n}\n\ninterface InstructionEval {\n iterationIndex: number;\n matchedInstructions?: string[];\n promptInjectionCount: number;\n toolInjectionCount: number;\n}\n\nfunction extractInstructionEvals(commitLog: RawCommit[]): InstructionEval[] {\n const out: InstructionEval[] = [];\n let iter = 0;\n for (const entry of commitLog) {\n const id = entry.stageId ?? \"\";\n if (id !== \"evaluate-instructions\") continue;\n iter++;\n const u = (entry.updates ?? {}) as Record<string, unknown>;\n const matchedRaw = u[\"matchedInstructions\"];\n const matched = parseMatched(matchedRaw);\n const promptInj = Array.isArray(u[\"promptInjections\"]) ? u[\"promptInjections\"].length : 0;\n const toolInj = Array.isArray(u[\"toolInjections\"]) ? u[\"toolInjections\"].length : 0;\n out.push({\n iterationIndex: iter,\n ...(matched.length > 0 && { matchedInstructions: matched }),\n promptInjectionCount: promptInj,\n toolInjectionCount: toolInj,\n });\n }\n return out;\n}\n\nfunction parseMatched(v: unknown): string[] {\n if (!v) return [];\n if (Array.isArray(v)) return v.filter((x) => typeof x === \"string\");\n if (typeof v === \"string\") {\n // format: \"N matched: id1, id2, id3...\"\n const m = v.match(/:\\s*(.+)/);\n if (!m) return [];\n return m[1]\n .split(\",\")\n .map((s) => s.trim().replace(/\\.{3}$/, \"\"))\n .filter(Boolean);\n }\n return [];\n}\n\ninterface ToolResolve {\n iterationIndex: number;\n visibleTools: string[];\n}\n\nfunction extractToolResolves(commitLog: RawCommit[]): ToolResolve[] {\n const out: ToolResolve[] = [];\n let iter = 0;\n for (const entry of commitLog) {\n const id = entry.stageId ?? \"\";\n if (id !== \"resolve-tools\") continue;\n iter++;\n const u = (entry.updates ?? {}) as Record<string, unknown>;\n const descs = u[\"toolDescriptions\"] as Array<{ name: string }> | undefined;\n out.push({\n iterationIndex: iter,\n visibleTools: (descs ?? []).map((d) => d.name),\n });\n }\n return out;\n}\n\n// ── Assemble turns ────────────────────────────────────────────────────\n\nfunction assembleTurns(\n messages: AgentMessage[],\n llmCalls: LLMCall[],\n toolExecs: ToolExec[],\n instructionEvals: InstructionEval[],\n toolResolves: ToolResolve[],\n): AgentTurn[] {\n // Build a per-iteration map (flat across turns) then split by turn.\n // For a fresh agent instance, iter counts restart every turn — but\n // because commitLog is cumulative, iter numbers across commitLog are\n // monotonically increasing over the whole execution. So we group\n // iterations by the message boundary they fall in.\n //\n // Algorithm: walk messages in order. Each user message starts a new\n // turn. Each assistant message that has toolCalls (or is the final)\n // consumes the next LLM call from llmCalls. Tool-role messages that\n // follow bind to the most recent assistant message's toolCalls.\n\n const turns: AgentTurn[] = [];\n let currentTurn: {\n index: number;\n userPrompt: string;\n iterations: AgentIteration[];\n finalContent: string;\n } | null = null;\n let llmIdx = 0;\n const toolExecByIter = new Map(toolExecs.map((t) => [t.iterationIndex, t]));\n const instrByIter = new Map(instructionEvals.map((i) => [i.iterationIndex, i]));\n const visibleByIter = new Map(toolResolves.map((t) => [t.iterationIndex, t]));\n\n for (const msg of messages) {\n if (msg.role === \"user\") {\n if (currentTurn) turns.push(finalizeTurn(currentTurn));\n currentTurn = {\n index: turns.length,\n userPrompt: msg.content,\n iterations: [],\n finalContent: \"\",\n };\n continue;\n }\n if (!currentTurn) continue; // skip system prompt + anything before first user\n\n if (msg.role === \"assistant\") {\n const call = llmCalls[llmIdx];\n llmIdx++;\n const iterIndex = call?.iterationIndex ?? currentTurn.iterations.length + 1;\n const exec = toolExecByIter.get(iterIndex);\n const instr = instrByIter.get(iterIndex);\n const visible = visibleByIter.get(iterIndex);\n\n const toolCalls: AgentToolInvocation[] = (exec?.toolCalls ?? []).map((tc) => ({\n ...tc,\n turnIndex: currentTurn!.index,\n }));\n\n const iteration: AgentIteration = {\n index: iterIndex,\n ...(call?.model && { model: call.model }),\n ...(call?.inputTokens !== undefined && { inputTokens: call.inputTokens }),\n ...(call?.outputTokens !== undefined && { outputTokens: call.outputTokens }),\n ...(call?.durationMs !== undefined && { durationMs: call.durationMs }),\n ...(call?.stopReason && { stopReason: call.stopReason }),\n assistantContent: call?.assistantContent ?? msg.content,\n toolCalls,\n decisionAtStart: {}, // TODO(phase-2): derive from pre-iter commit\n ...(instr?.matchedInstructions && { matchedInstructions: instr.matchedInstructions }),\n visibleTools: visible?.visibleTools ?? [],\n };\n\n currentTurn.iterations.push(iteration);\n if (!toolCalls.length) currentTurn.finalContent = iteration.assistantContent;\n continue;\n }\n\n if (msg.role === \"tool\" && msg.toolCallId) {\n // Bind the result string back to the matching tool invocation in\n // the latest iteration.\n const iter = currentTurn.iterations[currentTurn.iterations.length - 1];\n if (!iter) continue;\n const idx = iter.toolCalls.findIndex((tc) => tc.id === msg.toolCallId);\n if (idx < 0) continue;\n const updated = { ...iter.toolCalls[idx], result: msg.content };\n // Rewrite via mutation — iter is readonly at the type level but we\n // own this intermediate structure during assembly.\n (iter.toolCalls as AgentToolInvocation[])[idx] = updated;\n }\n }\n\n if (currentTurn) turns.push(finalizeTurn(currentTurn));\n return turns;\n}\n\nfunction finalizeTurn(t: {\n index: number;\n userPrompt: string;\n iterations: AgentIteration[];\n finalContent: string;\n}): AgentTurn {\n const totalInputTokens = t.iterations.reduce((s, i) => s + (i.inputTokens ?? 0), 0);\n const totalOutputTokens = t.iterations.reduce((s, i) => s + (i.outputTokens ?? 0), 0);\n const totalDurationMs = t.iterations.reduce((s, i) => s + (i.durationMs ?? 0), 0);\n return {\n index: t.index,\n userPrompt: t.userPrompt,\n iterations: t.iterations,\n finalContent: t.finalContent,\n totalInputTokens,\n totalOutputTokens,\n totalDurationMs,\n };\n}\n","/**\n * MessagesPanel — the primary Lens surface. Chat-shaped view of an agent\n * run with turn boundaries, iteration markers, and expandable tool calls.\n *\n * Data comes from `fromAgentSnapshot(runtimeSnapshot).turns`. Each turn\n * is:\n * • one user message\n * • one or more assistant iterations (each may request N tool calls)\n * • tool role bubbles bound to their assistant parent\n * • final assistant bubble\n *\n * Theme is read via `useLensTheme()` which maps FootprintTheme tokens\n * into Lens's semantic palette. Consumers get free light/dark support\n * by wrapping their app in `<FootprintTheme tokens={coolLight|coolDark}>`\n * — no Lens-specific theme API to learn.\n */\nimport { useState } from \"react\";\nimport type {\n AgentIteration,\n AgentMessage,\n AgentTimeline,\n AgentToolInvocation,\n AgentTurn,\n} from \"../adapters/types\";\nimport { useLensTheme } from \"../theme/useLensTheme\";\n\nexport interface MessagesPanelProps {\n readonly timeline: AgentTimeline;\n /**\n * Called when the user clicks a tool-call card. Host app surfaces it\n * in the Tool Call Inspector. When omitted, clicking is a no-op.\n */\n readonly onToolCallClick?: (invocation: AgentToolInvocation) => void;\n /** Optional system-prompt text to render in the collapsible preamble. */\n readonly systemPrompt?: string;\n}\n\nexport function MessagesPanel({\n timeline,\n onToolCallClick,\n systemPrompt,\n}: MessagesPanelProps) {\n const t = useLensTheme();\n return (\n <div\n data-fp-lens=\"messages-panel\"\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: 16,\n padding: \"16px 24px\",\n background: t.bg,\n color: t.text,\n fontFamily: t.fontSans,\n fontSize: 14,\n lineHeight: 1.55,\n minHeight: 0,\n overflow: \"auto\",\n }}\n >\n {systemPrompt && <SystemBubble text={systemPrompt} />}\n {timeline.turns.map((turn) => (\n <TurnBlock key={turn.index} turn={turn} onToolCallClick={onToolCallClick} />\n ))}\n </div>\n );\n}\n\nfunction SystemBubble({ text }: { text: string }) {\n const t = useLensTheme();\n const [open, setOpen] = useState(false);\n const preview = text.slice(0, 140).replace(/\\s+/g, \" \") + (text.length > 140 ? \"…\" : \"\");\n return (\n <div\n style={{\n alignSelf: \"center\",\n width: \"100%\",\n maxWidth: 880,\n border: `1px dashed ${t.border}`,\n borderRadius: t.radius,\n padding: \"8px 12px\",\n background: t.bgElev,\n fontSize: 12,\n color: t.textMuted,\n }}\n >\n <button\n onClick={() => setOpen((v) => !v)}\n style={{\n background: \"transparent\",\n border: \"none\",\n color: t.textMuted,\n cursor: \"pointer\",\n padding: 0,\n font: \"inherit\",\n }}\n >\n <strong>SYSTEM</strong> {open ? \"▾\" : \"▸\"} {open ? \"\" : preview}\n </button>\n {open && (\n <pre\n style={{\n marginTop: 8,\n whiteSpace: \"pre-wrap\",\n fontFamily: t.fontMono,\n fontSize: 11,\n color: t.text,\n }}\n >\n {text}\n </pre>\n )}\n </div>\n );\n}\n\nfunction TurnBlock({\n turn,\n onToolCallClick,\n}: {\n turn: AgentTurn;\n onToolCallClick?: (inv: AgentToolInvocation) => void;\n}) {\n const t = useLensTheme();\n return (\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 12 }}>\n <TurnHeader turn={turn} />\n <UserBubble text={turn.userPrompt} />\n {turn.iterations.map((iter) => (\n <IterationBlock key={iter.index} iter={iter} onToolCallClick={onToolCallClick} />\n ))}\n {turn.finalContent && turn.iterations.length > 0 && (\n <div style={{ fontSize: 11, color: t.textSubtle, textAlign: \"center\" }}>\n turn {turn.index + 1} final · {turn.iterations.length} iter · {turn.totalInputTokens}→\n {turn.totalOutputTokens} tok · {(turn.totalDurationMs / 1000).toFixed(1)}s\n </div>\n )}\n </div>\n );\n}\n\nfunction TurnHeader({ turn }: { turn: AgentTurn }) {\n const t = useLensTheme();\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n color: t.textSubtle,\n fontSize: 11,\n textTransform: \"uppercase\",\n letterSpacing: \"0.08em\",\n fontWeight: 600,\n }}\n >\n <div style={{ flex: 1, height: 1, background: t.border }} />\n <span>Turn {turn.index + 1}</span>\n <div style={{ flex: 1, height: 1, background: t.border }} />\n </div>\n );\n}\n\nfunction UserBubble({ text }: { text: string }) {\n const t = useLensTheme();\n return (\n <div style={{ display: \"flex\", justifyContent: \"flex-end\" }}>\n <div\n style={{\n background: `color-mix(in srgb, ${t.accent} 18%, ${t.bgElev})`,\n border: `1px solid ${t.border}`,\n color: t.text,\n maxWidth: 720,\n padding: \"10px 14px\",\n borderRadius: `${t.radius} ${t.radius} 2px ${t.radius}`,\n whiteSpace: \"pre-wrap\",\n }}\n >\n {text}\n </div>\n </div>\n );\n}\n\nfunction IterationBlock({\n iter,\n onToolCallClick,\n}: {\n iter: AgentIteration;\n onToolCallClick?: (inv: AgentToolInvocation) => void;\n}) {\n const t = useLensTheme();\n return (\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6 }}>\n <IterationBadge iter={iter} />\n {iter.assistantContent && (\n <div\n style={{\n background: t.bgElev,\n border: `1px solid ${t.border}`,\n borderRadius: `2px ${t.radius} ${t.radius} ${t.radius}`,\n padding: \"10px 14px\",\n maxWidth: 820,\n whiteSpace: \"pre-wrap\",\n }}\n >\n {iter.assistantContent}\n </div>\n )}\n {iter.toolCalls.length > 0 && (\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6, paddingLeft: 12 }}>\n {iter.toolCalls.map((tc) => (\n <ToolCallCard key={tc.id} invocation={tc} onClick={onToolCallClick} />\n ))}\n </div>\n )}\n </div>\n );\n}\n\nfunction IterationBadge({ iter }: { iter: AgentIteration }) {\n const t = useLensTheme();\n const bits: string[] = [`iter ${iter.index}`];\n if (iter.model) bits.push(iter.model);\n if (iter.inputTokens !== undefined)\n bits.push(`${iter.inputTokens}→${iter.outputTokens ?? \"?\"} tok`);\n if (iter.durationMs !== undefined) bits.push(`${(iter.durationMs / 1000).toFixed(2)}s`);\n if (iter.stopReason) bits.push(iter.stopReason);\n return (\n <div\n style={{\n alignSelf: \"flex-start\",\n fontSize: 10,\n color: t.textSubtle,\n textTransform: \"uppercase\",\n letterSpacing: \"0.08em\",\n fontWeight: 600,\n fontFamily: t.fontMono,\n }}\n >\n {bits.join(\" · \")}\n </div>\n );\n}\n\nfunction ToolCallCard({\n invocation,\n onClick,\n}: {\n invocation: AgentToolInvocation;\n onClick?: (inv: AgentToolInvocation) => void;\n}) {\n const t = useLensTheme();\n const [open, setOpen] = useState(false);\n const preview = shortArgs(invocation.arguments);\n const errored = invocation.error === true;\n return (\n <div\n style={{\n border: `1px solid ${errored ? t.error : t.border}`,\n borderLeft: `3px solid ${errored ? t.error : t.accent}`,\n borderRadius: 6,\n background: t.bg,\n overflow: \"hidden\",\n }}\n >\n <div\n onClick={() => {\n setOpen((v) => !v);\n onClick?.(invocation);\n }}\n style={{\n padding: \"8px 12px\",\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n fontSize: 12,\n fontFamily: t.fontMono,\n }}\n >\n <span style={{ color: errored ? t.error : t.accent, fontWeight: 600 }}>\n {invocation.name}\n </span>\n <span style={{ color: t.textMuted }}>({preview})</span>\n <span style={{ flex: 1 }} />\n {invocation.decisionUpdate && Object.keys(invocation.decisionUpdate).length > 0 && (\n <span\n style={{\n fontSize: 10,\n padding: \"1px 6px\",\n borderRadius: 3,\n background: `color-mix(in srgb, ${t.warning} 20%, transparent)`,\n color: t.warning,\n fontFamily: t.fontSans,\n fontWeight: 600,\n textTransform: \"uppercase\",\n }}\n >\n decisionUpdate\n </span>\n )}\n <span style={{ color: t.textSubtle }}>{open ? \"▾\" : \"▸\"}</span>\n </div>\n {open && (\n <div style={{ padding: \"8px 12px\", borderTop: `1px solid ${t.border}` }}>\n <Label t={t}>args</Label>\n <JsonBlock value={invocation.arguments} />\n {invocation.result && (\n <>\n <Label t={t} style={{ marginTop: 10 }}>\n result\n </Label>\n <pre\n style={{\n margin: 0,\n padding: \"8px 10px\",\n background: t.bgElev,\n borderRadius: 4,\n fontSize: 11,\n fontFamily: t.fontMono,\n color: errored ? t.error : t.text,\n maxHeight: 280,\n overflow: \"auto\",\n whiteSpace: \"pre-wrap\",\n }}\n >\n {invocation.result}\n </pre>\n </>\n )}\n {invocation.decisionUpdate &&\n Object.keys(invocation.decisionUpdate).length > 0 && (\n <>\n <Label t={t} style={{ marginTop: 10 }}>\n decisionUpdate\n </Label>\n <JsonBlock value={invocation.decisionUpdate} />\n </>\n )}\n </div>\n )}\n </div>\n );\n}\n\nfunction Label({\n t,\n children,\n style,\n}: {\n t: ReturnType<typeof useLensTheme>;\n children: React.ReactNode;\n style?: React.CSSProperties;\n}) {\n return (\n <div\n style={{\n fontSize: 10,\n color: t.textSubtle,\n textTransform: \"uppercase\",\n letterSpacing: \"0.08em\",\n fontWeight: 600,\n marginBottom: 4,\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n\nfunction JsonBlock({ value }: { value: unknown }) {\n const t = useLensTheme();\n return (\n <pre\n style={{\n margin: 0,\n padding: \"8px 10px\",\n background: t.bgElev,\n borderRadius: 4,\n fontSize: 11,\n fontFamily: t.fontMono,\n color: t.text,\n maxHeight: 200,\n overflow: \"auto\",\n }}\n >\n {JSON.stringify(value, null, 2)}\n </pre>\n );\n}\n\nfunction shortArgs(args: Record<string, unknown>): string {\n const keys = Object.keys(args);\n if (keys.length === 0) return \"\";\n if (keys.length === 1) {\n const v = args[keys[0]];\n if (typeof v === \"string\" && v.length < 40) return `${keys[0]}: \"${v}\"`;\n }\n return keys.join(\", \");\n}\n\nexport { ToolCallCard };\n\nfunction _assertUnused(_: AgentMessage) {\n // Exported type is referenced from ./index.ts; keeping the import\n // for bundler tree-shaking consistency without introducing a new\n // linter warning on a \"used-elsewhere\" type import.\n void _;\n}\n_assertUnused;\n","/**\n * useLensTheme — single source of truth for Lens colors + sizing.\n *\n * ─────────────────────────────────────────────────────────────────────────\n * Theme pass-through contract (IMPORTANT for consumers):\n *\n * Lens does NOT invent its own theme system. It reads tokens from the\n * FootprintTheme context already defined in `footprint-explainable-ui`.\n * A consumer app that wraps its tree in:\n *\n * import { FootprintTheme, coolDark, coolLight } from 'footprint-explainable-ui';\n * <FootprintTheme tokens={theme === 'light' ? coolLight : coolDark}>\n * <AgentLens runtimeSnapshot={snap} />\n * </FootprintTheme>\n *\n * …gets both Lens AND the drill-down explainable-ui drawer themed from the\n * same token bag. No separate `theme` prop, no duplicate palette, no\n * drift between the two views when the user flips light/dark.\n *\n * If no FootprintTheme provider is mounted, Lens falls back to cool-dark\n * defaults — the same defaults explainable-ui uses, so it looks correct\n * out of the box without configuration.\n * ─────────────────────────────────────────────────────────────────────────\n */\nimport { useFootprintTheme, coolDark } from \"footprint-explainable-ui\";\nimport type { ThemeTokens } from \"footprint-explainable-ui\";\n\n/**\n * The resolved color palette + sizing tokens Lens renders against.\n * Always defined — callers never need to null-check.\n */\nexport interface LensTheme {\n readonly bg: string;\n readonly bgElev: string;\n readonly bgHover: string;\n readonly border: string;\n readonly borderStrong: string;\n readonly text: string;\n readonly textMuted: string;\n readonly textSubtle: string;\n readonly accent: string;\n readonly success: string;\n readonly warning: string;\n readonly error: string;\n readonly fontSans: string;\n readonly fontMono: string;\n readonly radius: string;\n}\n\n/**\n * Read tokens from FootprintTheme context (if present) and map them\n * into Lens's semantic palette. Missing tokens fall back to coolDark.\n */\nexport function useLensTheme(): LensTheme {\n const ctx = useFootprintTheme();\n return resolve(ctx);\n}\n\n/** Pure mapping — exported for unit tests + non-hook call sites. */\nexport function resolve(tokens: ThemeTokens | undefined): LensTheme {\n const t = tokens ?? {};\n const c = t.colors ?? coolDark.colors ?? {};\n const fallback = coolDark.colors ?? {};\n return {\n bg: c.bgPrimary ?? fallback.bgPrimary ?? \"#0f172a\",\n bgElev: c.bgSecondary ?? fallback.bgSecondary ?? \"#1e293b\",\n bgHover: c.bgTertiary ?? fallback.bgTertiary ?? \"#334155\",\n border: c.border ?? fallback.border ?? \"#334155\",\n borderStrong: c.bgTertiary ?? fallback.bgTertiary ?? \"#334155\",\n text: c.textPrimary ?? fallback.textPrimary ?? \"#f8fafc\",\n textMuted: c.textSecondary ?? fallback.textSecondary ?? \"#94a3b8\",\n textSubtle: c.textMuted ?? fallback.textMuted ?? \"#64748b\",\n accent: c.primary ?? fallback.primary ?? \"#6366f1\",\n success: c.success ?? fallback.success ?? \"#22c55e\",\n warning: c.warning ?? fallback.warning ?? \"#f59e0b\",\n error: c.error ?? fallback.error ?? \"#ef4444\",\n fontSans: t.fontFamily?.sans ?? coolDark.fontFamily?.sans ?? \"system-ui, sans-serif\",\n fontMono: t.fontFamily?.mono ?? coolDark.fontFamily?.mono ?? \"ui-monospace, monospace\",\n radius: t.radius ?? coolDark.radius ?? \"8px\",\n };\n}\n","/**\n * IterationStrip — horizontal ribbon of LLM calls across the run, one\n * chip per iteration. Click to scroll/pin MessagesPanel to that iter.\n *\n * v0.1 is display-only with the selection callback; parent app owns the\n * scroll behavior.\n */\nimport type { AgentTimeline } from \"../adapters/types\";\nimport { useLensTheme } from \"../theme/useLensTheme\";\n\nexport interface IterationStripProps {\n readonly timeline: AgentTimeline;\n readonly selectedKey?: string | null;\n readonly onSelect?: (key: string) => void;\n}\n\nexport function IterationStrip({ timeline, selectedKey, onSelect }: IterationStripProps) {\n const t = useLensTheme();\n const chips = timeline.turns.flatMap((turn) =>\n turn.iterations.map((iter) => ({\n key: `${turn.index}.${iter.index}`,\n turn: turn.index + 1,\n iter: iter.index,\n label: chipLabel(iter),\n tools: iter.toolCalls.length,\n durationMs: iter.durationMs ?? 0,\n stopReason: iter.stopReason,\n })),\n );\n\n return (\n <div\n data-fp-lens=\"iteration-strip\"\n style={{\n display: \"flex\",\n gap: 4,\n padding: \"8px 12px\",\n overflowX: \"auto\",\n borderBottom: `1px solid ${t.border}`,\n background: t.bgElev,\n }}\n >\n {chips.length === 0 && (\n <span style={{ color: t.textSubtle, fontSize: 11 }}>No iterations yet.</span>\n )}\n {chips.map((c) => {\n const active = c.key === selectedKey;\n const isFinal = c.stopReason === \"stop\" || c.stopReason === \"end_turn\";\n return (\n <button\n key={c.key}\n onClick={() => onSelect?.(c.key)}\n style={{\n background: active ? t.accent : \"transparent\",\n color: active ? \"#fff\" : t.textMuted,\n border: `1px solid ${active ? t.accent : t.border}`,\n borderRadius: 4,\n padding: \"4px 8px\",\n fontSize: 11,\n fontFamily: \"ui-monospace, monospace\",\n cursor: \"pointer\",\n whiteSpace: \"nowrap\",\n flexShrink: 0,\n }}\n title={`turn ${c.turn} · iter ${c.iter} · ${c.tools} tool call${\n c.tools === 1 ? \"\" : \"s\"\n }${c.stopReason ? ` · ${c.stopReason}` : \"\"}`}\n >\n t{c.turn}.i{c.iter} · {c.label} {isFinal ? \"✓\" : \"\"}\n </button>\n );\n })}\n </div>\n );\n}\n\nfunction chipLabel(iter: { toolCalls: readonly unknown[]; durationMs?: number }): string {\n const d = iter.durationMs ?? 0;\n const secs = d >= 1000 ? `${(d / 1000).toFixed(1)}s` : `${Math.round(d)}ms`;\n const toolBit = iter.toolCalls.length > 0 ? `${iter.toolCalls.length}t` : \"final\";\n return `${secs} · ${toolBit}`;\n}\n","/**\n * ToolCallInspector — flat sidebar list of every tool invocation in the\n * run. Primary workflow: skim for errors, click to focus a specific\n * call (mirrors MessagesPanel's selection).\n *\n * v0.1 minimum — name, args preview, latency, error badge. Drill-in to\n * the tool's underlying footprintjs flowchart via explainable-ui is a\n * phase-2 item (requires surfacing per-tool sub-snapshots).\n */\nimport type { AgentToolInvocation, AgentTimeline } from \"../adapters/types\";\nimport { useLensTheme } from \"../theme/useLensTheme\";\n\nexport interface ToolCallInspectorProps {\n readonly timeline: AgentTimeline;\n readonly selectedId?: string | null;\n readonly onSelect?: (invocation: AgentToolInvocation) => void;\n}\n\nexport function ToolCallInspector({\n timeline,\n selectedId,\n onSelect,\n}: ToolCallInspectorProps) {\n const t = useLensTheme();\n return (\n <div\n data-fp-lens=\"tool-call-inspector\"\n style={{\n background: t.bg,\n color: t.text,\n fontFamily: t.fontSans,\n display: \"flex\",\n flexDirection: \"column\",\n minHeight: 0,\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n padding: \"10px 14px\",\n borderBottom: `1px solid ${t.border}`,\n fontSize: 11,\n color: t.textSubtle,\n textTransform: \"uppercase\",\n letterSpacing: \"0.08em\",\n fontWeight: 600,\n background: t.bgElev,\n }}\n >\n Tool calls · {timeline.tools.length}\n </div>\n <div style={{ overflow: \"auto\", flex: 1 }}>\n {timeline.tools.length === 0 && (\n <div style={{ padding: 14, color: t.textSubtle, fontSize: 12 }}>\n No tool calls yet.\n </div>\n )}\n {timeline.tools.map((tc) => {\n const active = tc.id === selectedId;\n const errored = tc.error === true;\n return (\n <button\n key={tc.id}\n onClick={() => onSelect?.(tc)}\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"stretch\",\n width: \"100%\",\n textAlign: \"left\",\n padding: \"8px 12px\",\n background: active ? t.bgHover : \"transparent\",\n border: \"none\",\n borderLeft: `3px solid ${\n active ? t.accent : errored ? t.error : \"transparent\"\n }`,\n borderBottom: `1px solid ${t.border}`,\n color: t.text,\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n gap: 8,\n alignItems: \"baseline\",\n fontSize: 12,\n fontFamily: t.fontMono,\n }}\n >\n <span style={{ color: errored ? t.error : t.accent, fontWeight: 600 }}>\n {tc.name}\n </span>\n <span\n style={{ color: t.textSubtle, fontSize: 10, marginLeft: \"auto\" }}\n >\n t{tc.turnIndex + 1}.i{tc.iterationIndex}\n {tc.durationMs !== undefined && ` · ${Math.round(tc.durationMs)}ms`}\n </span>\n </div>\n <div\n style={{\n fontSize: 10,\n color: t.textMuted,\n marginTop: 2,\n fontFamily: t.fontMono,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }}\n >\n {shortArgs(tc.arguments)}\n </div>\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n\nfunction shortArgs(args: Record<string, unknown>): string {\n const keys = Object.keys(args);\n if (keys.length === 0) return \"— no args —\";\n return keys\n .map((k) => {\n const v = args[k];\n if (typeof v === \"string\") return `${k}: \"${v.length > 20 ? v.slice(0, 20) + \"…\" : v}\"`;\n if (typeof v === \"number\" || typeof v === \"boolean\") return `${k}: ${v}`;\n return `${k}: …`;\n })\n .join(\", \");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyBA,IAAAA,gBAAkC;;;ACY3B,SAAS,kBAAkB,SAAqC;AACrE,QAAM,SAAS,SAAS,eAAe,CAAC;AACxC,QAAM,cAA4B,OAAO,YAAY,CAAC;AACtD,QAAM,WAAW,YAAY,IAAI,gBAAgB;AAEjD,QAAM,YAAY,MAAM,QAAQ,SAAS,SAAS,IAAI,QAAQ,YAAY,CAAC;AAC3E,QAAM,WAAW,gBAAgB,SAAS;AAC1C,QAAM,YAAY,sBAAsB,SAAS;AACjD,QAAM,mB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A,YACZ;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":["import_react","import_jsx_runtime","import_jsx_runtime","shortArgs","import_jsx_runtime"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/AgentLens.tsx","../src/adapters/fromAgentSnapshot.ts","../src/panels/MessagesPanel.tsx","../src/theme/useLensTheme.ts","../src/panels/IterationStrip.tsx","../src/panels/ToolCallInspector.tsx","../src/adapters/LiveTimelineBuilder.ts","../src/adapters/useLiveTimeline.ts"],"sourcesContent":["/**\n * agentfootprint-lens — public entry.\n *\n * See through your agent's decisions: messages, prompts, tool calls,\n * decision scope, cost — all in one timeline.\n */\n\n// Top-level shell — the 99% consumer entry point.\nexport { AgentLens } from \"./AgentLens\";\nexport type { AgentLensProps } from \"./AgentLens\";\n\n// Individual panels — for consumers who want to compose their own layout.\nexport { MessagesPanel } from \"./panels/MessagesPanel\";\nexport type { MessagesPanelProps } from \"./panels/MessagesPanel\";\nexport { IterationStrip } from \"./panels/IterationStrip\";\nexport type { IterationStripProps } from \"./panels/IterationStrip\";\nexport { ToolCallInspector } from \"./panels/ToolCallInspector\";\nexport type { ToolCallInspectorProps } from \"./panels/ToolCallInspector\";\n\n// Primary path: collect during traversal via the builder/hook. This is\n// the footprintjs-idiomatic approach — ingest emit events as they fire,\n// build the AgentTimeline incrementally, live-update the UI mid-run.\nexport { LiveTimelineBuilder } from \"./adapters/LiveTimelineBuilder\";\nexport { useLiveTimeline } from \"./adapters/useLiveTimeline\";\nexport type { UseLiveTimelineResult } from \"./adapters/useLiveTimeline\";\n\n// Fallback path: parse a completed snapshot (e.g. an imported trace, or\n// a run that finished before Lens was wired up). Still useful — but the\n// live path is preferred for in-app debugging because it respects the\n// \"no post-process\" principle (every field is written once, when its\n// source event fires during traversal).\nexport { fromAgentSnapshot } from \"./adapters/fromAgentSnapshot\";\n\nexport type {\n AgentTimeline,\n AgentTurn,\n AgentIteration,\n AgentMessage,\n AgentToolInvocation,\n AgentToolCallStub,\n} from \"./adapters/types\";\n\n// Theme — the resolved palette the panels render against.\n// Consumers shouldn't need to use this directly; it's available for\n// custom panel authors who want to match the Lens look.\nexport { useLensTheme, resolve as resolveLensTheme } from \"./theme/useLensTheme\";\nexport type { LensTheme } from \"./theme/useLensTheme\";\n","/**\n * <AgentLens> — top-level shell.\n *\n * Composes the three v0.1 surfaces: IterationStrip (top), MessagesPanel\n * (center, primary), ToolCallInspector (right sidebar). Selection state\n * is internal; parent apps can hook into `onToolCallClick` to drive\n * external drill-downs (e.g. open a footprint-explainable-ui drawer\n * scoped to the tool's flowchart execution).\n *\n * ─────────────────────────────────────────────────────────────────────────\n * Usage (zero-boilerplate):\n *\n * import { AgentLens } from 'agentfootprint-lens';\n * import { FootprintTheme, coolDark, coolLight } from 'footprint-explainable-ui';\n *\n * <FootprintTheme tokens={dark ? coolDark : coolLight}>\n * <AgentLens runtimeSnapshot={agent.getSnapshot()} />\n * </FootprintTheme>\n *\n * No Lens-specific theme prop — tokens flow from the standard\n * FootprintTheme context. The drill-in drawer (explainable-ui) reads\n * the same context, so chat + trace stay in sync when the consumer\n * flips themes.\n * ─────────────────────────────────────────────────────────────────────────\n */\nimport { useMemo, useState } from \"react\";\nimport { fromAgentSnapshot } from \"./adapters/fromAgentSnapshot\";\nimport type {\n AgentToolInvocation,\n AgentTimeline,\n} from \"./adapters/types\";\nimport { MessagesPanel } from \"./panels/MessagesPanel\";\nimport { IterationStrip } from \"./panels/IterationStrip\";\nimport { ToolCallInspector } from \"./panels/ToolCallInspector\";\nimport { useLensTheme } from \"./theme/useLensTheme\";\n\nexport interface AgentLensProps {\n /**\n * Raw runtimeSnapshot from `agent.getSnapshot()`. Lens parses this\n * into an agent-shaped AgentTimeline internally. Pass `null` when a\n * run hasn't happened yet — Lens renders an empty state.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly runtimeSnapshot?: any | null;\n /**\n * Pre-parsed timeline, for callers who want to run the adapter once\n * upstream and share the result. Overrides `runtimeSnapshot` when set.\n */\n readonly timeline?: AgentTimeline;\n /**\n * Optional system prompt to render in the collapsible preamble of\n * MessagesPanel. Usually `runtimeSnapshot.sharedState.systemPrompt`\n * or the agent's configured base prompt.\n */\n readonly systemPrompt?: string;\n /**\n * Called when the user clicks a tool call in either the Inspector or\n * the inline Messages tool-call card. Parent can use this to open a\n * drawer rendering `<ExplainableShell>` from footprint-explainable-ui\n * scoped to that tool's internal flowchart execution — the\n * composition seam between Lens (agent view) and explainable-ui\n * (tool-internal view).\n */\n readonly onToolCallClick?: (invocation: AgentToolInvocation) => void;\n}\n\nexport function AgentLens({\n runtimeSnapshot,\n timeline: providedTimeline,\n systemPrompt,\n onToolCallClick,\n}: AgentLensProps) {\n const t = useLensTheme();\n const timeline = useMemo<AgentTimeline | null>(() => {\n if (providedTimeline) return providedTimeline;\n if (!runtimeSnapshot) return null;\n return fromAgentSnapshot(runtimeSnapshot);\n }, [providedTimeline, runtimeSnapshot]);\n\n const [selectedToolId, setSelectedToolId] = useState<string | null>(null);\n const [selectedIterKey, setSelectedIterKey] = useState<string | null>(null);\n\n function handleToolClick(inv: AgentToolInvocation) {\n setSelectedToolId(inv.id);\n setSelectedIterKey(`${inv.turnIndex}.${inv.iterationIndex}`);\n onToolCallClick?.(inv);\n }\n\n if (!timeline) {\n return (\n <div\n data-fp-lens=\"empty\"\n style={{\n padding: 32,\n color: t.textMuted,\n fontFamily: t.fontSans,\n textAlign: \"center\",\n background: t.bg,\n }}\n >\n No agent run to show yet. Pass <code>runtimeSnapshot</code> after the agent runs.\n </div>\n );\n }\n\n const derivedSystemPrompt =\n systemPrompt ??\n (typeof timeline.rawSnapshot?.sharedState?.systemPrompt === \"string\"\n ? (timeline.rawSnapshot.sharedState.systemPrompt as string)\n : undefined);\n\n return (\n <div\n data-fp-lens=\"shell\"\n style={{\n display: \"grid\",\n gridTemplateColumns: \"1fr 320px\",\n gridTemplateRows: \"auto 1fr\",\n gridTemplateAreas: '\"strip strip\" \"messages inspector\"',\n height: \"100%\",\n minHeight: 0,\n background: t.bg,\n color: t.text,\n fontFamily: t.fontSans,\n }}\n >\n <div style={{ gridArea: \"strip\" }}>\n <IterationStrip\n timeline={timeline}\n selectedKey={selectedIterKey}\n onSelect={setSelectedIterKey}\n />\n </div>\n <div style={{ gridArea: \"messages\", minHeight: 0, overflow: \"hidden\" }}>\n <MessagesPanel\n timeline={timeline}\n onToolCallClick={handleToolClick}\n {...(derivedSystemPrompt && { systemPrompt: derivedSystemPrompt })}\n />\n </div>\n <div\n style={{\n gridArea: \"inspector\",\n minHeight: 0,\n overflow: \"hidden\",\n borderLeft: `1px solid ${t.border}`,\n }}\n >\n <ToolCallInspector\n timeline={timeline}\n selectedId={selectedToolId}\n onSelect={handleToolClick}\n />\n </div>\n </div>\n );\n}\n","/**\n * fromAgentSnapshot — turn an agentfootprint runtimeSnapshot into the\n * agent-shaped AgentTimeline Lens renders against.\n *\n * ─────────────────────────────────────────────────────────────────────────\n * The raw snapshot is flowchart-shaped (stages, commitLog, subflowResults).\n * Lens needs agent-shape: turns[] → iterations[] → {messages, toolCalls,\n * decision, tokens, latency, visibleTools}. That's what this file does.\n *\n * Derivation strategy (all sources already present — no library change\n * needed):\n * • `sharedState.messages[]` — canonical conversation\n * • `commitLog` entries for `call-llm` / `streaming-call-llm` — per-iter\n * LLM request+response (model, tokens, duration, stop reason)\n * • `commitLog` entries for `execute-tool-calls` — per-iter tool outputs\n * and decision updates\n * • `sf-instructions-to-llm` snapshots — matched instruction ids +\n * injection counts per iter\n * • `sf-tools` snapshots — tool list visible to the LLM that iter\n *\n * Turn boundaries are inferred by walking `messages[]` and grouping\n * everything between user messages into one turn. Iteration boundaries\n * are the LLM call events within a turn.\n * ─────────────────────────────────────────────────────────────────────────\n */\n\nimport type {\n AgentIteration,\n AgentMessage,\n AgentTimeline,\n AgentToolInvocation,\n AgentTurn,\n} from \"./types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnySnapshot = any;\n\nexport function fromAgentSnapshot(runtime: AnySnapshot): AgentTimeline {\n const shared = runtime?.sharedState ?? {};\n const rawMessages: RawMessage[] = shared.messages ?? [];\n const messages = rawMessages.map(normalizeMessage);\n\n const commitLog = Array.isArray(runtime?.commitLog) ? runtime.commitLog : [];\n const llmCalls = extractLLMCalls(commitLog);\n const toolExecs = extractToolExecutions(commitLog);\n const instructionEvals = extractInstructionEvals(commitLog);\n const toolResolves = extractToolResolves(commitLog);\n\n const turns = assembleTurns(messages, llmCalls, toolExecs, instructionEvals, toolResolves);\n const allTools = turns.flatMap((t) => t.iterations.flatMap((i) => i.toolCalls));\n\n return {\n turns,\n messages,\n tools: allTools,\n finalDecision: (shared.decision as Record<string, unknown>) ?? {},\n rawSnapshot: runtime,\n };\n}\n\n// ── Normalize ─────────────────────────────────────────────────────────\n\ninterface RawMessage {\n role: string;\n content: string | unknown;\n toolCalls?: Array<{ id: string; name: string; arguments: Record<string, unknown> }>;\n toolCallId?: string;\n}\n\nfunction normalizeMessage(m: RawMessage): AgentMessage {\n const role = ((): AgentMessage[\"role\"] => {\n if (m.role === \"system\" || m.role === \"user\" || m.role === \"assistant\" || m.role === \"tool\")\n return m.role;\n return \"user\";\n })();\n const content = typeof m.content === \"string\" ? m.content : JSON.stringify(m.content);\n return {\n role,\n content,\n ...(m.toolCalls?.length ? { toolCalls: m.toolCalls } : {}),\n ...(m.toolCallId ? { toolCallId: m.toolCallId } : {}),\n };\n}\n\n// ── Extract from commitLog ────────────────────────────────────────────\n\ninterface RawCommit {\n stageId?: string;\n stage?: string;\n runtimeStageId?: string;\n updates?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n trace?: any;\n}\n\ninterface LLMCall {\n iterationIndex: number;\n model?: string;\n inputTokens?: number;\n outputTokens?: number;\n durationMs?: number;\n stopReason?: string;\n assistantContent: string;\n toolCallsRequested: Array<{ id: string; name: string; arguments: Record<string, unknown> }>;\n}\n\nfunction extractLLMCalls(commitLog: RawCommit[]): LLMCall[] {\n const out: LLMCall[] = [];\n let iter = 0;\n for (const entry of commitLog) {\n const id = entry.stageId ?? \"\";\n if (id !== \"call-llm\" && id !== \"streaming-call-llm\") continue;\n iter++;\n const u = (entry.updates ?? {}) as Record<string, unknown>;\n const rawResponse =\n (u[\"adapterRawResponse\"] as Record<string, unknown> | undefined) ??\n (u[\"llmResponse\"] as Record<string, unknown> | undefined);\n const usage = rawResponse?.usage as\n | { inputTokens?: number; outputTokens?: number }\n | undefined;\n out.push({\n iterationIndex: iter,\n model: rawResponse?.model as string | undefined,\n inputTokens: usage?.inputTokens,\n outputTokens: usage?.outputTokens,\n durationMs: (u[\"callDurationMs\"] as number | undefined) ?? undefined,\n stopReason: rawResponse?.stopReason as string | undefined,\n assistantContent: (rawResponse?.content as string | undefined) ?? \"\",\n toolCallsRequested:\n (rawResponse?.toolCalls as LLMCall[\"toolCallsRequested\"] | undefined) ?? [],\n });\n }\n return out;\n}\n\ninterface ToolExec {\n iterationIndex: number;\n toolCalls: AgentToolInvocation[];\n}\n\nfunction extractToolExecutions(commitLog: RawCommit[]): ToolExec[] {\n const out: ToolExec[] = [];\n let iter = 0;\n for (const entry of commitLog) {\n const id = entry.stageId ?? \"\";\n if (id !== \"execute-tool-calls\") continue;\n iter++;\n const u = (entry.updates ?? {}) as Record<string, unknown>;\n // agentfootprint stores parsed tool calls + their results via\n // tool-start / tool-end emit events + the tool-role messages appended\n // to `messages`. Simplest stable derivation: walk messages right\n // after this commit and collect the tool-result entries.\n // For v0.1 we emit the tool call stubs; full resolution happens at\n // the assembler step where we have both sides in hand.\n const rawCalls = u[\"toolCalls\"] as LLMCall[\"toolCallsRequested\"] | undefined;\n const stubs: AgentToolInvocation[] = (rawCalls ?? []).map((c) => ({\n id: c.id,\n name: c.name,\n arguments: c.arguments ?? {},\n result: \"\", // filled in during assembly\n iterationIndex: iter,\n turnIndex: 0, // reassigned during assembly\n decisionUpdate: u[\"updatedDecision\"] as Record<string, unknown> | undefined,\n }));\n out.push({ iterationIndex: iter, toolCalls: stubs });\n }\n return out;\n}\n\ninterface InstructionEval {\n iterationIndex: number;\n matchedInstructions?: string[];\n promptInjectionCount: number;\n toolInjectionCount: number;\n}\n\nfunction extractInstructionEvals(commitLog: RawCommit[]): InstructionEval[] {\n const out: InstructionEval[] = [];\n let iter = 0;\n for (const entry of commitLog) {\n const id = entry.stageId ?? \"\";\n if (id !== \"evaluate-instructions\") continue;\n iter++;\n const u = (entry.updates ?? {}) as Record<string, unknown>;\n const matchedRaw = u[\"matchedInstructions\"];\n const matched = parseMatched(matchedRaw);\n const promptInj = Array.isArray(u[\"promptInjections\"]) ? u[\"promptInjections\"].length : 0;\n const toolInj = Array.isArray(u[\"toolInjections\"]) ? u[\"toolInjections\"].length : 0;\n out.push({\n iterationIndex: iter,\n ...(matched.length > 0 && { matchedInstructions: matched }),\n promptInjectionCount: promptInj,\n toolInjectionCount: toolInj,\n });\n }\n return out;\n}\n\nfunction parseMatched(v: unknown): string[] {\n if (!v) return [];\n if (Array.isArray(v)) return v.filter((x) => typeof x === \"string\");\n if (typeof v === \"string\") {\n // format: \"N matched: id1, id2, id3...\"\n const m = v.match(/:\\s*(.+)/);\n if (!m) return [];\n return m[1]\n .split(\",\")\n .map((s) => s.trim().replace(/\\.{3}$/, \"\"))\n .filter(Boolean);\n }\n return [];\n}\n\ninterface ToolResolve {\n iterationIndex: number;\n visibleTools: string[];\n}\n\nfunction extractToolResolves(commitLog: RawCommit[]): ToolResolve[] {\n const out: ToolResolve[] = [];\n let iter = 0;\n for (const entry of commitLog) {\n const id = entry.stageId ?? \"\";\n if (id !== \"resolve-tools\") continue;\n iter++;\n const u = (entry.updates ?? {}) as Record<string, unknown>;\n const descs = u[\"toolDescriptions\"] as Array<{ name: string }> | undefined;\n out.push({\n iterationIndex: iter,\n visibleTools: (descs ?? []).map((d) => d.name),\n });\n }\n return out;\n}\n\n// ── Assemble turns ────────────────────────────────────────────────────\n\nfunction assembleTurns(\n messages: AgentMessage[],\n llmCalls: LLMCall[],\n toolExecs: ToolExec[],\n instructionEvals: InstructionEval[],\n toolResolves: ToolResolve[],\n): AgentTurn[] {\n // Build a per-iteration map (flat across turns) then split by turn.\n // For a fresh agent instance, iter counts restart every turn — but\n // because commitLog is cumulative, iter numbers across commitLog are\n // monotonically increasing over the whole execution. So we group\n // iterations by the message boundary they fall in.\n //\n // Algorithm: walk messages in order. Each user message starts a new\n // turn. Each assistant message that has toolCalls (or is the final)\n // consumes the next LLM call from llmCalls. Tool-role messages that\n // follow bind to the most recent assistant message's toolCalls.\n\n const turns: AgentTurn[] = [];\n let currentTurn: {\n index: number;\n userPrompt: string;\n iterations: AgentIteration[];\n finalContent: string;\n } | null = null;\n let llmIdx = 0;\n const toolExecByIter = new Map(toolExecs.map((t) => [t.iterationIndex, t]));\n const instrByIter = new Map(instructionEvals.map((i) => [i.iterationIndex, i]));\n const visibleByIter = new Map(toolResolves.map((t) => [t.iterationIndex, t]));\n\n for (const msg of messages) {\n if (msg.role === \"user\") {\n if (currentTurn) turns.push(finalizeTurn(currentTurn));\n currentTurn = {\n index: turns.length,\n userPrompt: msg.content,\n iterations: [],\n finalContent: \"\",\n };\n continue;\n }\n if (!currentTurn) continue; // skip system prompt + anything before first user\n\n if (msg.role === \"assistant\") {\n const call = llmCalls[llmIdx];\n llmIdx++;\n const iterIndex = call?.iterationIndex ?? currentTurn.iterations.length + 1;\n const exec = toolExecByIter.get(iterIndex);\n const instr = instrByIter.get(iterIndex);\n const visible = visibleByIter.get(iterIndex);\n\n const toolCalls: AgentToolInvocation[] = (exec?.toolCalls ?? []).map((tc) => ({\n ...tc,\n turnIndex: currentTurn!.index,\n }));\n\n const iteration: AgentIteration = {\n index: iterIndex,\n ...(call?.model && { model: call.model }),\n ...(call?.inputTokens !== undefined && { inputTokens: call.inputTokens }),\n ...(call?.outputTokens !== undefined && { outputTokens: call.outputTokens }),\n ...(call?.durationMs !== undefined && { durationMs: call.durationMs }),\n ...(call?.stopReason && { stopReason: call.stopReason }),\n assistantContent: call?.assistantContent ?? msg.content,\n toolCalls,\n decisionAtStart: {}, // TODO(phase-2): derive from pre-iter commit\n ...(instr?.matchedInstructions && { matchedInstructions: instr.matchedInstructions }),\n visibleTools: visible?.visibleTools ?? [],\n };\n\n currentTurn.iterations.push(iteration);\n if (!toolCalls.length) currentTurn.finalContent = iteration.assistantContent;\n continue;\n }\n\n if (msg.role === \"tool\" && msg.toolCallId) {\n // Bind the result string back to the matching tool invocation in\n // the latest iteration.\n const iter = currentTurn.iterations[currentTurn.iterations.length - 1];\n if (!iter) continue;\n const idx = iter.toolCalls.findIndex((tc) => tc.id === msg.toolCallId);\n if (idx < 0) continue;\n const updated = { ...iter.toolCalls[idx], result: msg.content };\n // Rewrite via mutation — iter is readonly at the type level but we\n // own this intermediate structure during assembly.\n (iter.toolCalls as AgentToolInvocation[])[idx] = updated;\n }\n }\n\n if (currentTurn) turns.push(finalizeTurn(currentTurn));\n return turns;\n}\n\nfunction finalizeTurn(t: {\n index: number;\n userPrompt: string;\n iterations: AgentIteration[];\n finalContent: string;\n}): AgentTurn {\n const totalInputTokens = t.iterations.reduce((s, i) => s + (i.inputTokens ?? 0), 0);\n const totalOutputTokens = t.iterations.reduce((s, i) => s + (i.outputTokens ?? 0), 0);\n const totalDurationMs = t.iterations.reduce((s, i) => s + (i.durationMs ?? 0), 0);\n return {\n index: t.index,\n userPrompt: t.userPrompt,\n iterations: t.iterations,\n finalContent: t.finalContent,\n totalInputTokens,\n totalOutputTokens,\n totalDurationMs,\n };\n}\n","/**\n * MessagesPanel — the primary Lens surface. Chat-shaped view of an agent\n * run with turn boundaries, iteration markers, and expandable tool calls.\n *\n * Data comes from `fromAgentSnapshot(runtimeSnapshot).turns`. Each turn\n * is:\n * • one user message\n * • one or more assistant iterations (each may request N tool calls)\n * • tool role bubbles bound to their assistant parent\n * • final assistant bubble\n *\n * Theme is read via `useLensTheme()` which maps FootprintTheme tokens\n * into Lens's semantic palette. Consumers get free light/dark support\n * by wrapping their app in `<FootprintTheme tokens={coolLight|coolDark}>`\n * — no Lens-specific theme API to learn.\n */\nimport { useState } from \"react\";\nimport type {\n AgentIteration,\n AgentMessage,\n AgentTimeline,\n AgentToolInvocation,\n AgentTurn,\n} from \"../adapters/types\";\nimport { useLensTheme } from \"../theme/useLensTheme\";\n\nexport interface MessagesPanelProps {\n readonly timeline: AgentTimeline;\n /**\n * Called when the user clicks a tool-call card. Host app surfaces it\n * in the Tool Call Inspector. When omitted, clicking is a no-op.\n */\n readonly onToolCallClick?: (invocation: AgentToolInvocation) => void;\n /** Optional system-prompt text to render in the collapsible preamble. */\n readonly systemPrompt?: string;\n}\n\nexport function MessagesPanel({\n timeline,\n onToolCallClick,\n systemPrompt,\n}: MessagesPanelProps) {\n const t = useLensTheme();\n return (\n <div\n data-fp-lens=\"messages-panel\"\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n gap: 16,\n padding: \"16px 24px\",\n background: t.bg,\n color: t.text,\n fontFamily: t.fontSans,\n fontSize: 14,\n lineHeight: 1.55,\n minHeight: 0,\n overflow: \"auto\",\n }}\n >\n {systemPrompt && <SystemBubble text={systemPrompt} />}\n {timeline.turns.map((turn) => (\n <TurnBlock key={turn.index} turn={turn} onToolCallClick={onToolCallClick} />\n ))}\n </div>\n );\n}\n\nfunction SystemBubble({ text }: { text: string }) {\n const t = useLensTheme();\n const [open, setOpen] = useState(false);\n const preview = text.slice(0, 140).replace(/\\s+/g, \" \") + (text.length > 140 ? \"…\" : \"\");\n return (\n <div\n style={{\n alignSelf: \"center\",\n width: \"100%\",\n maxWidth: 880,\n border: `1px dashed ${t.border}`,\n borderRadius: t.radius,\n padding: \"8px 12px\",\n background: t.bgElev,\n fontSize: 12,\n color: t.textMuted,\n }}\n >\n <button\n onClick={() => setOpen((v) => !v)}\n style={{\n background: \"transparent\",\n border: \"none\",\n color: t.textMuted,\n cursor: \"pointer\",\n padding: 0,\n font: \"inherit\",\n }}\n >\n <strong>SYSTEM</strong> {open ? \"▾\" : \"▸\"} {open ? \"\" : preview}\n </button>\n {open && (\n <pre\n style={{\n marginTop: 8,\n whiteSpace: \"pre-wrap\",\n fontFamily: t.fontMono,\n fontSize: 11,\n color: t.text,\n }}\n >\n {text}\n </pre>\n )}\n </div>\n );\n}\n\nfunction TurnBlock({\n turn,\n onToolCallClick,\n}: {\n turn: AgentTurn;\n onToolCallClick?: (inv: AgentToolInvocation) => void;\n}) {\n const t = useLensTheme();\n return (\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 12 }}>\n <TurnHeader turn={turn} />\n <UserBubble text={turn.userPrompt} />\n {turn.iterations.map((iter) => (\n <IterationBlock key={iter.index} iter={iter} onToolCallClick={onToolCallClick} />\n ))}\n {turn.finalContent && turn.iterations.length > 0 && (\n <div style={{ fontSize: 11, color: t.textSubtle, textAlign: \"center\" }}>\n turn {turn.index + 1} final · {turn.iterations.length} iter · {turn.totalInputTokens}→\n {turn.totalOutputTokens} tok · {(turn.totalDurationMs / 1000).toFixed(1)}s\n </div>\n )}\n </div>\n );\n}\n\nfunction TurnHeader({ turn }: { turn: AgentTurn }) {\n const t = useLensTheme();\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 8,\n color: t.textSubtle,\n fontSize: 11,\n textTransform: \"uppercase\",\n letterSpacing: \"0.08em\",\n fontWeight: 600,\n }}\n >\n <div style={{ flex: 1, height: 1, background: t.border }} />\n <span>Turn {turn.index + 1}</span>\n <div style={{ flex: 1, height: 1, background: t.border }} />\n </div>\n );\n}\n\nfunction UserBubble({ text }: { text: string }) {\n const t = useLensTheme();\n return (\n <div style={{ display: \"flex\", justifyContent: \"flex-end\" }}>\n <div\n style={{\n background: `color-mix(in srgb, ${t.accent} 18%, ${t.bgElev})`,\n border: `1px solid ${t.border}`,\n color: t.text,\n maxWidth: 720,\n padding: \"10px 14px\",\n borderRadius: `${t.radius} ${t.radius} 2px ${t.radius}`,\n whiteSpace: \"pre-wrap\",\n }}\n >\n {text}\n </div>\n </div>\n );\n}\n\nfunction IterationBlock({\n iter,\n onToolCallClick,\n}: {\n iter: AgentIteration;\n onToolCallClick?: (inv: AgentToolInvocation) => void;\n}) {\n const t = useLensTheme();\n return (\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6 }}>\n <IterationBadge iter={iter} />\n {iter.assistantContent && (\n <div\n style={{\n background: t.bgElev,\n border: `1px solid ${t.border}`,\n borderRadius: `2px ${t.radius} ${t.radius} ${t.radius}`,\n padding: \"10px 14px\",\n maxWidth: 820,\n whiteSpace: \"pre-wrap\",\n }}\n >\n {iter.assistantContent}\n </div>\n )}\n {iter.toolCalls.length > 0 && (\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 6, paddingLeft: 12 }}>\n {iter.toolCalls.map((tc) => (\n <ToolCallCard key={tc.id} invocation={tc} onClick={onToolCallClick} />\n ))}\n </div>\n )}\n </div>\n );\n}\n\nfunction IterationBadge({ iter }: { iter: AgentIteration }) {\n const t = useLensTheme();\n const bits: string[] = [`iter ${iter.index}`];\n if (iter.model) bits.push(iter.model);\n if (iter.inputTokens !== undefined)\n bits.push(`${iter.inputTokens}→${iter.outputTokens ?? \"?\"} tok`);\n if (iter.durationMs !== undefined) bits.push(`${(iter.durationMs / 1000).toFixed(2)}s`);\n if (iter.stopReason) bits.push(iter.stopReason);\n return (\n <div\n style={{\n alignSelf: \"flex-start\",\n fontSize: 10,\n color: t.textSubtle,\n textTransform: \"uppercase\",\n letterSpacing: \"0.08em\",\n fontWeight: 600,\n fontFamily: t.fontMono,\n }}\n >\n {bits.join(\" · \")}\n </div>\n );\n}\n\nfunction ToolCallCard({\n invocation,\n onClick,\n}: {\n invocation: AgentToolInvocation;\n onClick?: (inv: AgentToolInvocation) => void;\n}) {\n const t = useLensTheme();\n const [open, setOpen] = useState(false);\n const preview = shortArgs(invocation.arguments);\n const errored = invocation.error === true;\n return (\n <div\n style={{\n border: `1px solid ${errored ? t.error : t.border}`,\n borderLeft: `3px solid ${errored ? t.error : t.accent}`,\n borderRadius: 6,\n background: t.bg,\n overflow: \"hidden\",\n }}\n >\n <div\n onClick={() => {\n setOpen((v) => !v);\n onClick?.(invocation);\n }}\n style={{\n padding: \"8px 12px\",\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n gap: 10,\n fontSize: 12,\n fontFamily: t.fontMono,\n }}\n >\n <span style={{ color: errored ? t.error : t.accent, fontWeight: 600 }}>\n {invocation.name}\n </span>\n <span style={{ color: t.textMuted }}>({preview})</span>\n <span style={{ flex: 1 }} />\n {invocation.decisionUpdate && Object.keys(invocation.decisionUpdate).length > 0 && (\n <span\n style={{\n fontSize: 10,\n padding: \"1px 6px\",\n borderRadius: 3,\n background: `color-mix(in srgb, ${t.warning} 20%, transparent)`,\n color: t.warning,\n fontFamily: t.fontSans,\n fontWeight: 600,\n textTransform: \"uppercase\",\n }}\n >\n decisionUpdate\n </span>\n )}\n <span style={{ color: t.textSubtle }}>{open ? \"▾\" : \"▸\"}</span>\n </div>\n {open && (\n <div style={{ padding: \"8px 12px\", borderTop: `1px solid ${t.border}` }}>\n <Label t={t}>args</Label>\n <JsonBlock value={invocation.arguments} />\n {invocation.result && (\n <>\n <Label t={t} style={{ marginTop: 10 }}>\n result\n </Label>\n <pre\n style={{\n margin: 0,\n padding: \"8px 10px\",\n background: t.bgElev,\n borderRadius: 4,\n fontSize: 11,\n fontFamily: t.fontMono,\n color: errored ? t.error : t.text,\n maxHeight: 280,\n overflow: \"auto\",\n whiteSpace: \"pre-wrap\",\n }}\n >\n {invocation.result}\n </pre>\n </>\n )}\n {invocation.decisionUpdate &&\n Object.keys(invocation.decisionUpdate).length > 0 && (\n <>\n <Label t={t} style={{ marginTop: 10 }}>\n decisionUpdate\n </Label>\n <JsonBlock value={invocation.decisionUpdate} />\n </>\n )}\n </div>\n )}\n </div>\n );\n}\n\nfunction Label({\n t,\n children,\n style,\n}: {\n t: ReturnType<typeof useLensTheme>;\n children: React.ReactNode;\n style?: React.CSSProperties;\n}) {\n return (\n <div\n style={{\n fontSize: 10,\n color: t.textSubtle,\n textTransform: \"uppercase\",\n letterSpacing: \"0.08em\",\n fontWeight: 600,\n marginBottom: 4,\n ...style,\n }}\n >\n {children}\n </div>\n );\n}\n\nfunction JsonBlock({ value }: { value: unknown }) {\n const t = useLensTheme();\n return (\n <pre\n style={{\n margin: 0,\n padding: \"8px 10px\",\n background: t.bgElev,\n borderRadius: 4,\n fontSize: 11,\n fontFamily: t.fontMono,\n color: t.text,\n maxHeight: 200,\n overflow: \"auto\",\n }}\n >\n {JSON.stringify(value, null, 2)}\n </pre>\n );\n}\n\nfunction shortArgs(args: Record<string, unknown>): string {\n const keys = Object.keys(args);\n if (keys.length === 0) return \"\";\n if (keys.length === 1) {\n const v = args[keys[0]];\n if (typeof v === \"string\" && v.length < 40) return `${keys[0]}: \"${v}\"`;\n }\n return keys.join(\", \");\n}\n\nexport { ToolCallCard };\n\nfunction _assertUnused(_: AgentMessage) {\n // Exported type is referenced from ./index.ts; keeping the import\n // for bundler tree-shaking consistency without introducing a new\n // linter warning on a \"used-elsewhere\" type import.\n void _;\n}\n_assertUnused;\n","/**\n * useLensTheme — single source of truth for Lens colors + sizing.\n *\n * ─────────────────────────────────────────────────────────────────────────\n * Theme pass-through contract (IMPORTANT for consumers):\n *\n * Lens does NOT invent its own theme system. It reads tokens from the\n * FootprintTheme context already defined in `footprint-explainable-ui`.\n * A consumer app that wraps its tree in:\n *\n * import { FootprintTheme, coolDark, coolLight } from 'footprint-explainable-ui';\n * <FootprintTheme tokens={theme === 'light' ? coolLight : coolDark}>\n * <AgentLens runtimeSnapshot={snap} />\n * </FootprintTheme>\n *\n * …gets both Lens AND the drill-down explainable-ui drawer themed from the\n * same token bag. No separate `theme` prop, no duplicate palette, no\n * drift between the two views when the user flips light/dark.\n *\n * If no FootprintTheme provider is mounted, Lens falls back to cool-dark\n * defaults — the same defaults explainable-ui uses, so it looks correct\n * out of the box without configuration.\n * ─────────────────────────────────────────────────────────────────────────\n */\nimport { useFootprintTheme, coolDark } from \"footprint-explainable-ui\";\nimport type { ThemeTokens } from \"footprint-explainable-ui\";\n\n/**\n * The resolved color palette + sizing tokens Lens renders against.\n * Always defined — callers never need to null-check.\n */\nexport interface LensTheme {\n readonly bg: string;\n readonly bgElev: string;\n readonly bgHover: string;\n readonly border: string;\n readonly borderStrong: string;\n readonly text: string;\n readonly textMuted: string;\n readonly textSubtle: string;\n readonly accent: string;\n readonly success: string;\n readonly warning: string;\n readonly error: string;\n readonly fontSans: string;\n readonly fontMono: string;\n readonly radius: string;\n}\n\n/**\n * Read tokens from FootprintTheme context (if present) and map them\n * into Lens's semantic palette. Missing tokens fall back to coolDark.\n */\nexport function useLensTheme(): LensTheme {\n const ctx = useFootprintTheme();\n return resolve(ctx);\n}\n\n/** Pure mapping — exported for unit tests + non-hook call sites. */\nexport function resolve(tokens: ThemeTokens | undefined): LensTheme {\n const t = tokens ?? {};\n const c = t.colors ?? coolDark.colors ?? {};\n const fallback = coolDark.colors ?? {};\n return {\n bg: c.bgPrimary ?? fallback.bgPrimary ?? \"#0f172a\",\n bgElev: c.bgSecondary ?? fallback.bgSecondary ?? \"#1e293b\",\n bgHover: c.bgTertiary ?? fallback.bgTertiary ?? \"#334155\",\n border: c.border ?? fallback.border ?? \"#334155\",\n borderStrong: c.bgTertiary ?? fallback.bgTertiary ?? \"#334155\",\n text: c.textPrimary ?? fallback.textPrimary ?? \"#f8fafc\",\n textMuted: c.textSecondary ?? fallback.textSecondary ?? \"#94a3b8\",\n textSubtle: c.textMuted ?? fallback.textMuted ?? \"#64748b\",\n accent: c.primary ?? fallback.primary ?? \"#6366f1\",\n success: c.success ?? fallback.success ?? \"#22c55e\",\n warning: c.warning ?? fallback.warning ?? \"#f59e0b\",\n error: c.error ?? fallback.error ?? \"#ef4444\",\n fontSans: t.fontFamily?.sans ?? coolDark.fontFamily?.sans ?? \"system-ui, sans-serif\",\n fontMono: t.fontFamily?.mono ?? coolDark.fontFamily?.mono ?? \"ui-monospace, monospace\",\n radius: t.radius ?? coolDark.radius ?? \"8px\",\n };\n}\n","/**\n * IterationStrip — horizontal ribbon of LLM calls across the run, one\n * chip per iteration. Click to scroll/pin MessagesPanel to that iter.\n *\n * v0.1 is display-only with the selection callback; parent app owns the\n * scroll behavior.\n */\nimport type { AgentTimeline } from \"../adapters/types\";\nimport { useLensTheme } from \"../theme/useLensTheme\";\n\nexport interface IterationStripProps {\n readonly timeline: AgentTimeline;\n readonly selectedKey?: string | null;\n readonly onSelect?: (key: string) => void;\n}\n\nexport function IterationStrip({ timeline, selectedKey, onSelect }: IterationStripProps) {\n const t = useLensTheme();\n const chips = timeline.turns.flatMap((turn) =>\n turn.iterations.map((iter) => ({\n key: `${turn.index}.${iter.index}`,\n turn: turn.index + 1,\n iter: iter.index,\n label: chipLabel(iter),\n tools: iter.toolCalls.length,\n durationMs: iter.durationMs ?? 0,\n stopReason: iter.stopReason,\n })),\n );\n\n return (\n <div\n data-fp-lens=\"iteration-strip\"\n style={{\n display: \"flex\",\n gap: 4,\n padding: \"8px 12px\",\n overflowX: \"auto\",\n borderBottom: `1px solid ${t.border}`,\n background: t.bgElev,\n }}\n >\n {chips.length === 0 && (\n <span style={{ color: t.textSubtle, fontSize: 11 }}>No iterations yet.</span>\n )}\n {chips.map((c) => {\n const active = c.key === selectedKey;\n const isFinal = c.stopReason === \"stop\" || c.stopReason === \"end_turn\";\n return (\n <button\n key={c.key}\n onClick={() => onSelect?.(c.key)}\n style={{\n background: active ? t.accent : \"transparent\",\n color: active ? \"#fff\" : t.textMuted,\n border: `1px solid ${active ? t.accent : t.border}`,\n borderRadius: 4,\n padding: \"4px 8px\",\n fontSize: 11,\n fontFamily: \"ui-monospace, monospace\",\n cursor: \"pointer\",\n whiteSpace: \"nowrap\",\n flexShrink: 0,\n }}\n title={`turn ${c.turn} · iter ${c.iter} · ${c.tools} tool call${\n c.tools === 1 ? \"\" : \"s\"\n }${c.stopReason ? ` · ${c.stopReason}` : \"\"}`}\n >\n t{c.turn}.i{c.iter} · {c.label} {isFinal ? \"✓\" : \"\"}\n </button>\n );\n })}\n </div>\n );\n}\n\nfunction chipLabel(iter: { toolCalls: readonly unknown[]; durationMs?: number }): string {\n const d = iter.durationMs ?? 0;\n const secs = d >= 1000 ? `${(d / 1000).toFixed(1)}s` : `${Math.round(d)}ms`;\n const toolBit = iter.toolCalls.length > 0 ? `${iter.toolCalls.length}t` : \"final\";\n return `${secs} · ${toolBit}`;\n}\n","/**\n * ToolCallInspector — flat sidebar list of every tool invocation in the\n * run. Primary workflow: skim for errors, click to focus a specific\n * call (mirrors MessagesPanel's selection).\n *\n * v0.1 minimum — name, args preview, latency, error badge. Drill-in to\n * the tool's underlying footprintjs flowchart via explainable-ui is a\n * phase-2 item (requires surfacing per-tool sub-snapshots).\n */\nimport type { AgentToolInvocation, AgentTimeline } from \"../adapters/types\";\nimport { useLensTheme } from \"../theme/useLensTheme\";\n\nexport interface ToolCallInspectorProps {\n readonly timeline: AgentTimeline;\n readonly selectedId?: string | null;\n readonly onSelect?: (invocation: AgentToolInvocation) => void;\n}\n\nexport function ToolCallInspector({\n timeline,\n selectedId,\n onSelect,\n}: ToolCallInspectorProps) {\n const t = useLensTheme();\n return (\n <div\n data-fp-lens=\"tool-call-inspector\"\n style={{\n background: t.bg,\n color: t.text,\n fontFamily: t.fontSans,\n display: \"flex\",\n flexDirection: \"column\",\n minHeight: 0,\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n padding: \"10px 14px\",\n borderBottom: `1px solid ${t.border}`,\n fontSize: 11,\n color: t.textSubtle,\n textTransform: \"uppercase\",\n letterSpacing: \"0.08em\",\n fontWeight: 600,\n background: t.bgElev,\n }}\n >\n Tool calls · {timeline.tools.length}\n </div>\n <div style={{ overflow: \"auto\", flex: 1 }}>\n {timeline.tools.length === 0 && (\n <div style={{ padding: 14, color: t.textSubtle, fontSize: 12 }}>\n No tool calls yet.\n </div>\n )}\n {timeline.tools.map((tc) => {\n const active = tc.id === selectedId;\n const errored = tc.error === true;\n return (\n <button\n key={tc.id}\n onClick={() => onSelect?.(tc)}\n style={{\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"stretch\",\n width: \"100%\",\n textAlign: \"left\",\n padding: \"8px 12px\",\n background: active ? t.bgHover : \"transparent\",\n border: \"none\",\n borderLeft: `3px solid ${\n active ? t.accent : errored ? t.error : \"transparent\"\n }`,\n borderBottom: `1px solid ${t.border}`,\n color: t.text,\n cursor: \"pointer\",\n fontFamily: \"inherit\",\n }}\n >\n <div\n style={{\n display: \"flex\",\n gap: 8,\n alignItems: \"baseline\",\n fontSize: 12,\n fontFamily: t.fontMono,\n }}\n >\n <span style={{ color: errored ? t.error : t.accent, fontWeight: 600 }}>\n {tc.name}\n </span>\n <span\n style={{ color: t.textSubtle, fontSize: 10, marginLeft: \"auto\" }}\n >\n t{tc.turnIndex + 1}.i{tc.iterationIndex}\n {tc.durationMs !== undefined && ` · ${Math.round(tc.durationMs)}ms`}\n </span>\n </div>\n <div\n style={{\n fontSize: 10,\n color: t.textMuted,\n marginTop: 2,\n fontFamily: t.fontMono,\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"nowrap\",\n }}\n >\n {shortArgs(tc.arguments)}\n </div>\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n\nfunction shortArgs(args: Record<string, unknown>): string {\n const keys = Object.keys(args);\n if (keys.length === 0) return \"— no args —\";\n return keys\n .map((k) => {\n const v = args[k];\n if (typeof v === \"string\") return `${k}: \"${v.length > 20 ? v.slice(0, 20) + \"…\" : v}\"`;\n if (typeof v === \"number\" || typeof v === \"boolean\") return `${k}: ${v}`;\n return `${k}: …`;\n })\n .join(\", \");\n}\n","/**\n * LiveTimelineBuilder — ingests agentfootprint emit events AS THEY HAPPEN\n * and accumulates the `AgentTimeline` incrementally. Zero post-processing:\n * every field is set as the corresponding event fires during traversal.\n *\n * ─────────────────────────────────────────────────────────────────────────\n * Why this exists\n *\n * footprintjs's core principle: \"collect during traversal, never post-\n * process.\" Walking `commitLog` after the run to reconstruct the agent\n * view is valid but it re-traverses data that already flowed past. The\n * Builder is the correct shape — it's a recorder that subscribes to the\n * stream of events the agent already emits and writes each field exactly\n * once, when the source-of-truth event fires.\n *\n * Consumer wiring (from a React app):\n *\n * const builder = useMemo(() => new LiveTimelineBuilder(), []);\n * const [timeline, setTimeline] = useState(builder.getTimeline());\n * // In Neo's runTurn onEvent:\n * await agent.run(prompt, {\n * onEvent: (e) => {\n * builder.ingest(e);\n * setTimeline(builder.getTimeline());\n * },\n * });\n * <AgentLens timeline={timeline} />\n *\n * Or via the `useLiveTimeline()` React hook below — same mechanics, less\n * boilerplate.\n *\n * The events consumed are all `agentfootprint.stream.*` (llm_start,\n * llm_end, tool_start, tool_end) + `agentfootprint.agent.turn_complete`.\n * User messages are captured by calling `startTurn(userPrompt)` before\n * each `agent.run()` invocation — that's the one piece the event stream\n * doesn't carry (agent.run() is where the user message enters the\n * system, not an event emission).\n * ─────────────────────────────────────────────────────────────────────────\n */\nimport type {\n AgentIteration,\n AgentMessage,\n AgentTimeline,\n AgentToolInvocation,\n AgentTurn,\n} from \"./types\";\n\n// Minimal shape we need from an agent event — structural only, no direct\n// dep on agentfootprint's event type (which may evolve).\ninterface AgentEventLike {\n readonly type: string;\n readonly toolName?: string;\n readonly toolCallId?: string;\n readonly args?: Record<string, unknown>;\n readonly result?: { content?: string; error?: boolean } | string;\n readonly iteration?: number;\n readonly content?: string;\n readonly toolCallCount?: number;\n readonly model?: string;\n readonly usage?: { inputTokens?: number; outputTokens?: number };\n readonly stopReason?: string;\n readonly durationMs?: number;\n readonly iterations?: number;\n readonly reason?: string;\n}\n\ninterface MutableTurn {\n index: number;\n userPrompt: string;\n iterations: MutableIteration[];\n finalContent: string;\n totalInputTokens: number;\n totalOutputTokens: number;\n totalDurationMs: number;\n startMs: number;\n}\n\ninterface MutableIteration {\n index: number;\n model?: string;\n inputTokens?: number;\n outputTokens?: number;\n durationMs?: number;\n stopReason?: string;\n assistantContent: string;\n toolCalls: MutableTool[];\n decisionAtStart: Record<string, unknown>;\n matchedInstructions?: string[];\n visibleTools: string[];\n startMs: number;\n}\n\ninterface MutableTool {\n id: string;\n name: string;\n arguments: Record<string, unknown>;\n result: string;\n error?: boolean;\n decisionUpdate?: Record<string, unknown>;\n iterationIndex: number;\n turnIndex: number;\n durationMs?: number;\n startMs: number;\n}\n\nexport class LiveTimelineBuilder {\n private turns: MutableTurn[] = [];\n private currentTurn: MutableTurn | null = null;\n private currentIter: MutableIteration | null = null;\n private toolByCallId = new Map<string, MutableTool>();\n private messages: AgentMessage[] = [];\n private systemPrompt: string | undefined;\n private finalDecision: Record<string, unknown> = {};\n\n /**\n * Begin a new turn. Call this BEFORE `agent.run(userPrompt)` so the\n * user's prompt appears alongside the iterations it produced. Safe to\n * call even mid-conversation — it closes the previous turn cleanly.\n */\n startTurn(userPrompt: string): void {\n if (this.currentTurn) this.commitCurrentTurn();\n this.currentTurn = {\n index: this.turns.length,\n userPrompt,\n iterations: [],\n finalContent: \"\",\n totalInputTokens: 0,\n totalOutputTokens: 0,\n totalDurationMs: 0,\n startMs: Date.now(),\n };\n this.messages.push({ role: \"user\", content: userPrompt });\n }\n\n /**\n * Optional — attach the system prompt so MessagesPanel can render it\n * in the collapsible preamble. Usually set once at agent construction.\n */\n setSystemPrompt(prompt: string): void {\n this.systemPrompt = prompt;\n }\n\n /**\n * Feed one agent stream event. Safe to call for unknown events; we\n * ignore anything we don't recognize.\n */\n ingest(event: AgentEventLike | unknown): void {\n const e = event as AgentEventLike;\n if (!e || typeof e.type !== \"string\") return;\n switch (e.type) {\n case \"llm_start\":\n case \"agentfootprint.stream.llm_start\":\n this.onLLMStart(e);\n return;\n case \"llm_end\":\n case \"agentfootprint.stream.llm_end\":\n this.onLLMEnd(e);\n return;\n case \"tool_start\":\n case \"agentfootprint.stream.tool_start\":\n this.onToolStart(e);\n return;\n case \"tool_end\":\n case \"agentfootprint.stream.tool_end\":\n this.onToolEnd(e);\n return;\n case \"turn_end\":\n case \"agentfootprint.agent.turn_complete\":\n this.commitCurrentTurn();\n return;\n default:\n return;\n }\n }\n\n private onLLMStart(e: AgentEventLike): void {\n if (!this.currentTurn) return;\n const iterNum = e.iteration ?? this.currentTurn.iterations.length + 1;\n this.currentIter = {\n index: iterNum,\n assistantContent: \"\",\n toolCalls: [],\n decisionAtStart: {},\n visibleTools: [],\n startMs: Date.now(),\n };\n this.currentTurn.iterations.push(this.currentIter);\n }\n\n private onLLMEnd(e: AgentEventLike): void {\n if (!this.currentIter || !this.currentTurn) return;\n this.currentIter.assistantContent = e.content ?? this.currentIter.assistantContent;\n if (e.model) this.currentIter.model = e.model;\n if (e.usage?.inputTokens !== undefined) this.currentIter.inputTokens = e.usage.inputTokens;\n if (e.usage?.outputTokens !== undefined) this.currentIter.outputTokens = e.usage.outputTokens;\n if (e.stopReason) this.currentIter.stopReason = e.stopReason;\n this.currentIter.durationMs = e.durationMs ?? Date.now() - this.currentIter.startMs;\n\n // Aggregate into turn totals.\n this.currentTurn.totalInputTokens += this.currentIter.inputTokens ?? 0;\n this.currentTurn.totalOutputTokens += this.currentIter.outputTokens ?? 0;\n this.currentTurn.totalDurationMs += this.currentIter.durationMs ?? 0;\n\n // Assistant message for the chat view.\n if (this.currentIter.assistantContent) {\n this.messages.push({ role: \"assistant\", content: this.currentIter.assistantContent });\n }\n // If no tool calls follow, this iteration's content IS the turn's final answer.\n if ((e.toolCallCount ?? 0) === 0) {\n this.currentTurn.finalContent = this.currentIter.assistantContent;\n }\n }\n\n private onToolStart(e: AgentEventLike): void {\n if (!this.currentIter || !this.currentTurn) return;\n const tool: MutableTool = {\n id: e.toolCallId ?? `tool-${this.currentIter.toolCalls.length}`,\n name: e.toolName ?? \"unknown\",\n arguments: e.args ?? {},\n result: \"\",\n iterationIndex: this.currentIter.index,\n turnIndex: this.currentTurn.index,\n startMs: Date.now(),\n };\n this.currentIter.toolCalls.push(tool);\n this.toolByCallId.set(tool.id, tool);\n }\n\n private onToolEnd(e: AgentEventLike): void {\n const tool = this.toolByCallId.get(e.toolCallId ?? \"\");\n if (!tool) return;\n const r = e.result;\n if (typeof r === \"string\") {\n tool.result = r;\n } else if (r && typeof r === \"object\") {\n tool.result = r.content ?? \"\";\n if (r.error === true) tool.error = true;\n }\n tool.durationMs = e.durationMs ?? Date.now() - tool.startMs;\n // Record the tool-role message so MessagesPanel can render it.\n this.messages.push({ role: \"tool\", content: tool.result, toolCallId: tool.id });\n }\n\n private commitCurrentTurn(): void {\n if (!this.currentTurn) return;\n this.turns.push(this.currentTurn);\n this.currentTurn = null;\n this.currentIter = null;\n }\n\n /**\n * Snapshot the current state as an immutable `AgentTimeline`. Safe to\n * call at any point — mid-run gives you the partial state so Lens can\n * live-update.\n */\n getTimeline(): AgentTimeline {\n const allTurns = [...this.turns];\n if (this.currentTurn) allTurns.push(this.currentTurn);\n const tools: AgentToolInvocation[] = [];\n const frozenTurns: AgentTurn[] = allTurns.map((t) => {\n const iterations: AgentIteration[] = t.iterations.map((i) => {\n const tcs = i.toolCalls.map((tc) => ({ ...tc } as AgentToolInvocation));\n tools.push(...tcs);\n return { ...i, toolCalls: tcs } as AgentIteration;\n });\n return { ...t, iterations } as AgentTurn;\n });\n return {\n turns: frozenTurns,\n messages: [...this.messages],\n tools,\n finalDecision: { ...this.finalDecision },\n rawSnapshot: null,\n };\n }\n\n /**\n * Fold in a final `decision` scope after the run — useful when\n * the consumer wants the Decision Ribbon (phase-2) to reflect the\n * post-run state. Safe no-op during the run itself.\n */\n setFinalDecision(decision: Record<string, unknown>): void {\n this.finalDecision = decision;\n }\n\n /** Get the optional system prompt for the Messages preamble. */\n getSystemPrompt(): string | undefined {\n return this.systemPrompt;\n }\n\n /** Wipe state. Useful when the consumer starts a fresh conversation. */\n reset(): void {\n this.turns = [];\n this.currentTurn = null;\n this.currentIter = null;\n this.toolByCallId.clear();\n this.messages = [];\n this.finalDecision = {};\n }\n}\n","/**\n * useLiveTimeline — React hook wrapper around LiveTimelineBuilder.\n *\n * The hook owns a stable builder across renders and returns:\n * • `timeline` — current state (re-renders on every `ingest` call)\n * • `ingest` — feed an agentfootprint stream event\n * • `startTurn`, `setSystemPrompt`, `setFinalDecision`, `reset` — forward methods\n *\n * Usage:\n *\n * const lens = useLiveTimeline();\n * <AgentLens timeline={lens.timeline} />\n *\n * // Before agent.run():\n * lens.startTurn(userPrompt);\n * await agent.run(userPrompt, { onEvent: lens.ingest });\n *\n * The hook keeps the agent-shaped view in sync AS events fire — Lens\n * updates incrementally during the run, not only after it completes.\n */\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport { LiveTimelineBuilder } from \"./LiveTimelineBuilder\";\nimport type { AgentTimeline } from \"./types\";\n\nexport interface UseLiveTimelineResult {\n readonly timeline: AgentTimeline;\n readonly ingest: (event: unknown) => void;\n readonly startTurn: (userPrompt: string) => void;\n readonly setSystemPrompt: (prompt: string) => void;\n readonly setFinalDecision: (decision: Record<string, unknown>) => void;\n readonly reset: () => void;\n /** Escape hatch — exposed for integrations that need builder internals. */\n readonly builder: LiveTimelineBuilder;\n}\n\nexport function useLiveTimeline(): UseLiveTimelineResult {\n const builderRef = useRef<LiveTimelineBuilder | null>(null);\n if (!builderRef.current) builderRef.current = new LiveTimelineBuilder();\n const builder = builderRef.current;\n\n const [timeline, setTimeline] = useState<AgentTimeline>(() => builder.getTimeline());\n\n const sync = useCallback(() => {\n setTimeline(builder.getTimeline());\n }, [builder]);\n\n const ingest = useCallback(\n (event: unknown) => {\n builder.ingest(event);\n sync();\n },\n [builder, sync],\n );\n\n const startTurn = useCallback(\n (userPrompt: string) => {\n builder.startTurn(userPrompt);\n sync();\n },\n [builder, sync],\n );\n\n const setSystemPrompt = useCallback(\n (prompt: string) => {\n builder.setSystemPrompt(prompt);\n sync();\n },\n [builder, sync],\n );\n\n const setFinalDecision = useCallback(\n (decision: Record<string, unknown>) => {\n builder.setFinalDecision(decision);\n sync();\n },\n [builder, sync],\n );\n\n const reset = useCallback(() => {\n builder.reset();\n sync();\n }, [builder, sync]);\n\n return useMemo(\n () => ({ timeline, ingest, startTurn, setSystemPrompt, setFinalDecision, reset, builder }),\n [timeline, ingest, startTurn, setSystemPrompt, setFinalDecision, reset, builder],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACyBA,IAAAA,gBAAkC;;;ACY3B,SAAS,kBAAkB,SAAqC;AACrE,QAAM,SAAS,SAAS,eAAe,CAAC;AACxC,QAAM,cAA4B,OAAO,YAAY,CAAC;AACtD,QAAM,WAAW,YAAY,IAAI,gBAAgB;AAEjD,QAAM,YAAY,MAAM,QAAQ,SAAS,SAAS,IAAI,QAAQ,YAAY,CAAC;AAC3E,QAAM,WAAW,gBAAgB,SAAS;AAC1C,QAAM,YAAY,sBAAsB,SAAS;AACjD,QAAM,mBAAmB,wBAAwB,SAAS;AAC1D,QAAM,eAAe,oBAAoB,SAAS;AAElD,QAAM,QAAQ,cAAc,UAAU,UAAU,WAAW,kBAAkB,YAAY;AACzF,QAAM,WAAW,MAAM,QAAQ,CAAC,MAAM,EAAE,WAAW,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;AAE9E,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP,eAAgB,OAAO,YAAwC,CAAC;AAAA,IAChE,aAAa;AAAA,EACf;AACF;AAWA,SAAS,iBAAiB,GAA6B;AACrD,QAAM,QAAQ,MAA4B;AACxC,QAAI,EAAE,SAAS,YAAY,EAAE,SAAS,UAAU,EAAE,SAAS,eAAe,EAAE,SAAS;AACnF,aAAO,EAAE;AACX,WAAO;AAAA,EACT,GAAG;AACH,QAAM,UAAU,OAAO,EAAE,YAAY,WAAW,EAAE,UAAU,KAAK,UAAU,EAAE,OAAO;AACpF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,GAAI,EAAE,WAAW,SAAS,EAAE,WAAW,EAAE,UAAU,IAAI,CAAC;AAAA,IACxD,GA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