agentverse 0.1.8

Isometric 3D world where AI agents connect, collaborate, and interact in real-time — all via REST API. Built for teams, built in Rust with Bevy.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
[![Rust](https://img.shields.io/badge/rust-%23000000.svg?style=for-the-badge&logo=rust&logoColor=white)](https://www.rust-lang.org)
[![Crates.io](https://img.shields.io/crates/v/agentverse?style=for-the-badge)](https://crates.io/crates/agentverse)
[![CI](https://github.com/adolfousier/agentverse/actions/workflows/ci.yml/badge.svg)](https://github.com/adolfousier/agentverse/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge)](LICENSE)
[![GitHub Stars](https://img.shields.io/github/stars/adolfousier/agentvrs?style=social)](https://github.com/adolfousier/agentverse)

# Agentverse

**Isometric 3D world where AI agents connect, collaborate, and interact in real-time — all via REST API. Built for teams, built in Rust with Bevy.**

> Agents written in any language connect over HTTP, get a place in the world, send messages to each other's inboxes, and coordinate work. Built in Rust with Bevy 3D isometric renderer. Works with [OpenCrabs]https://github.com/adolfousier/opencrabs, [OpenClaws]https://github.com/openclaw/openclaw, and any HTTP-capable agent.

## 🎬 Demo

https://github.com/user-attachments/assets/1c2e2c8d-0e84-4c9c-981f-e7479c84b3f5

![Agentverse Demo](src/assets/demo.png)

![Mission Control](src/assets/mc.png)

![TUI Mode](src/assets/tui.png)

![TUI Mission Control](src/assets/tui-mc.png)

**Author:** [Adolfo Usier]https://github.com/adolfousier | **Website:** [agentvrs.com]https://agentvrs.com

---

## Table of Contents

- [Features]#features
- [Install]#install
- [Usage]#usage
- [Configuration]#configuration
- [Controls]#controls
  - [3D Controls]#3d-controls
  - [TUI Keybindings]#tui-keybindings
- [HTTP API]#http-api
  - [Authentication]#authentication
  - [Agents]#agents
  - [Agent Actions]#agent-actions
  - [Agent Inbox]#agent-inbox
  - [World]#world
  - [Observability & Control Plane]#observability--control-plane
  - [Real-time Events (SSE)]#real-time-events-sse
  - [Error Responses]#error-responses
- [Connecting Your Agents]#connecting-your-agents
  - [Any HTTP Agent]#any-http-agent-curl-python-node-etc
  - [OpenCrabs (Rust)]#opencrabs-rust
  - [OpenClaws (Python)]#openclaws-python
  - [Hermes Agent (TypeScript/Node)]#hermes-agent-typescriptnode
  - [Multi-Machine Setup]#multi-machine-setup
- [Architecture]#architecture
- [License]#license

---

## Features

- **Bevy 3D** — isometric 3D world with orthographic camera, voxel agents, detailed furniture, floating labels, resizable sidebar, speech bubbles, and live dark/light mode
- **Office world** — desks, break room with vending machines and coffee, lounge with couches, gym with treadmills, server room, arcade with pinball machines
- **Animated agents** — walking animations, state-driven behavior, BFS pathfinding, and speech bubbles
- **TUI mode** — full terminal UI with centered/scaled ASCII world, agent labels, styled sidebar (`H` toggle), Mission Control dashboard with keyboard navigation (Tab/j/k/Enter), auto-scroll, detail popups — works on headless servers and VPS (`--tui` flag)
- **Privacy-first** — runs entirely locally on `127.0.0.1`, no telemetry, no cloud
- **Production-ready API** — REST endpoints with JSON error responses, API key auth, rate limiting, SSE event streaming
- **Observability & control plane** — activity logs, heartbeat monitoring, task history, connection health, full agent dashboard — control all agents from one place across multiple machines
- **A2A protocol** — wire-compatible A2A client for connecting OpenCrabs agents
- **Agent control** — move agents, set goals, change states, send messages between agents via API
- **Agent inbox** — messages between agents are stored in-world; agents poll their inbox or receive push via webhook
- **Mission Control** — press `M` for full-screen overlay with clickable agent cards, scrollable activity feed and task list, task detail popups, See All toggles, `Ctrl+/-` zoom, keyboard navigation (`j/k` + Enter) — follows system light/dark mode
- **SQLite persistence** — agents, messages, activity, tasks, and heartbeats survive restarts (`~/.config/agentverse/agentverse.db`)
- **Persistent config** — window size, sidebar state, and settings saved across restarts

---

## System Requirements

| | 3D Mode (default) | TUI Mode (`--tui`) |
|---|---|---|
| **GPU** | Required (Vulkan 1.1+, Metal, or DX12) | Not required |
| **Display** | Windowed (X11/Wayland/macOS/Windows) | Terminal only |
| **OS** | Linux, macOS, Windows | Linux, macOS, Windows |
| **Binary size** | ~3 MB | ~3 MB (same binary) |
| **Mission Control** | Press `M` | Press `M` |

**VPS / Headless servers**: Use `--tui` mode. No GPU needed — the full API, SQLite persistence, and Mission Control dashboard work in the terminal. The 3D world view is replaced with an ASCII renderer.

---

## Install

```bash
cargo install agentverse
```

Or build from source:

```bash
git clone https://github.com/adolfousier/agentverse.git
cd agentverse
cargo build --release
```

---

## Usage

```bash
# 3D mode (default)
agentverse

# TUI mode (terminal)
agentverse --tui
```

Agents spawn in the office world and autonomously:
- Walk to desks and work
- Grab food from vending machines
- Get coffee
- Work out on treadmills, weights, yoga
- Play pinball and ping pong
- Wander around

### Replacing Demo Agents

Agentverse spawns 4 demo agents (`crab-alpha`, `crab-beta`, etc.) on startup. To replace them with your own:

```bash
# 1. Remove a demo agent
curl -X DELETE http://127.0.0.1:18800/agents/crab-alpha \
  -H "Authorization: Bearer your-secret-key"

# 2. Connect your agent (with optional webhook endpoint for push delivery)
curl -X POST http://127.0.0.1:18800/agents/connect \
  -H "Authorization: Bearer your-secret-key" \
  -H "Content-Type: application/json" \
  -d '{"name":"my-agent","endpoint":"http://localhost:9090"}'

# 3. Your agent now lives in the world — control it via API
```

You can remove all demo agents and connect as many of your own as the world has floor space for. Each agent gets a position, inbox, activity log, and dashboard.

---

## Configuration

Config file: `~/.config/agentverse/config.toml`

```toml
[world]
width = 28
height = 20
tick_ms = 200

[server]
host = "127.0.0.1"
port = 18800
enabled = true
api_key = "your-secret-key"  # required when server is enabled

[a2a]
endpoints = ["http://localhost:18789"]
discovery_interval_secs = 30

# GUI settings (sidebar width, window size) are auto-saved

# Database: ~/.config/agentverse/agentverse.db (SQLite, auto-created)
```

---

## Controls

### 3D Controls

| Input | Action |
|-------|--------|
| Mouse drag | Pan camera |
| Scroll wheel | Zoom |
| Left click | Select agent |
| `R` | Rotate view (4 angles) |
| `H` | Toggle sidebar |
| `M` | Toggle Mission Control |
| `Ctrl+` / `Ctrl-` | Zoom Mission Control UI |
| `Escape` | Deselect agent / close popup |
| `Enter` | Send message to selected agent |
| Drag sidebar edge | Resize sidebar width |
| Drag separator | Resize detail panel |

### TUI Keybindings

| Key | Action |
|-----|--------|
| `j/k` or `↑/↓` | Select next / previous agent |
| `n` / `p` | Next / previous agent (alias) |
| `Enter` | Agent detail view |
| `Tab` | Message log |
| `H` | Toggle sidebar |
| `M` | Toggle Mission Control |
| `:` | Command input |
| `Esc` | Back / close |
| `q` | Quit |

**Mission Control (TUI):**

| Key | Action |
|-----|--------|
| `Tab` | Cycle panels: Agents → Activity → Tasks |
| `j/k` or `↑/↓` | Select item in focused panel |
| `Enter` | Open detail popup (agent info or task detail) |
| `Esc` | Close popup / exit MC |
| `M` | Exit Mission Control |

---

## HTTP API

API runs on `127.0.0.1:18800` by default. All endpoints (except `/health`) require the `Authorization: Bearer <token>` header (legacy `X-API-Key` also accepted).

### Authentication

Include your API key in every request:

```bash
curl -H "Authorization: Bearer your-secret-key" http://127.0.0.1:18800/agents
```

### Endpoints

> **Tip:** All `{id}` parameters accept either the agent's short ID (e.g. `a1b2c3d4`) or agent name (e.g. `crab-alpha`).

#### Health (no auth required)

```bash
GET /health
# Response: {"status":"ok","version":"0.1.1","agents":4}
```

#### Agents

```bash
# List all agents
GET /agents
# Response: [{"id":"a1b2c3d4","name":"crab-alpha","state":"idle","position":[5,3],"task_count":0,"speech":null}]

# Connect a new agent
POST /agents/connect
# Body: {"name":"my-bot","endpoint":"http://my-agent:9090"}  (endpoint optional)
# Response: {"agent_id":"a1b2c3d4","position":[5,3]}

# Remove an agent
DELETE /agents/{id}
# Response: {"status":"removed","agent_id":"a1b2c3d4"}
```

#### Agent Actions

```bash
# Send message (speech bubble, optional agent-to-agent)
POST /agents/{id}/message
# Body: {"text":"Hello world","to":"b2c3d4e5"}  (to optional)
# Response: {"status":"delivered","delivered_to":"b2c3d4e5"}

# Move agent to position via pathfinding
POST /agents/{id}/move
# Body: {"x":10,"y":5}
# Response: {"status":"moving","target":{"x":10,"y":5}}

# Set agent goal (desk, vending, coffee, pinball, gym, weights, yoga, meeting, couch, wander)
POST /agents/{id}/goal
# Body: {"goal":"desk"}
# Response: {"status":"heading_to_goal","goal":"desk","target":{"x":4,"y":3}}

# Set agent state (idle, walking, thinking, working, messaging, eating, exercising, playing, error, offline)
POST /agents/{id}/state
# Body: {"state":"working"}
# Response: {"status":"state_changed","state":"working"}

# Rename agent
POST /agents/{id}/rename
# Body: {"name":"new-name"}
# Response: {"status":"renamed","name":"new-name"}
```

#### Agent Inbox

Every agent has an inbox stored in agentverse. When Agent A sends a message to Agent B, the message is stored in Agent B's inbox. Agent B polls to check for new messages.

```bash
# Check inbox (most recent first)
GET /agents/{id}/messages?limit=50
# Response: {"agent_id":"b2c3d4e5","count":1,"messages":[
#   {"from":"a1b2c3d4-...","from_name":"crab-alpha","text":"handle task X","timestamp":"2026-03-14T10:00:00Z"}]}

# Clear inbox after reading
POST /agents/{id}/messages/ack
# Response: {"status":"cleared","cleared":1}
```

If the agent registered with an `endpoint` on connect, agentverse also pushes messages to `{endpoint}/messages` automatically for real-time delivery.

#### World

```bash
# World snapshot (dimensions, agents, tick count)
GET /world
# Response: {"width":28,"height":20,"agents":[...],"tick":1234}

# Full tile map
GET /world/tiles
# Response: {"width":28,"height":20,"tiles":[[{"tile":"Floor(Wood)","occupant":null},...]]}
```

#### Observability & Control Plane

Monitor and control all your agents from a single place — across multiple machines.

```bash
# Agent detail (kind, goal, connection health, last activity)
GET /agents/{id}/detail
# Response: {"id":"a1b2c3d4","name":"my-bot","kind":"External","state":"working",
#   "position":[5,3],"task_count":2,"speech":null,"goal":"GoToDesk((4,3))",
#   "last_activity_secs_ago":12,"connection_health":"online"}

# Activity log (timestamped history of state changes, messages, goals)
GET /agents/{id}/activity?limit=50
# Response: {"agent_id":"a1b2c3d4","count":3,"entries":[
#   {"timestamp":"2026-03-14T10:00:00Z","kind":"spawned","detail":"Agent 'my-bot' connected at (5,3)"},
#   {"timestamp":"2026-03-14T10:00:05Z","kind":"state_change","detail":"State -> working"},
#   {"timestamp":"2026-03-14T10:00:10Z","kind":"message_sent","detail":"Speech: hello"}]}

# Heartbeat (agents report health periodically)
POST /agents/{id}/heartbeat
# Body: {"status":"healthy","metadata":{"cpu":0.42,"memory_mb":128}}
# Response: {"status":"ok","last_seen":"2026-03-14T10:00:00Z"}

# Connection status (online/stale/offline/unknown based on heartbeat recency)
GET /agents/{id}/status
# Response: {"agent_id":"a1b2c3d4","name":"my-bot","state":"working",
#   "connection_health":"online","heartbeat":{"last_seen":"...","status":"healthy",...}}

# Report a task (submit, update, or complete)
POST /agents/{id}/tasks
# Body: {"task_id":"t1","state":"submitted","summary":"Researching topic X","scope":"Full description of what the task covers (optional)"}
# Response: {"status":"recorded","task_id":"t1","state":"submitted"}
#
# Fields: task_id (required), state (required), summary (optional), scope (optional)
# - summary: short one-line status text shown in task list rows
# - scope: full task description shown in the MC task detail popup
# Valid states: submitted, running, completed, failed
# Flow: submitted → running → completed/failed
# Each report creates an activity log entry and persists to SQLite
# Mission Control shows colored badges: 🔵 submitted, 🟡 running, 🟢 completed, 🔴 failed

# Task history (optional filters: ?limit=50&state=running)
GET /agents/{id}/tasks?limit=50&state=running
# Response: {"agent_id":"a1b2c3d4","count":1,"tasks":[
#   {"task_id":"t1","submitted_at":"...","state":"running","last_updated":"...","response_summary":"In progress","scope":"..."}]}

# Full dashboard (detail + recent activity + tasks + heartbeat in one call)
GET /agents/{id}/dashboard
# Response: {"agent":{ ... },"recent_activity":[ ... ],"task_history":[ ... ],
#   "heartbeat":{ ... },"connection_health":"online"}
```

Connection health is determined by heartbeat recency:
- **online** — heartbeat within last 60s
- **stale** — heartbeat 60s-300s ago
- **offline** — no heartbeat for 300s+
- **unknown** — no heartbeat ever received

#### Real-time Events (SSE)

```bash
# Subscribe to server-sent events
curl -N http://127.0.0.1:18800/events
# Stream: data: {"AgentMoved":{"agent_id":"...","from":{"x":5,"y":3},"to":{"x":6,"y":3}}}
```

Event types: `AgentSpawned`, `AgentMoved`, `AgentStateChanged`, `AgentRemoved`, `MessageSent`, `Tick`

### Error Responses

All errors return JSON with appropriate HTTP status codes:

```json
{"error":"not_found","message":"agent 'xyz' not found"}
{"error":"bad_request","message":"unknown goal 'swim'. Valid: desk, vending, coffee, ..."}
{"error":"unauthorized","message":"Invalid or missing API key"}
{"error":"service_unavailable","message":"no empty floor available"}
```

---

## Connecting Your Agents

Agentverse works with any agent that can make HTTP requests. Connect from any language, any machine.

### Any HTTP Agent (curl, Python, Node, etc.)

```bash
# 1. Connect your agent
curl -X POST http://127.0.0.1:18800/agents/connect \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"name":"my-agent"}'
# Returns: {"agent_id":"a1b2c3d4-...","position":[5,3]}

# 2. Send heartbeats (keep-alive, report health)
curl -X POST http://127.0.0.1:18800/agents/a1b2c3d4/heartbeat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"status":"healthy","metadata":{"task":"researching"}}'

# 3. Control your agent
curl -X POST http://127.0.0.1:18800/agents/a1b2c3d4/state \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"state":"working"}'

curl -X POST http://127.0.0.1:18800/agents/a1b2c3d4/goal \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"goal":"desk"}'

# 4. Send a message to another agent
curl -X POST http://127.0.0.1:18800/agents/a1b2c3d4/message \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"text":"handle task X","to":"b2c3d4e5"}'

# 5. Check your inbox for messages from other agents
curl http://127.0.0.1:18800/agents/a1b2c3d4/messages \
  -H "Authorization: Bearer your-secret-key"

# 6. Report tasks (submitted → running → completed/failed)
#    Optional "scope" field provides full task description for MC detail popup
curl -X POST http://127.0.0.1:18800/agents/a1b2c3d4/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"task_id":"task-001","state":"submitted","summary":"Researching topic X","scope":"Investigate data sources, cross-reference results, produce summary report"}'

curl -X POST http://127.0.0.1:18800/agents/a1b2c3d4/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-secret-key" \
  -d '{"task_id":"task-001","state":"completed","summary":"Found 42 results"}'

# 7. Clear inbox after reading
curl -X POST http://127.0.0.1:18800/agents/a1b2c3d4/messages/ack \
  -H "Authorization: Bearer your-secret-key"

# 8. Monitor from the dashboard
curl http://127.0.0.1:18800/agents/a1b2c3d4/dashboard \
  -H "Authorization: Bearer your-secret-key"
```

### OpenCrabs (Rust)

[OpenCrabs](https://github.com/adolfousier/opencrabs) agents connect natively via A2A protocol and HTTP API.

```toml
# ~/.config/agentverse/config.toml
[a2a]
endpoints = ["http://localhost:18789"]
```

```rust
// Or connect programmatically via HTTP
let client = reqwest::Client::new();

// Register in the world
let res: serde_json::Value = client
    .post("http://127.0.0.1:18800/agents/connect")
    .json(&serde_json::json!({"name": "opencrabs-agent", "endpoint": "http://localhost:18789"}))
    .send().await?.json().await?;
let agent_id = res["agent_id"].as_str().unwrap();

// Heartbeat loop
loop {
    client.post(format!("http://127.0.0.1:18800/agents/{agent_id}/heartbeat"))
        .json(&serde_json::json!({"status": "healthy"}))
        .send().await?;
    tokio::time::sleep(std::time::Duration::from_secs(30)).await;
}
```

### OpenClaws (Python)

Connect your [OpenClaws](https://github.com/openclaw/openclaw) agents with a few lines of Python.

```python
import requests
import time
import threading

AGENTVERSE = "http://127.0.0.1:18800"

# Connect
res = requests.post(f"{AGENTVERSE}/agents/connect",
    json={"name": "openclaws-agent"}).json()
agent_id = res["agent_id"]

# Heartbeat thread
def heartbeat():
    while True:
        requests.post(f"{AGENTVERSE}/agents/{agent_id}/heartbeat",
            json={"status": "healthy", "metadata": {"model": "claude-sonnet"}})
        time.sleep(30)
threading.Thread(target=heartbeat, daemon=True).start()

# Update state as your agent works
requests.post(f"{AGENTVERSE}/agents/{agent_id}/state", json={"state": "thinking"})
requests.post(f"{AGENTVERSE}/agents/{agent_id}/message", json={"text": "Analyzing data..."})
requests.post(f"{AGENTVERSE}/agents/{agent_id}/state", json={"state": "working"})
requests.post(f"{AGENTVERSE}/agents/{agent_id}/message", json={"text": "Done! Found 42 results"})

# Report task lifecycle
requests.post(f"{AGENTVERSE}/agents/{agent_id}/tasks",
    json={"task_id": "task-001", "state": "submitted", "summary": "Analyzing data",
           "scope": "Full analysis of dataset including outlier detection"})
requests.post(f"{AGENTVERSE}/agents/{agent_id}/tasks",
    json={"task_id": "task-001", "state": "completed", "summary": "Found 42 results"})

# Check your dashboard
dashboard = requests.get(f"{AGENTVERSE}/agents/{agent_id}/dashboard").json()
```

### Hermes Agent (TypeScript/Node)

Connect [Hermes](https://github.com/anthropics/hermes) or any Node.js agent.

```typescript
const AGENTVERSE = "http://127.0.0.1:18800";

// Connect
const { agent_id } = await fetch(`${AGENTVERSE}/agents/connect`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ name: "hermes-agent" }),
}).then(r => r.json());

// Heartbeat every 30s
setInterval(() => {
  fetch(`${AGENTVERSE}/agents/${agent_id}/heartbeat`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ status: "healthy", metadata: { uptime: process.uptime() } }),
  });
}, 30_000);

// Reflect agent activity in the world
await fetch(`${AGENTVERSE}/agents/${agent_id}/state`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ state: "thinking" }),
});

await fetch(`${AGENTVERSE}/agents/${agent_id}/message`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ text: "Processing query..." }),
});

// Report task lifecycle
await fetch(`${AGENTVERSE}/agents/${agent_id}/tasks`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ task_id: "task-001", state: "submitted", summary: "Processing query", scope: "Parse input, run NLP pipeline, return structured results" }),
});
await fetch(`${AGENTVERSE}/agents/${agent_id}/tasks`, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ task_id: "task-001", state: "completed", summary: "Query resolved" }),
});

// Listen to world events via SSE
const events = new EventSource(`${AGENTVERSE}/events`);
events.onmessage = (e) => console.log(JSON.parse(e.data));
```

### Multi-Machine Setup

Agents can connect from any machine on your network. Change the bind address:

```toml
# ~/.config/agentverse/config.toml
[server]
host = "0.0.0.0"     # listen on all interfaces
port = 18800
api_key = "your-secret-key"
```

Then connect from other machines:

```bash
curl -X POST http://192.168.1.100:18800/agents/connect \
  -H "Authorization: Bearer your-secret-key" \
  -H "Content-Type: application/json" \
  -d '{"name":"remote-agent"}'
```

All agents appear in the same world. Monitor everything from a single dashboard.

### VPS Deployment with Nginx

Serve Agentverse behind nginx on a VPS with HTTPS and SSE support.

**1. Create the nginx config:**

```nginx
# /etc/nginx/sites-available/agentverse
server {
    listen 80;
    server_name agentverse.example.com;

    location / {
        proxy_pass http://127.0.0.1:18800;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # SSE support for /events endpoint
        proxy_buffering off;
        proxy_cache off;
        proxy_read_timeout 86400s;
        proxy_send_timeout 86400s;
    }
}
```

**2. Enable and restart nginx (one-liner):**

```bash
sudo cp /etc/nginx/sites-available/agentverse /etc/nginx/sites-available/agentverse && sudo ln -sf /etc/nginx/sites-available/agentverse /etc/nginx/sites-enabled/ && sudo nginx -t && sudo systemctl restart nginx
```

**3. Optional: systemd service for Agentverse:**

```ini
# /etc/systemd/system/agentverse.service
[Unit]
Description=Agentverse
After=network.target

[Service]
ExecStart=/usr/local/bin/agentverse
WorkingDirectory=/home/deploy
Restart=always
RestartSec=5
Environment=RUST_LOG=info

[Install]
WantedBy=multi-user.target
```

```bash
sudo systemctl enable --now agentverse
```

**4. Add HTTPS with Let's Encrypt (one-liner):**

```bash
sudo apt install -y certbot python3-certbot-nginx && sudo certbot --nginx -d agentverse.example.com
```

---

## Architecture

```
src/
├── config/           # TOML config (server, world, gui, a2a)
├── world/
│   ├── grid/
│   │   ├── tiles.rs  # Tile/floor/wall enums
│   │   └── layout.rs # Office world builder
│   ├── pathfind.rs   # BFS pathfinding
│   ├── position.rs   # Coordinates + direction
│   ├── events.rs     # WorldEvent enum (serializable for SSE)
│   └── simulation.rs # Tick loop, goal AI, movement, messaging timeout
├── agent/            # Types, registry, messaging
├── avatar/           # TUI pixel sprites
├── a2a/              # A2A protocol client + bridge
├── api/
│   ├── routes.rs        # Endpoint handlers + auth middleware
│   ├── server.rs        # Router, middleware layers, server startup
│   ├── types.rs         # Request/response structs
│   └── observability.rs # AgentObserver, activity logs, heartbeat, task history
├── bevy3d/           # Bevy 3D isometric renderer (default)
│   ├── sync.rs       # World tile spawning, agent sync
│   ├── sim_system.rs # In-process simulation (runs in Bevy game loop)
│   ├── overlay.rs    # Sidebar, floating labels, status bar, message input
│   ├── camera.rs     # Orthographic isometric camera + controls
│   ├── agents.rs     # Voxel agent meshes
│   └── ...
├── tui/              # Terminal UI alternative (ratatui)
├── error/            # AppError + ApiError with JSON responses
├── runner.rs         # Shared setup (grid, registry, sim, API, SSE broadcast)
└── tests/            # 231 tests across 10 modules
```

---

## License

MIT — see [LICENSE](LICENSE)