MentatLab docs
Architecture
MentatLab separates workflow design, orchestration, and execution into clear service boundaries.
High-Level Components
- Frontend (
services/frontend)- React + ReactFlow Mission Control canvas
- Panels for console, timeline, and issues
- Interacts with Gateway over HTTP and run-scoped SSE
- Gateway (
services/gateway-go)- API proxy to Orchestrator
- Transparent SSE proxy and middleware (auth, rate limits, headers)
- Orchestrator (
services/orchestrator-go)- DAG scheduler and run lifecycle
- Agent registry, flow store, run store
- Execution backends (memory/redis/k8s)
- Redis
- Shared run state and messaging backend (when configured)
- Agents (
agents/)- External processes or workloads following stdin/stdout NDJSON contract
Request/Run Lifecycle
- User creates or updates a flow in Mission Control.
- Frontend calls Gateway (
/api/v1/flows,/api/v1/runs). - Gateway forwards to Orchestrator and streams events back.
- Orchestrator schedules nodes according to DAG dependencies.
- Node execution emits events; run status is persisted in runstore.
- Frontend updates timeline/console with live run events.
Run Event Transport
GET /api/v1/runs/{id}/events is the canonical live event path. The
orchestrator persists/replays events through the runstore and exposes them as
Server-Sent Events; the gateway proxies that response without a write deadline
so long-running runs remain connected.
The legacy /ws/streams/{id} route is intentionally unavailable and returns
HTTP 410 with the corresponding SSE URL. Its Redis Pub/Sub implementation did
not consume the Redis Streams written by the orchestrator, so a successful
WebSocket upgrade falsely reported connectivity without a producer. WebSocket
streaming may only return after an end-to-end bridge is implemented and tested.
Orchestrator Internal Packages
internal/api- HTTP handlers and routinginternal/scheduler- DAG scheduling/executioninternal/registry- agent registration and lookupinternal/flowstore- flow persistenceinternal/runstore- run state persistenceinternal/k8s- Kubernetes job driver
Execution Modes
memory- in-memory state for local devredis- Redis-backed run state for durable dev/prodk8s- Kubernetes Jobs for agent execution in cluster
Key Design Goals
- Deterministic DAG execution for repeatable runs
- Observable run lifecycle (events + metrics)
- Pluggable execution backends and storage
- Agent-language agnostic integration via NDJSON