From 350acccd8b3b342ef102a8b4621c2f7e08e50cc8 Mon Sep 17 00:00:00 2001 From: openhands Date: Wed, 18 Mar 2026 16:21:05 +0000 Subject: [PATCH] fix: add create_agent_session and inject_formula to agent-session.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both dev-agent.sh and gardener-agent.sh call these functions but they were never implemented during the #158 extraction. Adds: - create_agent_session(session, workdir) — tmux + claude + wait for ready - inject_formula(session, text) — alias for agent_inject_into_session --- lib/agent-session.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/agent-session.sh b/lib/agent-session.sh index 7c415cc..bbb4eac 100644 --- a/lib/agent-session.sh +++ b/lib/agent-session.sh @@ -40,6 +40,24 @@ agent_inject_into_session() { rm -f "$tmpfile" } +# Create a tmux session running Claude in the given workdir. +# Returns 0 if session is ready, 1 otherwise. +create_agent_session() { + local session="$1" + local workdir="${2:-.}" + tmux new-session -d -s "$session" -c "$workdir" \ + "claude --dangerously-skip-permissions" 2>/dev/null + sleep 1 + tmux has-session -t "$session" 2>/dev/null || return 1 + agent_wait_for_claude_ready "$session" 120 || return 1 + return 0 +} + +# Inject a prompt/formula into a session (alias for agent_inject_into_session). +inject_formula() { + agent_inject_into_session "$@" +} + # Kill a tmux session gracefully (no-op if not found). agent_kill_session() { tmux kill-session -t "$1" 2>/dev/null || true