This document summarizes the core architecture of codelia and the package boundaries used in this monorepo.
The agent is a simple loop:
User
│
▼
Agent.run/runStream
│ (messages + tools)
▼
LLM (BaseChatModel.ainvoke)
│ └─ messages[] (assistant/reasoning/tool_calls in sequence)
▼
Tool execution
│ └─ ToolMessage
▼
Agent loop (repeat)
│
└─ Final response or done signal
@codelia/core- Agent loop, message history, tools, context management, and provider adapters.
@codelia/shared-types- Cross-boundary stable types shared by core/protocol/runtime.
@codelia/protocol- Core-independent UI/runtime wire protocol types and method names.
@codelia/config- Config schema, parsing, and defaults.
@codelia/config-loader- Config file discovery/load/merge helpers.
@codelia/logger- Shared logging helpers (stderr logger and debug flag helpers).
@codelia/runtime- JSON-RPC runtime server that connects UI/TUI to core tools and agents.
@codelia/storage- Session logs and resume state persistence.
@codelia/model-metadata- Model metadata resolution and registry helpers.
@codelia/cli- Product entrypoint that launches TUI/runtime paths (no core/tool implementation).
crates/tui- Rust TUI client that drives the runtime.
- Tool output cache trims large tool outputs and keeps references for replay.
- Compaction summarizes history when context usage is high.
- Usage tracking aggregates token usage across runs.
Dependency direction:
A --> Bmeans "A depends on B".A -.-> Bmeans "A spawns/calls B as a process" (not a build-time dependency).
graph TD
core["@codelia/core"]
shared["@codelia/shared-types"]
storage["@codelia/storage"]
protocol["@codelia/protocol"]
config["@codelia/config"]
configloader["@codelia/config-loader"]
runtime["@codelia/runtime"]
logger["@codelia/logger"]
cli["@codelia/cli"]
modelmeta["@codelia/model-metadata"]
tui["crates/tui"]
core --> shared
core --> config
protocol --> shared
configloader --> config
runtime --> core
runtime --> logger
runtime --> protocol
runtime --> config
runtime --> configloader
cli --> runtime
cli --> configloader
cli --> storage
cli -.-> tui
runtime --> modelmeta
runtime --> storage
modelmeta --> core
modelmeta --> storage
tui -.-> runtime