@galaxy-yearn/codex-deepseek-gateway 0.1.3 → 0.1.5

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/README.md CHANGED
@@ -1,59 +1,49 @@
1
1
  # Codex DeepSeek Gateway
2
2
 
3
- A small local gateway for using DeepSeek V4 models from Codex.
3
+ A lightweight local gateway for using DeepSeek models in Codex.
4
4
 
5
- Codex keeps sending OpenAI `Responses API` requests to a local endpoint. The gateway converts those requests to DeepSeek-compatible `Chat Completions`, calls DeepSeek, then converts the result back to Responses JSON or streaming `response.*` events.
5
+ Codex keeps using the OpenAI `Responses API` wire format. The gateway translates requests to DeepSeek-compatible `Chat Completions`, calls DeepSeek, then translates the result back to Responses JSON or `response.*` SSE events.
6
6
 
7
- NPM package: [@galaxy-yearn/codex-deepseek-gateway](https://www.npmjs.com/package/@galaxy-yearn/codex-deepseek-gateway)
8
-
9
- The runtime uses only the Node.js standard library. It installs under `~/.codex/deepseek-gateway`, runs as a detached background process, and does not edit your existing Codex config.
10
-
11
- Use this when you want Codex to stay on its normal Responses API path while the actual model is DeepSeek, including DeepSeek thinking output, function calls, local session resume help, and optional web search emulation through Tavily and Firecrawl.
7
+ Package: [@galaxy-yearn/codex-deepseek-gateway](https://www.npmjs.com/package/@galaxy-yearn/codex-deepseek-gateway)
12
8
 
13
9
  ## Requirements
14
10
 
15
- - Node.js 20 or newer
11
+ - Node.js 22 or newer
16
12
  - A DeepSeek API key
17
- - Codex configured from `~/.codex/config.toml`
13
+ - Codex CLI
18
14
 
19
15
  ## Install
20
16
 
21
- Run:
22
-
23
17
  ```sh
24
- npx @galaxy-yearn/codex-deepseek-gateway install
18
+ npm install -g @galaxy-yearn/codex-deepseek-gateway
19
+ codex-deepseek-gateway --version
20
+ codex-deepseek-gateway install
25
21
  ```
26
22
 
27
- This copies the runtime to:
28
-
29
- ```text
30
- ~/.codex/deepseek-gateway
31
- ```
32
-
33
- It creates two local config files:
23
+ The runtime is copied to `~/.codex/deepseek-gateway`. Put your DeepSeek API key in:
34
24
 
35
25
  ```text
36
26
  ~/.codex/deepseek-gateway/config/gateway.local.json
37
- ~/.codex/deepseek-gateway/config/model-aliases.json
38
27
  ```
39
28
 
40
- Put your DeepSeek API key in `gateway.local.json`:
41
-
42
29
  ```json
43
- "upstreamApiKey": "sk-..."
30
+ {
31
+ "upstreamApiKey": "sk-..."
32
+ }
44
33
  ```
45
34
 
46
- `model-aliases.json` controls the gateway-facing model IDs exposed on `GET /v1/models` and used by the `sessions` picker. Edit it only if you want to add or rename model aliases.
47
-
48
- If the key is already configured, `install` also starts the gateway. If this is your first install, add the key and then run:
35
+ `install` preserves an existing `gateway.local.json`. If this is your first install, add the key and start the gateway:
49
36
 
50
37
  ```sh
51
- npx @galaxy-yearn/codex-deepseek-gateway start
38
+ codex-deepseek-gateway start
39
+ codex-deepseek-gateway status
52
40
  ```
53
41
 
54
- ## Configure Codex
42
+ `status` should show `"reachable": true`.
43
+
44
+ ## Codex Config
55
45
 
56
- Edit `~/.codex/config.toml`:
46
+ Add this provider to `~/.codex/config.toml`:
57
47
 
58
48
  ```toml
59
49
  model_provider = "deepseek-gateway"
@@ -68,183 +58,122 @@ base_url = "http://127.0.0.1:3000/v1"
68
58
  wire_api = "responses"
69
59
  ```
70
60
 
71
- Use `deepseek-v4-pro` instead of `deepseek-v4-flash` if you want the pro model.
72
-
73
- Restart Codex after changing `config.toml`.
61
+ Use `deepseek-v4-pro` if you want the pro model. Restart Codex after editing `config.toml`.
74
62
 
75
- ## Start And Verify
63
+ ## Usage
76
64
 
77
- Start, stop, and inspect the local background process:
65
+ Start a new Codex conversation with gateway overrides:
78
66
 
79
67
  ```sh
80
- npx @galaxy-yearn/codex-deepseek-gateway start
81
- npx @galaxy-yearn/codex-deepseek-gateway stop
82
- npx @galaxy-yearn/codex-deepseek-gateway status
68
+ codex-deepseek-gateway new
83
69
  ```
84
70
 
85
- `status` should show `"reachable": true`.
86
-
87
- Run `doctor` to check the active Codex config and the DeepSeek request shape the gateway will send:
71
+ Resume a Codex session from the current project:
88
72
 
89
73
  ```sh
90
- npx @galaxy-yearn/codex-deepseek-gateway doctor
74
+ codex-deepseek-gateway sessions
91
75
  ```
92
76
 
93
- Important fields:
77
+ Useful non-interactive forms:
94
78
 
95
- - `codexConfigUsingGateway` should be `true`
96
- - `codexModel` should be your gateway model, for example `deepseek-v4-pro`
97
- - `codexReasoningEffort` should match `model_reasoning_effort`
98
- - `deepseekThinking` shows the DeepSeek `thinking` payload
99
- - `deepseekReasoningEffort` shows the DeepSeek effort sent upstream
100
- - `gatewayEmitsReasoningSummary` should be `true` when DeepSeek thinking is enabled
101
- - `tavilyWebSearchReady` and `firecrawlWebFetchReady` show whether optional web search backends are usable
79
+ ```sh
80
+ codex-deepseek-gateway new --model deepseek-v4-flash --reasoning-effort low
81
+ codex-deepseek-gateway new --print
82
+ codex-deepseek-gateway sessions --print
83
+ codex-deepseek-gateway sessions --all
84
+ codex-deepseek-gateway sessions --exec <id-or-row>
85
+ ```
102
86
 
103
- Avoid running Codex through a proxy while using the local gateway. Some proxy clients intercept `http://127.0.0.1:3000` and can break local gateway requests.
87
+ `new` chooses a model, then Codex reasoning effort. `sessions` chooses a session first, then model and reasoning effort. Both launch Codex with:
104
88
 
105
- ## Models
89
+ ```sh
90
+ codex -c model_provider=deepseek-gateway -c model=<model> -c model_reasoning_effort=<effort> -c model_supports_reasoning_summaries=true -c model_reasoning_summary=auto
91
+ ```
106
92
 
107
- The installed `config/model-aliases.json` starts with:
93
+ Model aliases are read from:
108
94
 
109
- ```json
110
- {
111
- "deepseek-v4-flash": {
112
- "model": "deepseek-v4-flash",
113
- "thinking": "auto"
114
- },
115
- "deepseek-v4-pro": {
116
- "model": "deepseek-v4-pro",
117
- "thinking": "auto"
118
- }
119
- }
95
+ ```text
96
+ ~/.codex/deepseek-gateway/config/model-aliases.json
120
97
  ```
121
98
 
122
- The gateway serves these aliases directly on `GET /v1/models`. If you also want to merge DeepSeek's upstream `/models` list, set this in `gateway.local.json`:
99
+ ## Commands
123
100
 
124
- ```json
125
- "fetchUpstreamModels": true
101
+ ```sh
102
+ codex-deepseek-gateway install
103
+ codex-deepseek-gateway start
104
+ codex-deepseek-gateway stop
105
+ codex-deepseek-gateway status
106
+ codex-deepseek-gateway doctor
107
+ codex-deepseek-gateway new
108
+ codex-deepseek-gateway sessions
109
+ codex-deepseek-gateway uninstall
126
110
  ```
127
111
 
128
- Whether Codex TUI `/model` shows custom provider models depends on the Codex client build. `config.toml` and the `sessions` command remain the reliable ways to choose a model.
112
+ `doctor` checks the active Codex config, DeepSeek request shape, reasoning mode, and optional web-search backend readiness.
113
+
114
+ To remove the local runtime and then uninstall the global package:
115
+
116
+ ```sh
117
+ codex-deepseek-gateway uninstall
118
+ npm uninstall -g @galaxy-yearn/codex-deepseek-gateway
119
+ ```
129
120
 
130
121
  ## Reasoning
131
122
 
132
- Codex reasoning effort maps to DeepSeek V4 thinking mode:
123
+ Codex effort maps to DeepSeek V4 thinking mode:
133
124
 
134
- | Codex `model_reasoning_effort` | DeepSeek request |
125
+ | Codex effort | DeepSeek request |
135
126
  | --- | --- |
136
127
  | `low` | `thinking.type = disabled` |
137
128
  | `medium` | `thinking.type = enabled`, `reasoning_effort = high` |
138
129
  | `high` | `thinking.type = enabled`, `reasoning_effort = high` |
139
130
  | `xhigh` | `thinking.type = enabled`, `reasoning_effort = max` |
140
131
 
141
- `model_supports_reasoning_summaries = true` and `model_reasoning_summary = "auto"` tell Codex to use its normal thinking UI path. When DeepSeek returns `reasoning_content`, the gateway keeps the raw text as `reasoning_text` and mirrors it into `summary_text` with a `Reasoning` heading for Codex TUI compatibility.
142
-
143
- When thinking is enabled, the gateway intentionally buffers visible assistant text and tool-call output until the upstream response completes, then emits reasoning first. This improves thinking order in Codex at the cost of higher first-token latency.
132
+ When DeepSeek returns `reasoning_content`, the gateway preserves the raw text for DeepSeek history and sends a display-only Markdown-cleaned copy through Codex's reasoning summary UI. The raw reasoning is not duplicated into visible message content.
144
133
 
145
134
  ## Web Search
146
135
 
147
- Web search is off by default. To let Codex's native `web_search` or `web_search_preview` tool work while DeepSeek is active, configure the optional backends in `gateway.local.json`.
148
-
149
- Tavily provides search results:
136
+ Web search is optional and off by default. Configure Tavily for search:
150
137
 
151
138
  ```json
152
- "tavilyApiKey": "tvly-...",
153
- "tavilyWebSearchEnabled": true
139
+ {
140
+ "tavilyApiKey": "tvly-...",
141
+ "tavilyWebSearchEnabled": true
142
+ }
154
143
  ```
155
144
 
156
- Firecrawl provides opened-page reading and focused page lookup:
145
+ Configure Firecrawl if you also want opened-page reading:
157
146
 
158
147
  ```json
159
- "firecrawlApiKey": "fc-...",
160
- "firecrawlWebFetchEnabled": true,
161
- "firecrawlAutoScrapeTopResults": 3
162
- ```
163
-
164
- Codex does not need MCP, a different tool name, or prompt changes. The gateway converts Codex web search requests into internal Chat Completions tools:
165
-
166
- - `tavily_search` searches the web and returns citation-ready snippets.
167
- - `firecrawl_open_page` reads a specific public page.
168
- - `firecrawl_find_in_page` reads a page with a focused query.
169
-
170
- DeepSeek receives compact text context containing the search query, sources, snippets, and optional opened-page excerpts. Codex receives Responses-compatible `web_search_call` items, final assistant messages, and URL citation annotations when the final text cites a matching source marker.
171
-
172
- The web payload is intentionally text-focused. Tavily is called with `include_raw_content: false`; Firecrawl defaults to main content, removes base64 images, rejects local/private URLs, and truncates page text before it reaches the model.
173
-
174
- ## Sessions
175
-
176
- Open a cross-provider session picker from a project:
177
-
178
- ```sh
179
- npx @galaxy-yearn/codex-deepseek-gateway sessions
180
- ```
181
-
182
- The picker is read-only. It scans Codex local transcript files, lists sessions for the current project across providers, then runs:
183
-
184
- ```sh
185
- codex resume <session-id> -c model_provider=deepseek-gateway -c model=<model> -c model_reasoning_effort=<effort>
186
- ```
187
-
188
- Flow:
189
-
190
- - choose a model from `~/.codex/deepseek-gateway/config/model-aliases.json`
191
- - choose Codex reasoning effort
192
- - choose the session to resume
193
- - use `Up/Down` to select, `Enter` to confirm, `Left` to go back, and `Esc` to quit
194
-
195
- Print copyable resume commands instead of opening the picker:
196
-
197
- ```sh
198
- npx @galaxy-yearn/codex-deepseek-gateway sessions --print
199
- ```
200
-
201
- Include sessions outside the current project:
202
-
203
- ```sh
204
- npx @galaxy-yearn/codex-deepseek-gateway sessions --all
205
- ```
206
-
207
- The command does not edit session files, change provider ownership, or change Codex's native resume picker filters. It only helps you find the hidden session id and resume it with explicit config overrides.
208
-
209
- ## Commands
210
-
211
- ```sh
212
- npx @galaxy-yearn/codex-deepseek-gateway install
213
- npx @galaxy-yearn/codex-deepseek-gateway start
214
- npx @galaxy-yearn/codex-deepseek-gateway stop
215
- npx @galaxy-yearn/codex-deepseek-gateway status
216
- npx @galaxy-yearn/codex-deepseek-gateway doctor
217
- npx @galaxy-yearn/codex-deepseek-gateway sessions
218
- npx @galaxy-yearn/codex-deepseek-gateway uninstall
148
+ {
149
+ "firecrawlApiKey": "fc-...",
150
+ "firecrawlWebFetchEnabled": true
151
+ }
219
152
  ```
220
153
 
221
- `start` launches a headless background Node.js process. `stop` stops it. `uninstall` stops the gateway and removes `~/.codex/deepseek-gateway`, but it does not edit `~/.codex/config.toml`.
154
+ Codex can keep requesting `web_search` / `web_search_preview`. The gateway exposes compact internal web tools to DeepSeek, executes Tavily/Firecrawl calls itself, feeds tool results back to the model, and returns Codex-compatible `web_search_call` items. `TAVILY_MAX_SEARCH_ROUNDS` defaults to `10` and is only a runaway/cost guardrail; when reached, the gateway disables web tools for one final-answer turn.
222
155
 
223
- If `start` returns without visible output on your terminal, run `status`; `"reachable": true` is the source of truth.
156
+ Final answers should include useful source titles and URLs directly.
224
157
 
225
- ## What Works
158
+ ## 0.1.5 Updates
226
159
 
227
- - Codex `POST /v1/responses`
228
- - streaming and non-streaming responses
229
- - text input and output
230
- - image, file, and audio content parts when DeepSeek accepts the corresponding Chat Completions shape
231
- - function tools and tool-call history
232
- - DeepSeek thinking mode and `reasoning_content`
233
- - lightweight local `previous_response_id` / `conversation` history while the gateway process is running
234
- - `GET /v1/models` with local model aliases and optional upstream discovery
235
- - optional Tavily/Firecrawl-backed `web_search` emulation
236
- - read-only cross-provider session picker
160
+ - Global CLI usage: install once with `npm install -g`, then run `codex-deepseek-gateway ...` from any directory.
161
+ - `install` preserves `gateway.local.json`; runtime defaults stay in code.
162
+ - `new` and `sessions` launch Codex with reasoning-summary config overrides.
163
+ - `sessions` first chooses the session, hides subagent transcripts, and sorts by the latest user-message date.
164
+ - DeepSeek-facing tool descriptions are compact; namespaced Codex local tools, including multi-agent tools, pass back to Codex with namespace preserved.
165
+ - Web search uses a model-driven loop: internal Tavily/Firecrawl tools run in the gateway, local Codex tools pass through to Codex, and final-answer turns no longer end as empty completions.
166
+ - Reasoning display now uses Codex summary events only, with display-only Markdown cleanup to avoid duplicate or truncated thinking text.
237
167
 
238
168
  ## Limits
239
169
 
240
- Chat Completions is not a full Responses API replacement. Some Responses features have no equivalent upstream field.
170
+ Chat Completions is not a full Responses API replacement.
241
171
 
242
- - Hosted tools such as file search, computer use, image generation, and code interpreter are represented as function-tool shims unless Codex executes matching tools locally. Web search is the only hosted tool the gateway can emulate directly.
243
- - Tavily and Firecrawl web emulation is text-focused. It does not expose raw HTML, screenshots, browser actions, crawl/map jobs, cookies, private network access, or provider-specific payloads through Codex `web_search`.
244
- - URL citations are returned in the Responses metadata path. Whether they appear as clickable links in the terminal depends on the Codex client build and how it renders custom-provider citation annotations.
172
+ - Hosted tools without a local Codex executor are represented as function shims. Web search is the only hosted tool the gateway emulates directly.
173
+ - Tavily/Firecrawl web emulation is text-focused; it does not provide browser control, screenshots, raw HTML, cookies, crawl jobs, or private-network access.
245
174
  - OpenAI `file_id` values are passed through; the gateway cannot fetch private OpenAI-hosted files.
246
- - In-memory conversation history is lost when the gateway restarts.
247
- - The gateway exposes model aliases on `/v1/models`, including aliases from `config/model-aliases.json`. Whether Codex TUI `/model` actually shows custom provider models depends on the Codex build. `config.toml` remains the reliable fallback.
175
+ - In-memory `previous_response_id` / `conversation` history is lost when the gateway process restarts.
176
+ - The gateway exposes model aliases on `/v1/models`; whether Codex TUI `/model` shows them depends on the Codex build. `config.toml`, `new`, and `sessions` are the reliable model-selection paths.
248
177
 
249
178
  ## License
250
179
 
@@ -13,6 +13,7 @@ import { createRequire } from 'node:module';
13
13
  import { dirname, join, resolve } from 'node:path';
14
14
  import { fileURLToPath } from 'node:url';
15
15
  import { loadConfig } from '../src/config.js';
16
+ import { newConversation } from '../src/codex-launch.js';
16
17
  import { sessions } from '../src/codex-sessions.js';
17
18
  import { toProviderChatCompletionsRequest } from '../src/protocol.js';
18
19
 
@@ -33,20 +34,23 @@ Usage:
33
34
  codex-deepseek-gateway stop
34
35
  codex-deepseek-gateway status
35
36
  codex-deepseek-gateway doctor
37
+ codex-deepseek-gateway new
36
38
  codex-deepseek-gateway sessions
37
39
  codex-deepseek-gateway uninstall
38
40
 
39
41
  Options:
42
+ -v, --version Print package version
40
43
  --dir <path> Install directory, defaults to ~/.codex/deepseek-gateway
41
44
  --no-edit Do not open the local config file after install
42
45
  --all With sessions, include sessions outside the current project
43
- --provider <id> With sessions, target model_provider override
44
- --model <id> With sessions, target model override
46
+ --provider <id> With new/sessions, target model_provider override
47
+ --model <id> With new/sessions, target model override
45
48
  --reasoning-effort <level>
46
- With sessions, target Codex reasoning effort
49
+ With new/sessions, target Codex reasoning effort
47
50
  --exec <id> With sessions, run the generated codex resume command
48
51
  --limit <n> With sessions, max rows to print, defaults to 20
49
- --print With sessions, print copyable resume commands instead of picker
52
+ --print With new, print the launch command. With sessions, print
53
+ copyable resume commands instead of picker
50
54
  `);
51
55
  }
52
56
 
@@ -55,7 +59,9 @@ function parseArgs(argv) {
55
59
  const rest = [];
56
60
  for (let index = 0; index < argv.length; index += 1) {
57
61
  const arg = argv[index];
58
- if (arg === '--dir' || arg === '-d' || arg === '-InstallDir') {
62
+ if (arg === '--version' || arg === '-v') {
63
+ options.version = true;
64
+ } else if (arg === '--dir' || arg === '-d' || arg === '-InstallDir') {
59
65
  const value = argv[index + 1];
60
66
  if (!value) throw new Error(`${arg} requires a path`);
61
67
  options.dir = resolve(value);
@@ -250,6 +256,10 @@ async function install(options) {
250
256
  }
251
257
 
252
258
  async function start(options) {
259
+ if (!existsSync(options.dir)) {
260
+ throw new Error(`Missing runtime at ${options.dir}. Run install first.`);
261
+ }
262
+ copyRuntime(options.dir);
253
263
  if (!existsSync(serverPath(options.dir))) {
254
264
  throw new Error(`Missing runtime at ${options.dir}. Run install first.`);
255
265
  }
@@ -363,7 +373,6 @@ async function doctor(options) {
363
373
  : thinkingEnabled
364
374
  ? 'summary'
365
375
  : 'disabled';
366
- const codexSummaryConfigured = supportsReasoningSummaries && summaryMode && summaryMode !== 'none';
367
376
  print(JSON.stringify({
368
377
  packageVersion: packageJson.version,
369
378
  installDir: options.dir,
@@ -380,8 +389,6 @@ async function doctor(options) {
380
389
  deepseekThinking: upstreamRequest.thinking || null,
381
390
  deepseekReasoningEffort: upstreamRequest.reasoning_effort || null,
382
391
  reasoningDisplayMode,
383
- gatewayEmitsReasoningSummary: reasoningDisplayMode === 'summary',
384
- codexSummaryConfigured,
385
392
  tavilyWebSearchEnabled: Boolean(config.tavilyWebSearchEnabled),
386
393
  tavilyWebSearchReady: Boolean(config.tavilyWebSearchEnabled && config.tavilyApiKey),
387
394
  firecrawlWebFetchEnabled: Boolean(config.firecrawlWebFetchEnabled),
@@ -400,11 +407,15 @@ async function uninstall(options) {
400
407
 
401
408
  async function main() {
402
409
  const { command, options } = parseArgs(process.argv.slice(2));
410
+ if (options.version) {
411
+ print(`${packageJson.version}\n`);
412
+ return;
413
+ }
403
414
  if (!command || command === '-h' || command === '--help' || command === 'help') {
404
415
  usage();
405
416
  return;
406
417
  }
407
- const commands = { install, start, stop, status, doctor, sessions, uninstall };
418
+ const commands = { install, start, stop, status, doctor, new: newConversation, sessions, uninstall };
408
419
  const handler = commands[command];
409
420
  if (!handler) {
410
421
  throw new Error(`Unknown command: ${command}`);
@@ -1,23 +1,7 @@
1
1
  {
2
- "port": 3000,
3
- "host": "127.0.0.1",
4
- "upstreamProvider": "deepseek",
5
- "upstreamBaseUrl": "https://api.deepseek.com",
6
2
  "upstreamApiKey": "sk-REPLACE_ME",
7
- "upstreamTimeoutMs": 120000,
8
3
  "tavilyApiKey": "",
9
4
  "tavilyWebSearchEnabled": false,
10
- "tavilySearchDepth": "basic",
11
- "tavilyMaxResults": 5,
12
- "tavilyMaxSearchRounds": 2,
13
- "tavilyTimeoutMs": 15000,
14
5
  "firecrawlApiKey": "",
15
- "firecrawlWebFetchEnabled": false,
16
- "firecrawlAutoScrapeTopResults": 3,
17
- "firecrawlPageMaxChars": 5000,
18
- "firecrawlTimeoutMs": 30000,
19
- "fetchUpstreamModels": false,
20
- "modelsTimeoutMs": 5000,
21
- "modelsCacheMs": 60000,
22
- "debugPayload": false
6
+ "firecrawlWebFetchEnabled": false
23
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxy-yearn/codex-deepseek-gateway",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Local OpenAI Codex Responses API gateway for DeepSeek Chat Completions.",
5
5
  "type": "module",
6
6
  "main": "src/server.js",
@@ -19,7 +19,7 @@
19
19
  "test": "node --test"
20
20
  },
21
21
  "engines": {
22
- "node": ">=20"
22
+ "node": ">=22"
23
23
  },
24
24
  "keywords": [
25
25
  "codex",