codex-copilot-dx 0.9.24 → 0.9.26

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.
Files changed (40) hide show
  1. package/README.md +15 -12
  2. package/bin/cli.mjs +24 -32
  3. package/docs/ARCHITECTURE.md +69 -0
  4. package/docs/README.md +6 -0
  5. package/docs/REFERENCE.md +112 -10
  6. package/package.json +3 -2
  7. package/src/adapter.mjs +1 -0
  8. package/src/cli-image.mjs +13 -10
  9. package/src/cli-options.mjs +1 -1
  10. package/src/cli-status.mjs +5 -0
  11. package/src/client-integration.mjs +41 -0
  12. package/src/codex-config-doctor.mjs +3 -3
  13. package/src/codex-paths.mjs +10 -0
  14. package/src/codex-thread-compression.mjs +11 -6
  15. package/src/config.mjs +10 -6
  16. package/src/copilot-responses-compat.mjs +30 -2
  17. package/src/copilot-responses-policy.mjs +14 -3
  18. package/src/dashboard/index.html +18 -9
  19. package/src/dashboard/language.js +14 -0
  20. package/src/dashboard/ui.css +2 -0
  21. package/src/dashboard/ui.js +10 -0
  22. package/src/launcher.mjs +50 -2
  23. package/src/lock.mjs +29 -0
  24. package/src/native-prediction-profile.mjs +46 -23
  25. package/src/native-prediction-state.mjs +29 -0
  26. package/src/native-prediction-transport.mjs +24 -9
  27. package/src/native-prediction-windows.mjs +174 -0
  28. package/src/native-prediction.mjs +102 -28
  29. package/src/network-route.mjs +102 -0
  30. package/src/observability.mjs +2 -0
  31. package/src/operation-error.mjs +37 -0
  32. package/src/package-update.mjs +2 -3
  33. package/src/prediction-retirement.mjs +13 -2
  34. package/src/proxy-tunnel.mjs +102 -0
  35. package/src/responses-proxy.mjs +13 -3
  36. package/src/responses-request.mjs +35 -2
  37. package/src/user-settings.mjs +17 -4
  38. package/src/version.mjs +23 -46
  39. package/src/windows-prediction-network.cs +154 -0
  40. package/src/windows-prediction-network.mjs +123 -0
package/README.md CHANGED
@@ -4,12 +4,11 @@ Use Codex App with GitHub Copilot through a local adapter.
4
4
 
5
5
  CCDX targets Codex App. It discovers Copilot models, adapts the client's model
6
6
  catalog, and preserves Responses streaming, tool calls and conversation history.
7
- Default Auto-review: **GPT-6.1 Sol / low**. Image generation is **off by default**.
8
- Native predictions are also **off by default**.
7
+ Default Auto-review: **GPT-6.1 Sol / low**. Image generation is **off by default**. Native predictions are also **off by default**.
9
8
 
10
9
  ## Install and run
11
10
 
12
- Requires macOS, Codex App, Node.js **22.15+**, and a GitHub account with Copilot
11
+ Requires macOS or Windows, Codex App, Node.js **22.15+**, and a GitHub account with Copilot
13
12
  access to the models you want to use.
14
13
 
