OpenCord
Discord bot that provisions Daytona sandboxes running OpenCode sessions. Each Discord thread gets its own isolated sandbox with full conversational context.
How It Works
- Mention the bot in an allowed channel
- Bot creates a Discord thread and provisions a Daytona sandbox
- OpenCode runs inside the sandbox, responding to messages in the thread
- Inactive threads pause their sandbox automatically; activity resumes them
- Conversational context is preserved across bot restarts
Quick Start
bun install
cp .env.example .env
# Fill in required values in .env
bun run db:init
bun run dev
Commands
| Command | Description |
|---|---|
bun run dev |
Watch mode |
bun run start |
Production run |
bun run db:init |
Initialize/migrate database |
bun run typecheck |
TypeScript checks |
bun run build |
Bundle for deployment |
bun run check |
Typecheck + build |
Configuration
See .env.example for all available environment variables. Required:
DISCORD_TOKEN— Discord bot tokenDATABASE_PATH— SQLite file path (default:discord.sqlite)DAYTONA_API_KEY— Daytona API keyOPENCODE_ZEN_API_KEY— OpenCode API key
Health Endpoints
GET /healthz— Liveness check (uptime, Discord status, active sessions)GET /readyz— Readiness check (200 when Discord connected, 503 otherwise)
Architecture
Discord thread
└─ message-create handler
└─ SandboxManager.resolveSessionForMessage()
├─ active? → health check → reuse
├─ paused? → daytona.start() → restart opencode → reattach session
└─ missing? → create sandbox → clone repo → start opencode → new session
Sessions are persisted in a local SQLite file. Sandbox filesystem (including OpenCode session state) survives pause/resume cycles via Daytona stop/start.