Skip to content

afine907/agent-sse-flow

agent-sse-flow

A lightweight React component for visualizing AI Agent execution traces from SSE streams. Free, unlimited, local-first. No cloud account required.

NPM Version License: MIT CI Bundle Size TypeScript Tests

Live Demo Β· NPM Β· Documentation Β· Examples Β· Changelog Β· Contributing


Why agent-sse-flow?

agent-sse-flow LangSmith
Price Free, open-source Free tier limited
Trace limit Unlimited 5,000/month
Data location Local (never leaves your machine) Cloud
Setup 5 minutes, npm install Account required
Dependencies React + 2 small libs LangChain ecosystem
Self-hosted Yes No

Features

Core Visualization

  • Real-time SSE streaming with automatic reconnection
  • 6 view modes: List, Timeline, Waterfall, DAG, Swimlane, Cluster
  • Virtual scrolling β€” handles 100K+ events smoothly
  • Dark/Light themes with full CSS variable customization
  • Responsive layout β€” works on mobile and desktop

Filtering & Search

  • Full-text search (Ctrl/Cmd+K) across all event fields
  • Time range filter with datetime pickers
  • Event type filter checkboxes
  • Agent filter with drag-to-reorder
  • Bookmarks & pinning for important events

Analytics & Debugging

  • Cost dashboard β€” total cost, per-agent breakdown, pie chart
  • Token usage chart β€” cumulative tokens over time
  • Performance bottleneck detection β€” slow tools, high cost, error rates
  • Event breakpoints β€” pause on specific event types
  • Event snapshots β€” save/load event state via IndexedDB
  • Event diff β€” side-by-side comparison of two events
  • JSON syntax highlighting in tool arguments
  • Duration visualization bars for tool calls

Data Management

  • Export events as JSON or CSV
  • Record raw SSE streams as JSONL for replay
  • IndexedDB persistence for session restore
  • Event stream recording for debugging

Developer Experience

  • TypeScript with strict mode and full type exports
  • i18n β€” English and Chinese built-in
  • ARIA accessibility β€” proper roles, labels, and keyboard navigation
  • Sound feedback β€” optional audio cues for errors and status changes
  • Custom renderers β€” override message and result rendering
  • Storybook β€” interactive component development

Integrations

  • Transport adapters: SSE (default), WebSocket, HTTP Polling
  • Framework examples: Next.js, Vite, Express, FastAPI
  • Agent framework examples: LangGraph, OpenAI Agents, CrewAI

Quick Start

Install

npm install agent-sse-flow
# or
pnpm add agent-sse-flow

Use

import { AgentFlow } from 'agent-sse-flow'
import 'agent-sse-flow/style.css'

function App() {
  return (
    <AgentFlow
      url="http://localhost:8080/agent/stream"
      theme="dark"
    />
  )
}

That's it. The component connects to your SSE endpoint and renders the agent execution trace in real time.


SSE Event Format

Send JSON events from your backend:

{"type": "start", "message": "Agent started", "agentName": "researcher", "agentColor": "#3b82f6"}
{"type": "thinking", "message": "Analyzing request...", "agentName": "researcher"}
{"type": "tool_call", "tool": "search_web", "args": {"query": "AI news"}, "agentName": "researcher"}
{"type": "tool_result", "result": "Found 10 results...", "duration": 1250}
{"type": "message", "message": "Here's what I found...", "cost": 0.002, "tokens": 150}
{"type": "error", "message": "Rate limit exceeded"}
{"type": "end", "message": "Done", "cost": 0.015, "tokens": 1200, "duration": 3500}

Event Types

Type Description Key Fields
start Agent started message, agentName?, agentColor?
thinking Agent reasoning message, agentName?
tool_call Tool invocation tool, args, agentName?, duration?
tool_result Tool output result, duration?, cost?, tokens?
message Text output message, cost?, tokens?
error Error occurred message
end Agent finished message, cost?, tokens?, duration?

All fields except type are optional. See API Reference for the full FlowEvent interface.


Props

Prop Type Default Description
url string required SSE endpoint URL
theme 'light' | 'dark' 'dark' Color theme
autoConnect boolean true Auto-connect on mount
maxEvents number 100000 Max events in memory
viewMode 'list' | 'timeline' 'list' Default view mode
defaultCollapsed boolean false Collapse new events in timeline
autoReconnect boolean true Reconnect on disconnect
maxReconnectAttempts number 10 Max reconnect tries
searchKey string 'k' Search shortcut key (+ Ctrl/Cmd)
locale 'en' | 'zh' 'en' UI language
customTheme Record<string, string> - CSS variable overrides
renderMessage (msg: string) => ReactNode - Custom message renderer
renderResult (result: string) => ReactNode - Custom result renderer
onError (error: Error) => void - Error callback
onStatusChange (status: EventStatus) => void - Connection status callback
className string - Custom CSS class
style CSSProperties - Custom inline styles

Documentation

Document Description
API Reference Complete API docs for all props, hooks, types, and utilities
Advanced Features DAG, swimlane, breakpoints, snapshots, AI analysis, and more
Architecture System design, data flow, and module structure
Integration Guide Step-by-step setup for various backends
Examples Framework-specific integration examples

Integrations

Backend Examples

Framework Guide
Express.js examples/express-backend.md
FastAPI (Python) examples/fastapi-backend.md

Agent Framework Examples

Framework Guide
LangGraph examples/langgraph-integration.md
OpenAI Agents SDK examples/openai-agents.md
CrewAI examples/crewai-integration.md

Frontend Examples

Framework Guide
Next.js examples/nextjs.md
Vite + React examples/vite-react.md
Storybook examples/storybook.md

Theming

Customize with CSS variables:

<AgentFlow
  url="/api/stream"
  customTheme={{
    '--af-accent': '#10b981',
    '--af-bg': '#0f172a',
    '--af-text': '#e2e8f0',
    '--af-border': '#1e293b',
  }}
/>

See the full list of CSS variables in the API Reference.


Development

# Install dependencies
pnpm install

# Start dev server (with mock SSE server)
pnpm dev

# Run tests
pnpm test

# Type check
pnpm type-check

# Build library
pnpm build

# Storybook
pnpm dev-storybook

Contributing

Contributions are welcome! Please read the Contributing Guide for details on:

  • Development setup
  • Coding conventions
  • Commit format
  • Pull request process

License

MIT Β© 2025

About

πŸš€ A lightweight React component for visualizing Agent SSE streams. Free, unlimited, local.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors