#!/usr/bin/env bash
set -euo pipefail

agent="${1:?usage: attach-session <agent>}"
home="/home/${agent}"

cd "${home}"

# Attach if it exists, otherwise create it. -D ensures stale clients do not block reattach.
exec tmux new-session -A -D -s main -c "${home}"
