toilet-pi2.1.0
Remote control Pi, OMP, and OpenCode sessions from a central web UI
Built for omp
The author tagged this package omp-extension.
Reports 0
No reports yet.
Readme
Toilet-Pi
Control your pi, OMP, and OpenCode sessions from a browser or CLI.
Toilet-Pi gives you one mobile-friendly view of pi sessions across your computers. You can watch active work, send prompts, abort a run, resume an inactive session in the background, or start a new session in a project.
How it works
Browser
│
▼
Central Toilet-Pi server
▲ ▲
│ │
Optional supervisor Shared extension
(discovery/resume) (one per running session)
│ │
└── pi / OMP └── new headless pi / OMP sessions in existing folders
The central server is a lightweight WebSocket hub: it keeps a live overview of connected machines and routes browser commands and session events. Normal interactive sessions connect directly through the shared Toilet-Pi extension and can launch new headless sessions in other folders on their machine (Pi launches Pi, OMP launches OMP). The optional supervisor discovers local pi and OMP session files and enables inactive-session history and resume.
This design provides one UI across multiple computers without moving session files or model credentials to the server. Connections are outbound from each machine, interactive sessions remain independent when Toilet-Pi is unavailable, and server state can be rebuilt as machines and sessions reconnect.
What you get
- Live access to normal interactive pi sessions
- Sessions grouped by machine or project
- Remote prompts and aborts
- Background resume for inactive sessions
- New background sessions from the browser
- Seamless handoff back to the local pi TUI
- Plain-text orchestration CLI with tracked dispatch, settlement waits, and branch-aware history
- Scoped orchestrator tokens and browser model/thinking selection
- Claude Code sessions alongside pi ones: watch, prompt, answer permission prompts and abort (.claude-plugin)
- Native OpenCode V2 sessions: live output, persisted remote prompts, permission replies, model variants, history, abort, archive, and new sessions
Interactive sessions remain usable if Toilet-Pi is offline. Background sessions keep running and reconnect after temporary server outages. Runner-launched sessions survive their launching session exiting; supervisor-managed sessions stop when that supervisor shuts down. Both stop when the session is closed or an interactive agent takes ownership.
Requirements
- Node.js 22.19 or newer
- A compatible coding agent:
pi, OMP, or OpenCode V2 - Git
Quick start
1. Install Toilet-Pi
Clone the repository, install its dependencies, and install the extension for your agent:
git clone https://github.com/mrexodia/toilet-pi.git
cd toilet-pi
npm run setup
# pi
pi install https://github.com/mrexodia/toilet-pi
# OMP
omp plugin install github:mrexodia/toilet-pi
Both agents load the same toilet-pi.ts extension; OMP does not require a separate entrypoint.
For OpenCode, add the published package to the plugins array in your global or project
opencode.json(c):
{
"$schema": "https://opencode.ai/config.json",
"plugins": ["toilet-pi"]
}
OpenCode resolves the npm package and loads its server, TUI, and RPC exports together; no separate
npm install, supervisor, or detached agent process is needed. When developing from this checkout,
run npm install in the repository and use its absolute path instead of "toilet-pi".
To update later, run pi update --extensions for pi or omp plugin upgrade toilet-pi for OMP, then restart the agent or run /reload.
2. Start the server
npm start
The server prints an Admin login URL. Open that URL in your browser.
By default the server runs at http://localhost:3457. Its generated admin token is stored in ~/.pi/agent/toilet-pi-server.json.
3. Connect your machine
In the web UI:
- Open Installation.
- Generate a machine connect URL.
- Copy the URL.
Then open pi or OMP on that machine and run:
/toilet-pi setup wss://your-server/ws?token=...
The same command works in the OpenCode TUI. /toilet-pi status reports how many OpenCode sessions
the shared service currently mirrors. The connect token is saved in the existing owner-only
~/.pi/agent/toilet-pi.json file, not in opencode.json.
Use the exact ws:// or wss:// URL generated by the web UI. Do not use the browser Admin login URL.
4. Choose live sessions only or supervisor discovery
Live sessions only (no project scan): keep one connected Pi running on the machine, for example over SSH inside herdr, tmux, or screen. From the web UI, select that session and choose New Session, then enter an existing absolute folder path on that machine. The CLI and Optchat's agent_new use the same launch path. Children connect directly, can launch further sessions, and do not depend on the initial SSH terminal or Pi staying alive. Only connected sessions/projects are listed; inactive sessions are not discovered or resumable in this mode.
The chosen runtime and its model credentials must already be installed on the target machine. New children use RPC mode with a small detached stdin-keeping worker, not a scanning supervisor. Pi launches Pi; OMP launches OMP. The browser prefers the selected active parent as launcher, even when a supervisor is available. This does not copy files, create folders, or transfer the parent's selected model; children use their runtime's normal configuration and separate session storage. TOILET_PI_PI_COMMAND / TOILET_PI_OMP_COMMAND override the executable (one command, not a shell fragment). Set TOILET_PI_DISABLE_LAUNCH=1 before starting a runner to disable its launch capability. Optchat defaults to Pi children; configure "childRuntime": "omp" in its home's optchat.json, use its setup wizard, or pass --child-runtime omp / OPTCHAT_CHILD_RUNTIME=omp. Explicit agent_new or CLI new --runtime pi|omp choices override the default.
Supervisor discovery (optional): to include inactive projects and enable persisted history/resume, keep this running:
npm run supervisor
The supervisor makes local pi and OMP sessions and projects visible and starts matching background processes when requested from the browser.
5. Use Toilet-Pi
Open the web UI to:
- inspect sessions across connected machines
- send a prompt to an active session
- resume an inactive session by sending it a prompt
- start a new session from the Projects view
- abort an active run
Normal local pi and OMP sessions connect automatically through toilet-pi.ts.
OMP preserves extension instances across /new, /resume, /fork, and branch operations, so Toilet-Pi handles OMP's session_switch and session_branch events and reconnects whenever the session GUID changes. Pi's separate shutdown/start replacement lifecycle is also supported. Same-identity reloads, tree navigation, and successful compaction refresh the existing connection instead.
Toilet-Pi mirrors sessions open in an OpenCode terminal tab or Desktop window, including idle background tabs. With terminal tabs disabled, it mirrors the session on screen. Closing the last tab for a session removes it from the live list without archiving it. If a window crashes, its entry expires after about two minutes. Sessions launched from Toilet-Pi stay reachable without a local tab until archived. For Desktop tab tracking, enable the plugin in your global OpenCode config.
Remote prompts are submitted
with OpenCode's native message IDs and appear in the session as ordinary persisted user messages.
steer and follow-up map to OpenCode's native steer and queue delivery. A remote terminate interrupts
and archives the session; it does not delete its history. Permission prompts appear in the transcript
and accept yes [request-id], always [request-id], or no [request-id].
The web transcript shows delivered prompts and completed tool output, including shell commands and
elapsed time. CLI history and Optchat's agent_history read OpenCode's active session context.
Older messages may be unavailable after compaction, so OpenCode history pages report complete: false.
Connection recovery
The Pi/OMP extension and optchat share the same connection recovery transport:
- Normal system DNS is always tried first. On
EAI_AGAINonly, a runner can reuse an address from a successful connection to the same hostname that opened or received a pong within the last five minutes. The fallback stays in memory, expires while offline, and does not help a cold start or mask permanent DNS errors. - Each connection attempt has a 15-second deadline covering DNS, TCP, TLS and the WebSocket upgrade. Existing ping/pong heartbeats detect connections that stop responding; reconnects use jittered exponential backoff.
- TLS hostname/certificate verification is unchanged. No public DNS service is contacted as a fallback and no system DNS settings are modified.
- Diagnostics include DNS fallback use, connection lifetime, last-pong age, retry delays and locally initiated terminations. The extension keeps errors in its status widget when a TUI is attached, without writing over it; headless runners log to stdout.
Reconnects publish a fresh session snapshot without automatically replaying submitted work. The extension still
stops automatic reconnection when replaced, released, or rejected with policy code 1008. Setup verification
keeps its separate five-second timeout and uses fresh DNS rather than the running session's fallback address.
These measures shorten outages; they cannot prevent network failures or Cloudflare Durable Object resets. Reload/restart the extension after updating its code. See optchat for its runner-specific details.
Claude Code
This repository is also a Claude Code plugin. Installed (claude plugin install toilet-pi@mrexodia from
mrexodia/claude-marketplace), it mirrors every Claude Code session on
the machine to the hub live; started with claude --dangerously-load-development-channels plugin:toilet-pi@mrexodia,
a session also takes prompts, permission answers and aborts from the web UI and CLI. See
.claude-plugin/README.md.
CLI
A compact plain-text CLI supports discovery, model/thinking selection, dispatch, lifecycle control, observation, and history:
node cli/toilet-pi.js --help
Log in once with a hidden admin-token prompt:
npx toilet-pi login --server https://toilet.example.com
npx toilet-pi hosts
npx toilet-pi logout
Login saves the server URL and session cookie—not the admin secret—in ~/.pi/agent/toilet-pi-auth.json. Treat this plaintext file as a secret; it uses owner-only permissions on Unix and inherits directory ACLs on Windows. Logout removes it locally, without revoking copied cookies. Environment credentials remain optional overrides, including scoped orchestrator tokens.
The CLI never reads/modifies machine configuration or implicitly starts a session. models returns models and their supported thinking levels in one request.
toilet-pi sessions
toilet-pi history SESSION --last 6
toilet-pi resume SESSION --timeout 90
toilet-pi send SESSION --stdin --wait
toilet-pi wait SESSION --input INPUT_ID
Tracked prompts include a visible correlation marker. wait uses agent_settled, not transient idle updates; settlement is not task success. Input IDs are printed before transmission for reconciliation, and mutations are never automatically replayed. OMP's new runtime capabilities remain unverified; unsupported operations fail conservatively.
See CLI usage and protocol and the orchestrator implementation plan.
Useful extension commands
/toilet-pi
Show the available Toilet-Pi subcommands.
/toilet-pi setup [connect-url]
Enter or replace this machine's connect URL. Omit the URL to open the setup prompt.
/toilet-pi status
Show the current Toilet-Pi connection status.
To try the extension without installing it permanently:
pi -e https://github.com/mrexodia/toilet-pi
Adding another computer
On every additional computer:
- Clone the repository with
git clone https://github.com/mrexodia/toilet-pi.git. - Enter the repository and run
npm run setup. - Install the extension with
pi install https://github.com/mrexodia/toilet-pioromp plugin install github:mrexodia/toilet-pi. - Generate a fresh machine URL from Installation in the web UI.
- Run
/toilet-pi setup <machine-url>inside pi or OMP. - Keep a connected Pi running, or start
npm run supervisorif you want inactive-project discovery and resume.
Generate a separate machine URL for each computer.
Cloudflare Workers deployment
First generate a strong server token:
node --input-type=module -e "import { randomBytes } from 'node:crypto'; console.log(randomBytes(32).toString('base64url'))"
Then deploy the server and web UI. Paste the generated token when Wrangler asks for the secret value:
cd server
npx wrangler login
npx wrangler secret put TOILET_PI_SERVER_TOKEN
cd ..
npm run deploy
After deployment, open:
https://your-worker.workers.dev/#token=YOUR_SERVER_TOKEN
The shared pi/OMP extension and any optional supervisor still run locally on each connected computer.
Configuration
Common environment variables:
| Variable | Purpose |
|---|---|
PORT |
Local server port; defaults to 3457 |
TOILET_PI_PUBLIC_URL |
Public URL override for the Node server |
TOILET_PI_SERVER_TOKEN |
Fixed admin token instead of the generated local token |
TOILET_PI_HOST_ID |
Custom name for a machine |
TOILET_PI_SESSION_DIR |
Custom pi session directory |
TOILET_PI_OMP_SESSION_DIR |
Custom OMP session directory |
TOILET_PI_PI_COMMAND |
Path or command used to launch pi |
TOILET_PI_OMP_COMMAND |
Path or command used to launch OMP |
TOILET_PI_DEFAULT_RUNTIME |
Supervisor's default for brand-new sessions; pi by default (runner defaults inherit Pi/OMP, or Optchat's childRuntime) |
TOILET_PI_DISABLE_LAUNCH |
Set to 1 to disable launching children from a connected runner |
TOILET_PI_SERVER_URL |
Machine connect URL override |
PI_CODING_AGENT_DIR |
Override pi's agent directory |
OMP_CODING_AGENT_DIR |
Override OMP's agent directory for the supervisor |
The supervisor scans both ~/.pi/agent/sessions and ~/.omp/agent/sessions, tags each session with its source runtime, and launches the matching command when resuming it. OMP itself also calls its agent-directory variable PI_CODING_AGENT_DIR; OMP_CODING_AGENT_DIR is a Toilet-Pi supervisor alias that lets pi and OMP use distinct overrides in the same process. On Linux and macOS, the supervisor also follows OMP's active XDG_DATA_HOME/omp/sessions layout.
Machine configuration is normally stored in the active agent directory as toilet-pi.json. The supervisor checks the default runtime's directory first, then the other runtime.
Troubleshooting
- Machine not visible: keep at least one Toilet-Pi-enabled Pi connected on that machine, or run the optional
npm run supervisor. - New session will not start: update/restart the server and the connected runner, confirm the target folder is an existing absolute path, and check that the selected
pi/ompexecutable (or itsTOILET_PI_*_COMMANDoverride) is available to that runner. If startup times out, inspect sessions before retrying. - Interactive session not visible: confirm the package is installed with
pi listoromp plugin list, then restart the agent or run/reload. - Inactive session will not start: the machine's supervisor must be connected.
- Wrong server configured: run
/toilet-piagain with a newly generated machine URL. - Remote access fails: use HTTPS/WSS when exposing Toilet-Pi outside your local network.
Security and persistence
Treat the Admin login URL, server token, machine URLs, and orchestrator tokens as secrets. Use HTTPS for remote deployments. Prefer short-lived, host/session-restricted orchestrator grants for automation; see CLI permissions. These scopes are not an agent/tool sandbox.
Server session state is held in memory and rebuilt as clients reconnect. Your actual pi and OMP session files remain on their original machines.
License
MPL-2.0