diff --git a/bin/omarchy-install-ai-hermes b/bin/omarchy-install-ai-hermes index 8a87420d52ee..6293bbcc331a 100755 --- a/bin/omarchy-install-ai-hermes +++ b/bin/omarchy-install-ai-hermes @@ -1,6 +1,8 @@ #!/bin/bash # omarchy:summary=Install the Hermes desktop app +# omarchy:args=[--local|--remote] +# omarchy:examples=omarchy install ai hermes --local | omarchy install ai hermes --remote # omarchy:requires-sudo=true set -e @@ -10,8 +12,46 @@ if (( EUID == 0 )); then exit 1 fi -# The same install the default agent gets, plus opening the window. -omarchy-install-hermes-cli --now +if (( $# > 1 )); then + echo "Usage: omarchy-install-ai-hermes [--local|--remote]" >&2 + exit 1 +fi + +mode=${1:-} +case "$mode" in +"") + if [[ ! -t 0 ]]; then + echo "Choose --local to set up Hermes here, or --remote to connect Desktop to an existing Hermes." >&2 + exit 1 + fi + local_option=$(omarchy-i18n hermes.installLocal) + remote_option=$(omarchy-i18n hermes.installRemote) + choice=$(gum choose --header "$(omarchy-i18n hermes.installMode)" "$local_option" "$remote_option") || exit 0 + case "$choice" in + "$local_option") mode=--local ;; + "$remote_option") mode=--remote ;; + *) exit 0 ;; + esac + ;; +--local | --remote) ;; +*) + echo "Usage: omarchy-install-ai-hermes [--local|--remote]" >&2 + exit 1 + ;; +esac + +if [[ $mode == "--local" ]]; then + # The same install the default agent gets, plus opening the window. + omarchy-install-hermes-cli --now +else + # The packaged Electron app has its own first-run remote connection form. + # Do not bootstrap a host runtime, replace CLI commands, retire mise, or + # start a theme waiter that would need a local gateway to finish. + omarchy-pkg-add hermes-desktop + echo "Choose 'Connect to existing Hermes' in Desktop's first-run screen." + echo "If Desktop is already set up, add your existing gateway in Settings > Gateways." + echo "No local runtime or gateway is set up by this installation; existing ones are left alone." +fi echo "Opening Hermes Desktop..." setsid uwsm-app -- /usr/bin/hermes-desktop >/dev/null 2>&1 & diff --git a/bin/omarchy-install-hermes-cli b/bin/omarchy-install-hermes-cli index a5acd0fe7c81..e54e678211dd 100755 --- a/bin/omarchy-install-hermes-cli +++ b/bin/omarchy-install-hermes-cli @@ -5,13 +5,14 @@ # omarchy:examples=omarchy install hermes cli --now | omarchy install hermes cli --check # omarchy:requires-sudo=true -# There is one Hermes on a machine, and it is the desktop app's. hermes-desktop +# For local use, Hermes is the desktop app's runtime. hermes-desktop # ships upstream's installer and the release it was built from, and that # installer makes the only Hermes that can update itself: a checkout under # ~/.hermes with its own venv, which `hermes update` fast-forwards. The mise # build this replaced had no checkout, so nothing an update could move. # Choosing Hermes as the default agent therefore installs the app, the way -# Install > AI does, short of opening its window; see omarchy-install-ai-hermes. +# Install > AI's local choice does, short of opening its window; see +# omarchy-install-ai-hermes. Its remote-only choice does not call this installer. # Hermes is only ever installed through the app: --check asks whether the # app's Hermes is in and its command is what omarchy-agent would run, and # --now installs the app whatever else answered to hermes before, saving diff --git a/default/i18n/en/cli.json b/default/i18n/en/cli.json index 5e83d3a4b19a..904fc38cec3a 100644 --- a/default/i18n/en/cli.json +++ b/default/i18n/en/cli.json @@ -104,6 +104,9 @@ "gpu.enableDedicated": "Enable dedicated GPU and reboot?", "gpu.useIntegrated": "Use only integrated GPU and reboot?", "hermes.deleteData": "Also delete ~/.hermes and ~/.config/Hermes (%1: chats, memories, skills, connections and tokens)?", + "hermes.installLocal": "Set up Hermes on this computer", + "hermes.installMode": "How do you want to use Hermes Desktop?", + "hermes.installRemote": "Connect to existing Hermes", "input.touchpadDisabled": "Touchpad disabled", "input.touchpadEnabled": "Touchpad enabled", "input.touchscreenDisabled": "Touchscreen disabled", diff --git a/manual/17-ai.md b/manual/17-ai.md index 0eba2b148e5a..bfd47e2461d3 100644 --- a/manual/17-ai.md +++ b/manual/17-ai.md @@ -71,7 +71,11 @@ Crashes can also be silenced one program at a time, which is what the diagnosis The _Install > AI_ menu also carries a few graphical AI apps: the ChatGPT desktop app, the Claude desktop app (Anthropic's Linux beta, with Chat, Cowork, and Claude Code tabs), Grok Bot for chatting with xAI's models, Hermes Desktop, OpenClaw, and the Perplexity desktop app. Grok Bot is the desktop chat app. The coding agent is the `grok` command. -Hermes Desktop is the one to know about, because a machine has one Hermes, and it is the app's: Hermes is only ever installed through the app, and the `hermes` command the default agent runs is the app's. Choosing Hermes as the default agent installs the same thing the _Install > AI_ entry does: the package, and a Hermes runtime under `~/.hermes` set up by Hermes' own installer, which takes a few minutes the first time. That runtime is the one Hermes the terminal `hermes` command, the default agent and the app all use, and it updates itself with `hermes update` rather than waiting on an Omarchy release. Installing it also hands Hermes the Omarchy theme as a skin named `omarchy`, which every Hermes surface follows as you switch themes; pick another under Hermes' Appearance settings or with `/skin` if you'd rather it didn't, and Omarchy leaves that choice alone. Removing the app under _Remove > AI_ closes Hermes first, gateway included, takes that runtime with it, and keeps your chats, memories, and the skills Hermes wrote for itself unless you tell it otherwise: it asks, defaulting to no, whether that data and your connection settings should go too. +Installing Hermes Desktop under _Install > AI_ asks whether to **Set up Hermes on this computer** or **Connect to existing Hermes**. Choose the latter if your agent already runs in Docker or on another machine: Omarchy installs the desktop app without provisioning a local runtime, replacing your terminal commands, or starting a local gateway. In Desktop's first-run screen, choose **Connect to existing Hermes** and enter your gateway's dashboard URL and authentication details; for a Docker dashboard published on this computer, that might be `http://localhost:9119`. If Desktop is already configured, add and select the gateway under **Settings > Gateways** (called **Connections** in older builds). Existing local installations are left alone, and selecting a local profile in Desktop can still start a local agent. The remote agent keeps its own theme and lifecycle; closing Desktop does not stop it. Use `omarchy install ai hermes --remote` to install this way without the question. + +Choosing **Set up Hermes on this computer**, or choosing Hermes as the default terminal agent, installs the package and a Hermes runtime under `~/.hermes` set up by Hermes' own installer, which takes a few minutes the first time. That runtime is the one the terminal `hermes` command, the default agent and the local desktop connection all use, and it updates itself with `hermes update` rather than waiting on an Omarchy release. Installing it also hands Hermes the Omarchy theme as a skin named `omarchy`, which every local Hermes surface follows as you switch themes; pick another under Hermes' Appearance settings or with `/skin` if you'd rather it didn't, and Omarchy leaves that choice alone. Use `omarchy install ai hermes --local` to choose this path without the question, including after a remote-only installation. + +Removing the app under _Remove > AI_ closes local Hermes processes first, gateway included, takes its installed local runtime with it if present, and keeps your chats, memories, and skills unless you tell it otherwise: it asks, defaulting to no, whether that data and your connection settings should go too. It does not stop or remove an agent running in Docker or on another machine. OpenClaw's desktop experience is its Control UI, which opens as a web app backed by its own local gateway. OpenClaw lives in `~/.openclaw` and updates itself: use the Control UI's "Update Gateway" button or run `openclaw update`, and the gateway restarts on the new version. Omarchy only chooses the release a fresh install starts from. Removing OpenClaw under _Remove > AI_ takes the gateway service and the app with it and then asks whether `~/.openclaw` should go too, since that holds your chats and credentials alongside OpenClaw itself and the plugin runtimes it downloads; the default keeps it, and installing OpenClaw again picks it back up. diff --git a/test/shell.d/hermes-desktop-install-test.sh b/test/shell.d/hermes-desktop-install-test.sh index 41b1694a8e27..127d9fb05c65 100644 --- a/test/shell.d/hermes-desktop-install-test.sh +++ b/test/shell.d/hermes-desktop-install-test.sh @@ -235,7 +235,7 @@ new_home() { # before anything is asserted; one that stopped earlier started nothing. run_installer() { HOME="$test_home" HERMES_HOME="${OMARCHY_TEST_HOME:-$hermes_home}" PATH="$test_tmp/bin:$test_home/.local/bin:$PATH" npm_config_yes= \ - bash "$test_tmp/installer" >"$test_tmp/output" 2>&1 || return + bash "$test_tmp/installer" "${1:---local}" >"$test_tmp/output" 2>&1 || return for (( attempt=0; attempt<200; attempt++ )); do if grep -q '^launch' "$test_tmp/events"; then return 0; fi sleep 0.01 @@ -700,3 +700,13 @@ run_installer || fail "setup supports the relocated desktop helper" "$(cat "$tes [[ $(cat "$hermes_home/desktop-build-stamp.json") == 'upstream build stamp' ]] || fail "relocated helper writes the build stamp" grep -qx launch "$test_tmp/events" || fail "setup launches after the relocated helper writes the stamp" pass "new releases use the relocated desktop stamp writer" + +new_home remote-to-local +run_installer --remote || fail "remote-only installation succeeds before local setup" "$(cat "$test_tmp/output")" +[[ $(cat "$test_tmp/events") == $'package hermes-desktop\nlaunch-before-copy' ]] || fail "remote-only setup opens the package without seeding a runtime" "$(cat "$test_tmp/events")" +[[ ! -e $runtime && ! -e $test_home/.local/bin/hermes ]] || fail "remote-only setup leaves no runtime or CLI" +: >"$test_tmp/events" +run_installer || fail "a remote-only installation can later set up a local runtime" "$(cat "$test_tmp/output")" +[[ $(cat "$test_tmp/events") == $'bootstrap\nbuild-stamp\ntheme-stop\ntheme-start\nlaunch' ]] || fail "later local setup uses the existing package and performs the full runtime setup" "$(cat "$test_tmp/events")" +run_cli --check || fail "the later local setup is ready for the default terminal agent" +pass "a remote-only desktop can later provision the same local runtime as the default agent" diff --git a/test/shell.d/hermes-desktop-remote-test.sh b/test/shell.d/hermes-desktop-remote-test.sh new file mode 100755 index 000000000000..90cc519f6afc --- /dev/null +++ b/test/shell.d/hermes-desktop-remote-test.sh @@ -0,0 +1,189 @@ +#!/bin/bash + +set -euo pipefail + +source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" + +for command in python3 script; do require_command "$command"; done + +test_tmp=$(mktemp -d) +trap 'rm -rf -- "$test_tmp"' EXIT +export OMARCHY_TEST_ROOT="$test_tmp" +export OMARCHY_PATH="$ROOT" +mkdir -p "$test_tmp/bin" + +# Exercise the real installer with package, service and app entry points replaced. +# No test installs software or opens the user's Desktop or Docker service. +python3 - "$ROOT" "$test_tmp" <<'PY' +from pathlib import Path +import sys +root, scratch = map(Path, sys.argv[1:]) +script = (root / 'bin/omarchy-install-ai-hermes').read_text() +script = script.replace('/usr/bin/hermes-desktop', str(scratch / 'bin/hermes-desktop')) +(scratch / 'installer').write_text(script) +PY + +cat >"$test_tmp/bin/omarchy-install-hermes-cli" <<'SH' +#!/bin/bash +printf 'local %s\n' "$*" >>"$OMARCHY_TEST_ROOT/events" +exit "${OMARCHY_TEST_LOCAL_STATUS:-0}" +SH +cat >"$test_tmp/bin/omarchy-pkg-add" <<'SH' +#!/bin/bash +printf 'package %s\n' "$*" >>"$OMARCHY_TEST_ROOT/events" +exit "${OMARCHY_TEST_PACKAGE_STATUS:-0}" +SH +cat >"$test_tmp/bin/hermes-desktop" <<'SH' +#!/bin/bash +printf 'launch\n' >>"$OMARCHY_TEST_ROOT/events" +SH +cat >"$test_tmp/bin/setsid" <<'SH' +#!/bin/bash +exec "$@" +SH +cat >"$test_tmp/bin/uwsm-app" <<'SH' +#!/bin/bash +[[ $1 == -- ]] || exit 1 +shift +exec "$@" +SH +cat >"$test_tmp/bin/gum" <<'SH' +#!/bin/bash +printf '%s\n' "$@" >"$OMARCHY_TEST_ROOT/choice-args" +[[ $1 == choose && $2 == --header ]] || exit 1 +[[ ${OMARCHY_TEST_CHOICE:-local} != cancel ]] || exit 130 +if [[ ${OMARCHY_TEST_CHOICE:-local} == remote ]]; then + printf '%s\n' "$5" +else + printf '%s\n' "$4" +fi +SH +cat >"$test_tmp/bin/omarchy-i18n" <<'SH' +#!/bin/bash +exec python3 - "$OMARCHY_PATH/default/i18n/en/cli.json" "$1" <<'PY' +import json +import sys +print(json.load(open(sys.argv[1]))[sys.argv[2]]) +PY +SH +chmod +x "$test_tmp/bin/"* + +new_home() { + test_home="$test_tmp/$1" + mkdir -p "$test_home" + : >"$test_tmp/events" + rm -f "$test_tmp/choice-args" +} + +run_installer() { + HOME="$test_home" HERMES_HOME="$test_home/.hermes" PATH="$test_tmp/bin:$PATH" \ + bash "$test_tmp/installer" "$@" "$test_tmp/output" 2>&1 +} + +run_choice() { + HOME="$test_home" HERMES_HOME="$test_home/.hermes" PATH="$test_tmp/bin:$PATH" \ + script -qec "bash '$test_tmp/installer'; status=\$?; sleep 0.1; exit \$status" /dev/null "$test_tmp/output" 2>&1 +} + +wait_for_launch() { + for (( attempt=0; attempt<200; attempt++ )); do + if grep -qx launch "$test_tmp/events"; then return 0; fi + sleep 0.01 + done + fail "Desktop launch completes" "$(cat "$test_tmp/output")" +} + +new_home remote +run_installer --remote || fail "explicit remote installation succeeds" "$(cat "$test_tmp/output")" +wait_for_launch +[[ $(cat "$test_tmp/events") == $'package hermes-desktop\nlaunch' ]] || fail "remote installation only installs the package and opens Desktop" +[[ ! -e $test_home/.hermes && ! -e $test_home/.local/bin ]] || fail "remote installation creates no host runtime or CLI wrappers" +grep -q 'Connect to existing Hermes' "$test_tmp/output" || fail "remote installation explains upstream onboarding" +pass "remote installation skips local runtime, CLI handover and theme setup" + +new_home existing-local +mkdir -p "$test_home/.hermes/hermes-agent" "$test_home/.local/bin" "$test_home/.config/systemd/user" +printf 'local work\n' >"$test_home/.hermes/hermes-agent/work" +printf 'existing command\n' >"$test_home/.local/bin/hermes" +printf 'existing gateway\n' >"$test_home/.config/systemd/user/hermes-gateway.service" +run_installer --remote || fail "remote installation accepts an existing local installation" +wait_for_launch +[[ $(cat "$test_tmp/events") == $'package hermes-desktop\nlaunch' ]] || fail "remote installation never calls the local installer" +[[ $(cat "$test_home/.hermes/hermes-agent/work") == 'local work' ]] || fail "existing runtime is preserved" +[[ $(cat "$test_home/.local/bin/hermes") == 'existing command' ]] || fail "existing CLI is preserved" +[[ $(cat "$test_home/.config/systemd/user/hermes-gateway.service") == 'existing gateway' ]] || fail "existing gateway unit is preserved" +pass "remote installation leaves existing local runtimes, commands and services alone" + +new_home local +run_installer --local || fail "explicit local installation succeeds" +wait_for_launch +[[ $(cat "$test_tmp/events") == $'local --now\nlaunch' ]] || fail "local installation delegates to the unchanged default-agent installer" +pass "explicit local installation preserves the existing runtime setup path" + +for choice in local remote; do + new_home "choose-$choice" + OMARCHY_TEST_CHOICE="$choice" run_choice || fail "interactive $choice choice succeeds" "$(cat "$test_tmp/output")" + wait_for_launch + if [[ $choice == local ]]; then + expected=$'local --now\nlaunch' + else + expected=$'package hermes-desktop\nlaunch' + fi + [[ $(cat "$test_tmp/events") == "$expected" ]] || fail "interactive $choice choice dispatches correctly" + grep -qx 'How do you want to use Hermes Desktop?' "$test_tmp/choice-args" || fail "choice uses the translated header" + grep -qx 'Connect to existing Hermes' "$test_tmp/choice-args" || fail "choice offers an existing backend" +done +pass "interactive local and existing-backend choices use the English catalog and select the right path" + +new_home cancel +OMARCHY_TEST_CHOICE=cancel run_choice || fail "cancelling the picker exits cleanly" +[[ ! -s $test_tmp/events ]] || fail "cancelling installs and launches nothing" +pass "cancelling the choice has no side effects" + +new_home invalid +for args in '' '--unknown' '--remote --local'; do + read -ra argv <<<"$args" + run_installer "${argv[@]}" && fail "missing noninteractive or invalid mode is rejected" + [[ ! -s $test_tmp/events ]] || fail "invalid mode has no side effects" +done +pass "noninteractive callers must choose a valid explicit mode" + +new_home package-failure +OMARCHY_TEST_PACKAGE_STATUS=7 run_installer --remote && fail "package failure must stop installation" +[[ $(cat "$test_tmp/events") == 'package hermes-desktop' ]] || fail "package failure does not open Desktop" +new_home local-failure +OMARCHY_TEST_LOCAL_STATUS=7 run_installer --local && fail "local setup failure must stop installation" +[[ $(cat "$test_tmp/events") == 'local --now' ]] || fail "local failure does not open Desktop" +pass "failed package or runtime setup stops before launch" + +# Check the companion launcher's no-runtime path rather than assuming that +# installing only the package is enough. The Electron binary is a recorder; +# upstream's actual first-run remote form still needs graphical verification. +if find_omarchy_pkgs; then + new_home packaged-launcher + mkdir -p "$test_tmp/package" + cat >"$test_tmp/package/Hermes" <<'SH' +#!/bin/bash +printf 'packaged-app\n' >>"$OMARCHY_TEST_ROOT/events" +printf '%s\n' "$@" >"$OMARCHY_TEST_ROOT/app-args" +SH + cat >"$test_tmp/bin/unshare" <<'SH' +#!/bin/bash +exit 0 +SH + chmod +x "$test_tmp/package/Hermes" "$test_tmp/bin/unshare" + python3 - "$OMARCHY_PKGS_ROOT/hermes-desktop/hermes-desktop.sh" "$test_tmp" <<'PY' +from pathlib import Path +import sys +source, scratch = map(Path, sys.argv[1:]) +(scratch / 'package-launcher').write_text(source.read_text().replace('/opt/hermes-desktop', str(scratch / 'package'))) +PY + HOME="$test_home" HERMES_HOME="$test_home/.hermes" PATH="$test_tmp/bin:$PATH" \ + bash "$test_tmp/package-launcher" >"$test_tmp/output" 2>&1 || fail "packaged launcher works without a runtime" "$(cat "$test_tmp/output")" + [[ $(cat "$test_tmp/events") == packaged-app ]] || fail "launcher opens the packaged Electron app" + [[ ! -e $test_home/.hermes ]] || fail "launcher does not provision a runtime" + grep -qx -- --disable-setuid-sandbox "$test_tmp/app-args" || fail "launcher keeps the Electron namespace sandbox" + pass "the actual package launcher opens Electron without a local runtime" +else + skip "package launcher check needs the companion omarchy-pkgs checkout" +fi