Matrix OSMatrix OS

Developer Overview

Technical reference for building on and contributing to Matrix OS.

This section covers the technical internals of Matrix OS for developers who want to understand the architecture, contribute to the project, or build extensions.

AI-generated documentation

For a comprehensive, always-up-to-date reference generated from the source code, see the Matrix OS DeepWiki.

Tech Stack

LayerTechnology
LanguageTypeScript 5.5+ (strict mode, ES modules)
RuntimeNode.js 24+
AIClaude Agent SDK V1 (query() + resume) with Opus 4.6
FrontendNext.js 16, React 19
BackendHono (HTTP/WebSocket gateway)
Channelsnode-telegram-bot-api, @whiskeysockets/baileys, discord.js, @slack/bolt
FederationMatrix protocol (matrix-js-sdk)
DatabaseSQLite via Drizzle ORM (better-sqlite3, WAL mode)
ValidationZod 4 (zod/v4 import)
Schedulingnode-cron + native timers
TestingVitest (99-100% coverage target, @vitest/coverage-v8)
Package Managerpnpm (install), bun (scripts)

Key Concepts

Kernel = Agent SDK

The spawnKernel() function in packages/kernel/src/spawn.ts is the entry point. It calls query() for initial prompts and resume for multi-turn conversations. The kernelOptions() function in packages/kernel/src/options.ts configures the kernel with the system prompt, IPC servers, agent definitions, and hooks.

IPC via MCP

The kernel communicates with the system through 26 IPC tools exposed as an in-process MCP server via createSdkMcpServer(). Each tool is defined with tool(), a Zod schema for input validation, and an async handler.

Hooks

Hooks intercept agent actions at defined lifecycle points. PreToolUse hooks run before tool execution (safety guards, protected files). PostToolUse hooks run after (git snapshots, state updates, shell notifications). A Stop hook persists the session.

Dispatch Queue

The gateway's dispatcher manages a serial FIFO queue by default, ensuring only one kernel call runs at a time to prevent file system corruption. It can be configured for concurrent dispatch with maxConcurrency, where each process registers in the SQLite tasks table.

Developer Resources

How is this guide?

On this page