Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat: add managed tmux runtime download and path resolution for macOS

0xken15df512a6aec74
diff --git a/cli/scripts/install.sh b/cli/scripts/install.sh
index f9c1294db..7cb66e8af 100755
--- a/cli/scripts/install.sh
+++ b/cli/scripts/install.sh
@@ -23,10 +23,12 @@
#
# What the CLI RUNS is a short list — tmux (its only terminal backend), `ps`, and on a Linux desktop
# the clipboard helper for the active display — and step 1 checks exactly that list. Everything else
-# here (Homebrew, the Apple developer tools, apt, curl/tar/sed/awk/sha256sum) is only a way of
-# obtaining one of those or of downloading the runtime, and is looked at only when the thing it
-# obtains is missing: a Mac with tmux never hears about Homebrew, a Mac with Homebrew never hears
-# about Xcode, and the download tools are checked only when a runtime is actually downloaded.
+# here (Homebrew, apt, curl/tar/sed/awk/sha256sum) is only a way of obtaining one of those or of
+# downloading a runtime, and is looked at only when the thing it obtains is missing: a Mac with tmux
+# never hears about Homebrew, and the download tools are checked only when something is downloaded.
+# On a Mac without tmux, Homebrew is used if it is already there; otherwise tmux comes the way Node
+# does — a checksum-verified MANAGED build from our manifest into ~/.harness/runtime, no compiler,
+# no package manager and no password (see cli/scripts/build-managed-tmux.sh).
# Desktop mode (`--desktop`) trusts the app's own host pre-flight and skips step 1; host mode
# (`--host`) is the app handing step 1 to a real terminal for its password prompts and stops after it.
# The runtime's absolute path is baked into the launcher, so a Finder launch — where PATH is
@@ -65,13 +67,91 @@ METADATA_URL="${HARNESS_METADATA_URL:-https://storage.googleapis.com/s3-autonomo
# Published by `make upload-node-runtime` in the desktop repo; the desktop app reads the same manifest
# (its --dart-define is spelled the same) so both installers land on identical bytes.
RUNTIME_METADATA_URL="${HARNESS_RUNTIME_METADATA_URL:-https://storage.googleapis.com/s3-autonomous-upgrade-3/harness/runtime/metadata.json}"
+# Published by release-tmux-runtime.yml (`make upload-tmux-runtime`): macOS tmux built against static
+# libevent/ncurses, its own manifest because the Node one already has a "darwin-arm64" key.
+TMUX_METADATA_URL="${HARNESS_TMUX_METADATA_URL:-https://storage.googleapis.com/s3-autonomous-upgrade-3/harness/runtime/tmux/metadata.json}"
HARNESS_KEY="${HARNESS_KEY:-cli}"
CLI_DIR="$HOME/.harness/cli"
RUNTIME_DIR="$HOME/.harness/runtime"
CURRENT_NODE_FILE="$RUNTIME_DIR/current-node"
+CURRENT_TMUX_FILE="$RUNTIME_DIR/current-tmux"
BIN_DIR="$HOME/.local/bin"
LAUNCHER="$BIN_DIR/harness"
+# Shared by every download in this file — tmux in step 1 and Node in step 2 — so both manifests are
+# read by one implementation. Everything here must run in plain POSIX sh: there is no Node yet.
+
+# sha256 is the one tool that genuinely differs between the two platforms; the pair smooths it over.
+sha256_of() {
+ if command -v shasum >/dev/null 2>&1; then
+ shasum -a 256 "$1" | awk '{print $1}'
+ elif command -v sha256sum >/dev/null 2>&1; then
+ sha256sum "$1" | awk '{print $1}'
+ else
+ echo "✗ Need shasum or sha256sum to verify a download, and found neither." >&2
+ exit 11
+ fi
+}
+
+# Our manifests are published one key per line; pull just one platform's object out and read its
+# fields. No jq/python dependency, which a bare machine may equally not have.
+manifest_entry() { # <manifest json> <platform>
+ printf '%s\n' "$1" | sed -n "/\"$2\"[[:space:]]*:[[:space:]]*{/,/}/p"
+}
+entry_field() { # <entry> <key>
+ printf '%s\n' "$1" | sed -n "s/.*\"$2\"[[:space:]]*:[[:space:]]*\"\([^\"]*\)\".*/\1/p" | head -1
+}
+
+# The platform key our manifests use for this computer, or nothing on one we publish nothing for.
+manifest_platform() {
+ case "$(uname -s)" in
+ Darwin) _os=darwin ;;
+ Linux) _os=linux ;;
+ *) return 0 ;;
+ esac
+ case "$(uname -m)" in
+ arm64|aarch64) _arch=arm64 ;;
+ x86_64|amd64) _arch=x64 ;;
+ *) return 0 ;;
+ esac
+ printf '%s-%s\n' "$_os" "$_arch"
+}
+
+# Ensure ~/.local/bin is on PATH (per shell), idempotently — step 4 below, and host mode too, which
+# may have just linked ~/.local/bin/tmux and stops before step 4.
+add_path_line='export PATH="$HOME/.local/bin:$PATH"'
+marker='# added by harness installer'
+ensure_rc() {
+ rc="$1"
+ [ -f "$rc" ] || : > "$rc"
+ if ! grep -qF "$marker" "$rc" 2>/dev/null; then
+ printf '\n%s\n%s\n' "$marker" "$add_path_line" >> "$rc"
+ echo " ✓ added ~/.local/bin to PATH in $rc"
+ fi
+}
+ensure_path_rc() {
+case "$(basename "${SHELL:-/bin/sh}")" in
+ zsh) ensure_rc "$HOME/.zshrc" ;;
+ # `.bashrc` alone is not enough. A LOGIN shell reads .bash_profile / .bash_login / .profile and never
+ # .bashrc — that is `bash -lc`, `ssh host cmd`, most CI, and every `docker exec … bash -l`. On a
+ # desktop or an ssh session the shell is interactive so .bashrc is read and the gap is invisible;
+ # inside a container it means `harness` is never on PATH no matter how many new shells you open.
+ # macOS already covered this by also writing .bash_profile (Terminal starts login shells); do the
+ # same on Linux, writing whichever login file bash will actually consult — it reads the FIRST that
+ # exists, so appending to a lower-priority one would be silently ignored.
+ bash) ensure_rc "$HOME/.bashrc"
+ if [ -f "$HOME/.bash_profile" ]; then ensure_rc "$HOME/.bash_profile"
+ elif [ -f "$HOME/.bash_login" ]; then ensure_rc "$HOME/.bash_login"
+ elif [ "$(uname)" = "Darwin" ]; then ensure_rc "$HOME/.bash_profile"
+ else ensure_rc "$HOME/.profile"
+ fi ;;
+ fish) mkdir -p "$HOME/.config/fish"
+ rc="$HOME/.config/fish/config.fish"; [ -f "$rc" ] || : > "$rc"
+ grep -qF "$marker" "$rc" 2>/dev/null || printf '\n%s\nfish_add_path %s\n' "$marker" "$HOME/.local/bin" >> "$rc" ;;
+ *) ensure_rc "$HOME/.profile" ;;
+esac
+}
+
# 1. Host requirements (standalone and --host). The CLI runs tmux, `ps`, and on a Linux desktop the
# clipboard helper — those are checked, and only what is missing is obtained. This installer
# already runs in a terminal, so package-manager password prompts stay with the OS — never Harness.
@@ -106,61 +186,100 @@ tmux_runs() {
command -v tmux >/dev/null 2>&1 && tmux -V >/dev/null 2>&1
}
+# The managed tmux for this Mac: download, verify, unpack under ~/.harness/runtime, record it in
+# current-tmux (what the daemon reads, like current-node) and link it as ~/.local/bin/tmux so every
+# shell that has ~/.local/bin — which step 4 arranges — resolves the same binary the daemon runs.
+install_managed_tmux() {
+ platform="$(manifest_platform)"
+ case "$platform" in
+ darwin-*) ;;
+ *)
+ echo "✗ No managed tmux is published for $(uname -s)/$(uname -m). Install tmux (brew install tmux), then retry." >&2
+ exit 22
+ ;;
+ esac
+ echo "▸ Installing the managed tmux into $RUNTIME_DIR"
+ tmux_manifest="$(curl -fsSL "$TMUX_METADATA_URL")" || {
+ echo "✗ Could not fetch the tmux manifest: $TMUX_METADATA_URL" >&2
+ echo " Install tmux yourself (brew install tmux), then retry." >&2
+ exit 22
+ }
+ tmux_entry="$(manifest_entry "$tmux_manifest" "$platform")"
+ tmux_url="$(entry_field "$tmux_entry" url)"
+ tmux_sha="$(entry_field "$tmux_entry" sha256)"
+ tmux_root="$(entry_field "$tmux_entry" archiveRoot)"
+ tmux_version="$(entry_field "$tmux_entry" version)"
+ if [ -z "$tmux_url" ] || [ -z "$tmux_sha" ] || [ -z "$tmux_root" ] || [ -z "$tmux_version" ]; then
+ echo "✗ The tmux manifest has no usable '$platform' entry. Install tmux yourself (brew install tmux), then retry." >&2
+ exit 22
+ fi
+ tmux_target="$RUNTIME_DIR/$tmux_root"
+ if [ ! -x "$tmux_target/bin/tmux" ]; then
+ mkdir -p "$RUNTIME_DIR"
+ chmod 700 "$RUNTIME_DIR" 2>/dev/null || true
+ tmux_staging="$RUNTIME_DIR/.tmux-staging-$$"
+ rm -rf "$tmux_staging"
+ mkdir -p "$tmux_staging"
+ trap 'rm -rf "$tmux_staging"' EXIT INT TERM
+ echo " ▸ downloading tmux $tmux_version ($platform)…"
+ curl -fsSL "$tmux_url" -o "$tmux_staging/tmux.tar.gz" || {
+ echo "✗ Could not download $tmux_url" >&2
+ exit 22
+ }
+ tmux_got="$(sha256_of "$tmux_staging/tmux.tar.gz")"
+ if [ "$tmux_got" != "$tmux_sha" ]; then
+ echo "✗ tmux download failed checksum verification (expected $tmux_sha, got $tmux_got)" >&2
+ exit 22
+ fi
+ tar -xzf "$tmux_staging/tmux.tar.gz" -C "$tmux_staging" || {
+ echo "✗ Could not unpack the tmux archive" >&2
+ exit 22
+ }
+ [ -x "$tmux_staging/$tmux_root/bin/tmux" ] || {
+ echo "✗ The tmux archive has no $tmux_root/bin/tmux" >&2
+ exit 22
+ }
+ rm -rf "$tmux_target"
+ mv "$tmux_staging/$tmux_root" "$tmux_target"
+ rm -rf "$tmux_staging"
+ trap - EXIT INT TERM
+ fi
+ "$tmux_target/bin/tmux" -V >/dev/null 2>&1 || {
+ echo "✗ The managed tmux does not run on this computer: $tmux_target/bin/tmux" >&2
+ exit 22
+ }
+ printf '%s\n' "$tmux_target/bin/tmux" > "$CURRENT_TMUX_FILE"
+ chmod 600 "$CURRENT_TMUX_FILE" 2>/dev/null || true
+ mkdir -p "$BIN_DIR"
+ ln -sfn "$tmux_target/bin/tmux" "$BIN_DIR/tmux"
+ export PATH="$BIN_DIR:$PATH"
+ echo " ✓ installed tmux $tmux_version → $tmux_target"
+}
+
if [ "$INSTALL_MODE" != "desktop" ]; then
case "$(uname -s)" in
Darwin)
if tmux_runs; then
- : # tmux runs. Homebrew and the Apple developer tools are how it would have been installed;
- # with it here they are nobody's business, and neither is looked at.
+ : # tmux runs. How it got here is nobody's business, and nothing else is looked at.
else
- # A Homebrew installed for a different shell is still installed.
- if ! command -v brew >/dev/null 2>&1; then
- eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv 2>/dev/null || true)"
- fi
+ # A Homebrew installed for a different shell is still installed — and if it is here at all,
+ # its tmux is preferred: it is what the owner already maintains. The prefixes are overridable
+ # so a test (or an unusual install) can say where, or that there is none.
if ! command -v brew >/dev/null 2>&1; then
- # Homebrew's own installer needs the Apple developer tools; this is the only place they matter.
- if ! /usr/bin/xcrun --find clang >/dev/null 2>&1; then
- echo "▸ Apple developer tools are required by Homebrew (Xcode or Command Line Tools)."
- if [ -x /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild ]; then
- # xcrun answers "not ready" for two different reasons, and only one of them is the
- # developer directory. An unaccepted Xcode licence exits 69 and no amount of
- # xcode-select fixes it.
- if ! /usr/bin/xcodebuild -license check >/dev/null 2>&1; then
- echo " Xcode is installed but its licence has not been accepted."
- echo " macOS may ask for your password to accept it."
- sudo /usr/bin/xcodebuild -license accept
- fi
- if ! /usr/bin/xcrun --find clang >/dev/null 2>&1; then
- echo " Xcode is installed but is not the active developer directory."
- echo " macOS may ask for your password to select it."
- sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
- fi
- else
- echo " macOS will open its installer now. Finish it, then run this Harness installer again."
- xcode-select --install >/dev/null 2>&1 || true
- exit 20
+ for brew_prefix in ${HARNESS_HOMEBREW_PREFIXES:-/opt/homebrew /usr/local}; do
+ if [ -x "$brew_prefix/bin/brew" ]; then
+ eval "$("$brew_prefix/bin/brew" shellenv 2>/dev/null || true)"
+ break
fi
- /usr/bin/xcrun --find clang >/dev/null 2>&1 || {
- echo "✗ Apple developer tools are selected but are not usable." >&2
- exit 20
- }
- fi
- echo "▸ Installing Homebrew (macOS may ask for your password)"
- /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || {
- echo "✗ Homebrew installation failed. Review the output above, then retry." >&2
- exit 21
- }
- eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv 2>/dev/null)"
- command -v brew >/dev/null 2>&1 || {
- echo "✗ Homebrew was installed but is not available to this shell." >&2
- exit 21
- }
+ done
fi
- echo "▸ Installing tmux via Homebrew"
- brew install tmux || {
- echo "✗ Could not install tmux via Homebrew. Retry with: brew install tmux" >&2
- exit 22
- }
+ if command -v brew >/dev/null 2>&1; then
+ echo "▸ Installing tmux via Homebrew"
+ brew install tmux || echo "▸ Homebrew could not install tmux; using the managed build instead."
+ fi
+ # No Homebrew, or a Homebrew that could not: the managed build. Nothing to compile, nothing
+ # to ask a password for — the same checksum-verified download Node gets in step 2.
+ tmux_runs || install_managed_tmux
fi
;;
Linux)
@@ -225,6 +344,7 @@ tmux_runs || {
}
echo "✓ tmux ready ($(tmux -V))"
if [ "$INSTALL_MODE" = "host" ]; then
+ ensure_path_rc
echo "✓ Host requirements ready."
exit 0
fi
@@ -351,17 +471,6 @@ if [ -z "$NODE_BIN" ]; then
require_command sed
require_command awk
- # sha256 is the one tool that genuinely differs between the two platforms, and it is needed
- # BEFORE Node exists to smooth it over — hence this pair rather than step 2's single JS path.
- if command -v shasum >/dev/null 2>&1; then
- sha256_of() { shasum -a 256 "$1" | awk '{print $1}'; }
- elif command -v sha256sum >/dev/null 2>&1; then
- sha256_of() { sha256sum "$1" | awk '{print $1}'; }
- else
- echo "✗ Need shasum or sha256sum to verify the Node download, and found neither." >&2
- exit 11
- fi
-
echo "▸ Installing the Harness Node runtime into $RUNTIME_DIR"
echo " The CLI runs on its own Node so it behaves the same from a terminal and from the app."
echo " Your system Node, nvm and Homebrew are not read or changed."
@@ -369,16 +478,11 @@ if [ -z "$NODE_BIN" ]; then
echo "✗ Could not fetch the Node runtime manifest: $RUNTIME_METADATA_URL" >&2
exit 1
}
- # The manifest is our own, published one key per line; pull just this platform's object out and
- # read its fields. No jq/python dependency, which a bare machine may equally not have.
- runtime_entry="$(printf '%s\n' "$runtime_manifest" | sed -n "/\"$node_platform\"[[:space:]]*:[[:space:]]*{/,/}/p")"
- entry_field() {
- printf '%s\n' "$runtime_entry" | sed -n "s/.*\"$1\"[[:space:]]*:[[:space:]]*\"\([^\"]*\)\".*/\1/p" | head -1
- }
- node_url="$(entry_field url)"
- node_sha="$(entry_field sha256)"
- node_root="$(entry_field archiveRoot)"
- node_version="$(entry_field version)"
+ runtime_entry="$(manifest_entry "$runtime_manifest" "$node_platform")"
+ node_url="$(entry_field "$runtime_entry" url)"
+ node_sha="$(entry_field "$runtime_entry" sha256)"
+ node_root="$(entry_field "$runtime_entry" archiveRoot)"
+ node_version="$(entry_field "$runtime_entry" version)"
if [ -z "$node_url" ] || [ -z "$node_sha" ] || [ -z "$node_root" ] || [ -z "$node_version" ]; then
echo "✗ The Node runtime manifest has no usable '$node_platform' entry." >&2
exit 1
@@ -461,37 +565,8 @@ const bin = path.join(os.homedir(), '.local', 'bin')
})().catch((err) => { console.error('✗ install failed: ' + err.message); process.exit(1) })
HARNESSJS
-# 4. Ensure ~/.local/bin is on PATH (per shell), idempotently.
-add_path_line='export PATH="$HOME/.local/bin:$PATH"'
-marker='# added by harness installer'
-ensure_rc() {
- rc="$1"
- [ -f "$rc" ] || : > "$rc"
- if ! grep -qF "$marker" "$rc" 2>/dev/null; then
- printf '\n%s\n%s\n' "$marker" "$add_path_line" >> "$rc"
- echo " ✓ added ~/.local/bin to PATH in $rc"
- fi
-}
-case "$(basename "${SHELL:-/bin/sh}")" in
- zsh) ensure_rc "$HOME/.zshrc" ;;
- # `.bashrc` alone is not enough. A LOGIN shell reads .bash_profile / .bash_login / .profile and never
- # .bashrc — that is `bash -lc`, `ssh host cmd`, most CI, and every `docker exec … bash -l`. On a
- # desktop or an ssh session the shell is interactive so .bashrc is read and the gap is invisible;
- # inside a container it means `harness` is never on PATH no matter how many new shells you open.
- # macOS already covered this by also writing .bash_profile (Terminal starts login shells); do the
- # same on Linux, writing whichever login file bash will actually consult — it reads the FIRST that
- # exists, so appending to a lower-priority one would be silently ignored.
- bash) ensure_rc "$HOME/.bashrc"
- if [ -f "$HOME/.bash_profile" ]; then ensure_rc "$HOME/.bash_profile"
- elif [ -f "$HOME/.bash_login" ]; then ensure_rc "$HOME/.bash_login"
- elif [ "$(uname)" = "Darwin" ]; then ensure_rc "$HOME/.bash_profile"
- else ensure_rc "$HOME/.profile"
- fi ;;
- fish) mkdir -p "$HOME/.config/fish"
- rc="$HOME/.config/fish/config.fish"; [ -f "$rc" ] || : > "$rc"
- grep -qF "$marker" "$rc" 2>/dev/null || printf '\n%s\nfish_add_path %s\n' "$marker" "$HOME/.local/bin" >> "$rc" ;;
- *) ensure_rc "$HOME/.profile" ;;
-esac
+# 4. Ensure ~/.local/bin is on PATH (per shell), idempotently — defined up with the other helpers.
+ensure_path_rc
# 5. Final verification. Use the launcher by absolute path because this process cannot update its
# parent shell's PATH. Installation never authenticates or starts the adapter implicitly.
diff --git a/cli/src/lib/tmuxOnPath.spec.ts b/cli/src/lib/tmuxOnPath.spec.ts
index 560e99e26..2a0127f4d 100644
--- a/cli/src/lib/tmuxOnPath.spec.ts
+++ b/cli/src/lib/tmuxOnPath.spec.ts
@@ -1,9 +1,9 @@
-import { chmodSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
+import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { delimiter, join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import { TmuxBackend } from './tmuxBackend.js'
-import { ensureTmuxOnPath, requireTmuxAvailable, resolveViaLoginShell } from './tmuxOnPath.js'
+import { ensureTmuxOnPath, managedTmuxPath, requireTmuxAvailable, resolveViaLoginShell } from './tmuxOnPath.js'
const dirs: string[] = []
const originalPath = process.env.PATH
@@ -18,6 +18,9 @@ function scratch(prefix: string): string {
return dir
}
+/** A runtime dir with no managed tmux — so a developer machine's real ~/.harness never leaks in. */
+const noManagedTmux = () => scratch('tmux-onpath-no-runtime-')
+
/** A stand-in for the user's shell: it knows about `binDir`, the daemon's own PATH does not. */
function fakeShell(binDir: string): string {
const dir = scratch('tmux-onpath-shell-')
@@ -63,7 +66,7 @@ describe('ensureTmuxOnPath', () => {
const binDir = fakeTmux()
const env: NodeJS.ProcessEnv = { PATH: '/nonexistent-for-this-test' }
- const outcome = await ensureTmuxOnPath(env, fakeShell(binDir))
+ const outcome = await ensureTmuxOnPath(env, fakeShell(binDir), noManagedTmux())
expect(outcome.state).toBe('adopted')
if (outcome.state !== 'adopted') return
@@ -80,7 +83,7 @@ describe('ensureTmuxOnPath', () => {
// bash keeps it in .bash_profile, which only `-l` does.
const binDir = fakeTmux()
const env: NodeJS.ProcessEnv = { PATH: '/nonexistent' }
- const outcome = await ensureTmuxOnPath(env, loginOnlyShell(binDir))
+ const outcome = await ensureTmuxOnPath(env, loginOnlyShell(binDir), noManagedTmux())
expect(outcome.state).toBe('adopted')
expect(env.PATH?.split(delimiter)[0]).toBe(binDir)
@@ -97,17 +100,47 @@ PATH="${binDir}" exec /bin/sh -c "$@"
chmodSync(shell, 0o700)
const env: NodeJS.ProcessEnv = { PATH: '/nonexistent-for-this-test' }
- const outcome = await ensureTmuxOnPath(env, shell)
+ const outcome = await ensureTmuxOnPath(env, shell, noManagedTmux())
expect(outcome).toMatchObject({ state: 'adopted', path: join(binDir, 'tmux') })
expect(env.PATH?.split(delimiter)[0]).toBe(binDir)
})
+ it('adopts the managed tmux before asking any shell', async () => {
+ const runtimeDir = scratch('tmux-onpath-runtime-')
+ const binDir = join(runtimeDir, 'tmux-9.9-darwin-arm64', 'bin')
+ mkdirSync(binDir, { recursive: true })
+ const managed = join(binDir, 'tmux')
+ writeFileSync(managed, '#!/bin/sh\nexit 0\n', { mode: 0o755 })
+ writeFileSync(join(runtimeDir, 'current-tmux'), `${managed}\n`)
+ const env: NodeJS.ProcessEnv = { PATH: '/nonexistent' }
+
+ // A shell that would answer is deliberately NOT given: the managed build needs none.
+ const outcome = await ensureTmuxOnPath(env, '/nonexistent/shell', runtimeDir)
+
+ expect(outcome).toEqual({ state: 'adopted', path: managed, from: 'managed runtime' })
+ expect(env.PATH!.split(delimiter)[0]).toBe(binDir)
+ })
+
+ it('ignores a current-tmux that points outside the runtime dir or cannot run', () => {
+ const runtimeDir = scratch('tmux-onpath-runtime-bad-')
+ const elsewhere = scratch('tmux-onpath-elsewhere-')
+ const outside = join(elsewhere, 'tmux')
+ writeFileSync(outside, '#!/bin/sh\nexit 0\n', { mode: 0o755 })
+ writeFileSync(join(runtimeDir, 'current-tmux'), `${outside}\n`)
+ expect(managedTmuxPath(runtimeDir)).toBeNull()
+
+ writeFileSync(join(runtimeDir, 'current-tmux'), `${join(runtimeDir, 'gone', 'bin', 'tmux')}\n`)
+ expect(managedTmuxPath(runtimeDir)).toBeNull()
+
+ expect(managedTmuxPath(scratch('tmux-onpath-runtime-empty-'))).toBeNull()
+ })
+
it('leaves an already-working PATH untouched', async () => {
const binDir = fakeTmux()
const env: NodeJS.ProcessEnv = { PATH: binDir }
- const outcome = await ensureTmuxOnPath(env, fakeShell(binDir))
+ const outcome = await ensureTmuxOnPath(env, fakeShell(binDir), noManagedTmux())
expect(outcome.state).toBe('present')
// No duplicate entry: this runs on every start, so it has to be idempotent.
@@ -118,7 +151,7 @@ PATH="${binDir}" exec /bin/sh -c "$@"
const emptyBin = scratch('tmux-onpath-empty-')
const env: NodeJS.ProcessEnv = { PATH: '/nonexistent-for-this-test' }
- const outcome = await ensureTmuxOnPath(env, fakeShell(emptyBin))
+ const outcome = await ensureTmuxOnPath(env, fakeShell(emptyBin), noManagedTmux())
expect(outcome.state).toBe('absent')
expect(env.PATH).toBe('/nonexistent-for-this-test')
@@ -155,7 +188,7 @@ exit 0
if (before.state !== 'succeeded') expect(before.reason).toBe('tmux is unavailable')
// After: the same call, once the daemon has been told where the user's shell finds tmux.
- expect((await ensureTmuxOnPath(process.env, shell)).state).toBe('adopted')
+ expect((await ensureTmuxOnPath(process.env, shell, noManagedTmux())).state).toBe('adopted')
const after = await new TmuxBackend().create({ cwd: '/tmp', label: 'harness-test' })
expect(after).toEqual({
diff --git a/cli/src/lib/tmuxOnPath.ts b/cli/src/lib/tmuxOnPath.ts
index 12caddd24..689099d5a 100644
--- a/cli/src/lib/tmuxOnPath.ts
+++ b/cli/src/lib/tmuxOnPath.ts
@@ -13,7 +13,9 @@
* on the daemon's PATH, once, at startup. Every existing `execFile('tmux', …)` then works unchanged.
*/
import { execFile } from 'node:child_process'
-import { delimiter, dirname, isAbsolute } from 'node:path'
+import { accessSync, constants, readFileSync } from 'node:fs'
+import { delimiter, dirname, isAbsolute, join, sep } from 'node:path'
+import { env as appEnv } from '../config/env.js'
import { binaryOnPath } from './binaryOnPath.js'
import { interactiveEngineShell } from './engineLaunch.js'
@@ -24,7 +26,7 @@ const RESOLVE_SCRIPT = 'command -v "$1" 2>/dev/null'
export type TmuxPathOutcome =
/** Already resolvable; the daemon's PATH was left alone. */
| { state: 'present'; path?: string }
- /** Found via the user's shell and its directory prepended to PATH. */
+ /** Found — through the managed runtime or the user's shell — and its directory prepended to PATH. */
| { state: 'adopted'; path: string; from: string }
/** Not resolvable either way — tmux is genuinely absent, or there is no usable login shell. */
| { state: 'absent'; reason: string }
@@ -42,6 +44,27 @@ export function requireTmuxAvailable(outcome: TmuxPathOutcome): AvailableTmuxPat
return outcome
}
+/**
+ * The tmux the installer put under ~/.harness/runtime, recorded in `current-tmux` exactly as the
+ * managed Node is recorded in `current-node` — on a Mac that had no tmux and no Homebrew, the
+ * installer downloads our checksum-verified build there and links it as ~/.local/bin/tmux. Null on
+ * every other machine, and for a record that names something outside the runtime dir or not
+ * executable: only a path inside the directory we own is ever trusted, the same containment check
+ * `managedNodePath` applies.
+ */
+export function managedTmuxPath(runtimeDir: string = appEnv.ADAPTER_RUNTIME_DIR): string | null {
+ try {
+ const recorded = readFileSync(join(runtimeDir, 'current-tmux'), 'utf-8').trim()
+ if (recorded && recorded.startsWith(runtimeDir + sep)) {
+ accessSync(recorded, constants.X_OK)
+ return recorded
+ }
+ } catch {
+ // No managed tmux here — the ordinary case on a Mac with Homebrew and on every Linux box.
+ }
+ return null
+}
+
/** Where the user's own interactive shell finds a command, which is not where the daemon looks. */
export async function resolveViaLoginShell(
command: string,
@@ -100,8 +123,18 @@ function probe(shellPath: string, args: readonly string[], command: string): Pro
export async function ensureTmuxOnPath(
env: NodeJS.ProcessEnv = process.env,
shell: string | undefined = undefined,
+ runtimeDir: string = appEnv.ADAPTER_RUNTIME_DIR,
): Promise<TmuxPathOutcome> {
if (binaryOnPath('tmux', env)) return { state: 'present' }
+ // The managed build comes before asking the shell: it is what the user's own shells resolve too
+ // (~/.local/bin is put first on PATH by the installer), so the daemon and the terminal keep
+ // talking to one server — and it needs no shell at all, which a launch-agent context may lack.
+ const managed = managedTmuxPath(runtimeDir)
+ if (managed) {
+ const dir = dirname(managed)
+ env.PATH = env.PATH ? `${dir}${delimiter}${env.PATH}` : dir
+ return { state: 'adopted', path: managed, from: 'managed runtime' }
+ }
const resolved = await resolveViaLoginShell('tmux', shell)
if (!resolved) {
return {
diff --git a/cli/src/scripts/install.spec.ts b/cli/src/scripts/install.spec.ts
index 6eee9579c..bb29bf903 100644
--- a/cli/src/scripts/install.spec.ts
+++ b/cli/src/scripts/install.spec.ts
@@ -1,6 +1,6 @@
import { spawnSync } from "child_process";
import { join } from "path";
-import { chmodSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "fs";
+import { chmodSync, mkdirSync, mkdtempSync, readFileSync, readlinkSync, rmSync, writeFileSync } from "fs";
import { tmpdir } from "os";
import { describe, expect, it } from "vitest";
@@ -19,15 +19,16 @@ const writeLinuxHostCommands = (directory: string) => {
};
// Step 1 of the script — the host-requirements ladder — as one runnable unit.
+// From the constants (RUNTIME_DIR, BIN_DIR, the manifest URLs) through the whole host step.
const hostSetupOf = (source: string) =>
- source.slice(source.indexOf("require_command()"), source.indexOf("# 2. Resolve the Node"));
+ source.slice(source.indexOf('METADATA_URL="${HARNESS_METADATA_URL'), source.indexOf("# 2. Resolve the Node"));
// The download-tools check that guards the Node download, with the helpers it calls.
const downloadToolsOf = (source: string) =>
- source.slice(source.indexOf("require_command()"), source.indexOf("tmux_runs()")) +
+ source.slice(source.indexOf('METADATA_URL="${HARNESS_METADATA_URL'), source.indexOf("tmux_runs()")) +
source.slice(
source.indexOf(" # Fetching, unpacking and verifying the runtime"),
- source.indexOf(" # sha256 is the one tool"),
+ source.indexOf(' echo "▸ Installing the Harness Node runtime'),
);
describe("scripts/install.sh command contract", () => {
@@ -110,41 +111,40 @@ describe("scripts/install.sh command contract", () => {
expect(tmuxStep).toBeGreaterThan(-1);
expect(nodeStep).toBeGreaterThan(tmuxStep);
expect(cliStep).toBeGreaterThan(nodeStep);
- expect(source).toContain("/usr/bin/xcrun --find clang");
- expect(source).toContain(
- "sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer",
- );
- expect(source).toContain("xcode-select --install");
- // An unaccepted Xcode licence makes xcrun fail exactly like an unselected directory; only
- // one of them is fixed by xcode-select, so the licence is checked and accepted first.
- expect(source).toContain("/usr/bin/xcodebuild -license check");
- expect(source).toContain("sudo /usr/bin/xcodebuild -license accept");
- expect(source.indexOf("-license accept")).toBeLessThan(
- source.indexOf("sudo xcode-select --switch"),
- );
- expect(source).toContain("Homebrew installation failed");
expect(source).toContain("brew install tmux");
+ expect(source).toContain("install_managed_tmux");
expect(source).toContain("install_with_apt $missing_host_packages");
expect(source).toContain('if [ "$(id -u)" -eq 0 ]; then');
expect(source).toContain('sudo apt-get "$@"');
expect(source).not.toContain("sudo apt-get update &&");
- expect(source).toContain("Could not install tmux via Homebrew");
expect(source).toContain("tmux is required but did not pass verification");
expect(source).toContain("exit 22");
+ // Obtaining tmux never needs a compiler, Xcode or the Homebrew installer any more.
+ expect(source).not.toContain("xcrun");
+ expect(source).not.toContain("xcode-select");
+ expect(source).not.toContain("Homebrew/install/HEAD/install.sh");
+ expect(source).not.toContain("exit 20");
+ expect(source).not.toContain("exit 21");
});
- // The ladder, in source order: tmux is asked about first, Homebrew only when tmux is missing, the
- // Apple developer tools only when Homebrew is missing too.
- it("asks about Homebrew only without tmux, and about Xcode only without Homebrew", () => {
+ // The ladder, in source order: tmux is asked about first, Homebrew used only when tmux is missing
+ // and Homebrew is already there, the managed build for everything else.
+ it("asks about Homebrew only without tmux, and downloads the managed build without Homebrew", () => {
const source = readFileSync(installer, "utf8");
- const darwin = source.slice(source.indexOf(" Darwin)"), source.indexOf(" Linux)"));
+ const hostStep = source.slice(source.indexOf("# 1. Host requirements"));
+ const darwin = hostStep.slice(hostStep.indexOf(" Darwin)"), hostStep.indexOf(" Linux)"));
const tmuxCheck = darwin.indexOf("if tmux_runs; then");
- const brewCheck = darwin.indexOf('if ! command -v brew >/dev/null 2>&1; then');
- const xcrunCheck = darwin.indexOf("/usr/bin/xcrun --find clang");
+ const brewCheck = darwin.indexOf("if command -v brew >/dev/null 2>&1; then");
+ const managed = darwin.indexOf("tmux_runs || install_managed_tmux");
expect(tmuxCheck).toBeGreaterThan(-1);
expect(brewCheck).toBeGreaterThan(tmuxCheck);
- expect(xcrunCheck).toBeGreaterThan(brewCheck);
+ expect(managed).toBeGreaterThan(brewCheck);
+ // The managed archive is checksum-pinned by the manifest and recorded for the daemon.
+ expect(source).toContain("harness/runtime/tmux/metadata.json");
+ expect(source).toContain('CURRENT_TMUX_FILE="$RUNTIME_DIR/current-tmux"');
+ expect(source).toContain("tmux download failed checksum verification");
+ expect(source).toContain('ln -sfn "$tmux_target/bin/tmux" "$BIN_DIR/tmux"');
});
it("does nothing on a Mac that already runs tmux", () => {
@@ -174,12 +174,12 @@ describe("scripts/install.sh command contract", () => {
}
});
- it("installs tmux with an existing Homebrew and never looks for Xcode", () => {
+ it("installs tmux with an existing Homebrew and never fetches the managed build", () => {
const source = readFileSync(installer, "utf8");
const hostSetup = hostSetupOf(source);
const scratch = mkdtempSync(join(tmpdir(), "harness-mac-brew-"));
const invocations = join(scratch, "brew-invocations");
- const developerTools = join(scratch, "developer-tools-touched");
+ const fetched = join(scratch, "curl-invoked");
const fakeTmux = join(scratch, "tmux");
try {
@@ -187,21 +187,173 @@ describe("scripts/install.sh command contract", () => {
writeCommand(scratch, "brew", [
`printf '%s\\n' "$*" >> '${invocations}'`,
`if [ "$1" = "shellenv" ]; then exit 0; fi`,
- `printf '%s\\n' '#!/bin/sh' 'printf "tmux 3.6\\\\n"' > '${fakeTmux}'`,
+ `printf '%s\\n' '#!/bin/sh' 'printf "tmux 3.7c\\\\n"' > '${fakeTmux}'`,
`/bin/chmod 700 '${fakeTmux}'`,
]);
- writeCommand(scratch, "sudo", [`: > '${developerTools}'`, "exit 99"]);
- writeCommand(scratch, "xcode-select", [`: > '${developerTools}'`, "exit 99"]);
+ writeCommand(scratch, "curl", [`: > '${fetched}'`, "exit 99"]);
const result = spawnSync("/bin/sh", ["-c", hostSetup], {
encoding: "utf8",
- env: { ...process.env, INSTALL_MODE: "standalone", PATH: scratch },
+ env: {
+ ...process.env,
+ INSTALL_MODE: "standalone",
+ PATH: scratch,
+ HARNESS_HOMEBREW_PREFIXES: join(scratch, "no-homebrew"),
+ },
});
expect(result.status).toBe(0);
expect(readFileSync(invocations, "utf8")).toContain("install tmux\n");
- expect(result.stdout).not.toContain("Apple developer tools");
- expect(() => readFileSync(developerTools, "utf8")).toThrow();
+ expect(result.stdout).not.toContain("managed");
+ expect(() => readFileSync(fetched, "utf8")).toThrow();
+ } finally {
+ rmSync(scratch, { recursive: true, force: true });
+ }
+ });
+
+ // A fake CDN: `curl -o` writes the archive, plain `curl` prints the manifest. The archive wraps a
+ // fake tmux so the whole managed path — fetch, verify, unpack, record, link — runs for real.
+ const managedFixture = (scratch: string, tamperSha = false) => {
+ const home = join(scratch, "home");
+ const root = "tmux-9.9-darwin-arm64";
+ const stage = join(scratch, "stage", root, "bin");
+ mkdirSync(stage, { recursive: true });
+ writeCommand(stage, "tmux", ["printf 'tmux 9.9\\n'"]);
+ const archive = join(scratch, `${root}.tar.gz`);
+ spawnSync("tar", ["-czf", archive, "-C", join(scratch, "stage"), root]);
+ const sha = spawnSync("shasum", ["-a", "256", archive], { encoding: "utf8" }).stdout.split(" ")[0];
+ const manifest = JSON.stringify({
+ tmux: {
+ "darwin-arm64": {
+ version: "9.9",
+ url: "https://cdn.example/tmux.tar.gz",
+ sha256: tamperSha ? "0".repeat(64) : sha,
+ size: 1,
+ archiveRoot: root,
+ },
+ },
+ }, null, 2);
+ writeFileSync(join(scratch, "manifest.json"), manifest);
+ writeCommand(scratch, "curl", [
+ `printf '%s\\n' "$*" >> '${join(scratch, "curl-invocations")}'`,
+ `case "$*" in *"-o "*) cp '${archive}' "$4" ;; *) cat '${join(scratch, "manifest.json")}' ;; esac`,
+ ]);
+ writeCommand(scratch, "uname", [`if [ "$1" = "-m" ]; then printf 'arm64\\n'; else printf 'Darwin\\n'; fi`]);
+ mkdirSync(home, { recursive: true });
+ return { home, root };
+ };
+
+ it("downloads, verifies and links the managed tmux when there is no Homebrew", () => {
+ const source = readFileSync(installer, "utf8");
+ const hostSetup = hostSetupOf(source);
+ const scratch = mkdtempSync(join(tmpdir(), "harness-mac-managed-"));
+
+ try {
+ const { home, root } = managedFixture(scratch);
+ const result = spawnSync("/bin/sh", ["-c", hostSetup], {
+ encoding: "utf8",
+ env: {
+ ...process.env,
+ HOME: home,
+ INSTALL_MODE: "standalone",
+ // Only stock tools beyond the fakes: no brew, no tmux — and the fakes win.
+ PATH: `${scratch}:/usr/bin:/bin`,
+ HARNESS_TMUX_METADATA_URL: "https://cdn.example/manifest.json",
+ HARNESS_HOMEBREW_PREFIXES: join(scratch, "no-homebrew"),
+ },
+ });
+
+ expect(result.status).toBe(0);
+ expect(result.stdout).toContain("downloading tmux 9.9 (darwin-arm64)");
+ expect(result.stdout).toContain("tmux ready (tmux 9.9)");
+ const binary = join(home, ".harness", "runtime", root, "bin", "tmux");
+ expect(readFileSync(join(home, ".harness", "runtime", "current-tmux"), "utf8").trim()).toBe(binary);
+ expect(readlinkSync(join(home, ".local", "bin", "tmux"))).toBe(binary);
+ expect(readFileSync(join(scratch, "curl-invocations"), "utf8")).toContain("https://cdn.example/manifest.json");
+ } finally {
+ rmSync(scratch, { recursive: true, force: true });
+ }
+ });
+
+ it("refuses a managed tmux whose checksum does not match, and links nothing", () => {
+ const source = readFileSync(installer, "utf8");
+ const hostSetup = hostSetupOf(source);
+ const scratch = mkdtempSync(join(tmpdir(), "harness-mac-managed-bad-"));
+
+ try {
+ const { home } = managedFixture(scratch, true);
+ const result = spawnSync("/bin/sh", ["-c", hostSetup], {
+ encoding: "utf8",
+ env: {
+ ...process.env,
+ HOME: home,
+ INSTALL_MODE: "standalone",
+ PATH: `${scratch}:/usr/bin:/bin`,
+ HARNESS_TMUX_METADATA_URL: "https://cdn.example/manifest.json",
+ HARNESS_HOMEBREW_PREFIXES: join(scratch, "no-homebrew"),
+ },
+ });
+
+ expect(result.status).toBe(22);
+ expect(result.stderr).toContain("checksum verification");
+ expect(() => readlinkSync(join(home, ".local", "bin", "tmux"))).toThrow();
+ expect(() => readFileSync(join(home, ".harness", "runtime", "current-tmux"))).toThrow();
+ } finally {
+ rmSync(scratch, { recursive: true, force: true });
+ }
+ });
+
+ it("falls back to the managed build when Homebrew cannot install tmux", () => {
+ const source = readFileSync(installer, "utf8");
+ const hostSetup = hostSetupOf(source);
+ const scratch = mkdtempSync(join(tmpdir(), "harness-mac-brew-broken-"));
+
+ try {
+ const { home, root } = managedFixture(scratch);
+ writeCommand(scratch, "brew", [`if [ "$1" = "shellenv" ]; then exit 0; fi`, "exit 1"]);
+ const result = spawnSync("/bin/sh", ["-c", hostSetup], {
+ encoding: "utf8",
+ env: {
+ ...process.env,
+ HOME: home,
+ INSTALL_MODE: "standalone",
+ PATH: `${scratch}:/usr/bin:/bin`,
+ HARNESS_TMUX_METADATA_URL: "https://cdn.example/manifest.json",
+ HARNESS_HOMEBREW_PREFIXES: join(scratch, "no-homebrew"),
+ },
+ });
+
+ expect(result.status).toBe(0);
+ expect(result.stdout).toContain("Homebrew could not install tmux");
+ expect(readlinkSync(join(home, ".local", "bin", "tmux"))).toContain(root);
+ } finally {
+ rmSync(scratch, { recursive: true, force: true });
+ }
+ });
+
+ it("host mode puts ~/.local/bin on PATH for new shells", () => {
+ const source = readFileSync(installer, "utf8");
+ const hostSetup = hostSetupOf(source);
+ const scratch = mkdtempSync(join(tmpdir(), "harness-host-rc-"));
+
+ try {
+ const { home } = managedFixture(scratch);
+ const result = spawnSync("/bin/sh", ["-c", hostSetup], {
+ encoding: "utf8",
+ env: {
+ ...process.env,
+ HOME: home,
+ SHELL: "/bin/zsh",
+ INSTALL_MODE: "host",
+ PATH: `${scratch}:/usr/bin:/bin`,
+ HARNESS_TMUX_METADATA_URL: "https://cdn.example/manifest.json",
+ HARNESS_HOMEBREW_PREFIXES: join(scratch, "no-homebrew"),
+ },
+ });
+
+ expect(result.status).toBe(0);
+ expect(result.stdout).toContain("Host requirements ready");
+ expect(readFileSync(join(home, ".zshrc"), "utf8")).toContain('export PATH="$HOME/.local/bin:$PATH"');
} finally {
rmSync(scratch, { recursive: true, force: true });
}
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.md
index a71b788bd..82620c05c 100644
--- a/desktop/CLAUDE.md
+++ b/desktop/CLAUDE.md
@@ -82,7 +82,7 @@ manifest with `--dart-define=DESKTOP_UPDATE_METADATA_URL=...`; `HARNESS_RUNTIME_
the same for the desktop updater only. The managed Node runtime is still published from this repo with
`make upload-node-runtime ARGS=22.23.2` (`darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`) — and,
since 2026-09-15, a managed **tmux** for macOS the same way (`release-tmux-runtime.yml` /
-`make upload-tmux-runtime`, RELEASE.md "Managed tmux runtime"; not consumed by anything yet) — but
+`make upload-tmux-runtime`, RELEASE.md "Managed tmux runtime") — but
its consumer is now the `harness` installer rather than this app.
## Architecture
@@ -117,21 +117,22 @@ on its own or on the app's behalf, and records it in `current-node`; the launche
binary absolutely, so a Finder launch (PATH is launchd's bare `/usr/bin:/bin:/usr/sbin:/sbin`) and a
Terminal launch behave identically. One implementation, shared with everyone who installs the CLI from
a terminal, instead of a second copy here that had to keep its own pinned checksums in step.
-**tmux** is the one dependency still taken from the OS package manager, and the only reason the setup
-screen ever opens a terminal: a fresh Homebrew or any `apt-get install` needs a password prompt on a
-real tty.
+**tmux** on Linux is the one dependency still taken from the OS package manager, and the only reason
+the setup screen ever opens a terminal: `apt-get install` needs a password prompt on a real tty. On
+macOS it is a managed runtime (or the Homebrew one, if Homebrew is already there) and needs neither.
**Readiness is the list of commands the app runs, nothing more** (`EnvironmentStep`: tmux — plus `ps`
on Linux — the Harness CLI, and on a Linux desktop the clipboard helper). Homebrew, the Apple developer
tools, apt and the curl/tar/sed/awk/sha256sum the CLI installer downloads Node with are *recipes* for a
missing command, kept in `EnvironmentReadiness.plan` and probed top-down only while the command is
-missing: a Mac with tmux is never asked about Homebrew, a Mac with Homebrew never about `xcrun`, and a
-Linux box with a managed runtime never about curl. The ladder itself is implemented once, in
-`cli/scripts/install.sh` (`--host` runs just that half); the macOS Terminal window the app opens is a
-log/exit-code frame around it, while the Linux one keeps the app's own apt transaction so its
-clock-skew repair stays. Gating readiness on the recipes was what sent a computer whose tmux ran fine
-into Terminal to reinstall developer tools after a macOS upgrade — the screen renders `plan`, it does
-not infer one.
+missing: a Mac with tmux is never asked about Homebrew, and a Linux box with a managed runtime never
+about curl. The ladder itself is implemented once, in `cli/scripts/install.sh` (`--host` runs just
+that half): on macOS tmux comes from the Homebrew already present or, failing that, the managed
+build downloaded into `~/.harness/runtime` — no compiler, no package manager, no password, so the
+app runs `--host` in-app and never opens a Terminal window there. Linux keeps the app's own apt
+transaction (its clock-skew repair) and the one Terminal handoff. Gating readiness on the recipes
+was what sent a computer whose tmux ran fine into Terminal to reinstall developer tools after a macOS
+upgrade — the screen renders `plan`, it does not infer one.
### Boot and state
diff --git a/desktop/RELEASE.md b/desktop/RELEASE.md
index 2da2141f8..ad4d2bfef 100644
--- a/desktop/RELEASE.md
+++ b/desktop/RELEASE.md
@@ -58,7 +58,7 @@ Until that managed manifest covers a platform, the desktop build falls back to i
official Node 22 archive for it. The fallback keeps first-run setup functional but is intentionally
not a replacement for publishing the managed runtime channel before release.
-Homebrew and `apt` are still used for **tmux**, which is a separate step and unrelated to Node — and only when tmux is missing; a computer that already runs it is never asked about either.
+**tmux** is a separate step and unrelated to Node: on macOS it comes from Homebrew when Homebrew is already there, else from the managed runtime below; on Linux from `apt` — and only when tmux is missing; a computer that already runs it is never asked about any of them.
## Managed tmux runtime (macOS)
@@ -87,9 +87,13 @@ make upload-tmux-runtime ARGS="3.7c /path/to/archives"
The manifest is `harness/runtime/tmux/metadata.json` — its own file, because `install.sh` slices a
manifest by the first `"<platform>"` key and Node's already has one — with the same
-`{version,url,sha256,size,archiveRoot}` entries. **Nothing consumes it yet**: `install.sh` still
-reaches tmux through Homebrew on macOS. Teaching it to download this archive (and the CLI to put
-`~/.harness/runtime/current-tmux` on the daemon's PATH) is the next step; publish the runtime first.
+`{version,url,sha256,size,archiveRoot}` entries. `install.sh` reads it on a Mac that has no tmux and
+no Homebrew (Homebrew's tmux is used when Homebrew is already there): download into
+`~/.harness/runtime/tmux-<ver>-<platform>`, verify, record the binary in `~/.harness/runtime/current-tmux`
+(which the daemon's `ensureTmuxOnPath` puts on its PATH, exactly like `current-node`) and link it as
+`~/.local/bin/tmux`. The desktop runs that same `install.sh --host` in-app, so on macOS first-run setup
+never opens a Terminal window. Publish a new runtime **before** the `install.sh` that pins a newer
+tmux level, and keep it level with what Homebrew ships.
## Two macOS builds — Intel on Skia, Apple Silicon on Impeller
diff --git a/desktop/lib/bootstrap/environment_provisioner.dart b/desktop/lib/bootstrap/environment_provisioner.dart
index a27c98928..cd7fdb0ef 100644
--- a/desktop/lib/bootstrap/environment_provisioner.dart
+++ b/desktop/lib/bootstrap/environment_provisioner.dart
@@ -12,9 +12,11 @@ const String kHarnessDesktopInstallCommand =
'curl -fsSL https://cdn.autonomous.ai/harness/cli/install.sh | '
'/bin/sh -s -- --desktop';
-/// The same installer's host half — tmux and what the CLI runs beside it —
-/// for the Terminal window the app opens when obtaining them needs a
-/// password. One ladder, implemented once, in the script.
+/// The same installer's host half — tmux and what the CLI runs beside it.
+/// On macOS this is how tmux is obtained, in-app: Homebrew's if Homebrew is
+/// already there, else the managed build downloaded into `~/.harness/runtime`
+/// (no compiler, no package manager, no password). One ladder, implemented
+/// once, in the script.
const String kHarnessHostSetupCommand =
'curl -fsSL https://cdn.autonomous.ai/harness/cli/install.sh | '
'/bin/sh -s -- --host';
@@ -60,10 +62,12 @@ enum EnvironmentSetupPhase {
enum EnvironmentSetupMode { automatic, manual }
-/// Identifies which host setup owns a visible Terminal handoff. Linux can wait
+/// Identifies which host setup owns a visible Terminal handoff. Only Linux has
+/// one now — apt needs a password on a real tty; on macOS nothing does since
+/// tmux comes from Homebrew-if-present or the managed download. Linux can wait
/// on the clipboard helper even when tmux itself is already ready, so a
/// resumed failure must not always be attributed to the tmux row.
-enum EnvironmentTerminalSetup { linuxHost, tmux }
+enum EnvironmentTerminalSetup { linuxHost }
class EnvironmentFailure {
final EnvironmentStep? step;
@@ -124,29 +128,22 @@ class EnvironmentPlanItem {
this.packages = const [],
});
- /// The macOS ladder for tmux, one rung each, and the CLI installer — the
- /// items a plan is assembled from, written down once.
- static const appleDeveloperTools = EnvironmentPlanItem(
- step: EnvironmentStep.tmux,
- title: 'Apple developer tools',
- detail: 'Xcode or Command Line Tools · needed by the Homebrew installer',
- command: '/usr/bin/xcrun --find clang || { if [ -x /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild ]; then sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer; else xcode-select --install; fi; }',
- requiresTerminal: true,
- );
-
- static const homebrew = EnvironmentPlanItem(
+ /// The items a plan is assembled from, written down once. tmux on macOS
+ /// is a single in-app step whichever way it is obtained; the detail says
+ /// which, because that is the one thing the person reading the plan may
+ /// care about.
+ static const tmuxViaHomebrew = EnvironmentPlanItem(
step: EnvironmentStep.tmux,
- title: 'Homebrew',
- detail: 'Package manager that installs tmux',
- command: '/bin/bash -c "\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"',
- requiresTerminal: true,
+ title: 'tmux',
+ detail: 'Installs with the Homebrew already on this Mac',
+ command: kHarnessHostSetupCommand,
);
- static const tmuxViaHomebrew = EnvironmentPlanItem(
+ static const tmuxManaged = EnvironmentPlanItem(
step: EnvironmentStep.tmux,
title: 'tmux',
- detail: 'Required for every terminal session',
- command: 'eval "\$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv)" && brew install tmux',
+ detail: 'Downloads a verified build into ~/.harness/runtime',
+ command: kHarnessHostSetupCommand,
);
static const harnessCli = EnvironmentPlanItem(
@@ -329,7 +326,6 @@ class EnvironmentProvisioner {
final bool _isMacOS;
final bool _isLinux;
final bool _isWindows;
- final bool _forceMissingAppleDeveloperTools;
final Map<String, String> _platformEnvironment;
EnvironmentProvisioner({
@@ -340,7 +336,6 @@ class EnvironmentProvisioner {
bool? isMacOS,
bool? isLinux,
bool? isWindows,
- bool? forceMissingAppleDeveloperTools,
Map<String, String>? platformEnvironment,
}) : harnessHome = harnessHome ?? Directory(_defaultHarnessHome()),
_run = run ?? _defaultRun,
@@ -349,12 +344,7 @@ class EnvironmentProvisioner {
_isMacOS = isMacOS ?? Platform.isMacOS,
_isLinux = isLinux ?? Platform.isLinux,
_isWindows = isWindows ?? Platform.isWindows,
- _platformEnvironment = platformEnvironment ?? Platform.environment,
- _forceMissingAppleDeveloperTools =
- forceMissingAppleDeveloperTools ??
- const bool.fromEnvironment(
- 'HARNESS_DESKTOP_FORCE_MISSING_APPLE_DEVELOPER_TOOLS',
- );
+ _platformEnvironment = platformEnvironment ?? Platform.environment;
/// HOME, then USERPROFILE. Windows sets only the latter, so a launch from Explorer used to throw
/// out of this constructor before a single frame could render.
@@ -518,12 +508,10 @@ class EnvironmentProvisioner {
(await File(previousTerminalResult).readAsString()).trim(),
);
if (exitCode != null && exitCode != 0) {
- final linuxHost =
- state.terminalSetup == EnvironmentTerminalSetup.linuxHost;
+ // The only Terminal handoff left is Linux's apt transaction.
final clipboardFailed =
- linuxHost &&
state.steps[EnvironmentStep.clipboard] ==
- EnvironmentStepStatus.needsTerminal;
+ EnvironmentStepStatus.needsTerminal;
final tmuxFailed =
state.steps[EnvironmentStep.tmux] ==
EnvironmentStepStatus.needsTerminal;
@@ -539,21 +527,15 @@ class EnvironmentProvisioner {
status: EnvironmentStepStatus.failed,
);
}
- final classifiedFailure = linuxHost
- ? _classifiedLinuxPackageFailure(
- exitCode,
- previousTerminalLogText,
- )
- : null;
+ final classifiedFailure = _classifiedLinuxPackageFailure(
+ exitCode,
+ previousTerminalLogText,
+ );
emit(
- step: linuxHost ? null : EnvironmentStep.tmux,
- status: linuxHost ? null : EnvironmentStepStatus.failed,
message: 'The Terminal setup exited with code $exitCode.',
phase: EnvironmentSetupPhase.failed,
failure: EnvironmentFailure(
- step: !linuxHost
- ? EnvironmentStep.tmux
- : clipboardFailed
+ step: clipboardFailed
? EnvironmentStep.clipboard
: tmuxFailed
? EnvironmentStep.tmux
@@ -566,11 +548,7 @@ class EnvironmentProvisioner {
'Terminal exited with code $exitCode. Review the complete log below.',
command:
classifiedFailure?.command ??
- (linuxHost
- ? await _linuxHostManualCommand(
- _aptPackagesOf(state.plan),
- )
- : _manualCommandFor(EnvironmentStep.tmux)),
+ await _linuxHostManualCommand(_aptPackagesOf(state.plan)),
exitCode: exitCode,
),
);
@@ -632,12 +610,8 @@ class EnvironmentProvisioner {
return state;
}
if (completedTerminalSetup != null && !state.hostReady) {
- final linuxHost =
- completedTerminalSetup == EnvironmentTerminalSetup.linuxHost;
emit(
- message: linuxHost
- ? 'The Linux host dependency install finished, but verification still found missing packages.'
- : 'The Terminal setup finished, but tmux still did not pass verification.',
+ message: 'The Linux host dependency install finished, but verification still found missing packages.',
phase: EnvironmentSetupPhase.failed,
failure: EnvironmentFailure(
step: !probe.terminalReady
@@ -648,9 +622,7 @@ class EnvironmentProvisioner {
title: 'Host dependency verification failed',
detail:
'Still missing: ${probe.missingHostNames.join(', ')}. Review the Terminal log, then retry when ready.',
- command: linuxHost
- ? await _linuxHostManualCommand(probe.aptPackages)
- : _manualCommandFor(EnvironmentStep.tmux),
+ command: await _linuxHostManualCommand(probe.aptPackages),
),
);
return state;
@@ -764,53 +736,52 @@ class EnvironmentProvisioner {
}
if (_isMacOS && !probe.tmuxRuns) {
- if (probe.homebrewInstallsTmux) {
- // Homebrew is here, so tmux is one bottle away and needs no password.
+ // One in-app step whichever rung applies: the installer's host half
+ // uses the Homebrew already here or downloads the managed build.
+ // Neither needs a password, so no Terminal window and no waiting.
+ emit(
+ step: EnvironmentStep.tmux,
+ status: EnvironmentStepStatus.running,
+ message: probe.homebrewInstallsTmux
+ ? 'Installing tmux via Homebrew…'
+ : 'Downloading the managed tmux…',
+ );
+ ProcessResult? installResult;
+ try {
+ installResult = await _shellStreaming(
+ 'set -e; $kHarnessHostSetupCommand',
+ onOutput: (line) => emit(output: line),
+ );
+ } catch (error) {
+ emit(output: 'tmux install failed: $error');
+ }
+ if (installResult?.exitCode == 0 && await _hasTmux()) {
emit(
step: EnvironmentStep.tmux,
- status: EnvironmentStepStatus.running,
- message: 'Installing tmux via Homebrew…',
+ status: EnvironmentStepStatus.ready,
+ message: 'tmux is ready.',
+ output: '✓ tmux installed',
+ plan: state.planWithout(EnvironmentStep.tmux),
);
- ProcessResult? installResult;
- try {
- installResult = await _shellStreaming(
- 'brew install tmux',
- onOutput: (line) => emit(output: line),
- );
- } catch (error) {
- emit(output: 'Background tmux install failed: $error');
- }
- if (installResult?.exitCode == 0 && await _hasTmux()) {
- emit(
- step: EnvironmentStep.tmux,
- status: EnvironmentStepStatus.ready,
- message: 'tmux is ready.',
- output: '✓ tmux installed via Homebrew',
- plan: state.planWithout(EnvironmentStep.tmux),
- );
- } else {
- if (installResult != null) {
- emit(
- output: installResult.exitCode == 0
- ? 'Homebrew finished, but tmux did not pass verification.'
- : 'Background tmux install exited ${installResult.exitCode}: '
- '${_resultText(installResult)}',
- );
- }
- await _handTmuxToTerminal(
- emit,
- 'Complete the visible Homebrew prompts in Terminal. Harness never sees your password.',
- 'Background install failed; Terminal opened to retry tmux.',
- );
- return state;
- }
} else {
- // Homebrew (and maybe the developer tools) must be installed first,
- // and both ask for a password — a real terminal's job.
- await _handTmuxToTerminal(
- emit,
- 'Complete any password or macOS prompts in Terminal. Harness never sees your password.',
- 'Terminal opened to install ${probe.planFor(EnvironmentStep.tmux).map((item) => item.title).join(', ')}.',
+ final detail = installResult == null
+ ? 'The tmux installer could not be started.'
+ : installResult.exitCode == 0
+ ? 'The installer finished, but tmux did not pass verification.'
+ : 'The tmux installer exited ${installResult.exitCode}: '
+ '${_resultText(installResult)}';
+ emit(
+ step: EnvironmentStep.tmux,
+ status: EnvironmentStepStatus.failed,
+ message: detail,
+ phase: EnvironmentSetupPhase.failed,
+ failure: EnvironmentFailure(
+ step: EnvironmentStep.tmux,
+ title: 'tmux could not be installed',
+ detail: detail,
+ command: _manualCommandFor(EnvironmentStep.tmux),
+ exitCode: installResult?.exitCode,
+ ),
);
return state;
}
@@ -872,43 +843,6 @@ class EnvironmentProvisioner {
}
}
- /// Opens the Terminal window that installs tmux (and whatever obtaining it
- /// takes) and leaves the tmux row waiting on it.
- Future<void> _handTmuxToTerminal(
- void Function({
- EnvironmentStep? step,
- EnvironmentStepStatus? status,
- String? message,
- String? output,
- EnvironmentSetupPhase? phase,
- EnvironmentFailure? failure,
- String? terminalLogPath,
- String? terminalResultPath,
- EnvironmentTerminalSetup? terminalSetup,
- List<EnvironmentPlanItem>? plan,
- })
- emit,
- String message,
- String output,
- ) async {
- emit(
- step: EnvironmentStep.tmux,
- status: EnvironmentStepStatus.running,
- message: 'Preparing tmux in a secure terminal…',
- );
- final terminal = await _launchTmuxSetup();
- emit(
- step: EnvironmentStep.tmux,
- status: EnvironmentStepStatus.needsTerminal,
- message: message,
- output: output,
- phase: EnvironmentSetupPhase.waitingForTerminal,
- terminalLogPath: terminal.log.path,
- terminalResultPath: terminal.result.path,
- terminalSetup: EnvironmentTerminalSetup.tmux,
- );
- }
-
/// One read-only look at what this computer runs, and the plan for what it
/// does not — each rung probed only when the one above it is missing.
Future<_HostProbe> _probe() async {
@@ -917,17 +851,13 @@ class EnvironmentProvisioner {
final tmuxRuns = await _hasTmux();
var homebrewInstallsTmux = false;
if (!tmuxRuns) {
- if (await _hasHomebrew()) {
- homebrewInstallsTmux = true;
- } else {
- // Homebrew's installer is what needs the developer tools — not
- // tmux, and not this app — so they are asked about only here.
- if (!await _hasAppleDeveloperTools()) {
- plan.add(EnvironmentPlanItem.appleDeveloperTools);
- }
- plan.add(EnvironmentPlanItem.homebrew);
- }
- plan.add(EnvironmentPlanItem.tmuxViaHomebrew);
+ // Asked only to word the plan: the installer decides the same way.
+ homebrewInstallsTmux = await _hasHomebrew();
+ plan.add(
+ homebrewInstallsTmux
+ ? EnvironmentPlanItem.tmuxViaHomebrew
+ : EnvironmentPlanItem.tmuxManaged,
+ );
}
final harnessRuns = await _hasHarness();
if (!harnessRuns) plan.add(EnvironmentPlanItem.harnessCli);
@@ -1318,9 +1248,6 @@ fi''';
List<String> packages,
) => _launchTerminalSetup(linuxPackages: packages);
- Future<({File log, File result})> _launchTmuxSetup() =>
- _launchTerminalSetup();
-
Future<({File log, File result})> _launchTerminalSetup({
List<String> linuxPackages = const [],
}) async {
@@ -1347,19 +1274,8 @@ fi''';
return result.exitCode == 0;
}
- /// `xcode-select -p` only proves that a path was selected. It also succeeds
- /// for an incomplete or moved Command Line Tools directory. Resolve a tool
- /// through xcrun so pre-flight reflects whether Homebrew can actually use
- /// the selected Apple toolchain.
- Future<bool> _hasAppleDeveloperTools() async {
- if (_forceMissingAppleDeveloperTools) return false;
- final result = await _shell(
- 'command -v /usr/bin/xcrun >/dev/null 2>&1 && '
- '/usr/bin/xcrun --find clang >/dev/null 2>&1',
- );
- return result.exitCode == 0;
- }
-
+ /// The Linux apt transaction as a script for a real terminal — the one
+ /// host step left that needs a password on a tty.
Future<File> _writeTerminalBootstrapScript({
List<String> linuxPackages = const [],
}) async {
@@ -1368,34 +1284,6 @@ fi''';
);
await directory.create(recursive: true);
await _run('/bin/chmod', ['700', directory.path]);
- if (_isMacOS) {
- // The ladder itself — tmux, else Homebrew, else the developer tools
- // first — lives in the CLI installer's `--host` mode, so this window
- // only adds what the app needs from it: a log and an exit code.
- final script = File('${directory.path}/install-tmux.command');
- await script.writeAsString('''#!/bin/zsh
-set -e
-umask 077
-LOG_FILE="${directory.path}/terminal.log"
-RESULT_FILE="${directory.path}/terminal.exit"
-exec > >(tee -a "\$LOG_FILE") 2>&1
-finish() {
- status=\$?
- printf '%s\\n' "\$status" > "\$RESULT_FILE"
- if [ "\$status" -ne 0 ]; then
- echo
- echo 'System setup failed. Review the error above, then return to Harness.'
- read -r '?Press Enter to close this window…' || true
- fi
- return "\$status"
-}
-trap finish EXIT
-$kHarnessHostSetupCommand
-echo 'Return to Harness.'
-''', flush: true);
- await _run('/bin/chmod', ['700', script.path]);
- return script;
- }
final packageList = linuxPackages.isEmpty
? const ['tmux']
: linuxPackages.toSet().toList();
@@ -1558,7 +1446,7 @@ fi
'sudo apt-get install -y ${_linuxClipboardPackage() ?? 'xclip or wl-clipboard'}',
EnvironmentStep.tmux =>
_isMacOS
- ? 'brew install tmux && tmux -V'
+ ? '$kHarnessHostSetupCommand && tmux -V'
: 'sudo apt-get install -y tmux && tmux -V',
EnvironmentStep.harness =>
'$kHarnessDesktopInstallCommand && harness version',
@@ -1627,26 +1515,22 @@ class _HostProbe {
String get tmuxMessage {
if (terminalReady) return 'tmux is ready.';
- final titles = planFor(EnvironmentStep.tmux).map((item) => item.title);
- if (homebrewInstallsTmux) return 'tmux will be installed with Homebrew.';
- if (titles.length > 1) {
- return '${titles.join(', then ')} will be installed in Terminal.';
+ if (aptPackages.isNotEmpty) {
+ return '${psRuns ? 'tmux' : 'tmux and ps'} will be installed with apt.';
}
- return '${psRuns ? 'tmux' : 'tmux and ps'} will be installed with apt.';
+ return homebrewInstallsTmux
+ ? 'tmux will be installed with Homebrew.'
+ : 'tmux will be downloaded into ~/.harness/runtime.';
}
String get tmuxOutput {
if (terminalReady) return '✓ tmux --version';
final lines = <String>[tmuxRuns ? '✓ tmux --version' : '✗ tmux --version'];
if (!psRuns) lines.add('✗ ps');
- if (homebrewInstallsTmux) lines.add('✓ brew --version');
- for (final item in planFor(EnvironmentStep.tmux)) {
- if (identical(item, EnvironmentPlanItem.homebrew)) {
- lines.add('✗ brew --version');
- }
- if (identical(item, EnvironmentPlanItem.appleDeveloperTools)) {
- lines.add('✗ xcrun --find clang');
- }
+ if (aptPackages.isEmpty) {
+ lines.add(
+ homebrewInstallsTmux ? '✓ brew --version' : '– managed tmux download',
+ );
}
return lines.join(' · ');
}
diff --git a/desktop/lib/widgets/environment_setup_screen.dart b/desktop/lib/widgets/environment_setup_screen.dart
index 852c7a89d..c599f41cd 100644
--- a/desktop/lib/widgets/environment_setup_screen.dart
+++ b/desktop/lib/widgets/environment_setup_screen.dart
@@ -328,9 +328,9 @@ class _EnvironmentSetupScreenState extends State<EnvironmentSetupScreen> {
return Platform.isLinux ? '$base · tmux, ps' : base;
}
if (Platform.isLinux) return '$base · installs with apt';
- final titles = steps.map((item) => item.title).toList();
- if (titles.length == 1) return '$base · installs with Homebrew';
- return '$base · installs ${titles.join(', then ')}';
+ // macOS: one in-app step; the item's detail says whether Homebrew or the
+ // managed download does it.
+ return '$base · ${steps.first.detail.toLowerCase()}';
}
String? get _linuxClipboardPackage {
diff --git a/desktop/test/boot_flow_widget_test.dart b/desktop/test/boot_flow_widget_test.dart
index 89de7e2d1..de71525d3 100644
--- a/desktop/test/boot_flow_widget_test.dart
+++ b/desktop/test/boot_flow_widget_test.dart
@@ -707,7 +707,7 @@ void main() {
},
phase: EnvironmentSetupPhase.chooseMethod,
mode: EnvironmentSetupMode.automatic,
- plan: [EnvironmentPlanItem.homebrew, EnvironmentPlanItem.tmuxViaHomebrew],
+ plan: [EnvironmentPlanItem.tmuxManaged],
);
await tester.pumpWidget(
ProviderScope(
@@ -717,23 +717,21 @@ void main() {
);
await tester.pump();
- expect(find.text('Homebrew'), findsOneWidget);
expect(find.text('tmux'), findsOneWidget);
expect(find.text('Managed Node 20+ & Harness CLI'), findsNothing);
- expect(find.text('Install 2 tools'), findsOneWidget);
- expect(find.text('Admin prompts stay in Terminal'), findsOneWidget);
+ expect(find.text('Install 1 tool'), findsOneWidget);
+ // Nothing on macOS needs a password any more: no Terminal notice.
+ expect(find.text('Admin prompts stay in Terminal'), findsNothing);
await tester.tap(find.text('Manual setup'));
await tester.pump();
- expect(find.text('1 · Homebrew'), findsOneWidget);
- expect(find.text('2 · tmux'), findsOneWidget);
+ expect(find.text('1 · tmux'), findsOneWidget);
expect(
- find.textContaining('Homebrew/install/HEAD/install.sh'),
+ find.textContaining('install.sh | /bin/sh -s -- --host'),
findsOneWidget,
);
- expect(find.textContaining('brew install tmux'), findsOneWidget);
- expect(find.textContaining('cdn.autonomous.ai'), findsNothing);
+ expect(find.textContaining('Homebrew/install/HEAD'), findsNothing);
});
testWidgets('CLI-only install plan does not warn about admin prompts', (
@@ -766,24 +764,18 @@ void main() {
});
testWidgets(
- 'review lists the whole ladder when neither tmux nor Homebrew nor Xcode is there',
+ 'review shows tmux and the CLI as two in-app steps on a bare Mac',
(tester) async {
- // The plan is the provisioner's, in ladder order: the developer tools
- // appear only because Homebrew was found missing, Homebrew only because
- // tmux was.
+ // No tmux, no Homebrew, no Harness: still nothing that needs Terminal.
final app = makeNotifier(AppStatus.preparingEnvironment);
app.environmentReadiness = const EnvironmentReadiness(
steps: {
EnvironmentStep.clipboard: EnvironmentStepStatus.notApplicable,
- EnvironmentStep.harness: EnvironmentStepStatus.ready,
+ EnvironmentStep.harness: EnvironmentStepStatus.failed,
EnvironmentStep.tmux: EnvironmentStepStatus.failed,
},
phase: EnvironmentSetupPhase.review,
- plan: [
- EnvironmentPlanItem.appleDeveloperTools,
- EnvironmentPlanItem.homebrew,
- EnvironmentPlanItem.tmuxViaHomebrew,
- ],
+ plan: [EnvironmentPlanItem.tmuxManaged, EnvironmentPlanItem.harnessCli],
);
await tester.pumpWidget(
ProviderScope(
@@ -793,19 +785,18 @@ void main() {
);
await tester.pump();
- expect(find.text('Apple developer tools'), findsOneWidget);
- expect(find.text('Homebrew'), findsOneWidget);
expect(find.text('tmux'), findsOneWidget);
- expect(find.text('Install 3 tools'), findsOneWidget);
- expect(
- tester.getTopLeft(find.text('Apple developer tools')).dy,
- lessThan(tester.getTopLeft(find.text('Homebrew')).dy),
- );
+ expect(find.text('Managed Node 20+ & Harness CLI'), findsOneWidget);
+ expect(find.text('Install 2 tools'), findsOneWidget);
+ expect(find.text('Admin prompts stay in Terminal'), findsNothing);
+ expect(find.text('Apple developer tools'), findsNothing);
+ expect(find.text('Homebrew'), findsNothing);
expect(
- tester.getTopLeft(find.text('Homebrew')).dy,
- lessThan(tester.getTopLeft(find.text('tmux')).dy),
+ tester.getTopLeft(find.text('tmux')).dy,
+ lessThan(
+ tester.getTopLeft(find.text('Managed Node 20+ & Harness CLI')).dy,
+ ),
);
- expect(find.text('Apple developer tools'), findsOneWidget);
},
);
diff --git a/desktop/test/environment_provisioner_test.dart b/desktop/test/environment_provisioner_test.dart
index a6b0ee32c..26f4d9338 100644
--- a/desktop/test/environment_provisioner_test.dart
+++ b/desktop/test/environment_provisioner_test.dart
@@ -34,7 +34,6 @@ void main() {
bool Function()? homebrewPresent,
bool Function()? xclipPresent,
bool Function()? wlCopyPresent,
- bool developerToolsPresent = true,
bool aptPresent = true,
bool runAsRoot = false,
bool passwordlessSudo = false,
@@ -90,12 +89,13 @@ void main() {
stderr: linuxInstallExitCode == 0 ? '' : linuxInstallStderr,
);
}
- if (shell.contains('brew install tmux')) {
+ // The installer's host half: the one in-app step that obtains tmux on macOS.
+ if (shell.contains('install.sh | /bin/sh -s -- --host')) {
if (tmuxInstallExitCode == 0) await installTmux?.call();
return result(
tmuxInstallExitCode,
- stdout: tmuxInstallExitCode == 0 ? 'tmux installed' : '',
- stderr: tmuxInstallExitCode == 0 ? '' : 'Homebrew install failed',
+ stdout: tmuxInstallExitCode == 0 ? '✓ tmux ready (tmux 3.7c)' : '',
+ stderr: tmuxInstallExitCode == 0 ? '' : 'tmux install failed',
);
}
if (shell.contains('command -v brew')) {
@@ -121,11 +121,6 @@ void main() {
if (shell.contains('sudo -n true')) {
return passwordlessSudo ? result(0) : result(1);
}
- if (shell.contains('/usr/bin/xcrun --find clang')) {
- return developerToolsPresent
- ? result(0, stdout: '/usr/bin/clang')
- : result(1, stderr: 'unable to find utility clang');
- }
if (shell.contains('cdn.autonomous.ai/harness/cli/install.sh')) {
await installHarness?.call();
return result(0, stdout: 'Harness installed');
@@ -168,13 +163,12 @@ void main() {
},
);
- // The macOS ladder, one rung at a time. Each rung is probed only when the
- // one above it is missing: tmux, else Homebrew, else the developer tools.
- test('a computer with tmux is ready without Apple developer tools or Homebrew', () async {
- // The tools are how tmux gets INSTALLED, not how it runs. A `brew install`
- // from last year keeps working after a macOS upgrade invalidated the
- // Command Line Tools or an Xcode update left its licence unaccepted —
- // and this used to send that computer into Terminal to reinstall them.
+ // The macOS ladder: tmux, else one in-app installer step that uses the
+ // Homebrew already here or downloads the managed build. Nothing here ever
+ // needs a Terminal window, Xcode, or a password.
+ test('a computer with tmux is ready without Homebrew', () async {
+ // Homebrew is how tmux MIGHT have got here, not how it runs — a `brew
+ // install` from last year keeps working after Homebrew itself broke.
var terminalLaunches = 0;
final calls = <String>[];
final provisioner = EnvironmentProvisioner(
@@ -183,7 +177,6 @@ void main() {
isLinux: false,
openTerminal: (_) async => terminalLaunches++,
run: runner(
- developerToolsPresent: false,
homebrewPresent: () => false,
tmuxPresent: () => true,
installHarness: createManagedHarness,
@@ -200,56 +193,20 @@ void main() {
expect(readiness.isReady, isTrue, reason: readiness.output.join('\n'));
expect(readiness.steps[EnvironmentStep.tmux], EnvironmentStepStatus.ready);
expect(readiness.plan, isEmpty);
- expect(
- calls.any((line) => line.contains('/usr/bin/xcrun --find clang')),
- isFalse,
- );
expect(calls.any((line) => line.contains('brew --version')), isFalse);
+ expect(calls.any((line) => line.contains('--host')), isFalse);
expect(terminalLaunches, 0);
});
- test('with Homebrew present the plan is tmux alone and Xcode is never asked about', () async {
- final calls = <String>[];
- final provisioner = EnvironmentProvisioner(
- harnessHome: scratch,
- isMacOS: true,
- isLinux: false,
- run: runner(
- developerToolsPresent: false,
- homebrewPresent: () => true,
- tmuxPresent: () => false,
- calls: calls,
- ),
- );
-
- final readiness = await provisioner.ensureReady(
- onProgress: (_) {},
- install: false,
- );
-
- expect(readiness.phase, EnvironmentSetupPhase.review);
- expect(readiness.plan.map((item) => item.title), [
- 'tmux',
- 'Managed Node 20+ & Harness CLI',
- ]);
- expect(readiness.plan.first.requiresTerminal, isFalse);
- expect(
- calls.any((line) => line.contains('/usr/bin/xcrun --find clang')),
- isFalse,
- );
- expect(readiness.output.join('\n'), contains('✓ brew --version'));
- });
-
- test('without Homebrew the developer tools are probed, and listed only when missing', () async {
- for (final developerTools in [true, false]) {
+ test('without tmux the plan is one in-app step, worded by whether Homebrew is here', () async {
+ for (final homebrew in [true, false]) {
final calls = <String>[];
final provisioner = EnvironmentProvisioner(
harnessHome: scratch,
isMacOS: true,
isLinux: false,
run: runner(
- developerToolsPresent: developerTools,
- homebrewPresent: () => false,
+ homebrewPresent: () => homebrew,
tmuxPresent: () => false,
calls: calls,
),
@@ -261,42 +218,41 @@ void main() {
);
expect(readiness.phase, EnvironmentSetupPhase.review);
- expect(
- calls.where((line) => line.contains('/usr/bin/xcrun --find clang')),
- hasLength(1),
- reason: 'developerTools=$developerTools',
- );
expect(readiness.plan.map((item) => item.title), [
- if (!developerTools) 'Apple developer tools',
- 'Homebrew',
'tmux',
'Managed Node 20+ & Harness CLI',
]);
+ expect(readiness.plan.first.requiresTerminal, isFalse);
+ expect(readiness.plan.first.command, kHarnessHostSetupCommand);
expect(
- readiness.plan.where((item) => item.requiresTerminal).length,
- developerTools ? 1 : 2,
+ readiness.plan.first.detail,
+ homebrew ? contains('Homebrew') : contains('~/.harness/runtime'),
);
expect(
readiness.output.join('\n'),
- developerTools
- ? isNot(contains('xcrun --find clang'))
- : contains('✗ xcrun --find clang'),
+ homebrew
+ ? contains('✓ brew --version')
+ : contains('managed tmux download'),
);
+ expect(calls.any((line) => line.contains('xcrun')), isFalse);
+ expect(calls.any((line) => line.contains('--host')), isFalse);
}
});
- test('automatic setup hands the Homebrew rungs to Terminal, through the installer', () async {
- String? terminalScript;
+ test('automatic setup obtains tmux in-app through the installer, never in Terminal', () async {
+ await createManagedHarness();
+ var tmuxPresent = false;
+ var terminalLaunches = 0;
final calls = <String>[];
final provisioner = EnvironmentProvisioner(
harnessHome: scratch,
isMacOS: true,
isLinux: false,
- openTerminal: (path) async => terminalScript = path,
+ openTerminal: (_) async => terminalLaunches++,
run: runner(
- developerToolsPresent: false,
homebrewPresent: () => false,
- tmuxPresent: () => false,
+ tmuxPresent: () => tmuxPresent,
+ installTmux: () async => tmuxPresent = true,
calls: calls,
),
);
@@ -307,81 +263,23 @@ void main() {
mode: EnvironmentSetupMode.automatic,
);
- expect(readiness.phase, EnvironmentSetupPhase.waitingForTerminal);
- expect(
- readiness.steps[EnvironmentStep.tmux],
- EnvironmentStepStatus.needsTerminal,
- );
- expect(readiness.terminalSetup, EnvironmentTerminalSetup.tmux);
- expect(terminalScript, isNotNull);
- expect(calls.where((line) => line.contains('brew install tmux')), isEmpty);
- expect(calls.where((line) => line.contains('install.sh')), isEmpty);
- // The ladder lives in the CLI installer's host mode; the window only adds
- // the log and exit code the app polls.
- final script = await File(terminalScript!).readAsString();
- expect(script, contains(kHarnessHostSetupCommand));
- expect(script, contains('terminal.log'));
- expect(script, contains('terminal.exit'));
- expect(script, isNot(contains('xcode-select')));
- expect(script, isNot(contains('brew install')));
- if (File('/bin/zsh').existsSync()) {
- expect(
- (await Process.run('/bin/zsh', ['-n', terminalScript!])).exitCode,
- 0,
- );
- }
+ expect(readiness.isReady, isTrue, reason: readiness.output.join('\n'));
+ expect(readiness.plan, isEmpty);
+ expect(terminalLaunches, 0);
+ expect(calls.where((line) => line.contains('--host')), hasLength(1));
+ expect(calls.any((line) => line.contains('brew install')), isFalse);
+ expect(readiness.output.join('\n'), contains('tmux ready (tmux 3.7c)'));
});
- test(
- 'macOS installs only missing tmux in-app when Homebrew is ready',
- () async {
- await createManagedHarness();
- var tmuxPresent = false;
- var terminalLaunches = 0;
- final calls = <String>[];
- final provisioner = EnvironmentProvisioner(
- harnessHome: scratch,
- isMacOS: true,
- isLinux: false,
- openTerminal: (_) async => terminalLaunches++,
- run: runner(
- tmuxPresent: () => tmuxPresent,
- installTmux: () async => tmuxPresent = true,
- calls: calls,
- ),
- );
-
- final readiness = await provisioner.ensureReady(
- onProgress: (_) {},
- install: true,
- mode: EnvironmentSetupMode.automatic,
- );
-
- expect(readiness.isReady, isTrue);
- expect(readiness.plan, isEmpty);
- expect(terminalLaunches, 0);
- expect(
- calls.where((line) => line.contains('brew install tmux')),
- hasLength(1),
- );
- expect(readiness.output.join('\n'), contains('tmux installed'));
- },
- );
-
- test('a failed in-app tmux install retries visibly in Terminal', () async {
+ test('a failed in-app tmux install fails the step with the installer as the manual command', () async {
await createManagedHarness();
- String? terminalScript;
- final calls = <String>[];
+ var terminalLaunches = 0;
final provisioner = EnvironmentProvisioner(
harnessHome: scratch,
isMacOS: true,
isLinux: false,
- openTerminal: (path) async => terminalScript = path,
- run: runner(
- tmuxPresent: () => false,
- tmuxInstallExitCode: 7,
- calls: calls,
- ),
+ openTerminal: (_) async => terminalLaunches++,
+ run: runner(tmuxPresent: () => false, tmuxInstallExitCode: 22),
);
final readiness = await provisioner.ensureReady(
@@ -390,14 +288,13 @@ void main() {
mode: EnvironmentSetupMode.automatic,
);
- expect(readiness.phase, EnvironmentSetupPhase.waitingForTerminal);
- expect(
- readiness.steps[EnvironmentStep.tmux],
- EnvironmentStepStatus.needsTerminal,
- );
- expect(terminalScript, isNotNull);
- expect(readiness.output.join('\n'), contains('exited 7'));
- expect(readiness.output.join('\n'), contains('Terminal opened to retry'));
+ expect(readiness.phase, EnvironmentSetupPhase.failed);
+ expect(readiness.steps[EnvironmentStep.tmux], EnvironmentStepStatus.failed);
+ expect(readiness.failure?.step, EnvironmentStep.tmux);
+ expect(readiness.failure?.exitCode, 22);
+ expect(readiness.failure?.command, contains(kHarnessHostSetupCommand));
+ expect(readiness.failure?.detail, contains('exited 22'));
+ expect(terminalLaunches, 0);
});
test('automatic setup installs Harness, then verifies', () async {
diff --git a/desktop/test/environment_setup_screen_test.dart b/desktop/test/environment_setup_screen_test.dart
index f2b9ae081..fb2494bfd 100644
--- a/desktop/test/environment_setup_screen_test.dart
+++ b/desktop/test/environment_setup_screen_test.dart
@@ -18,14 +18,8 @@ const _review = EnvironmentReadiness(
EnvironmentStep.harness: EnvironmentStepStatus.failed,
},
phase: EnvironmentSetupPhase.review,
- // The full ladder — nothing on this computer — so the layout tests see the
- // longest plan the screen can render.
- plan: [
- EnvironmentPlanItem.appleDeveloperTools,
- EnvironmentPlanItem.homebrew,
- EnvironmentPlanItem.tmuxViaHomebrew,
- EnvironmentPlanItem.harnessCli,
- ],
+ // Nothing on this computer — the longest plan the screen renders on macOS.
+ plan: [EnvironmentPlanItem.tmuxManaged, EnvironmentPlanItem.harnessCli],
);
class _Login extends CliLogin {
@@ -214,7 +208,7 @@ void main() {
final app = _app(provisioner);
addTearDown(app.dispose);
await _mount(tester, app, textScale: scale);
- expect(find.text('Install 4 tools').hitTestable(), findsOneWidget);
+ expect(find.text('Install 2 tools').hitTestable(), findsOneWidget);
expect(provisioner.attempts, isEmpty);
app.environmentReadiness = _review.copyWith(
phase: EnvironmentSetupPhase.failed,