architecturelisted
Install: claude install-skill vmehera123/leashd
# leashd architecture
Safety-first agentic coding daemon. Shape: **connectors → Engine → middleware → agent runtime**, with every tool call the agent makes intercepted by a **three-layer safety pipeline**, and an **EventBus** decoupling plugins. This skill is the mental model plus a file map.
> **Specs drift.** `specs/app/` has deeper numbered references, but they lag the code — `00-quick-reference.md` still lists deleted modules (`task_orchestrator.py`, `auto_approver.py`, …). Treat specs and `README.md` as starting points; **verify every claim against source before relying on it.**
## Request flow (one user message)
```
connector (web / telegram) → MultiConnector (chat_id routing)
→ Engine.handle_message → middleware chain (auth, rate limit)
→ agent runtime executes
→ each tool call → Gatekeeper: sandbox → policy → approval
→ streamed response back to the connector
```
## Bootstrap & wiring
`main.py:run()` → `cli.py` (argparse router, smart-start) → `main.py:start()` → one of `_run_cli` / `_run_telegram` / `_run_web` / `_run_multi` (chosen by which connectors are configured) → **`app.py:build_engine(config, connector)`**.
`build_engine` is the single wiring point. In order it constructs: logging → MCP server config → session store + message store (both global at `~/.leashd/`) → `SessionManager` → **`agent = get_agent(config.agent_runtime, config)`** → `EventBus` → `PolicyEngine` → `SandboxEnforcer` → `AuditLogger` → `create_builtin_plugins(...)` → appro