codex-copilot-dx 0.9.33 → 0.9.35

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
@@ -2,8 +2,7 @@
2
2
 
3
3
  Use Codex App with GitHub Copilot through a local adapter.
4
4
 
5
- CCDX targets Codex App. It discovers Copilot models, adapts the client's model
6
- catalog, and preserves Responses streaming, tool calls and conversation history.
5
+ CCDX targets Codex App: Copilot discovery, adapted model catalogs, Responses streaming, tool calls and conversation history.
7
6
  Default Auto-review: **GPT-6.1 Sol / low**. Image generation is **off by default**. Native predictions are also **off by default**.
8
7
 
9
8
  ## Install and run
@@ -23,7 +22,7 @@ enabled. If PowerShell blocks scripts, use `npm.cmd` / `ccdx.cmd`; do not change
23
22
 
24
23
  Open [the local dashboard](http://127.0.0.1:2026/) for status, model discovery,
25
24
  usage, cache/limits, recent failures, request context and animation settings.
26
- Auto refresh runs every 30 minutes while visible and can be switched off. Hidden pages pause; opening sections and manual refresh still work.
25
+ Auto refresh runs every 30 minutes while visible and can be switched off. Hidden pages pause; opening sections and manual refresh still work. Startup uses an atom icon and aligned checks; `Ready` refers to the core service. Narrow/non-color terminals use a plain title.
27
26
 
28
27
  ## Commands
29
28
 
@@ -75,6 +74,7 @@ Auto refresh runs every 30 minutes while visible and can be switched off. Hidden
75
74
  Other domains and the CCDX model endpoint stay on their existing routes.
76
75
  No program files or OS trust are changed. Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are retained.
77
76
  Windows supports company PAC/WPAD; macOS dynamic routing remains unsupported. Windows setup needs the official MSIX App, Windows PowerShell and .NET Framework 4.7.2+—not Git/OpenSSL. See the reference for limits.
77
+ Bridge checks allow three same-port recovery attempts per process, without App restart/replay. Only closed, initialized Apps in direct environments receive an owned persistent route; user/company proxies are preserved. Missing routes in running Apps are not hot-attached.
78
78
  - CCDX adds experimental local history compression only when installed App
79
79
  runtimes support it and report it off. Existing choices are preserved; an
80
80
  already-enabled default, unavailable runtime or failed check is skipped.
@@ -82,11 +82,11 @@ Auto refresh runs every 30 minutes while visible and can be switched off. Hidden
82
82
  use public HTTPS URLs; well-known NAT64 mappings follow IPv4 address rules.
83
83
  - Keep the adapter on loopback. LAN mode is only for trusted networks; do not
84
84
  expose it to the public internet. The dashboard is not an authentication wall
85
- for the API. Diagnostic errors may contain sensitive upstream text.
85
+ for the API. Inference rejects browser Origin headers; native clients remain supported. Diagnostic errors may contain sensitive upstream text.
86
86
 
87
87
  Startup checks GitHub's latest-release web redirect, not npm or the anonymous REST quota, and suggests `ccdx update github`.
88
88
  Updates install the exact stable tag; dependencies still use npm's configured registry. Lookup errors identify HTTP refusal, timeout, network failure or invalid redirects.
89
- Updates warn about mismatched npm targets without changing PATH/prefix. Full `ccdx doctor` reports this target and readonly credential permissions; it never changes ACLs.
89
+ Updates warn about mismatched npm targets without changing PATH/prefix and verify the installed target version (exact tag for GitHub). Restart the adapter separately. Full `ccdx doctor` reports this target and readonly credential permissions; it never changes ACLs.
90
90
  Recent errors separate HTTP and model failures. HTTP metadata retains status, source and IDs, not error bodies or prompts; original errors still reach Codex unchanged.
91
91
 
92
92
  The dashboard and CLI separate prediction preference, bridge state and observed config traffic; candidate visibility stays unknown.
package/bin/cli.mjs CHANGED
@@ -22,6 +22,7 @@ import { createProfileRuntime } from "../src/profile-runtime.mjs";
22
22
  import { createProfileModelRuntime } from "../src/profile-model-runtime.mjs";
23
23
  import { createCodexModelCatalog } from "../src/codex-model-catalog.mjs";
24
24
  import { setResponseHistoryMaxBytes } from "../src/response-history.mjs";
25
+ import { startupBanner, startupCheck, startupReady, startupLogger, predictionStartupCheck } from "../src/startup-ui.mjs";
25
26
 
26
27
  const LOCAL_VERSION = localPackageVersion();
27
28
  const CLI_NAME = cliCommandName();
@@ -271,7 +272,8 @@ async function clientIntegrations() {
271
272
  if (!clientIntegration) {
272
273
  const { createClientIntegration } = await import("../src/client-integration.mjs");
273
274
  clientIntegration = createClientIntegration({ port: ADAPTER_PORT, host: ADAPTER_HOST,
274
- info: (message) => console.log(status("info", message)), warning: (message) => console.warn(status("warn", message)) });
275
+ configLog: startupLogger("Config"),
276
+ info: (message) => console.log(startupCheck("info", "Client", message)), warning: (message) => console.warn(startupCheck("warn", "Client", message)) });
275
277
  }
276
278
  return clientIntegration;
277
279
  }
@@ -293,30 +295,36 @@ async function reuseRunningAdapterIfAvailable() {
293
295
  }
294
296
  if (!running.ok) return false;
