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.

3.6 KB
Raw Blame
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
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; }
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; }
if [ "$#" -eq 0 ];then integrations_tui;else run_integrations "$@";fi