codex-grok-bridge 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/README.md +160 -30
- package/package.json +5 -1
- package/src/bridge.mjs +204 -8
- package/src/imagine.mjs +184 -0
- package/src/proxy.mjs +87 -2
- package/src/realtime.mjs +212 -0
- package/src/runtime.mjs +3 -0
- package/src/tools.mjs +445 -43
- package/src/videogen.mjs +345 -0
- package/src/voice.mjs +1359 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.8.0 — 2026-10-02
|
|
4
|
+
|
|
5
|
+
- When xAI rejects a Codex voice offer on `POST /v1/realtime/calls` or `POST /v1/live`, the bridge reads the SDP part of the multipart body, whether the parts use CRLF or LF, and answers locally with werift. Opus is used when that is the offered codec. Audio is bridged to the xAI voice socket. The sideband for that answered call stays on the bridge. An offer the local peer cannot answer stays the upstream response. An offer xAI accepts is still forwarded. Codex cloud tasks are not in this package.
|
|
6
|
+
- Runtime dependencies are `werift` 0.24.4 and `opusscript` 0.1.1. There is still no `XAI_API_KEY`.
|
|
7
|
+
- Codex image `size` is sent to Imagine as `aspect_ratio` (`1024x1024` → `1:1`, `1536x1024` → `3:2`, `1024x1536` → `2:3`) for new pictures and edits. `quality: high` is `2k`, `low` is `1k`, and `auto` omits resolution. `n` is capped at 10. A local file path on an image edit is refused.
|
|
8
|
+
- A generated image is saved once. The completed response carries that file note instead of the raw image bytes.
|
|
9
|
+
- `grok_bridge_generate_video` accepts `480p`, `720p`, or `1080p`. A bad duration, aspect ratio, resolution, or local image path is rejected without calling the API. The finished clip is downloaded, without the login bearer, into `~/.local/share/codex-grok-bridge/generated-videos/`. The tool result names the temporary URL and the saved file. A moderation withhold is a tool message, not a failed turn. If the download fails, the result is still the URL.
|
|
10
|
+
- A custom tool call that comes back under its Codex name is restored when that name belongs to one tool, including streamed argument events and the completed response output. A custom tool result is restored even when it only has a call id.
|
|
11
|
+
- A function result that arrives as a list of content parts is forwarded as text. A remote image URL in that list is included. An inline PNG, JPEG, or WebP is attached after the tool result so the model can see it.
|
|
12
|
+
- A previous web search keeps its query and the pages it found.
|
|
13
|
+
- Command stdout, stderr, or an aggregated log stays in the forwarded history, with a non-zero exit code.
|
|
14
|
+
- A chat audio attachment is replaced with an explanation so its bytes do not reject the turn.
|
|
15
|
+
- When a reasoning summary is empty, plain text in the reasoning content is forwarded. Encrypted reasoning stays dropped.
|
|
16
|
+
|
|
17
|
+
## 1.7.2 — 2026-09-30
|
|
18
|
+
|
|
19
|
+
- Readable compaction summaries are passed through as user messages. A compaction item that only carries encrypted or internal fields is still dropped.
|
|
20
|
+
- A Grok thread can generate a video without an API key. The bridge declares `grok_bridge_generate_video` on the upstream request and, when the model calls it, posts to `https://api.x.ai/v1/videos/generations` with the grok login bearer, polls `GET /videos/{request_id}`, and returns the video URL to the model as the tool result. A refusal from that API stays a tool error and does not fail the turn.
|
|
21
|
+
- Codex input items Grok does not accept (`local_shell_call`, `web_search_call`, `tool_search_call`, `tool_search_output`, `additional_tools`, `image_generation_call`, and unmapped custom tool items) keep their readable text as user `input_text` messages, the same shape as a compaction summary. That text includes shell commands, search queries, tool-search text, an image `revised_prompt`, and custom tool text. `encrypted_content`, `encrypted_function_args`, `internal_*` fields, and image-byte `result` values stay dropped.
|
|
22
|
+
- `POST /v1/images/generations` and `POST /v1/images/edits` are forwarded to the Imagine API with the grok login bearer. Codex's `gpt-image-2` body is rewritten to `grok-imagine-image-quality` and `b64_json`. OpenAI `file_id` edits are refused. No `XAI_API_KEY`.
|
|
23
|
+
- Codex `web_search` is kept as one server-side `{type:"web_search"}` tool. `web_search_call` results are passed through to Codex.
|
|
24
|
+
- Voice WebRTC (`POST /v1/realtime/calls`) and Codex cloud tasks are not in this package.
|
|
25
|
+
|
|
3
26
|
## 1.7.1 — 2026-09-30
|
|
4
27
|
|
|
5
28
|
- The bridge holds the upstream reply and sends it to Codex only after `response.completed`. A reset before that (`ECONNRESET`, `EPIPE`, `UND_ERR_SOCKET`, or a close before the reply finishes) is retried up to two more times, and only if Codex has not been sent a byte. This provider's Codex `request_max_retries` and `stream_max_retries` are 0. A retry sends the prompt again, so that attempt's input tokens can be billed again.
|
package/README.md
CHANGED
|
@@ -30,13 +30,55 @@ The bridge does **not** execute Grok-native tools. It translates Codex tools int
|
|
|
30
30
|
function calling, streams the upstream Responses events, and rewrites names back
|
|
31
31
|
so Codex still recognizes them.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Eighteen files under `src/`. Zero runtime dependencies. Node.js ≥ 22.
|
|
34
34
|
|
|
35
35
|
This is not a second-opinion review product and not a Grok-native search
|
|
36
36
|
product. The picker shows `grok-4.7` (Grok 4.7 / xAI) and keeps `grok-4.6`.
|
|
37
37
|
Any other `grok-*` id uses the same route. `GROK_BRIDGE_MODELS` adds further
|
|
38
|
-
`grok-*` ids.
|
|
39
|
-
|
|
38
|
+
`grok-*` ids. Codex `web_search` is xAI's server-side tool, not a function
|
|
39
|
+
the bridge runs. See Release history.
|
|
40
|
+
|
|
41
|
+
## Release history
|
|
42
|
+
|
|
43
|
+
What each recent version added. Older cuts are in `CHANGELOG.md`.
|
|
44
|
+
|
|
45
|
+
### 1.8.0 — 2026-10-02
|
|
46
|
+
|
|
47
|
+
- When xAI rejects a Codex voice offer, the bridge reads the SDP part of the multipart body (CRLF or LF) and answers locally with werift, including Opus when that is the offered codec. Audio is bridged to the xAI voice socket, and that call's sideband stays on the bridge. An offer xAI accepts is still forwarded. Codex cloud tasks are not in this package.
|
|
48
|
+
- Runtime dependencies are `werift` 0.24.4 and `opusscript` 0.1.1. No `XAI_API_KEY`.
|
|
49
|
+
- Codex image `size` maps to Imagine `aspect_ratio` on new pictures and edits. `quality: high` is `2k`, `low` is `1k`, and `auto` omits resolution. `n` is capped at 10. A local file path on an image edit is refused.
|
|
50
|
+
- A generated image is saved once, and the completed response carries that file note.
|
|
51
|
+
- Video generation accepts `480p`, `720p`, or `1080p`. The finished clip is saved under `~/.local/share/codex-grok-bridge/generated-videos/` without the login bearer. The tool result names the URL and the file.
|
|
52
|
+
- Custom tool names and results are restored, including a result that only has a call id. Function results that arrive as content parts are forwarded as text, with an inline PNG, JPEG, or WebP attached so the model can see it.
|
|
53
|
+
- A previous web search keeps its query and the pages it found. Command output and a non-zero exit code stay in history. A chat audio attachment is replaced with an explanation. An empty reasoning summary falls back to plain reasoning text.
|
|
54
|
+
|
|
55
|
+
### 1.7.2 — 2026-09-30
|
|
56
|
+
|
|
57
|
+
- Readable compaction summaries are passed through as user messages. A compaction item that only carries encrypted or internal fields is still dropped.
|
|
58
|
+
- `grok_bridge_generate_video`. The bridge declares this tool and, when the model calls it, posts to `https://api.x.ai/v1/videos/generations` with the grok login bearer, polls `GET /videos/{request_id}`, and returns the video URL as the tool result. A refusal from that API stays a tool error and does not fail the turn.
|
|
59
|
+
- Readable text from Codex input items that used to be dropped is forwarded as user `input_text`: shell, search, tool-search, a revised image prompt, and custom tool text. Encrypted blobs and image-byte results stay dropped.
|
|
60
|
+
- `POST /v1/images/generations` and `POST /v1/images/edits` are forwarded to the Imagine API with the grok login bearer. Codex's `gpt-image-2` body is rewritten to `grok-imagine-image-quality` and `b64_json`. OpenAI `file_id` edits are refused. No `XAI_API_KEY`.
|
|
61
|
+
- Codex `web_search` is kept as one server-side `{type:"web_search"}` tool. `web_search_call` results are passed through to Codex.
|
|
62
|
+
- Voice WebRTC (`POST /v1/realtime/calls`) and Codex cloud tasks are not in this package.
|
|
63
|
+
|
|
64
|
+
### 1.7.1 — 2026-09-30
|
|
65
|
+
|
|
66
|
+
- The bridge holds the upstream reply and sends it to Codex only after `response.completed`. A reset before that (`ECONNRESET`, `EPIPE`, `UND_ERR_SOCKET`, or a close before the reply finishes) is retried up to two more times, and only if Codex has not been sent a byte. This provider's Codex `request_max_retries` and `stream_max_retries` are 0. A retry sends the prompt again, so that attempt's input tokens can be billed again.
|
|
67
|
+
- When `grok --version` fails or does not report a version, the client version is `unknown` instead of the stale `1.0.24`.
|
|
68
|
+
|
|
69
|
+
### 1.7.0 — 2026-09-29
|
|
70
|
+
|
|
71
|
+
- One `x-grok-conv-id` per Codex thread, and the forwarded transcript prefix stays byte-stable so the prompt cache can hit. The full transcript is still sent.
|
|
72
|
+
- Upstream `cached_prompt_tokens` and `cache_read_input_tokens` are copied onto `response.completed` usage and the diagnostics log when the proxy sends them, including `0`. Missing counters are not invented.
|
|
73
|
+
|
|
74
|
+
### 1.6.1 — 2026-09-28
|
|
75
|
+
|
|
76
|
+
- Darwin bundled CLI resolves `Codex.app/Contents/Resources/codex-cli/bin/codex` when that file exists (Codex 26.924). The legacy `Contents/Resources/codex` path remains the fallback. `CODEX_BINARY` still wins. Linux and Windows layouts are unchanged.
|
|
77
|
+
|
|
78
|
+
### 1.6.0 — 2026-09-27
|
|
79
|
+
|
|
80
|
+
- Default catalog model is `grok-4.7` (`Grok 4.7 / xAI`). `grok-4.6` stays listed so existing threads still resolve.
|
|
81
|
+
- `grok-*` still routes to `grok_build_cli`. No other model ids were added. `GROK_BRIDGE_MODELS` still appends extra `grok-*` ids.
|
|
40
82
|
|
|
41
83
|
## Requirements
|
|
42
84
|
|
|
@@ -72,7 +114,7 @@ starts, and tears the provider down with that process.
|
|
|
72
114
|
```sh
|
|
73
115
|
git clone https://github.com/deximple/codex-grok-bridge.git
|
|
74
116
|
cd codex-grok-bridge
|
|
75
|
-
npm test #
|
|
117
|
+
npm test # 191 tests, no network, no inference
|
|
76
118
|
node scripts/codex-grok.mjs
|
|
77
119
|
```
|
|
78
120
|
|
|
@@ -107,8 +149,8 @@ launches from its usual icon.
|
|
|
107
149
|
2. The wrapper adds Grok to the model catalog and sets the provider of a new
|
|
108
150
|
Grok thread to `grok_build_cli`.
|
|
109
151
|
3. Codex `/v1/responses` requests go to the localhost bridge.
|
|
110
|
-
4. The bridge flattens Codex tools
|
|
111
|
-
|
|
152
|
+
4. The bridge flattens Codex function and custom tools into function tools,
|
|
153
|
+
forwards `web_search` as xAI's server-side tool, then pipes the
|
|
112
154
|
`cli-chat-proxy.grok.com` Responses stream through.
|
|
113
155
|
5. Tool results return as the next Codex request `input`.
|
|
114
156
|
|
|
@@ -139,8 +181,12 @@ before any of it is sent.
|
|
|
139
181
|
Codex keeps the conversation and sends the whole turn each time. Grok can
|
|
140
182
|
treat the unchanged beginning as a cache. If the connection drops before
|
|
141
183
|
Codex has been sent any bytes, the bridge tries again. Codex does not send
|
|
142
|
-
that same request again. Voice
|
|
143
|
-
|
|
184
|
+
that same request again. Voice call setup (`POST /v1/realtime/calls` and
|
|
185
|
+
`POST /v1/live`) is forwarded raw when xAI accepts it. When xAI rejects that
|
|
186
|
+
offer, the bridge reads the SDP part of Codex's multipart body, whether the parts use CRLF or LF, answers with
|
|
187
|
+
its own WebRTC peer, including Opus when that is the offered codec, and
|
|
188
|
+
bridges the audio to the xAI voice socket. Microphone audio is held until `session.updated`, up to two seconds of it, and released after 2 seconds if that ack never arrives. A resumed socket waits for its own `session.updated` again. Requests queued on the old socket are dropped, so the new `session.update` goes out first. Audio still waiting to play is dropped with that socket, and the resumed session is told how much was already sent. It does not keep the previous interrupt or a deferred `response.create`, and later audio still plays. Voice audio accepts `response.output_audio.delta` and `response.audio.delta`, fields `delta` or `audio`. A reply shorter than one audio frame is still sent when the turn ends. Playback is paced at one Opus frame per 20 ms. When the user starts speaking, playback of the current reply stops, and a waiting tool reply is held until they stop. A transcript that arrives after that stop is not shown, and the turn closes on the words already sent. Once that caption has closed, the next user utterance leaves the following reply's words visible. Audio that arrives after that reply ends stays silent until the next response starts. A desktop `response.cancel` stops that playback too, without holding later tool replies for speech that did not start. A reply already waiting stays held if the user is still speaking. If playback was still queued, the assistant item is truncated to the audio already sent. A tool reply waits until the voice response is done and queued playback has been sent. If the socket drops first, that reply is sent after the resumed session is ready. A `response.create` that races an active response is sent again after that response finishes, and after any tool reply that was waiting. The answer is the DTLS server and lists only this machine's host addresses, including 127.0.0.1, as plain host candidates, so the desktop voice helper opens its event channel. The sideband for that answered call stays on the bridge. A dropped voice socket redials once on the same xAI conversation (resumption enabled). A second drop tells the desktop "Voice connection closed." An intentional hangup does not. A recoverable xAI error does not, because the desktop would end the call. The first sideband event is `session.updated`, sent when the desktop connects so the call is not held for the xAI session ack. `session.close` from the desktop hangs up without waiting for TCP. xAI transcript events are rewritten into the desktop v3 sideband names. Text replies from `response.output_text.delta` and `response.text.delta` use that same transcript. The chunk may be in `delta` or `text`. If the audio transcript never sends a done event, `response.done` still closes the turn. A new user utterance closes the previous user caption when its completed event never arrived. A later completed event for that same caption is not sent again. The call's session instructions and earlier messages are kept. Developer history from the call is added to those instructions and kept on a later session update. If the call asks for a delegation acknowledgement, those instructions say to speak one short sentence before calling `codex`. A later session update keeps that sentence. Split context appends are joined. A streamed codex reply is spoken once after a pause. Several codex results that finish together are all sent before the spoken reply, or before one continuation. If that spoken turn is rejected before it starts, the next reply is not left waiting. Commentary closes the tool without being read aloud. `[STATUS]` does not finish the call. A `codex` tool call becomes the desktop handoff.
|
|
189
|
+
Codex cloud tasks are not in this package.
|
|
144
190
|
|
|
145
191
|
If the Responses path misbehaves, `GROK_BRIDGE_INFERENCE=cli` falls back to the
|
|
146
192
|
older CLI envelope. That path pastes the whole JSON into a prompt each turn, so
|
|
@@ -179,7 +225,9 @@ not read Codex’s `imagegen` skill and do not send the picture to OpenAI.
|
|
|
179
225
|
|
|
180
226
|
### Reasoning
|
|
181
227
|
|
|
182
|
-
Plain-text summaries on Codex `reasoning` items are forwarded.
|
|
228
|
+
Plain-text summaries on Codex `reasoning` items are forwarded. When that
|
|
229
|
+
summary is empty, plain text in the reasoning content is forwarded instead.
|
|
230
|
+
Encrypted
|
|
183
231
|
`encrypted_content` and Codex’s own item ids are stripped. This is so a
|
|
184
232
|
multi-call turn can continue its own reasoning. The upstream has been observed
|
|
185
233
|
to accept this shape. The same pass keeps only the fields Grok’s Responses
|
|
@@ -198,9 +246,17 @@ that overlap the parent turn.
|
|
|
198
246
|
### Tools
|
|
199
247
|
|
|
200
248
|
Ordinary function tools, namespaced function tools, and freeform custom tools
|
|
201
|
-
are translated.
|
|
202
|
-
|
|
203
|
-
|
|
249
|
+
are translated. A custom tool call that comes back under the Codex name is
|
|
250
|
+
restored when that name belongs to one tool. The same name is restored on a
|
|
251
|
+
streamed arguments event and inside the completed response output. A custom
|
|
252
|
+
tool result is restored too, including when it only carries the call id. A function result that arrives as a list of content parts is
|
|
253
|
+
forwarded as text. A remote image URL in that list is included. An inline
|
|
254
|
+
PNG, JPEG, or WebP is attached after the tool result so the model can see it.
|
|
255
|
+
A previous web search keeps its query and the page URLs it found. Command output
|
|
256
|
+
in stdout, stderr, or an aggregated log stays in the history. A non-zero exit
|
|
257
|
+
code stays with that output. File edits, MCP,
|
|
258
|
+
and similar work inside whatever Codex exposed, at whatever approval policy the
|
|
259
|
+
user set. Not every tool has been live-tested individually.
|
|
204
260
|
|
|
205
261
|
### Image attachments (vision)
|
|
206
262
|
|
|
@@ -212,11 +268,13 @@ One unusable attachment no longer kills the conversation. The bridge walks the
|
|
|
212
268
|
whole history; a single over-limit image used to make every later turn fail
|
|
213
269
|
with 400. Now that attachment is replaced with an explanation and the rest
|
|
214
270
|
goes through. Usable images stay `input_image` (Grok reads them). Remote URLs
|
|
215
|
-
are not fetched.
|
|
271
|
+
are not fetched. An audio attachment is replaced with an explanation so its
|
|
272
|
+
bytes do not reject the turn.
|
|
216
273
|
|
|
217
274
|
### Image generation
|
|
218
275
|
|
|
219
|
-
|
|
276
|
+
A generated image is saved once. The completed response carries that same
|
|
277
|
+
file note instead of the raw image bytes. The bridge declares `{ type: "image_generation" }` on the upstream request.
|
|
220
278
|
Codex does not offer an image-generation tool to this provider (263 tools, none
|
|
221
279
|
of them generate — `view_image` only), so without the declaration Codex’s
|
|
222
280
|
`imagegen` skill falls back to OpenAI (`image_gen` or `OPENAI_API_KEY` +
|
|
@@ -245,6 +303,13 @@ The bridge inspects the saved file. If there is no alpha channel it tells the
|
|
|
245
303
|
model not to describe the picture as transparent. If you need a real alpha
|
|
246
304
|
channel or accurate inpainting, use Codex’s OpenAI path.
|
|
247
305
|
|
|
306
|
+
### Video generation
|
|
307
|
+
|
|
308
|
+
A finished clip is a temporary URL. The bridge downloads that file, without
|
|
309
|
+
the login bearer, into `~/.local/share/codex-grok-bridge/generated-videos/`
|
|
310
|
+
and the tool result names both the URL and the saved file. If the download
|
|
311
|
+
fails, the result is still the URL.
|
|
312
|
+
|
|
248
313
|
### GPT ↔ Grok switching
|
|
249
314
|
|
|
250
315
|
Supported on an idle persisted root thread. `turn/start`,
|
|
@@ -258,7 +323,7 @@ starting a new thread, before the first turn is saved.
|
|
|
258
323
|
|
|
259
324
|
### Not in this release
|
|
260
325
|
|
|
261
|
-
|
|
326
|
+
A voice session still depends on the xAI voice socket accepting the login, and on the desktop completing ICE with the bridge. Codex cloud tasks are not in this package.
|
|
262
327
|
|
|
263
328
|
Upstream sometimes resets the connection mid-response (three measured cases:
|
|
264
329
|
25 s / 27 s / 253 s, 726 KB–22 MB). The bridge holds the reply and, if that
|
|
@@ -308,7 +373,7 @@ Start here when something breaks. Do not open `~/.grok/auth.json` or
|
|
|
308
373
|
## Verify
|
|
309
374
|
|
|
310
375
|
```sh
|
|
311
|
-
npm test #
|
|
376
|
+
npm test # 191 tests, no remote inference
|
|
312
377
|
npm run test:coverage # 80% line / branch / function gate
|
|
313
378
|
npm run verify:app-server # real app-server routing; also runs against an installed bundle
|
|
314
379
|
npm audit --omit=dev
|
|
@@ -377,14 +442,56 @@ Grok 4.7을 Codex 모델 목록에 넣고, Codex의 `/v1/responses`를
|
|
|
377
442
|
calling으로 옮기고, 상류 Responses 스트림을 전달한 뒤, Codex가 알아보는
|
|
378
443
|
이름으로 되돌립니다.
|
|
379
444
|
|
|
380
|
-
`src/` 아래 파일
|
|
445
|
+
`src/` 아래 파일 18개. 런타임 의존성 없음. Node.js 22 이상. 1.5.0부터 npm
|
|
381
446
|
`"os"`는 `darwin` / `linux` / `win32`입니다.
|
|
382
447
|
|
|
383
448
|
코드 리뷰 전용 제품이 아니고 Grok 네이티브 검색 제품도 아닙니다. 피커에는
|
|
384
449
|
`grok-4.7`(Grok 4.7 / xAI)이 기본으로 보이고 `grok-4.6`도 남습니다. 그 외
|
|
385
450
|
`grok-*` id도 같은 경로로 붙고, `GROK_BRIDGE_MODELS`로 카탈로그에 더합니다.
|
|
386
|
-
Codex
|
|
387
|
-
|
|
451
|
+
Codex `web_search`는 브리지가 실행하는 함수가 아니라 xAI 서버 도구입니다.
|
|
452
|
+
릴리스 기록을 보세요.
|
|
453
|
+
|
|
454
|
+
## 릴리스 기록
|
|
455
|
+
|
|
456
|
+
최근 버전이 더한 것입니다. 그 이전은 `CHANGELOG.md`에 있습니다.
|
|
457
|
+
|
|
458
|
+
### 1.8.0 — 2026-10-02
|
|
459
|
+
|
|
460
|
+
- xAI가 Codex 음성 offer를 거절하면 브리지가 multipart 본문의 SDP를 읽습니다. 파트 구분이 CRLF든 LF든 같습니다. werift로 로컬에서 답하고, offer가 Opus이면 Opus로 답합니다. 오디오는 xAI 음성 소켓으로 잇고, 그 통화의 sideband는 브리지에 남습니다. xAI가 수락한 offer는 그대로 넘깁니다. Codex 클라우드 작업은 이 패키지에 없습니다.
|
|
461
|
+
- 런타임 의존성은 `werift` 0.24.4와 `opusscript` 0.1.1입니다. `XAI_API_KEY`는 쓰지 않습니다.
|
|
462
|
+
- Codex 이미지 `size`는 새 그림과 편집 모두 Imagine `aspect_ratio`로 보냅니다. `quality: high`는 `2k`, `low`는 `1k`이고, `auto`는 해상도를 비웁니다. `n`은 최대 10장입니다. 이미지 편집의 로컬 파일 경로는 거절합니다.
|
|
463
|
+
- 생성된 이미지는 한 번만 저장하고, 완료된 응답에는 그 파일 설명을 실습니다.
|
|
464
|
+
- 영상 생성은 `480p`, `720p`, `1080p`를 받습니다. 끝난 클립은 로그인 베어러 없이 `~/.local/share/codex-grok-bridge/generated-videos/`에 저장하고, 도구 결과에는 URL과 파일을 함께 넣습니다.
|
|
465
|
+
- 커스텀 도구 이름과 결과를 다시 맞춥니다. call id만 있는 결과도 맞춥니다. 내용 목록으로 온 함수 결과는 텍스트로 넘기고, 인라인 PNG·JPEG·WebP는 모델이 보게 붙입니다.
|
|
466
|
+
- 이전 웹 검색은 질의와 찾은 페이지를 남깁니다. 명령 출력과 0이 아닌 종료 코드도 이력에 남습니다. 채팅 오디오 첨부는 설명으로 바꿉니다. reasoning 요약이 비어 있으면 평문 내용을 넘깁니다.
|
|
467
|
+
|
|
468
|
+
### 1.7.2 — 2026-09-30
|
|
469
|
+
|
|
470
|
+
- 읽을 수 있는 compaction 요약을 사용자 메시지로 넘깁니다. 암호화된 내용이나 내부 필드만 있는 compaction 항목은 그대로 버립니다.
|
|
471
|
+
- `grok_bridge_generate_video`. 브리지가 이 도구를 선언하고, 모델이 호출하면 grok 로그인 bearer로 `https://api.x.ai/v1/videos/generations`에 보낸 뒤 `GET /videos/{request_id}`를 폴링하고, 영상 URL을 도구 결과로 돌려줍니다. 그 API의 거절은 도구 오류로 남고 턴을 실패시키지 않습니다.
|
|
472
|
+
- 예전에는 버리던 Codex 입력 항목의 읽을 수 있는 글을 사용자 `input_text`로 넘깁니다. 셸, 검색, tool-search, 수정된 이미지 프롬프트, 커스텀 도구 텍스트입니다. 암호화된 blob과 이미지 바이트 결과는 그대로 버립니다.
|
|
473
|
+
- `POST /v1/images/generations`와 `POST /v1/images/edits`를 grok 로그인 bearer로 Imagine API에 넘깁니다. Codex의 `gpt-image-2` 본문은 `grok-imagine-image-quality`와 `b64_json`으로 바꿉니다. OpenAI `file_id` 편집은 거절합니다. `XAI_API_KEY`는 쓰지 않습니다.
|
|
474
|
+
- Codex `web_search`는 서버 측 `{type:"web_search"}` 도구 하나로 유지합니다. `web_search_call` 결과는 Codex로 통과합니다.
|
|
475
|
+
- 음성 WebRTC(`POST /v1/realtime/calls`)와 Codex 클라우드 작업은 이 패키지에 없습니다.
|
|
476
|
+
|
|
477
|
+
### 1.7.1 — 2026-09-30
|
|
478
|
+
|
|
479
|
+
- 브리지는 상류 응답을 `response.completed` 이후에만 Codex로 보냅니다. 그 전의 리셋(`ECONNRESET`, `EPIPE`, `UND_ERR_SOCKET`, 또는 응답이 끝나기 전의 닫힘)은 최대 두 번 더 재시도하며, Codex에 바이트를 아직 보내지 않았을 때만 합니다. 이 provider의 Codex `request_max_retries`와 `stream_max_retries`는 0입니다. 재시도는 프롬프트를 다시 보내므로 그 시도의 입력 토큰이 다시 과금될 수 있습니다.
|
|
480
|
+
- `grok --version`이 실패하거나 버전을 보고하지 않으면 클라이언트 버전은 오래된 `1.0.24` 대신 `unknown`입니다.
|
|
481
|
+
|
|
482
|
+
### 1.7.0 — 2026-09-29
|
|
483
|
+
|
|
484
|
+
- Codex 스레드마다 `x-grok-conv-id`는 하나이고, 전달하는 트랜스크립트 접두는 바이트 그대로라 프롬프트 캐시가 맞을 수 있습니다. 전체 트랜스크립트는 그대로 보냅니다.
|
|
485
|
+
- 상류가 보내면 `cached_prompt_tokens`와 `cache_read_input_tokens`를 `response.completed` usage와 진단 로그에 복사합니다. `0`도 포함합니다. 없는 카운터는 만들지 않습니다.
|
|
486
|
+
|
|
487
|
+
### 1.6.1 — 2026-09-28
|
|
488
|
+
|
|
489
|
+
- Darwin 번들 CLI는 파일이 있으면 `Codex.app/Contents/Resources/codex-cli/bin/codex`를 씁니다(Codex 26.924). 예전 `Contents/Resources/codex`는 폴백으로 남습니다. `CODEX_BINARY`가 우선합니다. Linux와 Windows 배치는 그대로입니다.
|
|
490
|
+
|
|
491
|
+
### 1.6.0 — 2026-09-27
|
|
492
|
+
|
|
493
|
+
- 기본 카탈로그 모델은 `grok-4.7`(Grok 4.7 / xAI)입니다. `grok-4.6`은 기존 스레드가 계속 맞게 목록에 남습니다.
|
|
494
|
+
- `grok-*`는 여전히 `grok_build_cli`로 갑니다. 다른 모델 id는 추가하지 않았습니다. `GROK_BRIDGE_MODELS`는 그 외 `grok-*` id를 카탈로그에 더합니다.
|
|
388
495
|
|
|
389
496
|
## 필요한 것
|
|
390
497
|
|
|
@@ -419,7 +526,7 @@ codex-grok exec --skip-git-repo-check --sandbox workspace-write '작업 내용'
|
|
|
419
526
|
```sh
|
|
420
527
|
git clone https://github.com/deximple/codex-grok-bridge.git
|
|
421
528
|
cd codex-grok-bridge
|
|
422
|
-
npm test #
|
|
529
|
+
npm test # 191건, 네트워크·추론 없음
|
|
423
530
|
node scripts/codex-grok.mjs
|
|
424
531
|
```
|
|
425
532
|
|
|
@@ -453,8 +560,8 @@ Codex 창에도 보일 수 있습니다.
|
|
|
453
560
|
2. 래퍼가 모델 목록에 Grok를 추가하고, 새 Grok 작업의 제공자를
|
|
454
561
|
`grok_build_cli`로 설정합니다.
|
|
455
562
|
3. Codex의 `/v1/responses` 요청은 localhost 브리지로 갑니다.
|
|
456
|
-
4. 브리지는 Codex
|
|
457
|
-
|
|
563
|
+
4. 브리지는 Codex 함수·커스텀 도구를 function tool로 펼치고, `web_search`는
|
|
564
|
+
xAI 서버 도구로 넘긴 뒤 `cli-chat-proxy.grok.com` Responses 스트림을 이어줍니다.
|
|
458
565
|
5. 도구 결과는 다음 Codex 요청의 `input`으로 돌아갑니다.
|
|
459
566
|
|
|
460
567
|
인증은 `grok login` 세션입니다. `XAI_API_KEY`는 쓰지 않습니다.
|
|
@@ -481,8 +588,13 @@ Codex 창에도 보일 수 있습니다.
|
|
|
481
588
|
|
|
482
589
|
Codex가 대화를 갖고 있고, 턴마다 그 턴 전체를 보냅니다. 앞부분이 그대로면
|
|
483
590
|
Grok는 그 부분을 캐시로 볼 수 있습니다. Codex에 바이트를 보내기 전에 연결이
|
|
484
|
-
끊기면 브리지가 다시 시도합니다. Codex는 그 요청을 또 보내지 않습니다.
|
|
485
|
-
|
|
591
|
+
끊기면 브리지가 다시 시도합니다. Codex는 그 요청을 또 보내지 않습니다. 음성
|
|
592
|
+
통화 설정(`POST /v1/realtime/calls`, `POST /v1/live`)은 xAI가 수락하면 원문
|
|
593
|
+
그대로 넘깁니다. xAI가 그 offer를 거절하면 브리지가 Codex multipart 본문에서 SDP를 읽습니다. 파트 구분이 CRLF든 LF든 같습니다.
|
|
594
|
+
자체 WebRTC 피어로 답합니다. offer가 Opus이면 Opus로 답하고, 오디오를 xAI
|
|
595
|
+
음성 소켓으로 잇습니다. 마이크 오디오는 `session.updated`까지 최대 2초분을 붙들고, 그 확인이 없으면 2초 뒤에 보냅니다. 다시 붙은 소켓은 자기 `session.updated`를 다시 기다립니다. 이전 소켓에 쌓인 요청은 버리고, 새 `session.update`를 먼저 보냅니다. 아직 재생되지 않은 음성도 그 소켓과 함께 버리고, 이미 보낸 길이는 다시 붙은 세션에 알립니다. 이전 말끊기나 미뤄 둔 `response.create`는 따라가지 않고, 이후 음성은 재생됩니다. 음성 오디오는 `response.output_audio.delta`와 `response.audio.delta`를 받으며, 필드는 `delta` 또는 `audio`입니다. 한 프레임보다 짧은 답도 턴이 끝나면 보냅니다. 재생은 Opus 프레임을 20 ms마다 하나씩 보냅니다. 사용자가 말하기 시작하면 현재 답의 재생을 멈추고, 기다리던 도구 답은 말이 끝날 때까지 붙듭니다. 그 뒤에 도착한 자막은 보내지 않고, 이미 보낸 말로 턴을 닫습니다. 그 자막이 닫힌 뒤에는 다음 답의 말을 숨기지 않습니다. 그 답이 끝난 뒤의 음성은 다음 응답이 시작되기 전에는 재생하지 않습니다. 데스크톱의 `response.cancel`도 재생을 멈추며, 말하지 않은 뒤의 도구 답은 붙들지 않습니다. 이미 기다리던 답은 사용자가 아직 말하는 동안 붙듭니다. 재생이 아직 남아 있으면 어시스턴트 항목은 이미 보낸 음성 길이까지만 남깁니다. 도구 답은 음성 응답이 끝나고 대기 중인 재생을 보낸 뒤에 나갑니다. 그 전에 소켓이 끊기면, 다시 붙은 세션이 준비된 뒤에 보냅니다. 진행 중인 응답과 겹친 `response.create`는 기다리던 도구 답 다음에, 그 응답이 끝난 뒤에 다시 보냅니다. 답변은 DTLS 서버이고, 이 기기의 호스트 주소만 넣으며 127.0.0.1도
|
|
596
|
+
일반 호스트 후보로 포함해서, 데스크톱 음성 헬퍼가 이벤트 채널을 엽니다. 그렇게 답한 통화의 sideband는 브리지에
|
|
597
|
+
남습니다. 끊긴 음성 소켓은 같은 xAI 대화로 한 번 다시 연결합니다(resumption 사용). 두 번째로 끊기면 데스크톱에 “Voice connection closed.”를 알립니다. 의도한 종료는 알리지 않습니다. 복구 가능한 xAI 오류는 알리지 않습니다. 데스크톱이 통화를 끝내기 때문입니다. sideband가 연결되면 바로 `session.updated`를 보내 xAI 세션 확인을 기다리지 않습니다. 데스크톱의 `session.close`는 TCP를 기다리지 않고 통화를 끊습니다. xAI 전사 이벤트는 데스크톱 v3 sideband가 읽는 이름으로 바꿉니다. `response.output_text.delta`와 `response.text.delta` 텍스트 답도 같은 자막으로 보냅니다. 조각은 `delta` 또는 `text`에 있을 수 있습니다. 음성 자막의 완료 이벤트가 없어도 `response.done`이 그 턴을 닫습니다. 사용자가 다시 말하기 시작하면, 완료 이벤트가 없던 이전 사용자 자막도 닫습니다. 그 자막의 늦은 완료 이벤트는 다시 보내지 않습니다. 통화의 세션 지시문과 이전 메시지는 유지합니다. 개발자 이력은 그 지시문에 넣고, 나중 세션 갱신에도 남깁니다. 도구 호출 전에 짧게 말하라는 설정이 있으면, `codex`를 부르기 전에 한 문장을 말하도록 지시문에 넣습니다. 나중 세션 갱신에도 그 문장을 남깁니다. 나뉜 문맥 추가는 이어 붙입니다. 스트리밍된 codex 답은 잠시 멈춘 뒤 한 번만 말합니다. 같이 끝난 여러 codex 결과는 말을 잇기 전에 모두 보냅니다. 말로 읽는 답이 시작 전에 거절되면 다음 답은 기다리지 않습니다. commentary는 소리 내 읽지 않고 도구를 닫습니다. `[STATUS]`는 통화를 끝내지 않습니다. `codex` 도구 호출은 데스크톱 handoff가 됩니다. Codex 클라우드 작업은 이 패키지에 없습니다.
|
|
486
598
|
|
|
487
599
|
Responses 경로가 이상하면 `GROK_BRIDGE_INFERENCE=cli`로 이전 CLI 봉투 경로를
|
|
488
600
|
씁니다. 매 턴 전체 JSON을 프롬프트로 넣으므로 더 느리고 비싸며, 토큰 단위
|
|
@@ -518,7 +630,8 @@ OpenAI로 보내지 말라는 뜻입니다. `GROK_BRIDGE_IMAGE_GEN=off`면 도
|
|
|
518
630
|
|
|
519
631
|
### reasoning
|
|
520
632
|
|
|
521
|
-
Codex `reasoning` 항목의 평문 요약은 상류로 전달합니다.
|
|
633
|
+
Codex `reasoning` 항목의 평문 요약은 상류로 전달합니다. 요약이 비어 있으면
|
|
634
|
+
내용의 평문을 대신 전달합니다. 암호화된
|
|
522
635
|
`encrypted_content`와 Codex 자체 아이템 id는 제거합니다. 여러 번 호출이 이어지는
|
|
523
636
|
턴에서 모델이 자기 추론을 이어받게 하기 위한 것이며, 상류가 이 형태를 수락하는
|
|
524
637
|
것을 확인했습니다. 같은 과정에서 아이템과 content part는 Grok Responses가
|
|
@@ -534,7 +647,15 @@ Codex `reasoning` 항목의 평문 요약은 상류로 전달합니다. 암호
|
|
|
534
647
|
|
|
535
648
|
### 도구
|
|
536
649
|
|
|
537
|
-
일반 함수 도구, namespace 함수 도구, freeform 커스텀 도구를 변환합니다.
|
|
650
|
+
일반 함수 도구, namespace 함수 도구, freeform 커스텀 도구를 변환합니다. 커스텀
|
|
651
|
+
도구 호출이 Codex 이름으로 돌아와도, 그 이름이 도구 하나뿐이면 다시 맞춥니다.
|
|
652
|
+
스트리밍된 인자 이벤트와 완료된 응답 목록의 이름도 같이 맞춥니다. 커스텀
|
|
653
|
+
도구 결과도 맞추며, call id만 있어도 맞춥니다. 내용
|
|
654
|
+
목록으로 온 함수 결과는 텍스트로 넘깁니다. 원격 이미지 주소는 그 글에
|
|
655
|
+
넣고, 인라인 PNG·JPEG·WebP는 도구 결과 뒤에 붙여 모델이 보게 합니다. 이전
|
|
656
|
+
웹 검색은 질의와 찾은 페이지 주소를 이력에 남깁니다. stdout,
|
|
657
|
+
stderr, 합쳐진 명령 출력도 이력에 남습니다. 0이 아닌 종료 코드도 그 출력과
|
|
658
|
+
함께 남습니다. 파일
|
|
538
659
|
변경·MCP 등은 Codex가 노출한 도구와 사용자가 정한 승인 정책 안에서 동작합니다.
|
|
539
660
|
개별 기능을 모두 실검증한 것은 아닙니다.
|
|
540
661
|
|
|
@@ -548,11 +669,13 @@ PNG / JPEG / WebP. **이미지당 10 MiB, 요청 전체 20 MiB**, 서로 다른
|
|
|
548
669
|
때문에, 예전에는 한도를 넘는 이미지가 히스토리에 한 번 들어가면 이후 모든 턴이
|
|
549
670
|
영구히 400이었습니다. 지금은 그 첨부만 이유를 밝힌 텍스트로 바꾸고 나머지는
|
|
550
671
|
그대로 보냅니다. 쓸 수 있는 이미지는 `input_image` 그대로 넘어가며 Grok가 직접
|
|
551
|
-
읽습니다. 원격 URL은 가져오지 않습니다.
|
|
672
|
+
읽습니다. 원격 URL은 가져오지 않습니다. 오디오 첨부는 설명으로 바꿔서, 그
|
|
673
|
+
바이트가 턴을 거절하지 않게 합니다.
|
|
552
674
|
|
|
553
675
|
### 이미지 생성
|
|
554
676
|
|
|
555
|
-
|
|
677
|
+
생성된 이미지는 한 번만 저장하고, 완료된 응답에는 그 파일 설명을 실어 원본
|
|
678
|
+
바이트를 남기지 않습니다. 브리지가 상류 요청에 `{ type: "image_generation" }`을 직접 선언합니다. Codex는
|
|
556
679
|
이 프로바이더에 이미지 생성 도구를 주지 않습니다(263개 중 없음, `view_image`
|
|
557
680
|
뿐). 선언이 없으면 Codex `imagegen` 스킬이 OpenAI 경로(`image_gen` 또는
|
|
558
681
|
`OPENAI_API_KEY` + `gpt-image-*`)로 가서, 추론은 Grok인데 그림만 다른 벤더가
|
|
@@ -580,6 +703,13 @@ Grok의 `image_generation`은 텍스트→이미지만 제대로 됩니다.
|
|
|
580
703
|
설명하지 말라고 적습니다. 진짜 알파나 정확한 인페인팅이 필요하면 Codex의
|
|
581
704
|
OpenAI 경로가 맞습니다.
|
|
582
705
|
|
|
706
|
+
### 영상 생성
|
|
707
|
+
|
|
708
|
+
끝난 클립은 임시 URL입니다. 브리지는 로그인 베어러 없이 그 파일을
|
|
709
|
+
`~/.local/share/codex-grok-bridge/generated-videos/`에 받고, 도구 결과에는
|
|
710
|
+
URL과 저장한 파일 경로를 함께 넣습니다. 다운로드가 실패하면 결과는 URL만
|
|
711
|
+
남습니다.
|
|
712
|
+
|
|
583
713
|
### GPT ↔ Grok 전환
|
|
584
714
|
|
|
585
715
|
대기 중인 저장된 루트 작업에서만 됩니다. `turn/start`,
|
|
@@ -592,7 +722,7 @@ OpenAI 경로가 맞습니다.
|
|
|
592
722
|
|
|
593
723
|
### 이번 릴리스에 없는 것
|
|
594
724
|
|
|
595
|
-
|
|
725
|
+
음성 세션은 xAI 음성 소켓이 로그인을 수락하는지, 그리고 데스크톱이 브리지와 ICE를 끝내는지를 따릅니다. Codex 클라우드 작업은 이 패키지에 없습니다.
|
|
596
726
|
|
|
597
727
|
상류가 응답 중간에 연결을 리셋하는 경우가 있습니다(실측 3건: 25초 / 27초 /
|
|
598
728
|
253초, 726 KB–22 MB). 브리지는 응답을 들고 있다가, Codex에 그 응답을 보내기
|
|
@@ -640,7 +770,7 @@ OpenAI 경로가 맞습니다.
|
|
|
640
770
|
## 검증
|
|
641
771
|
|
|
642
772
|
```sh
|
|
643
|
-
npm test #
|
|
773
|
+
npm test # 191건, 외부 추론 없음
|
|
644
774
|
npm run test:coverage # line/branch/function 80% 게이트
|
|
645
775
|
npm run verify:app-server # 실제 app-server 라우팅. 설치된 앱 번들에서도 실행
|
|
646
776
|
npm audit --omit=dev
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codex-grok-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Run Grok 4.7 as the model inside Codex, with Codex still owning tools, permissions, history and MCP. Uses the grok login session, not an API key.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -51,5 +51,9 @@
|
|
|
51
51
|
"prepublishOnly": "npm test",
|
|
52
52
|
"test": "node --test",
|
|
53
53
|
"test:coverage": "node --test --experimental-test-coverage --test-coverage-include='src/*.mjs' --test-coverage-lines=80 --test-coverage-functions=80 --test-coverage-branches=80"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"opusscript": "0.1.1",
|
|
57
|
+
"werift": "0.24.4"
|
|
54
58
|
}
|
|
55
59
|
}
|