#!/usr/bin/env bash # multi-agent-mux-delegate-job β€” user-facing orchestrator for the multi-agent-mux-delegate-job skill. # # Subcommands: # submit register a job, start the subscriber FIRST, then run the agent, # then (optionally) run a validation script. # status show one job record. # list list all jobs. # verify run a user-supplied --validate script against a job's artifacts. # wait block until all running/pending jobs reach a terminal state. # # This is a reference wrapper: it shells out to the python scripts that live # next to it. Copy it into your project and customise as needed. It never hard # fails if `claude`/`codex`/`tmux` are missing β€” it prints what it would run. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Load local .env if it exists in current dir or workspace root if [[ -f .env ]]; then set -a; source .env; set +a elif [[ -f "$SCRIPT_DIR/../../.env" ]]; then set -a; source "$SCRIPT_DIR/../../.env"; set +a fi # Pick an interpreter: prefer a project .venv, else python3. pick_python() { local py_bin if [[ -n "${DELEGATE_JOB_PYTHON:-}" ]]; then py_bin="$DELEGATE_JOB_PYTHON" elif [[ -x "${WORKDIR:-.}/.venv/bin/python" ]]; then py_bin="${WORKDIR}/.venv/bin/python" elif [[ -x ".venv/bin/python" ]]; then py_bin="$(pwd)/.venv/bin/python" else py_bin="python3" fi if ! "$py_bin" -c "import paho.mqtt" 2>/dev/null; then echo "ERROR: paho-mqtt package is missing for $py_bin." >&2 echo " Please create a virtual environment and install it:" >&2 echo " python3 -m venv .venv && .venv/bin/pip install -r \"$SCRIPT_DIR/requirements.txt\"" >&2 exit 1 fi echo "$py_bin" } REGISTRY_DIR_DEFAULT=".mam/jobs" usage() { cat <<'EOF' multi-agent-mux-delegate-job [options] submit --agent --prompt [--workdir ] [--agent-session