raijin.sh is a small Cloudflare Worker application for creating short-lived browser-to-terminal sessions on systems you control.
It serves static frontend assets, exposes the relay/bootstrap routes, and binds a Durable Object namespace for per-session in-memory relay state. The remote side is a Python 3 stdlib-only bootstrap that leaves no installed agent behind.
- Creates a temporary session from the browser.
- Keeps session metadata in browser
localStorage, not in server-side persistent storage. - Shows a copyable one-line Python bootstrap command.
- Opens a live terminal in the browser with
xterm.js. - Runs
/bin/sh -liby default inside a PTY on the remote Linux host. - Supports
interactive,command, andreadonlysession modes. - Kills the shell and ends the session on browser disconnect, explicit end, idle expiry, or hard lifetime expiry.
- Stores no transcript by default.
- Cloudflare Workers
- Cloudflare Durable Objects
- Static assets served by the same Worker project
- Vanilla HTML/CSS/JS frontend built with Vite
xterm.jsfor the browser terminal- Python 3 stdlib-only remote bootstrap
- Node.js 20+ with
npm - Python 3
- Linux shell for realistic end-to-end testing
-
Install dependencies:
npm install
Use the one-command dev workflow:
npm run devThat starts:
vite build --watchto keepdist/currentwrangler dev --local --port 8787for the Worker, assets, and Durable Objects
Open http://localhost:8787.
- Open the home page.
- Click
New Session. - Copy the bootstrap command from
/s/:sessionId. - Paste it into a Linux shell you control.
- Verify the terminal becomes interactive in the browser.
- Resize the browser and confirm the shell follows.
- Click
End Sessionand confirm the shell exits remotely.
See TEST_PLAN.md for the full manual checklist.
This repo is designed for Cloudflare Workers Builds.
-
Push this repo to GitHub.
-
In Cloudflare, go to
Workers & Pages. -
Create a new application and choose
Import a repository. -
Select this repository.
-
Keep the project root at the repo root.
-
Set the build command to:
npm run build
-
Set the deploy command to:
npx wrangler deploy
-
Save and deploy.
Cloudflare Workers Builds expects the Worker name in the dashboard to match the name field in wrangler.jsonc. This repo uses raijin.
After the first deploy, add raijin.sh as a custom domain in Cloudflare. The bootstrap command uses the current origin, so it works with either the generated workers.dev host or the final custom domain.
- src/index.js: Worker routes and bootstrap generation
- src/session-do.js: session Durable Object
- src/frontend/home.js: home page UI
- src/frontend/session.js: session page UI and terminal client
- src/frontend/session-store.js: browser-owned session metadata and bootstrap generation
- wrangler.jsonc: Worker config, assets, Durable Object binding, migrations
Verified locally on April 10, 2026 with:
npm run buildnpx wrangler deploy --dry-run- local
wrangler devsmoke tests covering create session, websocket connect, Python bootstrap connect, terminal output, resize, explicit end, and shell cleanup