A virtual office where you hire and manage real AI agents. Each employee at a desk is a live coding agent that actually reads, writes, and runs code in its own workspace folder while you watch it work from a top-down Phaser office.
Hire an agent, give it a name, type a task, and watch it walk to its desk and start typing. Speech bubbles and the office feed stream its real tool calls and output in real time.
📖 Deep dive: see docs/DATABASE.md for querying the Supabase database, and the docs folder for feature-specific architecture guides.
┌─────────────────────┐ WebSocket ┌──────────────────────┐
│ Client (Phaser 3) │ ◄──── ws://:3001 ─────► │ Server (Node + ws) │
│ office scene, HUD │ │ AgentManager │
└─────────────────────┘ │ └─ Agent runner ──┼──► LLM API
└──────────┬───────────┘
│ each agent works in
▼
ag/workspace/<name>-<id>/
- The client is a Phaser 3 game served by Vite. It renders the office, animates agents between their desks, and shows a HUD for hiring, assigning tasks, and reading per-agent logs.
- The server is a Node WebSocket server (
ws://localhost:3001). It owns all state: the roster, per-agent logs, and the running SDK sessions. - All game data lives in one folder:
ag/. Each hired agent gets its own sandbox directory underag/workspace/— tasks run there; agents can create files, run shell commands, and search the web, but are instructed to stay inside their folder. - State persists across restarts: the full roster and every agent message are saved to
ag/save.json(the single save file the server reloads on boot), and each play session gets a JSON transcript inag/logs/. If the server restarts mid-task, agents come back idle with a note in their log.
- Hire as many agents as you want — the first 8 get desks, the rest work standing. Each gets a name, a random job title (Code Gremlin, Bug Whisperer, Refactor Goblin…), a sprite, and an optional custom system prompt set at hire time.
- Persistent memory — each agent is one continuous conversation with message history, resumed on every task, so it remembers every order you've given it and everything it did, across server restarts.
- Assign tasks to one agent or broadcast the same task to everyone who's free ("ASSIGN TO ALL").
- Live activity feed — assistant text, tool calls, results, and errors stream into the office feed and per-agent log panels.
- Stop and fire — abort a running task, or remove an agent entirely (their desk frees up).
- Status lifecycle:
idle → thinking → working → done / error, reflected in the game world.
- Node.js 20+
- pnpm
- A
DEEPSEEK_KEYin your environment /.env(see.env.examplefor all variables)
pnpm install
# (optional) regenerate the pixel-art tileset and character sprites
pnpm assets
# start the agent server and the Vite client together
pnpm devThen open http://localhost:5173. On first launch you'll name yourself and your office, then hit + HIRE AGENT to bring on your first employee.
| Command | What it does |
|---|---|
pnpm dev |
Runs the WebSocket server (tsx watch) and Vite client concurrently |
pnpm server |
Runs only the agent server on port 3001 |
pnpm client |
Runs only the Vite dev server on port 5173 |
pnpm build |
Builds the client into dist/ |
pnpm assets |
Regenerates sprites/tilesets into client/public/assets/ |
pnpm typecheck |
Type-checks the whole project with tsc --noEmit |
| Variable | Default | Purpose |
|---|---|---|
DEEPSEEK_KEY |
— | DeepSeek API key (primary LLM provider, required) |
KIMI_KEY |
— | Kimi/Moonshot API key (vision provider, optional) |
SUPABASE_URL |
— | Cloud Supabase URL (enables auth + persistence) |
SUPABASE_SERVICE_ROLE_KEY |
— | Supabase service role key (server-side, bypasses RLS) |
⚠️ Security note: agents can run shell commands inside their workspace folder. The workspace folder is a convention enforced by prompt (cwd+ instructions), not an OS sandbox. Treatag/workspace/as untrusted output, and disable auto-approve in Settings if you want manual confirmation before each command.
agent-game/
├── shared/
│ └── types.ts # Protocol + types shared by client and server (ClientMsg/ServerMsg, models, port)
├── server/
│ ├── index.ts # WebSocket server: connections, message routing, snapshots
│ ├── manager.ts # AgentManager: hire/assign/stop/fire, task lifecycle, desk + sprite allocation
│ ├── persistence.ts # SaveFile — roster and logs persisted to ag/save.json
│ ├── logger.ts # SessionLogger — append-only session log in ag/logs/
│ └── providers/
│ ├── types.ts # ProviderRunner interface (task → async stream of TaskEvents)
│ └── cline.ts # Agent runner (LLM API + local tools)
├── client/
│ ├── index.html
│ ├── public/assets/ # Generated tileset, character sprites, map
│ └── src/
│ ├── main.ts # Boot: Phaser game + HUD + WebSocket connection
│ ├── net.ts # WebSocket client
│ ├── store.ts # Client-side state synced from server messages
│ ├── ui/hud.ts # DOM HUD: roster, hire dialog, task input, log panels
│ └── game/
│ ├── scene.ts # Office scene: tilemap, desks, camera
│ ├── agent.ts # Agent sprites, walking animation, speech bubbles
│ └── path.ts # Grid pathfinding for agent movement
├── scripts/
│ └── generate-assets.ts # Procedurally generates all pixel art (pngjs)
└── ag/ # All game data (gitignored)
├── save.json # the save file — roster + every agent message
├── logs/ # one JSON transcript per play session
└── workspace/ # per-agent working directories
Providers are pluggable. Implement the ProviderRunner signature from server/providers/types.ts — an async generator that takes a task plus run context (cwd, model, systemPrompt, abort) and yields TaskEvents (text | tool | result | error) — then wire it into the runner selection in server/manager.ts and add its models to shared/types.ts.
All persistent state lives in a cloud Supabase (Postgres) instance. The project is pre-linked via supabase link.
# Query the production DB
npx supabase db query "SELECT COUNT(*) FROM public.api_usage_records" --linkedSee docs/DATABASE.md for the full guide — table reference, common queries, and pitfalls to avoid.