15
14
  ```bash
@@ -19,7 +18,8 @@ ccdx
19
18
 
20
19
  CCDX reuses a compatible local credential or starts GitHub Device Flow, listens
21
20
  on `127.0.0.1:2026`, configures Codex, and opens the App. No client binary patch
22
- is needed. The configured `dummy` API key is a placeholder, not a credential.
21
+ is needed. On Windows, open the App manually unless native prediction setup is
22
+ enabled. The configured `dummy` API key is a placeholder, not a credential.
23
23
 
24
24
  Open [the local dashboard](http://127.0.0.1:2026/) for status, model discovery,
25
25
  usage, cache/limits, recent failures, request context and animation settings.
@@ -30,7 +30,7 @@ The dashboard does not poll in the background; refresh when needed.
30
30
  | Command | Purpose |
31
31
  | --- | --- |
32
32
  | `ccdx help` | Command help; use `ccdx help <command>` for details |
33
- | `ccdx start` | Start without launching the App |
33
+ | `ccdx start` | Start or reuse the adapter and open Codex when auto-launch is enabled |
34
34
  | `ccdx status` | Runtime, limits and bounded request diagnostics |
35
35
  | `ccdx doctor` | Configuration, adapter and read-only App/catalog diagnostics |
36
36
  | `ccdx doctor config` | Read-only configuration check |
@@ -45,7 +45,7 @@ The dashboard does not poll in the background; refresh when needed.
45
45
  | `ccdx limits --decoded 256` | Set the decoded request-body budget; restart to apply |
46
46
  | `ccdx enable-image` | Opt in to image generation/editing with your own API |
47
47
  | `ccdx image-status` / `ccdx disable-image` | Check or disable optional images |
48
- | `ccdx prediction on` / `off` / `status` | Opt in to native next-message predictions (macOS) |
48
+ | `ccdx prediction on` / `off` / `status` | Opt in to native predictions (macOS and Windows) |
49
49
  | `ccdx update` | Update the global package |
50
50
 
51
51
  ## Compatibility and safety
@@ -53,7 +53,7 @@ The dashboard does not poll in the background; refresh when needed.
53
53
  - Standard/Fast follow the exact variants advertised by Copilot; CCDX does not
54
54
  invent Fast availability. Auto-review is separate from the foreground model.
55
55
  - Model discovery does not prove inference access. If a new model is absent in
56
- Codex, run `ccdx doctor`; fully quit the App with **Command-Q** before reopening.
56
+ Codex, run `ccdx doctor`; fully quit the App (**Command-Q** on macOS) before reopening.
57
57
  CCDX does not claim it can verify the App's internal model cache externally.
58
58
  - After a package upgrade, restart the running CCDX adapter. Choosing a model or
59
59
  effort on a current adapter takes effect on its next Auto-review request.
@@ -73,8 +73,8 @@ The dashboard does not poll in the background; refresh when needed.
73
73
  trust and an App-only route for `chatgpt.com` and `ab.chatgpt.com`; HTTPS on those
74
74
  hosts is decrypted locally, but only prediction configuration is changed.
75
75
  Other domains and the CCDX model endpoint stay on their existing routes.
76
- No program files or OS trust are changed. Existing proxies are not replaced.
77
- See the reference for restart, rollback and client-version boundaries.
76
+ No program files or OS trust are changed. Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are retained.
77
+ Windows supports company PAC/WPAD routing; macOS dynamic routing remains unsupported. Windows setup needs the official MSIX App and OpenSSL. See the reference for compatibility limits.
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.
@@ -84,11 +84,14 @@ The dashboard does not poll in the background; refresh when needed.
84
84
  expose it to the public internet. The dashboard is not an authentication wall
85
85
  for the API. Diagnostic errors may contain sensitive upstream text.
86
86
 
87
- Startup checks GitHub Releases, not npm, and suggests `ccdx update github` when a newer stable version is available. GitHub updates install the exact release tag; dependency downloads still use npm's configured registry.
87
+ Startup checks GitHub's latest-release web redirect, not npm or the anonymous REST quota, and suggests `ccdx update github`.
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
+
90
+ The dashboard and CLI separate prediction preference, bridge state and observed config traffic; candidate visibility stays unknown.
91
+ Inference, client integration, optional images and management have separate ownership. See [architecture boundaries](docs/ARCHITECTURE.md).
88
92
 
89
93
  See the [complete command/configuration reference](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/REFERENCE.md)
90
- for authentication recovery, configuration-write boundaries, advanced limits,
91
- logging, image setup and client compatibility details.
94
+ for authentication recovery, configuration safety, limits, logging, images and client compatibility.
92
95
  The same reference is included as `docs/REFERENCE.md` in the installed npm package.
93
96
 
94
97
  ## Development
package/bin/cli.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { ensureAuth, openCodex } from "../src/launcher.mjs";
4
- import { ensureCodexConfig } from "../src/config.mjs";
5
4
  import { startAdapter } from "../src/adapter.mjs";
6
5
  import { defaultCopilotClient, refreshVSCodeVersion } from "../src/copilot.mjs";
7
6
  import { status } from "../src/status.mjs";
@@ -22,9 +21,7 @@ import { runAuthCommand } from "../src/cli-auth.mjs";
22
21
  import { createProfileRuntime } from "../src/profile-runtime.mjs";
23
22
  import { createProfileModelRuntime } from "../src/profile-model-runtime.mjs";
24
23
  import { createCodexModelCatalog } from "../src/codex-model-catalog.mjs";
25
- import { readImageProviderConfig } from "../src/image-provider-config.mjs";
26
24
  import { setResponseHistoryMaxBytes } from "../src/response-history.mjs";
27
- import { ensureCodexThreadCompression } from "../src/codex-thread-compression.mjs";
28
25
 
29
26
  const LOCAL_VERSION = localPackageVersion();
30
27
  const CLI_NAME = cliCommandName();
@@ -91,7 +88,10 @@ if (CLI.command === "suggestion") {
91
88
  if (CLI.command === "prediction") {
92
89
  try {
93
90
  const { runPredictionCommand } = await import("../src/native-prediction.mjs");
94
- await runPredictionCommand({ action: CLI.action });
91
+ await runPredictionCommand({ action: CLI.action, runtimeSnapshot: () => {
92
+ const probe = parseAdapterProbeOptions(process.env);
93
+ return readAdapterStatus({ host: probe.adapterHost, port: probe.adapterPort, timeoutMs: probe.existingAdapterTimeoutMs }).then(({ data }) => data);
94
+ } });
95
95
  process.exit(0);
96
96
  } catch (error) {
97
97
  console.error(status("err", error.message));
@@ -265,6 +265,16 @@ let activeServer = null;
265
265
  let modelRefreshTimer = null;
266
266
  let shuttingDown = false;
267
267
  let nativePrediction = null;
268
+ let clientIntegration = null;
269
+
270
+ async function clientIntegrations() {
271
+ if (!clientIntegration) {
272
+ const { createClientIntegration } = await import("../src/client-integration.mjs");
273
+ clientIntegration = createClientIntegration({ port: ADAPTER_PORT, host: ADAPTER_HOST,
274
+ info: (message) => console.log(status("info", message)), warning: (message) => console.warn(status("warn", message)) });
275
+ }
276
+ return clientIntegration;
277
+ }
268
278
 
269
279
  if (LOGGING.filePath) {
270
280
  console.log(status("info", `Debug log: ${LOGGING.filePath}`));
@@ -288,16 +298,18 @@ async function reuseRunningAdapterIfAvailable() {
288
298
 
289
299
  let predictionPacUrl = null;
290
300
  let predictionApp = null;
301
+ let predictionProfile = null;
291
302
  try {
292
303
  const { readPredictionSettings } = await import("../src/native-prediction-profile.mjs");
293
304
  const preference = readPredictionSettings();
294
305
  if (preference.enabled) {
295
306
  predictionPacUrl = running.data?.native_prediction_pac || null;
296
307
  predictionApp = preference.app?.app;
308
+ predictionProfile = preference.app?.profile;
297
309
  if (!predictionPacUrl) console.warn(status("warn", "Restart ccdx to activate the newly enabled prediction bridge"));
298
310
  }
299
311
  } catch (error) { console.warn(status("warn", error.message)); }
300
- await openCodex({ predictionPacUrl, predictionApp });
312
+ await openCodex({ predictionPacUrl, predictionApp, predictionProfile });
301
313
  console.log(`