295
297
 
296
- console.log(status("ok", `Using existing adapter at ${running.baseUrl}`));
297
- const { compressionSetup } = await configureCodexClient();
298
+ console.log(startupCheck("ok", "Adapter", `Using existing service at ${running.baseUrl}`));
299
+ console.log(startupCheck("info", "Auth", "Using existing service credentials; not rechecked"));
300
+ const { compressionSetup, imageEnabled, imageMcpSkipped } = await configureCodexClient();
298
301
 
299
302
  let predictionPacUrl = null;
300
303
  let predictionApp = null;
301
304
  let predictionProfile = null;
305
+ let persistedPredictionRoute = false;
306
+ let predictionConfigured = false;
307
+ let launchRoute = "unknown";
302
308
  try {
303
309
  const { readPredictionSettings } = await import("../src/native-prediction-profile.mjs");
304
310
  const preference = readPredictionSettings();
311
+ predictionConfigured = preference.enabled;
305
312
  if (preference.enabled) {
306
313
  predictionPacUrl = running.data?.native_prediction_pac || null;
307
314
  predictionApp = preference.app?.app;
308
315
  predictionProfile = preference.app?.profile;
316
+ const { hasInstalledPredictionRoute } = await import("../src/native-prediction-route.mjs");
317
+ const { predictionPaths } = await import("../src/native-prediction-profile.mjs");
318
+ persistedPredictionRoute = hasInstalledPredictionRoute({ ...predictionPaths({ app: preference.app }), pacUrl: predictionPacUrl });
309
319
  if (!predictionPacUrl) console.warn(status("warn", "Restart ccdx to activate the newly enabled prediction bridge"));
310
320
  }
311
321
  } catch (error) { console.warn(status("warn", error.message)); }
312
- await openCodex({ predictionPacUrl, predictionApp, predictionProfile });
313
- console.log(`
314
- ${status("ok", "Ready, using the existing ccdx adapter")}
315
-
316
- Adapter: ${running.baseUrl}
317
-
318
- Tip: Run ${CLI_NAME} help to view more features and commands.
319
- `);
322
+ await openCodex({ predictionPacUrl, predictionApp, predictionProfile, persistedPredictionRoute,
323
+ onPredictionRoute: route => { launchRoute = route; }, log: startupLogger("App") });
324
+ console.log(predictionStartupCheck({ configured: predictionConfigured, bridge: predictionPacUrl ? "running" : "unknown", launch_route: launchRoute }));
325
+ console.log(startupCheck(imageEnabled && imageMcpSkipped ? "warn" : "info", "Images", imageEnabled
326
+ ? imageMcpSkipped ? "Client setup skipped; see warning above" : "Configured; provider not tested" : "Off"));
327
+ console.log(startupReady({ baseUrl: running.baseUrl, commandName: CLI_NAME, reused: true }));
320
328
  await compressionSetup;
321
329
  return true;
322
330
  }
@@ -337,17 +345,14 @@ if (CLI.command === "doctor") {
337
345
  process.exit(checks.some((check) => check.kind === "err") ? 1 : 0);
338
346
  }
339
347
 
340
- console.log(`
341
- ${CLI_BANNER}
342
- Use Codex App with GitHub Copilot
343
- `);
348
+ console.log(`\n${startupBanner({ commandName: CLI_NAME, version: LOCAL_VERSION })}\n`);
344
349
 
