Architecture
OpenBot is built on a modern, event-driven architecture designed for high extensibility and local-first performance.
The Event Bus
Section titled “The Event Bus”At the heart of OpenBot is a central event bus. Every action, from a user typing a message to an agent performing a tool call, is represented as an event.
Event Flow
Section titled “Event Flow”- Source: An event is published to the bus (e.g., via
POST /api/publish). - Routing: The Melony-powered runtime routes the event to all subscribed agents and plugins.
- Processing: Subscribed components process the event and may perform side effects (like updating storage).
- Emission: Components can
yieldnew events back to the bus, triggering further cycles.
Melony Runtime
Section titled “Melony Runtime”OpenBot uses Melony, a lightweight event-driven runtime. Melony manages the lifecycle of events and ensures that they are delivered to the correct handlers efficiently.
Key Benefits of Melony:
Section titled “Key Benefits of Melony:”- Asynchronous Generators: Handlers use
async function*to stream events back to the bus. - Type Safety: Built with TypeScript for robust development.
- Predictable State: Helps maintain a consistent state across the entire harness.
Project Structure
Section titled “Project Structure”Understanding the layout of the OpenBot repository helps when contributing or debugging:
src/app: Contains the CLI, server implementation, and core event types.src/harness: The core orchestration logic, including the agent harness and MCP runtime.src/plugins: Built-in plugin implementations (e.g., storage, UI).src/services: Local services like the storage engine.src/registry: Manages the discovery and loading of plugins.
Local-First Storage
Section titled “Local-First Storage”OpenBot stores all its data in ~/.openbot. This includes:
agents/: Custom agent definitions (AGENT.md).channels/: Per-channel workspace (SPEC.md,state.json) andthreads/<threadId>/folders where conversationevents.jsonllives (threads required for chat). See Your First Channel.plugins/: Shared plugins. Each plugin must be in its own subdirectory (e.g.,~/.openbot/plugins/my-plugin/index.js).config.json: Global server configuration.variables.json: Environment variables and secrets.memory/: Long-term memory log for agents using the memory plugin.