agent-visualizer
v1.0.4
Published
A visualizer for agent interactions
Downloads
1
Readme
Agent Interaction Visualizer
A lightweight npm package for visualizing agent interactions in a tree-like structure with colorful console output.
Features
- Visualize agent interactions in a tree structure
- Real-time updates as interactions are logged
- Colorful console output for better readability
- Track total interactions and involved agents
- Easy-to-use API
- Option to toggle visualization on/off
Installation
Install the package using npm:
npm install agent-visualizer
Or using yarn:
yarn add agent-visualizer
Usage
Import the AgentVisualizer class from the package and use it to log interactions and visualize them in the console.
import { AgentVisualizer } from "agent-visualizer";
// Create a new instance with visualization enabled
const visualizer = new AgentVisualizerWrapper(true);
// Start the visualizer
visualizer.startVisualizer();
// Log interactions
visualizer.log("agent1", "agent2");
// Reset the visualizer
visualizer.reset();
To disable visualization, simply pass false
when creating the instance:
const visualizer = new AgentVisualizerWrapper(false);
API Reference
AgentVisualizerWrapper
The main class for creating and managing the agent interaction visualization.
Methods
startVisualizer(): void
Starts the visualizer. This method should be called before logging any interactions.
log(from: string, to: string): void
Logs an interaction between two agents and updates the visualization (if enabled).
from
: The name of the agent initiating the interactionto
: The name of the agent receiving the interaction
reset(): void
Resets the visualizer, clearing all interactions and agents.
Note
When visualization is disabled (useVisualizer
set to false
), the log
and reset
methods will have no effect, allowing you to disabled it in production environments.