refactor(security,concurrency): resolve structural issues, enforce Claude permission skip, update docs
This commit is contained in:
@@ -164,12 +164,10 @@ run_agent() {
|
||||
# The user attaches with `tmux attach -t <session>` and types follow-up
|
||||
# prompts themselves. We pre-load the first prompt via stdin and `read`
|
||||
# keeps the pane open after the agent exits so the user can review.
|
||||
case "$AGENT" in
|
||||
claude-code) bin="claude";;
|
||||
codex) bin="codex";;
|
||||
human) echo "[human agent] complete the task, then run publish_event.py --event completed"; return;;
|
||||
*) bin="$AGENT";;
|
||||
esac
|
||||
if [ "$AGENT" = "human" ]; then
|
||||
echo "[human agent] complete the task, then run publish_event.py --event completed"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$DRY_RUN" == "1" ]]; then
|
||||
echo "[dry-run] would launch agent '$AGENT' in a fresh tmux session with instructions:"
|
||||
@@ -182,21 +180,17 @@ run_agent() {
|
||||
echo " Install with: brew install tmux (or your package manager)" >&2
|
||||
return 1
|
||||
fi
|
||||
if ! command -v "$bin" >/dev/null 2>&1; then
|
||||
echo "ERROR: agent binary '$bin' not found in PATH." >&2
|
||||
return 1
|
||||
|
||||
local _tmux="tmux"
|
||||
if [ -n "${TMUX_SERVER_NAME:-}" ]; then
|
||||
_tmux="tmux -L $TMUX_SERVER_NAME"
|
||||
fi
|
||||
|
||||
local sess="${AGENT_SESSION#tmux:}"
|
||||
# Detect a stale session with the same name (e.g. the user is still attached
|
||||
# from an earlier run, or a previous wrapper died without cleanup). tmux
|
||||
# new-session on an existing name fails silently; check first and fail loud.
|
||||
if tmux has-session -t "$sess" 2>/dev/null; then
|
||||
local attached
|
||||
attached=$(tmux list-clients -t "$sess" 2>/dev/null | wc -l | tr -d ' ')
|
||||
echo "ERROR: tmux session '$sess' already exists (clients attached: $attached)." >&2
|
||||
echo " Pick a unique --agent-session (e.g. tmux:demo, tmux:claude-a) or" >&2
|
||||
echo " kill the stale one first: tmux kill-session -t $sess" >&2
|
||||
|
||||
if ! $_tmux has-session -t "$sess" 2>/dev/null; then
|
||||
echo "ERROR: 에이전트 세션 '$sess'이 존재하지 않습니다. 작업을 위임하기 전에 먼저 에이전트 세션을 기동해 주세요." >&2
|
||||
echo " 팁: 'multi-agent-mux-resume' 또는 'multi-agent-mux-create'를 통해 에이전트를 먼저 생성할 수 있습니다." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -206,9 +200,13 @@ run_agent() {
|
||||
trap 'rc=$?; if [ $rc -ne 0 ]; then "$PY" "$pub_script" --job "$job_id" --event error --detail "agent bootstrap failed (exit $rc)"; fi' EXIT
|
||||
fi
|
||||
|
||||
tmux new-session -d -s "$sess" -c "$WORKDIR" \
|
||||
"printf '%s' \"$instructions\" | $bin --dangerously-skip-permissions; echo; echo '--- agent exited (job $job_id); press enter to close ---'; read"
|
||||
echo "agent launched in tmux session: $sess (attach with: tmux attach -t $sess)"
|
||||
echo "살아있는 에이전트 세션 '$sess'에 작업을 위임합니다..."
|
||||
$_tmux set-buffer -b "job_buf_$job_id" "$instructions"
|
||||
$_tmux paste-buffer -b "job_buf_$job_id" -t "$sess"
|
||||
$_tmux send-keys -t "$sess" C-m
|
||||
$_tmux delete-buffer -b "job_buf_$job_id"
|
||||
|
||||
echo "작업이 세션 '$sess'에 전송되었습니다. (연결하려면: $_tmux attach -t $sess)"
|
||||
trap - EXIT
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user