345
350
  async function printUpdateNotice() {
346
351
  try {
347
352
  const { latestVersion, updateAvailable } = await checkForUpdate({ currentVersion: LOCAL_VERSION });
348
353
  if (!updateAvailable) return;
349
- console.log(`\n ${status("warn", `Update available: ${LOCAL_VERSION} -> ${latestVersion}`)}`);
350
- console.log(` Run ${CLI_NAME} update github to update, then restart ${CLI_NAME}.\n`);
354
+ console.log(`\n${status("warn", `Update available: ${LOCAL_VERSION} -> ${latestVersion}`)}`);
355
+ console.log(`Run ${CLI_NAME} update github to update, then restart ${CLI_NAME}.\n`);
351
356
  } catch {
352
357
  // Never block startup on the update check.
353
358
  }
@@ -364,20 +369,25 @@ try {
364
369
  }
365
370
 
366
371
  // Ensure GitHub login, using device flow if no token exists.
367
- await ensureAuth();
372
+ await ensureAuth({ log: startupLogger("Auth") });
368
373
 
369
374
  const profileRuntime = createProfileRuntime({ codexClient: defaultCopilotClient });
375
+ let startupComplete = false;
370
376
  const profileModels = createProfileModelRuntime({
371
377
  codexClient: profileRuntime.codexClient,
372
378
  codexCredentialFingerprint: profileRuntime.codexCredentialFingerprint,
373
379
  timeoutMs: MODEL_REFRESH_TIMEOUT_MS,
374
380
  commandName: CLI_NAME,
375
381
  autoReviewModelResolver: () => autoReviewModelPreference().model,
382
+ log: (kind, message) => console.log(startupComplete ? status(kind, message) : startupCheck(kind, "Models", message)),
376
383
  });
377
384
 
378
385
  // Refresh the VS Code version in the background; fallback is non-blocking.
379
386
  void refreshVSCodeVersion();
380
387
  await profileModels.initialize();
388
+ if (profileModels.codexRegistry.source !== "live") {
389
+ console.log(startupCheck("info", "Models", `${profileModels.codexRegistry.source} list loaded${profileModels.codexRegistry.refreshInFlight ? "; refreshing" : ""}`));
390
+ }
381
391
 
382
392
  if (!isLoopbackHost(ADAPTER_HOST)) {
383
393
  console.log(status("warn", `ADAPTER_HOST=${ADAPTER_HOST} exposes the adapter beyond loopback because CCDX_ALLOW_LAN=1 is set. Use only on trusted networks.`));
@@ -387,6 +397,7 @@ try {
387
397
  const terminalAnimationTheme = terminalAnimationPreference().theme;
388
398
  const codexModelCatalog = createCodexModelCatalog();
389
399
  activeServer = await startAdapter(ADAPTER_PORT, ADAPTER_HOST, {
400
+ log: startupLogger("Adapter"),
390
401
  autoReviewModelResolver: () => autoReviewPreference(),
391
402
  codexClient: profileRuntime.codexClient,
392
403
  codexModelCatalog,
@@ -401,13 +412,19 @@ try {
401
412
  });
402
413
 
403
414
  // Point Codex App at the adapter.
404
- const { compressionSetup } = await configureCodexClient();
415
+ const { compressionSetup, imageEnabled, imageMcpSkipped } = await configureCodexClient();
405
416
 
406
417
  // Optional native prediction setup must never prevent the core adapter from running.
407
418
  nativePrediction = await (await clientIntegrations()).start();
419
+ const persistentRoute = await nativePrediction?.prepareRoute();
408
420
 
409
421
  // Launch Codex when available. A running App is never forcibly restarted.
410
- await openCodex({ predictionPacUrl: nativePrediction?.pacUrl, predictionApp: nativePrediction?.app, predictionProfile: nativePrediction?.profile });
422
+ await openCodex({ predictionPacUrl: nativePrediction?.pacUrl, predictionApp: nativePrediction?.app, predictionProfile: nativePrediction?.profile,
423
+ preparePredictionRoute: () => nativePrediction?.prepareRoute(), persistedPredictionRoute: persistentRoute?.status === "installed",
424
+ onPredictionRoute: route => clientIntegration?.launched(route), log: startupLogger("App") });
425
+ console.log(predictionStartupCheck(clientIntegration?.snapshot().prediction));
426
+ console.log(startupCheck(imageEnabled && imageMcpSkipped ? "warn" : "info", "Images", imageEnabled
427
+ ? imageMcpSkipped ? "Client setup skipped; see warning above" : "Configured; provider not tested" : "Off"));
411
428
 
412
429
  // Periodically refresh the model list + endpoint cache so a long-running
413
430
  // adapter picks up newly released models without a restart.
@@ -419,15 +436,8 @@ try {
419
436
  modelRefreshTimer.unref?.();
420
437
  }
421
438
 
422
- console.log(`
423
- ${status("ok", "Ready, CCDX adapter is ready to use")}
424
-
425
- Adapter: ${adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT)}
426
-
427
- Tip: Run ${CLI_NAME} help to view more features and commands.
428
-
429
- Press Ctrl+C to stop.
430
- `);
439
+ startupComplete = true;
440
+ console.log(startupReady({ baseUrl: adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT), commandName: CLI_NAME }));
431
441
 
432
442
  const shutdown = async (signal) => {
433
443
  if (shuttingDown) return;
@@ -17,6 +17,8 @@ The CLI composes the service. Client integration owns its `configure`, `start`,
17
17
  `snapshot` and `close` operations. It does not forward inference requests or
18
18
  render the dashboard. The adapter exposes integration snapshots and keeps
19
19
  management/MCP routes separate from the Responses path.
20
+ The HTTP dispatch boundary rejects browser Origin-bearing inference requests
21
+ before body admission, credential use or provider dispatch; native LAN opt-in is unchanged.
20
22
 
21
23
  Package installation is an explicit management operation in `package-update.mjs`,
22
24
  not part of inference or optional client integration. Windows uses the system
@@ -29,6 +31,9 @@ global target. A different target warns, but never changes PATH or prefix. Its
29
31
  bounded npm probe is limited to explicit update and full doctor commands.
30
32
  Its stdout/stderr are captured separately; npm configuration warnings do not
31
33
  leak into doctor output. The real installer's inherited streams are unchanged.
34
+ After installation, the updater verifies bounded package metadata at that same
35
+ selected target, with exact-version verification for GitHub. It never equates
36
+ installation with replacement of an already-running service.
32
37
 
33
38
  Authentication keeps its public facade in `auth.mjs`. Device-code polling and
34
39
  cancellation live in `auth-device-flow.mjs`; local discovery and transactional
@@ -64,9 +69,24 @@ prediction lifecycle, with locked first-start persistence and no replacement
64
69
  on conflict. OS process inspection stays in the launcher/platform boundary;
65
70
  it runs only for explicit prediction-enabled launch/reuse, not per model request.
66
71
  macOS uses bounded system `ps` reads and Windows retains its existing registered
67
- process checks. No process is stopped, no permanent watcher or dependency is
72
+ process checks. No process is stopped and no App-process watcher or dependency is
68
73
  added. Core inference keeps its existing service port and lifecycle.
69
74
 
75
+ `native-prediction-recovery.mjs` supervises only the enabled optional bridge,
76
+ using a low-cost listener check, same-route restart, single-flight recovery and
77
+ a three-attempt budget. It does not watch App processes, modify proxy policy or
78
+ replay inference. `native-prediction-route.mjs` separately owns the closed-profile
79
+ preference transaction and its rollback metadata. It accepts direct environments
80
+ only, preserves company/user routing, and never treats a saved preference as
81
+ proof of a running route or visible candidate. App compatibility is rechecked only
82
+ when its recorded identity changes, before existing trust/port checks are reused.
83
+
84
+ `startup-ui.mjs` is pure terminal presentation: a static A atom, aligned checks
85
+ and the common new/reused-service footer. It depends only on terminal/status
86
+ utilities, not on inference or platform probes. The CLI feeds existing lifecycle
87
+ results into it; presentation does not run doctor, call models or wait for optional
88
+ background tasks. All status tags share one fixed-width column.
89
+
70
90
  Connection-ownership replay rejection is a provider-owned retry policy. It
71
91
  removes only unavailable reasoning once, preserving visible history and tools.
72
92
  Opaque compaction cannot be assumed equivalent to remaining plaintext. The
@@ -80,6 +100,10 @@ Without a complete verified local source, rejection still returns
80
100
  `ccdx_history_rebuild_required`, without modifying stored history. Diagnostic
81
101
  metadata cannot reconstruct unavailable encrypted memory. LAN/browser callers
82
102
  and referenced/split histories do not gain filesystem recovery access.
103
+ The recovery module reuses the existing abort-aware singleflight for equivalent
104
+ source reads, not prepared requests or reservation handles. Caller validation and
105
+ admission remain independent. Only bounded snapshot-bound failure codes survive
106
+ settlement for two seconds; no successful plaintext cache or transcript index exists.
83
107
 
84
108
  ## Dashboard reads
85
109
 
@@ -131,6 +155,9 @@ dashboard merges recent HTTP, model and request-timeline failures for display.
131
155
  Tests cover module dependency direction, default-off behavior, concurrent writers,
132
156
  proxy handshakes, TLS validation, streaming, history isolation and release lookup.
133
157
  Performance measurements distinguish request preparation from model latency.
158
+ Actual loopback HTTP tests gate first-delta delivery before provider completion
159
+ and cancellation propagation for both native Responses and Chat translation.
160
+ Empty-stream diagnostics are additive scalar metadata, not a new retry policy.
134
161
  Release reports describe a specific environment, not an SLA or a guarantee of
135
162
  compatibility with every future client or corporate network policy.
136
163
  CI runs Node 22.15 and 24 on Linux, Windows and macOS. The owned temporary-prefix
package/docs/REFERENCE.md CHANGED
@@ -155,8 +155,10 @@ fallback after upstream-proxy rejection is added. The default App profile
155
155
  is `~/Library/Application Support/Codex`; an explicit
156
156
  `CODEX_ELECTRON_USER_DATA_PATH` is respected. Quit the App before trust changes;
157
157
  CCDX never kills it. The launcher uses the exact App that passed the compatibility
158
- check. Updating the App invalidates that check: quit it and run `prediction on`
159
- again. Unknown client/store/configuration formats are not forcibly rewritten.
158
+ check. A changed App is rechecked once at bridge startup using the existing
159
+ signature/protocol and profile checks. The exact App/profile identity, saved port
160
+ and trust must remain unchanged; unsupported updates still require explicit setup.
161
+ Unknown client/store/configuration formats are not forcibly rewritten.
160
162
  These are checked compatibility boundaries, not a promise for every future App.
161
163
 
162
164
  The bridge changes only its own prediction fields and preserves already-enabled
@@ -173,14 +175,17 @@ provide a separate prediction-model picker.
173
175
  `prediction off` immediately disables new local overlays. Quit/reopen Codex to
174
176
  clear its cached predictions and temporary route. If the App is still running,
175
177
  trust removal is deferred; quit it and run `prediction off` again. Only the exact
176
- owned certificate record is removed, never the whole store. Failed activation
178
+ owned certificate record is removed, never the whole store. A CCDX-owned persistent
179
+ proxy preference is restored first, preserving all unrelated preference values.
180
+ User-replaced proxy preferences are not restored over. Failed activation
177
181
  rolls back newly added trust; certificate replacement keeps old trust until the
178
182
  new preference is committed. If the bridge stops, new connections can fall back
179
183
  to the original route; already-interrupted requests are not replayed. An App
180
184
  already using the saved address need not be relaunched just because CCDX restarts.
181
185
  If its route is missing or differs, fully quit Codex and run `ccdx` to attach it.
182
- `CCDX_AUTO_LAUNCH=0` keeps
183
- automatic launch disabled and does not attach the route to a manually opened App.
186
+ `CCDX_AUTO_LAUNCH=0` keeps automatic launch disabled and never hot-attaches a
187
+ running App. An already-persisted direct-environment preference can still be read
188
+ when the App is manually opened.
184
189
  Optional prediction failures never prevent the core adapter or image service from
185
190
  starting. `prediction status` reports the saved preference and, when a compatible
186
191
  running adapter responds, its bridge state, configuration-response observations
@@ -191,6 +196,36 @@ no prompt matching, UI injection, transcript scanning or extra inference is used
191
196
  to invent that status. Prediction settings are stored separately in
192
197
  `~/.config/codex-copilot-dx/native-prediction/` (or under `XDG_CONFIG_HOME`).
193
198
 
199
+ Since `0.9.34`, an enabled bridge has a lightweight 30-second listener check.
200
+ Healthy checks do not spawn processes, call upstream, inspect transcripts or
201
+ probe model endpoints. A failed owned listener/native company-routing worker can
202
+ be recreated on the saved port, using the same checked profile and certificate.
203
+ There are at most three recovery attempts per CCDX process, with 30/60/120-second
204
+ backoff gates; checks themselves run every 30 seconds. Occupied ports are not
205
+ stolen or rotated. Startup failures do not gain a retry loop, and configuration
206
+ HTTP errors or missing gray text alone do not trigger transport restarts. Existing
207
+ requests can fail during an outage and are never replayed by this supervisor.
208
+ Disabled prediction startup creates no recovery timer. The existing in-memory
209
+ overlay switch still observes explicit on/off changes independently.
210
+
211
+ Before enabled App launch, CCDX can persist its PAC in that verified profile's
212
+ `Default/Preferences`, but only in a direct environment, with initialized regular
213
+ profile files and the App closed. Existing explicit App proxies and all company
214
+ static/PAC/WPAD routes are preserved. Ownership intent is stored in `route.json`
215
+ before changing the one proxy field; unrelated settings are retained, concurrent
216
+ edits fail closed, and matching setup is not rewritten. If an App is already
217
+ running, first-time migration is deferred until a normal closed-App launch;
218
+ CCDX does not claim it can hot-attach a missing route. A manually reopened App
219
+ with a saved preference is reported as awaiting configuration traffic, not as
220
+ launch-route verified. This preference is a prevention measure, not a guarantee
221
+ for every future Chromium profile format or OS version. Company proxy users keep
222
+ the verified launch-argument path. Core inference/image routes are unchanged.
223
+
224
+ `prediction status` and `ccdx status` also expose launch-route evidence, persistent
225
+ route state, recovery attempts and recoveries. These are independent of the
226
+ unknown candidate-visibility value. A successful recovery only means the bridge
227
+ was recreated on the original address, not that gray text appeared.
228
+
194
229
  ### Configuration ownership
195
230
 
196
231
  Core setup, image setup/guidance, config doctor, optional history compression and
@@ -227,6 +262,13 @@ One in-process adapter listens on `127.0.0.1:2026` by default and exposes:
227
262
 
228
263
  Responses-only models and compaction use Copilot's Responses transport directly. For requests routed through Chat Completions, CCDX converts the supported text, image, and function-tool subset and rejects incompatible message content rather than turning it into JSON text. Chat `length` and `content_filter` finish reasons become incomplete Responses in both streaming and non-streaming modes. Both streaming SSE and non-streaming responses are supported.
229
264
 
265
+ Chat conversion maps an explicitly supplied `reasoning.effort` to `reasoning_effort`.
266
+ Known effort values are checked against the existing model catalog when it advertises
267
+ an effort array; without that metadata, upstream validation remains authoritative.
268
+ No extra model lookup is made. Malformed function tools, forced undeclared functions,
269
+ unsupported tool-choice strings and unknown text formats receive a local compatibility
270
+ error instead of being dropped. Native Responses request fields are not changed by this check.
271
+
230
272
  The adapter handles response history, encrypted reasoning state, function/custom tools, images, compaction, cancellation, retries, and usage metadata within the compatibility boundaries below. Routing prefers endpoint metadata from Copilot's live or cached catalog; when metadata is unavailable, a small built-in set identifies known Responses-only GPT models.
231
273
 
232
274
  ### Local compaction recovery
@@ -262,6 +304,15 @@ a 16-candidate bound. Decoded reads and the rebuilt body are bounded by the
262
304
  running adapter's decoded-body limit; history admission reservations cover
263
305
  recovery preparation. Requests cannot retry after visible output has begun.
264
306
 
307
+ Overlapping equivalent recovery readers share in-flight source discovery/decoding,
308
+ with independent cancellation and independent restored requests. Every caller retains
309
+ its admission reservation; exclusive admission can serialize reads instead of sharing.
310
+ Successful plaintext is not retained after the flight settles. Up to 32 failure-code
311
+ records last two seconds, keyed by the exact source file identity/size/timestamps,
312
+ thread, compaction digest and byte limit. Directory discovery still runs; missing
313
+ sources, cancellation, deadlines and unstable snapshots are not cached. Source changes
314
+ invalidate reuse. No transcript index, watcher or healthy-request scan is added.
315
+
265
316
  Neither the original rollout nor client configuration is rewritten. Recovery
266
317
  diagnostics contain type/count/status metadata, not transcript text, ciphertext
267
318
  or file paths. If verification fails, `ccdx_history_rebuild_required` includes
@@ -366,7 +417,21 @@ The upgrade intentionally does not delete or rewrite retired Claude or PM Studio
366
417
  ## Commands
367
418
 
368
419
  Run `ccdx <command> --help` for command-specific behavior and side-effect details.
369
- After startup, CCDX prints a short reminder that `ccdx help` lists all available commands.
420
+ Startup uses aligned status/project/result columns and a left-aligned Ready footer
421
+ with the Web UI URL and `ccdx help`. Ctrl+C is shown only for the foreground-owned
422
+ service, never a short-lived command reusing another service. A static, favicon-style
423
+ atom uses ANSI green and half-block characters only on interactive color terminals
424
+ at least 72 columns wide; narrow terminals, `NO_COLOR`, `TERM=dumb` and redirected
425
+ output keep a plain title. No new graphics/font/runtime dependency is installed.
426
+ Credentials found are not labeled online-authorized, cached model lists are not
427
+ labeled fresh upstream data, and image configuration is not a provider test.
428
+ Ready reports core readiness independently of optional prediction/image warnings.
429
+ Model refresh logs show counts; `ccdx models` retains the complete live list.
430
+ After Ready, background refresh uses the same two-column status/message layout as
431
+ other runtime logs. Status messages remove terminal controls and collapse newlines;
432
+ the static banner and multiline interactive prompts retain their own presentation.
433
+ VS Code compatibility-version details remain available in debug logging. Startup
434
+ does not wait for optional update/compression work or add online doctor/model probes.
370
435
 
371
436
  ### Live models
372
437
 
@@ -528,6 +593,14 @@ Installer errors and nonzero exits fail the update without a success message or
528
593
  automatic retry. Missing Git, blocked dependency downloads or npm cache-only
529
594
  settings remain npm/environment errors, not fixed by changing the launcher.
530
595
 
596
+ After a zero installer exit, CCDX reads bounded metadata from npm's selected global
597
+ target and verifies the package name and stable version. GitHub requires the exact
598
+ selected release version. A missing/mismatched target fails verification without
599
+ retrying installation; if the global target could not be discovered, the command
600
+ explicitly reports that the installed version is unverified rather than announcing
601
+ an update. This check neither changes PATH/prefix/registry nor restarts a running
602
+ adapter, and it does not verify package-file integrity or npm's current latest tag.
603
+
531
604
  Normal startup checks the official GitHub `releases/latest` web endpoint once in
532
605
  the background, without accessing the npm registry or REST API. The anonymous
533
606
  check requires no PAT or Copilot credentials, has a two-second deadline, validates
@@ -651,6 +724,12 @@ curl -s http://127.0.0.1:2026/_ccdx/status | jq
651
724
 
652
725
  The status endpoint is restricted to the socket's real loopback address even when LAN binding is explicitly enabled. It reports fixed-size HTTP request counters separately from bounded `completed` / `incomplete` / `failed` / `cancelled` response outcomes by model and origin, plus bounded incomplete-reason counts, TTFT/TPOT histograms, admission pressure, memory use, response-history size/tree concentration/lookup misses, image queue/cache and adaptive-history state, model-cache counts, token expiry state, and the ten most recent upstream `response.failed` diagnostics retained by the running process. HTTP errors without a model terminal remain "without terminal" and retain their known origin; they are not counted as model failures. History eviction markers are not failed-request counts; `ccdx status` warns near the cache limit without deleting or compressing history. Failure diagnostics include the event type, model, error code/message, response/request IDs when supplied upstream, and retry outcome. Common credential forms, long opaque encrypted values, and explicitly labelled input/prompt/tool-content echoes are redacted. They are cleared when the adapter restarts. No request/response bodies, credential fields, or account profiles are copied into status. Arbitrary upstream prose cannot be guaranteed free of sensitive content; review diagnostics before sharing them.
653
726
 
727
+ `stream_performance.by_route.*.empty_stream_completions` counts completed streams
728
+ with no observed output and an explicit zero output-token count. The recent request's
729
+ `empty_stream_completion` flag records the same condition. Missing usage is not zero;
730
+ non-streaming replies and observed tool/refusal output are excluded. This diagnostic
731
+ does not change completion status, trigger a retry or reject legitimate empty replies.
732
+
654
733
  `image_mcp` has its own HTTP route counter. After the image handler has been used, `image_generation` separately reports active, succeeded, failed, busy, cancelled, and chat-file delivery-failure counts, including tool errors returned with HTTP 200. A delivery failure can accompany a successful generation; it never causes another generation. Before handler initialization this field is `null`, meaning not observed, not necessarily disabled. Status never initializes that handler, reads its provider credential, installs guidance, or probes the provider. Input-image optimization metrics remain separate. `logging` reports pending records/bytes, queue caps, overflow drops, and write failures for usage and enabled debug-file logging.
655
734
 
656
735
  `stream_performance.by_route` also reports `request_ttft_ms`, measured from adapter entry to the first observed output delta, including local preparation. The existing `ttft_ms` continues to start at upstream dispatch. Neither timestamp means the client has drained or displayed the output. `preparation_ms` contains bounded histograms for admission (including history reservations), body reading/decompression/JSON parsing, history materialization/compact preparation, image optimization, and request serialization. Each sample measures one operation, including failed operations; retries can add samples. These are diagnostic intervals rather than a complete breakdown of request time: body reading includes internal decoded-body admission waits; authentication, routing, and other preparation are not individually timed. Non-streaming requests contribute preparation samples without inventing a first-token measurement.
@@ -699,6 +778,7 @@ Recovery first tries compatible local credentials and starts Device Flow only wh
699
778
 
700
779
  - CCDX binds to loopback by default. Non-loopback hosts are rejected unless `CCDX_ALLOW_LAN=1` is set explicitly.
701
780
  - Enabling LAN binding exposes a Copilot-backed API to other reachable machines. Provide your own host firewall and network isolation; do not expose the listener to an untrusted network.
781
+ - Inference POSTs reject any browser `Origin` header before reading the body or contacting upstream, including simple `text/plain` requests. Native Codex/Node requests without Origin and deliberately enabled native LAN clients keep their existing access. This is not authentication or protection against untrusted local native programs.
702
782
  - The GitHub OAuth credential is stored locally at `~/.local/share/copilot-api/github_token`. Short-lived Copilot service tokens remain in process memory and are refreshed as needed.
703
783
  - The optional image API credential is stored separately with mode `0600` only after `ccdx enable-image`; it is never placed in Codex configuration or diagnostic output.
704
784
  - Runtime status and usage records retain metadata rather than request/response content. Diagnostic logging records status and error messages; it is not a general redaction layer for arbitrary error text. See Debug logging before sharing logs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "0.9.33",
3
+ "version": "0.9.35",
4
4
  "description": "Use Codex App with GitHub Copilot",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
package/src/adapter.mjs CHANGED
@@ -204,6 +204,13 @@ export function createAdapterHandler(options = {}) {
204
204
  upstreamTimeoutMs,
205
205
  });
206
206
  const dispatch = async (req, res, pathname) => {
207
+ if (req.method === "POST" && ["/v1/responses", "/v1/responses/compact"].includes(pathname)
208
+ && Object.hasOwn(req.headers || {}, "origin")) {
209
+ const error = httpError("Browser origins are not allowed for inference", 403);
210
+ error.jsonBody = { error: { message: error.message, type: "invalid_request_error", code: "ccdx_browser_origin_forbidden" } };
211
+ sendJsonError(res, error, 403);
212
+ return;
213
+ }
207
214
  if (DASHBOARD_API_PATHS.has(pathname)) {
208
215
  const { handleDashboardApi } = await import("./dashboard-api.mjs");
209
216
  return handleDashboardApi(req, res, pathname, options.dashboardOptions);
@@ -499,7 +506,7 @@ export function startAdapter(port = 2026, host = "127.0.0.1", options = {}) {
499
506
  server.listen(port, host, () => {
500
507
  server.off("error", onListenError);
501
508
  const actualPort = server.address()?.port || port;
502
- console.log(status("ok", `Adapter listening on http://${host}:${actualPort}`));
509
+ (options.log || console.log)(status("ok", `Adapter listening on http://${host}:${actualPort}`));
503
510
  resolve(server);
504
511
  });
505
512
  });
@@ -192,6 +192,7 @@ export function formatAdapterStatus({ baseUrl, data }, { commandName = "ccdx", c
192
192
  const prediction = data.client_integrations?.prediction;
193
193
  if (prediction) {
194
194
  lines.push(status("info", `Native predictions: ${prediction.configured ? "on" : "off"}; bridge ${prediction.bridge}; client route ${prediction.client_route}; visible candidate unknown`));
195
+ if (prediction.launch_route) lines.push(status("info", `Prediction self-check: App route ${prediction.launch_route}; persistent route ${prediction.persistence || "unknown"}; ${count(prediction.recovery?.recovered)} bridge recoveries, ${count(prediction.recovery?.attempts)}/3 attempts used`));
195
196
  if (prediction.reason) lines.push(status("warn", terminalCell(prediction.reason).slice(0, 400)));
196
197
  }
197
198
  if (data.profiles?.codex) {
@@ -3,10 +3,11 @@ import { readImageProviderConfig } from "./image-provider-config.mjs";
3
3
  import { ensureCodexThreadCompression } from "./codex-thread-compression.mjs";
4
4
  import { runInBackground } from "./startup.mjs";
5
5
  import { createPredictionState } from "./native-prediction-state.mjs";
6
+ import { supervisePrediction } from "./native-prediction-recovery.mjs";
6
7
 
7
8
  // The CLI composes the services; this module owns optional client integration
8
9
  // lifecycle. It never forwards model requests or depends on dashboard rendering.
9
- export function createClientIntegration({ port, host, info = () => {}, warning = () => {} } = {}) {
10
+ export function createClientIntegration({ port, host, info = () => {}, warning = () => {}, configLog } = {}) {
10
11
  const prediction = createPredictionState();
11
12
  let native = null;
12
13
  return {
@@ -18,23 +19,29 @@ export function createClientIntegration({ port, host, info = () => {}, warning =
18
19
  if (result.preserved) warning("Modified prediction settings were preserved");
19
20
  } catch (error) { warning(`${error.message}. Core startup will continue.`); }
20
21
  const enabled = Boolean(readImageProviderConfig());
21
- const { imageMcpSkipped } = ensureCodexConfig(port, { host, imageProviderEnabled: enabled });
22
+ const { imageMcpSkipped } = ensureCodexConfig(port, { host, imageProviderEnabled: enabled, ...(configLog ? { log: configLog } : {}) });
22
23
  if (enabled && !imageMcpSkipped) {
23
24
  try {
24
25
  const { syncEnabledImageSkill } = await import("./cli-image.mjs");
25
26
  syncEnabledImageSkill({ adapterPort: port, adapterHost: host });
26
27
  } catch (error) { warning(`Image guidance could not be updated: ${error.message}`); }
27
28
  }
28
- return { compressionSetup: runInBackground(ensureCodexThreadCompression) };
29
+ return { imageEnabled: enabled, imageMcpSkipped, compressionSetup: runInBackground(ensureCodexThreadCompression) };
29
30
  },
30
31
  async start() {
31
32
  try {
32
33
  const { startNativePrediction } = await import("./native-prediction.mjs");
33
34
  native = await startNativePrediction({ state: prediction, warning: info });
35
+ if (native) {
36
+ const expectedPort = Number(new URL(native.pacUrl).port);
37
+ native = supervisePrediction({ native, state: prediction, warning,
38
+ restart: () => startNativePrediction({ state: prediction, warning: info, expectedPort }) });
39
+ }
34
40
  } catch (error) { prediction.unavailable(error); warning(`${error.message}. Core startup will continue.`); }
35
41
  return native;
36
42
  },
37
43
  pacUrl() { return native?.pacUrl || null; },
44
+ launched(route) { prediction.launch(route); },
38
45
  snapshot() { return { prediction: prediction.snapshot() }; },
39
46
  async close() { await native?.close(); native = null; },
40
47
  };
package/src/config.mjs CHANGED
@@ -286,6 +286,7 @@ function ensureCodexConfigUnlocked(adapterPort = 2026, {
286
286
  filePath,
287
287
  host = "127.0.0.1",
288
288
  imageProviderEnabled = false,
289
+ log = console.log,
289
290
  } = {}) {
290
291
  const baseUrl = `${adapterBaseUrl(host, adapterPort)}/v1`;
291
292
 
@@ -304,10 +305,10 @@ function ensureCodexConfigUnlocked(adapterPort = 2026, {
304
305
  ? { content: initialCodexConfig(adapterPort, host), changed: true }
305
306
  : computeUpdatedCodexConfig(content, adapterPort, host);
306
307
  if (!core.changed) {
307
- console.log(status("ok", `Codex already points to ${baseUrl}`));
308
+ log(status("ok", `Codex already points to ${baseUrl}`));
308
309
  } else {
309
310
  atomicWriteFileIfChangedSync(filePath, core.content);
310
- console.log(status("ok", content === undefined ? `Created Codex configuration: ${filePath}` : `Configured Codex base URL: ${baseUrl}`));
311
+ log(status("ok", content === undefined ? `Created Codex configuration: ${filePath}` : `Configured Codex base URL: ${baseUrl}`));
311
312
  }
312
313
  // Disabled means no image maintenance, including no implicit removal of old
313
314
  // or user-owned entries. Explicit disable-image owns the cleanup operation.
package/src/copilot.mjs CHANGED
@@ -251,7 +251,7 @@ export async function refreshVSCodeVersion() {
251
251
  clearTimeout(timer);
252
252
  if (resp.ok) {
253
253
  cachedVersion = parseVSCodeVersion(await resp.json());
254
- console.log(status("info", `VS Code version: ${cachedVersion}`));
254
+ debugLog(`VS Code version: ${cachedVersion}`);
255
255
  }
256
256
  } catch {
257
257
  // Keep the fallback quietly.
@@ -23,7 +23,7 @@
23
23
 
24
24
  <main>
25
25
  <section class="intro">
26
- <h1><span aria-hidden="true">$</span> ccdx status</h1>
26
+ <h1><svg class="status-icon" viewBox="0 0 64 64" aria-hidden="true" focusable="false"><g fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round"><ellipse cx="32" cy="32" rx="26" ry="10"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(60 32 32)"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(120 32 32)"/></g><circle cx="32" cy="32" r="4.5" fill="currentColor"/></svg> ccdx status</h1>
27
27
  <div class="snapshot-meta"><p id="auth-account" role="status" data-i18n data-i18n-title title="Saved GitHub Copilot account / local credentials only; not an online entitlement check.">GitHub / READING</p><p id="updated" data-i18n>Reading status…</p></div>
28
28
  </section>
29
29
 
@@ -10,6 +10,7 @@
10
10
  "Enabled": ["Enabled", "已开启"],
11
11
  "Disabled": ["Disabled", "已关闭"],
12
12
  "Running": ["Running", "运行中"],
13
+ "Recovering": ["Recovering", "恢复中"],
13
14
  "Stopped": ["Stopped", "未运行"],
14
15
  "Unavailable": ["Unavailable", "不可用"],
15
16
  "Observed": ["Observed", "已收到配置请求"],
@@ -149,7 +149,7 @@
149
149
  if (element("prediction-preference")) {
150
150
  const prediction = data.client_integrations?.prediction;
151
151
  text("prediction-preference", prediction ? prediction.configured ? "Enabled" : "Disabled" : "Unknown");
152
- text("prediction-bridge", ({ running: "Running", stopped: "Stopped", unavailable: "Unavailable" })[prediction?.bridge] || "Unknown");
152
+ text("prediction-bridge", ({ running: "Running", recovering: "Recovering", stopped: "Stopped", unavailable: "Unavailable" })[prediction?.bridge] || "Unknown");
153
153
  text("prediction-route", prediction?.client_route === "observed" ? "Observed" : "Unknown");
154
154
  text("prediction-candidate", "Unknown");
155
155
  const note = element("prediction-note");
@@ -24,7 +24,7 @@ button:disabled { opacity: .55; cursor: wait; }
24
24
  :root[data-theme="light"] .icon-moon { display: block; }
25
25
  .intro { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; padding: 38px 0 25px; }
26
26
  h1 { margin: 0; font-size: clamp(20px, 3vw, 27px); font-weight: 650; letter-spacing: -.035em; }
27
- h1 span { color: var(--accent-soft); }
27
+ .status-icon { display: inline-block; width: 1em; height: 1em; vertical-align: -.125em; color: var(--accent); }
28
28
  .intro p { margin: 0; color: var(--subtle); font-size: 11px; }
29
29
  .snapshot-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: baseline; gap: 8px 18px; min-width: 0; }
30
30
  .intro .snapshot-meta p { margin: 0; overflow-wrap: anywhere; }