[codex] Run async hooks and deliver output on accepted requests
Stack 2/3: #27771 → this PR → #27772
Purpose
#27771 provides the bounded runtime and informational parser, but async hook declarations remain disabled. This PR activates them and connects completed output to accepted model requests.
The central invariant is that an async hook may inform a later request, but it can never alter the operation that launched it.
Behavior
Synchronous hooks retain their existing behavior. Async handlers run in the background without emitting HookStarted or HookCompleted, and any blocking, steering, or input-mutation fields in their output are ignored.
Ready output is snapshotted before synchronous UserPromptSubmit hooks run. Delivery advances only after at least one input is accepted, which means:
- output that finishes during prompt-hook execution waits for the following accepted request;
- rejected input does not consume queued output;
- an accepted steer can receive eligible output; and
SessionStartandSubagentStartoutput always skips the first accepted request.
The runtime survives hook configuration refreshes so in-flight commands and queued output are preserved. Session shutdown aborts and joins detached commands.
Deferred additionalContext is recorded in model-visible history. Deferred systemMessage values are shown to the user without entering model context. Idle threads are not woken solely to deliver hook output.