The product, its assistant, the repo, the host and every unit on the box now share one name. 638 files, ~3,000 mentions: UI copy, config, env keys (FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs, articles, the deploy workflow other repos reuse, and nine file names. - Three article slugs carried the old name and had been shared; permanent redirects keep those links alive (next.config.ts). - test-no-retired-name.sh now also forbids the old product name across the whole repo, so the rename cannot creep back through templates and examples. - ASSISTANT_STACK collapses the product and the assistant into one entry, because they are now the same name. Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki` database and role, loki.orangecat.ch (old host 308s to it; /api, /widget, /embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases. The Resend sending domain stays fleetcrown.orangecat.ch until the new domain is verified in DNS. Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
8.8 KiB
Loki Agent Execution Platform
Status: Architecture / north star. LocalPtyExecutor shipped; Docker-backed SandboxExecutor substrate shipped behind an explicit env flag. The zellij path is gone (2026-09-11, Fleet Runner 0.8.19): every agent PTY is owned by a runner. Last updated: 2026-09-11 Scope: How Loki runs, streams, observes, and controls agent processes for many tenants on arbitrary client devices — without puppeting anyone's terminal.
Non-negotiables (the requirements that kill the current design)
- Billions of users, any device/terminal. Web, mobile, an IDE, or a power user's own shell — none can be the substrate for execution. The terminal is a view.
- Multi-tenant SaaS. Agents run untrusted code → hard isolation per agent.
- Long-running + resumable. Agents pause, hibernate, and resume across nodes.
- No dependence on the user's local machine or multiplexer. zellij/tmux/iTerm are not assumptions. Most users will never run anything locally.
- Cost-efficient at scale. Most agents are idle most of the time → you cannot keep billions of live containers; idle agents must hibernate and free their compute.
The path this replaced violated all five: it shelled into the user's zellij, guessed
session/tab names, mimed keystrokes, scraped the screen for status, and depended on
a /tmp sentinel. That was a single-user, single-box, one-multiplexer hack.
First principles
- An agent is a process with: a PTY (stdin/stdout), a filesystem (the workspace), a lifecycle, and observable state. Nothing about that requires zellij or a tab name.
- Loki must OWN that process's PTY and environment — spawn it in compute we control — rather than borrow a human's interactive terminal.
- The terminal is a rendering target, never the substrate. Same owned byte-stream
renders to the browser
xterm, a mobile view, or a native attach client. - State is event-sourced from the owned process, never screen-scraped or inferred
from
/tmp. "Working" = the process emitted work / has live output, as a fact. - Identity is a stable id Loki assigns, never a zellij name we have to find.
The four planes
┌─ Control plane ─────────────┐ stateless, horizontally scalable (the Next.js app/API)
│ auth · tenancy · orchestration · scheduling · billing · dashboard
└─────────────┬───────────────┘
│ Executor interface (the ONE abstraction)
┌─ Connection plane ──────────┐ streaming gateway (WS/gRPC), multiplexed, sharded by
│ PTY bytes + events ⇄ browser │ tenant, resumable (ring-buffer replay on reconnect),
│ xterm; backpressure-managed │ backpressure-aware
└─────────────┬───────────────┘
┌─ Execution plane ───────────┐ one agent per sandbox (Firecracker microVM / gVisor /
│ isolated PTY + FS + secrets │ K8s pod / Fly Machine / e2b). Autoscaled, bin-packed,
│ per agent; hibernates idle │ hibernates when idle.
└─────────────┬───────────────┘
┌─ State plane ───────────────┐ durable event log = SSOT for agent status; object
│ event log + FS snapshots │ storage for workspace snapshots → pause/resume/migrate
└─────────────────────────────┘
The one abstraction: Executor
Everything hangs off a single interface. Terminal-agnostic by construction — it traffics in bytes + a stable handle + structured events, not tabs and names.
interface Executor {
provision(spec: WorkspaceSpec): Promise<WorkspaceHandle>; // stable id, not a name
attach(handle: WorkspaceHandle): DuplexByteStream; // PTY in/out
events(handle: WorkspaceHandle): AsyncIterable<AgentEvent>; // lifecycle/status, event-sourced
snapshot(handle: WorkspaceHandle): Promise<SnapshotRef>; // hibernate
restore(ref: SnapshotRef): Promise<WorkspaceHandle>; // resume (maybe on another node)
terminate(handle: WorkspaceHandle): Promise<void>;
}
Implementations are added in order — same interface, no control-plane/UI changes:
| Executor | Backend | Serves |
|---|---|---|
LocalPtyExecutor |
node-pty on one box |
dev + single-box self-host; proves the interface end-to-end |
SandboxExecutor |
Docker today; Firecracker / gVisor / K8s / Fly Machines / e2b later | multi-tenant production scale (replaces today's pending_command keystroke hack) |
LocalRunnerExecutor (optional) |
the user's own machine via Fleet Runner | power users who want "run on my hardware" |
zellij/tmux are not executors. The zellij path was retired on 2026-09-11 (Fleet
Runner 0.8.19): src/lib/zellij.ts, src/lib/terminals/* and home/worker.ts are deleted,
and the web local runtime (RUNTIME_AVAILABLE=true) acts only on owned PTYs
(listOwnedTabs in src/lib/agent-execution/owned.ts; the /api/control field is liveTabs).
Why this scales to billions (it's a trodden path)
Same shape as GitHub Codespaces, Replit, Gitpod, Coder, e2b.dev, Fly Machines, Devin: stateless control plane + autoscaled per-tenant microVMs + hibernate-when-idle + streamed PTYs. The hard parts (isolation, hibernation, streaming) are solved patterns, not research.
Build order (every step is on the path — nothing thrown away)
Executorinterface + event-sourced workspace state — the SSOT. Status comes from the event log, not/procscans or/tmpsentinels.LocalPtyExecutor+ stream to the@xterm/xtermalready shipped — Loki works with zero zellij, single-tenant. This is the proving ground for the interface.- Unify the dashboard on the Executor model — done: the zellij path is deleted and the cloud path is the same executor on the box; one mental model.
SandboxExecutor— Docker-backed substrate behindLOKI_EXECUTOR=sandbox. It enforces a workspace root, per-container resource limits,no-new-privileges,cap-drop=ALL, and deny-by-default networking. This is the execution primitive; product entitlements still decide who may use hosted execution.- Hibernation + autoscaling — checkpoint idle agents, free compute; cost at scale.
- Native-attach gateway (optional) — let power users attach their own terminal to a workspace over the connection plane.
What this retired
zellij/tmux name-guessing · /tmp currentPrompt sentinels · screen-scrape status
derivation · keystroke injection into a borrowed pane. pending_commands remains the
queue between the control plane and a runner, but what a runner does with a claimed row
is write into a PTY it spawned — an inject for a tab with no live owned PTY fails loudly
("no running agent for … — dispatch to start one") and the cloud enqueues a dispatch
(cold start) instead.
Relationship to current code
The Next.js app stays as the control plane. The @xterm/xterm terminal is the
view for step 2. The reliability fixes shipped 2026-06-17 (timeouts, launch-state
sentinel, verified inject) kept the legacy zellij path usable until LocalPtyExecutor
replaced it; that bridge was removed with the zellij deletion on 2026-09-11.
Where a dispatch runs is a stored decision, not a presence check.
pickDispatchChannel(project) (src/lib/execution-access.ts) resolves: locus lock (a
laptop-only checkout stays local; a checkout under the box clone root stays cloud) →
user_projects.builder_pref ("Runs on" in Control → project profile) → cloud floor
(DEFAULT_BUILDER_CHANNEL = "cloud"). Runner presence and laptop battery route nothing;
an offline chosen builder queues visibly (runnerConnected: false) and never reroutes.
Failure classification for a run lives in src/lib/failure-remedy.ts
(START_SESSION | RETRY | NONE).
SandboxExecutor Runtime Knobs
The active executor is selected in src/lib/agent-execution/index.ts.
LOKI_EXECUTOR=local-pty(default): node-pty on the host.LOKI_EXECUTOR=sandbox: Docker-backed sandbox.LOKI_SANDBOX_IMAGE: image to run; defaultubuntu:24.04.LOKI_SANDBOX_WORKSPACE_ROOT: onlycwdvalues under this root are accepted.LOKI_SANDBOX_NETWORK:none(default) orbridge.LOKI_SANDBOX_CPUS,LOKI_SANDBOX_MEMORY,LOKI_SANDBOX_PIDS: resource caps.LOKI_SANDBOX_USER:current(default) orroot.LOKI_SANDBOX_MOUNT:rw(default) orro.
Important: this substrate does not by itself make hosted execution public. The shared cloud builder remains private until hosted entitlements, per-user credentials, metering, and onboarding smoke tests are complete.