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.

9.4 KB
Raw Blame
#!/usr/bin/env bash
# User-facing command usage + dispatch. Sourced by bin/mso.
# shellcheck source=help.sh
source "$ROOT/scripts/cli/help.sh"

# Every verb the dispatch table implements, one per line, aliases split out. Read
# from the table itself so a new arm can never be missing from did-you-mean.
MSO_CLI_VERB_FILES=(
  "$ROOT/scripts/cli/commands-host.sh"
  "$ROOT/scripts/cli/commands-runtime.sh"
  "$ROOT/scripts/cli/commands-state.sh"
  "$ROOT/scripts/cli/commands-admin.sh"
)
verbs() {
  awk 'match($0, /^  [a-zA-Z|-]+\)/) {
         s = substr($0, 3, RLENGTH - 3); gsub(/\|/, "\n", s); print s
       }' "${MSO_CLI_VERB_FILES[@]}"
}

# One usage string per command group, used by BOTH `--help` and the error path —
# so the help you get when you ask cannot disagree with the help you get when
# you're wrong.
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_domain="domain status|setup --user <user> --connection <cloudflare-connection> [--origin <https://host>] [--template <{id}.host>] [--zone <name|id>] [--tunnel <UUID>] [--local <http://loopback:port>] [--manual] [--apply]|ensure <id> [--apply]|doctor <id>|repair-env [--apply]|restore [--apply]"
U_doctor="doctor [--fix] [--json]"
U_pair="pair [--json]"
U_flow="flow list|inspect <id> [--project <project>]|run <id> --input <JSON|@file> --key <id> [--wait]|status <run-id> [--wait]|save|delete <id> --revision <revision> [--input <JSON|@file>]"
U_workflow="workflow list|embeds|embed-save --input <JSON|@file>|show <id>|create --input <JSON|@file>|save <id> --revision <revision> --input <JSON|@file>|clone <id>|delete <id> --revision <revision>|run <id> --input <JSON|@file> --key <id> [--wait]|status <run-id> [--wait]|runs <id>|versions <id>|restore <id> --revision <current> --version <saved>|catalog [--query q]|templates|template <id>|variables|variable-set <KEY> --input <JSON> [--secret]|variable-delete <KEY>|ai --prompt <text>"
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_channels="channels list|create --input <JSON|@file>|save <id> --revision <n> --input <JSON|@file>|delete <id> --revision <n>|test <id>|send <id> --text <message> [--target <id>]"
U_agent_groups="agent-groups list|show <id>|create --input <JSON|@file>|save <id> --revision <n> --input <JSON|@file>|delete <id> --revision <n>|run <id> --prompt <text> [--members <ids>]|stop <run-id>"
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]"
U_mapp="mapp enable <id> [install-key=value...]|start|stop|restart <id>|catalog|shell-list|shell-save <JSON|@file>|shell-domain <id>|shell-domain-save <id> <JSON|@file>|list|show|logs|backups|jobs|job <id> <jobId>|pending <id>|install|update|power <id> <act>|cancel <id> <jobId>"
U_term="term open [cwd] [cols] [rows]|input <id> <text>|resize <id> <cols> <rows>|stream <id>|close <id>"
U_device="device list|pending|approve <id> [label] [--role viewer|operator|owner]|role <id> <role>|revoke <id>|revoke all --yes"
U_service="service status|start|stop|restart|logs [n]"
U_stats="stats [--json] | stats --usage [--days N] [--json] [--models]"
U_run="run <prompt…> [--json] [--file <path>] [--thinking] [--approve-scope read|write|exec] [--continue|-c|--resume <ref>]"
U_session="session list [limit]|show [id|name|latest]|export [id|name|latest] [--out <file>]|import <file|-> [--title <title>]"
U_unit="unit logs <system|user> <unit> [limit]|start|stop|restart <system|user> <unit>"
U_reset="reset [--scope config|all] [--json] [--apply --confirm <preview-token>]"
U_uninstall="uninstall [--purge] [--remove-code] [--service name.service] [--json] [--apply --confirm <preview-token>]"
U_update="update [--rebuild] | status | reconcile | log | --auto on|off | --channel stable|main"
U_cockpit="cockpit [project] | cockpit show [project] | cockpit search <query…>"
U_threads="threads list|show <id>|save <json>|rename <json>|rm <id>"
U_agent_sessions="agent-sessions list [limit]|show <id>|create [title]"
U_agent_profiles="agent-profiles list|create|edit|clone|default|enable|disable <JSON|@file>|run <JSON|@file>"
U_agents="agents list [current-session-id]|send <source-session-id> <target> <message> [message|task]|inbox <session-id> [--all]"
U_org="org flow-custom-nodes|flow-nodes-move|flow-update|flow-replace|flow-node-upsert|flow-node-delete|flow-edge-upsert|flow-edge-delete <revision> <JSON with unitId|@file>|show|unit-upsert <revision> <JSON|@file>|seat-upsert <revision> <JSON|@file>|unit-delete <revision> <id>|seat-delete <revision> <id>|replace <revision> <JSON|@file>"
U_a2a="a2a list|state|sessions|spawn <source-session> <objective> [title]|inbox <session>|discover <url>|add <url> [alias]|rm <target>|send <target> <message> [--wait]|stream <target> <message>|task <target> <taskId> [history]|cancel <target> <taskId>|handoff <target> <objective> [context] [--wait]|local sessions|local handoff <session> <objective>|local spawn <sourceSession> <objective> [title]|local inbox <session>|trace <start|progress|plan|action|evidence|blocker|result|handoff|status|context|attach|finish|cancel|list> [...]|auth list [target]|auth add <target> [label] [bearer|api-key|oauth2]|auth use <target> <credentialId|none>|auth rm <credentialId>|inbound list|inbound create [label] [read|write|exec]|inbound rm <tokenId>"
U_memory="memory list|add <text>|rm <id>"
U_memory_graph="memory-graph [project]"
U_agent_vault="agent-vault show|sync [project]|read <project> <note-path>"
U_config="config show|set <json>|key <provider>|style <off|caveman|ponytail>|rm <provider>"
U_prefs="prefs show|set <json>"
U_federation="federation status"
U_models="models [status|list [provider]|add <provider> [--api-key <key>] [--type api-key|oauth]|auth <provider>|rm <provider>|catalog [provider]|test]"
U_jev="jev status|decide <model.route|failure.triage|recipe.promote> [JSON|@file]|request <JSON|@file>"
U_skills="skills list|read <id>|search <query…>|available|info <id>|install <id…> [-y] [--force]|remove <id…> [-y]|store list|store install|remove <id> <revision>"
U_mcp="mcp project <JSON>|list|pat <label> [read|write|exec] [ttlDays]|activity [n]|service-token --label <label> --client-id <id> --scope <read|write|exec> --tools <name,name> [--constraints-json <json>]|revoke <id>|revoke all"
U_oauth="oauth <provider> start|poll   OAuth currently: openai (ChatGPT Codex)"
U_completion="completion [bash|zsh|fish|sh]"
# Command families are sourced here so bin/mso remains only bootstrap + entrypoint.
# shellcheck source=agent-run.sh
source "$ROOT/scripts/cli/agent-run.sh"
# shellcheck source=commands-host.sh
source "$ROOT/scripts/cli/commands-host.sh"
# shellcheck source=commands-runtime.sh
source "$ROOT/scripts/cli/commands-runtime.sh"
# shellcheck source=commands-state.sh
source "$ROOT/scripts/cli/commands-state.sh"
# shellcheck source=commands-admin.sh
source "$ROOT/scripts/cli/commands-admin.sh"

