Files
loki/scripts/run-codex-task.sh
T
g-butandClaude Sonnet 4.6 f3e706875e fix(beacon): fix two runner script bugs blocking codex/gemini switches
run-codex-task.sh passed --ask-for-approval which only exists on the
interactive codex CLI, not codex exec — causing immediate failure on
every switch. Also both runner scripts computed ROOT=parent-of-scripts-dir
which resolves to ~/.local/share when installed, making the stop-hook
call (agent-hook-bridge.sh) silently fail every run. Fixed to use
SCRIPT_DIR (same directory as the runners) which works both in the
repo and from the installed ~/.local/share/cockpit-beacon/ location.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 01:03:02 +02:00

38 lines
859 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
if [ "$#" -lt 3 ]; then
echo "usage: run-codex-task.sh <tab> <project-dir> <prompt-file> [model]" >&2
exit 2
fi
TAB_NAME="$1"
PROJECT_DIR="$2"
PROMPT_FILE="$3"
MODEL="${4:-gpt-5.4}" # must match AGENT_DEFAULT_MODELS.codex in src/lib/agent-registry.ts
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SESSION_DIR="${AGENT_SESSIONS_DIR:-$HOME/.claude/sessions}"
mkdir -p "$SESSION_DIR"
source "$HOME/.bashrc" >/dev/null 2>&1 || true
cd "$PROJECT_DIR"
status=0
codex exec \
--model "$MODEL" \
--cd "$PROJECT_DIR" \
--sandbox workspace-write \
--add-dir "$SESSION_DIR" \
- < "$PROMPT_FILE" || status=$?
rm -f "$PROMPT_FILE"
printf '%s' "$PROJECT_DIR" \
| jq -Rs '{cwd:.}' \
| AGENT_TAB_NAME="$TAB_NAME" AGENT_CURRENT_AGENT="codex" "$SCRIPT_DIR/agent-hook-bridge.sh" stop || true
exit "$status"