Skip to content

Overview

Get started

mare is an agent harness built as a small Rust core plus Lua 5.5 plugins that you can read, wrap, or replace.

The Rust core provides OS confinement, durable storage, the Lua runtime, and the terminal renderer (mare-tui and mare-cli). The agent loop, tools, model providers, compaction, permission rules, and UI components, themes, and statusline ship as built-in Lua plugins inside the binary.

mare layered architecture Four-layer architecture of mare: Front ends (TUI via mare-cli and mare-tui, Headless, mare RPC 3.0 over JSON-RPC 2.0, HTTP/WS listener, ACP) over Plugins (Built-in Lua 5.5, User and project config, Packages), Public Lua API (Cordis services, Event and policy bus, UI components), and the Rust core kernel (OS sandbox, Durable JSONL appends, File snapshots, Lua watchdog, Runtime and TUI). Front ends five ways into the same session Terminal UI mare (mare-cli/tui) Headless -p · --json mare RPC 3.0 --rpc (JSON-RPC 2.0) HTTP / WS listener --web (plugin UI/RPC) Editor ACP mare acp commands · prompts · event streams Plugins Lua 5.5 · readable, replaceable (override = true) Built-in plugins agent · tools · providers · compact · session permissions · ui components/themes · mcp · changes User & project config ~/.config/mare/init.lua · plugins/ .mare/plugins/ (trusted projects) Packages mare.plugins.add(...) mare-plugins & git repos inject / provide · service contracts Public Lua API stable plugin contract (mare runtime types) Cordis services ctx.agent · tools · llm · session Events & policy bus ctx:on · ctx.bus · ctx.policy UI components ui.* / mare.ui.* · overlays · keymaps guarded Rust bindings · safety boundary Rust core kernel confinement, durability & runtime guarantees OS sandbox bwrap · Landlock Seatbelt · WinACL/User Durable store mare-store JSONL tree via session plugin File snapshots mare-binding::snapshot per-turn /rewind Lua watchdog watchdog_ms aborts slow coroutine Runtime & TUI Lua 5.5 (mlua 0.12) mare-tui · trust
⤢
Layer Written in What it does
Core Rust Plugin kernel (events, services, lifecycle, watchdog), Lua runtime, OS sandbox, session storage, file snapshots, project trust, terminal renderer (mare-tui), mare RPC 3.0 (JSON-RPC 2.0)
Built-in plugins Lua 5.5 Agent loop, tools, providers, compaction, permissions, approvals, sessions, slash commands, UI components, themes, statusline, review, background jobs, MCP client
Your plugins Lua 5.5 Additions or overrides from init.lua, ~/.config/mare/plugins/, .mare/plugins/, or installed packages

Run mare runtime to print the read-only directory containing the built-in plugin sources (agent.lua, tools.lua, …) and Lua type definitions.

  • Configure a plugin: mare.plugin("tools", { bash_timeout_ms = 120000 })
  • Add a tool, slash command, key binding, or style in init.lua.
  • Replace any built-in with a same-name plugin setting override = true (/plugins shows it as overriding the built-in).

Core boundaries:

  • Core safety: Sandboxing, file/process permission checks, crash-safe JSONL writes, project trust, and the Lua watchdog (watchdog_ms) live in Rust. Replacing the agent loop preserves them for calls routed through the permissions plugin and guarded tool pipeline.
  • Trusted plugins: Plugins run as trusted code. A plugin that disables or replaces permissions, or calls primitives directly outside a tool call, is not confined by those checks.
  • Fault isolation: Failures in optional plugins or packages report a warning and are skipped; failures in essential services, plugins with required = true, or required packages block requests until fixed and /reloaded. /plugins shows tracebacks.
Front end Command Purpose
Terminal UI mare Interactive terminal sessions (mare-tui + mare-cli)
Headless mare -p "prompt" or mare --json "prompt" One-shot prompts and JSON streams for scripts and CI
stdio RPC mare --rpc Drive sessions over mare RPC 3.0 (JSON-RPC 2.0; mare rpc schema)
HTTP / WebSocket mare --web Authenticated HTTP routes and WebSocket RPC (web UI provided by plugins)
ACP mare acp Editor integration (Agent Client Protocol)

In-process Lua (init.lua and plugins) runs in the extension layer shared by every front end.

Deferred to later releases: ralph, lsp, model-router, and worktree plugins, /import, and HTML/JSONL session export (implementable as third-party plugins in the meantime).