What is the Daemion kernel?
The kernel is the core of Daemion — 6 substrates that manage AI resources, conversation state, and runtime behavior. Everything else in the system — agents, jobs, themes, commands, integrations — exists as an extension that plugs into one or more substrates. You extend the kernel; you don’t modify it.
Extensions are JSON data stored in SQLite, not compiled code. An agent can create a new extension at runtime without touching the codebase.
Architecture
┌─────────────────────────────────────────────────────────┐
│ KERNEL │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
│ │ Extension │ │ Context │ │ Execution │ │
│ │ Substrate │ │ Substrate │ │ Substrate │ │
│ └─────────────┘ └─────────────┘ └─────────────────┘ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Presentation │ │ Trigger │ │ Storage │ │
│ │ Substrate │ │ Substrate │ │ Substrate │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────┘
▼ ▼
┌─────────────────────────────────────────────────────────┐
│ EXTENSIONS │
│ command theme job renderer integration action │
│ widget app artifact capability control │
└─────────────────────────────────────────────────────────┘
1. Extension Substrate
Registers, loads, and validates all 12 extension types at runtime. Extensions are rows in SQLite — not compiled-in modules. The system resolves them by type and name, validates them against their Zod schema, and makes them available to the rest of the kernel.
Because extensions are data, an agent can create, update, or disable an extension mid-conversation — no deploy, no restart needed. The gateway also supports reseeding (POST /reseed) to re-sync built-in extensions and disk-backed configs without restarting the process.
12 extension types: command, theme, job, renderer, integration, action, widget, app, artifact, capability, control, plus agent itself.
Source: src/gateway/storage.ts, src/schema/extension.ts
2. Context Substrate
The context substrate decides what an agent knows before it generates a response. It is RLM-inspired: rather than compressing history into summaries, context is externalized into queryable stores and the agent decides what to retrieve.
RLM (Recursive Language Models) is a design philosophy from Alex Zhang’s 2025 post where models recursively decompose large context by calling themselves on subsets. Daemion takes the same philosophy — externalize context, let the model control retrieval — but implements it with search tools over SQLite and Engram rather than recursive self-calls.
Three layers are assembled in parallel via Promise.all before each response:
Layer 1 — Recent turns (~10) pulled from SQLite. These are always in context. They represent the live thread the agent is participating in.
Layer 2 — Engram recall — semantic search (vector + BM25 hybrid) over the Neo4j knowledge graph. Entities, facts, and insights stored across sessions. The agent can also call engram_recall mid-response as a tool if it needs more.
Layer 3 — History tools — five search tools the agent calls on demand:
| Tool | What it does |
|---|---|
list_threads | Discover all conversation threads with metadata |
search_history | Full-text search within the agent’s own threads |
get_thread | Retrieve a specific thread with cursor pagination |
find_relevant | Time-scoped search with recency re-ranking |
search_all | Cross-agent full-text search across all threads |
No running summaries. No compression. Every message is stored at full fidelity in SQLite. The agent pulls what it needs; it doesn’t get handed a lossy digest.
Source: src/gateway/agent.ts, src/core/history-tools.ts
3. Execution Substrate
Manages all Claude invocations via the Agent SDK. Responsible for model selection, turn budgets, cost limits, streaming, cancellation, and per-thread concurrency. Every chat message and job run flows through this substrate.
Mode Model Max Turns Budget ──────────────────────────────────────────────────── Chat (quick) claude-sonnet 10 turns $0.50 Chat (complex) claude-sonnet 25 turns $5.00 Job execution configurable 30 turns $5.00
The substrate streams partial responses over WebSocket as text-delta events, so the UI updates token-by-token. Tool calls emit tool-start events so the client can show progress in real time.
Spawning Claude as a subprocess causes a hang bug (#771). The Agent SDK handles the subprocess lifecycle correctly. All Claude calls go through invokeAgent() in src/core/invoker.ts or the gateway’s chat handler.
Source: src/core/invoker.ts, src/gateway/agent.ts
4. Presentation Substrate
Renders agent output to the client. Handles streaming text, tool call visibility, error states, and artifact display. Extension renderers can register custom display components for specialized content types — a code renderer, a diff renderer, a chart renderer.
The substrate is the bridge between the Execution substrate’s stream events and what the user actually sees in the PWA.
Source: app/components/
5. Trigger Substrate
Evaluates conditions that cause jobs or agents to fire. Five trigger types are supported:
| Type | When it fires |
|---|---|
message | On incoming chat message |
command | On /, @, !, or # prefix |
cron | On a schedule (standard cron, minute precision) |
watch | On filesystem change |
chain | After a parent job completes |
webhook | On external HTTP callback |
shouldJobFire() for each enabled job. Cron matching uses the croner library. Chain triggers are not evaluated by the scheduler — they fire directly in the engine after the parent job completes.Source: src/core/triggers.ts, src/gateway/scheduler.ts
6. Storage Substrate
Three backends, each with a distinct role:
SQLite — the primary operational store. Messages, threads, extensions, projects, and job run history all live here. Zero network dependencies; the file lives at ~/.daemion/daemion.db.
Engram (Neo4j) — the knowledge graph. Entities, facts, relationships, and free-form insights. Queried via hybrid semantic + BM25 search. This is where agents accumulate long-term memory across sessions.
Filesystem — agent identity files (agents/*.yaml, agents/*/system.md), job prompts (jobs/*/prompt.md), app source bundles, and project configs. Readable at startup; hot-reloadable for agent configs.
Engram requires a running Neo4j instance and the memory-graph skill. If Engram is unavailable, context assembly degrades gracefully — recent turns and history tools still work, Engram recall is skipped.
Source: src/gateway/storage.ts
General FAQ
src/gateway/server.ts) that exposes kernel capabilities as API endpoints. The gateway is how the kernel runs in production.The substrates above are implemented across: src/core/engine.ts, src/core/triggers.ts, src/core/invoker.ts, src/core/history-tools.ts, src/gateway/storage.ts, src/gateway/agent.ts, and src/gateway/websocket.ts.