Rabbit Hole Inc

Describe an AI agent in plain words and Rabbit Hole drafts its config. You run the agent on your own machine.

What Rabbit Hole does

How we use Google services

Rabbit Hole uses Google OAuth to sign users in. We access only the scopes the user authorizes. All data is processed per our Privacy Policy.

User data is never sold or shared with third parties for advertising.

technical

Building Wunderland: From CLI to Full-Stack Agent Platform

Johnny Dunn·March 1, 2026·7 min read
wunderlandarchitectureclidockersqlitegraphologydeep-dive

Wunderland started as a CLI tool. Seventeen commands. One SQLite database. File-based configuration you could check into git. The kind of project that fits in your head.

It didn't stay that way.

Twelve months later, Wunderland is a full-stack agent platform: 37 messaging channel adapters, 23 LLM provider integrations, a graph-based capability discovery engine, an agent dashboard at rabbithole.inc, and a Docker Compose export that lets you self-host the agent on a small VPS. This post covers the architecture decisions that got us here — what we chose, what we rejected, and why.

Why File-Based Configuration

Agent frameworks love dashboards. Point and click to configure your agent. Drag and drop to add tools. The experience feels polished in a demo. In practice, it creates three problems.

No version control. When your agent's personality lives in a database row behind a web form, you can't git log to see what changed, git blame to see who changed it, or git revert to undo a bad config push. You're back to screenshots and "I think it used to say something different."

No environments. Development, staging, production — the standard deployment pipeline assumes your configuration lives in files that can be branched and merged. Database-backed configs require custom export/import tooling that nobody builds until it's too late.

No composability. Files compose. You can cat them, diff them, template them with envsubst, validate them with JSON Schema, and feed them into CI/CD pipelines. A config stored behind an API endpoint requires bespoke integration at every step.

Wunderland's agent configuration is a single agent.config.json file:

{
  "name": "support-agent",
  "personality": "Helpful, concise, technically precise",
  "provider": {
    "name": "anthropic",
    "model": "claude-sonnet-4-20250514"
  },
  "security_tier": "balanced",
  "channels": ["telegram", "discord", "webchat"],
  "skills": ["web-search", "calendar", "file-ops"],
  "memory": {
    "backend": "sqlite",
    "path": "./data/memory.db"
  }
}

wunderland export serializes this plus all resolved skills, tool schemas, and channel configs into a portable manifest. wunderland import rebuilds it anywhere. The file is the source of truth.

SQLite as the Default Database

Every agent platform eventually needs a database. Conversation history, memory, user preferences, approval queues, audit logs. The question is which database.

Postgres is the obvious choice for a platform that expects multi-tenant production traffic. We'll get there. But for the CLI use case — a developer running a single agent on their laptop or a small team deploying to a VPS — Postgres is overhead. You need a running server, connection management, migrations, backups.

SQLite gives you a single file. cp data/app.sqlite3 backup.sqlite3 is your backup strategy. scp it to another machine and your agent picks up where it left off. No daemon. No port conflicts. No connection pool tuning.

We use Drizzle ORM for schema definition and queries. The schema lives in code, migrations are explicit, and switching to Postgres later is a Drizzle adapter swap — not a rewrite.

Schema Design

The ensureColumnExists pattern handles migrations without downtime. Instead of a formal migration runner that locks tables, each service checks for required columns at startup and adds them if missing:

async function ensureColumnExists(
  db: Database,
  table: string,
  column: string,
  type: string,
  defaultValue?: string,
) {
  const info = db.prepare(`PRAGMA table_info(${table})`).all();
  const exists = info.some((col: any) => col.name === column);
  if (!exists) {
    const def = defaultValue !== undefined ? ` DEFAULT ${defaultValue}` : '';
    db.prepare(`ALTER TABLE ${table} ADD COLUMN ${column} ${type}${def}`).run();
  }
}

Rough? Yes. Production-grade for multi-team schema management? No. But for a single-agent database where the application owns the entire schema, it's simpler and more reliable than a migration folder that gets out of sync.

Capability Discovery with graphology

