@railtownai/railtracks-visualizer 0.0.24 → 0.0.26

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.
@@ -23,5 +23,6 @@ export declare const getOverviewLlmDetails: (llmDetails: LLMDetails[]) => LLMDet
23
23
  export declare const sumTotalCost: (llmDetails: LLMDetails[]) => number;
24
24
  export declare const sumTotalInputTokens: (llmDetails: LLMDetails[]) => number;
25
25
  export declare const sumTotalOutputTokens: (llmDetails: LLMDetails[]) => number;
26
+ export declare const sumTotalLatency: (llmDetails: LLMDetails[]) => number;
26
27
  export declare const AgentNode: React.FC<AgentNodeProps>;
27
28
  export {};
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { LLMContent } from "../../dto/AgentRunNode";
3
+ interface InputArrayRendererProps {
4
+ input: LLMContent[];
5
+ }
6
+ export declare const InputArrayRenderer: React.FC<InputArrayRendererProps>;
7
+ export {};
@@ -2,6 +2,7 @@ import React from "react";
2
2
  interface CodeBlockProps {
3
3
  content: string;
4
4
  language?: string;
5
+ showHeader?: boolean;
5
6
  }
6
7
  export declare const CodeBlock: React.FC<CodeBlockProps>;
7
8
  export {};
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
2
  import { JsonFile } from "../../hooks/useApi";
