Documentation
¶
Overview ¶
Package agent provides visualization components for AI agent monitoring and state display.
Package agent provides visualization components for AI agent monitoring and state display.
This file implements a multi-mode memory visualization system with three display modes: concentric rotating rings, a heat map grid, and a hierarchical tree view.
Package agent provides visualization components for AI agent monitoring and state display.
This file implements a live metrics dashboard with sparklines, gauges, trend indicators, and threshold alerts for monitoring agent performance metrics.
Package agent provides visualization components for AI agent monitoring and state display.
This file implements a state machine visualizer that displays agent state transitions as an animated directed graph with visit counts, history trails, and transition effects.
Package agent provides visualization components for AI agent monitoring and state display.
This file implements a multi-agent swarm visualization that shows agents as nodes in a dynamic network with connections, data packets, and activity animations.
Index ¶
- type AgentMetrics
- type AgentNode
- type AgentState
- type Dashboard
- func (d *Dashboard) Init() tea.Cmd
- func (d *Dashboard) Resize(w, h int)
- func (d *Dashboard) SetIntensity(intensity float64)
- func (d *Dashboard) SetMetrics(m AgentMetrics)
- func (d *Dashboard) SetState(state AgentState)
- func (d *Dashboard) Update(msg tea.Msg, dt float64) tea.Cmd
- func (d *Dashboard) View() string
- type DashboardModel
- type MemoryHeatmap
- type MemoryRing
- type MemoryRingLayer
- type MemoryRingViz
- type MemorySegment
- type MemoryTree
- type MemoryTreeNode
- type MemoryType
- type MemoryViz
- func (mv *MemoryViz) AccessMemory(id string, intensity float64)
- func (mv *MemoryViz) GetHeatmap() *MemoryHeatmap
- func (mv *MemoryViz) GetRing() *MemoryRingViz
- func (mv *MemoryViz) GetTree() *MemoryTree
- func (mv *MemoryViz) Resize(w, h int)
- func (mv *MemoryViz) SwitchMode(mode MemoryVizMode)
- func (mv *MemoryViz) Update(msg tea.Msg, dt float64) tea.Cmd
- func (mv *MemoryViz) View() string
- type MemoryVizMode
- type MemoryVizSegment
- type MetricEntry
- type MetricsLayout
- type MetricsViz
- func (mv *MetricsViz) AddMetric(name string, unit string, min, max float64, color lipgloss.Color)
- func (mv *MetricsViz) GetMetric(name string) *MetricEntry
- func (mv *MetricsViz) RemoveMetric(name string)
- func (mv *MetricsViz) Reset()
- func (mv *MetricsViz) Resize(w, h int)
- func (mv *MetricsViz) SetThreshold(name string, threshold float64)
- func (mv *MetricsViz) Update(msg tea.Msg, dt float64) tea.Cmd
- func (mv *MetricsViz) UpdateMetric(name string, value float64)
- func (mv *MetricsViz) View() string
- type StateMachineViz
- func (smv *StateMachineViz) AddState(name string, pos motion.Vector2D, color lipgloss.Color)
- func (smv *StateMachineViz) AddTransition(from, to string)
- func (smv *StateMachineViz) GetCurrentState() string
- func (smv *StateMachineViz) GetHistory() []string
- func (smv *StateMachineViz) GetStateNode(name string) *StateNode
- func (smv *StateMachineViz) Reset()
- func (smv *StateMachineViz) Resize(w, h int)
- func (smv *StateMachineViz) TransitionTo(state string)
- func (smv *StateMachineViz) Update(msg tea.Msg, dt float64) tea.Cmd
- func (smv *StateMachineViz) View() string
- type StateNode
- type StateTransitionViz
- type SwarmConnection
- type SwarmLayout
- type SwarmPacket
- type SwarmVisualizer
- func (sv *SwarmVisualizer) AddAgent(id, name string, state AgentState)
- func (sv *SwarmVisualizer) Connect(from, to string)
- func (sv *SwarmVisualizer) Disconnect(from, to string)
- func (sv *SwarmVisualizer) GetAgent(id string) *AgentNode
- func (sv *SwarmVisualizer) GetAgentIDs() []string
- func (sv *SwarmVisualizer) RemoveAgent(id string)
- func (sv *SwarmVisualizer) Resize(w, h int)
- func (sv *SwarmVisualizer) SendPacket(from, to string)
- func (sv *SwarmVisualizer) SetAgentState(id string, state AgentState)
- func (sv *SwarmVisualizer) String() string
- func (sv *SwarmVisualizer) Update(msg tea.Msg, dt float64) tea.Cmd
- func (sv *SwarmVisualizer) View() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentMetrics ¶
type AgentMetrics struct {
Model string
TokensIn int
TokensOut int
Latency time.Duration
ToolsCalled int
MemoryUsed int
Errors int
Requests int
Uptime time.Duration
}
AgentMetrics holds current agent performance metrics.
type AgentNode ¶
type AgentNode struct {
ID string
Name string
State AgentState
Pos motion.Vector2D
TargetPos motion.Vector2D
Vel motion.Vector2D
Size float64
Color lipgloss.Color
PulsePhase float64
Activity float64
Connections []string
// Orbital layout: angle offset and radius
OrbitAngle float64
OrbitRadius float64
}
AgentNode represents a single agent in the swarm visualization.
type AgentState ¶
type AgentState int
AgentState represents the cognitive state of an agent.
const ( AgentIdle AgentState = iota AgentListening AgentThinking AgentResponding AgentError AgentSleeping )
func (AgentState) StateColor ¶
func (s AgentState) StateColor() lipgloss.Color
StateColor returns the color associated with each state.
func (AgentState) String ¶
func (s AgentState) String() string
String returns the human-readable state name.
type Dashboard ¶
type Dashboard struct {
Width int
Height int
State AgentState
Intensity float64
// Core visualization
Core *widget.PulseWidget
// Neural network visualization
Neural *widget.GraphWidget
// Particle effects
Particles *motion.ParticleSystem
// Memory visualization
Memory *MemoryRing
// Status display
Metrics AgentMetrics
StatusBar string
// Rendering
Buffer *render.Buffer
Compositor *render.Compositor
// Animation
Ticker *scene.Ticker
Time float64
// contains filtered or unexported fields
}
Dashboard is a complete agent visualization combining multiple effects.
func NewDashboard ¶
NewDashboard creates a new agent dashboard.
func (*Dashboard) SetIntensity ¶
SetIntensity sets the overall intensity (0-1).
func (*Dashboard) SetMetrics ¶
func (d *Dashboard) SetMetrics(m AgentMetrics)
SetMetrics updates the displayed metrics.
func (*Dashboard) SetState ¶
func (d *Dashboard) SetState(state AgentState)
SetState changes the agent state and updates visualizations.
type DashboardModel ¶
type DashboardModel struct {
Dashboard *Dashboard
}
DashboardModel wraps Dashboard for tea.Model compatibility.
func NewDashboardModel ¶
func NewDashboardModel(w, h int) DashboardModel
NewDashboardModel creates a new dashboard model.
type MemoryHeatmap ¶
type MemoryHeatmap struct {
Grid [][]float64
GridW int
GridH int
Decay float64
Gradient *render.Gradient
}
MemoryHeatmap shows memory access patterns as a colored heat grid. Cells glow brighter when recently accessed and decay over time.
type MemoryRing ¶
type MemoryRing struct {
Segments []MemorySegment
Radius float64
Rotation float64
ActiveIdx int
}
MemoryRing visualizes agent memory as a rotating ring of segments.
func NewMemoryRing ¶
func NewMemoryRing(segments int) *MemoryRing
NewMemoryRing creates a memory ring with the given number of segments.
func (*MemoryRing) Activate ¶
func (mr *MemoryRing) Activate(id string)
Activate marks a segment as recently active.
func (*MemoryRing) AddSegment ¶
func (mr *MemoryRing) AddSegment(id string, memType MemoryType, size float64)
AddSegment adds a memory segment.
func (*MemoryRing) RenderInto ¶
RenderInto renders the memory ring into a buffer.
func (*MemoryRing) Update ¶
func (mr *MemoryRing) Update(dt float64)
Update advances the ring animation.
type MemoryRingLayer ¶
type MemoryRingLayer struct {
Name string
Type MemoryType
Radius float64
Rotation float64
RotationSpeed float64
Segments []MemoryVizSegment
Color lipgloss.Color
}
MemoryRingLayer represents a single concentric ring in the ring visualization.
type MemoryRingViz ¶
type MemoryRingViz struct {
Rings []*MemoryRingLayer
Rotation float64
Center motion.Vector2D
}
MemoryRingViz shows memory as concentric rotating rings, with each ring representing a different memory type (short-term, long-term, etc.).
type MemorySegment ¶
type MemorySegment struct {
ID string
Type MemoryType
Size float64
Activity float64
Color lipgloss.Color
}
MemorySegment represents a single memory segment.
type MemoryTree ¶
type MemoryTree struct {
Root *MemoryTreeNode
Expanded map[string]bool
Selected string
}
MemoryTree shows memory as a hierarchical tree with expandable nodes.
type MemoryTreeNode ¶
type MemoryTreeNode struct {
ID string
Name string
Type MemoryType
Children []*MemoryTreeNode
Size float64
Activity float64
Color lipgloss.Color
}
MemoryTreeNode represents a node in the memory tree hierarchy.
type MemoryType ¶
type MemoryType int
MemoryType categorizes memory segments.
const ( MemoryShortTerm MemoryType = iota MemoryLongTerm MemoryEpisodic MemorySemantic MemorySkill )
type MemoryViz ¶
type MemoryViz struct {
Mode MemoryVizMode
Ring *MemoryRingViz
Heatmap *MemoryHeatmap
Tree *MemoryTree
Width int
Height int
Ticker *scene.Ticker
Time float64
Buffer *render.Buffer
}
MemoryViz provides multiple memory visualization modes with animated transitions.
func NewMemoryViz ¶
func NewMemoryViz(mode MemoryVizMode) *MemoryViz
NewMemoryViz creates a new memory visualizer in the specified mode.
func (*MemoryViz) AccessMemory ¶
AccessMemory records a memory access event, updating the appropriate visualization.
func (*MemoryViz) GetHeatmap ¶
func (mv *MemoryViz) GetHeatmap() *MemoryHeatmap
GetHeatmap returns the heatmap visualization, creating it if necessary.
func (*MemoryViz) GetRing ¶
func (mv *MemoryViz) GetRing() *MemoryRingViz
GetRing returns the ring visualization, creating it if necessary.
func (*MemoryViz) GetTree ¶
func (mv *MemoryViz) GetTree() *MemoryTree
GetTree returns the tree visualization, creating it if necessary.
func (*MemoryViz) SwitchMode ¶
func (mv *MemoryViz) SwitchMode(mode MemoryVizMode)
SwitchMode changes the visualization mode.
type MemoryVizMode ¶
type MemoryVizMode int
MemoryVizMode selects the visualization mode for the memory display.
const ( // MemoryModeRing shows memory as concentric rotating rings. MemoryModeRing MemoryVizMode = iota // MemoryModeHeatmap shows memory access patterns as a heat grid. MemoryModeHeatmap // MemoryModeTree shows memory as a hierarchical tree. MemoryModeTree )
type MemoryVizSegment ¶
MemoryVizSegment represents a segment within a memory ring layer.
type MetricEntry ¶
type MetricEntry struct {
Name string
Value float64
Min, Max float64
Unit string
History []float64
MaxHistory int
Color lipgloss.Color
Trend float64 // positive = up, negative = down, zero = stable
Threshold *float64 // alert threshold (nil = no threshold)
}
MetricEntry represents a single metric with its current value and history.
type MetricsLayout ¶
type MetricsLayout int
MetricsLayout determines how metrics are arranged in the dashboard.
const ( // MetricsLayoutGrid arranges metrics in a regular grid. MetricsLayoutGrid MetricsLayout = iota // MetricsLayoutList arranges metrics in a single column. MetricsLayoutList // MetricsLayoutCompact arranges metrics in a condensed format. MetricsLayoutCompact )
type MetricsViz ¶
type MetricsViz struct {
Metrics map[string]*MetricEntry
Order []string // Display order
Layout MetricsLayout
Width int
Height int
Ticker *scene.Ticker
Time float64
Buffer *render.Buffer
}
MetricsViz displays agent metrics with sparklines, gauges, and trend indicators. Each metric tracks its current value, history, min/max bounds, trend direction, and optional alert thresholds.
func NewMetricsViz ¶
func NewMetricsViz(layout MetricsLayout) *MetricsViz
NewMetricsViz creates a new metrics dashboard with the specified layout.
func (*MetricsViz) AddMetric ¶
AddMetric registers a new metric with the given name, unit, bounds, and color.
func (*MetricsViz) GetMetric ¶
func (mv *MetricsViz) GetMetric(name string) *MetricEntry
GetMetric returns the metric entry for the given name, or nil if not found.
func (*MetricsViz) RemoveMetric ¶
func (mv *MetricsViz) RemoveMetric(name string)
RemoveMetric removes a metric from the dashboard.
func (*MetricsViz) Reset ¶
func (mv *MetricsViz) Reset()
Reset resets all metrics to their initial state, clearing history and values.
func (*MetricsViz) Resize ¶
func (mv *MetricsViz) Resize(w, h int)
Resize updates the visualization dimensions.
func (*MetricsViz) SetThreshold ¶
func (mv *MetricsViz) SetThreshold(name string, threshold float64)
SetThreshold sets an alert threshold for the named metric. When the value exceeds the threshold, the metric changes color.
func (*MetricsViz) UpdateMetric ¶
func (mv *MetricsViz) UpdateMetric(name string, value float64)
UpdateMetric sets a new value for the named metric, updating history and trend.
func (*MetricsViz) View ¶
func (mv *MetricsViz) View() string
View renders the metrics dashboard as a string.
type StateMachineViz ¶
type StateMachineViz struct {
States map[string]*StateNode
Transitions []*StateTransitionViz
Current string
Previous string
History []string
MaxHistory int
Width int
Height int
Ticker *scene.Ticker
Buffer *render.Buffer
Time float64
// Transition animation state
TransitionAnim float64
TransitionFrom string
TransitionDest string
TransitionActive bool
}
StateMachineViz visualizes agent state transitions as an interactive directed graph. It shows states as circles, transitions as animated arrows, the current state with a pulse effect, visit counts, and a history trail of recent transitions.
func NewStateMachineViz ¶
func NewStateMachineViz() *StateMachineViz
NewStateMachineViz creates a new state machine visualizer with default settings.
func (*StateMachineViz) AddState ¶
AddState adds a new state node at the given position with the specified color.
func (*StateMachineViz) AddTransition ¶
func (smv *StateMachineViz) AddTransition(from, to string)
AddTransition registers a directed transition between two states.
func (*StateMachineViz) GetCurrentState ¶
func (smv *StateMachineViz) GetCurrentState() string
GetCurrentState returns the name of the current active state.
func (*StateMachineViz) GetHistory ¶
func (smv *StateMachineViz) GetHistory() []string
GetHistory returns the current transition history.
func (*StateMachineViz) GetStateNode ¶
func (smv *StateMachineViz) GetStateNode(name string) *StateNode
GetStateNode returns the state node for the given name, or nil if not found.
func (*StateMachineViz) Reset ¶
func (smv *StateMachineViz) Reset()
Reset resets the visualizer to its initial state, clearing history and visit counts.
func (*StateMachineViz) Resize ¶
func (smv *StateMachineViz) Resize(w, h int)
Resize updates the visualization dimensions.
func (*StateMachineViz) TransitionTo ¶
func (smv *StateMachineViz) TransitionTo(state string)
TransitionTo animates a transition from the current state to the target state. It updates visit counts, history, and triggers the transition animation.
func (*StateMachineViz) View ¶
func (smv *StateMachineViz) View() string
View renders the state machine visualization as a string.
type StateNode ¶
type StateNode struct {
Name string
Pos motion.Vector2D
Active bool
Color lipgloss.Color
VisitCount int
LastVisited time.Time
PulsePhase float64
}
StateNode represents a single state in the state machine graph.
type StateTransitionViz ¶
type StateTransitionViz struct {
From string
To string
Count int
Recent bool
Progress float64
Color lipgloss.Color
}
StateTransitionViz represents a visual transition between two states.
type SwarmConnection ¶
type SwarmConnection struct {
From string
To string
Active bool
Packets []*SwarmPacket
Color lipgloss.Color
}
SwarmConnection represents a directed connection between two agents.
type SwarmLayout ¶
type SwarmLayout int
SwarmLayout determines how agent nodes are arranged in the swarm.
const ( // SwarmLayoutRadial arranges agents in a circle around the center. SwarmLayoutRadial SwarmLayout = iota // SwarmLayoutForce uses force-directed positioning with physics. SwarmLayoutForce // SwarmLayoutGrid arranges agents in a regular grid pattern. SwarmLayoutGrid // SwarmLayoutOrbital places agents on rotating orbital rings. SwarmLayoutOrbital )
type SwarmPacket ¶
SwarmPacket represents a data packet flowing along a connection.
type SwarmVisualizer ¶
type SwarmVisualizer struct {
Agents map[string]*AgentNode
Connections []*SwarmConnection
Center motion.Vector2D
Layout SwarmLayout
Width int
Height int
Ticker *scene.Ticker
Buffer *render.Buffer
Time float64
}
SwarmVisualizer shows multiple agents in a dynamic network visualization. Agents are rendered as colored nodes with state-dependent visuals, connected by dotted lines with animated data packets flowing between them.
func NewSwarmVisualizer ¶
func NewSwarmVisualizer(layout SwarmLayout) *SwarmVisualizer
NewSwarmVisualizer creates a new swarm visualizer with the specified layout.
func (*SwarmVisualizer) AddAgent ¶
func (sv *SwarmVisualizer) AddAgent(id, name string, state AgentState)
AddAgent adds a new agent node to the swarm with the given state.
func (*SwarmVisualizer) Connect ¶
func (sv *SwarmVisualizer) Connect(from, to string)
Connect creates a directed connection from one agent to another.
func (*SwarmVisualizer) Disconnect ¶
func (sv *SwarmVisualizer) Disconnect(from, to string)
Disconnect removes a directed connection between two agents.
func (*SwarmVisualizer) GetAgent ¶
func (sv *SwarmVisualizer) GetAgent(id string) *AgentNode
GetAgent returns the agent node for the given ID, or nil if not found.
func (*SwarmVisualizer) GetAgentIDs ¶
func (sv *SwarmVisualizer) GetAgentIDs() []string
GetAgentIDs returns a slice of all agent IDs in the swarm.
func (*SwarmVisualizer) RemoveAgent ¶
func (sv *SwarmVisualizer) RemoveAgent(id string)
RemoveAgent removes an agent and all its connections from the swarm.
func (*SwarmVisualizer) Resize ¶
func (sv *SwarmVisualizer) Resize(w, h int)
Resize updates the visualization dimensions and reapplies layout.
func (*SwarmVisualizer) SendPacket ¶
func (sv *SwarmVisualizer) SendPacket(from, to string)
SendPacket sends a data packet along a connection, triggering an activity burst.
func (*SwarmVisualizer) SetAgentState ¶
func (sv *SwarmVisualizer) SetAgentState(id string, state AgentState)
SetAgentState updates an agent's state and its associated color.
func (*SwarmVisualizer) String ¶
func (sv *SwarmVisualizer) String() string
String returns a debug summary of the swarm state.
func (*SwarmVisualizer) Update ¶
Update advances the swarm animation by one frame. It handles frame ticks, window resize, and updates all agent animations.
func (*SwarmVisualizer) View ¶
func (sv *SwarmVisualizer) View() string
View renders the complete swarm visualization as a string.