Metadata-Version: 2.5
Name: agent-visualizer
Version: 1.0.0
Summary: Watch your multi-agent AI workflow as a 2D retro pixel-art game
Project-URL: Homepage, https://github.com/Shubhs5758/agent-visualizer
Project-URL: Documentation, https://github.com/Shubhs5758/agent-visualizer#readme
Project-URL: Issues, https://github.com/Shubhs5758/agent-visualizer/issues
Author: Shubhs5758
License: MIT License
        
        Copyright (c) 2026 Shubhs5758
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,deepagents,langchain,langgraph,multi-agent,observability,visualization
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Software Development :: Debuggers
Requires-Python: >=3.9
Provides-Extra: all
Requires-Dist: aiohttp>=3.9; extra == 'all'
Requires-Dist: websocket-client>=1.7; extra == 'all'
Provides-Extra: server
Requires-Dist: aiohttp>=3.9; extra == 'server'
Provides-Extra: ws
Requires-Dist: websocket-client>=1.7; extra == 'ws'
Description-Content-Type: text/markdown

# agent-visualizer

Watch your multi-agent AI workflow as a **2D retro pixel-art game**. Agents spawn
on a grid, walk to the Library to read memory, march to the Tool Forge to run
tools, and cross the map to talk to each other — driven by events streamed from
your existing agent code.

Works with **LangGraph**, **LangChain**, **deepagents**, or any Python at all.

```bash
pip install "agent-visualizer[server]"
agent-visualizer serve
```

That opens the dashboard at <http://localhost:8765>. No Node, no npm, no separate
front end — the built UI ships inside the wheel.

Try it with no code of your own:

```bash
agent-visualizer demo      # in a second terminal
```

---

## Integrating

### LangGraph / LangChain — one callback

Each LangGraph **node** becomes a sprite automatically; your nodes stay clean.

```python
from agent_visualizer import VisualizerCallback

vis = VisualizerCallback()
graph.invoke(state, config={"callbacks": [vis]})
```

It walks the sprite to the Tool Forge on `on_tool_start`, to the Library on
`on_retriever_start`, bubbles LLM output, and accumulates token/latency metrics.

To control the name a sprite gets — useful with `create_react_agent`, whose
internal nodes are called `agent` and `tools` — set it in metadata:

```python
researcher = create_react_agent(model, tools).with_config(
    {"metadata": {"agent_id": "researcher"}}
)
```

### Any plain function

```python
from agent_visualizer import visualize_agent

@visualize_agent("scout_1", role="scout", avatar_type="rogue")
def scout(query: str) -> str:
    ...
```

### Direct control

```python
from agent_visualizer import AgentVisualizerClient

vis = AgentVisualizerClient()

scout = vis.register("scout_1", name="Scout", role="scout", avatar_type="rogue")
scout.move_to(zone="library")
scout.update_state("Executing Tool: WebSearch", metrics={"tokens": 320, "latency_ms": 140})
scout.speak("Found the target node.", to="mage_1")
```

Zones: `gateway`, `library`, `tools`, `council`, `vault`.
Avatars: `knight`, `artificer`, `rogue`, `cleric`, `bard`, `ranger`, `mage`, `druid`.

---

## Install options

| Command | Gets you |
| --- | --- |
| `pip install agent-visualizer` | The client only — **zero dependencies** |
| `pip install "agent-visualizer[ws]"` | + WebSocket transport (lower latency) |
| `pip install "agent-visualizer[server]"` | + the bridge and the bundled dashboard |
| `pip install "agent-visualizer[all]"` | Everything |

The client works with **no dependencies at all**: without `websocket-client` it
falls back to batched HTTP POST using only the standard library. Install the
`ws` extra when you want the persistent socket.

---

## CLI

| Command | Does |
| --- | --- |
| `agent-visualizer serve` | Bridge + dashboard on `:8765` (opens a browser) |
| `agent-visualizer serve --port 9000` | Different port |
| `agent-visualizer serve --no-dashboard` | API only |
| `agent-visualizer demo` | Play a scripted three-agent scenario |
| `agent-visualizer info` | Version, extras, whether the UI is bundled |

---

## Design guarantees

- **Never breaks your program.** Every method is fire-and-forget; transport
  errors are swallowed and logged at DEBUG. If the bridge is not running, your
  agent code still runs at full speed.
- **Never blocks.** A daemon thread owns the socket; your calls only enqueue.
- **Survives restarts.** On reconnect the client re-announces every agent it
  registered, so the scene repopulates even if the bridge restarted mid-run.
- **Disable in production** with `AgentVisualizerClient(..., enabled=False)` —
  every method becomes a no-op.

For a long-running service, create **one** client at startup and share it;
`VisualizerCallback(server_url=...)` builds its own client and its own thread,
so constructing one per request leaks threads:

```python
client = AgentVisualizerClient()                      # once, at startup

def handle(state):
    vis = VisualizerCallback(client=client, reset_on_start=False)
    return graph.invoke(state, config={"callbacks": [vis]})
```

---

## Protocol

Any language that can send JSON can drive the visualizer:

```bash
curl -X POST http://localhost:8765/ingest -H 'Content-Type: application/json' \
  -d '{"event":"register","agent_id":"scout_1","name":"Scout","avatar_type":"rogue"}'
```

Five core events — `register`, `move`, `communicate`, `state_update`,
`graph_edge`. The full specification, including the JSON Schema, is in
`protocol/PROTOCOL.md` in the repository.

## License

MIT