302
314
  ${status("ok", "Ready, using the existing ccdx adapter")}
303
315
 
@@ -310,25 +322,7 @@ async function reuseRunningAdapterIfAvailable() {
310
322
  }
311
323
 
312
324
  async function configureCodexClient() {
313
- try {
314
- const { retirePredictionIntegration } = await import("../src/prediction-retirement.mjs");
315
- const result = retirePredictionIntegration();
316
- if (result.changed) console.log(status("info", "Removed the retired CCDX prediction integration"));
317
- if (result.preserved) console.warn(status("warn", "Modified prediction settings were preserved"));
318
- } catch (error) {
319
- console.warn(status("warn", `${error.message}. Core startup will continue.`));
320
- }
321
- const imageProviderEnabled = Boolean(readImageProviderConfig());
322
- const { imageMcpSkipped } = ensureCodexConfig(ADAPTER_PORT, { host: ADAPTER_HOST, imageProviderEnabled });
323
- if (imageProviderEnabled && !imageMcpSkipped) {
324
- try {
325
- const { syncEnabledImageSkill } = await import("../src/cli-image.mjs");
326
- syncEnabledImageSkill({ adapterPort: ADAPTER_PORT, adapterHost: ADAPTER_HOST });
327
- } catch (error) {
328
- console.warn(status("warn", `Image guidance could not be updated: ${error.message}`));
329
- }
330
- }
331
- return { compressionSetup: runInBackground(ensureCodexThreadCompression) };
325
+ return (await clientIntegrations()).configure();
332
326
  }
333
327
 
334
328
  if (CLI.command === "doctor") {
@@ -403,19 +397,17 @@ try {
403
397
  streamIdleTimeoutMs: RUNTIME.streamIdleTimeoutMs,
404
398
  terminalAnimationTheme,
405
399
  nativePredictionPac: () => nativePrediction?.pacUrl || null,
400
+ clientIntegrationSnapshot: () => clientIntegration?.snapshot() || null,
406
401
  });
407
402
 
408
403
  // Point Codex App at the adapter.
409
404
  const { compressionSetup } = await configureCodexClient();
410
405
 
411
406
  // Optional native prediction setup must never prevent the core adapter from running.
412
- try {
413
- const { startNativePrediction } = await import("../src/native-prediction.mjs");
414
- nativePrediction = await startNativePrediction({ warning: (message) => console.log(status("info", message)) });
415
- } catch (error) { console.warn(status("warn", `${error.message}. Core startup will continue.`)); }
407
+ nativePrediction = await (await clientIntegrations()).start();
416
408
 
417
409
  // Launch Codex when available. A running App is never forcibly restarted.
418
- await openCodex({ predictionPacUrl: nativePrediction?.pacUrl, predictionApp: nativePrediction?.app });
410
+ await openCodex({ predictionPacUrl: nativePrediction?.pacUrl, predictionApp: nativePrediction?.app, predictionProfile: nativePrediction?.profile });
419
411
 
420
412
  // Periodically refresh the model list + endpoint cache so a long-running
421
413
  // adapter picks up newly released models without a restart.
@@ -428,7 +420,7 @@ try {
428
420
  }
429
421
 
