# Oracle Bot — Mortdecai Mind's Eye

Live HTML5 viewport that renders what the Mortdecai AI model "sees" during Minecraft server interactions.

**Public URL:** `mind.mortdec.ai`

## Quick Start (local dev)

```bash
cd oracle-bot
npm install
node server.js
# Open http://localhost:3333
```

## Deploy to CT 644

```bash
# 1. Copy files to CT 644
ssh pve112 "pct exec 644 -- mkdir -p /opt/oracle-bot"
scp -r oracle-bot/* pve112:/tmp/oracle-bot/
ssh pve112 "pct push 644 /tmp/oracle-bot/ /opt/oracle-bot/ --recursive"

# 2. Install deps on CT 644
ssh pve112 "pct exec 644 -- bash -c 'cd /opt/oracle-bot && npm install --production'"

# 3. Install systemd service
ssh pve112 "pct exec 644 -- cp /opt/oracle-bot/oracle-bot.service /etc/systemd/system/"
ssh pve112 "pct exec 644 -- systemctl daemon-reload"
ssh pve112 "pct exec 644 -- systemctl enable --now oracle-bot"

# 4. Verify
ssh pve112 "pct exec 644 -- curl -s http://localhost:3333/health"
```

## Caddy Config (CT 600)

Add to `/etc/caddy/Caddyfile`:

```
mind.mortdec.ai {
    @internal path /trace /command
    respond @internal 404

    reverse_proxy 192.168.0.244:3333
}
```

Then: `caddy reload --config /etc/caddy/Caddyfile`

## Endpoints

| Endpoint | Access | Description |
|----------|--------|-------------|
| `GET /` | Public | Frontend (index.html) |
| `WS /ws` | Public | WebSocket stream |
| `GET /health` | Public | Health check |
| `POST /trace` | Internal | Gateway tool traces |
| `POST /command` | Internal | Bot commands |

## Test with simulated traces

```bash
curl -X POST http://localhost:3333/trace \
  -H "Content-Type: application/json" \
  -d '{"tool":"rcon.execute","input":{"command":"give slingshooter08 diamond 16"},"ok":true,"step":0,"mode":"god","player":"slingshooter08","session_id":"test-001"}'
```
