feat(codex): add gbot codex status, list-threads, and send - #28
Conversation
🦋 Changeset detectedLatest commit: fd7f07b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ef1c37f664
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const turn = await client.request("turn/start", { threadId, input: [{ type: "text", text }] }); | ||
| if (client.refused.length) { |
There was a problem hiding this comment.
Keep the session open for approval requests
When turn/start returns an inProgress turn, the model generally has not generated any command or file-change approval request yet. Checking client.refused immediately therefore misses requests that arrive after the response, and the finally block closes the socket, so a turn using an approval-requiring policy can be reported as successfully started while it later stalls or aborts without the advertised refusal error. Keep the connection open until an appropriate turn lifecycle event, or reject such sends up front based on resumed.approvalPolicy.
Useful? React with 👍 / 👎.
… RFC 6455 vectors
ef1c37f to
fd7f07b
Compare
Why
Grok Bot agents need a way to wake a Codex thread without a human relaying context (#24). This adds
gbot codex status,gbot codex list-threads [--limit N], andgbot codex send <threadId> <message...>, which attach to the local Codex app-server daemon and start a turn with the documented JSON-RPC methods.Closes #26. Parent: #24.
Scope
src/codex-bridge.js: socket discovery underCODEX_HOME, a minimal RFC 6455 client overnet(no new dependency),connectCodexAppServer,codexStatus,listCodexThreads,sendToCodexThread. Method and parameter names are pinned to Codex 0.154.0 fromcodex app-server generate-json-schema.src/cli.js: thecodexcommand branch,--jsonsupport, help text.test/codex-bridge.test.js: thirteen tests against an in-process fake app-server listening on a Unix socket, plus RFC 6455 known-answer vectors for masking, length headers, andSec-WebSocket-Accept.README.md: "Messaging Codex threads from Grok Bot" with the Desktop limitation, upstream issues, and failure modes. Oneminorchangeset.codex_appMCP override makesCODEX_APP_SERVER_USE_LOCAL_DAEMON=1unreachable openai/codex#41014 and #41112) and Desktop's privateCODEX_APP_TOOLS_PIPE_PATHsockets. The CLI explains both when the control socket is absent.Tradeoffs
codex app-server proxy. The spike showed the proxy is byte-transparent: the control socket speaks WebSocket, so JSON lines written to the proxy's stdin get no reply. A WebSocket client is needed either way, and Node's built-inWebSocketcannot dial Unix sockets, so the bridge carries a ~60-line client overnetand skips the extra process.sendresumes then starts a turn and returns without waiting.turn/starton a thread that is not loaded returns "thread not found", and the daemon keeps running a turn after the client disconnects, so resume-first with an immediate return is both required and sufficient.sendexits 1 naming the turn id and theapproval_policy = "never"remedy.senddisconnects once the turn starts, so later requests stay with the daemon for a Codex client to answer; the README says so.thread/listusesuseStateDbOnly: true. The default rescans every rollout file and took 26 s on this machine; the state DB answers in milliseconds with the same rows.Blast Radius
New command branch only; existing Grok Bot commands and the gateway backend are untouched.
codexdispatches beforeopenBackend, so it needs no Grok Bot auth. Package stays zero-dependency.Verification
npm test: 71 pass on the rebased branch (13 new).npx publint@0.3.24: All good.npm pack+ global install +gbot --helplists the codex commands.codex app-server daemon start:gbot codex status→ reachable, daemon 0.154.0, cli 0.154.0.gbot codex list-threads --limit 5→ five threads with status, cwd, preview.gbot codex send 01a0a283-6b74-7d60-b041-510313dcf6e4 'automated smoke from gbot bridge'→ turn01a0a28f-cebb-7b23-b149-5f96bdc49ed1inProgress; read-back overthread/readshows the userMessage and the agent replyack.status,list-threads,sendall exit 1 with the Desktop explanation and upstream links./fast/tmp/grokbot-run/bridge-spike/and/fast/tmp/grokbot-run/bridge-evidence/.