@datnguyennnx/localterm
v0.2.1
Published
A browser-based terminal: one browser tab is one PTY session. Friendly URL, persistent xterm.js front-end, hono + node-pty back-end.
Maintainers
Readme
localterm
Your terminal should just be a browser tab.
Run npx @datnguyennnx/localterm@latest start and every browser tab is one shell. Open a new tab to spawn another. Close the tab to kill it. That's the whole product.
Install
Run this command anywhere:
npx @datnguyennnx/localterm@latest startThis boots a local daemon and opens http://localterm.localhost:3417 in your browser. (*.localhost is reserved by RFC 6761 and resolves to 127.0.0.1 in every modern browser, so no /etc/hosts edit needed.)
To install globally:
npm install -g @datnguyennnx/localterm
localterm startUsage
The mental model is shell = browser tab:
- New tab → new shell
- Close tab → shell dies immediately
- Reload tab → fresh shell (the prior one is gone)
No session ids, no URL slugs, no reconnects. If you want a long-lived shell that survives reloads, run tmux inside localterm.
CLI
localterm start [-p 3417] [-H 127.0.0.1] [--no-open] [--yolo] [--max-sessions <count>]
localterm stop
localterm status
localterm restartState lives in ~/.localterm/ (PID, port, agent token, server log at ~/.localterm/server.log).
Agent Mode
localterm supports AI coding agents with structured output, command boundary detection, and a programmatic RPC interface. Pass ?mode=agent&token=<token> when connecting via WebSocket, or use the built-in WS-RPC methods:
| Method | Description |
| ------------------- | ------------------------------- |
| spawn_session | Create a new PTY session |
| list_sessions | List active sessions |
| write_input | Write data to a session |
| read_output | Read plain-text output |
| wait_for_boundary | Wait for command start/end |
| exec | Write command + wait for result |
Agent token is auto-generated at ~/.localterm/agent-token. Pass --yolo to bypass the command denylist.
Security
- Binds loopback hosts only:
127.0.0.1,localhost,*.localhost,::1. Non-loopback values are rejected. /api/*and/wsenforce loopbackHostandOriginheaders to defeat DNS-rebinding attacks.- Agent-mode connections require a token from
~/.localterm/agent-token. - One PTY per WebSocket. Closing the tab kills the shell — no orphaned processes.
Credits
localterm was originally created by Aiden Bai. MIT-licensed.
