Repository Public
1#!/bin/sh2# cr-codex-notify — Codex `notify` relay for Codex Remote.3# Registered as the top-level `notify` program of $CODEX_HOME/config.toml. Codex runs it with one4# extra argument, a JSON object ({"type":"agent-turn-complete","thread-id":…,…}); the runtime maps5# "agent-turn-complete" to the event the server treats as "waiting for input" (Stop).6# Outside a Codex Remote terminal session (no CR_SESSION_ID) it does nothing. It never prints7# anything, never blocks Codex for more than ~2 s and ALWAYS exits 0.8[ -n "${CR_SESSION_ID:-}" ] || exit 09[ -n "${CR_HOOK_SOCKET:-}" ] || exit 010[ -n "${CR_HOOK_TOKEN:-}" ] || exit 011command -v curl >/dev/null 2>&1 || exit 012# The JSON payload is the LAST argument (any configured arguments come before it).13payload=14for arg in "$@"; do payload=$arg; done15[ -n "$payload" ] || exit 016# The payload goes through stdin and the token through a curl config on fd 3, so that neither17# appears in the process list of curl.18printf '%s' "$payload" | curl --silent --max-time 2 --unix-socket "$CR_HOOK_SOCKET" --config /dev/fd/3 \19 -X POST -H 'Content-Type: application/json' -H "X-CR-Session: $CR_SESSION_ID" \20 --data-binary @- http://localhost/hooks/claude >/dev/null 2>&1 3<<EOF_CFG21header = "Authorization: Bearer $CR_HOOK_TOKEN"22EOF_CFG23exit 024