Architecture
omfp is one daemon (TypeScript on Bun) and any number of windows: the web UI in a browser or on a phone, and the desktop app, a small Electron shell around the same web UI. Windows only talk to the daemon, over one WebSocket each; the daemon runs pi in process.
flowchart LR
subgraph windows["Windows"]
browser["Browser"]
phone["Phone"]
desktop["Desktop app (Electron)"]
end
subgraph daemon["Daemon (Bun)"]
kernel["Kernel<br/>protocol · store · supervisor"]
user["User host<br/>your init.ts"]
subgraph ws["per workspace"]
workspace["Workspace host<br/>.omfp/init.ts · evals · jobs"]
end
subgraph th["per thread"]
thread1["Thread host<br/>pi session"]
thread2["Thread host<br/>pi session (subagent)"]
end
end
browser & phone & desktop <-->|WebSocket| kernel
kernel <--> user
kernel <--> workspace
kernel <--> thread1
kernel <--> thread2
The kernel
Section titled “The kernel”The kernel runs on the daemon’s main thread. It serves the protocol (methods and subscribable topics), routes each call to the feature that owns it, keeps the store (SQLite, in the data directory) and supervises the hosts. It knows threads, workspaces, jobs, approvals and windows, but runs no agent and no user code itself.
Supervised hosts
Section titled “Supervised hosts”Hosts are Bun workers the kernel can kill and restart in milliseconds. It pings each one on a heartbeat and gives every call a deadline; a host that hangs, throws or exits is restarted with the same init data and rebuilds itself.
- Thread host, one per running thread: holds the thread’s pi session, with omfp’s tools added to pi’s, and streams its events to the kernel. A restart resumes the session file.
- Workspace host, one per workspace: loads the user’s init file, then the workspace’s
.omfp/init.ts, as cordis plugins; runs the agents’ live evals, the declared jobs’ code, the tools and methods the init files declare. A restart runs the init files again. - User host, one per daemon: loads the user’s init file alone, for the settings and keys that apply before any workspace exists.
A prompt, end to end
Section titled “A prompt, end to end”sequenceDiagram
participant W as Window
participant K as Kernel
participant T as Thread host
W->>K: thread.prompt
K->>T: start the host if needed, pass the prompt
T-->>K: accepted
K-->>W: accepted
loop while the agent works
T-->>K: pi events (text, tool calls, results)
K-->>W: thread/<id> topic: every window watching the thread
end
A thread’s visible state is derived from its stream of pi events by one reducer (@omfp/core), the same in every
window, so a phone and a laptop show the same conversation. Closing every window stops nothing: threads, jobs and
workspaces keep running in the daemon.