Most agent frameworks give the LLM a flat list of tools. "Here are your 23 tools. Here are their schemas. Figure it out." This approach scales terribly. At 23 tools with ~80 tokens per schema, you're burning 1,840 tokens on a phone book before the conversation starts. At 50 tools, you've lost 4,000 tokens — context window space that could hold actual conversation history.

Graph-Based Tool Relationships

The capability discovery engine uses graphology — a graph library for JavaScript — to model relationships between tools, skills, and categories. Four edge types:

| Edge | Meaning | |------|---------| | DEPENDS_ON | Tool A requires Tool B (e.g., code-execute depends on file-write) | | COMPOSED_WITH | Tools commonly used together (learned from usage patterns) | | SAME_CATEGORY | Tools in the same functional category | | TAGGED_WITH | Tool shares a semantic tag with another |

When the discovery engine receives a query, it doesn't search a flat list. It traverses the graph: find the best semantic match, follow its edges to related capabilities, rank by relevance, and return the top-N results.

Tiered Loading

Capabilities load in three tiers:

Tier 0 always ships in the system prompt. Category summaries only — "You have access to tools for: file operations, web search, calendar management, code execution, communication." About 150 tokens.

Tier 1 activates per-message. The engine embeds the user's message, runs approximate nearest neighbor search (HNSW index via the existing IVectorStore interface), and returns the top 5 matches with one-line descriptions. About 200 tokens.

Tier 2 activates per-tool-call. When the agent decides to use a specific capability, the full JSON schema loads. About 300 tokens per tool, but only for tools the agent actually invokes.

Net context usage: ~350 tokens at rest, ~650 tokens during active tool use. Compared to the flat-list approach at ~1,840 tokens always, that's a 75-80% reduction.

Louvain Community Detection

The graph also powers automatic category assignment. New tools added to the registry don't need manual categorization — Louvain community detection identifies which cluster of existing tools the new one relates to and assigns it accordingly. The categories in Tier 0 update automatically.

Channel Architecture: 37 Platforms, One Agent

The channel system was designed around a single interface:

interface IChannelAdapter {
  platform: ChannelPlatform;
  connect(): Promise<void>;
  disconnect(): Promise<void>;
  send(message: OutboundMessage): Promise<void>;
  onMessage(handler: (message: InboundMessage) => void): void;
}

Every adapter implements this. Telegram, Discord, Slack, WhatsApp, Signal, Matrix, email, SMS — same four methods. The ChannelRouter dispatches inbound messages to the agent runtime and routes outbound messages back to the correct adapter.

Why Native Adapters Matter

A common shortcut: build one adapter for Telegram, then use bridge services (Matterbridge, Matrix bridges) for everything else. Bridges lose platform-specific features. Discord has embeds, reaction roles, thread replies. Telegram has inline keyboards, channel posts, bot commands. Slack has blocks, workflows, app home tabs.

Each Wunderland adapter uses the platform's native SDK. Discord embeds render as embeds. Telegram inline keyboards render as keyboards. The agent's response format adapts to the platform automatically — same content, platform-native presentation.

Priority Tiers

The first 20 channels shipped in four tiers, in order of user demand:

  • P0 (launch): Telegram, WhatsApp, Discord, Slack, webchat
  • P1 (month 2): Signal, iMessage, Google Chat, Teams
  • P2 (month 3): Matrix, Zalo, email, SMS
  • P3 (ongoing): Nostr, Twitch, Line, Feishu, Mattermost, Nextcloud Talk, Tlon

Each tier shipped when the adapter was stable in production, not when we had a "works in dev" proof of concept.

Docker Compose Export

Self-hosting shouldn't require reading deployment docs for an hour. The Rabbit Hole dashboard exports a complete docker-compose.yml with:

  • The agent runtime container (Node.js)
  • SQLite data volume
  • Configured channel adapters
  • Environment variable template

docker compose up -d and your agent is live. The same config that runs on your laptop runs on a small VPS.

What Comes Next

The architecture is modular by design. Each piece — provider registry, channel system, capability discovery, security tiers — is a standalone package in the monorepo. Adding a new LLM provider is a 50-line adapter. Adding a new channel is implementing four methods. Adding a new skill is writing a SKILL.md file and dropping it in the registry.

The platform scales by composition, not by complexity. That's the bet.

Discussion