@railtownai/railtracks-visualizer 0.0.1
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/LICENSE +201 -0
- package/README.md +23 -0
- package/dist/AgenticFlowVisualizer.d.ts +12 -0
- package/dist/AgenticFlowVisualizer.d.ts.map +1 -0
- package/dist/AgenticFlowVisualizer.js +710 -0
- package/dist/App.d.ts +4 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +89 -0
- package/dist/components/Edge.d.ts +30 -0
- package/dist/components/Edge.d.ts.map +1 -0
- package/dist/components/Edge.js +74 -0
- package/dist/components/FileSelector.d.ts +13 -0
- package/dist/components/FileSelector.d.ts.map +1 -0
- package/dist/components/FileSelector.js +24 -0
- package/dist/components/Node.d.ts +20 -0
- package/dist/components/Node.d.ts.map +1 -0
- package/dist/components/Node.js +100 -0
- package/dist/components/Timeline.d.ts +15 -0
- package/dist/components/Timeline.d.ts.map +1 -0
- package/dist/components/Timeline.js +118 -0
- package/dist/components/VerticalTimeline.d.ts +14 -0
- package/dist/components/VerticalTimeline.d.ts.map +1 -0
- package/dist/components/VerticalTimeline.js +156 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useApi.d.ts +17 -0
- package/dist/hooks/useApi.d.ts.map +1 -0
- package/dist/hooks/useApi.js +95 -0
- package/dist/hooks/useFlowData.d.ts +82 -0
- package/dist/hooks/useFlowData.d.ts.map +1 -0
- package/dist/hooks/useFlowData.js +66 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/test/setup.d.ts +2 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/test/setup.js +22 -0
- package/package.json +78 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PanelLeft } from "lucide-react";
|
|
3
|
+
const VerticalTimeline = ({ stamps, currentStep, onStepChange, onToggle }) => {
|
|
4
|
+
const maxStep = stamps.length > 0 ? Math.max(...stamps.map((s) => s.step)) : 0;
|
|
5
|
+
const minStep = stamps.length > 0 ? Math.min(...stamps.map((s) => s.step)) : 0;
|
|
6
|
+
const totalSteps = maxStep - minStep + 1;
|
|
7
|
+
// Calculate latency for each step
|
|
8
|
+
const getStepLatency = (step) => {
|
|
9
|
+
const stepStamps = stamps.filter((s) => s.step === step);
|
|
10
|
+
if (stepStamps.length === 0)
|
|
11
|
+
return null;
|
|
12
|
+
// Calculate time difference from previous step
|
|
13
|
+
const prevStep = step - 1;
|
|
14
|
+
const prevStepStamps = stamps.filter((s) => s.step === prevStep);
|
|
15
|
+
if (prevStepStamps.length === 0)
|
|
16
|
+
return null;
|
|
17
|
+
const currentTime = Math.min(...stepStamps.map((s) => s.time));
|
|
18
|
+
const prevTime = Math.max(...prevStepStamps.map((s) => s.time));
|
|
19
|
+
return currentTime - prevTime;
|
|
20
|
+
};
|
|
21
|
+
// Get step label
|
|
22
|
+
const getStepLabel = (step) => {
|
|
23
|
+
const stepStamps = stamps.filter((s) => s.step === step);
|
|
24
|
+
if (stepStamps.length === 0)
|
|
25
|
+
return `Step ${step}`;
|
|
26
|
+
// Get the first identifier for this step
|
|
27
|
+
const identifier = stepStamps[0]?.identifier || "";
|
|
28
|
+
return identifier || `Step ${step}`;
|
|
29
|
+
};
|
|
30
|
+
// Format latency
|
|
31
|
+
const formatLatency = (latency) => {
|
|
32
|
+
if (latency < 1000) {
|
|
33
|
+
return `${latency.toFixed(0)}ms`;
|
|
34
|
+
}
|
|
35
|
+
else if (latency < 60000) {
|
|
36
|
+
return `${(latency / 1000).toFixed(1)}s`;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return `${(latency / 60000).toFixed(1)}m`;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return (_jsxs("div", { style: {
|
|
43
|
+
width: "100%",
|
|
44
|
+
height: "100%",
|
|
45
|
+
backgroundColor: "white",
|
|
46
|
+
display: "flex",
|
|
47
|
+
flexDirection: "column",
|
|
48
|
+
overflow: "hidden"
|
|
49
|
+
}, children: [_jsxs("div", { style: {
|
|
50
|
+
padding: "16px",
|
|
51
|
+
borderBottom: "1px solid #e5e7eb",
|
|
52
|
+
backgroundColor: "#f9fafb",
|
|
53
|
+
display: "flex",
|
|
54
|
+
justifyContent: "space-between",
|
|
55
|
+
alignItems: "flex-start"
|
|
56
|
+
}, children: [_jsxs("div", { children: [_jsx("h3", { style: {
|
|
57
|
+
margin: 0,
|
|
58
|
+
fontSize: "16px",
|
|
59
|
+
fontWeight: 600,
|
|
60
|
+
color: "#1f2937"
|
|
61
|
+
}, children: "Timeline" }), _jsx("p", { style: {
|
|
62
|
+
margin: "4px 0 0 0",
|
|
63
|
+
fontSize: "12px",
|
|
64
|
+
color: "#6b7280"
|
|
65
|
+
}, children: "Click to jump to step" })] }), onToggle && (_jsx("button", { onClick: onToggle, style: {
|
|
66
|
+
border: "none",
|
|
67
|
+
background: "none",
|
|
68
|
+
cursor: "pointer",
|
|
69
|
+
color: "#6b7280",
|
|
70
|
+
padding: "4px",
|
|
71
|
+
display: "flex",
|
|
72
|
+
alignItems: "center",
|
|
73
|
+
justifyContent: "center",
|
|
74
|
+
transition: "color 0.2s ease"
|
|
75
|
+
}, title: "Collapse Panel", children: _jsx(PanelLeft, { size: 16 }) }))] }), _jsx("div", { style: {
|
|
76
|
+
flex: 1,
|
|
77
|
+
overflowY: "auto",
|
|
78
|
+
padding: "8px 0 16px 0" // Add bottom padding
|
|
79
|
+
}, children: Array.from({ length: totalSteps }, (_, index) => {
|
|
80
|
+
const step = minStep + index;
|
|
81
|
+
const isActive = step === currentStep;
|
|
82
|
+
const isPast = step < currentStep;
|
|
83
|
+
const hasStep = stamps.some((s) => s.step === step);
|
|
84
|
+
const latency = getStepLatency(step);
|
|
85
|
+
const label = getStepLabel(step);
|
|
86
|
+
return (_jsxs("div", { onClick: () => hasStep && onStepChange(step), style: {
|
|
87
|
+
padding: "12px 16px",
|
|
88
|
+
borderBottom: "1px solid #f3f4f6",
|
|
89
|
+
cursor: hasStep ? "pointer" : "default",
|
|
90
|
+
backgroundColor: isActive ? "#f0f9ff" : "transparent",
|
|
91
|
+
borderLeft: isActive ? "4px solid #6366f1" : "4px solid transparent",
|
|
92
|
+
transition: "all 0.2s ease",
|
|
93
|
+
position: "relative"
|
|
94
|
+
}, onMouseEnter: (e) => {
|
|
95
|
+
if (hasStep && !isActive) {
|
|
96
|
+
e.currentTarget.style.backgroundColor = "#f8fafc";
|
|
97
|
+
}
|
|
98
|
+
}, onMouseLeave: (e) => {
|
|
99
|
+
if (hasStep && !isActive) {
|
|
100
|
+
e.currentTarget.style.backgroundColor = "transparent";
|
|
101
|
+
}
|
|
102
|
+
}, children: [_jsxs("div", { style: {
|
|
103
|
+
display: "flex",
|
|
104
|
+
alignItems: "center",
|
|
105
|
+
gap: "8px",
|
|
106
|
+
marginBottom: "4px"
|
|
107
|
+
}, children: [_jsx("div", { style: {
|
|
108
|
+
width: "12px",
|
|
109
|
+
height: "12px",
|
|
110
|
+
borderRadius: "50%",
|
|
111
|
+
backgroundColor: isActive ? "#6366f1" : isPast ? "#fbbf24" : hasStep ? "#9ca3af" : "#e5e7eb",
|
|
112
|
+
border: isActive ? "2px solid #6366f1" : "1px solid #d1d5db",
|
|
113
|
+
flexShrink: 0
|
|
114
|
+
} }), _jsxs("span", { style: {
|
|
115
|
+
fontSize: "14px",
|
|
116
|
+
fontWeight: isActive ? 600 : 500,
|
|
117
|
+
color: isActive ? "#1f2937" : "#6b7280"
|
|
118
|
+
}, children: ["Step ", step] }), latency && (_jsx("span", { style: {
|
|
119
|
+
fontSize: "11px",
|
|
120
|
+
color: "#9ca3af",
|
|
121
|
+
backgroundColor: "#f3f4f6",
|
|
122
|
+
padding: "2px 6px",
|
|
123
|
+
borderRadius: "4px",
|
|
124
|
+
marginLeft: "auto"
|
|
125
|
+
}, children: formatLatency(latency) }))] }), _jsx("div", { style: {
|
|
126
|
+
fontSize: "13px",
|
|
127
|
+
color: hasStep ? "#1f2937" : "#9ca3af",
|
|
128
|
+
lineHeight: "1.4",
|
|
129
|
+
wordBreak: "break-word",
|
|
130
|
+
fontStyle: hasStep ? "normal" : "italic"
|
|
131
|
+
}, children: hasStep ? label : "No activity" }), isActive && (_jsx("div", { style: {
|
|
132
|
+
position: "absolute",
|
|
133
|
+
right: "8px",
|
|
134
|
+
top: "50%",
|
|
135
|
+
transform: "translateY(-50%)",
|
|
136
|
+
width: "6px",
|
|
137
|
+
height: "6px",
|
|
138
|
+
borderRadius: "50%",
|
|
139
|
+
backgroundColor: "#6366f1",
|
|
140
|
+
animation: "pulse 2s infinite"
|
|
141
|
+
} }))] }, step));
|
|
142
|
+
}) }), _jsx("style", { children: `
|
|
143
|
+
@keyframes pulse {
|
|
144
|
+
0% {
|
|
145
|
+
opacity: 1;
|
|
146
|
+
}
|
|
147
|
+
50% {
|
|
148
|
+
opacity: 0.5;
|
|
149
|
+
}
|
|
150
|
+
100% {
|
|
151
|
+
opacity: 1;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
` })] }));
|
|
155
|
+
};
|
|
156
|
+
export { VerticalTimeline };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useApi } from "./useApi";
|
|
2
|
+
export { useFlowData } from "./useFlowData";
|
|
3
|
+
export type { JsonFile, ApiError } from "./useApi";
|
|
4
|
+
export type { FlowDataState, DataJsonNode, DataJsonEdge, DataJsonStructure } from "./useFlowData";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACnD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface JsonFile {
|
|
2
|
+
name: string;
|
|
3
|
+
size?: number;
|
|
4
|
+
modified?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ApiError {
|
|
7
|
+
message: string;
|
|
8
|
+
status?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const useApi: () => {
|
|
11
|
+
loading: boolean;
|
|
12
|
+
error: ApiError | null;
|
|
13
|
+
listJsonFiles: () => Promise<JsonFile[]>;
|
|
14
|
+
loadJsonFile: (filename: string) => Promise<any>;
|
|
15
|
+
triggerRefresh: () => Promise<any>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=useApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useApi.d.ts","sourceRoot":"","sources":["../../src/hooks/useApi.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,MAAM;;;yBAK2B,OAAO,CAAC,QAAQ,EAAE,CAAC;6BA6Bb,MAAM,KAAG,OAAO,CAAC,GAAG,CAAC;0BAyB1B,OAAO,CAAC,GAAG,CAAC;CAiC1D,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { useState, useCallback } from "react";
|
|
2
|
+
// Base URL for the API
|
|
3
|
+
const API_BASE = "/api";
|
|
4
|
+
export const useApi = () => {
|
|
5
|
+
const [loading, setLoading] = useState(false);
|
|
6
|
+
const [error, setError] = useState(null);
|
|
7
|
+
// Function to list all JSON files in the .railtracks directory
|
|
8
|
+
const listJsonFiles = useCallback(async () => {
|
|
9
|
+
setLoading(true);
|
|
10
|
+
setError(null);
|
|
11
|
+
try {
|
|
12
|
+
console.log("Fetching files from:", `${API_BASE}/files`);
|
|
13
|
+
const response = await fetch(`${API_BASE}/files`);
|
|
14
|
+
console.log("Response status:", response.status);
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
17
|
+
}
|
|
18
|
+
const files = await response.json();
|
|
19
|
+
console.log("Files received:", files);
|
|
20
|
+
return files;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
console.error("Error fetching files:", err);
|
|
24
|
+
const errorMessage = err instanceof Error ? err.message : "Unknown error occurred";
|
|
25
|
+
const apiError = {
|
|
26
|
+
message: errorMessage,
|
|
27
|
+
status: err instanceof Error && "status" in err ? err.status : undefined
|
|
28
|
+
};
|
|
29
|
+
setError(apiError);
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
setLoading(false);
|
|
34
|
+
}
|
|
35
|
+
}, []);
|
|
36
|
+
// Function to load a specific JSON file
|
|
37
|
+
const loadJsonFile = useCallback(async (filename) => {
|
|
38
|
+
setLoading(true);
|
|
39
|
+
setError(null);
|
|
40
|
+
try {
|
|
41
|
+
const response = await fetch(`${API_BASE}/json/${filename}`);
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
44
|
+
}
|
|
45
|
+
const data = await response.json();
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
const errorMessage = err instanceof Error ? err.message : "Unknown error occurred";
|
|
50
|
+
const apiError = {
|
|
51
|
+
message: errorMessage,
|
|
52
|
+
status: err instanceof Error && "status" in err ? err.status : undefined
|
|
53
|
+
};
|
|
54
|
+
setError(apiError);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
setLoading(false);
|
|
59
|
+
}
|
|
60
|
+
}, []);
|
|
61
|
+
// Function to trigger a frontend refresh
|
|
62
|
+
const triggerRefresh = useCallback(async () => {
|
|
63
|
+
setLoading(true);
|
|
64
|
+
setError(null);
|
|
65
|
+
try {
|
|
66
|
+
const response = await fetch(`${API_BASE}/refresh`, {
|
|
67
|
+
method: "POST"
|
|
68
|
+
});
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
71
|
+
}
|
|
72
|
+
const result = await response.json();
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
const errorMessage = err instanceof Error ? err.message : "Unknown error occurred";
|
|
77
|
+
const apiError = {
|
|
78
|
+
message: errorMessage,
|
|
79
|
+
status: err instanceof Error && "status" in err ? err.status : undefined
|
|
80
|
+
};
|
|
81
|
+
setError(apiError);
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
setLoading(false);
|
|
86
|
+
}
|
|
87
|
+
}, []);
|
|
88
|
+
return {
|
|
89
|
+
loading,
|
|
90
|
+
error,
|
|
91
|
+
listJsonFiles,
|
|
92
|
+
loadJsonFile,
|
|
93
|
+
triggerRefresh
|
|
94
|
+
};
|
|
95
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { JsonFile } from "./useApi";
|
|
2
|
+
export interface DataJsonNode {
|
|
3
|
+
identifier: string;
|
|
4
|
+
node_type: string;
|
|
5
|
+
stamp: {
|
|
6
|
+
step: number;
|
|
7
|
+
time: number;
|
|
8
|
+
identifier: string;
|
|
9
|
+
};
|
|
10
|
+
details: {
|
|
11
|
+
internals?: {
|
|
12
|
+
llm_details?: Array<{
|
|
13
|
+
model_name: string;
|
|
14
|
+
model_provider: string;
|
|
15
|
+
input: Array<{
|
|
16
|
+
role: string;
|
|
17
|
+
content: any;
|
|
18
|
+
}>;
|
|
19
|
+
output: {
|
|
20
|
+
role: string;
|
|
21
|
+
content: any;
|
|
22
|
+
};
|
|
23
|
+
input_tokens: number | null;
|
|
24
|
+
output_tokens: number | null;
|
|
25
|
+
total_cost: number | null;
|
|
26
|
+
system_fingerprint: string | null;
|
|
27
|
+
}>;
|
|
28
|
+
latency?: {
|
|
29
|
+
total_time: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
parent: DataJsonNode | null;
|
|
34
|
+
}
|
|
35
|
+
export interface DataJsonEdge {
|
|
36
|
+
identifier: string;
|
|
37
|
+
source: string | null;
|
|
38
|
+
target: string;
|
|
39
|
+
stamp: {
|
|
40
|
+
step: number;
|
|
41
|
+
time: number;
|
|
42
|
+
identifier: string;
|
|
43
|
+
};
|
|
44
|
+
details: {
|
|
45
|
+
state?: string;
|
|
46
|
+
input_args?: any[];
|
|
47
|
+
input_kwargs?: any;
|
|
48
|
+
output?: any;
|
|
49
|
+
};
|
|
50
|
+
parent: DataJsonEdge | null;
|
|
51
|
+
}
|
|
52
|
+
export interface DataJsonStructure {
|
|
53
|
+
nodes: DataJsonNode[];
|
|
54
|
+
edges?: DataJsonEdge[];
|
|
55
|
+
stamps?: Array<{
|
|
56
|
+
step: number;
|
|
57
|
+
time: number;
|
|
58
|
+
identifier: string;
|
|
59
|
+
}>;
|
|
60
|
+
steps?: Array<{
|
|
61
|
+
step: number;
|
|
62
|
+
time: number;
|
|
63
|
+
identifier: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
export interface FlowDataState {
|
|
67
|
+
availableFiles: JsonFile[];
|
|
68
|
+
currentFile: string | null;
|
|
69
|
+
flowData: DataJsonStructure | null;
|
|
70
|
+
loading: boolean;
|
|
71
|
+
error: string | null;
|
|
72
|
+
}
|
|
73
|
+
export declare const useFlowData: () => {
|
|
74
|
+
loading: boolean;
|
|
75
|
+
error: string | null;
|
|
76
|
+
loadFile: (filename: string) => Promise<void>;
|
|
77
|
+
refreshFiles: () => Promise<void>;
|
|
78
|
+
availableFiles: JsonFile[];
|
|
79
|
+
currentFile: string | null;
|
|
80
|
+
flowData: DataJsonStructure | null;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=useFlowData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFlowData.d.ts","sourceRoot":"","sources":["../../src/hooks/useFlowData.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,QAAQ,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE;QACP,SAAS,CAAC,EAAE;YACV,WAAW,CAAC,EAAE,KAAK,CAAC;gBAClB,UAAU,EAAE,MAAM,CAAC;gBACnB,cAAc,EAAE,MAAM,CAAC;gBACvB,KAAK,EAAE,KAAK,CAAC;oBACX,IAAI,EAAE,MAAM,CAAC;oBACb,OAAO,EAAE,GAAG,CAAC;iBACd,CAAC,CAAC;gBACH,MAAM,EAAE;oBACN,IAAI,EAAE,MAAM,CAAC;oBACb,OAAO,EAAE,GAAG,CAAC;iBACd,CAAC;gBACF,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;gBAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;gBAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;gBAC1B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;aACnC,CAAC,CAAC;YACH,OAAO,CAAC,EAAE;gBACR,UAAU,EAAE,MAAM,CAAC;aACpB,CAAC;SACH,CAAC;KACH,CAAC;IACF,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;QACnB,YAAY,CAAC,EAAE,GAAG,CAAC;QACnB,MAAM,CAAC,EAAE,GAAG,CAAC;KACd,CAAC;IACF,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,QAAQ,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,WAAW;;;yBAyBH,MAAM;;oBAhCT,QAAQ,EAAE;iBACb,MAAM,GAAG,IAAI;cAChB,iBAAiB,GAAG,IAAI;CA4EnC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react";
|
|
2
|
+
import { useApi } from "./useApi";
|
|
3
|
+
export const useFlowData = () => {
|
|
4
|
+
const { listJsonFiles, loadJsonFile, loading: apiLoading, error: apiError } = useApi();
|
|
5
|
+
const [state, setState] = useState({
|
|
6
|
+
availableFiles: [],
|
|
7
|
+
currentFile: null,
|
|
8
|
+
flowData: null,
|
|
9
|
+
loading: false,
|
|
10
|
+
error: null
|
|
11
|
+
});
|
|
12
|
+
// Load available files on mount
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
loadAvailableFiles();
|
|
15
|
+
}, []);
|
|
16
|
+
const loadAvailableFiles = useCallback(async () => {
|
|
17
|
+
const files = await listJsonFiles();
|
|
18
|
+
setState((prev) => ({
|
|
19
|
+
...prev,
|
|
20
|
+
availableFiles: files
|
|
21
|
+
}));
|
|
22
|
+
}, [listJsonFiles]);
|
|
23
|
+
const loadFile = useCallback(async (filename) => {
|
|
24
|
+
setState((prev) => ({
|
|
25
|
+
...prev,
|
|
26
|
+
loading: true,
|
|
27
|
+
error: null
|
|
28
|
+
}));
|
|
29
|
+
try {
|
|
30
|
+
const data = await loadJsonFile(filename);
|
|
31
|
+
if (data) {
|
|
32
|
+
setState((prev) => ({
|
|
33
|
+
...prev,
|
|
34
|
+
currentFile: filename,
|
|
35
|
+
flowData: data,
|
|
36
|
+
loading: false,
|
|
37
|
+
error: null
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
setState((prev) => ({
|
|
42
|
+
...prev,
|
|
43
|
+
loading: false,
|
|
44
|
+
error: "Failed to load file data"
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
setState((prev) => ({
|
|
50
|
+
...prev,
|
|
51
|
+
loading: false,
|
|
52
|
+
error: err instanceof Error ? err.message : "Unknown error occurred"
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
}, [loadJsonFile]);
|
|
56
|
+
const refreshFiles = useCallback(async () => {
|
|
57
|
+
await loadAvailableFiles();
|
|
58
|
+
}, [loadAvailableFiles]);
|
|
59
|
+
return {
|
|
60
|
+
...state,
|
|
61
|
+
loading: state.loading || apiLoading,
|
|
62
|
+
error: state.error || apiError?.message || null,
|
|
63
|
+
loadFile,
|
|
64
|
+
refreshFiles
|
|
65
|
+
};
|
|
66
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as AgenticFlowVisualizer } from "./AgenticFlowVisualizer";
|
|
2
|
+
export { default as App } from "./App";
|
|
3
|
+
export { Edge } from "./components/Edge";
|
|
4
|
+
export { FileSelector } from "./components/FileSelector";
|
|
5
|
+
export { Node } from "./components/Node";
|
|
6
|
+
export { Timeline } from "./components/Timeline";
|
|
7
|
+
export { VerticalTimeline } from "./components/VerticalTimeline";
|
|
8
|
+
export * from "./hooks";
|
|
9
|
+
export * from "./types";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,cAAc,SAAS,CAAC;AAGxB,cAAc,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Library entry point for npm package
|
|
2
|
+
export { default as AgenticFlowVisualizer } from "./AgenticFlowVisualizer";
|
|
3
|
+
export { default as App } from "./App";
|
|
4
|
+
// Export components
|
|
5
|
+
export { Edge } from "./components/Edge";
|
|
6
|
+
export { FileSelector } from "./components/FileSelector";
|
|
7
|
+
export { Node } from "./components/Node";
|
|
8
|
+
export { Timeline } from "./components/Timeline";
|
|
9
|
+
export { VerticalTimeline } from "./components/VerticalTimeline";
|
|
10
|
+
// Export hooks
|
|
11
|
+
export * from "./hooks";
|
|
12
|
+
// Export types
|
|
13
|
+
export * from "./types";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/test/setup.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
2
|
+
import { vi } from "vitest";
|
|
3
|
+
// Mock ResizeObserver for React Flow components
|
|
4
|
+
global.ResizeObserver = class ResizeObserver {
|
|
5
|
+
observe() { }
|
|
6
|
+
unobserve() { }
|
|
7
|
+
disconnect() { }
|
|
8
|
+
};
|
|
9
|
+
// Mock window.matchMedia
|
|
10
|
+
Object.defineProperty(window, "matchMedia", {
|
|
11
|
+
writable: true,
|
|
12
|
+
value: vi.fn().mockImplementation((query) => ({
|
|
13
|
+
matches: false,
|
|
14
|
+
media: query,
|
|
15
|
+
onchange: null,
|
|
16
|
+
addListener: vi.fn(), // deprecated
|
|
17
|
+
removeListener: vi.fn(), // deprecated
|
|
18
|
+
addEventListener: vi.fn(),
|
|
19
|
+
removeEventListener: vi.fn(),
|
|
20
|
+
dispatchEvent: vi.fn()
|
|
21
|
+
}))
|
|
22
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@railtownai/railtracks-visualizer",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Railtown AI",
|
|
7
|
+
"description": "A visualizer for RailTracks agentic flows",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"module": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/railtownai/railtracks-visualizer.git"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"agents",
|
|
30
|
+
"visualizer",
|
|
31
|
+
"railtracks",
|
|
32
|
+
"agentic-flow",
|
|
33
|
+
"react",
|
|
34
|
+
"typescript"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"lucide-react": "0.525.0",
|
|
38
|
+
"react": "18.3.1",
|
|
39
|
+
"react-dom": "18.3.1",
|
|
40
|
+
"reactflow": "11.11.4"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"start": "vite",
|
|
44
|
+
"dev": "vite",
|
|
45
|
+
"lint": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
|
|
46
|
+
"lint:fix": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
|
|
47
|
+
"build": "tsc && vite build",
|
|
48
|
+
"build:lib": "tsc --project tsconfig.lib.json",
|
|
49
|
+
"publish:dry": "npm publish --dry-run",
|
|
50
|
+
"test": "vitest",
|
|
51
|
+
"test:run": "vitest run",
|
|
52
|
+
"test:ui": "vitest --ui",
|
|
53
|
+
"up": "ncu -u -x react -x react-dom -x @types/react -x @types/react-dom && npm install"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@testing-library/jest-dom": "6.6.3",
|
|
57
|
+
"@testing-library/react": "16.3.0",
|
|
58
|
+
"@types/react": "18.3.23",
|
|
59
|
+
"@types/react-dom": "18.3.7",
|
|
60
|
+
"@vitejs/plugin-react-swc": "3.10.2",
|
|
61
|
+
"jsdom": "26.1.0",
|
|
62
|
+
"npm-check-updates": "18.0.1",
|
|
63
|
+
"prettier": "3.6.2",
|
|
64
|
+
"typescript": "5.8.3",
|
|
65
|
+
"vite": "7.0.5",
|
|
66
|
+
"vitest": "3.2.4"
|
|
67
|
+
},
|
|
68
|
+
"prettier": {
|
|
69
|
+
"singleQuote": false,
|
|
70
|
+
"trailingComma": "none",
|
|
71
|
+
"arrowParens": "always",
|
|
72
|
+
"printWidth": 120,
|
|
73
|
+
"tabWidth": 2,
|
|
74
|
+
"useTabs": false,
|
|
75
|
+
"semi": true,
|
|
76
|
+
"bracketSpacing": true
|
|
77
|
+
}
|
|
78
|
+
}
|