Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
feat(cli): device pending + revoke all, per-command help, version
Rahmancf19f9e19a59
diff --git a/README.md b/README.mdindex cac35728..0fab2b11 100644--- a/README.md+++ b/README.md@@ -118,6 +118,7 @@ The browser UI is one frontend, not the product. The installer also puts `mso` o```bashmso -h # every verbmso device list # who can log in+mso device pending # who typed the password and is waitingmso approve <deviceId> "my phone"mso ls ~/projects # filesmso exec "df -h" # host shelldiff --git a/bin/mso b/bin/msoindex f1119972..7234ad1d 100755--- a/bin/mso+++ b/bin/mso@@ -14,16 +14,28 @@# TERMINAL term open [cwd] · term input <id> <text> · term close <id># AI ai <prompt…> · threads [id] · memory# CONFIG config · prefs · models · skills-# DEVICES device list|approve <id> [label]|revoke <id> (local, no login)-# devices = device list · whoami · login (this CLI's id + session)+# DEVICES device list|pending|approve <id> [label]|revoke <id>|revoke all --yes+# devices = device list · whoami · login (local, no login needed)# SERVICE service status|start|stop|restart|logs [n] · build · deploy# EDITOR crud list|get|set|del|cmds (see `mso crud`)-# ESCAPE api <METHOD> <path> [json] — any endpoint, e.g.-# mso api GET /api/v1/sys/stats+# ESCAPE api <METHOD> <path> [json] — any endpoint+# META version · help [command]+#+# EXAMPLES+# mso device pending who typed the password and is waiting+# mso device approve <id> "my phone" let them in+# mso exec "systemctl status nginx" run anything on the host+# mso camoufox start && mso camoufox session browser up + its VNC password+# mso mapp logs hermes a managed app's log tail+# mso api POST /api/v1/sys/cleanup no named verb? call it directly+#+# Per-command help: mso <command> --help (e.g. `mso device --help`)## READ = OS_FS_READ_ROOTS; WRITE = home + ~/projects; exec = full host power.set -euo pipefail+VERSION="1.0.0"+ROOT="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"B="${MSO_BASE:-${OS_BASE:-http://127.0.0.1:4005}}"ENVF="${MSO_ENV:-${OS_ENV:-$ROOT/.env.local}}"@@ -98,13 +110,38 @@ usage() { awk 'NR>1 { if ($0 !~ /^#/) exit; sub(/^# ?/, ""); print }' "$0"; }# from the table itself so a new arm can never be missing from did-you-mean.verbs() {awk '/^cmd="/ { on = 1 }- on && match($0, /^ [a-z|h-]+\)/) {+ on && match($0, /^ [a-zA-Z|-]+\)/) {s = substr($0, 3, RLENGTH - 3); gsub(/\|/, "\n", s); print s}' "$0"}+# One usage string per command group, used by BOTH `--help` and the error path —+# so the help you get when you ask can never disagree with the help you get when+# you're wrong.+U_camoufox="camoufox status|start|stop|session"+U_mapp="mapp list|show <id>|logs <id>|backups <id>|jobs <id>|install <id>|update <id>"+U_term="term open [cwd]|input <id> <text>|close <id>"+U_device="device list|pending|approve <id> [label]|revoke <id>|revoke all --yes"+U_service="service status|start|stop|restart|logs [n]"+U_crud="crud list <dir> | get <path> | set <path> <cmd k=v…|text> | del <path> | cmds"+U_api="api <METHOD> <path> [json] e.g. mso api GET /api/v1/sys/stats"++# `mso <command> --help` — hermes-style per-command help, before dispatch so a+# group never has to handle the flag itself.+if [ $# -ge 2 ]; then+ case "$2" in+ -h|--help|help)+ eval "u=\${U_$1-}"+ [ -n "${u-}" ] && { echo "usage: mso $u"; exit 0; }+ # No group usage means a flat verb: show the header line that documents it.+ usage | grep -E "(^|[ ·|])$1([ ·|]|$)" || usage+ exit 0 ;;+ esac+fi+cmd="${1:-help}"; shift || truecase "$cmd" in+ version|--version|-V) echo "mso $VERSION (base $B, root $ROOT)"; exit 0 ;;# ── files ────────────────────────────────────────────────────────────────ls) jget "/api/v1/fs/list?path=$(enc "${1:-~}")" ;;cat) jget "/api/v1/fs/read?path=$(enc "${1:?path}")" | jq -r . ;;@@ -130,7 +167,7 @@ case "$cmd" instart) jpost "/api/v1/camoufox/service" '{"action":"start"}' ;;stop) jpost "/api/v1/camoufox/service" '{"action":"stop"}' ;;session) jget "/api/v1/camoufox/session" ;;- *) die "camoufox: status|start|stop|session" ;;+ *) die "usage: mso $U_camoufox" ;;esac ;;# ── managed apps (hermes, openclaw…) ─────────────────────────────────────@@ -145,7 +182,7 @@ case "$cmd" injobs) jget "/api/v1/managed-apps/$(enc "${1:?id}")/jobs" ;;install) jpost "/api/v1/managed-apps/$(enc "${1:?id}")/install" "$(kv_args "${@:2}")" ;;update) jpost "/api/v1/managed-apps/$(enc "${1:?id}")/update" "$(kv_args "${@:2}")" ;;- *) die "mapp: list|show <id>|logs <id>|backups <id>|jobs <id>|install <id>|update <id>" ;;+ *) die "usage: mso $U_mapp" ;;esac ;;# ── terminal ─────────────────────────────────────────────────────────────@@ -155,7 +192,7 @@ case "$cmd" inopen) jpost "/api/v1/term/open" "$(jq -n --arg c "${1-}" '{cwd:$c}')" ;;input) jpost "/api/v1/term/input" "$(jq -n --arg i "${1:?id}" --arg d "${2:?text}" '{id:$i,data:$d}')" ;;close) jpost "/api/v1/term/close" "$(jq -n --arg i "${1:?id}" '{id:$i}')" ;;- *) die "term: open [cwd]|input <id> <text>|close <id>" ;;+ *) die "usage: mso $U_term" ;;esac ;;# ── assistant / state ────────────────────────────────────────────────────@@ -173,11 +210,13 @@ case "$cmd" indevices|device)case "${1:-list}" inlist) dev_script --list ;;+ pending) dev_script --pending ;;approve) [ -n "${2-}" ] || die "usage: mso device approve <deviceId> [label]"dev_script "$2" "${@:3}" ;;- revoke) [ -n "${2-}" ] || die "usage: mso device revoke <deviceId>"- dev_script --revoke "$2" ;;- *) die "device: list|approve <id> [label]|revoke <id>" ;;+ revoke) [ -n "${2-}" ] || die "usage: mso device revoke <deviceId> | all --yes"+ if [ "$2" = "all" ]; then dev_script --revoke-all "${3-}"+ else dev_script --revoke "$2"; fi ;;+ *) die "usage: mso $U_device" ;;esac ;;approve) [ -n "${1-}" ] || die "usage: mso approve <deviceId> [label] (ids: mso device list)"dev_script "$1" "${@:2}" ;;@@ -194,7 +233,7 @@ case "$cmd" instop) sudo systemctl stop mso.service ;;restart) sudo systemctl restart mso.service ;;logs) journalctl -u mso.service -n "${2:-50}" --no-pager ;;- *) die "service: status|start|stop|restart|logs [n]" ;;+ *) die "usage: mso $U_service" ;;esac ;;build) (cd "$ROOT" && npm run build) ;;deploy) (cd "$ROOT" && npm run build) && sudo systemctl restart mso.service && echo "deployed → $B" ;;@@ -219,7 +258,7 @@ case "$cmd" inelsejpost "/api/v1/fs/write" "$(jq -n --arg p "$path" --arg c "$op${*:+ $*}" '{path:$p,content:$c}')"fi ;;- *) die "crud: list <dir> | get <path> | set <path> <cmd k=v…|text> | del <path> | cmds" ;;+ *) die "usage: mso $U_crud" ;;esac ;;# ── escape hatch: any endpoint at all ────────────────────────────────────diff --git a/bin/mso.test.ts b/bin/mso.test.tsindex 3862134b..73de2db1 100644--- a/bin/mso.test.ts+++ b/bin/mso.test.ts@@ -39,4 +39,24 @@ describe("bin/mso", () => {it("exits non-zero on an unknown command", () => {expect(() => run("definitely-not-a-verb")).toThrow();});++ it("refuses `device revoke all` without --yes, and leaves the store intact", () => {+ const fs = require("node:fs") as typeof import("node:fs");+ const os = require("node:os") as typeof import("node:os");+ const store = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "mso-dev-")), "devices.json");+ const before = JSON.stringify({ approved: { ["a".repeat(32)]: { label: "x" } }, pending: {} });+ fs.writeFileSync(store, before);+ const withStore = (...args: string[]) =>+ execFileSync(CLI, args, {+ encoding: "utf8",+ env: { ...process.env, MSO_ENV: "/dev/null", OS_DEVICE_STORE: store },+ });++ // Revoking everything signs every browser out; one keystroke from `revoke <id>`.+ expect(() => withStore("device", "revoke", "all")).toThrow();+ expect(fs.readFileSync(store, "utf8")).toBe(before);++ withStore("device", "revoke", "all", "--yes");+ expect(JSON.parse(fs.readFileSync(store, "utf8")).approved).toEqual({});+ });});diff --git a/scripts/approve-device.js b/scripts/approve-device.jsindex a968ebb3..48470775 100644--- a/scripts/approve-device.js+++ b/scripts/approve-device.js@@ -48,11 +48,46 @@ if (args[0] === "--list") {process.exit(0);}+if (args[0] === "--pending") {+ const s = read();+ const pd = Object.entries(s.pending);+ console.log(`store: ${STORE}\n\nPENDING (typed correct password, awaiting approval):`);+ if (!pd.length) console.log(" (none)");+ for (const [id, d] of pd) console.log(` ${id} "${d.label}" ip=${d.ip} attempts=${d.attempts} last=${ts(d.lastSeen)}`);+ if (pd.length) console.log(`\napprove: mso device approve ${pd[0][0]} "a label"`);+ process.exit(0);+}++if (args[0] === "--revoke-all") {+ // Locks every browser out at once. Recoverable — approving is a local file+ // write that needs no session — but the confirmation is not optional, because+ // this is one keystroke away from `--revoke <id>`.+ const s = read();+ const ids = Object.keys(s.approved);+ if (!ids.length) { console.log("nothing to revoke — no approved devices"); process.exit(0); }+ if (args[1] !== "--yes") {+ console.error(`refusing: this revokes ALL ${ids.length} approved devices and signs every browser out.`);+ console.error("re-run with --yes if that is what you want. Re-approve later with:");+ console.error(" mso device approve <deviceId> \"label\"");+ process.exit(1);+ }+ s.approved = {};+ write(s);+ console.log(`revoked ${ids.length} device(s):`);+ for (const id of ids) console.log(` ${id}`);+ console.log("\nno device can sign in until you approve one again.");+ process.exit(0);+}+if (args[0] === "--revoke") {const id = args[1];if (!id) { console.error("usage: --revoke <deviceId>"); process.exit(1); }const s = read();- if (!s.approved[id]) { console.error(`not approved: ${id}`); process.exit(1); }+ if (!s.approved[id]) {+ console.error(`not approved: ${id}`);+ if (id === "all") console.error("to revoke every device: mso device revoke all --yes");+ process.exit(1);+ }delete s.approved[id];write(s);console.log(`revoked ${id}`);