430
422
  console.log(`
431
- ${status("ok", "Ready, Codex App is ready to use")}
423
+ ${status("ok", "Ready, CCDX adapter is ready to use")}
432
424
 
433
425
  Adapter: ${adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT)}
434
426
 
@@ -444,7 +436,7 @@ try {
444
436
  let exitCode = 0;
445
437
  try {
446
438
  if (modelRefreshTimer) clearInterval(modelRefreshTimer);
447
- await nativePrediction?.close();
439
+ await clientIntegration?.close();
448
440
  const result = await closeHttpServer(activeServer, { timeoutMs: RUNTIME.shutdownTimeoutMs });
449
441
  if (result.forced) console.warn(status("warn", "Forced remaining adapter connections closed"));
450
442
  await flushUsageWrites();
@@ -461,7 +453,7 @@ try {
461
453
  await compressionSetup;
462
454
  } catch (e) {
463
455
  console.error(status("err", e.message));
464
- await nativePrediction?.close().catch(() => {});
456
+ await clientIntegration?.close().catch(() => {});
465
457
  await closeHttpServer(activeServer, { timeoutMs: RUNTIME.shutdownTimeoutMs }).catch(() => {});
466
458
  await flushUsageWrites();
467
459
  await LOGGING.cleanup();
@@ -0,0 +1,69 @@
1
+ # Architecture boundaries
2
+
3
+ CCDX is one local Node service for Codex App. Client integration, image tools and
4
+ the dashboard are optional parts of that service, not a general plugin framework.
5
+
6
+ | Responsibility | Ownership | Boundary |
7
+ | --- | --- | --- |
8
+ | Core inference | `adapter.mjs`, Responses modules, model catalog, history | Copilot requests, streaming and recovery |
9
+ | Client integration | `client-integration.mjs`, Codex config, native prediction | Client setup, optional start/stop, diagnostic snapshots |
10
+ | Optional images | Image provider, CLI setup, image MCP and skill | Opt-in API access and image delivery; failures do not block core startup |
11
+ | Management | CLI, dashboard, observability, package updates | Bounded metadata and explicit user actions |
12
+ | Shared foundations | Codex paths, file locks, atomic files, network routes | No dependency on inference or dashboard rendering |
13
+
14
+ ## Composition and lifecycle
15
+
16
+ The CLI composes the service. Client integration owns its `configure`, `start`,
17
+ `snapshot` and `close` operations. It does not forward inference requests or
18
+ render the dashboard. The adapter exposes integration snapshots and keeps
19
+ management/MCP routes separate from the Responses path.
20
+
21
+ Native prediction has a separate loopback transport and an isolated HTTPS agent.
22
+ Only its two selected hosts use the App-specific route. Non-configuration requests
23
+ on those hosts are forwarded unchanged. The bridge does not replace Copilot or
24
+ image-provider networking, modify client program files, or install system trust.
25
+ Static upstream proxy routes and bypass rules are preserved. macOS dynamic
26
+ PAC/WPAD and static CIDR bypass rules are reported as unsupported, not discarded.
27
+ The Windows adapter isolates registration, process, proxy, OpenSSL and NTFS
28
+ interfaces in `native-prediction-windows.mjs`. The bridge, overlay, model selection
29
+ and lifecycle remain shared. Windows discovery requires verified registration
30
+ and an existing unambiguous profile; no generalized OS framework is introduced.
31
+ Windows automatic-proxy support has one isolated native WinHTTP worker
32
+ (`windows-prediction-network.mjs` / `.cs`) for company routing, authentication and
33
+ TLS trust. Its private, credit-based pipes stream data without transcript files.
34
+ The App PAC delegates unrelated URLs to the company script; Node never executes
35
+ that script. This worker is not a shared inference/image network backend and is
36
+ not started for disabled predictions or static/direct configurations.
37
+ Windows bridge-port ownership and App launch-route checks also stay in this
38
+ optional boundary. Core inference keeps its existing service port and lifecycle.
39
+
40
+ Connection-ownership replay rejection is a provider-owned retry policy. It
41
+ removes only unavailable reasoning once, preserving visible history and tools.
42
+ Opaque compaction cannot be assumed equivalent to remaining plaintext: rejection
43
+ returns `ccdx_history_rebuild_required`, without modifying stored history. The
44
+ client must restore full plaintext history; CCDX cannot reconstruct unavailable
45
+ encrypted memory from its diagnostic metadata.
46
+
47
+ ## Configuration ownership
48
+
49
+ `CODEX_HOME` selects Codex configuration. App profile/trust paths have their own
50
+ selection and are not inferred from that directory. CCDX writers use a shared
51
+ per-file lock, reread current contents and preserve unrelated values. Locks do
52
+ not coordinate editors or other applications that ignore them. Read-only status
53
+ and doctor commands do not write configuration.
54
+
55
+ Legacy public module exports remain available. This change adds a concrete
56
+ composition boundary; it does not relocate every file or add speculative APIs.
57
+
58
+ ## Evidence and verification
59
+
60
+ Prediction preference, bridge readiness and observed configuration responses are
61
+ different states. None proves that a candidate appeared in the App. The dashboard
62
+ keeps that result unknown. Integration diagnostics retain bounded, redacted
63
+ metadata, not conversation or image contents.
64
+
65
+ Tests cover module dependency direction, default-off behavior, concurrent writers,
66
+ proxy handshakes, TLS validation, streaming, history isolation and release lookup.
67
+ Performance measurements distinguish request preparation from model latency.
68
+ Release reports describe a specific environment, not an SLA or a guarantee of
69
+ compatibility with every future client or corporate network policy.
package/docs/README.md CHANGED
@@ -4,6 +4,8 @@ The [root README](../README.md) is the quick start; the [command/configuration
4
4
  reference](REFERENCE.md) preserves complete current behavior and limits. `ccdx --help` and
5
5
  `ccdx <command> --help` describe the installed package's CLI. Code and tests
6
6
  resolve any discrepancy; CLI version and running-adapter version can differ.
7
+ The [architecture boundaries](ARCHITECTURE.md) explain module ownership,
8
+ optional integration lifecycle and configuration safety.
7
9
 
8
10
  `ccdx doctor config` performs local, read-only configuration diagnostics and
9
11
  previews the current startup writer. It does not claim to resolve the complete
@@ -15,6 +17,10 @@ These reports record a specific release and test environment. Their version,
15
17
  test counts, timings, live-provider observations, and limitations remain
16
18
  historical facts rather than current guarantees.
17
19
 
20
+ - [0.9.26: Windows native predictions, safe ownership recovery and dashboard disclosures](RELEASE_0.9.26.md)
21
+ - [Windows prediction validation history](WINDOWS_PREDICTION_PREVIEW.md)
22
+ - [0.9.25: static proxy compatibility, integration boundaries and release diagnostics](RELEASE_0.9.25.md)
23
+
18
24
  - [0.9.19: GitHub startup checks and stable-release updates](RELEASE_0.9.19.md)
19
25
  - [0.9.21: compatibility-gated local history compression](RELEASE_0.9.21.md)
20
26
  - [0.9.20: timing evidence, real-client checks and bounded analytics reuse](RELEASE_0.9.20.md)
package/docs/REFERENCE.md CHANGED
@@ -26,11 +26,63 @@ the old Hook exits with an empty result, and the old MCP exposes no tools or pan
26
26
  ### Optional native predictions
27
27
 
28
28
  Native next-message predictions are **off by default** and use no MCP, Hook, skill,
29
- panel, renderer injection, or client-program modification. This macOS-only
30
- compatibility feature uses the App's existing composer UI and the conversation's
29
+ panel, renderer injection, or client-program modification. This compatibility
30
+ feature uses the App's existing composer UI and the conversation's
31
31
  selected model through CCDX. Suggestions are not sent automatically. Native
32
32
  eligibility rules still apply; availability is not promised for every thread type.
33
33
 
34
+ Version `0.9.26` adds Windows platform adapters. Native gray suggestions,
35
+ adoption/sending and switching predictions off were verified on Windows with the
36
+ `.4` candidate. Windows setup
37
+ requires a current-user, Store-signed `OpenAI.Codex` MSIX registration (Store and
38
+ official offline MSIX use the same registration), an initialized Codex profile and
39
+ OpenSSL. Git for Windows includes OpenSSL; CCDX does not download another runtime.
40
+ Run CCDX using Windows-native Node, not inside WSL. The App's agent may still use
41
+ WSL independently. No administrator prompt or execution-policy change is added.
42
+ AppData may be virtualized by MSIX: setup selects an existing `Codex/Local State`
43
+ profile (also `ChatGPT/Local State` for `ChatGPT.exe`) under roaming AppData or the
44
+ package's `LocalCache/Roaming` directory. The nested `Codex/web/Codex/Local State`
45
+ layout is also recognized; trust belongs to that nested profile's `Default`
46
+ directory, not to its parent `Codex` directory. Setup does not recursively scan
47
+ App data. A previously verified profile binding is reused on reactivation;
48
+ turning predictions off removes only CCDX trust, not that directory binding.
49
+ Absent or initially ambiguous profiles are not guessed; open the App once or set the exact
50
+ `CODEX_ELECTRON_USER_DATA_PATH`. Existing App profile trust uses the same bounded
51
+ Chromium database schema. Private-key privacy is verified with NTFS ACLs, not
52
+ Unix mode bits. No Windows root/personal certificate store is changed.
53
+
54
+ Windows reads the current user's WinINET proxy configuration through WinHTTP's
55
+ query API without changing it. Static proxies/bypass rules compose with the same
56
+ environment precedence. Automatic routing uses a separate, persistent Windows
57
+ WinHTTP worker and a temporary PAC that delegates unrelated URLs to the original
58
+ company script. The script is syntax-checked but never executed in Node. Windows
59
+ handles upstream routing, proxy failover, authentication and certificate trust;
60
+ the bridge never weakens TLS checks or the OS credential policy. Requests and
61
+ responses stream through bounded private pipes; cookies are not cached by the
62
+ worker, and redirects are not followed. Only the selected HTTPS hosts use the
63
+ bridge; WebSocket PAC URLs keep the original company decision. If native WPAD
64
+ discovery reports no PAC, configured static/direct settings are retained. A
65
+ configured PAC that cannot be downloaded is not replaced with direct access.
66
+ Explicit proxy environment rules combined with automatic routing are currently
67
+ preserved and reported as a conflict, not silently merged. The
68
+ launcher pins both Chromium `--user-data-dir` and the process-only
69
+ `CODEX_ELECTRON_USER_DATA_PATH` to that verified existing profile and passes the
70
+ local PAC to the exact registered executable. This prevents a direct MSIX launch
71
+ from using another profile without the trust record. An explicit conflicting
72
+ profile override is preserved and the optional launch is skipped. There is no
73
+ shell, account replacement, new profile, `CODEX_HOME` change or forced App exit. Disabled predictions
74
+ add no Windows probe or launch. `CCDX_AUTO_LAUNCH=0` is still respected.
75
+
76
+ Windows remembers its own loopback bridge port after successful activation and
77
+ reuses it across service restarts. A busy saved port is not stolen or silently
78
+ replaced. Before launch, CCDX checks only registered App main-process route
79
+ metadata. A running App with an old/unreadable PAC receives an explicit quit and
80
+ relaunch instruction; it is not killed or reported as newly connected. The first
81
+ upgrade from an ephemeral-port candidate may require one full App quit. Successful
82
+ process creation is not proof of configuration traffic. A bounded post-launch
83
+ main-process check verifies retained PAC arguments; adapter readiness is reported
84
+ separately from App route readiness.
85
+
34
86
  ```bash
35
87
  # Fully quit Codex App first.
36
88
  ccdx prediction on
@@ -53,8 +105,30 @@ account identity or account-permission value is rewritten. Credentials are not
53
105
  logged or persisted by the bridge. The local private key has owner-only permissions;
54
106
  its signing key is discarded after certificate creation.
55
107
 
56
- Existing App proxy/PAC/environment routes cause setup to skip with an explanation.
57
- This initial version does not compose enterprise proxies. The default App profile
108
+ Static proxy settings are composed with the local bridge. For HTTPS targets,
109
+ `https_proxy` takes precedence over `HTTPS_PROXY`, then `all_proxy`/`ALL_PROXY`,
110
+ then the macOS HTTPS proxy or SOCKS proxy. HTTP targets follow their corresponding
111
+ HTTP setting. An HTTP-only environment proxy is not used for HTTPS. HTTP CONNECT,
112
+ TLS to an HTTPS proxy, SOCKS5 (including username/password), `NO_PROXY`/`no_proxy`,
113
+ system exceptions and simple-host exclusions are supported. Proxy credentials
114
+ remain in memory, are never included in PAC responses or diagnostics, and are
115
+ sent only to the proxy. TLS verification remains enabled for both proxy and target.
116
+ Other App domains keep the resolved original route; if a bridge fails, its PAC
117
+ fallback uses that route rather than adding an unrequested direct connection.
118
+ Route selection is a startup snapshot; restart CCDX and Codex after changing it.
119
+ Bypass lists support host/domain patterns and optional ports. Unsupported CIDR
120
+ notation is reported explicitly rather than silently changing the route.
121
+
122
+ macOS dynamic PAC/WPAD remains unsupported and is not overwritten. Windows
123
+ automatic routing is opt-in and requires the native worker; a failed worker
124
+ closes its optional bridge while core inference continues. Restart CCDX and Codex
125
+ after changing networks or company PAC settings; this is not a live network-policy
126
+ watcher. Native composer behavior was verified on one Windows machine. Its
127
+ observed upstream route was direct; arbitrary company PAC, integrated-authentication
128
+ and client-certificate policies are not claimed as live-tested. A non-default `CODEX_API_BASE_URL` is
129
+ also preserved and reported as a custom-route conflict; setting it to the normal
130
+ `https://chatgpt.com/backend-api` does not cause a conflict. No automatic direct
131
+ fallback after upstream-proxy rejection is added. The default App profile
58
132
  is `~/Library/Application Support/Codex`; an explicit
59
133
  `CODEX_ELECTRON_USER_DATA_PATH` is respected. Quit the App before trust changes;
60
134
  CCDX never kills it. The launcher uses the exact App that passed the compatibility
@@ -79,14 +153,35 @@ trust removal is deferred; quit it and run `prediction off` again. Only the exac
79
153
  owned certificate record is removed, never the whole store. Failed activation
80
154
  rolls back newly added trust; certificate replacement keeps old trust until the
81
155
  new preference is committed. If the bridge stops, new connections can fall back
82
- to direct routing; already-interrupted requests are not replayed. Run `ccdx`
156
+ to the original route; already-interrupted requests are not replayed. Run `ccdx`
83
157
  after quitting Codex to attach a newly started bridge. `CCDX_AUTO_LAUNCH=0` keeps
84
158
  automatic launch disabled and does not attach the route to a manually opened App.
85
159
  Optional prediction failures never prevent the core adapter or image service from
86
- starting. `prediction status` reports the saved preference, not proof of live UI
87
- availability. Prediction settings are stored separately in
160
+ starting. `prediction status` reports the saved preference and, when a compatible
161
+ running adapter responds, its bridge state, configuration-response observations
162
+ and bounded TLS/upstream errors. The dashboard uses the same snapshot and manual
163
+ refresh. Configuration traffic is evidence of a request reaching the bridge, not
164
+ proof of a generated/displayed candidate. Candidate visibility remains unknown;
165
+ no prompt matching, UI injection, transcript scanning or extra inference is used
166
+ to invent that status. Prediction settings are stored separately in
88
167
  `~/.config/codex-copilot-dx/native-prediction/` (or under `XDG_CONFIG_HOME`).
89
168
 
169
+ ### Configuration ownership
170
+
171
+ Core setup, image setup/guidance, config doctor, optional history compression and
172
+ legacy prediction cleanup resolve the same `CODEX_HOME/config.toml`; absent
173
+ `CODEX_HOME`, they use `~/.codex/config.toml`. An explicit function-level file path
174
+ still takes precedence for embedders. App-profile trust is a separate location
175
+ selected by `CODEX_ELECTRON_USER_DATA_PATH`, not by `CODEX_HOME`.
176
+
177
+ CCDX-owned config mutations share an owner-recorded cross-process lock, reread
178
+ under the lock, and retain existing atomic replacement/rollback checks. User
179
+ settings updates use a separate lock for their shared JSON file; prediction
180
+ on/off uses its own settings lock. Readers take no lock and write no lock file.
181
+ Contention fails with a retry message instead of stealing a live lock. Other
182
+ applications do not participate in these locks, so snapshot conflict checks still
183
+ apply; the locks do not claim a global filesystem transaction.
184
+
90
185
  ### Core adapter
91
186
 
92
187
  One in-process adapter listens on `127.0.0.1:2026` by default and exposes:
@@ -141,7 +236,7 @@ On a normal launch, CCDX:
141
236
  1. Prints the installed package version and checks for a newer npm release in the background.
142
237
  2. Reuses a compatible running adapter when available; otherwise it reuses a compatible local Copilot credential or starts GitHub Device Flow when authentication is required.
143
238
  3. Loads a usable model cache or attempts a live refresh, then starts listening. A cache older than two hours refreshes in the background; a fresh cache can be used immediately. A failed refresh retains the last-known-good list when one is available.
144
- 4. Checks the startup-managed settings in `~/.codex/config.toml`, including the local `/v1` endpoint.
239
+ 4. Checks the startup-managed settings in `CODEX_HOME/config.toml` (default `~/.codex/config.toml`), including the local `/v1` endpoint.
145
240
  5. Attempts to open Codex App on macOS unless `CCDX_AUTO_LAUNCH` disables it.
146
241
 
147
242
  The `OPENAI_API_KEY=dummy` value used in the Codex shell environment is only a client-side placeholder. It is not a GitHub credential. CCDX exchanges the saved GitHub OAuth credential for short-lived Copilot service tokens internally.
@@ -156,7 +251,7 @@ If a compatible adapter is already running, a later launch reuses it and checks
156
251
 
157
252
  ### Codex configuration writes
158
253
 
159
- Normal startup and reuse of an existing adapter check `~/.codex/config.toml` once, after startup prerequisites succeed. There is no file watcher or periodic configuration rewrite. The path is based on the OS home directory; CCDX does not redirect it through `CODEX_HOME` or edit project-level Codex files.
254
+ Normal startup and reuse of an existing adapter check `CODEX_HOME/config.toml` (default `~/.codex/config.toml`) once, after startup prerequisites succeed. There is no file watcher or periodic configuration rewrite. Startup, image setup, config doctor, compression and legacy prediction cleanup share this path. CCDX does not edit project-level Codex files.
160
255
 
161
256
  | Setting | Existing file | New file |
162
257
  | --- | --- | --- |
@@ -318,7 +413,14 @@ ccdx update npm
318
413
  ccdx update github
319
414
  ```
320
415
 
321
- Normal startup checks the latest stable GitHub Release once in the background, without accessing the npm registry. The anonymous check requires no PAT or Copilot credentials, has a two-second deadline and a bounded response body, and silently skips network errors, rate limits and invalid metadata. It never falls back to npm, retries, polls, installs an update or restarts the service. When a newer release is found, it prints the versions and `ccdx update github`. On adapter reuse, Ready is displayed before waiting for any remaining check budget so the short-lived command does not lose its notification.
416
+ Normal startup checks the official GitHub `releases/latest` web endpoint once in
417
+ the background, without accessing the npm registry or REST API. The anonymous
418
+ check requires no PAT or Copilot credentials, has a two-second deadline, validates
419
+ only the redirect header, cancels the response body without reading HTML, and
420
+ silently skips errors. Redirects must use HTTPS, the exact GitHub repository and
421
+ a stable version tag with no credentials, query or fragment. It never follows
422
+ the redirect, retries, polls, installs or restarts. On adapter reuse, Ready is
423
+ displayed before waiting for any remaining check budget.
322
424
 
323
425
  `ccdx update gh` is accepted as shorthand for the GitHub source. The npm source installs `codex-copilot-dx@latest` through the registry already configured for npm, including a company mirror. The GitHub source queries the latest stable published Release (ten-second deadline), validates its version tag, and installs that exact tag from `DaleXiao/codex-copilot-dx`, not `main`. Lookup failure stops before installation, without an npm fallback. It opts in to Git fetching only for that command and does not change npm's persistent `allow-git` setting.
324
426
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "0.9.24",
3
+ "version": "0.9.26",
4
4
  "description": "Use Codex App with GitHub Copilot",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
@@ -15,7 +15,8 @@
15
15
  "scripts/benchmark-probes.mjs",
16
16
  "scripts/fixtures/",
17
17
  "README.md",
18
- "docs/REFERENCE.md"
18
+ "docs/REFERENCE.md",
19
+ "docs/ARCHITECTURE.md"
19
20
  ],
20
21
  "keywords": [
21
22
  "codex",
package/src/adapter.mjs CHANGED
@@ -236,6 +236,7 @@ export function createAdapterHandler(options = {}) {
236
236
  codexClient,
237
237
  codexModelRegistry,
238
238
  codexModelCatalog,
239
+ clientIntegrations: options.clientIntegrationSnapshot?.(),
239
240
  })));
240
241
  return;
241
242
  }
package/src/cli-image.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import fs from "node:fs";
2
2
  import os from "node:os";
3
- import path from "node:path";
4
3
  import readline from "node:readline";
5
4
  import { createInterface } from "node:readline/promises";
5
+ import { codexPaths } from "./codex-paths.mjs";
6
+ import { withFileLockSync } from "./lock.mjs";
6
7
  import { atomicWriteFileIfChangedSync, atomicWriteFilePairSync } from "./atomic-file.mjs";
7
8
  import { terminalCell } from "./cli-table.mjs";
8
9
  import { computeImageMcpCodexConfig } from "./config.mjs";
@@ -15,11 +16,6 @@ import {
15
16
  readImageProviderConfig,
16
17
  validateImageProviderConfig,
17
18
  } from "./image-provider-config.mjs";
18
-
19
- function defaultCodexConfigPath(home) {
20
- return path.join(home, ".codex", "config.toml");
21
- }
22
-
23
19
  async function visibleQuestion(input, output, question) {
24
20
  const prompt = createInterface({ input, output });
25
21
  try { return await prompt.question(question); }
@@ -102,7 +98,10 @@ function configSummary(config) {
102
98
  };
103
99
  }
104
100
 
105
- function enableImageProvider({ providerConfig, providerPath, codexPath, codexContent, adapterPort, adapterHost }) {
101
+ function enableImageProvider(options) {
102
+ return withFileLockSync(`${options.codexPath}.ccdx.lock`, () => enableImageProviderUnlocked(options));
103
+ }
104
+ function enableImageProviderUnlocked({ providerConfig, providerPath, codexPath, codexContent, adapterPort, adapterHost }) {
106
105
  const codex = computeImageMcpCodexConfig(codexContent, {
107
106
  enabled: true,
108
107
  adapterPort,
@@ -128,7 +127,11 @@ function enableImageProvider({ providerConfig, providerPath, codexPath, codexCon
128
127
  return { codexChanged: codex.changed, config: normalized };
129
128
  }
130
129
 
131
- function disableImageProvider({ providerPath, codexPath, codexContent, adapterPort, adapterHost }) {
130
+ function disableImageProvider(options) {
131
+ if (!fs.existsSync(options.codexPath)) return disableImageProviderUnlocked(options);
132
+ return withFileLockSync(`${options.codexPath}.ccdx.lock`, () => disableImageProviderUnlocked(options));
133
+ }
134
+ function disableImageProviderUnlocked({ providerPath, codexPath, codexContent, adapterPort, adapterHost }) {
132
135
  const codex = computeImageMcpCodexConfig(codexContent, {
133
136
  enabled: false,
134
137
  adapterPort,
@@ -154,7 +157,7 @@ function disableImageProvider({ providerPath, codexPath, codexContent, adapterPo
154
157
  return { changed: providerExists || codex.changed || skill.changed, preservedGuidance: Boolean(skill.preserved) };
155
158
  }
156
159
 
157
- export function syncEnabledImageSkill({ home = os.homedir(), codexPath = defaultCodexConfigPath(home), ...options } = {}) {
160
+ export function syncEnabledImageSkill({ home = os.homedir(), env = process.env, codexPath = codexPaths({ env, home }).config, ...options } = {}) {
158
161
  return updateImageSkill({ ...options, enabled: true, codexPath });
159
162
  }
160
163
 
@@ -179,7 +182,7 @@ export async function runImageCommand({
179
182
  probeFetchImpl = fetch,
180
183
  adapterPort = 2026,
181
184
  adapterHost = "127.0.0.1",
182
- codexPath = defaultCodexConfigPath(home),
185
+ codexPath = codexPaths({ env, home }).config,
183
186
  } = {}) {
184
187
  const providerPath = imageProviderConfigPath({ env, home });
185
188
  if (action === "status") {
@@ -372,7 +372,7 @@ function topicHelp(name, topic) {
372
372
  "image-status": `Usage:\n ${name} image-status\n\nShows provider configuration and locally advertised generation/editing tools without generating an image or exposing its API key.`,
373
373
  "auto-review-model": `Usage:\n ${name} auto-review-model\n\nSelect a Responses model, then an advertised reasoning effort. Enter keeps the default/current choice; q cancels both steps without saving. Effort 0 follows the client (low when omitted). Settings apply only to Auto-review on the next request; no client patch or restart is required for adapters running 0.9.13 or newer.`,
374
374
  "suggestion": `The CCDX prediction panel has been retired. Run ${name} suggestion off to safely remove unchanged CCDX registrations. This cleanup does not change native predictions; see ${name} prediction --help for that separate opt-in feature.`,
375
- prediction: `Usage:\n ${name} prediction [status|on|off]\n\nOptional native next-message predictions; off by default. macOS only. Quit Codex before on/off, then restart ccdx. On adds private App-profile certificate trust and an App-only route for chatgpt.com and ab.chatgpt.com. HTTPS on those hosts is decrypted locally; only prediction configuration is changed. No client program files, OS trust, account permissions, MCP or Hooks are changed. Existing proxies are not replaced. Official prediction configuration is preserved; the conversation's model is used. App updates require another compatibility check.`,
375
+ prediction: `Usage:\n ${name} prediction [status|on|off]\n\nOptional native next-message predictions; off by default. macOS and Windows (candidate). Windows requires the registered official MSIX App, an initialized profile and OpenSSL (included with Git for Windows); real composer verification is pending. Quit Codex before on/off, then restart ccdx. On adds private App-profile certificate trust and an App-only route for chatgpt.com and ab.chatgpt.com. HTTPS on those hosts is decrypted locally; only prediction configuration is changed. No client program files, OS trust, account permissions, MCP or Hooks are changed. Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are preserved; dynamic PAC/WPAD and CIDR bypass rules are reported as unsupported. Official prediction configuration is preserved; the conversation's model is used. App updates require another compatibility check. Status distinguishes saved preference and observed config traffic from unverified candidate visibility.`,
376
376
  update: `Usage:\n ${name} update [npm|github]\n\nUpdates the global package from the configured npm registry or the latest stable GitHub release. With no source, an interactive terminal prompts for one.`,
377
377
  version: `Usage:\n ${name} --version`,
378
378
  };
@@ -188,6 +188,11 @@ export function formatAdapterStatus({ baseUrl, data }, { commandName = "ccdx", c
188
188
  }
189
189
  }
190
190
  lines.push(status("info", `Models: ${count(models.models)} total; Copilot token ${copilot.token_cached ? `cached (${duration(copilot.token_expires_in_ms)} remaining)` : "not cached"}`));
191
+ const prediction = data.client_integrations?.prediction;
192
+ if (prediction) {
193
+ lines.push(status("info", `Native predictions: ${prediction.configured ? "on" : "off"}; bridge ${prediction.bridge}; client route ${prediction.client_route}; visible candidate unknown`));
194
+ if (prediction.reason) lines.push(status("warn", terminalCell(prediction.reason).slice(0, 400)));
195
+ }
191
196
  if (data.profiles?.codex) {
192
197
  lines.push(status("info", `Profile: ${profileSummary("Codex", data.profiles.codex)}`));
193
198
  }