Skip to main content

Module codex_wake

Module codex_wake 

Source
Expand description

ai-crew-sync context codex-wake: wake an idle Codex thread when the bus has something new for its window (#222).

A Codex thread whose turn has ended calls no tools, so a message for its window waits until its human types. Codex has no background hook that can start a turn; its app-server can (turn/start). This adapter is the bridge, and it is explicit at every step:

  • It runs only when started, for one thread, named by the thread id.
  • The thread id must be one the window’s own proxy recorded from Codex: the binding’s source is request-meta (_meta.threadId on the host’s own tool calls). Never a guess from a directory, a role or a name.
  • It acts as that window with the window’s credential, read from the private binding; the credential never reaches argv, a log, the model or the app-server.
  • One adapter per thread. A second one is refused while the first is alive.
  • It wakes only for news: a direct message newer than the last it woke for, or more undelivered conversation messages. What was waiting when it started does not wake the thread. The mark is written before the turn is requested, so a crash costs at most one missed wake (the messages stay unread on the bus), never a duplicate.
  • The turn it starts carries counts and where to read them, never a message body: the model reads with its own ACS tools.
  • It never starts a second turn: an active thread is waited on until it is idle. A thread that is not loaded is resumed first.
  • What it did is observable as presence, wake_result on the window: requested once Codex accepted the turn, confirmed once Codex said the turn started, failed when it gave up. None of these is a receipt: a started turn is not a read message, let alone an answer.

Structs§

Options

Enums§

Delivery
What one wake came to.
Ended
How a run ended, for the command’s exit message.

Constants§

WAKE_LABEL
The label the adapter announces as the window’s wake mechanism.

Functions§

run
Run the adapter for one thread until max_secs, or until the window closes. Whatever ends the run, an error included, the thread is released and the wake announcement withdrawn on the way out.