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
fix(install): make WSL CLI setup reliable
Rahman0d56f5ea33fa
diff --git a/README.md b/README.mdindex 9fe569d9..bf55001e 100644--- a/README.md+++ b/README.md@@ -120,13 +120,18 @@ The flow lets you choose:from Alfa's credentials);- reviewed **installable skills** such as Ponytail, Caveman and the MSO-safe RTK wrapper.-The installer also generates the owner login credentials, builds production, installs and-starts `mso.service`, and installs the CLI in both `~/.local/bin/mso` and—when the normal-service install has sudo available—`/usr/local/bin/mso`. That system launcher is important:-a child `curl | bash` process cannot modify the PATH of the shell that launched it, so-`mso -h` must work immediately **after the installer returns**, without asking you to-restart the shell. The installer also adds an idempotent `~/.local/bin` fallback to the-normal shell profile for future sessions.+The installer generates the owner login credentials, builds production, and installs the CLI+**before** it touches systemd. It always creates `~/.local/bin/mso`; when the invoking shell+already has `/usr/local/bin` on `PATH`, it also installs a guarded `/usr/local/bin/mso`+launcher (using sudo when needed). That order matters on WSL: a distro may ship a `systemctl`+binary even when systemd is not PID 1, and a service setup problem must never prevent the CLI+from being installed.++A child `curl | bash` process cannot modify its parent shell's `PATH`. The installer therefore+checks the **original invoking PATH** after creating the launchers and explicitly reports whether+`mso -h` will work immediately. If neither launcher is already reachable from that PATH, the+install still succeeds, persists `~/.local/bin` in the normal shell profile, and prints the exact+`export PATH=...` command for the current shell instead of falsely claiming success.If the environment has no controlling TTY (CI/cloud-init), the installer never blocks. Itprints the resume command instead:@@ -143,7 +148,8 @@ skills:curl -fsSL https://raw.githubusercontent.com/rahmanef63/mso/main/scripts/install.sh | bash -s -- -y```-After installation these should work immediately:+After installation, the installer prints whether the current shell can already resolve `mso`.+On the normal Ubuntu/WSL PATH (which includes `/usr/local/bin`) these work immediately:```bashmso -h@@ -153,6 +159,14 @@ mso skills available # reviewed installable skill listmso skills install ponytail caveman rtk -y```+If it explicitly says the current shell cannot see the user launcher yet, run the one-line+`export PATH="$HOME/.local/bin:$PATH"` it prints; new shells use the persisted profile entry.++**WSL2:** the CLI is supported even when systemd is not active. In that case the installer now+finishes the CLI instead of failing in `systemctl`, but it skips `mso.service`. For the full+background service, enable systemd in `/etc/wsl.conf`, exit all WSL sessions from Windows, reopen+the distro, then re-run the installer with `--onboard`.+`Caveman`/`Ponytail` appear in two intentionally different places. **Response presets**(`mso config style caveman|ponytail`) are lightweight Alfa output policies. The marketentries are full `SKILL.md` packages installed into the trusted operator root@@ -332,10 +346,10 @@ Tested:- Ubuntu 22.04- Ubuntu 24.04-Expected to work:+Supported deployment shapes:-- Debian 12-- Other systemd-based Linux distributions with Node.js 20.9+ and build tools+- WSL2 Ubuntu: CLI/install path works without systemd; the background service requires systemd enabled in WSL+- Debian 12 and other systemd-based Linux distributions with Node.js 20.9+ and build toolsNot currently supported:diff --git a/bun.lock b/bun.lockindex 846e63bf..f0802a53 100644--- a/bun.lock+++ b/bun.lock@@ -44,6 +44,7 @@"@vitest/coverage-v8": "^4.1.11","eslint": "^9.39.4","eslint-config-next": "^16.3.2",+ "fast-check": "^4.9.0","postcss": "^8.5.26","tailwindcss": "^4.3.0","typescript": "^5.9.3",@@ -682,6 +683,8 @@"expect-type": ["[email protected]", "", {}, "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA=="],+ "fast-check": ["[email protected]", "", { "dependencies": { "pure-rand": "^8.0.0" } }, "sha512-7ms6T7SybUev/PQITciI0yLM2pOSFy5zpG8Ty7tQofcVaQUvrMXp6CBwqF6fThLCLOrfBtuHAtwq6Yu4XPCllg=="],+"fast-deep-equal": ["[email protected]", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],"fast-glob": ["[email protected]", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.4" } }, "sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg=="],@@ -1008,6 +1011,8 @@"punycode": ["[email protected]", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="],+ "pure-rand": ["[email protected]", "", {}, "sha512-vvuOGgcuPJAirlHvuQw1TrOiw7ptaIXXmIbNuiNOY6lNGJJH49PQ1Kj4nd783nPdQhQdicgOjVI2yI/9BD6/Ng=="],+"queue-microtask": ["[email protected]", "", {}, "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="],"react": ["[email protected]", "", {}, "sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw=="],diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex b35276b6..ff9780e6 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `install` make WSL CLI setup reliable- `security` harden GitHub quality controls- `security` canonicalize writable path containmentdiff --git a/docs/INSTALL.md b/docs/INSTALL.mdindex 9088e818..080dfd84 100644--- a/docs/INSTALL.md+++ b/docs/INSTALL.md@@ -7,7 +7,8 @@## 0. Requirements-- Linux with systemd;+- Linux; systemd is required for the installed background service, but not for the CLI;+- WSL2 is supported for the CLI. Full service mode requires systemd enabled as PID 1;- Node.js 20.9+ (Node 22 recommended/current production runtime);- Bun for dependency installation/scripts;- a non-root user that owns MSO;@@ -31,13 +32,15 @@ The installer:2. installs Bun/dependencies as needed;3. creates private owner auth configuration when missing;4. runs the production build;-5. installs the `mso.service` system unit when systemd is available;-6. enables the owner's lingering user manager needed by self-update/managed-app user units;-7. installs `~/.local/bin/mso` plus a guarded `/usr/local/bin/mso` launcher so the parent- shell can resolve `mso` immediately after `curl | bash` returns;-8. persists an idempotent `~/.local/bin` PATH fallback for future shells;-9. starts/replaces the service only after a successful build;-10. on a fresh interactive install, opens `/dev/tty` and launches `mso onboard`.+5. installs `~/.local/bin/mso` **before service setup**, then attempts a guarded launcher in+ `/usr/local/bin` when that directory is already on the invoking shell's PATH;+6. verifies whether the invoking shell will actually resolve `mso` after the child installer+ returns, and persists an idempotent `~/.local/bin` PATH fallback for future shells;+7. installs the `mso.service` system unit only when systemd is really PID 1 (not merely when a+ `systemctl` executable exists);+8. enables the owner's lingering user manager needed by self-update/managed-app user units;+9. activates the service only after a successful build;+10. on a fresh interactive install with a verified running service, opens `/dev/tty` and launches `mso onboard`.Useful flags:@@ -83,6 +86,26 @@ Their model/provider configuration belongs to those applications and is not implfilled from Alfa's credential. Selected app installs stream their job transcript until aterminal status.+### WSL2++WSL can contain `systemctl` while still running a non-systemd PID 1. MSO treats those as two+different capabilities: the CLI is installed normally, while the background service is skipped+with an explicit message. This prevents service setup from aborting before `mso` exists.++For the full service on WSL2, enable systemd in `/etc/wsl.conf`:++```ini+[boot]+systemd=true+```++Then exit all WSL sessions from Windows, reopen the distro, confirm `ps -p 1 -o comm=` reports+`systemd`, and re-run the installer. The installer never edits WSL host configuration itself.++If the installer reports that the current shell did not already contain a reachable launcher+directory, use the exact PATH command it prints for that shell; the profile change is already+persisted for future shells.+## 2. Network exposureThe installer binds `127.0.0.1` by default. This is intentional: an authenticated MSO Ownerdiff --git a/lib/install-contract.test.ts b/lib/install-contract.test.tsindex e0e2cf22..4d49fed3 100644--- a/lib/install-contract.test.ts+++ b/lib/install-contract.test.ts@@ -22,12 +22,25 @@ describe("one-line installer contract", () => {expect(src).toContain('FRESH_INSTALL=1');});- it("makes mso discoverable immediately and persists the user PATH fallback", () => {+ it("installs the CLI before service setup and proves it against the invoking PATH", () => {const src = fs.readFileSync(INSTALL, "utf8");- expect(src).toContain("SYSTEM_CLI=/usr/local/bin/mso");+ expect(src.indexOf("# ---- CLI on PATH")).toBeLessThan(src.indexOf("# ---- systemd unit ----"));+ expect(src).toContain('PARENT_PATH="${PATH:-}"');+ expect(src).toContain('SYSTEM_BIN_DIR="${MSO_SYSTEM_BIN_DIR:-/usr/local/bin}"');+ expect(src).toContain('PATH="$PARENT_PATH" command -v mso');+ expect(src).toContain('"$BIN_DIR/mso" -h');expect(src).toContain("# >>> mso cli >>>");expect(src).toContain('export PATH="$BIN_DIR:$PATH"');- expect(src).toContain('command -v mso');+ });++ it("requires systemd as PID 1 before service setup and gates onboarding on verified health", () => {+ const src = fs.readFileSync(INSTALL, "utf8");+ expect(src).toContain("systemd_ready()");+ expect(src).toContain("/proc/1/comm");+ expect(src).toContain('= "systemd"');+ expect(src).toContain("WSL detected without systemd as PID 1");+ expect(src).toContain("SERVICE_READY=1");+ expect(src).toContain('[ "$RUN_ONBOARD" -eq 1 ] && [ "$SERVICE_READY" -eq 1 ]');});it("verifies a commit-pinned Bun bootstrap before execution", () => {diff --git a/lib/security/property-fuzz.test.ts b/lib/security/property-fuzz.test.tsnew file mode 100644index 00000000..c097042d--- /dev/null+++ b/lib/security/property-fuzz.test.ts@@ -0,0 +1,70 @@+import path from "node:path";+import * as fc from "fast-check";+import { describe, expect, it } from "vitest";+import { isUnderRoot } from "@/lib/host/paths";+import { assertSafeUrl, isForbiddenProviderAddress } from "@/lib/host/ssrf";+import { safeEqualHex, sha256b64url, verifyPkce } from "@/lib/mcp/pkce";++const segmentChar = fc.constantFrom(..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-");+const segment = fc.array(segmentChar, { minLength: 1, maxLength: 18 }).map((chars) => chars.join(""));+const octet = fc.integer({ min: 0, max: 255 });+const verifierChar = fc.constantFrom(..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~");+const verifier = fc.array(verifierChar, { minLength: 43, maxLength: 128 }).map((chars) => chars.join(""));++function changedSameLength(value: string): string {+ const first = value[0] === "A" ? "B" : "A";+ return first + value.slice(1);+}++describe("property fuzz — security boundaries", () => {+ it("keeps generated descendants inside a root and generated siblings outside it", () => {+ const root = path.resolve("/tmp/mso-property-root");+ fc.assert(+ fc.property(fc.array(segment, { minLength: 1, maxLength: 8 }), segment, (parts, siblingName) => {+ const inside = path.join(root, ...parts);+ const outside = path.join(path.dirname(root), `outside-${siblingName}`);+ expect(isUnderRoot(inside, root)).toBe(true);+ expect(isUnderRoot(outside, root)).toBe(false);+ }),+ { numRuns: 300 },+ );+ });++ it("rejects generated RFC1918 and loopback IPv4 provider addresses", () => {+ fc.assert(+ fc.property(octet, octet, octet, fc.integer({ min: 16, max: 31 }), (a, b, c, private172) => {+ const addresses = [+ `10.${a}.${b}.${c}`,+ `127.${a}.${b}.${c}`,+ `192.168.${a}.${b}`,+ `172.${private172}.${a}.${b}`,+ ];+ for (const address of addresses) expect(isForbiddenProviderAddress(address)).toBe(true);+ }),+ { numRuns: 300 },+ );+ });++ it("never accepts a generated private literal as a provider URL", () => {+ fc.assert(+ fc.property(octet, octet, octet, (a, b, c) => {+ expect(() => assertSafeUrl(`https://10.${a}.${b}.${c}/v1`)).toThrow(/not allowed/i);+ expect(() => assertSafeUrl(`https://127.${a}.${b}.${c}/v1`)).toThrow(/not allowed/i);+ }),+ { numRuns: 200 },+ );+ });++ it("keeps PKCE verification exact across generated RFC7636 verifiers", () => {+ fc.assert(+ fc.property(verifier, (value) => {+ const challenge = sha256b64url(value);+ expect(verifyPkce(value, challenge, "S256")).toBe(true);+ expect(verifyPkce(value, changedSameLength(challenge), "S256")).toBe(false);+ expect(safeEqualHex(challenge, challenge)).toBe(true);+ expect(safeEqualHex(challenge, changedSameLength(challenge))).toBe(false);+ }),+ { numRuns: 300 },+ );+ });+});diff --git a/package.json b/package.jsonindex c45b24a8..ec4c1dea 100644--- a/package.json+++ b/package.json@@ -75,6 +75,7 @@"@vitest/coverage-v8": "^4.1.11","eslint": "^9.39.4","eslint-config-next": "^16.3.2",+ "fast-check": "^4.9.0","postcss": "^8.5.26","tailwindcss": "^4.3.0","typescript": "^5.9.3",diff --git a/scripts/install.sh b/scripts/install.shindex d0fce8cb..9eaaad7c 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -37,6 +37,11 @@ ONBOARD_MODE=autoFRESH_INSTALL=0# bun is the package manager; the RUNTIME stays node (see ensure_bun below).export BUN_INSTALL="${BUN_INSTALL:-$HOME/.bun}"+# Capture the INVOKING shell PATH before Bun or the installer changes it. A child+# curl|bash process cannot export back into its parent, so this is the only PATH+# that matters when proving `mso -h` will resolve immediately after we return.+PARENT_PATH="${PATH:-}"+SERVICE_READY=0# Reproducible bootstrap: this is Bun v1.3.14's installer source, pinned by# immutable Git commit and verified before execution. Update both values together.BUN_BOOTSTRAP_COMMIT="0d9b296af33f2b851fcbf4df3e9ec89751734ba4"@@ -92,9 +97,50 @@ donesudo_do() { if command -v sudo >/dev/null 2>&1; then sudo "$@"; else die "need root for: $* (install sudo or run the step by hand)"; fi; }+is_wsl() {+ grep -qi microsoft /proc/sys/kernel/osrelease 2>/dev/null || grep -qi microsoft /proc/version 2>/dev/null+}++systemd_ready() {+ command -v systemctl >/dev/null 2>&1 || return 1+ [ -r /proc/1/comm ] || return 1+ [ "$(tr -d '\n' </proc/1/comm 2>/dev/null)" = "systemd" ]+}++path_has_dir() {+ case ":$1:" in *":$2:"*) return 0 ;; *) return 1 ;; esac+}++# Create/update one CLI symlink without ever replacing an unrelated command.+# Returns nonzero when the destination is unavailable; callers decide whether that+# is fatal (the user-local launcher is) or only affects current-shell discovery.+link_cli_guarded() {+ local link="$1" target="$2" current dir+ dir="$(dirname "$link")"+ [ -d "$dir" ] || return 1+ if [ -e "$link" ] && [ ! -L "$link" ]; then+ warn "$link already exists and is not a symlink — left untouched"+ return 1+ fi+ if [ -L "$link" ]; then+ current="$(readlink "$link")"+ case "$current" in+ "$DIR/"*) ;;+ *) warn "$link already points elsewhere ($current) — left untouched"; return 1 ;;+ esac+ fi+ if [ -w "$dir" ]; then+ ln -sfn "$target" "$link"+ elif command -v sudo >/dev/null 2>&1; then+ sudo ln -sfn "$target" "$link" || return 1+ else+ return 1+ fi+}+# If a service already exists, update IT in place (unless --dir was given) — so a# re-run never spins up a divergent second copy next to a working install.-if [ "$DIR_EXPLICIT" -eq 0 ] && command -v systemctl >/dev/null 2>&1; then+if [ "$DIR_EXPLICIT" -eq 0 ] && systemd_ready; thenexisting="$(systemctl show -p WorkingDirectory --value "$SERVICE" 2>/dev/null || true)"[ -n "$existing" ] && [ -d "$existing/.git" ] && DIR="$existing" && info "found existing service → updating $DIR"fi@@ -120,8 +166,11 @@ if [ "$DO_UNINSTALL" -eq 1 ]; thenif [ -L "$UNINST_BIN" ] && case "$(readlink "$UNINST_BIN")" in "$DIR/"*) true ;; *) false ;; esac; thenrm -f "$UNINST_BIN"; ok "removed cli symlink $UNINST_BIN"fi- if [ -L /usr/local/bin/mso ] && case "$(readlink /usr/local/bin/mso)" in "$DIR/"*) true ;; *) false ;; esac; then- sudo_do rm -f /usr/local/bin/mso; ok "removed cli symlink /usr/local/bin/mso"+ UNINST_SYSTEM_CLI="${MSO_SYSTEM_BIN_DIR:-/usr/local/bin}/mso"+ if [ -L "$UNINST_SYSTEM_CLI" ] && case "$(readlink "$UNINST_SYSTEM_CLI")" in "$DIR/"*) true ;; *) false ;; esac; then+ if [ -w "$(dirname "$UNINST_SYSTEM_CLI")" ]; then rm -f "$UNINST_SYSTEM_CLI"+ else sudo_do rm -f "$UNINST_SYSTEM_CLI"; fi+ ok "removed cli symlink $UNINST_SYSTEM_CLI"fiUNINST_SKILLS="${MSO_SKILL_DIR:-$HOME/.claude/skills}"if [ -d "$UNINST_SKILLS" ]; then@@ -259,8 +308,81 @@ fiinfo "building (next build)…"bun run build+# ---- CLI on PATH (before service setup so WSL/no-systemd still gets a CLI) ----+# The web UI is one frontend; bin/mso reaches the same /api surface from a shell.+BIN_DIR="${MSO_BIN_DIR:-$HOME/.local/bin}"+mkdir -p "$BIN_DIR"+ln -sfn "$DIR/bin/mso" "$BIN_DIR/mso"+ok "cli → $BIN_DIR/mso"++# A fresh distro/WSL home often omits ~/.local/bin from the current PATH. Persist+# one small idempotent block for future shells. Default to bash when SHELL is not+# exported (common in curl|bash/cloud-init); zsh gets its own rc instead.+path_block() {+ local rc="$1"+ [ -e "$rc" ] || : > "$rc"+ grep -q '^# >>> mso cli >>>$' "$rc" 2>/dev/null && return+ cat >> "$rc" <<'EOF'++# >>> mso cli >>>+case ":$PATH:" in+ *":$HOME/.local/bin:"*) ;;+ *) export PATH="$HOME/.local/bin:$PATH" ;;+esac+# <<< mso cli <<<+EOF+ info "added ~/.local/bin to PATH in $rc"+}+if [ "$BIN_DIR" = "$HOME/.local/bin" ]; then+ path_block "$HOME/.profile"+ case "${SHELL:-/bin/bash}" in+ */zsh) path_block "$HOME/.zshrc" ;;+ *) path_block "$HOME/.bashrc" ;;+ esac+else+ warn "custom MSO_BIN_DIR=$BIN_DIR is not written into shell profiles; add it to PATH yourself"+fi++# Prove discoverability from the PARENT shell's original PATH. If the user-local+# directory was already there, nothing else is needed. Otherwise use a guarded+# launcher in /usr/local/bin (or MSO_SYSTEM_BIN_DIR) only when that directory is+# already on the invoking PATH. This also makes `--no-service` useful on WSL.+SYSTEM_BIN_DIR="${MSO_SYSTEM_BIN_DIR:-/usr/local/bin}"+SYSTEM_CLI="$SYSTEM_BIN_DIR/mso"+TARGET_CLI_REAL="$(readlink -f "$DIR/bin/mso")"+CLI_IMMEDIATE=0+parent_cli="$(PATH="$PARENT_PATH" command -v mso 2>/dev/null || true)"+if [ -n "$parent_cli" ] && [ "$(readlink -f "$parent_cli" 2>/dev/null || true)" = "$TARGET_CLI_REAL" ]; then+ CLI_IMMEDIATE=1+elif path_has_dir "$PARENT_PATH" "$SYSTEM_BIN_DIR"; then+ if link_cli_guarded "$SYSTEM_CLI" "$DIR/bin/mso"; then+ ok "current-PATH cli → $SYSTEM_CLI"+ parent_cli="$(PATH="$PARENT_PATH" command -v mso 2>/dev/null || true)"+ if [ -n "$parent_cli" ] && [ "$(readlink -f "$parent_cli" 2>/dev/null || true)" = "$TARGET_CLI_REAL" ]; then+ CLI_IMMEDIATE=1+ fi+ else+ warn "could not install $SYSTEM_CLI; the user CLI is still installed at $BIN_DIR/mso"+ fi+else+ info "$SYSTEM_BIN_DIR is not on the invoking PATH — skipped the extra launcher"+fi++# Validate the actual launcher independently of PATH. The child installer may use+# its own exported PATH for onboarding, but that is NOT treated as proof that the+# parent shell can see the command.+"$BIN_DIR/mso" -h >/dev/null 2>&1 || die "CLI launcher is not executable: $BIN_DIR/mso"+export PATH="$BIN_DIR:$PATH"+if [ "$CLI_IMMEDIATE" -eq 1 ]; then+ ok "mso -h will resolve immediately after the installer returns ($parent_cli)"+else+ warn "mso is installed, but this shell's existing PATH cannot see it yet"+ warn "for this shell run: export PATH=\"$BIN_DIR:\$PATH\""+ info "future shells will load the persisted ~/.local/bin PATH block"+fi+# ---- systemd unit -----if [ "$DO_SERVICE" -eq 1 ] && command -v systemctl >/dev/null 2>&1; then+if [ "$DO_SERVICE" -eq 1 ] && systemd_ready; then# Start via npm (always on PATH, ships with node) to match the proven prod unit;# PORT/HOSTNAME are set as env too so `next start` binds correctly regardless.NPM_BIN="$(command -v npm)"@@ -356,7 +478,7 @@ EOF# /api/health perfectly while serving stale chunks, which is exactly how# a failed update used to report "health OK".if [ -z "$prev_build" ] || [ "$now_build" != "$prev_build" ]; then- up=1; ok "health OK (build ${now_build:-unknown})"; break+ up=1; SERVICE_READY=1; ok "health OK (build ${now_build:-unknown})"; breakfifisleep 2@@ -369,68 +491,14 @@ EOFwarn "$SERVICE is not running — check: journalctl -u mso -e"fifi-else- [ "$DO_SERVICE" -eq 1 ] && warn "no systemctl here — skipping service. Run manually: PORT=$PORT bun run start"-fi--# ---- CLI on PATH -----# The web UI is one frontend; bin/mso reaches the same /api surface from a shell.-BIN_DIR="${MSO_BIN_DIR:-$HOME/.local/bin}"-mkdir -p "$BIN_DIR"-ln -sfn "$DIR/bin/mso" "$BIN_DIR/mso"-ok "cli → $BIN_DIR/mso"--# Make the command available to the PARENT shell immediately after curl|bash returns.-# A child installer cannot export PATH back into its parent. /usr/local/bin is already-# on the normal system PATH, so install a second launcher there when the name is free-# (or already ours). Never overwrite an unrelated system command.-if [ "$DO_SERVICE" -eq 1 ]; then- SYSTEM_CLI=/usr/local/bin/mso- if [ ! -e "$SYSTEM_CLI" ] && [ ! -L "$SYSTEM_CLI" ]; then- sudo_do ln -s "$DIR/bin/mso" "$SYSTEM_CLI"- ok "system cli → $SYSTEM_CLI"- elif [ -L "$SYSTEM_CLI" ]; then- current_cli="$(readlink "$SYSTEM_CLI")"- case "$current_cli" in- "$DIR/"*) sudo_do ln -sfn "$DIR/bin/mso" "$SYSTEM_CLI"; ok "system cli → $SYSTEM_CLI" ;;- *) warn "$SYSTEM_CLI already points elsewhere ($current_cli) — left untouched" ;;- esac+elif [ "$DO_SERVICE" -eq 1 ]; then+ if is_wsl; then+ warn "WSL detected without systemd as PID 1 — service install skipped; the mso CLI is still installed"+ info "for the full service: enable systemd in /etc/wsl.conf, run 'wsl --shutdown' from Windows, reopen WSL, then re-run this installer --onboard"else- warn "$SYSTEM_CLI already exists and is not a symlink — left untouched"+ warn "systemd is not available as PID 1 — service install skipped; run manually: PORT=$PORT bun run start"fi-else- info "--no-service: skipped /usr/local/bin launcher (user CLI still at $BIN_DIR/mso)"-fi--# A fresh distro often omits ~/.local/bin from PATH. Persist one small idempotent-# block for future shells, and export it now so onboarding can invoke `mso`.-path_block() {- local rc="$1"- [ -e "$rc" ] || : > "$rc"- grep -q '^# >>> mso cli >>>$' "$rc" 2>/dev/null && return- cat >> "$rc" <<'EOF'--# >>> mso cli >>>-case ":$PATH:" in- *":$HOME/.local/bin:"*) ;;- *) export PATH="$HOME/.local/bin:$PATH" ;;-esac-# <<< mso cli <<<-EOF- info "added ~/.local/bin to PATH in $rc"-}-if [ "$BIN_DIR" = "$HOME/.local/bin" ]; then- path_block "$HOME/.profile"- case "${SHELL:-}" in- */bash) path_block "$HOME/.bashrc" ;;- */zsh) path_block "$HOME/.zshrc" ;;- esac-else- warn "custom MSO_BIN_DIR=$BIN_DIR is not written into shell profiles; add it to PATH yourself"fi-export PATH="$BIN_DIR:$PATH"-command -v mso >/dev/null 2>&1 || die "CLI symlink exists but is not executable: $BIN_DIR/mso"-ok "mso command ready ($(command -v mso))"# ---- optional Claude Code integration ----# MSO catalogs $DIR/claude-skills directly, so these symlinks are NOT required by MSO.@@ -480,13 +548,43 @@ case "$BIND" insession cookie is Secure. Put TLS in front, or tunnel to loopback.)" ;;esac+if [ "$SERVICE_READY" -eq 1 ]; then+ OPEN_STATUS="$REACH"+ LOG_STATUS="journalctl -u mso -f"+elif [ "$DO_SERVICE" -eq 0 ]; then+ OPEN_STATUS="not running (--no-service). Start manually: cd $DIR && PORT=$PORT bun run start"+ LOG_STATUS="no system service installed"+elif is_wsl; then+ OPEN_STATUS="not running (WSL systemd is unavailable). Enable systemd or start manually from $DIR"+ LOG_STATUS="no system service installed"+else+ OPEN_STATUS="service did not pass health verification; inspect the service journal before opening the UI"+ LOG_STATUS="journalctl -u mso -e"+fi+ok "mso installed at $DIR"cat <<EOF- Open: $REACH+ Runtime: $OPEN_STATUSEnv: $DIR/.env.localEOF-[ -n "$GEN_PW" ] && printf ' Password: %s (shown once — save it now; edit OS_LOGIN_PASSWORD in .env.local + restart to change)\n' "$GEN_PW"+[ -n "$GEN_PW" ] && printf ' Password: %s (shown once — save it now; edit OS_LOGIN_PASSWORD in .env.local + service refresh to change)\n' "$GEN_PW"+cat <<EOF++ Pair your first device after the API is running (device approval is a browser allowlist, not standards-based 2FA):+ 1. Open the URL, enter the password — the browser lands PENDING and shows a device id.+ 2. On this server:+ node $DIR/scripts/approve-device.js --list # see the pending id+ node $DIR/scripts/approve-device.js <deviceId> "my phone" # approve it+ 3. Reload + log in. Approve later devices from Settings → Devices.++ Logs: $LOG_STATUS+ Update: re-run this installer (pull + verify + build + service refresh), or --uninstall to remove+ Listen: $BIND:$PORT (change with --bind / MSO_BIND)+ Security: verify from OUTSIDE the box — `curl -m5 http://<public-ip>:$PORT/api/health`+ run on your laptop is the only test that proves what is reachable.+ Review ~/.mso/audit.log.+EOF# A successful fresh install should lead directly into a usable product. curl|bash# owns stdin, so interactive setup uses the controlling terminal explicitly.@@ -496,7 +594,7 @@ case "$ONBOARD_MODE" innever) RUN_ONBOARD=0 ;;auto) [ "$FRESH_INSTALL" -eq 1 ] && RUN_ONBOARD=1 ;;esac-if [ "$RUN_ONBOARD" -eq 1 ] && [ "$DO_SERVICE" -eq 1 ]; then+if [ "$RUN_ONBOARD" -eq 1 ] && [ "$SERVICE_READY" -eq 1 ]; thenif [ "$YES" -eq 1 ]; thenechoinfo "running minimal non-interactive onboarding (-y)…"@@ -512,21 +610,5 @@ if [ "$RUN_ONBOARD" -eq 1 ] && [ "$DO_SERVICE" -eq 1 ]; thenwarn "no interactive terminal detected — onboarding skipped. Run: mso onboard"fielif [ "$RUN_ONBOARD" -eq 1 ]; then- warn "--no-service leaves no running API to configure — run 'mso onboard' after starting MSO"+ warn "no verified running MSO API is available for onboarding — start/enable the service, then run 'mso onboard'"fi-cat <<EOF-- Pair your first device (device approval is a browser allowlist, not standards-based 2FA):- 1. Open the URL, enter the password — the browser lands PENDING and shows a device id.- 2. On this server:- node $DIR/scripts/approve-device.js --list # see the pending id- node $DIR/scripts/approve-device.js <deviceId> "my phone" # approve it- 3. Reload + log in. Approve later devices from Settings → Devices.-- Logs: journalctl -u mso -f- Update: re-run this installer (pull + rebuild + restart), or --uninstall to remove- Listen: $BIND:$PORT (change with --bind / MSO_BIND)- Security: verify from OUTSIDE the box — \`curl -m5 http://<public-ip>:$PORT/api/health\`- run on your laptop is the only test that proves what is reachable.- Review ~/.mso/audit.log.-EOF