Documentation
¶
Overview ¶
Package hook implements `codex-router hook`, the optional Codex command hook (UserPromptSubmit, Stop) that prints a systemMessage when the route changed since the previous turn. It reads the control snapshot and never emits additionalContext.
Index ¶
Constants ¶
const MessagePrefix = "router: "
MessagePrefix starts every line; Codex renders it as "↳ Hook · router: …".
const Timeout = 200 * time.Millisecond
Timeout bounds the whole hook run, socket included.
Variables ¶
This section is empty.
Functions ¶
func Message ¶
Message returns the switch line for the hook's turn, or "" when there is none: no decision for the turn yet, no earlier turn, or the same route. With no turn id in the input, the thread's latest turn is used.
func Run ¶
Run reads one hook input from stdin, asks the control socket named by control.EnvSocket (read through getenv) for a snapshot and writes {"systemMessage": ...} when the turn's route differs from the previous turn's, else {}. A missing or unreachable socket, unreadable input or a slow stdin or router all print {} within Timeout and return nil: a hook must never block Codex.