Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
feat(server): headless notification host — one-line install, zero open ports
enes06bcecc432c1
diff --git a/README.md b/README.mdindex 393271fe2..dac8ca5e6 100644--- a/README.md+++ b/README.md@@ -94,6 +94,21 @@ browser today; the SDK chat node is the one piece still desktop-only. See[`docs/SERVER.md`](./docs/SERVER.md) for the quickstart, security model, and currentlimitations.+#### 🔔 Get push notifications from any SSH host++The same server also runs **headless** as a background notification host: install it on any+Linux box you SSH into, and your phone gets **RUNNING / NEEDS YOU** push + Live-Activity+coverage for the agents running there — with **zero open ports** (the hook server stays+loopback-only and push goes out over HTTPS under a grant your phone drops over SSH).++```bash+curl -fsSL https://raw.githubusercontent.com/eneskirca/nodeterm/main/scripts/install-server.sh | bash+```++One line installs, builds, and runs it as a systemd service (`NODETERM_HEADLESS=1`); re-run it+to update. See the [headless notification host](./docs/SERVER.md#headless-notification-host)+section for details.+## 📦 DownloadGrab the latest build from **[nodeterm.dev](https://nodeterm.dev)** — the download buttondiff --git a/docs/SERVER.md b/docs/SERVER.mdindex de3c47bde..56a311658 100644--- a/docs/SERVER.md+++ b/docs/SERVER.md@@ -75,6 +75,57 @@ Binding a **non-loopback** host (anything other than `127.0.0.1` / `localhost` /interface would leak the session cookie. The intended deployment is loopback-boundbehind a TLS-terminating reverse proxy (see [TLS](#tls-reverse-proxy)).+## Headless notification host++The Server Edition doubles as a **headless notification host**: a background process on any+Linux box that gives a phone SSHing into it full push / Live-Activity coverage — **without+serving the browser UI and without opening a single port**.++### One-line install++```bash+curl -fsSL https://raw.githubusercontent.com/eneskirca/nodeterm/main/scripts/install-server.sh | bash+```++The installer (`scripts/install-server.sh`) is idempotent — re-run it any time to update. It:++- checks Node.js ≥ 20 + git, and warns (with the apt/dnf one-liner) if the C toolchain+ (`make`/`gcc`/`python3`) node-pty's native build needs is missing;+- clones (or `git pull`s) the repo into `~/.nodeterm-server-app`;+- installs deps (`npm ci --ignore-scripts`, then `npm rebuild node-pty` against Node's ABI —+ the same trap the [Docker](#docker--dokploy) build documents) and builds the renderer ++ server bundle;+- installs a **systemd** service (`NODETERM_HEADLESS=1`, `Restart=on-failure`, journald logs):+ a system unit at `/etc/systemd/system/nodeterm-server.service` when run as root, or a+ per-user unit + `loginctl enable-linger` otherwise — then enables and (re)starts it.++Follow the logs with `journalctl -u nodeterm-server -f` (add `--user` for a non-root install).++### `NODETERM_HEADLESS`++Set `NODETERM_HEADLESS=1` (also accepts `true`, case-insensitive) to boot in headless mode.+Everything boots **exactly as usual** — the loopback hook server, the agent-status mirror, the+usage poll, the granted push senders (push-notify + Live-Activity), and the pending-approvals+sweep — **except** the public HTTP/WS listener, which is **never bound**. There is no renderer+serving and no auth surface. `NODETERM_HOST` / `NODETERM_PORT` are ignored (nothing binds), and+`platform.broadcast` is a no-op while no browser UI is attached.++### Security rationale: zero open ports++The whole point of this mode is that it adds **no network attack surface**:++- **No public listener at all.** The HTTP/WS server is never created, so there is no port to+ expose, no login page to brute-force, and no session cookie in flight.+- **The hook server stays loopback-only.** Agent CLIs POST their lifecycle hooks to+ `127.0.0.1` (a per-session bearer token, fail-open) — it never leaves the host.+- **Push is outbound-only.** Notifications reach the phone over **outbound HTTPS**, authorized+ by a signed, device-scoped **grant** the phone itself drops at+ `~/.nodeterm/push-grants/<deviceId>.grant` when it reaches the host over SSH. No inbound+ connection, no standing relay identity — a grant a phone never dropped simply means no push.++The phone's own SSH session into the host is the trust boundary; nodeterm adds nothing listening+beside it.+## Security modelSingle-user auth. There is one password; sessions are per-browser.diff --git a/scripts/install-server.sh b/scripts/install-server.shnew file mode 100755index 000000000..c2329d5df--- /dev/null+++ b/scripts/install-server.sh@@ -0,0 +1,151 @@+#!/usr/bin/env bash+#+# nodeterm headless notification host — one-line installer / updater.+#+# curl -fsSL https://raw.githubusercontent.com/eneskirca/nodeterm/main/scripts/install-server.sh | bash+#+# Installs (or updates) the nodeterm Server Edition on this Linux host and runs it in HEADLESS+# mode (NODETERM_HEADLESS=1): it boots every core service — the loopback hook server, agent-status+# mirror, usage poll and the granted push senders — but binds NO public HTTP/WS listener, so there+# are ZERO open ports. A phone that SSHes into this host and drops a push grant gets full push /+# Live-Activity coverage for as long as the service runs. See docs/SERVER.md.+#+# Idempotent: re-run it any time to pull the latest code, rebuild, and restart the service.+set -euo pipefail++REPO_URL="${NODETERM_REPO_URL:-https://github.com/eneskirca/nodeterm}"+APP_DIR="${NODETERM_APP_DIR:-$HOME/.nodeterm-server-app}"+SERVICE_NAME="nodeterm-server"+MIN_NODE_MAJOR=20++# ---- pretty output ---------------------------------------------------------------------------+info() { printf '\033[36m→\033[0m %s\n' "$1"; }+ok() { printf '\033[32m✓\033[0m %s\n' "$1"; }+warn() { printf '\033[33m⚠\033[0m %s\n' "$1" >&2; }+fail() { printf '\033[31m✗\033[0m %s\n' "$1" >&2; exit 1; }++# ---- preflight: OS + required tools ----------------------------------------------------------+[ "$(uname -s)" = "Linux" ] || fail "The headless host targets Linux (systemd). For macOS run the desktop app; for containers use the Dockerfile (see docs/SERVER.md)."++command -v git >/dev/null 2>&1 || fail "git is not installed. Install it first (e.g. 'sudo apt install git' or 'sudo dnf install git')."++if ! command -v node >/dev/null 2>&1; then+ fail "Node.js is not installed. Install Node.js >= ${MIN_NODE_MAJOR} (https://nodejs.org or your distro / nvm) and re-run."+fi+NODE_BIN="$(command -v node)"+NODE_MAJOR="$("$NODE_BIN" -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0)"+if [ "$NODE_MAJOR" -lt "$MIN_NODE_MAJOR" ]; then+ fail "Node.js >= ${MIN_NODE_MAJOR} is required, found $("$NODE_BIN" -v). Upgrade Node and re-run."+fi++command -v npm >/dev/null 2>&1 || fail "npm is not installed (it normally ships with Node.js). Install npm and re-run."++# node-pty is a native module and is (re)built from source against Node's ABI, which needs a C/C+++# toolchain + python3. Missing tools → warn with the install one-liner, but don't hard-fail: if a+# prebuilt binary is available the build still succeeds.+MISSING_BUILD=""+for tool in make gcc python3; do+ command -v "$tool" >/dev/null 2>&1 || MISSING_BUILD="$MISSING_BUILD $tool"+done+if [ -n "$MISSING_BUILD" ]; then+ warn "Missing build tools for the node-pty native module:$MISSING_BUILD"+ warn " Debian/Ubuntu: sudo apt install -y build-essential python3"+ warn " Fedora/RHEL: sudo dnf install -y make gcc gcc-c++ python3"+ warn "Continuing — install them and re-run this script if the build below fails."+fi++# tmux is what makes terminal sessions survive restarts; the server falls back to a plain shell+# without it. Not fatal for a notification host, but worth flagging.+command -v tmux >/dev/null 2>&1 || warn "tmux is not installed — terminal sessions won't survive restarts (install 'tmux' for continuity)."++# ---- clone or update -------------------------------------------------------------------------+if [ -d "$APP_DIR/.git" ]; then+ info "Updating existing checkout in $APP_DIR"+ git -C "$APP_DIR" fetch --depth 1 origin main+ git -C "$APP_DIR" reset --hard origin/main+else+ [ -e "$APP_DIR" ] && fail "$APP_DIR exists but is not a git checkout. Remove it and re-run, or set NODETERM_APP_DIR."+ info "Cloning $REPO_URL into $APP_DIR"+ git clone --depth 1 "$REPO_URL" "$APP_DIR"+fi++cd "$APP_DIR"++# ---- install deps + build --------------------------------------------------------------------+# The repo's postinstall runs electron-rebuild (targets ELECTRON's ABI). The server runs under+# plain Node, so we --ignore-scripts and rebuild node-pty against Node's own ABI afterwards. Same+# trap the Dockerfile documents — see docs/SERVER.md.+info "Installing dependencies (npm ci --ignore-scripts)…"+npm ci --ignore-scripts++info "Building renderer + server bundle…"+npm run build+npm run server:build++info "Rebuilding node-pty against Node's ABI…"+npm rebuild node-pty++[ -f "$APP_DIR/out/server/main.cjs" ] || fail "Build did not produce out/server/main.cjs — check the output above."++# ---- install + (re)start the systemd service -------------------------------------------------+UNIT_DESC="nodeterm headless notification host"++write_unit() {+ # $1 = target unit path+ cat > "$1" <<UNIT+[Unit]+Description=$UNIT_DESC+After=network-online.target+Wants=network-online.target++[Service]+Type=simple+WorkingDirectory=$APP_DIR+Environment=NODETERM_HEADLESS=1+ExecStart=$NODE_BIN $APP_DIR/out/server/main.cjs+Restart=on-failure+RestartSec=5+# Logs go to journald (journalctl); StandardOutput/Error default to journal.++[Install]+WantedBy=$2+UNIT+}++if [ "$(id -u)" = "0" ]; then+ # Root install: system-wide unit.+ UNIT_PATH="/etc/systemd/system/${SERVICE_NAME}.service"+ info "Installing system service at $UNIT_PATH"+ write_unit "$UNIT_PATH" "multi-user.target"+ systemctl daemon-reload+ systemctl enable "$SERVICE_NAME"+ systemctl restart "$SERVICE_NAME"+ ok "Service installed and (re)started."+ echo+ systemctl --no-pager status "$SERVICE_NAME" || true+ echo+ info "Logs: journalctl -u $SERVICE_NAME -f"+ info "Update: re-run this script."+else+ # Non-root install: per-user unit + linger so it runs without an active login session.+ command -v systemctl >/dev/null 2>&1 || fail "systemctl not found — a systemd host is required for the service. (You can still run it manually: NODETERM_HEADLESS=1 node $APP_DIR/out/server/main.cjs)"+ UNIT_DIR="$HOME/.config/systemd/user"+ UNIT_PATH="$UNIT_DIR/${SERVICE_NAME}.service"+ info "Installing user service at $UNIT_PATH"+ mkdir -p "$UNIT_DIR"+ write_unit "$UNIT_PATH" "default.target"+ # enable-linger keeps the user manager (and the service) alive across logout / reboot.+ loginctl enable-linger "$(id -un)" 2>/dev/null || warn "Could not enable linger — the service may stop when you log out."+ systemctl --user daemon-reload+ systemctl --user enable "$SERVICE_NAME"+ systemctl --user restart "$SERVICE_NAME"+ ok "Service installed and (re)started."+ echo+ systemctl --user --no-pager status "$SERVICE_NAME" || true+ echo+ info "Logs: journalctl --user -u $SERVICE_NAME -f"+ info "Update: re-run this script."+fi++echo+ok "nodeterm headless notification host is running (NODETERM_HEADLESS=1 — zero open ports)."diff --git a/src/server/config.test.ts b/src/server/config.test.tsindex 7e50eff0c..444772c78 100644--- a/src/server/config.test.ts+++ b/src/server/config.test.ts@@ -26,6 +26,21 @@ describe('resolveConfig', () => {expect(() => resolveConfig({ NODETERM_HOST: '0.0.0.0' }, ['--insecure-http'])).not.toThrow()})+ it('headless: off by default, on for "1"/"true" (case-insensitive), off for anything else', () => {+ expect(resolveConfig({}, []).headless).toBe(false)+ expect(resolveConfig({ NODETERM_HEADLESS: '1' }, []).headless).toBe(true)+ expect(resolveConfig({ NODETERM_HEADLESS: 'true' }, []).headless).toBe(true)+ expect(resolveConfig({ NODETERM_HEADLESS: 'TRUE' }, []).headless).toBe(true)+ expect(resolveConfig({ NODETERM_HEADLESS: ' true ' }, []).headless).toBe(true)+ expect(resolveConfig({ NODETERM_HEADLESS: '0' }, []).headless).toBe(false)+ expect(resolveConfig({ NODETERM_HEADLESS: 'yes' }, []).headless).toBe(false)+ })++ it('headless: a non-loopback host no longer fails the boot (nothing binds)', () => {+ // In normal mode this throws; headless binds no listener, so the hazard does not apply.+ expect(() => resolveConfig({ NODETERM_HOST: '0.0.0.0', NODETERM_HEADLESS: '1' }, [])).not.toThrow()+ })+it('proxy trust: off by default', () => {expect(resolveConfig({}, []).trustProxy).toBeUndefined()})diff --git a/src/server/config.ts b/src/server/config.tsindex 5094fb8b2..3604da17d 100644--- a/src/server/config.ts+++ b/src/server/config.ts@@ -13,6 +13,15 @@ export type ServerConfig = {rendererDir: stringinsecureHttp: booleanpasswordSeed?: string+ /**+ * Headless notification-host mode (`NODETERM_HEADLESS=1`). When set, the server does NOT+ * bind the HTTP/WS listener at all — no renderer serving, no auth surface, no open port —+ * but boots every other core service exactly as usual (the loopback hook server, agent-status+ * mirror, usage poll, granted push senders, pending-approvals sweep). A phone that SSHes into+ * the host still gets full push / Live-Activity coverage as long as this process runs. See the+ * "Headless notification host" section of docs/SERVER.md.+ */+ headless: boolean/*** Merge the managed agent hooks into the user's real agent config dirs (~/.claude,* ~/.codex, ~/.gemini) at boot. Defaults to true — the server needs them to receive@@ -82,8 +91,14 @@ export function resolveConfig(env: NodeJS.ProcessEnv, argv: string[]): ServerConconst rendererDir = pick('renderer-dir', 'NODETERM_RENDERER_DIR', path.resolve('out/renderer'))const insecureHttp = args['insecure-http'] === trueconst passwordSeed = env.NODETERM_SERVER_PASSWORD || undefined+ // Headless mode is env-only (a deployment/systemd knob, not an interactive flag). Accept the two+ // truthy spellings the install script + systemd unit emit.+ const headlessEnv = (env.NODETERM_HEADLESS || '').trim().toLowerCase()+ const headless = headlessEnv === '1' || headlessEnv === 'true'- if (!isLoopback(host) && !insecureHttp) {+ // Headless binds nothing, so the "plain HTTP on a public interface" hazard the loopback refusal+ // guards against does not apply — a stray NODETERM_HOST must not fail a headless boot.+ if (!isLoopback(host) && !insecureHttp && !headless) {throw new Error(`Refusing to bind non-loopback host "${host}" over plain HTTP. Run nodeterm-server ` +`behind a TLS-terminating reverse proxy and keep it bound to a loopback address ` +@@ -111,5 +126,5 @@ export function resolveConfig(env: NodeJS.ProcessEnv, argv: string[]): ServerCon)}- return { port, host, dataDir, rendererDir, insecureHttp, passwordSeed, trustProxy }+ return { port, host, dataDir, rendererDir, insecureHttp, passwordSeed, trustProxy, headless }}diff --git a/src/server/index.ts b/src/server/index.tsindex 4c1b89a6f..4cc96c589 100644--- a/src/server/index.ts+++ b/src/server/index.ts@@ -100,8 +100,9 @@ export async function startServer(`and that it strips/overwrites this header on client requests.`)}- if (!auth.isConfigured()) {+ if (!config.headless && !auth.isConfigured()) {// No password set yet: print the one-time setup URL so the operator can bootstrap.+ // (Headless binds no listener, so there is no setup page to point at.)console.log(`Setup: http://${config.host}:${config.port}/setup?token=${auth.setupToken()}`)}@@ -289,6 +290,22 @@ export async function startServer(}await hookServer.start()+ // Headless notification host: every core service above (incl. the loopback hook server, which+ // is its own listener and MUST run) is booted, but we bind NO public HTTP/WS listener — no+ // renderer serving, no auth surface, no open port. The granted push senders reach the phone over+ // outbound HTTPS, and platform.broadcast is a no-op with zero attached UIs. See docs/SERVER.md.+ if (config.headless) {+ console.log('nodeterm-server headless mode — UI disabled (no HTTP/WS listener bound)')+ return {+ port: 0, // nothing bound+ async close() {+ // Detach PTY clients — tmux sessions keep running (Phase 1 contract).+ await ptyManager.killAll()+ hookServer.stop()+ }+ }+ }+const server = http.createServer(createHttpHandler({ auth, rendererDir: config.rendererDir, trustProxy: config.trustProxy }))diff --git a/src/server/main.ts b/src/server/main.tsindex b55aa1e6b..90bacd984 100644--- a/src/server/main.ts+++ b/src/server/main.ts@@ -13,8 +13,12 @@ process.on('unhandledRejection', (e) => console.error('[nodeterm-server] unhandlasync function main(): Promise<void> {const config = resolveConfig(process.env, process.argv.slice(2))const { port, close } = await startServer(config)- const scheme = config.insecureHttp ? 'http (insecure)' : 'http'- console.log(`nodeterm-server listening on ${scheme} ${config.host}:${port}`)+ // Headless binds no listener, so there is nothing to announce as "listening" (startServer already+ // logged the headless line). Only print the address in normal serving mode.+ if (!config.headless) {+ const scheme = config.insecureHttp ? 'http (insecure)' : 'http'+ console.log(`nodeterm-server listening on ${scheme} ${config.host}:${port}`)+ }const shutdown = (signal: string): void => {console.log(`\nReceived ${signal}, shutting down…`)diff --git a/test/server/headless-e2e.test.ts b/test/server/headless-e2e.test.tsnew file mode 100644index 000000000..319751e15--- /dev/null+++ b/test/server/headless-e2e.test.ts@@ -0,0 +1,47 @@+import { describe, it, expect } from 'vitest'+import fs from 'fs'+import os from 'os'+import path from 'path'+import net from 'net'+import { startServer } from '../../src/server/index'++// Headless notification-host boot smoke: every core service (incl. the loopback hook server) boots,+// but NO public HTTP/WS listener is bound. Follows the same startServer harness as server-e2e, minus+// tmux/pty (nothing is spawned here), so it runs everywhere.+describe('server headless mode: boots core services, binds no public listener', () => {+ it('startServer with headless:true returns port 0 and closes cleanly', async () => {+ const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-headless-'))+ try {+ const srv = await startServer({+ port: 8443,+ host: '127.0.0.1',+ dataDir,+ rendererDir: path.join(dataDir, 'no-renderer'),+ insecureHttp: false,+ headless: true,+ // Never touch the developer's real ~/.claude — the hook would point into `dataDir`,+ // which the teardown removes, leaving a dangling hook that breaks agent sessions.+ installHooks: false+ })+ // Nothing bound: the sentinel port is 0.+ expect(srv.port).toBe(0)+ // And the configured port (8443) is NOT listening — a connect attempt is refused.+ const listening = await new Promise<boolean>((resolve) => {+ const sock = net+ .connect({ host: '127.0.0.1', port: 8443 }, () => {+ sock.destroy()+ resolve(true)+ })+ .on('error', () => resolve(false))+ sock.setTimeout(500, () => {+ sock.destroy()+ resolve(false)+ })+ })+ expect(listening).toBe(false)+ await srv.close()+ } finally {+ fs.rmSync(dataDir, { recursive: true, force: true })+ }+ }, 30_000)+})