mso_cli_unknown() {
  local cmd="$1" head3 near
  echo "mso: unknown command '$cmd'" >&2
  head3="${cmd:0:3}"
  near=$(verbs | while read -r v; do
    case "$v" in
      "$cmd"*|*"$cmd"*|"$head3"*) echo "  $v" ;;
    esac
  done)
  [ -n "$near" ] && { echo "did you mean:" >&2; echo "$near" >&2; }
  echo >&2; usage >&2; exit 1
}

mso_cli_main() {
  if [ "${1-}" = domain ] && { [ "${2-}" = help ] || [ "${2-}" = --help ] || [ "${2-}" = -h ]; }; then mso_cmd_runtime domain help; return; fi
  if [ $# -ge 2 ]; then
    case "$2" in
      -h|--help|help)
        # Hyphenated verbs (`memory-graph`) map to U_memory_graph. A raw
        # ${U_memory-graph} expansion is the unrelated `memory` usage string.
        local help_key="${1//-/_}"
        eval "u=\${U_${help_key}-}"
        [ -n "${u-}" ] && { echo "usage: mso $u"; exit 0; }
        usage | grep -E "^ +$1( |$)" || usage
        exit 0 ;;
    esac
  fi

  local cmd="${1:-agent}"
  maybe_update_notice "$cmd"
  shift || true
  if [ "$cmd" = agent ] || [ "$cmd" = chat ]; then set -- "${AGENT_START_ARGS[@]}" "$@"; fi

  case "$cmd" in
    version|--version|-V|-v|ls|cat|raw|share|usage|search|project-candidates|write|mkdir|rm|mv|cp|zip|upload|exec|stats|ps|units|unit|packages|cleanup|status|health|doctor)
      mso_cmd_host "$cmd" "$@" ;;
    agent|chat|model|setup|onboard|provider|providers|integrations|channels|agent-groups|flow|workflow|gateway|domain|heartbeat|web|camoufox|apps|mapp|term|run|session)
      mso_cmd_runtime "$cmd" "$@" ;;
    ai|cockpit|threads|agent-sessions|agent-profiles|agents|org|a2a|memory|memory-graph|agent-vault|config|prefs|federation|models|jev|skills|changelog|stock)
      mso_cmd_state "$cmd" "$@" ;;
    devices|device|approve|revoke|oauth|mcp|audit|whoami|login|logout|passwd|service|build|deploy|update|reset|uninstall|crud|api|completion|pair)
      mso_cmd_admin "$cmd" "$@" ;;
    help|-h|--help) usage; exit 0 ;;
    *) mso_cli_unknown "$cmd" ;;
  esac
  echo
}