footprint-explainable-ui 0.18.1 → 0.20.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/adapters/fromRuntimeSnapshot.d.ts +33 -4
- package/dist/adapters/fromRuntimeSnapshot.d.ts.map +1 -1
- package/dist/adapters/fromRuntimeSnapshot.js +162 -33
- package/dist/adapters/fromRuntimeSnapshot.js.map +1 -1
- package/dist/components/ExplainableShell/ExplainableShell.d.ts +157 -14
- package/dist/components/ExplainableShell/ExplainableShell.d.ts.map +1 -1
- package/dist/components/ExplainableShell/ExplainableShell.js +676 -68
- package/dist/components/ExplainableShell/ExplainableShell.js.map +1 -1
- package/dist/components/ExplainableShell/index.d.ts +1 -1
- package/dist/components/ExplainableShell/index.d.ts.map +1 -1
- package/dist/components/FlowchartView/SubflowTree.d.ts +7 -14
- package/dist/components/FlowchartView/SubflowTree.d.ts.map +1 -1
- package/dist/components/FlowchartView/SubflowTree.js +56 -46
- package/dist/components/FlowchartView/SubflowTree.js.map +1 -1
- package/dist/components/FlowchartView/index.d.ts +32 -4
- package/dist/components/FlowchartView/index.d.ts.map +1 -1
- package/dist/components/FlowchartView/index.js +22 -2
- package/dist/components/FlowchartView/index.js.map +1 -1
- package/dist/components/FlowchartView/useSubflowNavigation.d.ts +41 -16
- package/dist/components/FlowchartView/useSubflowNavigation.d.ts.map +1 -1
- package/dist/components/FlowchartView/useSubflowNavigation.js +69 -50
- package/dist/components/FlowchartView/useSubflowNavigation.js.map +1 -1
- package/dist/components/GanttTimeline/GanttTimeline.d.ts.map +1 -1
- package/dist/components/GanttTimeline/GanttTimeline.js +5 -5
- package/dist/components/GanttTimeline/GanttTimeline.js.map +1 -1
- package/dist/components/MemoryInspector/MemoryInspector.d.ts.map +1 -1
- package/dist/components/MemoryInspector/MemoryInspector.js +36 -13
- package/dist/components/MemoryInspector/MemoryInspector.js.map +1 -1
- package/dist/components/NarrativeTrace/NarrativeTrace.d.ts.map +1 -1
- package/dist/components/NarrativeTrace/NarrativeTrace.js +24 -17
- package/dist/components/NarrativeTrace/NarrativeTrace.js.map +1 -1
- package/dist/components/ScopeDiff/ScopeDiff.js +3 -3
- package/dist/components/ScopeDiff/ScopeDiff.js.map +1 -1
- package/dist/components/StageNode/StageNode.d.ts +21 -0
- package/dist/components/StageNode/StageNode.d.ts.map +1 -1
- package/dist/components/StageNode/StageNode.js +189 -9
- package/dist/components/StageNode/StageNode.js.map +1 -1
- package/dist/components/TimeTravelControls/TimeTravelControls.d.ts.map +1 -1
- package/dist/components/TimeTravelControls/TimeTravelControls.js +19 -3
- package/dist/components/TimeTravelControls/TimeTravelControls.js.map +1 -1
- package/dist/components/TimeTravelDebugger/TimeTravelDebugger.d.ts +19 -8
- package/dist/components/TimeTravelDebugger/TimeTravelDebugger.d.ts.map +1 -1
- package/dist/components/TimeTravelDebugger/TimeTravelDebugger.js +23 -8
- package/dist/components/TimeTravelDebugger/TimeTravelDebugger.js.map +1 -1
- package/dist/flowchart.cjs +3512 -1341
- package/dist/flowchart.cjs.map +1 -1
- package/dist/flowchart.d.cts +1682 -176
- package/dist/flowchart.d.ts +1682 -176
- package/dist/flowchart.d.ts.map +1 -1
- package/dist/flowchart.js +3553 -1404
- package/dist/flowchart.js.map +1 -1
- package/dist/index.cjs +755 -556
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +277 -29
- package/dist/index.d.ts +277 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +748 -546
- package/dist/index.js.map +1 -1
- package/dist/theme/ThemeProvider.d.ts +14 -0
- package/dist/theme/ThemeProvider.d.ts.map +1 -1
- package/dist/theme/ThemeProvider.js +15 -1
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/index.d.ts +4 -2
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +3 -2
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/presets.d.ts +3 -0
- package/dist/theme/presets.d.ts.map +1 -1
- package/dist/theme/presets.js +22 -0
- package/dist/theme/presets.js.map +1 -1
- package/dist/theme/tokens.d.ts +22 -1
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +23 -2
- package/dist/theme/tokens.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/components/FlowchartView/FlowchartView.d.ts +0 -20
- package/dist/components/FlowchartView/FlowchartView.d.ts.map +0 -1
- package/dist/components/FlowchartView/FlowchartView.js +0 -80
- package/dist/components/FlowchartView/FlowchartView.js.map +0 -1
- package/dist/components/FlowchartView/TracedFlowchartView.d.ts +0 -20
- package/dist/components/FlowchartView/TracedFlowchartView.d.ts.map +0 -1
- package/dist/components/FlowchartView/TracedFlowchartView.js +0 -101
- package/dist/components/FlowchartView/TracedFlowchartView.js.map +0 -1
- package/dist/components/FlowchartView/specToReactFlow.d.ts +0 -56
- package/dist/components/FlowchartView/specToReactFlow.d.ts.map +0 -1
- package/dist/components/FlowchartView/specToReactFlow.js +0 -202
- package/dist/components/FlowchartView/specToReactFlow.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StageSnapshot } from "../types";
|
|
1
|
+
import type { StageSnapshot, NarrativeEntry } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Shape of FootPrint's RuntimeSnapshot (from FlowChartExecutor.getSnapshot()).
|
|
4
4
|
* We define it here instead of importing to avoid a hard dependency on footprintjs.
|
|
@@ -8,6 +8,8 @@ interface RuntimeStageSnapshot {
|
|
|
8
8
|
name?: string;
|
|
9
9
|
isDecider?: boolean;
|
|
10
10
|
isFork?: boolean;
|
|
11
|
+
/** User-level writes made by this stage (pre-namespace keys → values). */
|
|
12
|
+
stageWrites?: Record<string, unknown>;
|
|
11
13
|
logs: Record<string, unknown>;
|
|
12
14
|
errors: Record<string, unknown>;
|
|
13
15
|
metrics: Record<string, unknown>;
|
|
@@ -18,23 +20,51 @@ interface RuntimeStageSnapshot {
|
|
|
18
20
|
next?: RuntimeStageSnapshot;
|
|
19
21
|
children?: RuntimeStageSnapshot[];
|
|
20
22
|
}
|
|
23
|
+
interface RecorderSnapshot {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
data: unknown;
|
|
27
|
+
}
|
|
21
28
|
interface RuntimeSnapshot {
|
|
22
29
|
sharedState: Record<string, unknown>;
|
|
23
30
|
executionTree: RuntimeStageSnapshot;
|
|
24
31
|
commitLog: unknown[];
|
|
32
|
+
/** Per-subflow execution results (keyed by subflowId). */
|
|
33
|
+
subflowResults?: Record<string, unknown>;
|
|
34
|
+
/** Snapshots from recorders that implement toSnapshot() (e.g. MetricRecorder). */
|
|
35
|
+
recorders?: RecorderSnapshot[];
|
|
25
36
|
}
|
|
37
|
+
export type { NarrativeEntry } from '../types';
|
|
26
38
|
/**
|
|
27
39
|
* Converts a FootPrint RuntimeSnapshot into a flat array of StageSnapshots
|
|
28
40
|
* suitable for visualization components.
|
|
29
41
|
*
|
|
42
|
+
* The `narrativeEntries` parameter (from `executor.getNarrativeEntries()`)
|
|
43
|
+
* distributes the library's rich combined narrative per-stage.
|
|
44
|
+
* When narrative is not enabled, stages get "Narrative not available" —
|
|
45
|
+
* this adapter reflects what the library produces, nothing more.
|
|
46
|
+
*
|
|
30
47
|
* Usage:
|
|
31
48
|
* ```ts
|
|
32
49
|
* const executor = new FlowChartExecutor(chart);
|
|
33
50
|
* await executor.run();
|
|
34
|
-
* const snapshots = toVisualizationSnapshots(
|
|
51
|
+
* const snapshots = toVisualizationSnapshots(
|
|
52
|
+
* executor.getSnapshot(),
|
|
53
|
+
* executor.getNarrativeEntries(),
|
|
54
|
+
* );
|
|
35
55
|
* ```
|
|
36
56
|
*/
|
|
37
|
-
export declare function toVisualizationSnapshots(runtime: RuntimeSnapshot): StageSnapshot[];
|
|
57
|
+
export declare function toVisualizationSnapshots(runtime: RuntimeSnapshot, narrativeEntries?: NarrativeEntry[]): StageSnapshot[];
|
|
58
|
+
/**
|
|
59
|
+
* Converts a footprintjs SubflowResult (stored on StageSnapshot.subflowResult)
|
|
60
|
+
* into visualization snapshots for drill-down views.
|
|
61
|
+
*
|
|
62
|
+
* SubflowResult shape (from footprintjs):
|
|
63
|
+
* { subflowId, subflowName, treeContext: { globalContext, stageContexts, history }, parentStageId }
|
|
64
|
+
*
|
|
65
|
+
* Returns empty array if the input is not a valid SubflowResult.
|
|
66
|
+
*/
|
|
67
|
+
export declare function subflowResultToSnapshots(subflowResult: unknown, narrativeEntries?: NarrativeEntry[]): StageSnapshot[];
|
|
38
68
|
/**
|
|
39
69
|
* Creates StageSnapshots from simple arrays (when you don't have a RuntimeSnapshot).
|
|
40
70
|
* Useful for testing or custom data sources.
|
|
@@ -48,5 +78,4 @@ export declare function createSnapshots(stages: Array<{
|
|
|
48
78
|
description?: string;
|
|
49
79
|
subflowId?: string;
|
|
50
80
|
}>): StageSnapshot[];
|
|
51
|
-
export {};
|
|
52
81
|
//# sourceMappingURL=fromRuntimeSnapshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromRuntimeSnapshot.d.ts","sourceRoot":"","sources":["../../src/adapters/fromRuntimeSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"fromRuntimeSnapshot.d.ts","sourceRoot":"","sources":["../../src/adapters/fromRuntimeSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE9D;;;GAGG;AACH,UAAU,oBAAoB;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,MAAM,CA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AgB,eAAe,CAC7B,MAAM,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,GACD,aAAa,EAAE,CAkBjB"}
|
|
@@ -2,34 +2,142 @@
|
|
|
2
2
|
* Converts a FootPrint RuntimeSnapshot into a flat array of StageSnapshots
|
|
3
3
|
* suitable for visualization components.
|
|
4
4
|
*
|
|
5
|
+
* The `narrativeEntries` parameter (from `executor.getNarrativeEntries()`)
|
|
6
|
+
* distributes the library's rich combined narrative per-stage.
|
|
7
|
+
* When narrative is not enabled, stages get "Narrative not available" —
|
|
8
|
+
* this adapter reflects what the library produces, nothing more.
|
|
9
|
+
*
|
|
5
10
|
* Usage:
|
|
6
11
|
* ```ts
|
|
7
12
|
* const executor = new FlowChartExecutor(chart);
|
|
8
13
|
* await executor.run();
|
|
9
|
-
* const snapshots = toVisualizationSnapshots(
|
|
14
|
+
* const snapshots = toVisualizationSnapshots(
|
|
15
|
+
* executor.getSnapshot(),
|
|
16
|
+
* executor.getNarrativeEntries(),
|
|
17
|
+
* );
|
|
10
18
|
* ```
|
|
11
19
|
*/
|
|
12
|
-
export function toVisualizationSnapshots(runtime) {
|
|
20
|
+
export function toVisualizationSnapshots(runtime, narrativeEntries) {
|
|
21
|
+
const stageNarrativeMap = narrativeEntries?.length
|
|
22
|
+
? buildStageNarrativeMap(narrativeEntries)
|
|
23
|
+
: new Map();
|
|
24
|
+
// Extract per-stage timings from MetricRecorder if present in snapshot.recorders.
|
|
25
|
+
const stageTimings = extractStageTimings(runtime.recorders);
|
|
13
26
|
const snapshots = [];
|
|
14
|
-
flattenTree(runtime.executionTree, snapshots, runtime.sharedState);
|
|
27
|
+
flattenTree(runtime.executionTree, snapshots, runtime.sharedState, 0, runtime.subflowResults, {}, stageNarrativeMap, stageTimings);
|
|
15
28
|
return snapshots;
|
|
16
29
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Extracts per-stage duration data from recorder snapshots.
|
|
32
|
+
*
|
|
33
|
+
* Post-KeyedRecorder MetricRecorder serializes as
|
|
34
|
+
* { name: 'Metrics', data: { steps: { [runtimeStageId]: { stageName, duration, ... } } } }
|
|
35
|
+
*
|
|
36
|
+
* Older versions emitted `data.stages[stageName].totalDuration` directly;
|
|
37
|
+
* we still accept that shape for back-compat when loading old snapshots.
|
|
38
|
+
*
|
|
39
|
+
* Stages that ran multiple times (e.g. CallLLM inside a loop) have one
|
|
40
|
+
* entry per invocation keyed by runtimeStageId — sum their durations by
|
|
41
|
+
* stageName so the GanttTimeline shows cumulative wall time per stage.
|
|
42
|
+
*/
|
|
43
|
+
function extractStageTimings(recorders) {
|
|
44
|
+
const timings = new Map();
|
|
45
|
+
if (!recorders)
|
|
46
|
+
return timings;
|
|
47
|
+
for (const rec of recorders) {
|
|
48
|
+
if (rec.name !== 'Metrics' || !rec.data || typeof rec.data !== 'object')
|
|
49
|
+
continue;
|
|
50
|
+
const data = rec.data;
|
|
51
|
+
// New shape: data.steps[runtimeStageId] = { stageName, duration, ... }
|
|
52
|
+
if (data.steps) {
|
|
53
|
+
for (const step of Object.values(data.steps)) {
|
|
54
|
+
const name = step?.stageName;
|
|
55
|
+
const d = step?.duration;
|
|
56
|
+
if (!name || typeof d !== 'number' || d <= 0)
|
|
57
|
+
continue;
|
|
58
|
+
timings.set(name, Math.round((timings.get(name) ?? 0) + d));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Legacy shape: data.stages[stageName].totalDuration
|
|
62
|
+
if (data.stages) {
|
|
63
|
+
for (const [stageName, metrics] of Object.entries(data.stages)) {
|
|
64
|
+
if (typeof metrics.totalDuration === 'number' && metrics.totalDuration > 0) {
|
|
65
|
+
timings.set(stageName, Math.round(metrics.totalDuration));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return timings;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Groups narrative entries by stage name, preserving non-stage entries
|
|
74
|
+
* (conditions, forks) attached to the preceding stage.
|
|
75
|
+
*/
|
|
76
|
+
function buildStageNarrativeMap(entries) {
|
|
77
|
+
const map = new Map();
|
|
78
|
+
let currentStageName;
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
if (entry.stageName) {
|
|
81
|
+
currentStageName = entry.stageName;
|
|
82
|
+
}
|
|
83
|
+
if (currentStageName) {
|
|
84
|
+
if (!map.has(currentStageName)) {
|
|
85
|
+
map.set(currentStageName, []);
|
|
86
|
+
}
|
|
87
|
+
const indent = ' '.repeat(entry.depth);
|
|
88
|
+
map.get(currentStageName).push(`${indent}${entry.text}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return map;
|
|
92
|
+
}
|
|
93
|
+
function flattenTree(node, out, sharedState, accumulatedMs = 0, subflowResults, cumulativeMemory = {}, stageNarrativeMap = new Map(), stageTimings = new Map()) {
|
|
94
|
+
// Prefer MetricRecorder timing (real wall-clock), then scope.$metric('durationMs'), then 0.
|
|
95
|
+
const stageName = node.name ?? node.id;
|
|
96
|
+
const durationMs = (stageName ? stageTimings.get(stageName) : undefined) ??
|
|
97
|
+
(typeof node.metrics?.durationMs === "number" ? node.metrics.durationMs : 0);
|
|
22
98
|
const startMs = accumulatedMs;
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
99
|
+
// Use id for matching (stable, matches spec node ids).
|
|
100
|
+
// name may carry display prefixes like "[service-name] STAGE".
|
|
101
|
+
const stageId = node.id || node.name || 'unknown';
|
|
102
|
+
const displayName = node.name || node.id || 'unknown';
|
|
103
|
+
// Narrative comes from the library. When not available (e.g. subflow internals
|
|
104
|
+
// where the root recorder only captures enter/exit markers), build a basic
|
|
105
|
+
// narrative from the stage name, description, and data operations.
|
|
106
|
+
// Try id first, then name — narrative entries use node.name (may be prefixed)
|
|
107
|
+
// while snapshot uses node.id (stable). Both need to match for subflows.
|
|
108
|
+
const stageLines = stageNarrativeMap.get(stageId) ?? stageNarrativeMap.get(displayName);
|
|
109
|
+
let narrative;
|
|
110
|
+
if (stageLines) {
|
|
111
|
+
narrative = stageLines.join('\n');
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
const parts = [`${displayName} executed.`];
|
|
115
|
+
if (node.description)
|
|
116
|
+
parts.push(node.description);
|
|
117
|
+
if (node.stageWrites) {
|
|
118
|
+
const keys = Object.keys(node.stageWrites);
|
|
119
|
+
if (keys.length > 0)
|
|
120
|
+
parts.push(`Wrote: ${keys.join(', ')}`);
|
|
121
|
+
}
|
|
122
|
+
narrative = parts.join('\n');
|
|
29
123
|
}
|
|
124
|
+
// Build cumulative memory from stageWrites (actual setValue/updateValue calls)
|
|
125
|
+
const memory = { ...cumulativeMemory };
|
|
126
|
+
if (node.stageWrites) {
|
|
127
|
+
for (const [key, value] of Object.entries(node.stageWrites)) {
|
|
128
|
+
if (value === undefined) {
|
|
129
|
+
delete memory[key];
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
memory[key] = value;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const sfResult = subflowResults?.[node.subflowId ?? stageId];
|
|
30
137
|
out.push({
|
|
31
|
-
stageName:
|
|
32
|
-
stageLabel:
|
|
138
|
+
stageName: displayName,
|
|
139
|
+
stageLabel: stageId,
|
|
140
|
+
runtimeStageId: node.runtimeStageId ?? undefined,
|
|
33
141
|
memory,
|
|
34
142
|
narrative,
|
|
35
143
|
startMs,
|
|
@@ -37,39 +145,60 @@ function flattenTree(node, out, sharedState, accumulatedMs = 0) {
|
|
|
37
145
|
status: "done",
|
|
38
146
|
...(node.description ? { description: node.description } : undefined),
|
|
39
147
|
...(node.subflowId ? { subflowId: node.subflowId } : undefined),
|
|
148
|
+
...(sfResult ? { subflowResult: sfResult } : undefined),
|
|
40
149
|
});
|
|
41
150
|
let nextMs = startMs + durationMs;
|
|
42
151
|
// Handle parallel children (fork)
|
|
43
152
|
if (node.children && node.children.length > 0) {
|
|
44
153
|
let maxChildEnd = nextMs;
|
|
45
154
|
for (const child of node.children) {
|
|
46
|
-
const childEnd = flattenTree(child, out, sharedState, nextMs);
|
|
155
|
+
const childEnd = flattenTree(child, out, sharedState, nextMs, subflowResults, memory, stageNarrativeMap, stageTimings);
|
|
47
156
|
maxChildEnd = Math.max(maxChildEnd, childEnd);
|
|
48
157
|
}
|
|
49
158
|
nextMs = maxChildEnd;
|
|
50
159
|
}
|
|
51
160
|
// Handle linear continuation
|
|
52
161
|
if (node.next) {
|
|
53
|
-
nextMs = flattenTree(node.next, out, sharedState, nextMs);
|
|
162
|
+
nextMs = flattenTree(node.next, out, sharedState, nextMs, subflowResults, memory, stageNarrativeMap, stageTimings);
|
|
54
163
|
}
|
|
55
164
|
return nextMs;
|
|
56
165
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Converts a footprintjs SubflowResult (stored on StageSnapshot.subflowResult)
|
|
168
|
+
* into visualization snapshots for drill-down views.
|
|
169
|
+
*
|
|
170
|
+
* SubflowResult shape (from footprintjs):
|
|
171
|
+
* { subflowId, subflowName, treeContext: { globalContext, stageContexts, history }, parentStageId }
|
|
172
|
+
*
|
|
173
|
+
* Returns empty array if the input is not a valid SubflowResult.
|
|
174
|
+
*/
|
|
175
|
+
export function subflowResultToSnapshots(subflowResult, narrativeEntries) {
|
|
176
|
+
if (!subflowResult || typeof subflowResult !== 'object')
|
|
177
|
+
return [];
|
|
178
|
+
const sf = subflowResult;
|
|
179
|
+
if (!sf.treeContext?.stageContexts)
|
|
180
|
+
return [];
|
|
181
|
+
const runtime = {
|
|
182
|
+
sharedState: sf.treeContext.globalContext ?? {},
|
|
183
|
+
executionTree: sf.treeContext.stageContexts,
|
|
184
|
+
commitLog: sf.treeContext.history ?? [],
|
|
185
|
+
};
|
|
186
|
+
const snapshots = toVisualizationSnapshots(runtime, narrativeEntries);
|
|
187
|
+
// Strip subflow prefix from stage names so they match the spec node names.
|
|
188
|
+
// Runtime names are prefixed (e.g., "analyze/SeedScope") but spec nodes
|
|
189
|
+
// use unprefixed names (e.g., "SeedScope").
|
|
190
|
+
const prefix = sf.subflowId ? `${sf.subflowId}/` : '';
|
|
191
|
+
if (prefix) {
|
|
192
|
+
for (const snap of snapshots) {
|
|
193
|
+
if (snap.stageName.startsWith(prefix)) {
|
|
194
|
+
snap.stageName = snap.stageName.slice(prefix.length);
|
|
195
|
+
}
|
|
196
|
+
if (snap.stageLabel.startsWith(prefix)) {
|
|
197
|
+
snap.stageLabel = snap.stageLabel.slice(prefix.length);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
71
200
|
}
|
|
72
|
-
return
|
|
201
|
+
return snapshots;
|
|
73
202
|
}
|
|
74
203
|
/**
|
|
75
204
|
* Creates StageSnapshots from simple arrays (when you don't have a RuntimeSnapshot).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromRuntimeSnapshot.js","sourceRoot":"","sources":["../../src/adapters/fromRuntimeSnapshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fromRuntimeSnapshot.js","sourceRoot":"","sources":["../../src/adapters/fromRuntimeSnapshot.ts"],"names":[],"mappings":"AA4CA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAA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,CAAC,CAAC;QACnC,MAAM,IAAI,GAAkB;YAC1B,SAAS,EAAE,CAAC,CAAC,IAAI;YACjB,UAAU,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI;YAC7B,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,EAAE;YACtB,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,aAAa;YAC3D,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,QAAQ;YACpB,MAAM,EAAE,MAAM;YACd,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YAC/D,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;SAC1D,CAAC;QACF,KAAK,IAAI,QAAQ,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,26 +1,169 @@
|
|
|
1
|
-
import type { StageSnapshot, BaseComponentProps } from "../../types";
|
|
2
|
-
|
|
1
|
+
import type { StageSnapshot, BaseComponentProps, NarrativeEntry } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Minimal subflow-walking spec shape. Used INTERNALLY by drill-down
|
|
4
|
+
* resolution (which navigates `subflowStructure` to find a child chart
|
|
5
|
+
* inside the parent's serialized structure). No longer used for chart
|
|
6
|
+
* rendering — that happens via `traceGraph` + `<TracedFlow>` exclusively.
|
|
7
|
+
*
|
|
8
|
+
* Kept as a local type so the file no longer depends on any legacy
|
|
9
|
+
* spec-walk module.
|
|
10
|
+
*/
|
|
11
|
+
export interface SpecNode {
|
|
12
|
+
name: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
children?: SpecNode[];
|
|
16
|
+
next?: SpecNode;
|
|
17
|
+
isSubflowRoot?: boolean;
|
|
18
|
+
subflowId?: string;
|
|
19
|
+
subflowName?: string;
|
|
20
|
+
subflowStructure?: SpecNode;
|
|
21
|
+
}
|
|
22
|
+
/** Tab ID — "result", "memory", "narrative", or any custom recorder view ID. */
|
|
23
|
+
export type ShellTab = string;
|
|
24
|
+
export interface PanelLabels {
|
|
25
|
+
/** Left panel pill label (subflow tree). Default: "Topology" */
|
|
26
|
+
topology?: string;
|
|
27
|
+
/** Right panel pill label (memory/narrative). Default: "Details" */
|
|
28
|
+
details?: string;
|
|
29
|
+
/** Bottom panel pill label (timeline). Default: "Timeline" */
|
|
30
|
+
timeline?: string;
|
|
31
|
+
}
|
|
32
|
+
/** Which panels start expanded. Default: `{ details: true }` (flowchart + memory). */
|
|
33
|
+
export interface DefaultExpanded {
|
|
34
|
+
topology?: boolean;
|
|
35
|
+
details?: boolean;
|
|
36
|
+
timeline?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Raw runtime snapshot from FlowChartExecutor.getSnapshot().
|
|
40
|
+
* When provided, ExplainableShell converts it internally — zero boilerplate.
|
|
41
|
+
*/
|
|
42
|
+
export interface RuntimeSnapshotInput {
|
|
43
|
+
sharedState: Record<string, unknown>;
|
|
44
|
+
executionTree: unknown;
|
|
45
|
+
commitLog: unknown[];
|
|
46
|
+
subflowResults?: Record<string, unknown>;
|
|
47
|
+
/** Recorder snapshots from toSnapshot() — auto-generates detail tabs. */
|
|
48
|
+
recorders?: Array<{
|
|
49
|
+
id: string;
|
|
50
|
+
name: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
preferredOperation?: 'translate' | 'accumulate' | 'aggregate';
|
|
53
|
+
data: unknown;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A recorder view that appears as a tab in the details panel.
|
|
58
|
+
* Each recorder provides its own per-stage rendering.
|
|
59
|
+
* Memory and Narrative are built-in defaults — add more via this prop.
|
|
60
|
+
*/
|
|
61
|
+
export interface RecorderView {
|
|
62
|
+
/** Unique key for this view tab */
|
|
63
|
+
id: string;
|
|
64
|
+
/** Display label on the tab */
|
|
65
|
+
name: string;
|
|
66
|
+
/** Short description shown as tooltip and header for auto-detected views.
|
|
67
|
+
* e.g., "Per-step timing and I/O counts (KeyedRecorder)" */
|
|
68
|
+
description?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Render function — receives the current snapshot index and all snapshots.
|
|
71
|
+
* Return a React node to display in the details panel.
|
|
72
|
+
*/
|
|
73
|
+
render: (props: {
|
|
74
|
+
snapshots: StageSnapshot[];
|
|
75
|
+
selectedIndex: number;
|
|
76
|
+
}) => React.ReactNode;
|
|
77
|
+
}
|
|
3
78
|
export interface ExplainableShellProps extends BaseComponentProps {
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Pre-converted visualization snapshots. Use when you've already called
|
|
81
|
+
* toVisualizationSnapshots() yourself.
|
|
82
|
+
*/
|
|
83
|
+
snapshots?: StageSnapshot[];
|
|
84
|
+
/**
|
|
85
|
+
* Raw runtime snapshot from executor.getSnapshot(). The shell converts it
|
|
86
|
+
* internally via toVisualizationSnapshots(). When provided, `snapshots`
|
|
87
|
+
* and `resultData` are derived automatically. Pair with
|
|
88
|
+
* `narrativeEntries` for rich per-stage narrative.
|
|
89
|
+
*
|
|
90
|
+
* Usage: `<ExplainableShell runtimeSnapshot={executor.getSnapshot()} narrativeEntries={executor.getNarrativeEntries()} spec={spec} />`
|
|
91
|
+
*/
|
|
92
|
+
runtimeSnapshot?: RuntimeSnapshotInput | null;
|
|
93
|
+
spec?: SpecNode | null;
|
|
94
|
+
/**
|
|
95
|
+
* Build-time graph captured live via `createTraceStructureRecorder`.
|
|
96
|
+
* REQUIRED for chart rendering (v6+) — the legacy `spec` →
|
|
97
|
+
* legacy spec-walk post-walk path was removed in favor of this
|
|
98
|
+
* recorder-driven graph.
|
|
99
|
+
*
|
|
100
|
+
* Pair with `runtimeOverlay` for the full time-travel trace UI.
|
|
101
|
+
* When `traceGraph` is set but `runtimeOverlay` is absent, the
|
|
102
|
+
* chart renders without runtime coloring (build-time-only view).
|
|
103
|
+
*
|
|
104
|
+
* The `spec` prop, when also provided, is used INTERNALLY for
|
|
105
|
+
* subflow drill-down resolution (navigating `subflowStructure` to
|
|
106
|
+
* find a child chart inside the parent's serialized structure) —
|
|
107
|
+
* NOT for rendering.
|
|
108
|
+
*/
|
|
109
|
+
traceGraph?: import("../FlowchartView/traceStructureRecorder").TraceGraph | null;
|
|
110
|
+
/**
|
|
111
|
+
* Runtime overlay captured live via `createTraceRuntimeOverlay`.
|
|
112
|
+
* Pair with `traceGraph` to drive `<TracedFlow>` for the full
|
|
113
|
+
* time-travel trace UI.
|
|
114
|
+
*/
|
|
115
|
+
runtimeOverlay?: import("../FlowchartView/createTraceRuntimeOverlay").RuntimeOverlay | null;
|
|
116
|
+
title?: string;
|
|
7
117
|
resultData?: Record<string, unknown> | null;
|
|
8
|
-
/** Console log lines */
|
|
9
118
|
logs?: string[];
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
|
|
119
|
+
/** Structured narrative entries from `executor.getNarrativeEntries()`.
|
|
120
|
+
* This is the only narrative input — the flat-string form was
|
|
121
|
+
* removed; call `.map(e => e.text)` if you need it. */
|
|
122
|
+
narrativeEntries?: NarrativeEntry[];
|
|
13
123
|
tabs?: ShellTab[];
|
|
14
|
-
/** Initially active tab */
|
|
15
124
|
defaultTab?: ShellTab;
|
|
16
|
-
/** Hide console in result tab */
|
|
17
125
|
hideConsole?: boolean;
|
|
18
|
-
/**
|
|
126
|
+
/** Hide specific detail tabs (e.g., ['result', 'memory']). */
|
|
127
|
+
hideTabs?: string[];
|
|
128
|
+
/** Customize the labels on collapsible panel pills */
|
|
129
|
+
panelLabels?: PanelLabels;
|
|
130
|
+
/** Which panels start expanded. Default: `{ details: true }` */
|
|
131
|
+
defaultExpanded?: DefaultExpanded;
|
|
132
|
+
/**
|
|
133
|
+
* Recorder views — each becomes a tab in the details panel.
|
|
134
|
+
* Default: Memory + Narrative. Pass additional recorder views
|
|
135
|
+
* to show tokens, cost, tools, permissions, or custom data.
|
|
136
|
+
*
|
|
137
|
+
* Usage:
|
|
138
|
+
* recorderViews={[
|
|
139
|
+
* { id: 'tokens', name: 'Tokens', render: ({ selectedIndex }) => <div>...</div> },
|
|
140
|
+
* ]}
|
|
141
|
+
*/
|
|
142
|
+
recorderViews?: RecorderView[];
|
|
143
|
+
/**
|
|
144
|
+
* Custom flowchart renderer. When omitted, ExplainableShell renders
|
|
145
|
+
* via `<TracedFlow graph={traceGraph} overlay={runtimeOverlay} />` —
|
|
146
|
+
* the recorder-driven path. Override to plug a custom chart UI; the
|
|
147
|
+
* `spec` parameter is forwarded only for backward-compatible
|
|
148
|
+
* signatures (it's the same SpecNode used for drill-down) and may
|
|
149
|
+
* be `null` once consumers stop threading it in.
|
|
150
|
+
*/
|
|
19
151
|
renderFlowchart?: (props: {
|
|
152
|
+
spec: SpecNode | null;
|
|
20
153
|
snapshots: StageSnapshot[];
|
|
21
154
|
selectedIndex: number;
|
|
22
|
-
onNodeClick?: (
|
|
155
|
+
onNodeClick?: (indexOrId: number | string) => void;
|
|
156
|
+
showStageId?: boolean;
|
|
23
157
|
}) => React.ReactNode;
|
|
158
|
+
/**
|
|
159
|
+
* When true, render each node's stable `stageId` as a small monospace
|
|
160
|
+
* caption beneath the label in the default flowchart renderer.
|
|
161
|
+
* Teaching aid: it reveals the key recorders use
|
|
162
|
+
* (`runtimeStageId = [subflowPath/]stageId#executionIndex`) so a
|
|
163
|
+
* consumer can map any recorder's per-stage data back to a node.
|
|
164
|
+
* Default false.
|
|
165
|
+
*/
|
|
166
|
+
showStageId?: boolean;
|
|
24
167
|
}
|
|
25
|
-
export declare function ExplainableShell({ snapshots, resultData, logs,
|
|
168
|
+
export declare function ExplainableShell({ snapshots: snapshotsProp, runtimeSnapshot, spec, title, resultData: resultDataProp, logs, narrativeEntries, tabs, defaultTab, hideConsole, hideTabs: hideTabsProp, panelLabels, defaultExpanded, recorderViews, renderFlowchart, showStageId, traceGraph, runtimeOverlay, size, unstyled, className, style, }: ExplainableShellProps): import("react/jsx-runtime").JSX.Element;
|
|
26
169
|
//# sourceMappingURL=ExplainableShell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExplainableShell.d.ts","sourceRoot":"","sources":["../../../src/components/ExplainableShell/ExplainableShell.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExplainableShell.d.ts","sourceRoot":"","sources":["../../../src/components/ExplainableShell/ExplainableShell.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAarF;;;;;;;;GAQG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,QAAQ,CAAC;CAC7B;AASD,gFAAgF;AAChF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAc9B,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,OAAO,C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