feat(cli,registry): introduce --herdr-workspace option and decouple socket fallback chains
This commit is contained in:
@@ -68,6 +68,7 @@ If any check fails → abort with a non-zero exit and report the reason (automat
|
||||
When running multiple agent sessions alongside other workflows (e.g., cmux, background workers, manual herdr sessions), sharing the default herdr server can lead to session name conflicts, monitoring clutter, and accidental destruction of user sessions via global commands.
|
||||
|
||||
To prevent this, you can run this skill inside an **isolated herdr session** using the `HERDR_SESSION_NAME` environment variable or the `--herdr-session <name>` flag (opt-in; alias: `--herdr-server`; legacy env alias: `HERDR_SERVER_NAME`).
|
||||
Additionally, you can specify `--herdr-workspace <name>` to record a distinct project workspace label in `.mam/agent-sessions.yaml` (default: workspace slug without `mam-` prefix). Note that `--herdr-workspace` is a metadata label only and never selects a herdr daemon socket.
|
||||
|
||||
Under the hood this maps to a real, separate herdr **session** (`herdr --session <name>` — its own socket, its own `agent list`/`workspace list`, completely invisible to the default session and vice versa), not just a workspace label inside the same server. `lib.sh`'s shim bootstraps the named session's server headlessly (`herdr --session <name> server`, backgrounded) the first time it's needed, and scopes every subsequent herdr call to it automatically — this headless bootstrap is what lets it work even when the skill itself is running from inside another herdr-managed pane (a plain interactive `herdr --session <name>` launch is blocked there by herdr's "nested herdr is disabled" guard; headless `server` mode isn't).
|
||||
|
||||
@@ -79,7 +80,7 @@ Under the hood this maps to a real, separate herdr **session** (`herdr --session
|
||||
```
|
||||
2. **Via Option Flag**:
|
||||
```bash
|
||||
bash scripts/create_session.sh --workspace /path/to/project --agent claude --role developer --herdr-session multi-agent-canary
|
||||
bash scripts/create_session.sh --workspace /path/to/project --agent claude --role developer --herdr-session multi-agent-canary --herdr-workspace my-project
|
||||
```
|
||||
3. **Submit Job Integration**:
|
||||
You can automatically register a delegated job with a prompt when creating a session:
|
||||
|
||||
@@ -37,6 +37,10 @@ Options:
|
||||
--dry-run print commands without executing
|
||||
--herdr-session NAME specify isolated herdr session name (alias: --herdr-server)
|
||||
--herdr-server NAME specify isolated herdr session name (legacy alias)
|
||||
--herdr-workspace NAME workspace label recorded in the registry
|
||||
(flag > \$HERDR_WORKSPACE > workspace slug without mam-).
|
||||
A label only — it never selects a herdr socket;
|
||||
use --herdr-session for that.
|
||||
--submit-job PROMPT submit a job to multi-agent-mux-delegate-job registry with the given prompt
|
||||
--onboard automatically submit a project alignment/orientation job to the new agent
|
||||
--no-onboard disable automatic onboarding job submission
|
||||
@@ -53,6 +57,7 @@ SESSION_NAME=""
|
||||
USE_WRAPPER=0
|
||||
DRY_RUN=0
|
||||
HERDR_SERVER_OPT=""
|
||||
HERDR_WORKSPACE_OPT=""
|
||||
SUBMIT_JOB_PROMPT=""
|
||||
ONBOARD=1
|
||||
|
||||
@@ -65,6 +70,7 @@ while [ $# -gt 0 ]; do
|
||||
--wrapper) USE_WRAPPER=1; shift ;;
|
||||
--dry-run) DRY_RUN=1; shift ;;
|
||||
--herdr-session|--herdr-server) HERDR_SERVER_OPT="$2"; shift 2 ;;
|
||||
--herdr-workspace) HERDR_WORKSPACE_OPT="$2"; shift 2 ;;
|
||||
--submit-job) SUBMIT_JOB_PROMPT="$2"; shift 2 ;;
|
||||
--onboard) ONBOARD=1; shift ;;
|
||||
--no-onboard) ONBOARD=0; shift ;;
|
||||
@@ -137,6 +143,10 @@ LOCAL_BIN="${LOCAL_BIN:-$HOME/.local/bin}"
|
||||
WRAPPER="$LOCAL_BIN/$SESSION_NAME"
|
||||
|
||||
ws_slug="$(derive_workspace_slug "$WORKSPACE")"
|
||||
# 플래그 > 환경변수 > 워크스페이스 슬러그 (C-3: HERDR_SESSION_NAME 과 대칭).
|
||||
# D5: resolve_herdr_workspace 를 쓰지 않는다 — 동명 terminated 행 위에 재생성할 때
|
||||
# 낡은 pane.cwd 에서 파생된 라벨을 물려받기 때문 (create 는 사실을 세우는 쪽).
|
||||
MAM_WS_LABEL="${HERDR_WORKSPACE_OPT:-${HERDR_WORKSPACE:-${ws_slug#mam-}}}"
|
||||
if [ -z "$HERDR_SERVER_OPT" ]; then
|
||||
if [ -z "${HERDR_SESSION_NAME:-}" ] || [ "$HERDR_SESSION_NAME" = "default" ]; then
|
||||
export HERDR_SESSION_NAME="$ws_slug"
|
||||
@@ -197,7 +207,7 @@ spawn() {
|
||||
}
|
||||
|
||||
if [ "$DRY_RUN" = "1" ]; then
|
||||
echo "[dry-run] would spawn: herdr session '$SESSION_NAME' in $WORKSPACE (agent=$AGENT, herdr_session=${HERDR_SESSION_NAME:-default})"
|
||||
echo "[dry-run] would spawn: herdr session '$SESSION_NAME' in $WORKSPACE (agent=$AGENT, herdr_session=${HERDR_SESSION_NAME:-default}, herdr_workspace=${MAM_WS_LABEL})"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -214,7 +224,7 @@ cleanup_herdr_on_error() {
|
||||
trap cleanup_herdr_on_error EXIT
|
||||
|
||||
if [ -z "$HERDR_SERVER_OPT" ]; then
|
||||
RESOLVED_SERVER="$(resolve_herdr_workspace "$SESSION_NAME" "$WORKSPACE")"
|
||||
RESOLVED_SERVER="$(resolve_herdr_session "$SESSION_NAME" "$WORKSPACE")"
|
||||
export HERDR_SESSION_NAME="${HERDR_SESSION_NAME:-$RESOLVED_SERVER}"
|
||||
fi
|
||||
|
||||
@@ -285,6 +295,7 @@ atomic_dump_yaml "$AGENT_SESSIONS_YAML" \
|
||||
HERDR_EPOCH="$HERDR_EPOCH" PANE_PID="$PANE_PID" PANE_CWD="$PANE_CWD" \
|
||||
CMD_FULL="$CMD_FULL" START_CMD="$START_CMD" CHILD_PID="$CHILD_PID" \
|
||||
HERDR_SESSION_NAME="${HERDR_SESSION_NAME:-default}" \
|
||||
MAM_WS_LABEL="$MAM_WS_LABEL" \
|
||||
SESSION_UUID="$SESSION_UUID" \
|
||||
DELEGATE_JOB_ID="$DELEGATE_JOB_ID" ROLE="$ROLE" <<'PYEOF'
|
||||
name = os.environ['SESSION_NAME']
|
||||
@@ -313,6 +324,7 @@ entry = {
|
||||
'herdr_session_epoch': int(epoch) if epoch.isdigit() else 0,
|
||||
'herdr_session': server_name,
|
||||
'herdr_server': server_name,
|
||||
'herdr_workspace': os.environ.get('MAM_WS_LABEL', ''),
|
||||
'delegate_job_id': os.environ.get('DELEGATE_JOB_ID', '') or None,
|
||||
'pane': {
|
||||
'index': 0,
|
||||
|
||||
Reference in New Issue
Block a user