Skip to content

armgit / mso

Public Imported from GitHub
0

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.

feat(integrations): add interactive terminal navigator

Rahmanec52a00bc663
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 535f53c0..bf0c7665 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”.
**Added**
+- `integrations` add interactive terminal navigator
- `hostinger` add Mail API connection operations
- `integrations` add portable JSON transfer and standalone import adapter
- `integrations` unify native users connections and source-aware execution
diff --git a/docs/INTEGRATIONS.md b/docs/INTEGRATIONS.md
index e770de71..6a2e79ea 100644
--- a/docs/INTEGRATIONS.md
+++ b/docs/INTEGRATIONS.md
@@ -80,7 +80,21 @@ setup. Opening an outer widget is not proof that its form or provider authorizat
## CLI
-Inspect methods before creating a connection:
+Run `mso integrations` with no arguments in a terminal for the interactive navigator. It uses the same searchable arrow-key picker as the rest of the MSO CLI, with breadcrumb-style context and Esc/back navigation:
+
+```text
+Integrations
+├─ Connections
+│ └─ Credential user → Provider → Named connection → Actions
+├─ Credential users
+├─ Provider catalog
+├─ Current folder
+└─ Import / export JSON
+```
+
+Creating a connection interactively walks through **source/backend → authentication method → label/ID**, then can open the private credential form. Existing connections expose Verify, Route, Make default, Rename, Delete, provider authorization, and a Hostinger Mail submenu when applicable. Secrets never enter the picker or CLI arguments.
+
+All explicit commands remain stable for scripts and agents. A non-TTY bare invocation returns the snapshot instead of waiting for keyboard input. Inspect methods or automate directly with:
```sh
mso integrations create-user rahman "Rahman"
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 07273d44..cac2c333 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -4,6 +4,12 @@ A real ChatGPT screenshot showed Play Together twice inside one MSO Page result
Inline height now derives from the host-provided `maxHeight` and is capped at 48%, with the Page body owning overflow instead of forcing 360–480 px iframe minimums. Fullscreen and PiP remain explicit controls and keep their prior full-host sizing. Browser coverage proves one reviewed child frame per Page document, one load for unchanged results, inline mode under half of an 800 px host fixture, explicit fullscreen/PiP capability advertisement, source/origin readiness checks, timeout/retry, and Google-auth external-link safeguards. MCP server 1.12.1 / toolset 2026.09.06.1 records the metadata contract change.
+## 2026-09-05 — Interactive Integrations CLI parity with the native connection model
+
+The native connection model was correct but its CLI still exposed mostly raw subcommands and JSON. Bare `mso integrations` now opens a searchable TTY navigator over the same owner API: credential user → provider → named connection → source/auth → action. Esc returns to the parent instead of terminating the workflow. User lifecycle, connection creation/default/rename/delete, private setup, Composio authorization, route/verify, folder resolution, portable transfer, and Hostinger Mail browsing are reachable without memorizing JSON payloads. Explicit subcommands remain unchanged for automation, and non-TTY callers get a snapshot rather than an interactive hang.
+
+The TUI stores no parallel state and never accepts credential values. All mutations still flow through the existing confirmed native management endpoint; credential entry remains the private browser form.
+
## 2026-09-05 — Reconcile new connection-model findings before final publication
## 2026-09-05 — Hostinger Mail API as a first-class connection capability
diff --git a/scripts/cli/commands.sh b/scripts/cli/commands.sh
index d5abf00f..711cead4 100755
--- a/scripts/cli/commands.sh
+++ b/scripts/cli/commands.sh
@@ -24,7 +24,7 @@ verbs() {
U_camoufox="camoufox status|start|stop|session"
U_gateway="gateway start [--config <cloudflared.yml> --tunnel <name|uuid>]|stop|status|url|doctor|install|domain show|set <https://host>|clear"
U_doctor="doctor [--fix]"
-U_integrations="integrations transfer|status|users|catalog|connections [user] [provider]|which [folder]|request|resolve <user> <provider> [connection]|create-user <id> [label]|create-connection <user> <provider> <id> <source> <auth>|manage <JSON>|setup|verify <user> <provider> <connection>|hostinger-mail-orders|hostinger-mail-list|hostinger-mail-logs|execute <JSON>"
+U_integrations="integrations [interactive]|transfer|status|users|catalog|connections [user] [provider]|which [folder]|request|resolve <user> <provider> [connection]|create-user <id> [label]|create-connection <user> <provider> <id> <source> <auth>|manage <JSON>|setup|verify <user> <provider> <connection>|hostinger-mail-orders|hostinger-mail-list|hostinger-mail-logs|execute <JSON>"
U_provider="provider list|show <id>|setup <provider> <user> <connection>|set <id>|rm <id>|doctor [id]|projects|zones"
U_model="model [current|list [provider]|set <provider> <model>|set <provider/model>|<model-or-ref>]"
U_agent="agent [--continue|-c|--resume|-r <latest|index|id|title>|--yolo|-yolo] | agent --oneshot <prompt> [--json] [--approve-scope read|write|exec]"
diff --git a/scripts/mso-cli-integrations-tui-remote.sh b/scripts/mso-cli-integrations-tui-remote.sh
new file mode 100644
index 00000000..3f5c8a68
--- /dev/null
+++ b/scripts/mso-cli-integrations-tui-remote.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+# External/Hostinger submenus for the interactive Integrations navigator.
+integration_tui_composio_authorize() {
+ local user="$1" provider="$2" connection="$3" broker config answer managed body out
+ tty_line "Composio project connection ID (blank = auto): " ""; broker="$REPLY"
+ tty_line "Auth config ID (blank = auto): " ""; config="$REPLY"
+ tty_line "Allow a managed OAuth config if none exists? [y/N]: " "n"; answer="${REPLY,,}"; managed=false; case "$answer" in y|yes) managed=true;; esac
+ body=$(jq -nc --arg user "$user" --arg provider "$provider" --arg connection "$connection" --arg broker "$broker" --arg config "$config" --argjson managed "$managed" '{mode:"manage",action:"connection.authorize",confirm:true,user:$user,provider:$provider,connection:$connection,createManaged:$managed} + (if $broker!="" then {brokerConnection:$broker} else {} end) + (if $config!="" then {authConfigId:$config} else {} end)')
+ out=$(integration_tui_manage "$body")
+ jq 'del(.privateUrl)' <<<"$out"
+ if jq -e '.privateUrl' >/dev/null 2>&1 <<<"$out"; then printf '\nOpen this private authorization URL:\n%s\n' "$(jq -r .privateUrl <<<"$out")"; fi
+ integration_tui_pause
+}
+integration_tui_hostinger_mail() {
+ local user="$1" connection="$2" choice order resource kind out args
+ while true; do
+ integration_tui_header "$user › Hostinger › $connection › Mail"
+ choice=$(cat <<'ROWS' | integration_tui_pick "Hostinger Mail" ""
+orders Mail orders list account mail orders
+mailboxes Mailboxes list mailboxes for an order
+aliases Aliases list aliases
+forwarders Forwarders list forwarders
+autoreplies Autoreplies list automatic replies
+catchalls Catch-alls list catch-all routes
+webhooks Webhooks list webhook metadata
+logs Mail logs access/action/inbound/mailbox/outbound
+__back ← Back connection
+ROWS
+) || return 0
+ [ "$choice" = __back ] && return 0
+ if [ "$choice" = orders ]; then
+ out=$(integration_tui_execute "$user" hostinger "$connection" hostinger.mail.orders.list '{}' true)
+ jq '.result' <<<"$out"; integration_tui_pause; continue
+ fi
+ tty_line "Mail order ID (blank uses scoped connection order): " ""; order="$REPLY"
+ if [ "$choice" = logs ]; then
+ kind=$(cat <<'ROWS' | integration_tui_pick "Mail log" ""
+access Access access events
+action Action action events
+inbound Inbound inbound mail
+mailbox-actions Mailbox actions mailbox mutations
+outbound Outbound outbound mail
+ROWS
+) || continue
+ args=$(jq -nc --arg order "$order" --arg kind "$kind" '{kind:$kind,page:1}+(if $order!="" then {orderId:$order} else {} end)')
+ out=$(integration_tui_execute "$user" hostinger "$connection" hostinger.mail.logs.list "$args" true)
+ else
+ resource="$choice"; args=$(jq -nc --arg order "$order" --arg resource "$resource" '{resource:$resource,page:1}+(if $order!="" then {orderId:$order} else {} end)')
+ out=$(integration_tui_execute "$user" hostinger "$connection" hostinger.mail.list "$args" true)
+ fi
+ jq '.result' <<<"$out"; integration_tui_pause
+ done
+}
diff --git a/scripts/mso-cli-integrations-tui.sh b/scripts/mso-cli-integrations-tui.sh
new file mode 100644
index 00000000..a50069d6
--- /dev/null
+++ b/scripts/mso-cli-integrations-tui.sh
@@ -0,0 +1,204 @@
+#!/usr/bin/env bash
+# Interactive native Integrations navigator. Metadata only: credential values still
+# enter through the private browser form opened by `mso integrations setup`.
+
+# shellcheck source=mso-cli-integrations-tui-remote.sh
+source "$ROOT/scripts/mso-cli-integrations-tui-remote.sh"
+integration_tui_pick() {
+ local title="$1" active="${2-}" choice
+ shift 2 || true
+ if choice=$(tui_select "$title" "$active"); then printf '%s' "$choice"; return 0; fi
+ return 1
+}
+integration_tui_pause() { tty_line "Press Enter to continue… " ""; }
+integration_tui_snapshot() {
+ local user="${1-}" query="view=snapshot"
+ [ -n "$user" ] && query="$query&user=$(enc "$user")"
+ jget "/api/v1/integrations?$query"
+}
+integration_tui_header() {
+ local path="$1"
+ printf '\n\033[1mMSO Integrations\033[0m \033[2m%s\033[0m\n' "$path" > /dev/tty
+}
+integration_tui_slug() {
+ printf '%s' "$1" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9._-]+/-/g;s/^-+//;s/-+$//' | cut -c1-64
+}
+integration_tui_manage() {
+ local body="$1" out
+ out=$(jpost "/api/v1/integrations" "$body")
+ printf '%s\n' "$out"
+}
+integration_tui_execute() {
+ local user="$1" provider="$2" connection="$3" operation="$4" args="${5:-{}}" confirm="${6:-false}" body
+ body=$(jq -nc --arg user "$user" --arg provider "$provider" --arg connection "$connection" --arg operation "$operation" --argjson args "$args" --argjson confirm "$confirm" '{mode:"execute",user:$user,provider:$provider,connection:$connection,operation:$operation,arguments:$args} + (if $confirm then {confirm:true} else {} end)')
+ jpost "/api/v1/integrations" "$body"
+}
+integration_tui_add_user() {
+ local id label body
+ tty_line "New credential user ID: " ""; id="$REPLY"; [ -n "$id" ] || return 0
+ tty_line "Display label [$id]: " "$id"; label="$REPLY"
+ body=$(jq -nc --arg user "$id" --arg label "$label" '{mode:"manage",action:"user.create",confirm:true,user:$user,label:$label}')
+ integration_tui_manage "$body" | jq '{ok,action,user}'
+ integration_tui_pause
+}
+integration_tui_user_actions() {
+ local user="$1" choice target label copy body answer
+ while true; do
+ integration_tui_header "Users › $user"
+ choice=$(cat <<'ROWS' | integration_tui_pick "User · actions" ""
+providers Connections & providers manage named accounts/deployments
+make-default Set as default user fallback when no folder mapping matches
+bind-folder Use for current folder longest folder mapping wins
+rename Rename user preserve connections and folder mappings
+duplicate Duplicate user metadata by default; credentials require opt-in
+delete Delete user destructive; exact confirmation required
+__back ← Back users
+ROWS
+) || return 0
+ case "$choice" in
+ __back) return 0 ;;
+ providers) integration_tui_provider_flow "$user" ;;
+ make-default)
+ body=$(jq -nc --arg user "$user" '{mode:"manage",action:"user.default",confirm:true,user:$user}')
+ integration_tui_manage "$body" | jq '{ok,action,user}'; integration_tui_pause ;;
+ bind-folder)
+ body=$(jq -nc --arg user "$user" --arg path "$PWD" '{mode:"manage",action:"folder.map",confirm:true,user:$user,path:$path}')
+ integration_tui_manage "$body" | jq '{ok,action,user,path}'; integration_tui_pause ;;
+ rename)
+ tty_line "New user ID: " "$user"; target="$REPLY"; [ "$target" != "$user" ] || continue
+ tty_line "Display label [$target]: " "$target"; label="$REPLY"
+ body=$(jq -nc --arg user "$user" --arg target "$target" --arg label "$label" '{mode:"manage",action:"user.rename",confirm:true,user:$user,target:$target,label:$label}')
+ integration_tui_manage "$body" | jq '{ok,action,user}'; user="$target"; integration_tui_pause ;;
+ duplicate)
+ tty_line "Duplicate as user ID: " "${user}-copy"; target="$REPLY"; [ -n "$target" ] || continue
+ tty_line "Display label [$target]: " "$target"; label="$REPLY"
+ tty_line "Copy direct credentials too? [y/N]: " "n"; answer="${REPLY,,}"; copy=false; case "$answer" in y|yes) copy=true;; esac
+ body=$(jq -nc --arg user "$user" --arg target "$target" --arg label "$label" --argjson copy "$copy" '{mode:"manage",action:"user.duplicate",confirm:true,user:$user,target:$target,label:$label,copyCredentials:$copy}')
+ integration_tui_manage "$body" | jq '{ok,action,user}'; integration_tui_pause ;;
+ delete)
+ tty_line "Type $user to delete this credential user: " ""; [ "$REPLY" = "$user" ] || { echo "Cancelled."; integration_tui_pause; continue; }
+ body=$(jq -nc --arg user "$user" '{mode:"manage",action:"user.delete",confirm:true,user:$user}')
+ integration_tui_manage "$body" | jq '{ok,action,user}'; integration_tui_pause; return 0 ;;
+ esac
+ done
+}
+integration_tui_users() {
+ local snap choice rows
+ while true; do
+ snap=$(integration_tui_snapshot)
+ rows=$(jq -r '.users[] | [.id,.label,((.connectionCount|tostring)+" connection(s)" + (if .isDefault then " · default" else "" end)),(if .isDefault then "current" else "" end)]|@tsv' <<<"$snap")
+ integration_tui_header "Users"
+ choice=$({ printf '%s\n' "$rows"; printf '__add\t+ Add user\tnew isolated credential owner\n__back\t← Back\tIntegrations\n'; } | integration_tui_pick "Credential users" "$(jq -r '.user // empty' <<<"$snap")") || return 0
+ case "$choice" in __back) return 0;; __add) integration_tui_add_user;; *) integration_tui_user_actions "$choice";; esac
+ done
+}
+integration_tui_browse_providers() {
+ local snap choice row
+ snap=$(integration_tui_snapshot)
+ while true; do
+ integration_tui_header "Providers"
+ choice=$({ jq -r '.catalog[]|[.id,.title,((.sources|length|tostring)+" source(s)"),""]|@tsv' <<<"$snap"; printf '__back\t← Back\tIntegrations\n'; } | integration_tui_pick "Provider catalog" "") || return 0
+ [ "$choice" = __back ] && return 0
+ row=$(jq -c --arg id "$choice" '.catalog[]|select(.id==$id)' <<<"$snap")
+ printf '\n%s — %s\n' "$(jq -r .title <<<"$row")" "$(jq -r .description <<<"$row")"
+ jq -r '.sources[] | " " + .label + "\n" + (.methods[] | " • " + .label + " · " + .scope)' <<<"$row"
+ integration_tui_pause
+ done
+}
+integration_tui_new_connection() {
+ local user="$1" provider="$2" snap source method label id idDefault body answer
+ snap=$(integration_tui_snapshot "$user")
+ integration_tui_header "$user › $provider › New connection"
+ source=$(jq -r --arg id "$provider" '.catalog[]|select(.id==$id)|.sources[]|[.id,.label,((.methods|length|tostring)+" auth method(s)"),""]|@tsv' <<<"$snap" | integration_tui_pick "Source / backend" "") || return 0
+ method=$(jq -r --arg p "$provider" --arg s "$source" '.catalog[]|select(.id==$p)|.sources[]|select(.id==$s)|.methods[]|[.id,.label,(.scope+" · "+((.fields|length|tostring))+" field(s)"),""]|@tsv' <<<"$snap" | integration_tui_pick "Authentication" "") || return 0
+ tty_line "Connection label: " "$provider"; label="$REPLY"; [ -n "$label" ] || return 0
+ idDefault=$(integration_tui_slug "$label"); [ -n "$idDefault" ] || idDefault=connection
+ tty_line "Connection ID [$idDefault]: " "$idDefault"; id="$REPLY"
+ body=$(jq -nc --arg user "$user" --arg provider "$provider" --arg connection "$id" --arg label "$label" --arg source "$source" --arg method "$method" '{mode:"manage",action:"connection.create",confirm:true,user:$user,provider:$provider,connection:$connection,label:$label,source:$source,authMethod:$method}')
+ integration_tui_manage "$body" | jq '{ok,action,connection:(.connection|{id,label,provider,source,authMethod,scope,state,isDefault})}'
+ if [ "$source" = direct ]; then
+ tty_line "Open secure credential form now? [Y/n]: " "y"; answer="${REPLY,,}"
+ case "$answer" in n|no) ;; *) run_integrations setup "$user" "$provider" "$id";; esac
+ fi
+ integration_tui_pause
+}
+integration_tui_connection() {
+ local user="$1" provider="$2" connection="$3" choice snap row source isDefault body label confirm out
+ while true; do
+ snap=$(integration_tui_snapshot "$user")
+ row=$(jq -c --arg p "$provider" --arg c "$connection" '.connections[]|select(.provider==$p and .id==$c)' <<<"$snap")
+ [ -n "$row" ] || return 0
+ source=$(jq -r .source <<<"$row"); isDefault=$(jq -r '.isDefault//false' <<<"$row")
+ integration_tui_header "$user › $provider › $(jq -r .label <<<"$row")"
+ choice=$({
+ [ "$source" = direct ] && printf 'setup\tSet / rotate credentials\tprivate browser form\n'
+ [ "$source" = composio ] && printf 'authorize\tAuthorize account\tComposio hosted authorization\n'
+ printf 'verify\tVerify\tlive API/auth status\nroute\tRoute\tshow exact execution identity\n'
+ [ "$isDefault" != true ] && printf 'default\tMake default\tprovider fallback for this user\n'
+ [ "$provider" = hostinger ] && [ "$source" = direct ] && printf 'mail\tHostinger Mail\torders, mailboxes, aliases, logs…\n'
+ printf 'rename\tRename label\tmetadata only\ndelete\tDelete connection\tdestructive; exact confirmation\n__back\t← Back\tprovider\n'
+ } | integration_tui_pick "Connection actions" "") || return 0
+ case "$choice" in
+ __back) return 0 ;;
+ setup) run_integrations setup "$user" "$provider" "$connection"; integration_tui_pause ;;
+ authorize) integration_tui_composio_authorize "$user" "$provider" "$connection" ;;
+ verify) out=$(integration_tui_execute "$user" "$provider" "$connection" verify '{}' false); jq '{ok,detail,id,user,connection}' <<<"$out"; integration_tui_pause ;;
+ route) out=$(integration_tui_execute "$user" "$provider" "$connection" route '{}' false); jq '.' <<<"$out"; integration_tui_pause ;;
+ default) body=$(jq -nc --arg user "$user" --arg provider "$provider" --arg connection "$connection" '{mode:"manage",action:"connection.default",confirm:true,user:$user,provider:$provider,connection:$connection}'); integration_tui_manage "$body" | jq '{ok,action,connection:(.connection|{id,label,isDefault})}'; integration_tui_pause ;;
+ mail) integration_tui_hostinger_mail "$user" "$connection" ;;
+ rename) tty_line "New label: " "$(jq -r .label <<<"$row")"; label="$REPLY"; body=$(jq -nc --arg user "$user" --arg provider "$provider" --arg connection "$connection" --arg label "$label" '{mode:"manage",action:"connection.rename",confirm:true,user:$user,provider:$provider,connection:$connection,label:$label}'); integration_tui_manage "$body" | jq '{ok,action,connection:(.connection|{id,label})}'; integration_tui_pause ;;
+ delete) tty_line "Type $connection to delete this connection: " ""; confirm="$REPLY"; [ "$confirm" = "$connection" ] || { echo 'Cancelled.'; integration_tui_pause; continue; }; body=$(jq -nc --arg user "$user" --arg provider "$provider" --arg connection "$connection" '{mode:"manage",action:"connection.delete",confirm:true,user:$user,provider:$provider,connection:$connection}'); integration_tui_manage "$body" | jq '{ok,action,user,provider,connection}'; integration_tui_pause; return 0 ;;
+ esac
+ done
+}
+integration_tui_provider_flow() {
+ local user="$1" snap provider choice rows count title
+ while true; do
+ snap=$(integration_tui_snapshot "$user")
+ integration_tui_header "$user › Providers"
+ provider=$({ jq -r --arg u "$user" '.catalog[] as $p | [$p.id,$p.title,(([.connections[]|select(.provider==$p.id)]|length|tostring)+" connection(s)"),""]|@tsv' <<<"$snap"; printf '__back\t← Back\tuser\n'; } | integration_tui_pick "Providers" "") || return 0
+ [ "$provider" = __back ] && return 0
+ while true; do
+ snap=$(integration_tui_snapshot "$user")
+ title=$(jq -r --arg id "$provider" '.catalog[]|select(.id==$id)|.title' <<<"$snap")
+ rows=$(jq -r --arg p "$provider" '.connections[]|select(.provider==$p)|[.id,.label,(.source+" · "+.authMethod+" · "+.state+(if .isDefault then " · default" else "" end)),(if .isDefault then "current" else "" end)]|@tsv' <<<"$snap")
+ integration_tui_header "$user › $title"
+ choice=$({ printf '%s\n' "$rows"; printf '__new\t+ New connection\tchoose source/backend and auth\n__back\t← Back\tproviders\n'; } | integration_tui_pick "$title · connections" "") || break
+ case "$choice" in __back) break;; __new) integration_tui_new_connection "$user" "$provider";; *) integration_tui_connection "$user" "$provider" "$choice";; esac
+ done
+ done
+}
+integration_tui_connections() {
+ local snap choice rows
+ while true; do
+ snap=$(integration_tui_snapshot)
+ rows=$(jq -r '.users[]|[.id,.label,((.connectionCount|tostring)+" connection(s)"+(if .isDefault then " · default" else "" end)),(if .isDefault then "current" else "" end)]|@tsv' <<<"$snap")
+ integration_tui_header "Connections"
+ choice=$({ printf '%s\n' "$rows"; printf '__add\t+ Add user\tcreate credential owner first\n__back\t← Back\tIntegrations\n'; } | integration_tui_pick "Choose credential user" "$(jq -r '.user // empty' <<<"$snap")") || return 0
+ case "$choice" in __back) return 0;; __add) integration_tui_add_user;; *) integration_tui_provider_flow "$choice";; esac
+ done
+}
+integrations_tui() {
+ local choice out
+ tty_ok || { jget "/api/v1/integrations?view=snapshot"; return; }
+ while true; do
+ integration_tui_header "Home"
+ choice=$(cat <<'ROWS' | integration_tui_pick "Integrations" ""
+connections Connections User → Provider → Connection → Source → Auth
+users Credential users isolated account owners
+providers Provider catalog sources, auth methods and scope
+current Current folder show resolved credential user/bindings
+transfer Import / export JSON portable metadata or encrypted direct credentials
+quit Quit return to shell
+ROWS
+) || return 0
+ case "$choice" in
+ connections) integration_tui_connections ;;
+ users) integration_tui_users ;;
+ providers) integration_tui_browse_providers ;;
+ current) out=$(jget "/api/v1/integrations?view=which&cwd=$(enc "$PWD")"); jq '{user,resolution,bindings}' <<<"$out"; integration_tui_pause ;;
+ transfer) run_integrations transfer; integration_tui_pause ;;
+ quit) return 0 ;;
+ esac
+ done
+}
diff --git a/scripts/mso-cli-integrations-tui.test.ts b/scripts/mso-cli-integrations-tui.test.ts
new file mode 100644
index 00000000..5bfb79db
--- /dev/null
+++ b/scripts/mso-cli-integrations-tui.test.ts
@@ -0,0 +1,8 @@
+import {execFileSync} from "node:child_process";
+import {mkdtempSync,writeFileSync,readFileSync} from "node:fs";
+import os from "node:os";import path from "node:path";import {expect,it} from "vitest";
+const script=path.join(__dirname,"test-support/integrations-cli-tui-harness.sh");
+function runTui(choices:string[],prompts:string[]=[]){const dir=mkdtempSync(path.join(os.tmpdir(),"mso-integrations-tui-")),choice=path.join(dir,"choices"),prompt=path.join(dir,"prompts"),log=path.join(dir,"log");writeFileSync(choice,choices.join("\n")+"\n");writeFileSync(prompt,prompts.join("\n")+"\n");writeFileSync(log,"");execFileSync("bash",[script],{encoding:"utf8",env:{...process.env,MSO_TUI_CHOICES:choice,MSO_TUI_PROMPTS:prompt,MSO_TUI_LOG:log}});return readFileSync(log,"utf8").split("\n").filter(Boolean).map(line=>JSON.parse(line.split("\t").slice(1).join("\t")));}
+it("interactive hierarchy creates a named connection through the same manage API",()=>{const calls=runTui(["connections","alice","github","__new","direct","direct","__back","__back","__back","quit"],["Work GitHub","work","n"]);expect(calls).toContainEqual(expect.objectContaining({mode:"manage",action:"connection.create",confirm:true,user:"alice",provider:"github",connection:"work",source:"direct",authMethod:"direct"}));});
+it("interactive connection actions rename, set default and delete only the selected identity",()=>{const calls=runTui(["connections","alice","github","work","rename","default","delete","__back","__back","__back","quit"],["Renamed","work"]);expect(calls.map(x=>x.action).filter(Boolean)).toEqual(expect.arrayContaining(["connection.rename","connection.default","connection.delete"]));expect(calls.filter(x=>x.action?.startsWith("connection.")).every(x=>x.user==="alice"&&x.provider==="github"&&x.connection==="work")).toBe(true);});
+it("picker cancellation returns to its parent instead of killing the command",()=>{expect(()=>runTui(["connections","__ESC__","quit"])).not.toThrow();});
diff --git a/scripts/mso-cli-integrations.sh b/scripts/mso-cli-integrations.sh
index deb1eafd..fca44793 100644
--- a/scripts/mso-cli-integrations.sh
+++ b/scripts/mso-cli-integrations.sh
@@ -1,7 +1,13 @@
#!/usr/bin/env bash
# Native connection management. All actions use the same owner API as the browser.
+# shellcheck source=mso-cli-integrations-tui.sh
+source "$ROOT/scripts/mso-cli-integrations-tui.sh"
run_integrations() {
- local sub="${1:-status}" data user provider connection query body
+ if [ $# -eq 0 ]; then
+ if tty_ok && [ -t 0 ] && [ -t 1 ]; then integrations_tui; else jget "/api/v1/integrations?view=snapshot"; fi
+ return
+ fi
+ local sub="$1" data user provider connection query body
shift || true
case "$sub" in
transfer) data=$(jget "/api/v1/integrations/transfer"); printf "Open the owner-only JSON transfer page in your browser:\n%s\n" "$(jq -r .url <<<"$data")" ;;
diff --git a/scripts/mso-cli-integrations.test.ts b/scripts/mso-cli-integrations.test.ts
index 49eadc55..ceb6b12d 100644
--- a/scripts/mso-cli-integrations.test.ts
+++ b/scripts/mso-cli-integrations.test.ts
@@ -16,3 +16,5 @@ it("requires explicit metadata mutation confirmation and carries folder context"
expect(JSON.parse(run(["manage",JSON.stringify({action:"user.default",user:"alice",confirm:true})]))).toMatchObject({mode:"manage",confirm:true});
expect(run(["which","/home/test/project"])).toContain("view=which&cwd=/home/test/project");
});
+
+it("bare non-interactive integrations remains machine-safe and does not wait for a TTY",()=>{expect(run([])).toContain("view=snapshot")});
diff --git a/scripts/test-support/integrations-cli-tui-harness.sh b/scripts/test-support/integrations-cli-tui-harness.sh
new file mode 100755
index 00000000..c62b6396
--- /dev/null
+++ b/scripts/test-support/integrations-cli-tui-harness.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+set -euo pipefail
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+source "$ROOT/scripts/mso-cli-integrations.sh"
+: "${MSO_TUI_CHOICES:?choices file required}" "${MSO_TUI_PROMPTS:?prompts file required}" "${MSO_TUI_LOG:?log file required}"
+tty_ok(){ return 0; }
+integration_tui_header(){ :; }
+integration_tui_pause(){ :; }
+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"; }
+tui_select(){ local _title="$1" _active="${2-}" value; cat >/dev/null; value=$(pop_line "$MSO_TUI_CHOICES"); [ "$value" != __ESC__ ] || return 130; [ -n "$value" ] || return 130; printf '%s' "$value"; }
+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":1}],"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,"action":"connection.create","connection":{"id":"work","label":"Work GitHub","provider":"github","source":"direct","authMethod":"direct","scope":"account","state":"configured","isDefault":false}}' ;; connection.rename|connection.default|connection.delete|user.default|folder.map|user.create|user.rename|user.duplicate|user.delete) printf '%s' '{"ok":true,"action":"ok","user":"alice","provider":"github","connection":{"id":"work","label":"Renamed","isDefault":true}}' ;; verify) printf '%s' '{"id":"github","ok":true,"detail":"verified"}' ;; route) printf '%s' '{"user":"alice","id":"work","source":"direct","execution":{"route":"native-direct"}}' ;; hostinger.mail.orders.list) printf '%s' '{"result":{"data":[]}}' ;; *) printf '%s' '{}' ;; esac; }
+if [ "$#" -eq 0 ]; then integrations_tui; else run_integrations "$@"; fi