codex-copilot-dx 0.9.25 → 0.9.27

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
@@ -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.
@@ -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.
@@ -74,7 +74,7 @@ The dashboard does not poll in the background; refresh when needed.
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
76
  No program files or OS trust are changed. Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are retained.
77
- Dynamic PAC/WPAD routes are reported as unsupported; see the reference for routing, rollback and client-version limits.
77
+ 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.
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.
package/bin/cli.mjs CHANGED
@@ -298,16 +298,18 @@ async function reuseRunningAdapterIfAvailable() {
298
298
 
299
299
  let predictionPacUrl = null;
300
300
  let predictionApp = null;
301
+ let predictionProfile = null;
301
302
  try {
302
303
  const { readPredictionSettings } = await import("../src/native-prediction-profile.mjs");
303
304
  const preference = readPredictionSettings();
304
305
  if (preference.enabled) {
305
306
  predictionPacUrl = running.data?.native_prediction_pac || null;
306
307
  predictionApp = preference.app?.app;
308
+ predictionProfile = preference.app?.profile;
307
309
  if (!predictionPacUrl) console.warn(status("warn", "Restart ccdx to activate the newly enabled prediction bridge"));
308
310
  }
309
311
  } catch (error) { console.warn(status("warn", error.message)); }
310
- await openCodex({ predictionPacUrl, predictionApp });
312
+ await openCodex({ predictionPacUrl, predictionApp, predictionProfile });
311
313
  console.log(`
312
314
  ${status("ok", "Ready, using the existing ccdx adapter")}
313
315
 
@@ -405,7 +407,7 @@ try {
405
407
  nativePrediction = await (await clientIntegrations()).start();
406
408
 
407
409
  // Launch Codex when available. A running App is never forcibly restarted.
408
- await openCodex({ predictionPacUrl: nativePrediction?.pacUrl, predictionApp: nativePrediction?.app });
410
+ await openCodex({ predictionPacUrl: nativePrediction?.pacUrl, predictionApp: nativePrediction?.app, predictionProfile: nativePrediction?.profile });
409
411
 
410
412
  // Periodically refresh the model list + endpoint cache so a long-running
411
413
  // adapter picks up newly released models without a restart.
@@ -418,7 +420,7 @@ try {
418
420
  }
419
421
 
420
422
  console.log(`
421
- ${status("ok", "Ready, Codex App is ready to use")}
423
+ ${status("ok", "Ready, CCDX adapter is ready to use")}
422
424
 
423
425
  Adapter: ${adapterBaseUrl(ADAPTER_HOST, ADAPTER_PORT)}
424
426
 
@@ -22,8 +22,35 @@ Native prediction has a separate loopback transport and an isolated HTTPS agent.
22
22
  Only its two selected hosts use the App-specific route. Non-configuration requests
23
23
  on those hosts are forwarded unchanged. The bridge does not replace Copilot or
24
24
  image-provider networking, modify client program files, or install system trust.
25
- Static upstream proxy routes and bypass rules are preserved. Dynamic PAC/WPAD
26
- and CIDR bypass rules are reported as unsupported, not silently discarded.
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 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 certificate issuance is a separate one-shot helper
32
+ (`windows-prediction-certificate.mjs` / `.cs`), not part of the network worker.
33
+ Node generates RSA keys and sends them through stdin to the system .NET
34
+ `CertificateRequest` API; only public certificates return through stdout.
35
+ The existing PEM reader, App-profile trust schema and transactional activation
36
+ remain shared. Issuance requires neither external OpenSSL nor a Windows
37
+ certificate store. Valid existing credentials skip issuance; default-off startup
38
+ does not invoke it. macOS keeps the existing system OpenSSL implementation.
39
+ Windows automatic-proxy support has one isolated native WinHTTP worker
40
+ (`windows-prediction-network.mjs` / `.cs`) for company routing, authentication and
41
+ TLS trust. Its private, credit-based pipes stream data without transcript files.
42
+ The App PAC delegates unrelated URLs to the company script; Node never executes
43
+ that script. This worker is not a shared inference/image network backend and is
44
+ not started for disabled predictions or static/direct configurations.
45
+ Windows bridge-port ownership and App launch-route checks also stay in this
46
+ optional boundary. Core inference keeps its existing service port and lifecycle.
47
+
48
+ Connection-ownership replay rejection is a provider-owned retry policy. It
49
+ removes only unavailable reasoning once, preserving visible history and tools.
50
+ Opaque compaction cannot be assumed equivalent to remaining plaintext: rejection
51
+ returns `ccdx_history_rebuild_required`, without modifying stored history. The
52
+ client must restore full plaintext history; CCDX cannot reconstruct unavailable
53
+ encrypted memory from its diagnostic metadata.
27
54
 
28
55
  ## Configuration ownership
29
56
 
@@ -33,7 +60,7 @@ per-file lock, reread current contents and preserve unrelated values. Locks do
33
60
  not coordinate editors or other applications that ignore them. Read-only status
34
61
  and doctor commands do not write configuration.
35
62
 
36
- Legacy public module exports remain available. This change adds a concrete
63
+ Core inference interfaces remain unchanged. This change adds a concrete
37
64
  composition boundary; it does not relocate every file or add speculative APIs.
38
65
 
39
66
  ## Evidence and verification
package/docs/README.md CHANGED
@@ -17,6 +17,9 @@ These reports record a specific release and test environment. Their version,
17
17
  test counts, timings, live-provider observations, and limitations remain
18
18
  historical facts rather than current guarantees.
19
19
 
20
+ - [0.9.27: Windows certificate setup without Git/OpenSSL](RELEASE_0.9.27.md)
21
+ - [0.9.26: Windows native predictions, safe ownership recovery and dashboard disclosures](RELEASE_0.9.26.md)
22
+ - [Windows prediction validation history](WINDOWS_PREDICTION_PREVIEW.md)
20
23
  - [0.9.25: static proxy compatibility, integration boundaries and release diagnostics](RELEASE_0.9.25.md)
21
24
 
22
25
  - [0.9.19: GitHub startup checks and stable-release updates](RELEASE_0.9.19.md)
package/docs/REFERENCE.md CHANGED
@@ -26,11 +26,72 @@ 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,
39
+ Windows PowerShell and .NET Framework 4.7.2 or later. Since `0.9.27`, prediction
40
+ setup and renewal do not require Git or OpenSSL. Node generates ephemeral RSA
41
+ keys; the Windows .NET certificate API signs the same scoped CA/leaf certificate
42
+ pair. Private keys travel only through a child-process stdin pipe; only the leaf
43
+ key and public certificates are saved in CCDX's private directory. No Windows
44
+ certificate store is opened. Existing valid PEM credentials are reused without
45
+ conversion or reauthorization. macOS retains its system OpenSSL setup path.
46
+ CCDX does not download a runtime or bypass company PowerShell policy; unavailable
47
+ system APIs fail the optional setup without preventing core service startup.
48
+ This does not remove Git from the separate `ccdx update github` installation path.
49
+ Run CCDX using Windows-native Node, not inside WSL. The App's agent may still use
50
+ WSL independently. No administrator prompt or execution-policy change is added.
51
+ AppData may be virtualized by MSIX: setup selects an existing `Codex/Local State`
52
+ profile (also `ChatGPT/Local State` for `ChatGPT.exe`) under roaming AppData or the
53
+ package's `LocalCache/Roaming` directory. The nested `Codex/web/Codex/Local State`
54
+ layout is also recognized; trust belongs to that nested profile's `Default`
55
+ directory, not to its parent `Codex` directory. Setup does not recursively scan
56
+ App data. A previously verified profile binding is reused on reactivation;
57
+ turning predictions off removes only CCDX trust, not that directory binding.
58
+ Absent or initially ambiguous profiles are not guessed; open the App once or set the exact
59
+ `CODEX_ELECTRON_USER_DATA_PATH`. Existing App profile trust uses the same bounded
60
+ Chromium database schema. Private-key privacy is verified with NTFS ACLs, not
61
+ Unix mode bits. No Windows root/personal certificate store is changed.
62
+
63
+ Windows reads the current user's WinINET proxy configuration through WinHTTP's
64
+ query API without changing it. Static proxies/bypass rules compose with the same
65
+ environment precedence. Automatic routing uses a separate, persistent Windows
66
+ WinHTTP worker and a temporary PAC that delegates unrelated URLs to the original
67
+ company script. The script is syntax-checked but never executed in Node. Windows
68
+ handles upstream routing, proxy failover, authentication and certificate trust;
69
+ the bridge never weakens TLS checks or the OS credential policy. Requests and
70
+ responses stream through bounded private pipes; cookies are not cached by the
71
+ worker, and redirects are not followed. Only the selected HTTPS hosts use the
72
+ bridge; WebSocket PAC URLs keep the original company decision. If native WPAD
73
+ discovery reports no PAC, configured static/direct settings are retained. A
74
+ configured PAC that cannot be downloaded is not replaced with direct access.
75
+ Explicit proxy environment rules combined with automatic routing are currently
76
+ preserved and reported as a conflict, not silently merged. The
77
+ launcher pins both Chromium `--user-data-dir` and the process-only
78
+ `CODEX_ELECTRON_USER_DATA_PATH` to that verified existing profile and passes the
79
+ local PAC to the exact registered executable. This prevents a direct MSIX launch
80
+ from using another profile without the trust record. An explicit conflicting
81
+ profile override is preserved and the optional launch is skipped. There is no
82
+ shell, account replacement, new profile, `CODEX_HOME` change or forced App exit. Disabled predictions
83
+ add no Windows probe or launch. `CCDX_AUTO_LAUNCH=0` is still respected.
84
+
85
+ Windows remembers its own loopback bridge port after successful activation and
86
+ reuses it across service restarts. A busy saved port is not stolen or silently
87
+ replaced. Before launch, CCDX checks only registered App main-process route
88
+ metadata. A running App with an old/unreadable PAC receives an explicit quit and
89
+ relaunch instruction; it is not killed or reported as newly connected. The first
90
+ upgrade from an ephemeral-port candidate may require one full App quit. Successful
91
+ process creation is not proof of configuration traffic. A bounded post-launch
92
+ main-process check verifies retained PAC arguments; adapter readiness is reported
93
+ separately from App route readiness.
94
+
34
95
  ```bash
35
96
  # Fully quit Codex App first.
36
97
  ccdx prediction on
@@ -67,8 +128,13 @@ Route selection is a startup snapshot; restart CCDX and Codex after changing it.
67
128
  Bypass lists support host/domain patterns and optional ports. Unsupported CIDR
68
129
  notation is reported explicitly rather than silently changing the route.
69
130
 
70
- Dynamic PAC/WPAD is not executed or overwritten. Setup identifies the exact
71
- system setting and preserves its rules. A non-default `CODEX_API_BASE_URL` is
131
+ macOS dynamic PAC/WPAD remains unsupported and is not overwritten. Windows
132
+ automatic routing is opt-in and requires the native worker; a failed worker
133
+ closes its optional bridge while core inference continues. Restart CCDX and Codex
134
+ after changing networks or company PAC settings; this is not a live network-policy
135
+ watcher. Native composer behavior was verified on one Windows machine. Its
136
+ observed upstream route was direct; arbitrary company PAC, integrated-authentication
137
+ and client-certificate policies are not claimed as live-tested. A non-default `CODEX_API_BASE_URL` is
72
138
  also preserved and reported as a custom-route conflict; setting it to the normal
73
139
  `https://chatgpt.com/backend-api` does not cause a conflict. No automatic direct
74
140
  fallback after upstream-proxy rejection is added. The default App profile
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "0.9.25",
3
+ "version": "0.9.27",
4
4
  "description": "Use Codex App with GitHub Copilot",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
@@ -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. 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.`,
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
  };
@@ -1,6 +1,7 @@
1
1
  import { responses as copilotResponses } from "./copilot.mjs";
2
2
  import {
3
3
  isEncryptedContentVerificationError,
4
+ isConnectionOwnedInputError,
4
5
  isImageNamespaceCollisionError,
5
6
  sanitizeImageNamespaceCollisionRequest,
6
7
  } from "./copilot-responses-policy.mjs";
@@ -12,7 +13,9 @@ import { httpError } from "./http-errors.mjs";
12
13
  import {
13
14
  finalizeEncryptedHistoryRebase,
14
15
  sanitizeEncryptedReasoningRequest,
16
+ sanitizeConnectionOwnedReasoningRequest,
15
17
  } from "./responses-request.mjs";
18
+ import { responseFailureDetails } from "./response-failures.mjs";
16
19
  import { status } from "./status.mjs";
17
20
  import { markUpstreamHeaders } from "./stream-performance.mjs";
18
21
 
@@ -20,6 +23,12 @@ import { markUpstreamHeaders } from "./stream-performance.mjs";
20
23
  // by an exact upstream failure plus a request transformation that changes the
21
24
  // payload. Generic Responses preparation does not decide whether to retry.
22
25
  const RETRY_POLICIES = Object.freeze([
26
+ Object.freeze({
27
+ id: "encrypted-connection-rejected",
28
+ matches: isConnectionOwnedInputError,
29
+ apply: sanitizeConnectionOwnedReasoningRequest,
30
+ warning: "saved reasoning belongs to an unavailable connection; retrying once with visible history preserved",
31
+ }),
23
32
  Object.freeze({
24
33
  id: "image-namespace-collision",
25
34
  matches: isImageNamespaceCollisionError,
@@ -28,7 +37,7 @@ const RETRY_POLICIES = Object.freeze([
28
37
  }),
29
38
  Object.freeze({
30
39
  id: "encrypted-replay-rejected",
31
- matches: isEncryptedContentVerificationError,
40
+ matches: (statusCode, text) => !isConnectionOwnedInputError(statusCode, text) && isEncryptedContentVerificationError(statusCode, text),
32
41
  apply: sanitizeEncryptedReasoningRequest,
33
42
  warning: "encrypted replay content rejected by upstream; retrying without unavailable encrypted content",
34
43
  }),
@@ -54,6 +63,10 @@ export function selectCopilotResponseRetry(
54
63
  policyId: policy.id,
55
64
  warning: policy.warning,
56
65
  usedPolicies,
66
+ ...(policy.id === "encrypted-connection-rejected" ? { recovery: {
67
+ reasoning_items_removed: reqContext.body.input.length - candidate.body.input.length,
68
+ compaction_items_removed: 0,
69
+ } } : {}),
57
70
  };
58
71
  }
59
72
  return null;
@@ -84,7 +97,22 @@ export async function openCopilotResponse(reqContext, upstream = copilotResponse
84
97
  label: "Copilot Responses error body",
85
98
  });
86
99
  options.assertPrepareActive?.();
87
- const retry = selectCopilotResponseRetry(reqContext, resp.status, errorText, usedPolicies);
100
+ let retry;
101
+ try { retry = selectCopilotResponseRetry(reqContext, resp.status, errorText, usedPolicies); }
102
+ catch (error) {
103
+ if (error.code === "ccdx_history_rebuild_required") {
104
+ const details = responseFailureDetails({ error: error.jsonBody.error }, "upstream.http_error", {
105
+ model: reqContext.body.model, headers: resp.headers, retrySkipped: error.code });
106
+ error.jsonBody.error.upstream_request_id = details.upstream_request_id;
107
+ options.responseFailures?.record?.({ ...details, recovery: error.jsonBody.error.recovery });
108
+ }
109
+ throw error;
110
+ }
111
+ if (retry?.policyId === "encrypted-connection-rejected") {
112
+ options.responseFailures?.record?.({ ...responseFailureDetails(JSON.parse(errorText), "upstream.http_error", {
113
+ model: reqContext.body.model, headers: resp.headers, retried: true, retryPolicy: retry.policyId }),
114
+ recovery: retry.recovery });
115
+ }
88
116
  if (retry) {
89
117
  reqContext = retry.reqContext;
90
118
  console.warn(status("warn", retry.warning));
@@ -4,6 +4,15 @@ function cloneJson(value) {
4
4
  return value === undefined ? undefined : structuredClone(value);
5
5
  }
6
6
 
7
+ export function isConnectionOwnedInputError(statusCode, text) {
8
+ if (statusCode !== 400 || !text) return false;
9
+ try {
10
+ const error = JSON.parse(text)?.error;
11
+ return typeof error?.message === "string"
12
+ && error.message.trim().toLowerCase() === "input item does not belong to this connection";
13
+ } catch { return false; }
14
+ }
15
+
7
16
  export function isEncryptedContentVerificationError(statusCode, text) {
8
17
  if (statusCode < 400 || !text) return false;
9
18
  const lower = errorEvidenceText(text).toLowerCase();
@@ -14,7 +23,7 @@ export function isEncryptedContentVerificationError(statusCode, text) {
14
23
  && lower.includes("could not be decrypted or decoded");
15
24
  const missingEncryptedContent = statusCode < 500
16
25
  && /missing required parameter:\s*(['"]?)input\[\d+\](?:\.[a-z0-9_]+|\[\d+\])*\.encrypted_content\1(?=\.?(?:\s|$|["},\]]))/.test(lower);
17
- return reasoningFailure || functionOutputFailure || missingEncryptedContent;
26
+ return reasoningFailure || functionOutputFailure || missingEncryptedContent || isConnectionOwnedInputError(statusCode, text);
18
27
  }
19
28
 
20
29
  export function isImageNamespaceCollisionError(statusCode, text) {
@@ -50,6 +50,13 @@
50
50
  </article>
51
51
  </section>
52
52
 
53
+ <details class="panel dashboard-section" id="client-features" open>
54
+ <summary class="panel-heading"><h2 data-i18n>CLIENT FEATURES</h2><span data-i18n>OBSERVED STATE</span></summary>
55
+ <dl class="stats"><div><dt data-i18n>Native predictions</dt><dd id="prediction-preference">—</dd></div><div><dt data-i18n>Local bridge</dt><dd id="prediction-bridge">—</dd></div><div><dt data-i18n>Client route</dt><dd id="prediction-route">—</dd></div><div><dt data-i18n>Visible candidate</dt><dd id="prediction-candidate">—</dd></div></dl>
56
+ <p id="prediction-note" class="hint">—</p>
57
+ <p class="hint" data-i18n>Configured does not mean displayed. Use ccdx prediction status for details.</p>
58
+ </details>
59
+
53
60
  <details class="panel dashboard-section" id="request-context">
54
61
  <summary data-i18n>RECENT REQUEST CONTEXT</summary>
55
62
  <p id="context-note" class="table-note">—</p>
@@ -57,22 +64,17 @@
57
64
  <p class="hint" data-i18n>Recent upstream request metadata, not exact live session occupancy. Missing values are unknown. No prompt or image content is retained.</p>
58
65
  </details>
59
66
 
60
- <section class="panel dashboard-section" aria-label="CLIENT FEATURES" data-i18n-label>
61
- <div class="panel-heading"><h2 data-i18n>CLIENT FEATURES</h2><span data-i18n>OBSERVED STATE</span></div>
62
- <dl class="stats"><div><dt data-i18n>Native predictions</dt><dd id="prediction-preference">—</dd></div><div><dt data-i18n>Local bridge</dt><dd id="prediction-bridge">—</dd></div><div><dt data-i18n>Client route</dt><dd id="prediction-route">—</dd></div><div><dt data-i18n>Visible candidate</dt><dd id="prediction-candidate">—</dd></div></dl>
63
- <p id="prediction-note" class="hint">—</p>
64
- <p class="hint" data-i18n>Configured does not mean displayed. Use ccdx prediction status for details.</p>
65
- </section>
66
-
67
- <section class="panel dashboard-section" aria-label="Live upstream models" data-i18n-label>
68
- <div class="panel-heading"><h2 data-i18n>UPSTREAM GPT MODELS</h2><div class="heading-actions"><span id="models-state" data-i18n>CHECKING LIVE</span><button id="refresh-models" type="button" data-i18n>Refresh</button></div></div>
67
+ <details class="panel dashboard-section" id="upstream-models" open>
68
+ <summary class="panel-heading"><h2 data-i18n>UPSTREAM GPT MODELS</h2><span id="models-state" data-i18n>CHECKING LIVE</span></summary>
69
+ <div class="section-actions"><button id="refresh-models" type="button" data-i18n>Refresh</button></div>
69
70
  <p id="models-note" class="table-note" data-i18n>Querying GitHub Copilot…</p>
70
71
  <div class="table-wrap"><table><thead><tr><th scope="col" data-i18n>MODEL</th><th scope="col" data-i18n>VENDOR</th><th scope="col" data-i18n>API</th><th scope="col" data-i18n>FLAG</th></tr></thead><tbody id="live-models-body"><tr><td colspan="4" data-i18n>Loading…</td></tr></tbody></table></div>
71
72
  <p class="hint" data-i18n>Catalog listing does not guarantee inference access.</p>
72
- </section>
73
+ </details>
73
74
 
74
- <section class="panel dashboard-section" aria-label="Usage by model" data-i18n-label>
75
- <div class="panel-heading"><h2 data-i18n>USAGE</h2><div class="heading-actions"><span id="usage-state" data-i18n>READING LOG</span><button id="clear-usage-day" type="button" hidden data-i18n>All history</button><button id="refresh-usage" type="button" data-i18n>Refresh</button></div></div>
75
+ <details class="panel dashboard-section" id="model-usage" open>
76
+ <summary class="panel-heading"><h2 data-i18n>USAGE</h2><span id="usage-state" data-i18n>READING LOG</span></summary>
77
+ <div class="section-actions"><button id="clear-usage-day" type="button" hidden data-i18n>All history</button><button id="refresh-usage" type="button" data-i18n>Refresh</button></div>
76
78
  <p id="usage-note" class="table-note" data-i18n>Aggregating local usage metadata…</p>
77
79
  <div class="table-wrap"><table class="usage-table"><thead><tr><th scope="col" data-i18n>MODEL</th><th scope="col" data-i18n>CALLS</th><th scope="col" data-i18n>INPUT</th><th scope="col" data-i18n>CACHE READ</th><th scope="col" data-i18n>OUTPUT</th><th scope="col" data-i18n>TOTAL</th><th scope="col" data-i18n>CACHE HIT</th></tr></thead><tbody id="usage-body"><tr><td colspan="7" data-i18n>Loading…</td></tr></tbody></table></div>
78
80
  <p class="hint" data-i18n>Cache hit = recorded cached / input tokens. ~ = incomplete history. — = unavailable or invalid counts.</p>
@@ -92,13 +94,13 @@
92
94
  <div class="calendar-scroll"><div class="calendar-grid"><div id="calendar-months" class="calendar-months" aria-hidden="true"></div><div id="activity-calendar" class="activity-calendar" aria-label="Daily recorded request activity" data-i18n-label></div></div></div>
93
95
  <p id="analytics-selection" class="hint" role="status" data-i18n>Select a day to inspect its model totals. No history is distinct from zero recorded calls.</p>
94
96
  </details>
95
- </section>
97
+ </details>
96
98
 
97
- <section class="lower" aria-label="Recent failures" data-i18n-label>
98
- <div class="panel-heading"><h2 data-i18n>RECENT RESPONSE FAILURES</h2><span id="failure-count">requests + events</span></div>
99
+ <details class="lower" id="recent-failures" open>
100
+ <summary class="panel-heading"><h2 data-i18n>RECENT RESPONSE FAILURES</h2><span id="failure-count">requests + events</span></summary>
99
101
  <ol id="failures"><li class="empty" data-i18n>Reading…</li></ol>
100
102
  <p class="hint" data-i18n>Upstream messages may contain sensitive text.</p>
101
- </section>
103
+ </details>
102
104
 
103
105
  <details id="animation-settings" class="panel dashboard-section settings-panel">
104
106
  <summary class="panel-heading"><h2 data-i18n>TERMINAL ANIMATION</h2><span id="animation-state" data-i18n>READING</span></summary>
@@ -154,6 +154,7 @@
154
154
  "retry": ["Retry status", "重试情况"],
155
155
  "retry_policy": ["Retry rule", "重试规则"],
156
156
  "retry_skipped": ["Skip reason", "跳过原因"],
157
+ "recovery": ["Recovery", "恢复处理"],
157
158
  "attempted (outcome not recorded here)": ["Retried; result not recorded here.", "已重试;这里未记录结果。"],
158
159
  "attempted": ["retried", "已重试"],
159
160
  "not attempted": ["not retried", "未重试"],
@@ -95,6 +95,8 @@ details > summary::marker { content: ""; }
95
95
  details > summary::before { content: "+"; color: var(--heading); font-weight: 700; letter-spacing: 0; }
96
96
  details[open] > summary::before { content: "−"; }
97
97
  .settings-panel > summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
98
+ .dashboard-section > summary.panel-heading, .lower > summary.panel-heading { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
99
+ .dashboard-section > summary.panel-heading span, .lower > summary.panel-heading span { white-space: normal; text-align: right; }
98
100
  .failure-detail { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 7px 18px; margin: 14px 0; line-height: 1.6; }
99
101
  .failure-detail dt { color: var(--muted); }
100
102
  .failure-detail dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
@@ -96,6 +96,7 @@ function renderFailures(recent, recentRequests = []) {
96
96
  message: failure.message, response_id: failure.response_id, upstream_request_id: failure.upstream_request_id,
97
97
  retry: failure.retried ? (timeline ? "attempted" : "attempted (outcome not recorded here)") : "not attempted",
98
98
  retry_policy: failure.retry_policy, retry_skipped: failure.retry_skipped,
99
+ recovery: failure.recovery ? JSON.stringify(failure.recovery) : undefined,
99
100
  request_id: failure.request_id, outcome: timeline?.outcome, origin: timeline?.origin,
100
101
  phase: timeline?.phase, http_status: timeline?.http_status, upstream_attempts: timeline?.upstream_attempts,
101
102
  timings_ms: timingText };
package/src/launcher.mjs CHANGED
@@ -1,4 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { installedWindowsPredictionApp, windowsPredictionAppProcesses } from "./native-prediction-windows.mjs";
2
5
  import { status } from "./status.mjs";
3
6
 
4
7
  export { ensureAuth } from "./auth.mjs";
@@ -36,9 +39,54 @@ export function launchAttempts() {
36
39
  return [["-b", CODEX_BUNDLE_ID], ...APP_PATH_CANDIDATES.map((path) => [path])];
37
40
  }
38
41
 
39
- export async function openCodex({ env = process.env, spawnImpl = spawn, platform = process.platform, predictionPacUrl = null, predictionApp = null } = {}) {
42
+ export async function openCodex({ env = process.env, spawnImpl = spawn, platform = process.platform, predictionPacUrl = null, predictionApp = null, predictionProfile = null,
43
+ resolveWindowsApp = installedWindowsPredictionApp, windowsAppProcesses = windowsPredictionAppProcesses } = {}) {
44
+ if (platform === "win32" && autoLaunchEnabled(env) && typeof predictionPacUrl === "string"
45
+ && /^http:\/\/127\.0\.0\.1:\d{1,5}\/proxy\.pac$/.test(predictionPacUrl)
46
+ && typeof predictionApp === "string" && path.win32.isAbsolute(predictionApp)) {
47
+ try {
48
+ if (typeof predictionProfile !== "string" || !path.win32.isAbsolute(predictionProfile)
49
+ || /[\0\r\n]/.test(predictionProfile) || !fs.existsSync(path.win32.join(predictionProfile, "Local State"))) {
50
+ throw new Error("Verified Windows browser profile is unavailable; prediction launch was skipped");
51
+ }
52
+ const override = String(env.CODEX_ELECTRON_USER_DATA_PATH || "").trim();
53
+ if (override && path.win32.resolve(override).toLowerCase() !== path.win32.normalize(predictionProfile).toLowerCase()) {
54
+ throw new Error("Existing browser profile override differs from prediction trust; it was preserved");
55
+ }
56
+ const current = resolveWindowsApp({ env });
57
+ if (path.win32.normalize(current.app).toLowerCase() !== path.win32.normalize(predictionApp).toLowerCase()) {
58
+ throw new Error("Windows Codex App changed; prediction launch was skipped");
59
+ }
60
+ const running = windowsAppProcesses(current.app, { env });
61
+ if (running.length) {
62
+ if (running.length === 1 && running[0].readable && running[0].route === predictionPacUrl) {
63
+ console.log(status("ok", "Running Codex App uses the current prediction route"));return true;
64
+ }
65
+ throw new Error("Running Codex App uses an old or unverified prediction route. Fully quit the App, then run ccdx again; no process was stopped");
66
+ }
67
+ const launched = await new Promise(resolve => {
68
+ const child = spawnImpl(current.app, [`--user-data-dir=${predictionProfile}`, `--proxy-pac-url=${predictionPacUrl}`], {
69
+ cwd: path.win32.dirname(current.app), env: { ...env, CODEX_ELECTRON_USER_DATA_PATH: predictionProfile },
70
+ stdio: "ignore", detached: true, shell: false,
71
+ });
72
+ child.once("error", () => resolve(false));
73
+ child.once("spawn", () => { child.unref(); resolve(true); });
74
+ });
75
+ if (!launched) { console.log(status("warn", "Could not launch the registered Windows Codex App"));return false; }
76
+ await new Promise(resolve => setTimeout(resolve, 300));
77
+ const actual = windowsAppProcesses(current.app, { env });
78
+ const routeRetained = actual.length === 1 && actual[0].readable && actual[0].route === predictionPacUrl;
79
+ console.log(status(routeRetained ? "info" : "warn", routeRetained
80
+ ? "Codex launch route verified; prediction status will show when configuration traffic is observed"
81
+ : "Codex launch requested, but the active App did not retain the current prediction route. Core adapter remains available"));
82
+ return routeRetained;
83
+ } catch (error) {
84
+ console.log(status("warn", `Optional Windows prediction launch skipped: ${error.message}`));
85
+ return false;
86
+ }
87
+ }
40
88
  if (platform !== "darwin") {
41
- console.log(status("warn", "Auto-launch is only supported on macOS"));
89
+ console.log(status("warn", "Automatic launch requires macOS or an enabled Windows prediction setup"));
42
90
  console.log(status("info", "Open Codex App manually; it will connect to the adapter."));
43
91
  return false;
44
92
  }