codeflash-agent/plugin/vendor/codex/scripts/session-start-env.sh
Kevin Turcios 9456cf48fa Add set -e to vendored session-start-env.sh
Match upstream fix: propagate write failures as non-zero exit.
2026-04-21 05:32:30 -05:00

25 lines
717 B
Bash
Executable file

#!/bin/bash
# Codex companion SessionStart: export session ID and plugin data dir.
# Replaces the Node.js session-lifecycle-hook.mjs for the SessionStart path
# to avoid ~100ms V8 startup overhead.
set -euo pipefail
INPUT=$(cat)
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty' 2>/dev/null)
[ -z "$CLAUDE_ENV_FILE" ] && exit 0
shell_escape() {
printf "'%s'" "$(printf '%s' "$1" | sed "s/'/'\"\\'\"'/g")"
}
if [ -n "$SESSION_ID" ]; then
printf 'export CODEX_COMPANION_SESSION_ID=%s\n' "$(shell_escape "$SESSION_ID")" >> "$CLAUDE_ENV_FILE"
fi
if [ -n "${CLAUDE_PLUGIN_DATA:-}" ]; then
printf 'export CLAUDE_PLUGIN_DATA=%s\n' "$(shell_escape "$CLAUDE_PLUGIN_DATA")" >> "$CLAUDE_ENV_FILE"
fi
exit 0