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(security): eliminate parser gaps and enforce strict SAST coverage
Rahmancb37ccf06556
diff --git a/.github/workflows/security-core.yml b/.github/workflows/security-core.ymlindex 158f90ee..9c3a987e 100644--- a/.github/workflows/security-core.yml+++ b/.github/workflows/security-core.yml@@ -106,7 +106,7 @@ jobs:semgrep/semgrep@sha256:f1f7b71861c7b28b6e0f661225a2c4f58a484f5d0f182465c6d6b3b22f972adesemgrep scan --metrics=off--config=p/javascript --config=p/typescript --config=p/owasp-top-ten- --error /src+ --strict --error /srcshellcheck:name: ShellCheckdiff --git a/app/api/v1/managed-apps/proxy-split-origin.test.ts b/app/api/v1/managed-apps/proxy-split-origin.test.tsindex c8a76073..cc692852 100644--- a/app/api/v1/managed-apps/proxy-split-origin.test.ts+++ b/app/api/v1/managed-apps/proxy-split-origin.test.ts@@ -1,3 +1,4 @@+type CatalogModule = typeof import("@/lib/managed-apps/catalog");// The proxy route in SPLIT-ORIGIN mode: the dashboard is root-mounted on its own// host (hermes.mso.example.com), which is what finally closes the window.top reach// — the frame is cross-origin now, so `allow-same-origin` no longer grants the@@ -13,7 +14,7 @@ vi.mock("@/lib/agent/server", () => ({ verifyAuth: vi.fn(async () => true) }));const dashboardUrl = { current: "http://127.0.0.1:9119" };vi.mock("@/lib/managed-apps/catalog", async () => {- const real = await vi.importActual<typeof import("@/lib/managed-apps/catalog")>(+ const real = await vi.importActual<CatalogModule>("@/lib/managed-apps/catalog",);return {diff --git a/app/api/v1/managed-apps/proxy.test.ts b/app/api/v1/managed-apps/proxy.test.tsindex 973648ec..05c22fb4 100644--- a/app/api/v1/managed-apps/proxy.test.ts+++ b/app/api/v1/managed-apps/proxy.test.ts@@ -1,3 +1,4 @@+type CatalogModule = typeof import("@/lib/managed-apps/catalog");// Integration tests for /api/v1/managed-apps/[id]/proxy/[[...path]] — the// reverse proxy in front of the loopback-only Hermes/OpenClaw dashboards.// Auth and the catalog are mocked, fetch is stubbed: we exercise ONLY the@@ -10,7 +11,7 @@ vi.mock("@/lib/agent/server", () => ({ verifyAuth: vi.fn(async () => true) }));const dashboardUrl = { current: "http://127.0.0.1:9119" };vi.mock("@/lib/managed-apps/catalog", async () => {- const real = await vi.importActual<typeof import("@/lib/managed-apps/catalog")>(+ const real = await vi.importActual<CatalogModule>("@/lib/managed-apps/catalog",);return {diff --git a/bin/mso-update-offline.test.ts b/bin/mso-update-offline.test.tsindex 96d54bcb..00c1d785 100644--- a/bin/mso-update-offline.test.ts+++ b/bin/mso-update-offline.test.ts@@ -34,11 +34,11 @@ function fixture() {"scripts/cli/runtime.sh","scripts/cli/service.sh","scripts/cli/transport.sh",- "scripts/cli/onboarding.sh",+ "scripts/cli/onboarding.sh", "scripts/cli/onboarding-ai.sh","scripts/cli/commands.sh","scripts/cli/commands-host.sh","scripts/cli/commands-runtime.sh",- "scripts/cli/commands-state.sh",+ "scripts/cli/commands-state.sh", "scripts/cli/config-command.sh","scripts/cli/commands-admin.sh","scripts/lib/private-state.sh","scripts/lib/update-state.sh",diff --git a/bin/mso.test.ts b/bin/mso.test.tsindex c2f56637..e33f8f82 100644--- a/bin/mso.test.ts+++ b/bin/mso.test.ts@@ -13,6 +13,7 @@ const commandOwnerFiles = ["scripts/cli/commands-host.sh","scripts/cli/commands-runtime.sh","scripts/cli/commands-state.sh",+ "scripts/cli/config-command.sh","scripts/cli/commands-admin.sh",];const commandOwners = () => {diff --git a/claude-skills/mso-image-editor/image-editor.sh b/claude-skills/mso-image-editor/image-editor.shindex d8136eb3..4f75004b 100755--- a/claude-skills/mso-image-editor/image-editor.sh+++ b/claude-skills/mso-image-editor/image-editor.sh@@ -148,7 +148,10 @@ case "$cmd" inview)p="${1:?path}"; shift || truebase="${OS_PUBLIC_BASE:-${OS_PUBLIC_ORIGIN:-http://127.0.0.1:4005}}"- case "$p" in /*) ;; *) p="/$p" ;; esac+ case "$p" in+ /*) ;;+ *) p="/$p" ;;+ esacurl="$base/studio$p"; echo "$url"if [ "${1:-}" = "--shot" ]; then# The os-browser sidecar that backed this was deleted 2026-08-10 (its unitdiff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex cef22ae3..b0557265 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**+- `security` eliminate parser gaps and enforce strict SAST coverage- `gateway` wait for launcher handoff before tracking tunnel identity- `build` separate runtime inputs and clarify mobile MCP guides- `a11y` label settings controls and expose selected optionsdiff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex eb6a484c..9fa8e6ce 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -1,3 +1,7 @@+## 2026-09-09 — Complete Semgrep parser coverage++The remaining forty parser diagnostics are resolved through explicit multiline Bash case arms, quoted parameter-error words, parser-compatible arithmetic and non-truncating append-open lock descriptors. Permission masks retain octal interpretation through validated conversion; process stat parsing retains its last-closing-parenthesis boundary. TypeScript import types are named aliases, JSX ampersands are entities and embedded-script regexes use equivalent escaped less-than literals. Two CLI responsibilities move into focused sourced modules with fixture inventories updated. No Semgrep rules or source files are excluded; both CI and the full security entrypoint now use `--strict --error` so parser diagnostics block completion. This supersedes the earlier documented scanner limitation.+## 2026-09-09 — Gateway release handshake under CI schedulingThe final GitHub run exposed a remaining startup race: the held child already carries target argv, so command matching could acknowledge it before it consumed its release gate. Matching now refuses that exact launcher. Quick URL discovery pins the spawned PID/start ticks while wrappers exec; final readiness still requires exact executable/argv before state commits. The concurrent-start regression delays URL publication after interpreter exec, while checking one tracked live tunnel and successful cleanup. No timeouts, skips or identity checks were weakened to obtain a pass.diff --git a/frontend/slices/assistant/components/mcp-activity-view.tsx b/frontend/slices/assistant/components/mcp-activity-view.tsxindex 56e2ce22..b95b106c 100644--- a/frontend/slices/assistant/components/mcp-activity-view.tsx+++ b/frontend/slices/assistant/components/mcp-activity-view.tsx@@ -124,7 +124,7 @@ export function McpActivityView() {<div className="flex shrink-0 items-center gap-2 border-b border-border px-3 py-2"><Activity className="size-4" /><div className="min-w-0 flex-1">- <p className="text-xs font-semibold">Activity & Runs</p>+ <p className="text-xs font-semibold">Activity & Runs</p><p className="text-[10px] text-muted-foreground">{running ? `${running} run${running === 1 ? "" : "s"} active now` : "Alfa tool calls plus MSO workflows, grouped by task"}</p>diff --git a/frontend/slices/code-editor/lib/build-preview.ts b/frontend/slices/code-editor/lib/build-preview.tsindex b8e0037d..1f5a5678 100644--- a/frontend/slices/code-editor/lib/build-preview.ts+++ b/frontend/slices/code-editor/lib/build-preview.ts@@ -54,7 +54,7 @@ function importMap(code: string, jsx: boolean): string {// Safe-embed source as a JS string literal inside a <script>: JSON-encode, then// neutralise any "</script" / "<!--" the HTML parser would otherwise act on.function jsLiteral(code: string): string {- return JSON.stringify(code).replace(/<\/(script)/gi, "<\\/$1").replace(/<!--/g, "<\\!--");+ return JSON.stringify(code).replace(/\x3c\/(script)/gi, "<\\/$1").replace(/\x3c!--/g, "<\\!--");}const SHELL_CSS =diff --git a/frontend/slices/os-settings/components/a2a-peer-settings.tsx b/frontend/slices/os-settings/components/a2a-peer-settings.tsxindex 49876147..33c4d853 100644--- a/frontend/slices/os-settings/components/a2a-peer-settings.tsx+++ b/frontend/slices/os-settings/components/a2a-peer-settings.tsx@@ -193,7 +193,7 @@ export function A2APeerSettings({className="[@media(pointer:coarse)]:min-h-[44px]"onClick={() => void createCredential()}>- Save & activate+ Save & activate</Button></SettingsBlock>)}diff --git a/frontend/slices/os-settings/components/mcp-token-section.tsx b/frontend/slices/os-settings/components/mcp-token-section.tsxindex a73ff92d..20ec4353 100644--- a/frontend/slices/os-settings/components/mcp-token-section.tsx+++ b/frontend/slices/os-settings/components/mcp-token-section.tsx@@ -50,7 +50,7 @@ export function McpTokenSection({ tokens, onChanged, onConnect }: { tokens: McpT<details><summary className="cursor-pointer py-2 text-sm text-muted-foreground">Client details</summary><p className="break-all font-mono text-xs">{token.clientId}</p></details></SettingsBlock>)}<div className="flex flex-wrap gap-2">- {tokens.length > active.length && <Button variant="ghost" aria-pressed={showInactive} onClick={() => setShowInactive(value => !value)} className="min-h-11">{showInactive ? "Hide" : "Show"} expired & disconnected</Button>}+ {tokens.length > active.length && <Button variant="ghost" aria-pressed={showInactive} onClick={() => setShowInactive(value => !value)} className="min-h-11">{showInactive ? "Hide" : "Show"} expired & disconnected</Button>}{active.length > 1 && <Button variant="ghost" disabled={busy} onClick={() => setPending({ id: "all", label: `all ${active.length} active connections` })} className="min-h-11 text-destructive">Disconnect all</Button>}</div></SettingsSection>;diff --git a/lib/infra/connection-dispatch-public-env.test.ts b/lib/infra/connection-dispatch-public-env.test.tsindex ca61eee7..32f84b11 100644--- a/lib/infra/connection-dispatch-public-env.test.ts+++ b/lib/infra/connection-dispatch-public-env.test.ts@@ -1,10 +1,12 @@+type ConnectionServiceModule = typeof import("./connection-service");+type ClientsModule = typeof import("./clients");import { expect, it, vi } from "vitest";vi.mock("./clients", async (importOriginal) => {- const actual = await importOriginal<typeof import("./clients")>();+ const actual = await importOriginal<ClientsModule>();return { ...actual, upsertDokployPublicBuildEnv: vi.fn(async (args) => ({ ...args, changed: true, redeployQueued: true })) };});vi.mock("./connection-service", async (importOriginal) => {- const actual = await importOriginal<typeof import("./connection-service")>();+ const actual = await importOriginal<ConnectionServiceModule>();return {...actual,resolveIntegration: vi.fn(async () => ({ user:"alice",id:"default",source:"direct",authMethod:"direct",provider:"dokploy" })),diff --git a/lib/mcp/dispatch-authorization.test.ts b/lib/mcp/dispatch-authorization.test.tsindex 42e7a751..56333b96 100644--- a/lib/mcp/dispatch-authorization.test.ts+++ b/lib/mcp/dispatch-authorization.test.ts@@ -1,3 +1,4 @@+type AuditApiModule = typeof import("@/lib/host/audit-api");import { beforeEach, describe, expect, it, vi } from "vitest";// The catalog reaches lib/camoufox + lib/managed-apps, which are `server-only`.// Next aliases that specifier internally; vitest does not, so stub it — same@@ -11,7 +12,7 @@ vi.mock("@/lib/a2a/local-session", () => localSessionMock);// each tool, is what records.const audited: { action: string; actor?: string; target?: string; ok?: boolean }[] = [];vi.mock("@/lib/host/audit-api", async (orig) => {- const real = await orig<typeof import("@/lib/host/audit-api")>();+ const real = await orig<AuditApiModule>();return { ...real, audit: (e: { action: string }) => { audited.push(e); return Promise.resolve(); } };});diff --git a/lib/mcp/dispatch.test.ts b/lib/mcp/dispatch.test.tsindex 7f7e5919..e03bea48 100644--- a/lib/mcp/dispatch.test.ts+++ b/lib/mcp/dispatch.test.ts@@ -1,3 +1,4 @@+type AuditApiModule = typeof import("@/lib/host/audit-api");import { describe, expect, it, vi } from "vitest";// The catalog reaches lib/camoufox + lib/managed-apps, which are `server-only`.// Next aliases that specifier internally; vitest does not, so stub it — same@@ -11,7 +12,7 @@ vi.mock("@/lib/a2a/local-session", () => localSessionMock);// each tool, is what records.const audited: { action: string; actor?: string; target?: string; ok?: boolean }[] = [];vi.mock("@/lib/host/audit-api", async (orig) => {- const real = await orig<typeof import("@/lib/host/audit-api")>();+ const real = await orig<AuditApiModule>();return { ...real, audit: (e: { action: string }) => { audited.push(e); return Promise.resolve(); } };});diff --git a/lib/mcp/openai-file-upload.test.ts b/lib/mcp/openai-file-upload.test.tsindex cdd6fdfc..8299bc50 100644--- a/lib/mcp/openai-file-upload.test.ts+++ b/lib/mcp/openai-file-upload.test.ts@@ -1,9 +1,10 @@+type FsApiModule = typeof import("@/lib/host/fs-api");import { beforeEach, describe, expect, it, vi } from "vitest";vi.mock("server-only", () => ({}));const uploadInto = vi.fn(async () => ({ written: 1, failed: [] as string[] }));vi.mock("@/lib/host/fs-api", async (orig) => {- const real = await orig<typeof import("@/lib/host/fs-api")>();+ const real = await orig<FsApiModule>();return { ...real, uploadInto };});diff --git a/lib/onboard-contract.test.ts b/lib/onboard-contract.test.tsindex 14e164aa..00ddaccc 100644--- a/lib/onboard-contract.test.ts+++ b/lib/onboard-contract.test.ts@@ -9,6 +9,7 @@ const appVersion: string = JSON.parse(fs.readFileSync(path.join(__dirname, "../pconst cli = [fs.readFileSync(path.join(__dirname, "../bin/mso"), "utf8"),fs.readFileSync(path.join(__dirname, "../scripts/cli/onboarding.sh"), "utf8"),+ fs.readFileSync(path.join(__dirname, "../scripts/cli/onboarding-ai.sh"), "utf8"),fs.readFileSync(path.join(__dirname, "../scripts/cli/transport.sh"), "utf8"),].join("\n");diff --git a/lib/security/private-shell-state.test.ts b/lib/security/private-shell-state.test.tsindex 8dbfbf97..6794e332 100644--- a/lib/security/private-shell-state.test.ts+++ b/lib/security/private-shell-state.test.ts@@ -8,9 +8,9 @@ const ROOT = path.join(__dirname, "../..");const HELPER = path.join(ROOT, "scripts/lib/private-state.sh");const CLI = path.join(ROOT, "bin/mso");const CLI_MODULES = [- "scripts/cli/runtime.sh", "scripts/cli/service.sh", "scripts/cli/transport.sh", "scripts/cli/onboarding.sh",+ "scripts/cli/runtime.sh", "scripts/cli/service.sh", "scripts/cli/transport.sh", "scripts/cli/onboarding.sh", "scripts/cli/onboarding-ai.sh","scripts/cli/commands.sh", "scripts/cli/commands-host.sh", "scripts/cli/commands-runtime.sh",- "scripts/cli/commands-state.sh", "scripts/cli/commands-admin.sh",+ "scripts/cli/commands-state.sh", "scripts/cli/config-command.sh", "scripts/cli/commands-admin.sh",].map((rel) => path.join(ROOT, rel));const EDITOR = path.join(ROOT, "claude-skills/mso-image-editor/image-editor.sh");const ULTIMATE = path.join(ROOT, "scripts/security-ultimate.sh");diff --git a/package.json b/package.jsonindex 75757216..6ab57da3 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "mso",- "version": "0.2.6",+ "version": "0.2.7","private": true,"engines": {"node": ">=20.9",diff --git a/scripts/cli/commands-admin.sh b/scripts/cli/commands-admin.shindex c0c165d7..36b4c3d5 100755--- a/scripts/cli/commands-admin.sh+++ b/scripts/cli/commands-admin.sh@@ -28,7 +28,7 @@ case "$cmd" indev_script --revoke "$1" ;;# ── provider OAuth (device-code, NOT a browser redirect) ─────────────────oauth)- p="${1:?provider (e.g. openai)}"; sub="${2:-start}"+ p="${1:?"provider (e.g. openai)"}"; sub="${2:-start}"case "$sub" instart|poll) jpost "/api/oauth/$(enc "$p")" "$(jq -n --arg a "$sub" '{action:$a}')" ;;*) die "usage: mso $U_oauth" ;;diff --git a/scripts/cli/commands-host.sh b/scripts/cli/commands-host.shindex be6840f5..2c922d73 100755--- a/scripts/cli/commands-host.sh+++ b/scripts/cli/commands-host.sh@@ -17,7 +17,7 @@ case "$cmd" inraw) reqraw "$B/api/v1/fs/raw?path=$(enc "${1:?path}")"; exit 0 ;;share) reqraw "$B/api/v1/temp-share/$(enc "${1:?temporary link id}")?download=1"; exit 0 ;;usage) jget "/api/v1/fs/usage?path=$(enc "${1:-~}")" ;;- search) jget "/api/v1/fs/search?q=$(enc "${1:?query}")${2:+&root=$(enc "$2")}" ;;+ search) jget "/api/v1/fs/search?q=$(enc "${1:?query}")${2:+"&root=$(enc "$2")"}" ;;write) jpost "/api/v1/fs/write" "$(jq -n --arg p "${1:?path}" --arg c "${2-}" '{path:$p,content:$c}')" ;;mkdir) jpost "/api/v1/fs/mkdir" "$(jq -n --arg p "${1:?path}" '{path:$p}')" ;;rm) jdel "/api/v1/fs/delete" "$(jq -n --arg p "${1:?path}" '{path:$p}')" ;;@@ -163,7 +163,7 @@ case "$cmd" inecho "It never changes DNS, TLS certificates, firewall rules, public exposure, or credentials."fi[ "$fails" -eq 0 ] && echo "all good." || echo "$fails check(s) failed."- exit $(( fails > 0 ? 1 : 0 )) ;;+ if [ "$fails" -gt 0 ]; then exit 1; else exit 0; fi ;;*) die "internal CLI routing error: $cmd reached the wrong command family" ;;esac}diff --git a/scripts/cli/commands-state.sh b/scripts/cli/commands-state.shindex a0e86c4b..f1a0b1d3 100755--- a/scripts/cli/commands-state.sh+++ b/scripts/cli/commands-state.sh@@ -1,4 +1,6 @@#!/usr/bin/env bash+# shellcheck source=config-command.sh+source "$ROOT/scripts/cli/config-command.sh"# Assistant, sessions, A2A, memory/config/skills state commands.# Usage variables are defined by scripts/cli/commands.sh before this sourced handler runs.# shellcheck disable=SC2154@@ -110,7 +112,10 @@ case "$cmd" inelse jget "/api/v1/a2a?action=credentials"; fi ;;add)target="${1:?target}"; label="${2:-default}"; kind="${3:-bearer}"- case "$kind" in bearer|api-key|oauth2) ;; *) die "credential kind must be bearer, api-key, or oauth2" ;; esac+ case "$kind" in+ bearer|api-key|oauth2) ;;+ *) die "credential kind must be bearer, api-key, or oauth2" ;;+ esacagent_id="$(a2a_agent_id "$target")"; header_name=""; scheme_name=""schemes="$(a2a_agent_schemes "$agent_id")"; scheme_count="$(printf '%s\n' "$schemes" | sed '/^$/d' | wc -l | tr -d ' ')"if [ "$scheme_count" -eq 1 ]; then scheme_name="$(printf '%s\n' "$schemes" | sed '/^$/d' | head -1)";@@ -155,7 +160,10 @@ case "$cmd" incase "$in_sub" inlist) jget "/api/v1/a2a?action=credentials" ;;create|add)- label="${1:-peer}"; scope="${2:-read}"; case "$scope" in read|write|exec) ;; *) die "scope must be read, write, or exec" ;; esac+ label="${1:-peer}"; scope="${2:-read}"; case "$scope" in+ read|write|exec) ;;+ *) die "scope must be read, write, or exec" ;;+ esacjpost "/api/v1/a2a" "$(jq -n --arg label "$label" --arg scope "$scope" '{action:"inbound-token-create",label:$label,scope:$scope}')" ;;rm|remove) jpost "/api/v1/a2a" "$(jq -n --arg tokenId "${1:?tokenId}" '{action:"inbound-token-remove",tokenId:$tokenId}')" ;;*) die "usage: mso $U_a2a" ;;@@ -169,23 +177,7 @@ case "$cmd" inrm) jdel "/api/memory?id=$(enc "${2:?id}")" ;;*) die "usage: mso $U_memory" ;;esac ;;- config)- case "${1:-show}" in- show) jget "/api/config" ;;- set) jpost "/api/config" "$(json_arg "${2:?json, e.g. '{\"model\":\"gpt-5.6\"}'}")" ;;- key) provider="${2:?provider}"- case "$provider" in anthropic|openai|openrouter|google|groq|xai|deepseek|mistral) ;;- *) die "API-key provider must be one of: anthropic openai openrouter google groq xai deepseek mistral" ;; esac- tty_secret "Paste $provider API key: "; key="$REPLY"- [ -n "$key" ] || die "empty API key"- body=$(printf '%s\0%s' "$provider" "$key" | provider_key_body)- secret_post "/api/config" "$body"; unset key body REPLY ;;- style) style="${2:?off|caveman|ponytail}"- case "$style" in off|caveman|ponytail) ;; *) die "style must be off, caveman or ponytail" ;; esac- jpost "/api/config" "$(jq -nc --arg v "$style" '{tokenSaver:$v}')" ;;- rm) jdel "/api/config?provider=$(enc "${2:?provider}")" ;;- *) die "usage: mso $U_config" ;;- esac ;;+ config) mso_config_command "$U_config" "$@" ;;prefs)case "${1:-show}" inshow) jget "/api/prefs" ;;diff --git a/scripts/cli/commands.sh b/scripts/cli/commands.shindex 711cead4..2787d568 100755--- a/scripts/cli/commands.sh+++ b/scripts/cli/commands.sh@@ -63,7 +63,9 @@ mso_cli_unknown() {echo "mso: unknown command '$cmd'" >&2head3="${cmd:0:3}"near=$(verbs | while read -r v; do- case "$v" in "$cmd"*|*"$cmd"*|"$head3"*) echo " $v" ;; esac+ case "$v" in+ "$cmd"*|*"$cmd"*|"$head3"*) echo " $v" ;;+ esacdone)[ -n "$near" ] && { echo "did you mean:" >&2; echo "$near" >&2; }echo >&2; usage >&2; exit 1diff --git a/scripts/cli/config-command.sh b/scripts/cli/config-command.shnew file mode 100644index 00000000..1d64bfcd--- /dev/null+++ b/scripts/cli/config-command.sh@@ -0,0 +1,26 @@+#!/usr/bin/env bash+# Settings mutation commands share the existing secret-safe transport.+mso_config_command() {+ local config_usage="$1"; shift+ case "${1:-show}" in+ show) jget "/api/config" ;;+ set) jpost "/api/config" "$(json_arg "${2:?json, e.g. '{\"model\":\"gpt-5.6\"}'}")" ;;+ key) provider="${2:?provider}"+ case "$provider" in+ anthropic|openai|openrouter|google|groq|xai|deepseek|mistral) ;;+ *) die "API-key provider must be one of: anthropic openai openrouter google groq xai deepseek mistral" ;;+ esac+ tty_secret "Paste $provider API key: "; key="$REPLY"+ [ -n "$key" ] || die "empty API key"+ body=$(printf '%s\0%s' "$provider" "$key" | provider_key_body)+ secret_post "/api/config" "$body"; unset key body REPLY ;;+ style) style="${2:?"off|caveman|ponytail"}"+ case "$style" in+ off|caveman|ponytail) ;;+ *) die "style must be off, caveman or ponytail" ;;+ esac+ jpost "/api/config" "$(jq -nc --arg v "$style" '{tokenSaver:$v}')" ;;+ rm) jdel "/api/config?provider=$(enc "${2:?provider}")" ;;+ *) die "usage: mso $config_usage" ;;+ esac+}diff --git a/scripts/cli/onboarding-ai.sh b/scripts/cli/onboarding-ai.shnew file mode 100644index 00000000..d4d705da--- /dev/null+++ b/scripts/cli/onboarding-ai.sh@@ -0,0 +1,63 @@+#!/usr/bin/env bash+# Guided AI provider setup, using the shared private TTY/transport helpers.+onboard_ai() {+ local yes="$1" choice provider key body response interval code url poll+ if [ "$yes" = 1 ]; then+ echo " -- AI provider skipped (-y keeps external accounts unconfigured)"+ return+ fi+ echo+ echo "AI for Alfa"+ echo " 0) Skip for now"+ echo " 1) OpenAI ChatGPT OAuth (Codex consumer backend; no API key)"+ echo " 2) Anthropic API key"+ echo " 3) OpenAI Platform API key"+ echo " 4) OpenRouter API key"+ echo " 5) Google Gemini API key"+ echo " 6) Groq API key"+ echo " 7) xAI API key"+ echo " 8) DeepSeek API key"+ echo " 9) Mistral API key"+ tty_line "Choose [0]: " 0; choice="$REPLY"+ case "$choice" in+ 0|'') echo " -- skipped"; return ;;+ 1)+ response=$(jpost "/api/oauth/openai" '{"action":"start"}')+ code=$(jq -r '.userCode // empty' <<<"$response")+ url=$(jq -r '.verificationUrl // empty' <<<"$response")+ interval=$(jq -r '.intervalMs // 5000' <<<"$response")+ [ -n "$code" ] && [ -n "$url" ] || die "OpenAI OAuth did not return a device code"+ echo+ echo "Open this URL in any browser: $url"+ echo "Enter code: $code"+ echo "Waiting for authorization (Ctrl-C cancels this local wait; it does not expose the code)..."+ while true; do+ poll_seconds=$((interval / 1000))+ [ "$poll_seconds" -gt 2 ] || poll_seconds=3+ sleep "$poll_seconds"+ poll=$(jpost "/api/oauth/openai" '{"action":"poll"}')+ if [ "$(jq -r '.ok // false' <<<"$poll")" = true ]; then+ echo " ✓ OpenAI connected as $(jq -r '.slug' <<<"$poll")"+ return+ fi+ [ "$(jq -r '.pending // false' <<<"$poll")" = true ] || die "OpenAI OAuth failed: $poll"+ tty_print "."+ done ;;+ 2) provider=anthropic ;;+ 3) provider=openai ;;+ 4) provider=openrouter ;;+ 5) provider=google ;;+ 6) provider=groq ;;+ 7) provider=xai ;;+ 8) provider=deepseek ;;+ 9) provider=mistral ;;+ *) echo " ! unknown choice; skipped"; return ;;+ esac+ echo " $provider uses an API key here (not OAuth). The key is never placed in argv."+ tty_secret "Paste $provider API key: "; key="$REPLY"+ [ -n "$key" ] || { echo " -- empty key; skipped"; return; }+ body=$(printf '%s\0%s' "$provider" "$key" | provider_key_body)+ secret_post "/api/config" "$body" >/dev/null+ unset key body REPLY+ echo " ✓ $provider configured for Alfa"+}diff --git a/scripts/cli/onboarding.sh b/scripts/cli/onboarding.shindex 1dd6cbd6..a46ccec2 100755--- a/scripts/cli/onboarding.sh+++ b/scripts/cli/onboarding.sh@@ -1,5 +1,7 @@#!/usr/bin/env bash# TTY and guided onboarding helpers. Sourced by scripts/cli/runtime.sh.+# shellcheck source=onboarding-ai.sh+source "$ROOT/scripts/cli/onboarding-ai.sh"tty_ok() { [ -r /dev/tty ] && [ -w /dev/tty ]; }tty_print() { if tty_ok; then printf '%s' "$*" > /dev/tty; else printf '%s' "$*"; fi; }tty_line() {@@ -43,66 +45,6 @@ ensure_onboard_runtime() {esac}-onboard_ai() {- local yes="$1" choice provider key body response interval code url poll- if [ "$yes" = 1 ]; then- echo " -- AI provider skipped (-y keeps external accounts unconfigured)"- return- fi- echo- echo "AI for Alfa"- echo " 0) Skip for now"- echo " 1) OpenAI ChatGPT OAuth (Codex consumer backend; no API key)"- echo " 2) Anthropic API key"- echo " 3) OpenAI Platform API key"- echo " 4) OpenRouter API key"- echo " 5) Google Gemini API key"- echo " 6) Groq API key"- echo " 7) xAI API key"- echo " 8) DeepSeek API key"- echo " 9) Mistral API key"- tty_line "Choose [0]: " 0; choice="$REPLY"- case "$choice" in- 0|'') echo " -- skipped"; return ;;- 1)- response=$(jpost "/api/oauth/openai" '{"action":"start"}')- code=$(jq -r '.userCode // empty' <<<"$response")- url=$(jq -r '.verificationUrl // empty' <<<"$response")- interval=$(jq -r '.intervalMs // 5000' <<<"$response")- [ -n "$code" ] && [ -n "$url" ] || die "OpenAI OAuth did not return a device code"- echo- echo "Open this URL in any browser: $url"- echo "Enter code: $code"- echo "Waiting for authorization (Ctrl-C cancels this local wait; it does not expose the code)..."- while true; do- sleep "$(( interval / 1000 > 2 ? interval / 1000 : 3 ))"- poll=$(jpost "/api/oauth/openai" '{"action":"poll"}')- if [ "$(jq -r '.ok // false' <<<"$poll")" = true ]; then- echo " ✓ OpenAI connected as $(jq -r '.slug' <<<"$poll")"- return- fi- [ "$(jq -r '.pending // false' <<<"$poll")" = true ] || die "OpenAI OAuth failed: $poll"- tty_print "."- done ;;- 2) provider=anthropic ;;- 3) provider=openai ;;- 4) provider=openrouter ;;- 5) provider=google ;;- 6) provider=groq ;;- 7) provider=xai ;;- 8) provider=deepseek ;;- 9) provider=mistral ;;- *) echo " ! unknown choice; skipped"; return ;;- esac- echo " $provider uses an API key here (not OAuth). The key is never placed in argv."- tty_secret "Paste $provider API key: "; key="$REPLY"- [ -n "$key" ] || { echo " -- empty key; skipped"; return; }- body=$(printf '%s\0%s' "$provider" "$key" | provider_key_body)- secret_post "/api/config" "$body" >/dev/null- unset key body REPLY- echo " ✓ $provider configured for Alfa"-}-onboard_style() {local yes="$1" choice styleif [ "$yes" = 1 ]; then@@ -115,7 +57,11 @@ onboard_style() {echo " 1) Caveman — terse fragments, preserve technical substance"echo " 2) Ponytail — minimal senior-dev solution, avoid unnecessary code"tty_line "Choose [0]: " 0; choice="$REPLY"- case "$choice" in 1) style=caveman ;; 2) style=ponytail ;; *) style=off ;; esac+ case "$choice" in+ 1) style=caveman ;;+ 2) style=ponytail ;;+ *) style=off ;;+ esacfijpost "/api/config" "$(jq -nc --arg v "$style" '{tokenSaver:$v}')" >/dev/nullecho " ✓ Alfa response preset: $style"@@ -152,7 +98,12 @@ onboard_apps() {echo " 2) OpenClaw"echo " 3) Both"tty_line "Choose [0]: " 0; choice="$REPLY"- case "$choice" in 1) apps="hermes" ;; 2) apps="openclaw" ;; 3) apps="hermes openclaw" ;; *) return ;; esac+ case "$choice" in+ 1) apps="hermes" ;;+ 2) apps="openclaw" ;;+ 3) apps="hermes openclaw" ;;+ *) return ;;+ esacfor app in $apps; doif jget "/api/v1/managed-apps" | jq -e --arg id "$app" '.apps[] | select(.id==$id and .installed==true)' >/dev/null; thenecho " ✓ $app already installed"@@ -186,7 +137,11 @@ onboard_skills() {run_onboard() {local yes=0- case "${1-}" in -y|--yes) yes=1 ;; "") ;; *) die "usage: mso onboard [-y|--yes]" ;; esac+ case "${1-}" in+ -y|--yes) yes=1 ;;+ "") ;;+ *) die "usage: mso onboard [-y|--yes]" ;;+ esacecho "MSO onboarding"echo "=============="ensure_local_cli_devicediff --git a/scripts/cli/service.sh b/scripts/cli/service.shindex c8301a37..30e2634a 100755--- a/scripts/cli/service.sh+++ b/scripts/cli/service.sh@@ -21,7 +21,9 @@ gateway_local_url() {maybe_update_notice() {local verb="$1"[ -t 2 ] || return 0- case "$verb" in update|version|--version|-V|-v|help|-h|--help|completion) return 0 ;; esac+ case "$verb" in+ update|version|--version|-V|-v|help|-h|--help|completion) return 0 ;;+ esac[ -x "$ROOT/scripts/mso-update" ] || return 0MSO_UPDATE_ROOT="$ROOT" "$ROOT/scripts/mso-update" notice || true}diff --git a/scripts/cli/transport.sh b/scripts/cli/transport.shindex 2860a6a0..b6272f24 100755--- a/scripts/cli/transport.sh+++ b/scripts/cli/transport.sh@@ -75,7 +75,10 @@ req() {out=$(curl -sS -b "$JAR" "${ORIGIN[@]}" -w $'\n%{http_code}' "$@" || true)code="${out##*$'\n'}"; body="${out%$'\n'*}"fi- case "$code" in 2*) printf '%s' "$body" ;; *) die "request failed ($code): $body" ;; esac+ case "$code" in+ 2*) printf '%s' "$body" ;;+ *) die "request failed ($code): $body" ;;+ esac}# Binary-safe variant: streams straight to stdout, no capture, no code check.reqraw() {@@ -106,7 +109,10 @@ secret_post() {out=$(printf '%s' "$body" | curl -sS -b "$JAR" "${ORIGIN[@]}" -w $'\n%{http_code}' \-H 'content-type: application/json' -d @- "$B$route" || true)code="${out##*$'\n'}"; payload="${out%$'\n'*}"- case "$code" in 2*) printf '%s' "$payload" ;; *) die "request failed ($code): $payload" ;; esac+ case "$code" in+ 2*) printf '%s' "$payload" ;;+ *) die "request failed ($code): $payload" ;;+ esac}# Build an outbound A2A credential JSON body while keeping the secret off process argv.diff --git a/scripts/install-core.sh b/scripts/install-core.shindex d4cc78a8..1925a194 100755--- a/scripts/install-core.sh+++ b/scripts/install-core.sh@@ -53,7 +53,7 @@ BUN_BOOTSTRAP_SHA256="bab8acfb046aac8c72407bdcce903957665d655d7acaa3e11c7c4616beif [ -t 1 ] && [ -z "${NO_COLOR:-}" ]; thenC_OK=$'\033[32m'; C_WARN=$'\033[33m'; C_ERR=$'\033[31m'; C_DIM=$'\033[2m'; C_RST=$'\033[0m'else- C_OK=; C_WARN=; C_ERR=; C_DIM=; C_RST=+ C_OK=''; C_WARN=''; C_ERR=''; C_DIM=''; C_RST=''fiinfo() { printf '%s·%s %s\n' "$C_DIM" "$C_RST" "$*"; }ok() { printf '%s✓%s %s\n' "$C_OK" "$C_RST" "$*"; }@@ -122,7 +122,10 @@ systemd_ready() {}path_has_dir() {- case ":$1:" in *":$2:"*) return 0 ;; *) return 1 ;; esac+ case ":$1:" in+ *":$2:"*) return 0 ;;+ *) return 1 ;;+ esac}# PATH entries are resolved by the caller relative to the caller's cwd. The@@ -198,11 +201,17 @@ if [ "$DO_UNINSTALL" -eq 1 ]; then# against $DIR first, so a hand-made `mso` on PATH or a third-party skill of# the same name is never touched.UNINST_BIN="${MSO_BIN_DIR:-$HOME/.local/bin}/mso"- if [ -L "$UNINST_BIN" ] && case "$(readlink "$UNINST_BIN")" in "$DIR/"*) true ;; *) false ;; esac; then+ if [ -L "$UNINST_BIN" ] && case "$(readlink "$UNINST_BIN")" in+ "$DIR/"*) true ;;+ *) false ;;+ esac; thenrm -f "$UNINST_BIN"; ok "removed cli symlink $UNINST_BIN"fiUNINST_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 [ -L "$UNINST_SYSTEM_CLI" ] && case "$(readlink "$UNINST_SYSTEM_CLI")" in+ "$DIR/"*) true ;;+ *) false ;;+ esac; thenif [ -w "$(dirname "$UNINST_SYSTEM_CLI")" ]; then rm -f "$UNINST_SYSTEM_CLI"else sudo_do rm -f "$UNINST_SYSTEM_CLI"; fiok "removed cli symlink $UNINST_SYSTEM_CLI"@@ -211,7 +220,9 @@ if [ "$DO_UNINSTALL" -eq 1 ]; thenif [ -d "$UNINST_SKILLS" ]; thenfor l in "$UNINST_SKILLS"/*; do[ -L "$l" ] || continue- case "$(readlink "$l")" in "$DIR/claude-skills/"*) rm -f "$l"; info "removed skill $(basename "$l")" ;; esac+ case "$(readlink "$l")" in+ "$DIR/claude-skills/"*) rm -f "$l"; info "removed skill $(basename "$l")" ;;+ esacdonefi@@ -319,7 +330,10 @@ INSTALL_EARLY_UPDATE_CANONICAL_ROOT=''install_private_state_dir() {local requested="${1:-}" created=0 canonical owner mode old_umask[ -n "$requested" ] || die "empty installer private-state directory"- case "$requested" in /*) ;; *) die "installer private-state directory must be absolute: $requested" ;; esac+ case "$requested" in+ /*) ;;+ *) die "installer private-state directory must be absolute: $requested" ;;+ esac[ ! -L "$requested" ] || die "refusing symlink installer private-state directory: $requested"if [ ! -e "$requested" ]; then old_umask=$(umask); umask 077; mkdir -p -- "$requested"; umask "$old_umask"; created=1; fi[ -d "$requested" ] && [ ! -L "$requested" ] || die "not a real installer private-state directory: $requested"@@ -364,7 +378,7 @@ install_early_update_lock_acquire() {base="$(install_private_state_dir "${MSO_UPDATE_STATE_DIR:-$HOME/.mso/private/update-state}")"key="$(printf '%s' "$canonical" | sha256sum | awk '{print $1}')"; [[ "$key" =~ ^[0-9a-f]{64}$ ]] || die "cannot derive installer update-lock scope"state="$(install_private_state_dir "$base/$key")"; lock="$(install_private_state_ensure_file "$state/transaction.lock")"- exec {INSTALL_EARLY_UPDATE_LOCK_FD}<>"$lock" || die "cannot open installer update transaction lock"+ exec {INSTALL_EARLY_UPDATE_LOCK_FD}>>"$lock" || die "cannot open installer update transaction lock"timeout="${MSO_UPDATE_LOCK_TIMEOUT_SECONDS:-900}"; [[ "$timeout" =~ ^[0-9]+([.][0-9]+)?$ ]] || die "invalid installer update-lock timeout"if ! flock -x -w "$timeout" "$INSTALL_EARLY_UPDATE_LOCK_FD"; then exec {INSTALL_EARLY_UPDATE_LOCK_FD}>&- || true; INSTALL_EARLY_UPDATE_LOCK_FD=''; die "another MSO installer/update/deploy transaction is still running for $canonical"; fiINSTALL_EARLY_UPDATE_LOCK_HELD=1; INSTALL_EARLY_UPDATE_LOCK_FILE="$lock"; INSTALL_EARLY_UPDATE_CANONICAL_ROOT="$canonical"; trap install_early_update_lock_release EXITdiff --git a/scripts/install.sh b/scripts/install.shindex 721a8184..b8e012fa 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -12,7 +12,7 @@ set -Eeuo pipefailumask 077CORE_URL="${MSO_INSTALL_CORE_URL:-https://raw.githubusercontent.com/rahmanef63/mso/main/scripts/install-core.sh}"-CORE_SHA256="ac481aff3e31bbe829ab9238ff209ba92b96234127756df2b6b021222c304899"+CORE_SHA256="857e5c2571a8d83abce5687366c54515608af5c72c325d6e380e9b53cef044a0"CORE_EOF='# MSO_INSTALLER_CORE_EOF'TMP_INSTALLER=''diff --git a/scripts/install/cli.sh b/scripts/install/cli.shindex 7a11f345..d03c2892 100755--- a/scripts/install/cli.sh+++ b/scripts/install/cli.sh@@ -42,7 +42,10 @@ fi# already on the invoking PATH. This also makes `--no-service` useful on WSL.PARENT_PATH_RESOLVED="$(normalize_parent_path "$PARENT_PATH" "$PARENT_CWD")"SYSTEM_BIN_DIR="${MSO_SYSTEM_BIN_DIR:-/usr/local/bin}"-case "$SYSTEM_BIN_DIR" in /*) ;; *) SYSTEM_BIN_DIR="$PARENT_CWD/$SYSTEM_BIN_DIR" ;; esac+case "$SYSTEM_BIN_DIR" in+ /*) ;;+ *) SYSTEM_BIN_DIR="$PARENT_CWD/$SYSTEM_BIN_DIR" ;;+esacSYSTEM_CLI="$SYSTEM_BIN_DIR/mso"TARGET_CLI_REAL="$(readlink -f "$DIR/bin/mso")"CLI_IMMEDIATE=0diff --git a/scripts/install/finalize.sh b/scripts/install/finalize.shindex 63df1c03..fd933fb2 100755--- a/scripts/install/finalize.sh+++ b/scripts/install/finalize.sh@@ -22,7 +22,9 @@ if [ -d "$DIR/claude-skills" ] && [ -d "$(dirname "$SKILL_DIR")" ]; thenfor l in "$SKILL_DIR"/*; do[ -L "$l" ] || continuetgt="$(readlink "$l")"- case "$tgt" in "$DIR/claude-skills/"*) [ -d "$tgt" ] || { rm -f "$l"; info "pruned stale skill $(basename "$l")"; } ;; esac+ case "$tgt" in+ "$DIR/claude-skills/"*) [ -d "$tgt" ] || { rm -f "$l"; info "pruned stale skill $(basename "$l")"; } ;;+ esacdoneok "skills → $SKILL_DIR (/mso, /mso-camoufox, /mso-apps, /mso-list, …)"fidiff --git a/scripts/install/service.sh b/scripts/install/service.shindex 681df650..b74cbb64 100755--- a/scripts/install/service.sh+++ b/scripts/install/service.sh@@ -59,7 +59,9 @@ WantedBy=multi-user.targetEOF# A wildcard bind is not an address you can dial; probe loopback instead.HEALTH_HOST="$BIND"- case "$BIND" in 0.0.0.0|::|"") HEALTH_HOST=127.0.0.1 ;; esac+ case "$BIND" in+ 0.0.0.0|::|"") HEALTH_HOST=127.0.0.1 ;;+ esac# Makes /run/user/<uid> — where the user bus lives — exist without a login# session and survive logout. The XDG_RUNTIME_DIR above names that directory, sodiff --git a/scripts/lib/gateway-common.sh b/scripts/lib/gateway-common.shindex 2af3ddf9..4a58d240 100644--- a/scripts/lib/gateway-common.sh+++ b/scripts/lib/gateway-common.sh@@ -67,15 +67,18 @@ gateway_pid_alive() {local line rest[ "${1:-0}" -gt 1 ] 2>/dev/null && kill -0 "$1" 2>/dev/null || return 1IFS= read -r line <"/proc/$1/stat" 2>/dev/null || return 1- rest="${line##*) }"- case "$rest" in Z*|X*) return 1 ;; *) return 0 ;; esac+ rest="${line##*\) }"+ case "$rest" in+ Z*|X*) return 1 ;;+ *) return 0 ;;+ esac}gateway_proc_start_ticks() {local pid="$1" line restgateway_pid_alive "$pid" || return 1IFS= read -r line <"/proc/$pid/stat" || return 1- rest="${line##*) }"+ rest="${line##*\) }"set -- $rest[ "$#" -ge 20 ] || return 1printf '%s' "${20}"diff --git a/scripts/lib/gateway-config.sh b/scripts/lib/gateway-config.shindex b8a8929b..e72bbb1d 100644--- a/scripts/lib/gateway-config.sh+++ b/scripts/lib/gateway-config.sh@@ -2,11 +2,12 @@# Stable-origin configuration, diagnostics, and browser launcher.gateway_safe_env_file() {- local mode+ local mode mode_decimal[ -e "$ENVF" ] || gateway_fail "env file not found: $ENVF"[ -f "$ENVF" ] && [ ! -L "$ENVF" ] || gateway_fail "env file must be a regular non-symlink file"[ "$(stat -c '%u' "$ENVF")" = "$(id -u)" ] || gateway_fail "env file must be owned by current user"- mode="$(stat -c '%a' "$ENVF")"; (( (8#$mode & 077) == 0 )) \+ # Convert validated octal stat output before applying the permission mask.+ mode="$(stat -c '%a' "$ENVF")"; [[ "$mode" =~ ^[0-7]{1,4}$ ]] && mode_decimal="$(printf '%d' "0$mode")" && [ "$((mode_decimal & 63))" -eq 0 ] \|| gateway_fail "env file contains secrets and must not be group/world-accessible (got mode $mode)"}@@ -150,13 +151,20 @@ gateway_cmd_web() {local mode=auto print_only=0 url openershift || truewhile [ $# -gt 0 ]; do- case "$1" in --local) mode=local ;; --public) mode=public ;; --print) print_only=1 ;;- *) gateway_fail "usage: mso web [--local|--public] [--print]" ;; esac+ case "$1" in+ --local) mode=local ;;+ --public) mode=public ;;+ --print) print_only=1 ;;+ *) gateway_fail "usage: mso web [--local|--public] [--print]" ;;+ esacshiftdoneurl="$(gateway_with_lock gateway_cmd_web_resolve_locked "$mode")"- case "$url" in http:*) url="$(gateway_validate_loopback_origin "$url" 2>/dev/null || true)" ;;- https:*) url="$(gateway_validate_public_origin "$url" 2>/dev/null || true)" ;; *) url="" ;; esac+ case "$url" in+ http:*) url="$(gateway_validate_loopback_origin "$url" 2>/dev/null || true)" ;;+ https:*) url="$(gateway_validate_public_origin "$url" 2>/dev/null || true)" ;;+ *) url="" ;;+ esac[ -n "$url" ] || gateway_fail "refusing unsafe browser URL"[ "$print_only" = 1 ] && { printf '%s\n' "$url"; return; }if command -v wslview >/dev/null 2>&1; then opener=wslviewdiff --git a/scripts/lib/gateway-held-child.sh b/scripts/lib/gateway-held-child.shindex b30d7845..45577e3e 100755--- a/scripts/lib/gateway-held-child.sh+++ b/scripts/lib/gateway-held-child.sh@@ -5,7 +5,10 @@ set -euo pipefailparent_pid="${1:-}"; parent_ticks="${2:-}"; gate="${3:-}"; shift 3 || exit 2[[ "$parent_pid" =~ ^[0-9]+$ && "$parent_ticks" =~ ^[0-9]+$ ]] || exit 2-case "$gate" in /*) ;; *) exit 2 ;; esac+case "$gate" in+ /*) ;;+ *) exit 2 ;;+esac[ "$#" -gt 0 ] || exit 2cmd=("$@")@@ -18,7 +21,7 @@ for ((i=0; i<500; i++)); do[ -r "/proc/$parent_pid/stat" ] || exit 125IFS= read -r line <"/proc/$parent_pid/stat" || exit 125- rest="${line##*) }"; set -- $rest+ rest="${line##*\) }"; set -- $rest[ "${20:-}" = "$parent_ticks" ] || exit 125sleep 0.01donediff --git a/scripts/lib/gateway-lock.sh b/scripts/lib/gateway-lock.shindex 4b3b2372..53595234 100755--- a/scripts/lib/gateway-lock.sh+++ b/scripts/lib/gateway-lock.sh@@ -3,7 +3,7 @@gateway_lock_acquire() {gateway_private_file "$LOCK_FILE"- exec {GATEWAY_LOCK_FD}<>"$LOCK_FILE" || gateway_fail "cannot open gateway lifecycle lock"+ exec {GATEWAY_LOCK_FD}>>"$LOCK_FILE" || gateway_fail "cannot open gateway lifecycle lock"if ! flock -x -w 12 "$GATEWAY_LOCK_FD"; thenexec {GATEWAY_LOCK_FD}>&- || trueGATEWAY_LOCK_FD=''diff --git a/scripts/lib/gateway-recovery.sh b/scripts/lib/gateway-recovery.shindex e73c0008..9b737820 100755--- a/scripts/lib/gateway-recovery.sh+++ b/scripts/lib/gateway-recovery.sh@@ -4,7 +4,10 @@gateway_recovery_marker_path() {local requested="${MSO_GATEWAY_RECOVERY_MARKER:-}"[ -n "$requested" ] || gateway_fail "runtime-stop requires an update recovery marker"- case "$requested" in /*) ;; *) gateway_fail "update recovery marker must be an absolute path" ;; esac+ case "$requested" in+ /*) ;;+ *) gateway_fail "update recovery marker must be an absolute path" ;;+ esacmso_private_state_path "$requested" || gateway_fail "unsafe update recovery marker path"}diff --git a/scripts/lib/gateway-tool.sh b/scripts/lib/gateway-tool.shindex 90eb3a99..b60b39eb 100755--- a/scripts/lib/gateway-tool.sh+++ b/scripts/lib/gateway-tool.sh@@ -18,11 +18,12 @@ _gateway_tool_expected() {}_gateway_tool_validate() {- local file="$1" expected="$2" owner mode actual+ local file="$1" expected="$2" owner mode actual mode_decimal[ -f "$file" ] && [ ! -L "$file" ] || return 1owner="$(stat -c '%u' -- "$file" 2>/dev/null || true)"; [ "$owner" = "$(id -u)" ] || return 1mode="$(stat -c '%a' -- "$file" 2>/dev/null || true)"; [[ "$mode" =~ ^[0-7]{3,4}$ ]] || return 1- (( (8#$mode & 022) == 0 )) || return 1+ # Convert validated octal stat output before applying the permission mask.+ mode_decimal="$(printf '%d' "0$mode")" && [ "$((mode_decimal & 18))" -eq 0 ] || return 1actual="$(sha256sum "$file" 2>/dev/null | awk '{print $1}')"[ "$actual" = "$expected" ] || return 1[ -x "$file" ]@@ -31,7 +32,10 @@ _gateway_tool_validate() {gateway_resolve_cloudflared() {local override="${MSO_GATEWAY_CLOUDFLARED:-}" url expected dir dest tmp actualif [ -n "$override" ]; then- case "$override" in /*) ;; *) gateway_fail "MSO_GATEWAY_CLOUDFLARED must be an absolute path" ;; esac+ case "$override" in+ /*) ;;+ *) gateway_fail "MSO_GATEWAY_CLOUDFLARED must be an absolute path" ;;+ esac[ -f "$override" ] && [ ! -L "$override" ] && [ -x "$override" ] \|| gateway_fail "cloudflared override must be an executable regular non-symlink file: $override"CLOUDFLARED="$(realpath -e -- "$override")"diff --git a/scripts/lib/gateway-tunnel.sh b/scripts/lib/gateway-tunnel.shindex 49e3b593..dc1b746a 100644--- a/scripts/lib/gateway-tunnel.sh+++ b/scripts/lib/gateway-tunnel.sh@@ -46,12 +46,13 @@ NODE}gateway_validate_named_tunnel() {- local mode public+ local mode public mode_decimal[ -n "$GATEWAY_CONFIG" ] && [ -n "$GATEWAY_TUNNEL" ] || gateway_fail "named mode requires BOTH --config and --tunnel"[[ "$GATEWAY_TUNNEL" =~ ^[A-Za-z0-9_-]{1,80}$ ]] || gateway_fail "invalid tunnel name/UUID"[ -f "$GATEWAY_CONFIG" ] && [ ! -L "$GATEWAY_CONFIG" ] || gateway_fail "config must be a regular non-symlink file"[ "$(stat -c '%u' "$GATEWAY_CONFIG")" = "$(id -u)" ] || gateway_fail "cloudflared config must be owned by current user"- mode="$(stat -c '%a' "$GATEWAY_CONFIG")"; (( (8#$mode & 022) == 0 )) \+ # Convert validated octal stat output before applying the permission mask.+ mode="$(stat -c '%a' "$GATEWAY_CONFIG")"; [[ "$mode" =~ ^[0-7]{1,4}$ ]] && mode_decimal="$(printf '%d' "0$mode")" && [ "$((mode_decimal & 18))" -eq 0 ] \|| gateway_fail "cloudflared config must not be group/world-writable (got mode $mode)"public="$(gateway_validate_public_origin "${OS_PUBLIC_ORIGIN:-}" 2>/dev/null || true)"[ -n "$public" ] || gateway_fail "named mode requires OS_PUBLIC_ORIGIN=https://your-domain (use: mso gateway domain set https://...)"diff --git a/scripts/lib/private-state.sh b/scripts/lib/private-state.shindex 7289c85e..468cc61a 100755--- a/scripts/lib/private-state.sh+++ b/scripts/lib/private-state.sh@@ -10,7 +10,10 @@ mso_private_state_error() {mso_private_state_dir() {local requested="${1:-}" created=0 canonical owner mode old_umask[ -n "$requested" ] || { mso_private_state_error "empty directory path"; return 1; }- case "$requested" in /*) ;; *) mso_private_state_error "directory must be absolute: $requested"; return 1 ;; esac+ case "$requested" in+ /*) ;;+ *) mso_private_state_error "directory must be absolute: $requested"; return 1 ;;+ esac[ ! -L "$requested" ] || { mso_private_state_error "refusing symlink directory: $requested"; return 1; }if [ ! -e "$requested" ]; then@@ -49,7 +52,10 @@ mso_private_state_dir() {mso_private_state_path() {local requested="${1:-}" parent name canonical_parent[ -n "$requested" ] || { mso_private_state_error "empty file path"; return 1; }- case "$requested" in /*) ;; *) mso_private_state_error "file path must be absolute: $requested"; return 1 ;; esac+ case "$requested" in+ /*) ;;+ *) mso_private_state_error "file path must be absolute: $requested"; return 1 ;;+ esacparent=$(dirname -- "$requested")name=$(basename -- "$requested")[ -n "$name" ] && [ "$name" != . ] && [ "$name" != / ] || {diff --git a/scripts/lib/runtime-exclusion.sh b/scripts/lib/runtime-exclusion.shindex 97b10733..7aef120f 100755--- a/scripts/lib/runtime-exclusion.sh+++ b/scripts/lib/runtime-exclusion.sh@@ -23,9 +23,13 @@ runtime_exclusion_init() {runtime_exclusion_acquire() {local mode="$1" timeout="$2" flagruntime_exclusion_init || return 1- case "$mode" in shared) flag=-s ;; exclusive) flag=-x ;; *) return 2 ;; esac+ case "$mode" in+ shared) flag=-s ;;+ exclusive) flag=-x ;;+ *) return 2 ;;+ esac[[ "$timeout" =~ ^[0-9]+([.][0-9]+)?$ ]] || return 2- exec {RUNTIME_EXCLUSION_FD}<>"$RUNTIME_EXCLUSION_FILE" || return 1+ exec {RUNTIME_EXCLUSION_FD}>>"$RUNTIME_EXCLUSION_FILE" || return 1if ! flock "$flag" -w "$timeout" "$RUNTIME_EXCLUSION_FD"; thenexec {RUNTIME_EXCLUSION_FD}>&- || trueRUNTIME_EXCLUSION_FD=''diff --git a/scripts/lib/update-state.sh b/scripts/lib/update-state.shindex ff2c3230..933bbb99 100755--- a/scripts/lib/update-state.sh+++ b/scripts/lib/update-state.sh@@ -14,7 +14,7 @@ update_proc_start_ticks() {local pid="$1" line rest[ "$pid" -gt 1 ] 2>/dev/null && kill -0 "$pid" 2>/dev/null || return 1IFS= read -r line <"/proc/$pid/stat" || return 1- rest="${line##*) }"; set -- $rest+ rest="${line##*\) }"; set -- $rest[ "$#" -ge 20 ] || return 1printf '%s' "${20}"}@@ -71,7 +71,7 @@ update_lock_acquire() {[[ "$timeout" =~ ^[0-9]+([.][0-9]+)?$ ]] || fail "invalid update transaction lock timeout"init_update_statemso_private_state_ensure_file "$UPDATE_LOCK_DIR" >/dev/null || fail "unsafe offline update transaction lock"- exec {UPDATE_LOCK_FD}<>"$UPDATE_LOCK_DIR" || fail "cannot open offline update transaction lock"+ exec {UPDATE_LOCK_FD}>>"$UPDATE_LOCK_DIR" || fail "cannot open offline update transaction lock"if ! flock -x -w "$timeout" "$UPDATE_LOCK_FD"; thenexec {UPDATE_LOCK_FD}>&- || trueUPDATE_LOCK_FD=''diff --git a/scripts/managed-app-9router b/scripts/managed-app-9routerindex 1a1e461c..d5378abc 100755--- a/scripts/managed-app-9router+++ b/scripts/managed-app-9router@@ -33,7 +33,11 @@ EXPECTED_DIGEST="${IMAGE##*@}"}readonly NINE_ROUTER_IMAGE_REF IMAGE EXPECTED_DIGESTEXPOSE_PUBLIC="${NINE_ROUTER_EXPOSE_PUBLIC:-0}"-case "$EXPOSE_PUBLIC" in 0) BIND=127.0.0.1 ;; 1) BIND=0.0.0.0 ;; *) echo "NINE_ROUTER_EXPOSE_PUBLIC must be 0 or 1" >&2; exit 2 ;; esac+case "$EXPOSE_PUBLIC" in+ 0) BIND=127.0.0.1 ;;+ 1) BIND=0.0.0.0 ;;+ *) echo "NINE_ROUTER_EXPOSE_PUBLIC must be 0 or 1" >&2; exit 2 ;;+esacDATA="${NINE_ROUTER_DATA:-$HOME/.9router}"PROXY_NETWORK="${NINE_ROUTER_PROXY_NETWORK:-dokploy-network}"BASE="http://127.0.0.1:${PORT}"@@ -135,7 +139,9 @@ cmd_update() {# ~/.9router data stay. A reinstall finds its providers and stats untouched.cmd_uninstall() {local dry=0- case "${1:-}" in --dry-run) dry=1 ;; esac+ case "${1:-}" in+ --dry-run) dry=1 ;;+ esacif [ "$dry" = 1 ]; thenecho "would remove container: $NAME"echo "kept: image $IMAGE, data $DATA"diff --git a/scripts/mso-cli-agent.sh b/scripts/mso-cli-agent.shindex 16eadcbd..a7caf1ad 100755--- a/scripts/mso-cli-agent.sh+++ b/scripts/mso-cli-agent.sh@@ -31,14 +31,20 @@ onboard_infra() {echo "Infrastructure providers"echo " MSO Agent can use these after you connect them. Secrets stay server-side and never enter model tool arguments."tty_line "Configure Dokploy now? [y/N]: " "n"; choice="${REPLY,,}"- case "$choice" in y|yes) run_provider set dokploy ;; esac+ case "$choice" in+ y|yes) run_provider set dokploy ;;+ esacechoecho "DNS provider"echo " 0) Skip"echo " 1) Cloudflare (per-record writes only)"echo " 2) Hostinger (exact name/type RR-set updates; agent approval required)"tty_line "Choose [0]: " 0; choice="$REPLY"- case "$choice" in 1) run_provider set cloudflare ;; 2) run_provider set hostinger ;; *) echo " -- DNS provider skipped" ;; esac+ case "$choice" in+ 1) run_provider set cloudflare ;;+ 2) run_provider set hostinger ;;+ *) echo " -- DNS provider skipped" ;;+ esac}ai_config_ready() {@@ -166,7 +172,9 @@ configure_oauth_provider() {echo "Enter code: $code"echo "Waiting for authorization (active model will NOT change)..."while true; do- sleep "$(( interval / 1000 > 2 ? interval / 1000 : 3 ))"+ poll_seconds=$((interval / 1000))+ [ "$poll_seconds" -gt 2 ] || poll_seconds=3+ sleep "$poll_seconds"poll=$(jpost "/api/oauth/openai" '{"action":"poll","select":false}')if [ "$(jq -r '.ok // false' <<<"$poll")" = true ]; thenecho " ✓ connected $(jq -r '.slug' <<<"$poll"); model selection unchanged"@@ -189,7 +197,10 @@ configure_ai_provider() {tty_line "Provider name: " ""; name="$REPLY"; [ -n "$name" ] || die "provider name required"tty_line "Base URL (https://.../v1): " ""; base="$REPLY"; [ -n "$base" ] || die "base URL required"tty_line "Protocol [openai|anthropic] [openai]: " "openai"; protocol="$REPLY"- case "$protocol" in openai|anthropic) ;; *) die "protocol must be openai or anthropic" ;; esac+ case "$protocol" in+ openai|anthropic) ;;+ *) die "protocol must be openai or anthropic" ;;+ esactty_line "Models (comma/newline IDs; optional): " ""; models="$REPLY"tty_secret "API key: "; key="$REPLY"; [ -n "$key" ] || die "empty API key"body=$(printf '%s\0%s\0%s\0%s\0%s' "$name" "$base" "$protocol" "$key" "$models" | custom_provider_body_unselected)diff --git a/scripts/mso-cli-integrations-sc.sh b/scripts/mso-cli-integrations-sc.shindex 7a42496e..c557a2ab 100755--- a/scripts/mso-cli-integrations-sc.sh+++ b/scripts/mso-cli-integrations-sc.sh@@ -58,7 +58,10 @@ integration_sc_import_interactive(){integration_sc_preview_text "$preview"if ! jq -e '.canApply==true' >/dev/null <<<"$preview"; then printf 'Import cannot be applied with the current conflicts.\n'; return 1; fitty_line "Apply this create-only metadata import? [y/N]: " n; ans="${REPLY,,}"- case "$ans" in y|yes) ;; *) printf 'cancelled\n'; return 0;; esac+ case "$ans" in+ y|yes) ;;+ *) printf 'cancelled\n'; return 0;;+ esacapplied=$(integration_sc_apply_document "$bundle" "$preview") || returnprintf 'Imported %s named connection(s) from SI-Coder metadata.\n' "$(jq -r '.created//0'<<<"$applied")"printf 'Direct credentials still require private setup or an encrypted Integration Bundle. External OAuth/provider-MCP connections require reauthorization.\n'@@ -71,7 +74,10 @@ integration_sc_import_cli(){integration_sc_preview_text "$preview"if ! jq -e '.canApply==true' >/dev/null <<<"$preview"; then return 1; fitty_line "Apply this create-only metadata import? [y/N]: " n; ans="${REPLY,,}"- case "$ans" in y|yes) ;; *) printf 'cancelled\n'; return 0;; esac+ case "$ans" in+ y|yes) ;;+ *) printf 'cancelled\n'; return 0;;+ esacapplied=$(integration_sc_apply_document "$bundle" "$preview") || returnprintf 'Imported %s named connection(s).\n' "$(jq -r '.created//0'<<<"$applied")"}diff --git a/scripts/mso-cli-integrations-tui-remote.sh b/scripts/mso-cli-integrations-tui-remote.shindex 85c8063a..2f781cff 100644--- a/scripts/mso-cli-integrations-tui-remote.sh+++ b/scripts/mso-cli-integrations-tui-remote.sh@@ -9,11 +9,18 @@ integration_action_user_add(){ local root id label body; root=$(jq -r '.[0]//"usintegration_action_user_default(){ local u body;u=$(integration_context user:);body=$(jq -nc --arg u "$u" '{mode:"manage",action:"user.default",confirm:true,user:$u}');integration_tui_manage "$body" >/dev/null;integration_activity "✓ $u is now the default credential user"; }integration_action_user_bind(){ local u body;u=$(integration_context user:);body=$(jq -nc --arg u "$u" --arg p "$PWD" '{mode:"manage",action:"folder.map",confirm:true,user:$u,path:$p}');integration_tui_manage "$body" >/dev/null;integration_activity "✓ Mapped current folder to $u" "$PWD"; }integration_action_user_rename(){ local u target label body;u=$(integration_context user:);integration_prompt_mode;tty_line "New user ID: " "$u";target="$REPLY";[ "$target" != "$u" ]||return;tty_line "Display label [$target]: " "$target";label="$REPLY";body=$(jq -nc --arg u "$u" --arg t "$target" --arg l "$label" '{mode:"manage",action:"user.rename",confirm:true,user:$u,target:$t,label:$l}');integration_tui_manage "$body" >/dev/null;F_STACK=$(jq --arg old "user:$u" --arg new "user:$target" 'map(if .==$old then $new else . end)'<<<"$F_STACK");integration_activity "✓ Renamed credential user $u → $target"; }-integration_action_user_duplicate(){ local u target label ans copy body;u=$(integration_context user:);integration_prompt_mode;tty_line "Duplicate as user ID: " "${u}-copy";target="$REPLY";[ -n "$target" ]||return;tty_line "Display label [$target]: " "$target";label="$REPLY";tty_line "Copy direct credentials too? [y/N]: " n;ans="${REPLY,,}";copy=false;case "$ans" in y|yes)copy=true;;esac;body=$(jq -nc --arg u "$u" --arg t "$target" --arg l "$label" --argjson c "$copy" '{mode:"manage",action:"user.duplicate",confirm:true,user:$u,target:$t,label:$l,copyCredentials:$c}');integration_tui_manage "$body" >/dev/null;integration_activity "✓ Duplicated $u → $target" "$([ "$copy" = true ]&&printf 'direct credentials copied' || printf 'metadata only')"; }+integration_action_user_duplicate(){ local u target label ans copy body;u=$(integration_context user:);integration_prompt_mode;tty_line "Duplicate as user ID: " "${u}-copy";target="$REPLY";[ -n "$target" ]||return;tty_line "Display label [$target]: " "$target";label="$REPLY";tty_line "Copy direct credentials too? [y/N]: " n;ans="${REPLY,,}";copy=false;case "$ans" in+ y|yes)copy=true;;+esac;body=$(jq -nc --arg u "$u" --arg t "$target" --arg l "$label" --argjson c "$copy" '{mode:"manage",action:"user.duplicate",confirm:true,user:$u,target:$t,label:$l,copyCredentials:$c}');integration_tui_manage "$body" >/dev/null;integration_activity "✓ Duplicated $u → $target" "$([ "$copy" = true ]&&printf 'direct credentials copied' || printf 'metadata only')"; }integration_action_user_delete(){ local u body root;u=$(integration_context user:);root=$(jq -r '.[0]'<<<"$F_STACK");integration_prompt_mode;tty_line "Type $u to delete: " "";[ "$REPLY" = "$u" ]||{ integration_activity '⚠ Delete cancelled';return;};body=$(jq -nc --arg u "$u" '{mode:"manage",action:"user.delete",confirm:true,user:$u}');integration_tui_manage "$body" >/dev/null;F_STACK=$(jq -nc --arg r "$root" '[$r]');integration_activity "✓ Deleted credential user $u"; }-integration_action_create_connection(){ local u p s a label id body ans idx;u=$(integration_context user:);p=$(integration_context provider:);s=$(integration_context source:);a=$(integration_context auth:);integration_prompt_mode;tty_line "Connection label: " "$p";label="$REPLY";[ -n "$label" ]||return;id=$(integration_tui_slug "$label");[ -n "$id" ]||id=connection;tty_line "Connection ID [$id]: " "$id";id="$REPLY";body=$(jq -nc --arg u "$u" --arg p "$p" --arg c "$id" --arg l "$label" --arg s "$s" --arg a "$a" '{mode:"manage",action:"connection.create",confirm:true,user:$u,provider:$p,connection:$c,label:$l,source:$s,authMethod:$a}');integration_tui_manage "$body" >/dev/null;idx=$(jq '[to_entries[]|select(.value|startswith("provider:"))]|last.key'<<<"$F_STACK");F_STACK=$(jq --argjson i "$idx" --arg c "connection:$id" '.[0:$i+1]+[$c]'<<<"$F_STACK");integration_activity "✓ Created $label" "$u › $p › $id" "$s · $a";if [ "$s" = direct ];then tty_line "Open secure credential form now? [Y/n]: " y;ans="${REPLY,,}";case "$ans" in n|no);;*)integration_prompt_mode;run_integrations setup "$u" "$p" "$id";integration_wait;;esac;fi; }+integration_action_create_connection(){ local u p s a label id body ans idx;u=$(integration_context user:);p=$(integration_context provider:);s=$(integration_context source:);a=$(integration_context auth:);integration_prompt_mode;tty_line "Connection label: " "$p";label="$REPLY";[ -n "$label" ]||return;id=$(integration_tui_slug "$label");[ -n "$id" ]||id=connection;tty_line "Connection ID [$id]: " "$id";id="$REPLY";body=$(jq -nc --arg u "$u" --arg p "$p" --arg c "$id" --arg l "$label" --arg s "$s" --arg a "$a" '{mode:"manage",action:"connection.create",confirm:true,user:$u,provider:$p,connection:$c,label:$l,source:$s,authMethod:$a}');integration_tui_manage "$body" >/dev/null;idx=$(jq '[to_entries[]|select(.value|startswith("provider:"))]|last.key'<<<"$F_STACK");F_STACK=$(jq --argjson i "$idx" --arg c "connection:$id" '.[0:$i+1]+[$c]'<<<"$F_STACK");integration_activity "✓ Created $label" "$u › $p › $id" "$s · $a";if [ "$s" = direct ];then tty_line "Open secure credential form now? [Y/n]: " y;ans="${REPLY,,}";case "$ans" in+ n|no);;+ *)integration_prompt_mode;run_integrations setup "$u" "$p" "$id";integration_wait;;+esac;fi; }integration_action_setup(){ local u p c;u=$(integration_context user:);p=$(integration_context provider:);c=$(integration_context connection:);integration_prompt_mode;run_integrations setup "$u" "$p" "$c";integration_wait;integration_activity "✓ Secure setup opened for $u › $p › $c" "Credential values remain outside Finder/model state."; }-integration_action_authorize(){ local u p c broker cfg ans managed body out;u=$(integration_context user:);p=$(integration_context provider:);c=$(integration_context connection:);integration_prompt_mode;tty_line "Composio project connection ID (blank = auto): " "";broker="$REPLY";tty_line "Auth config ID (blank = auto): " "";cfg="$REPLY";tty_line "Allow managed OAuth config if none exists? [y/N]: " n;ans="${REPLY,,}";managed=false;case "$ans" in y|yes)managed=true;;esac;body=$(jq -nc --arg u "$u" --arg p "$p" --arg c "$c" --arg b "$broker" --arg g "$cfg" --argjson m "$managed" '{mode:"manage",action:"connection.authorize",confirm:true,user:$u,provider:$p,connection:$c,createManaged:$m}+(if $b!="" then {brokerConnection:$b}else{}end)+(if $g!="" then {authConfigId:$g}else{}end)');out=$(integration_tui_manage "$body");if jq -e '.privateUrl' >/dev/null 2>&1<<<"$out";then printf '\nOpen private authorization URL:\n%s\n' "$(jq -r .privateUrl<<<"$out")";integration_wait;fi;integration_activity "✓ Authorization flow prepared" "$u › $p › $c"; }+integration_action_authorize(){ local u p c broker cfg ans managed body out;u=$(integration_context user:);p=$(integration_context provider:);c=$(integration_context connection:);integration_prompt_mode;tty_line "Composio project connection ID (blank = auto): " "";broker="$REPLY";tty_line "Auth config ID (blank = auto): " "";cfg="$REPLY";tty_line "Allow managed OAuth config if none exists? [y/N]: " n;ans="${REPLY,,}";managed=false;case "$ans" in+ y|yes)managed=true;;+esac;body=$(jq -nc --arg u "$u" --arg p "$p" --arg c "$c" --arg b "$broker" --arg g "$cfg" --argjson m "$managed" '{mode:"manage",action:"connection.authorize",confirm:true,user:$u,provider:$p,connection:$c,createManaged:$m}+(if $b!="" then {brokerConnection:$b}else{}end)+(if $g!="" then {authConfigId:$g}else{}end)');out=$(integration_tui_manage "$body");if jq -e '.privateUrl' >/dev/null 2>&1<<<"$out";then printf '\nOpen private authorization URL:\n%s\n' "$(jq -r .privateUrl<<<"$out")";integration_wait;fi;integration_activity "✓ Authorization flow prepared" "$u › $p › $c"; }integration_action_verify(){ local u p c out ok detail;u=$(integration_context user:);p=$(integration_context provider:);c=$(integration_context connection:);out=$(integration_tui_execute "$u" "$p" "$c" verify '{}' false);ok=$(jq -r '.ok//.result.ok//"unknown"'<<<"$out");detail=$(jq -r '.detail//.result.detail//""'<<<"$out");if [ "$ok" = true ];then integration_activity "✓ Verified $u › $p › $c" "$detail";elif [ "$ok" = false ];then integration_activity "✕ Verification failed for $u › $p › $c" "$detail";else integration_activity "⚠ Verification unavailable for $u › $p › $c" "$detail";fi; }integration_action_route(){ local u p c out;u=$(integration_context user:);p=$(integration_context provider:);c=$(integration_context connection:);out=$(integration_tui_execute "$u" "$p" "$c" route '{}' false);integration_activity "✓ Route resolved: $u › $p › $c" "source: $(jq -r '.source//.result.source//"unknown"'<<<"$out")" "scope: $(jq -r '.scope//.result.scope//"unknown"'<<<"$out")"; }integration_action_connection_default(){ local u p c body;u=$(integration_context user:);p=$(integration_context provider:);c=$(integration_context connection:);body=$(jq -nc --arg u "$u" --arg p "$p" --arg c "$c" '{mode:"manage",action:"connection.default",confirm:true,user:$u,provider:$p,connection:$c}');integration_tui_manage "$body" >/dev/null;integration_activity "✓ $c is now default for $p"; }diff --git a/scripts/mso-update b/scripts/mso-updateindex 8ada6050..2b510f50 100755--- a/scripts/mso-update+++ b/scripts/mso-update@@ -214,7 +214,10 @@ service_source_matches_runtime() {update_unit_active() {local statestate="$(systemctl --user show -p ActiveState --value mso-self-update.service 2>/dev/null || true)"- case "$state" in activating|active|reloading|deactivating) return 0 ;; *) return 1 ;; esac+ case "$state" in+ activating|active|reloading|deactivating) return 0 ;;+ *) return 1 ;;+ esac}update_stage() {@@ -284,7 +287,11 @@ case "${1:-run}" innotice) notice ;;status|check) print_status ;;log) [ -f "$LOG" ] && tail -n "${2:-80}" "$LOG" || printf 'no update log yet: %s\n' "$LOG" ;;- run) case "${2-}" in "" ) run_update 0 ;; --rebuild|--rebuild-only) run_update 1 ;; *) fail "usage: mso update [--rebuild] | status | log" ;; esac ;;+ run) case "${2-}" in+ "" ) run_update 0 ;;+ --rebuild|--rebuild-only) run_update 1 ;;+ *) fail "usage: mso update [--rebuild] | status | log" ;;+ esac ;;--rebuild|--rebuild-only) run_update 1 ;;*) fail "usage: mso update [--rebuild] | status | log" ;;esacdiff --git a/scripts/security-ultimate.sh b/scripts/security-ultimate.shindex 97259672..b12918cc 100755--- a/scripts/security-ultimate.sh+++ b/scripts/security-ultimate.sh@@ -103,7 +103,7 @@ run_capture "Gitleaks history" docker run --rm --user "$(id -u):$(id -g)" \-v "$GIT_COMMON:/git:ro" -v "$ROOT:/repo:ro" "$GITLEAKS_IMAGE" \git --no-banner --redact --log-opts="--all --full-history --diff-merges=first-parent" --gitleaks-ignore-path /repo/.gitleaksignore /reporun_capture "Semgrep OWASP/SAST" docker run --rm -v "$SRC:/src:ro" "$SEMGREP_IMAGE" \- semgrep scan --metrics=off --config=p/javascript --config=p/typescript --config=p/owasp-top-ten --error /src+ semgrep scan --metrics=off --config=p/javascript --config=p/typescript --config=p/owasp-top-ten --strict --error /srcmapfile -t shell_files < <(git grep -Il '^#!.*sh' -- '*.sh' 'bin/*' 'scripts/*' 'claude-skills/*' || true)shell_args=()diff --git a/scripts/self-update.sh b/scripts/self-update.shindex d15a4bb6..133bd7b5 100755--- a/scripts/self-update.sh+++ b/scripts/self-update.sh@@ -149,7 +149,7 @@ while [ "$SECONDS" -lt "$RESTART_DEADLINE" ]; dodone[ -n "$NEW_PID" ] \|| die "mso.service did not return with a new MainPID within ${RESTART_WAIT_SECONDS}s; release state is unverified — inspect the system unit before retrying"-printf 'restarted %s -> %s after %ss\n' "$OLD_PID" "$NEW_PID" "$((RESTART_WAIT_SECONDS - (RESTART_DEADLINE - SECONDS)))"+printf 'restarted %s -> %s after %ss\n' "$OLD_PID" "$NEW_PID" "$((RESTART_WAIT_SECONDS - RESTART_DEADLINE + SECONDS))"# Verify the COMPLETE static asset graph referenced by root HTML. A healthy first# stylesheet is insufficient: an in-place build can leave one old JS chunk missingdiff --git a/scripts/test-fixtures/install-runtime-abort-recovery.sh b/scripts/test-fixtures/install-runtime-abort-recovery.shindex 4d852b30..43b0958e 100644--- a/scripts/test-fixtures/install-runtime-abort-recovery.sh+++ b/scripts/test-fixtures/install-runtime-abort-recovery.sh@@ -3,7 +3,10 @@ set -euo pipefailROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"MODE="${1:-}"-case "$MODE" in pre|post) ;; *) exit 2 ;; esac+case "$MODE" in+ pre|post) ;;+ *) exit 2 ;;+esacDIR=/tmpPORT=4005diff --git a/scripts/test-support/integrations-cli-tui-harness.sh b/scripts/test-support/integrations-cli-tui-harness.shindex c5c91080..094499d1 100755--- a/scripts/test-support/integrations-cli-tui-harness.sh+++ b/scripts/test-support/integrations-cli-tui-harness.sh@@ -5,10 +5,29 @@ source "$ROOT/scripts/mso-cli-integrations.sh": "${MSO_TUI_CHOICES:?events file required}" "${MSO_TUI_PROMPTS:?prompts file required}" "${MSO_TUI_LOG:?log file required}"tty_ok(){ return 0; };integration_alt_on(){ :; };integration_alt_off(){ :; };integration_prompt_mode(){ :; };integration_wait(){ :; }pop_line(){ local file="$1" line tmp;line=$(head -n1 "$file"||true);tmp="$file.tmp";tail -n +2 "$file">"$tmp";mv "$tmp" "$file";printf '%s' "$line"; }-integration_finder_event(){ local _snap="$1" _stack="$2" _activity="$3" _initial="${4-}" _query="${5-}" value;value=$(pop_line "$MSO_TUI_CHOICES");case "$value" in OPEN:*) jq -nc --arg id "${value#OPEN:}" --arg s "${value#OPEN:}" --arg q "$_query" '{type:"open",id:$id,selectedId:$s,query:$q}';;SELECT:*)jq -nc --arg id "${value#SELECT:}" --arg s "${value#SELECT:}" --arg q "$_query" '{type:"select",id:$id,selectedId:$s,query:$q}';;SHORTCUT:*)jq -nc --arg id "${value#SHORTCUT:}" --arg q "$_query" '{type:"shortcut",id:$id,query:$q}';;SECTION:*)jq -nc --arg id "${value#SECTION:}" '{type:"section",id:$id,query:""}';;BACK)printf '%s' '{"type":"back","query":""}';;QUIT|"")printf '%s' '{"type":"quit","query":""}';;*)return 130;;esac; }+integration_finder_event(){ local _snap="$1" _stack="$2" _activity="$3" _initial="${4-}" _query="${5-}" value;value=$(pop_line "$MSO_TUI_CHOICES");case "$value" in+ OPEN:*) jq -nc --arg id "${value#OPEN:}" --arg s "${value#OPEN:}" --arg q "$_query" '{type:"open",id:$id,selectedId:$s,query:$q}';;+ SELECT:*)jq -nc --arg id "${value#SELECT:}" --arg s "${value#SELECT:}" --arg q "$_query" '{type:"select",id:$id,selectedId:$s,query:$q}';;+ SHORTCUT:*)jq -nc --arg id "${value#SHORTCUT:}" --arg q "$_query" '{type:"shortcut",id:$id,query:$q}';;+ SECTION:*)jq -nc --arg id "${value#SECTION:}" '{type:"section",id:$id,query:""}';;+ BACK)printf '%s' '{"type":"back","query":""}';;+ QUIT|"")printf '%s' '{"type":"quit","query":""}';;+ *)return 130;;+esac; }tty_line(){ local _prompt="$1" default="${2-}" value;value=$(pop_line "$MSO_TUI_PROMPTS");REPLY="${value:-$default}"; }enc(){ printf '%s' "$1"; };die(){ printf '%s' "$*" >&2;exit 2; }SNAP='{"user":"alice","users":[{"id":"alice","label":"Alice","isDefault":true,"connectionCount":2}],"bindings":[],"catalog":[{"id":"github","title":"GitHub","description":"GitHub account","sources":[{"id":"direct","label":"MSO direct","methods":[{"id":"direct","label":"Direct credential","scope":"account","fields":[{"key":"apiKey"}]}]},{"id":"composio","label":"Composio","methods":[{"id":"oauth2","label":"OAuth2","scope":"account","fields":[]}]}]},{"id":"hostinger","title":"Hostinger","description":"Hostinger account","sources":[{"id":"direct","label":"MSO direct","methods":[{"id":"direct","label":"Account API token","scope":"account","fields":[{"key":"apiToken"}]},{"id":"mail","label":"Scoped Mail API token","scope":"mail-order","fields":[{"key":"mailApiToken"},{"key":"mailOrderId"}]}]}]}],"connections":[{"user":"alice","id":"work","label":"Work GitHub","provider":"github","source":"direct","authMethod":"direct","scope":"account","state":"verified","isDefault":false},{"user":"alice","id":"mail","label":"Mail","provider":"hostinger","source":"direct","authMethod":"mail","scope":"mail-order","state":"configured","isDefault":true}]}';-jget(){ case "$1" in *view=which*)printf '%s' '{"user":"alice","resolution":"default","bindings":[]}' ;;*transfer*)printf '%s' '{"url":"https://mso.example/integrations?transfer=1"}' ;;*)printf '%s' "$SNAP";;esac; }-jpost(){ local route="$1" body="${2-}";[ -n "$body" ]||body='{}';printf '%s\t%s\n' "$route" "$body">>"$MSO_TUI_LOG";if [[ "$route" == */infra/setup ]];then printf '%s' '{"setupUrl":"https://mso.example/integrations","token":"TEST_ONLY_PRIVATE_TOKEN"}';return;fi;case "$(jq -r '.action//.operation//empty'<<<"$body")" in connection.create)printf '%s' '{"ok":true,"connection":{"id":"work"}}';;connection.rename|connection.default|connection.delete|user.default|folder.map|user.create|user.rename|user.duplicate|user.delete)printf '%s' '{"ok":true}';;verify)printf '%s' '{"ok":true,"detail":"verified"}';;route)printf '%s' '{"source":"direct","scope":"account"}';;hostinger.mail.orders.list)printf '%s' '{"result":{"data":[]}}';;*)printf '%s' '{}';;esac; }+jget(){ case "$1" in+ *view=which*)printf '%s' '{"user":"alice","resolution":"default","bindings":[]}' ;;+ *transfer*)printf '%s' '{"url":"https://mso.example/integrations?transfer=1"}' ;;+ *)printf '%s' "$SNAP";;+esac; }+jpost(){ local route="$1" body="${2-}";[ -n "$body" ]||body='{}';printf '%s\t%s\n' "$route" "$body">>"$MSO_TUI_LOG";if [[ "$route" == */infra/setup ]];then printf '%s' '{"setupUrl":"https://mso.example/integrations","token":"TEST_ONLY_PRIVATE_TOKEN"}';return;fi;case "$(jq -r '.action//.operation//empty'<<<"$body")" in+ connection.create)printf '%s' '{"ok":true,"connection":{"id":"work"}}';;+ connection.rename|connection.default|connection.delete|user.default|folder.map|user.create|user.rename|user.duplicate|user.delete)printf '%s' '{"ok":true}';;+ verify)printf '%s' '{"ok":true,"detail":"verified"}';;+ route)printf '%s' '{"source":"direct","scope":"account"}';;+ hostinger.mail.orders.list)printf '%s' '{"result":{"data":[]}}';;+ *)printf '%s' '{}';;+esac; }if [ "$#" -eq 0 ];then integrations_tui;else run_integrations "$@";fi