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 support for building and publishing a managed macOS tmux runtime

0xken158348c550809d
diff --git a/.github/workflows/release-tmux-runtime.yml b/.github/workflows/release-tmux-runtime.yml
new file mode 100644
index 000000000..74ee14bf7
--- /dev/null
+++ b/.github/workflows/release-tmux-runtime.yml
@@ -0,0 +1,101 @@
+name: Release tmux runtime
+
+# Build and publish the managed tmux for macOS — the archive a Mac with no tmux and no Homebrew will
+# download into ~/.harness/runtime, the way it already downloads Node. Built once per tmux version,
+# here, so obtaining tmux never needs a compiler, a package manager or a password on the user's
+# computer. The recipe (static libevent + ncurses, tmux linked against them) and its three macOS
+# traps live in cli/scripts/build-managed-tmux.sh; publishing is desktop/scripts/publish-managed-
+# tmux-runtime.sh, a sibling of the Node publisher, writing harness/runtime/tmux/metadata.json.
+#
+# gh workflow run release-tmux-runtime.yml -f tmux_version=3.5a # build + publish
+# gh workflow run release-tmux-runtime.yml -f tmux_version=3.5a -f publish=false # build only, inspect the artifacts
+#
+# A macos-15 runner is Apple Silicon; the x64 archive is cross-built there and smoke-tested under
+# Rosetta by the build script itself. Nothing consumes the manifest until install.sh is taught to.
+
+on:
+ workflow_dispatch:
+ inputs:
+ tmux_version:
+ description: 'tmux release to build (its sha256 is pinned in the build script)'
+ required: true
+ default: '3.5a'
+ publish:
+ description: 'Upload the archives and rewrite harness/runtime/tmux/metadata.json'
+ type: boolean
+ default: true
+
+permissions:
+ contents: read
+
+env:
+ GCS_BUCKET: s3-autonomous-upgrade-3
+
+jobs:
+ # Proving the credential first: the builds take minutes, a bad secret costs seconds.
+ preflight:
+ if: ${{ inputs.publish }}
+ runs-on: ubuntu-latest
+ steps:
+ - uses: google-github-actions/auth@v2
+ with:
+ credentials_json: ${{ secrets.GCP_SA_KEY }}
+ - uses: google-github-actions/setup-gcloud@v2
+ - name: Verify GCS write access
+ run: |
+ set -euo pipefail
+ probe="gs://${GCS_BUCKET}/harness/runtime/tmux/.ci-preflight/${GITHUB_RUN_ID}"
+ echo "$GITHUB_RUN_ID" | gsutil cp - "$probe"
+ gsutil rm "$probe"
+
+ build:
+ runs-on: macos-15
+ strategy:
+ fail-fast: true
+ matrix:
+ platform: [darwin-arm64, darwin-x64]
+ steps:
+ - uses: actions/checkout@v7
+ - name: Build tmux ${{ inputs.tmux_version }} for ${{ matrix.platform }}
+ env:
+ TMUX_VERSION: ${{ inputs.tmux_version }}
+ run: |
+ set -euo pipefail
+ bash cli/scripts/build-managed-tmux.sh "${{ matrix.platform }}" "$RUNNER_TEMP/dist"
+ archive="$RUNNER_TEMP/dist/tmux-${TMUX_VERSION}-${{ matrix.platform }}.tar.gz"
+ {
+ echo "### tmux ${TMUX_VERSION} · ${{ matrix.platform }}"
+ echo '```'
+ echo "size $(wc -c < "$archive" | tr -d ' ') bytes"
+ echo "sha256 $(shasum -a 256 "$archive" | awk '{print $1}')"
+ tar -tzf "$archive"
+ echo '```'
+ } >> "$GITHUB_STEP_SUMMARY"
+ - uses: actions/upload-artifact@v4
+ with:
+ name: tmux-${{ inputs.tmux_version }}-${{ matrix.platform }}
+ path: ${{ runner.temp }}/dist/tmux-${{ inputs.tmux_version }}-${{ matrix.platform }}.tar.gz
+ if-no-files-found: error
+ retention-days: 14
+
+ publish:
+ if: ${{ inputs.publish }}
+ needs: [preflight, build]
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v7
+ - uses: actions/download-artifact@v4
+ with:
+ pattern: tmux-${{ inputs.tmux_version }}-*
+ path: dist
+ merge-multiple: true
+ - uses: google-github-actions/auth@v2
+ with:
+ credentials_json: ${{ secrets.GCP_SA_KEY }}
+ - uses: google-github-actions/setup-gcloud@v2
+ - name: Publish archives and manifest
+ run: |
+ set -euo pipefail
+ ls -la dist
+ bash desktop/scripts/publish-managed-tmux-runtime.sh "${{ inputs.tmux_version }}" dist
+ echo "Published tmux **${{ inputs.tmux_version }}** → \`https://storage.googleapis.com/${GCS_BUCKET}/harness/runtime/tmux/metadata.json\`" >> "$GITHUB_STEP_SUMMARY"
diff --git a/Makefile b/Makefile
index dfa268960..d082e5566 100644
--- a/Makefile
+++ b/Makefile
@@ -27,7 +27,7 @@ release-backend:
## and both Linux architectures, publishes to GCS, and cuts the GitHub Release. The version is bumped
## from max(last git tag, live harness/desktop/metadata.json). ARGS="--dry-run" to preview,
## ARGS="--minor" for a forced-update minor bump, ARGS="X.Y.Z" for an explicit version. The by-hand
-## escape hatches (upload-desktop, upload-desktop-linux, upload-node-runtime) live in desktop/Makefile.
+## escape hatches (upload-desktop, upload-desktop-linux, upload-node-runtime, upload-tmux-runtime) live in desktop/Makefile.
release-desktop:
bash desktop/scripts/release-desktop.sh $(ARGS)
diff --git a/cli/scripts/build-managed-tmux.sh b/cli/scripts/build-managed-tmux.sh
new file mode 100755
index 000000000..f9b085fc2
--- /dev/null
+++ b/cli/scripts/build-managed-tmux.sh
@@ -0,0 +1,171 @@
+#!/usr/bin/env bash
+# Build the managed tmux that `install.sh` downloads on a Mac that has no tmux and no Homebrew —
+# the same idea as the managed Node under ~/.harness/runtime: one checksum-verified archive we
+# publish, so obtaining tmux never needs a compiler, a package manager or a password on the user's
+# computer. Homebrew was how tmux got built before, and Homebrew's installer needs the Apple
+# developer tools, which cost a Terminal window, a 2 GB download and a ten-minute wait for a 1 MB
+# binary. This runs that build ONCE, in CI, per version.
+#
+# bash cli/scripts/build-managed-tmux.sh darwin-arm64 [out-dir]
+# bash cli/scripts/build-managed-tmux.sh darwin-x64 [out-dir] # cross-built on an arm64 Mac
+#
+# Produces <out-dir>/tmux-<ver>-<platform>.tar.gz whose root is tmux-<ver>-<platform>/bin/tmux,
+# plus the three upstream licences. libevent and ncurses are linked statically; libSystem stays
+# dynamic, as every macOS binary's does. Needs the Command Line Tools HERE, and nowhere else.
+#
+# The three sources are pinned by version AND sha256: a moved tarball fails loudly rather than
+# building something else. ncurses's unversioned `ncurses.tar.gz` is deliberately not used.
+set -euo pipefail
+
+PLATFORM="${1:-}"
+OUT_DIR="${2:-$PWD/dist/tmux}"
+case "$PLATFORM" in
+ darwin-arm64) ARCH=arm64; HOST=aarch64-apple-darwin ;;
+ darwin-x64) ARCH=x86_64; HOST=x86_64-apple-darwin ;;
+ *)
+ echo "usage: $0 darwin-arm64|darwin-x64 [out-dir]" >&2
+ exit 2
+ ;;
+esac
+[ "$(uname -s)" = Darwin ] || { echo "error: the managed tmux is built on macOS" >&2; exit 1; }
+
+TMUX_VERSION="${TMUX_VERSION:-3.5a}"
+LIBEVENT_VERSION="${LIBEVENT_VERSION:-2.1.12-stable}"
+NCURSES_VERSION="${NCURSES_VERSION:-6.5}"
+
+# Pinned sources. Bumping a version means bumping its checksum in the same change.
+LIBEVENT_URL="https://github.com/libevent/libevent/releases/download/release-${LIBEVENT_VERSION}/libevent-${LIBEVENT_VERSION}.tar.gz"
+LIBEVENT_SHA256="${LIBEVENT_SHA256:-92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb}"
+NCURSES_URL="https://invisible-mirror.net/archives/ncurses/ncurses-${NCURSES_VERSION}.tar.gz"
+NCURSES_SHA256="${NCURSES_SHA256:-136d91bc269a9a5785e5f9e980bc76ab57428f604ce3e5a5a90cebc767971cc6}"
+TMUX_URL="https://github.com/tmux/tmux/releases/download/${TMUX_VERSION}/tmux-${TMUX_VERSION}.tar.gz"
+TMUX_SHA256="${TMUX_SHA256:-16216bd0877170dfcc64157085ba9013610b12b082548c7c9542cc0103198951}"
+
+for command in curl tar shasum make cc codesign otool; do
+ command -v "$command" >/dev/null 2>&1 || { echo "error: $command is required" >&2; exit 1; }
+done
+/usr/bin/xcrun --find clang >/dev/null 2>&1 || {
+ echo "error: the Apple developer tools are required to BUILD tmux (never to install it)" >&2
+ exit 1
+}
+
+# `--host` only when actually cross-compiling. Passing it for the native build flips autoconf into
+# cross mode, where run-time feature tests are skipped and answered "no" — libevent then built a
+# tmux that segfaulted in evutil_make_internal_pipe_ on the very Mac that built it.
+NATIVE_ARCH="$(uname -m)"
+[ "$NATIVE_ARCH" = arm64 ] && NATIVE_ARCH=arm64 || NATIVE_ARCH=x86_64
+if [ "$ARCH" = "$NATIVE_ARCH" ]; then HOST_FLAG=""; else HOST_FLAG="--host=$HOST"; fi
+
+WORK="$(mktemp -d)"
+# KEEP_WORK=1 leaves the build tree behind for a post-mortem.
+[ -n "${KEEP_WORK:-}" ] && echo ">> work dir: $WORK" || trap 'rm -rf "$WORK"' EXIT
+ROOT="tmux-${TMUX_VERSION}-${PLATFORM}"
+STAGE="$WORK/stage/$ROOT"
+DEPS="$WORK/deps"
+mkdir -p "$STAGE/bin" "$DEPS" "$OUT_DIR"
+NPROC="$(sysctl -n hw.ncpu 2>/dev/null || echo 2)"
+
+fetch() { # url sha256 name
+ local archive="$WORK/$3.tar.gz" got
+ echo ">> $3: downloading $1"
+ curl -fsSL "$1" -o "$archive"
+ got="$(shasum -a 256 "$archive" | awk '{print $1}')"
+ [ "$got" = "$2" ] || { echo "error: $3 checksum mismatch (expected $2, got $got)" >&2; exit 1; }
+ mkdir -p "$WORK/src/$3"
+ tar -xzf "$archive" -C "$WORK/src/$3" --strip-components=1
+}
+fetch "$LIBEVENT_URL" "$LIBEVENT_SHA256" libevent
+fetch "$NCURSES_URL" "$NCURSES_SHA256" ncurses
+fetch "$TMUX_URL" "$TMUX_SHA256" tmux
+
+# One toolchain line for all three: the target arch (cross-built for x64 on an arm64 Mac) and a
+# deployment target old enough for every Mac the app supports.
+export MACOSX_DEPLOYMENT_TARGET="${MACOSX_DEPLOYMENT_TARGET:-12.0}"
+# The /usr/bin shim resolves the SDK through xcrun; the toolchain's own clang does not, and links
+# nothing without an explicit sysroot.
+export SDKROOT="$(/usr/bin/xcrun --show-sdk-path)"
+export CC=/usr/bin/clang
+export CFLAGS="-arch $ARCH -O2 -isysroot $SDKROOT"
+export LDFLAGS="-arch $ARCH -isysroot $SDKROOT -L$DEPS/lib"
+export CPPFLAGS="-I$DEPS/include -I$DEPS/include/ncursesw"
+export PKG_CONFIG_PATH="$DEPS/lib/pkgconfig"
+
+echo ">> libevent $LIBEVENT_VERSION"
+(
+ cd "$WORK/src/libevent"
+ # A current macOS SDK makes autoconf's link test for pipe2 succeed although macOS has no pipe2;
+ # the resulting HAVE_PIPE2 sends evutil_make_internal_pipe_ through a null pointer on the first
+ # new-session. Answered up front, then every Linux-only syscall is re-checked below.
+ # shellcheck disable=SC2086
+ ac_cv_func_pipe2=no ./configure $HOST_FLAG --prefix="$DEPS" --disable-shared --enable-static \
+ --disable-openssl --disable-samples --disable-libevent-regress --disable-debug-mode >/dev/null
+ if grep -Eq '^#define (EVENT__)?HAVE_(PIPE2|EPOLL|EVENTFD|TIMERFD|ACCEPT4|SIGNALFD|SPLICE)\b' config.h; then
+ echo "error: libevent's configure detected a Linux-only call on macOS:" >&2
+ grep -E '^#define (EVENT__)?HAVE_(PIPE2|EPOLL|EVENTFD|TIMERFD|ACCEPT4|SIGNALFD|SPLICE)\b' config.h >&2
+ exit 1
+ fi
+ make -j"$NPROC" >/dev/null 2>&1
+ make install >/dev/null
+)
+
+# ncurses: static, terminfo read from the macOS system database (tmux-256color is there on
+# macOS 13+, screen-256color everywhere), so no `tic`, no bundled terminfo, no programs that would
+# shadow /usr/bin/clear and friends.
+echo ">> ncurses $NCURSES_VERSION"
+(
+ cd "$WORK/src/ncurses"
+ # shellcheck disable=SC2086
+ ./configure $HOST_FLAG --prefix="$DEPS" \
+ --with-termlib --without-shared --with-normal --without-debug --without-ada \
+ --without-progs --without-manpages --without-tests --without-cxx --without-cxx-binding \
+ --enable-pc-files --with-pkg-config-libdir="$DEPS/lib/pkgconfig" \
+ --with-default-terminfo-dir=/usr/share/terminfo \
+ --with-terminfo-dirs=/usr/share/terminfo:/usr/lib/terminfo \
+ --disable-db-install >/dev/null 2>&1
+ make -j"$NPROC" >/dev/null 2>&1
+ make install >/dev/null 2>&1
+)
+
+echo ">> tmux $TMUX_VERSION"
+(
+ cd "$WORK/src/tmux"
+ # Named explicitly rather than left to pkg-config: ncurses 6 installs the wide-character
+ # `tinfow`, tmux's configure asks pkg-config for `tinfo`, and on a miss it silently links the
+ # system's ncurses 5.4 against our 6.5 headers — a binary that answers `-V` and then segfaults on
+ # `new-session`. The .a files above are the only libraries at these paths, so the link is static
+ # without any macOS-unfriendly -static flag.
+ LIBEVENT_CORE_CFLAGS="-I$DEPS/include" LIBEVENT_CORE_LIBS="-L$DEPS/lib -levent_core" \
+ LIBTINFO_CFLAGS="-I$DEPS/include -I$DEPS/include/ncursesw" LIBTINFO_LIBS="-L$DEPS/lib -ltinfow" \
+ ./configure $HOST_FLAG --prefix="$STAGE" --disable-utf8proc >/dev/null
+ make -j"$NPROC" >/dev/null 2>&1
+ cp tmux "$STAGE/bin/tmux"
+ cp COPYING "$STAGE/LICENSE.tmux"
+)
+cp "$WORK/src/libevent/LICENSE" "$STAGE/LICENSE.libevent"
+cp "$WORK/src/ncurses/COPYING" "$STAGE/LICENSE.ncurses"
+
+# Ad-hoc signature (the linker adds one on arm64; make it explicit and identical for x64). Nothing
+# here is notarized: curl sets no quarantine flag, so Gatekeeper never sees the binary.
+codesign -s - --force "$STAGE/bin/tmux" 2>/dev/null
+
+# The whole point: nothing but the OS may be needed at run time — no package-manager library, and
+# not the system's ncurses 5.4 either (see the tmux configure note above).
+if otool -L "$STAGE/bin/tmux" | tail -n +2 | grep -Ev '^\s+/usr/lib/lib(System\.B|resolv\.9|util)\.dylib '; then
+ echo "error: tmux links a library outside libSystem:" >&2
+ otool -L "$STAGE/bin/tmux" >&2
+ exit 1
+fi
+
+# Smoke test: version, then a real server on a private socket, under Rosetta for the x64 build.
+run() {
+ if [ "$ARCH" = x86_64 ] && [ "$(uname -m)" = arm64 ]; then arch -x86_64 "$@"; else "$@"; fi
+}
+run "$STAGE/bin/tmux" -V
+SOCKET="$WORK/smoke.sock"
+TERM=xterm-256color run "$STAGE/bin/tmux" -S "$SOCKET" -f /dev/null new-session -d -s smoke 'sleep 30'
+run "$STAGE/bin/tmux" -S "$SOCKET" list-sessions | grep -q '^smoke:'
+run "$STAGE/bin/tmux" -S "$SOCKET" kill-server
+
+ARCHIVE="$OUT_DIR/$ROOT.tar.gz"
+tar -czf "$ARCHIVE" -C "$WORK/stage" "$ROOT"
+echo ">> built $ARCHIVE ($(wc -c < "$ARCHIVE" | tr -d ' ') bytes, sha256 $(shasum -a 256 "$ARCHIVE" | awk '{print $1}'))"
diff --git a/desktop/CLAUDE.md b/desktop/CLAUDE.md
index ab2f28a7e..a71b788bd 100644
--- a/desktop/CLAUDE.md
+++ b/desktop/CLAUDE.md
@@ -80,7 +80,9 @@ gets a `version.txt` written into the built bundle at package time (see `lib/cor
since `flutter build linux` has no Info.plist-style stamping). Test the updater against a scratch
manifest with `--dart-define=DESKTOP_UPDATE_METADATA_URL=...`; `HARNESS_RUNTIME_METADATA_URL` does
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`), but
+`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
its consumer is now the `harness` installer rather than this app.
## Architecture
diff --git a/desktop/Makefile b/desktop/Makefile
index 1e20a2376..fa1c1ef37 100644
--- a/desktop/Makefile
+++ b/desktop/Makefile
@@ -1,4 +1,4 @@
-.PHONY: release upload-desktop upload-desktop-linux upload-node-runtime terminal-local-manual terminal-local-e2e terminal-prod-e2e
+.PHONY: release upload-desktop upload-desktop-linux upload-node-runtime upload-tmux-runtime terminal-local-manual terminal-local-e2e terminal-prod-e2e
## release: tag this commit vX.Y.Z_desktop and push the tag — CI builds macOS + Linux, publishes to
## GCS, and cuts the GitHub Release. The version is bumped from max(last git tag, live metadata.json),
@@ -30,6 +30,11 @@ upload-desktop-linux:
upload-node-runtime:
bash scripts/publish-managed-node-runtime.sh $(ARGS)
+## upload-tmux-runtime: publish the macOS tmux archives built by cli/scripts/build-managed-tmux.sh
+## (ARGS="3.5a <dir>"). CI does this from release-tmux-runtime.yml; by hand only for a rebuild.
+upload-tmux-runtime:
+ bash scripts/publish-managed-tmux-runtime.sh $(ARGS)
+
## terminal-local-manual: start the local backend/CLI stack and open the desktop fixture.
terminal-local-manual:
bash scripts/start-terminal-local-manual.sh
diff --git a/desktop/RELEASE.md b/desktop/RELEASE.md
index 61cee8a93..a6d5976b7 100644
--- a/desktop/RELEASE.md
+++ b/desktop/RELEASE.md
@@ -60,6 +60,32 @@ 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.
+## Managed tmux runtime (macOS)
+
+The same idea as Node, for the one host dependency that still came from a package manager: a
+checksum-verified `tmux` archive under `harness/runtime/tmux/`, built once per tmux version so a Mac
+with no tmux and no Homebrew can obtain it with no compiler, no package manager and no password.
+`cli/scripts/build-managed-tmux.sh` builds tmux against static libevent and ncurses (terminfo is
+read from macOS's own `/usr/share/terminfo`); the result links only `libSystem` and is ad-hoc
+signed. Its three macOS traps — the toolchain `clang` needing `SDKROOT`, tmux's configure silently
+linking the system ncurses 5.4 unless `LIBTINFO_LIBS` is explicit, and libevent's autoconf detecting
+a `pipe2` macOS does not have — are handled in the script and gated by `otool -L` and a real
+`new-session` smoke test (under Rosetta for the x64 build).
+
+Publish from CI, never by hand unless rebuilding the same version:
+
+```bash
+gh workflow run release-tmux-runtime.yml -f tmux_version=3.5a # build both, publish
+gh workflow run release-tmux-runtime.yml -f tmux_version=3.5a -f publish=false # build only, inspect
+make upload-tmux-runtime ARGS="3.5a /path/to/archives" # the publisher CI calls
+```
+
+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.
+
## Two macOS builds — Intel on Skia, Apple Silicon on Impeller
Every release ships the macOS app **twice**: the same universal (arm64 + x86_64) build of the same
diff --git a/desktop/scripts/publish-managed-tmux-runtime.sh b/desktop/scripts/publish-managed-tmux-runtime.sh
new file mode 100755
index 000000000..76b572e45
--- /dev/null
+++ b/desktop/scripts/publish-managed-tmux-runtime.sh
@@ -0,0 +1,99 @@
+#!/usr/bin/env bash
+# Publish the macOS tmux archives that `cli/scripts/build-managed-tmux.sh` produced, the same way
+# publish-managed-node-runtime.sh publishes Node: immutable archives under harness/runtime/tmux/,
+# and a manifest whose sha256 is what the installer trusts — never a checksum file fetched at
+# install time. Its own manifest, harness/runtime/tmux/metadata.json, rather than an entry in Node's:
+# install.sh slices a manifest by the FIRST "<platform>" key it finds, and Node's already has one.
+#
+# Usage: bash scripts/publish-managed-tmux-runtime.sh 3.5a <dir holding tmux-3.5a-darwin-{arm64,x64}.tar.gz>
+#
+# Nothing consumes this manifest yet; install.sh learns to download it in the next step.
+set -euo pipefail
+set +x
+
+VERSION="${1:-}"
+ARCHIVES_DIR="${2:-}"
+if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+[a-z]?$ ]] || [[ -z "$ARCHIVES_DIR" ]]; then
+ echo "usage: $0 <tmux version, e.g. 3.5a> <archives dir>" >&2
+ exit 2
+fi
+[[ -d "$ARCHIVES_DIR" ]] || { echo "error: $ARCHIVES_DIR is not a directory" >&2; exit 2; }
+
+for command in gsutil shasum python3; do
+ command -v "$command" >/dev/null 2>&1 || {
+ echo "error: $command is required" >&2
+ exit 1
+ }
+done
+
+GCS_BUCKET="${GCS_BUCKET:-s3-autonomous-upgrade-3}"
+PUBLIC_BASE="${GCS_PUBLIC_BASE_URL:-https://storage.googleapis.com/${GCS_BUCKET}}"
+METADATA_PATH="${METADATA_PATH:-harness/runtime/tmux/metadata.json}"
+WORK_DIR="$(mktemp -d)"
+SRC="$WORK_DIR/metadata.json"
+DST="$WORK_DIR/metadata.next.json"
+trap 'rm -rf "$WORK_DIR"' EXIT
+
+# Both platforms or nothing: a manifest naming one Mac and not the other would make the installer's
+# behaviour depend on which laptop it runs on.
+declare -a ENTRIES=()
+for platform in darwin-arm64 darwin-x64; do
+ archive="tmux-${VERSION}-${platform}.tar.gz"
+ archive_path="$ARCHIVES_DIR/$archive"
+ [[ -f "$archive_path" ]] || { echo "error: missing $archive_path" >&2; exit 1; }
+ root="tmux-${VERSION}-${platform}"
+ tar -tzf "$archive_path" | grep -qx "${root}/bin/tmux" || {
+ echo "error: $archive has no ${root}/bin/tmux" >&2
+ exit 1
+ }
+ sha256="$(shasum -a 256 "$archive_path" | awk '{print $1}')"
+ size="$(wc -c < "$archive_path" | tr -d ' ')"
+ ENTRIES+=("$platform|$VERSION|$archive|$sha256|$size|$root")
+done
+
+for entry in "${ENTRIES[@]}"; do
+ IFS='|' read -r platform version archive sha256 size root <<< "$entry"
+ object_path="harness/runtime/tmux/v${version}/${archive}"
+ echo ">> uploading $archive ($size bytes, sha256 $sha256)"
+ gsutil -h 'Cache-Control:public, max-age=31536000, immutable' cp \
+ "$ARCHIVES_DIR/$archive" "gs://${GCS_BUCKET}/${object_path}"
+done
+
+if ! gsutil cp "gs://${GCS_BUCKET}/${METADATA_PATH}" "$SRC" 2>/dev/null; then
+ printf '{}' > "$SRC"
+fi
+
+python3 - "$SRC" "$DST" "${PUBLIC_BASE%/}" "${ENTRIES[@]}" <<'PY'
+import json, sys
+src, dst, public_base, *entries = sys.argv[1:]
+try:
+ with open(src) as f:
+ document = json.load(f)
+except (OSError, json.JSONDecodeError):
+ document = {}
+if not isinstance(document, dict):
+ document = {}
+tmux = document.get("tmux")
+if not isinstance(tmux, dict):
+ tmux = {}
+document["tmux"] = tmux
+for entry in entries:
+ platform, version, archive, sha256, size, root = entry.split("|", 5)
+ tmux[platform] = {
+ "version": version,
+ "url": f"{public_base}/harness/runtime/tmux/v{version}/{archive}",
+ "sha256": sha256,
+ "size": int(size),
+ "archiveRoot": root,
+ }
+with open(dst, "w") as f:
+ json.dump(document, f, indent=2)
+ f.write("\n")
+PY
+
+gsutil -h 'Content-Type:application/json' \
+ -h 'Cache-Control:no-cache, no-store, must-revalidate' \
+ cp "$DST" "gs://${GCS_BUCKET}/${METADATA_PATH}"
+
+echo ">> published managed tmux ${VERSION}"
+echo ">> manifest: ${PUBLIC_BASE%/}/${METADATA_PATH}"