3
- interface AgentRun {
3
+ import { RealTimeLastUpdate } from "../../hooks/useRailtracksStream";
4
+ export interface AgentRunMenuItem {
4
5
  id: number;
5
6
  name: string;
6
- runId: string;
7
- sessionId: string;
7
+ run_id: string;
8
+ session_id: string;
8
9
  }
9
10
  interface HeaderProps {
10
11
  availableFiles: JsonFile[];
@@ -13,11 +14,13 @@ interface HeaderProps {
13
14
  onRefresh: () => void;
14
15
  loading: boolean;
15
16
  isMultipleAgentRuns: boolean;
16
- agentRuns: AgentRun[];
17
- selectedAgentRun: number;
18
- onAgentRunSelect: (runIndex: number) => void;
17
+ agentRuns: AgentRunMenuItem[];
18
+ selectedAgentRunId: string | null;
19
+ onAgentRunSelect: (runId: string) => void;
19
20
  showTimeline: boolean;
20
21
  onTimelineToggle: (checked: boolean) => void;
22
+ realTimeConnected?: boolean;
23
+ realTimeLastUpdate?: RealTimeLastUpdate | null;
21
24
  }
22
25
  export declare const Header: React.FC<HeaderProps>;
23
26
  export {};
@@ -8,21 +8,6 @@ import { AgentRunStep } from "./AgentRunStep";
8
8
  * This interface defines the structure for agent flow data that can be visualized
9
9
  * in the RailTracks UI. It contains the execution graph (nodes and edges) along
10
10
  * with timing information and session metadata.
11
- *
12
- * @example
13
- * ```typescript
14
- * const agentRun: AgentRun = {
15
- * session_id: "session_123",
16
- * name: "Customer Support Agent",
17
- * run_id: "run_456",
18
- * nodes: [...],
19
- * edges: [...],
20
- * stamps: [
21
- * { step: 1, time: 1640995200, identifier: "start" },
22
- * { step: 2, time: 1640995201, identifier: "user_input" }
23
- * ]
24
- * };
25
- * ```
26
11
  */
27
12
  export interface AgentRun {
28
13
  /** Unique identifier for the agent session this run belongs to */
@@ -31,6 +16,12 @@ export interface AgentRun {
31
16
  name: string;
32
17
  /** Unique identifier for this specific agent run */
33
18
  run_id: string;
19
+ /** Start time of the agent run (unix timestamp) */
20
+ start_time: number;
21
+ /** End time of the agent run (unix timestamp) */
22
+ end_time: number;
23
+ /** Status of the agent run (Completed, Failed, etc.) */
24
+ status: string;
34
25
  /** Array of nodes representing the agent's execution steps */
35
26
  nodes: AgentRunNode[];
36
27
  /** Optional array of edges connecting the nodes in the execution flow */
@@ -1,27 +1,5 @@
1
- /**
2
- * Represents a timestamped event for an edge
3
- */
4
- export interface EdgeStamp {
5
- /** The sequential step number in the agent execution */
6
- step: number;
7
- /** Unix timestamp when this event occurred */
8
- time: number;
9
- /** Unique identifier for this stamp */
10
- identifier: string;
11
- }
12
- /**
13
- * Represents detailed information about an edge
14
- */
15
- export interface EdgeDetails {
16
- /** Optional status information for the edge */
17
- status?: string;
18
- /** Optional array of input arguments passed to the target node */
19
- input_args?: any[];
20
- /** Optional object of input keyword arguments passed to the target node */
21
- input_kwargs?: any;
22
- /** Optional output data from the source node */
23
- output?: any;
24
- }
1
+ import { AgentRunEdgeStamp } from "./AgentRunEdgeStamp";
2
+ import { AgentRunEdgeDetails } from "./AgentRunEdgeDetails";
25
3
  /**
26
4
  * Represents an edge connecting nodes in the agent execution flow
27
5
  *
@@ -29,27 +7,6 @@ export interface EdgeDetails {
29
7
  * Edges represent the flow of data and control between different execution steps,
30
8
  * with timing information and optional execution details.
31
9
  *
32
- * @example
33
- * ```typescript
34
- * const edge: AgentRunEdge = {
35
- * identifier: "edge_123",
36
- * source: "node_1",
37
- * target: "node_2",
38
- * stamp: {
39
- * step: 2,
40
- * time: 1640995201,
41
- * identifier: "edge_1_to_2"
42
- * },
43
- * details: {
44
- * state: "completed",
45
- * status: "success",
46
- * input_args: ["Hello world"],
47
- * input_kwargs: { temperature: 0.7 },
48
- * output: { response: "Hi there!" }
49
- * },
50
- * parent: null
51
- * };
52
- * ```
53
10
  */
54
11
  export interface AgentRunEdge {
55
12
  /** Unique identifier for this edge */
@@ -59,9 +16,9 @@ export interface AgentRunEdge {
59
16
  /** Identifier of the target node this edge connects to */
60
17
  target: string;
61
18
  /** Timestamp information for when this edge was traversed */
62
- stamp: EdgeStamp;
19
+ stamp: AgentRunEdgeStamp;
63
20
  /** Detailed information about the edge's execution */
64
- details: EdgeDetails;
21
+ details: AgentRunEdgeDetails;
65
22
  /** Reference to the parent edge, or null if this is a root edge */
66
23
  parent: AgentRunEdge | null;
67
24
  }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Represents detailed information about an edge
3
+ */
4
+ export interface AgentRunEdgeDetails {
5
+ /** Optional status information for the edge */
6
+ status?: string;
7
+ /** Optional array of input arguments passed to the target node */
8
+ input_args?: any[];
9
+ /** Optional object of input keyword arguments passed to the target node */
10
+ input_kwargs?: any;
11
+ /** Optional output data from the source node */
12
+ output?: any;
13
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Represents a timestamped event for an edge
3
+ */
4
+ export interface AgentRunEdgeStamp {
5
+ /** The sequential step number in the agent execution */
6
+ step: number;
7
+ /** Unix timestamp when this event occurred */
8
+ time: number;
9
+ /** Unique identifier for this stamp */
10
+ identifier: string;
11
+ }
@@ -15,7 +15,10 @@ export interface NodeStamp {
15
15
  export interface LLMContent {
16
16
  /** Role of the message sender (e.g., "user", "assistant", "system") */
17
17
  role: string;
18
- /** The actual content of the message */
18
+ /** The actual content of the message.
19
+ * For tool calls, they can be a function call.
20
+ * For tool responses, it can be json.
21
+ * For LLM responses, it can be a string or a json object. */
19
22
  content: any;
20
23
  }
21
24
  /**
@@ -38,12 +41,16 @@ export interface LLMDetails {
38
41
  total_cost: number | null;
39
42
  /** System fingerprint for the model (null if not available) */
40
43
  system_fingerprint: string | null;
44
+ /** Total time taken for the node to execute in SECONDS.
45
+ * Older agent runs (backwards compatible) won't have latency parameter
46
+ * so we need to make it optional. */
47
+ latency?: number | null;
41
48
  }
42
49
  /**
43
50
  * Represents latency information for a node execution
44
51
  */
45
52
  export interface NodeLatency {
46
- /** Total time taken for the node to execute in milliseconds */
53
+ /** Total time taken for the node to execute in SECONDS */
47
54
  total_time: number;
48
55
  }
49
56
  /**
@@ -69,40 +76,11 @@ export interface NodeDetails {
69
76
  * Each node represents a discrete action or decision point in the agent's workflow,
70
77
  * with timing information, execution details, and optional LLM interaction data.
71
78
  *
72
- * @example
73
- * ```typescript
74
- * const node: AgentRunNode = {
75
- * identifier: "node_123",
76
- * node_type: "llm_call",
77
- * name: "Generate Response",
78
- * stamp: {
79
- * step: 1,
80
- * time: 1640995200,
81
- * identifier: "llm_call_1"
82
- * },
83
- * details: {
84
- * internals: {
85
- * llm_details: [{
86
- * model_name: "gpt-4",
87
- * model_provider: "openai",
88
- * input: [{ role: "user", content: "Hello" }],
89
- * output: { role: "assistant", content: "Hi there!" },
90
- * input_tokens: 5,
91
- * output_tokens: 3,
92
- * total_cost: 0.0001,
93
- * system_fingerprint: "fp_123"
94
- * }],
95
- * latency: { total_time: 1500 }
96
- * }
97
- * },
98
- * parent: null
99
- * };
100
- * ```
101
79
  */
102
80
  export interface AgentRunNode {
103
81
  /** Unique identifier for this node */
104
82
  identifier: string;
105
- /** Type of node (e.g., "llm_call", "tool_call", "decision") */
83
+ /** Type of node (e.g., "Tool", "Agent", "Coordinator") */
106
84
  node_type: string;
107
85
  /** Optional human-readable name for this node */
108
86
  name?: string;
@@ -1,2 +1,13 @@
1
1
  import { AgentRun } from "./AgentRun";
2
- export type AgentSession = AgentRun[];
2
+ export type AgentSession = {
3
+ /** Unique identifier for the agent session */
4
+ session_id: string;
5
+ /** Name of the agent session */
6
+ name: string;
7
+ /** Start time of the agent session (unix timestamp) */
8
+ start_time: number;
9
+ /** End time of the agent session (unix timestamp) */
10
+ end_time: number;
11
+ /** Array of agent runs */
12
+ runs: AgentRun[];
13
+ };
@@ -0,0 +1,9 @@
1
+ import { AgentRun } from "./AgentRun";
2
+ import { AgentRunEdge } from "./AgentRunEdge";
3
+ import { AgentRunEdgeDetails } from "./AgentRunEdgeDetails";
4
+ import { AgentRunEdgeStamp } from "./AgentRunEdgeStamp";
5
+ import { AgentRunNode } from "./AgentRunNode";
6
+ import { AgentRunStamp } from "./AgentRunStamp";
7
+ import { AgentRunStep } from "./AgentRunStep";
8
+ import { AgentSession } from "./AgentSession";
9
+ export type { AgentRun, AgentSession, AgentRunNode, AgentRunEdge, AgentRunEdgeDetails, AgentRunEdgeStamp, AgentRunStamp, AgentRunStep };
@@ -1,5 +1,6 @@
1
1
  export { useApi } from "./useApi";
2
2
  export { useFlowData } from "./useFlowData";
3
+ export { useRailtracksStream } from "./useRailtracksStream";
3
4
  export type { JsonFile, ApiError } from "./useApi";
4
5
  export type { FlowDataState } from "./useFlowData";
5
6
  export type { AgentRunNode } from "../dto/AgentRunNode";
@@ -1,3 +1,4 @@
1
+ import { AgentSession } from "../dto/AgentSession";
1
2
  export interface JsonFile {
2
3
  name: string;
3
4
  size?: number;
@@ -11,6 +12,6 @@ export declare const useApi: () => {
11
12
  loading: boolean;
12
13
  error: ApiError | null;
13
14
  listJsonFiles: () => Promise<JsonFile[]>;
14
- loadJsonFile: (filename: string) => Promise<any>;
15
- triggerRefresh: () => Promise<any>;
15
+ loadJsonFile: (filename: string) => Promise<AgentSession | null>;
16
+ triggerRefresh: () => Promise<JsonFile[] | null>;
16
17
  };
@@ -1,9 +1,9 @@
1
1
  import { JsonFile } from "./useApi";
2
- import { AgentRun } from "../dto/AgentRun";
2
+ import type { AgentSession } from "../dto";
3
3
  export interface FlowDataState {
4
4
  availableFiles: JsonFile[];
5
5
  currentFile: string | null;
6
- flowData: AgentRun | null;
6
+ flowData: AgentSession | null;
7
7
  loading: boolean;
8
8
  error: string | null;
9
9
  }
@@ -14,5 +14,5 @@ export declare const useFlowData: () => {
14
14
  refreshFiles: () => Promise<void>;
15
15
  availableFiles: JsonFile[];
16
16
  currentFile: string | null;
17
- flowData: AgentRun | null;
17
+ flowData: AgentSession | null;
18
18
  };
@@ -0,0 +1,18 @@
1
+ interface StreamMessage {
2
+ type: "connected" | "file_updated" | "keepalive";
3
+ filename?: string;
4
+ timestamp?: number;
5
+ [key: string]: any;
6
+ }
7
+ export interface RealTimeLastUpdate {
8
+ filename: string;
9
+ timestamp: Date;
10
+ }
11
+ declare const useRailtracksStream: (onMessage?: (data: StreamMessage) => void) => {
12
+ isConnected: boolean;
13
+ isConnecting: boolean;
14
+ error: string | null;
15
+ reconnect: () => Promise<void>;
16
+ disconnect: () => void;
17
+ };
18
+ export { useRailtracksStream };
@@ -16,6 +16,8 @@ export interface Theme {
16
16
  accentForeground: string;
17
17
  destructive: string;
18
18
  destructiveForeground: string;
19
+ success: string;
20
+ successForeground: string;
19
21
  border: string;
20
22
  mutedBorder: string;
21
23
  input: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@railtownai/railtracks-visualizer",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "license": "Apache-2.0",
5
5
  "author": "Railtown AI",
6
6
  "description": "A visualizer for RailTracks agentic flows",
@@ -48,6 +48,7 @@
48
48
  "lucide-react": "0.525.0",
49
49
  "moment": "2.30.1",
50
50
  "react-countup": "6.5.3",
51
+ "react-textarea-autosize": "8.5.9",
51
52
  "vaul": "1.1.2"
52
53
  },
53
54
  "scripts": {