codex-copilot-dx 1.3.7 → 1.3.9

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 (46) hide show
  1. package/README.md +7 -16
  2. package/bin/cli.mjs +55 -31
  3. package/docs/ARCHITECTURE.md +25 -1
  4. package/docs/REFERENCE.md +45 -10
  5. package/package.json +3 -3
  6. package/src/claude-gateway.mjs +21 -18
  7. package/src/cli-command-spec.mjs +3 -2
  8. package/src/cli-image.mjs +2 -80
  9. package/src/cli-options.mjs +1 -1
  10. package/src/client-integration.mjs +11 -4
  11. package/src/connection-runtime.mjs +1 -0
  12. package/src/dashboard/connections.js +5 -1
  13. package/src/dashboard/console.js +12 -6
  14. package/src/dashboard/features.js +73 -0
  15. package/src/dashboard/index.html +15 -14
  16. package/src/dashboard/language.js +60 -16
  17. package/src/dashboard/tools.js +4 -1
  18. package/src/dashboard/ui.js +1 -1
  19. package/src/dashboard/usage.js +2 -2
  20. package/src/dashboard-api.mjs +7 -2
  21. package/src/dashboard-tools.mjs +2 -1
  22. package/src/dashboard.mjs +1 -0
  23. package/src/doctor-compat.mjs +19 -13
  24. package/src/doctor.mjs +1 -1
  25. package/src/image-setup.mjs +110 -0
  26. package/src/local-privacy.mjs +15 -11
  27. package/src/local-tools.mjs +8 -2
  28. package/src/messages-history-transfer.mjs +12 -2
  29. package/src/messages-system-policy.mjs +20 -0
  30. package/src/model-capabilities.mjs +2 -2
  31. package/src/native-prediction-profile.mjs +5 -2
  32. package/src/native-prediction.mjs +18 -2
  33. package/src/optional-routes.mjs +1 -1
  34. package/src/prediction-control.mjs +64 -0
  35. package/src/prediction-operations.mjs +68 -0
  36. package/src/prediction-preference.mjs +75 -0
  37. package/src/privacy-model.mjs +35 -21
  38. package/src/privacy-transform.mjs +35 -4
  39. package/src/providers/m365.mjs +5 -2
  40. package/src/service-control.mjs +33 -7
  41. package/src/service-supervisor.mjs +39 -18
  42. package/src/service-worker.mjs +13 -1
  43. package/src/terminal-console.mjs +2 -2
  44. package/src/usage-analytics.mjs +6 -1
  45. package/src/usage-store.mjs +21 -8
  46. package/src/usage.mjs +18 -5
package/src/cli-image.mjs CHANGED
@@ -1,21 +1,17 @@
1
- import fs from "node:fs";
1
+ import { fileContent, enableImageProvider, disableImageProvider } from "./image-setup.mjs";
2
+ export { syncEnabledImageSkill } from "./image-setup.mjs";
2
3
  import os from "node:os";
3
4
  import readline from "node:readline";
4
5
  import { createInterface } from "node:readline/promises";
5
6
  import { codexPaths } from "./codex-paths.mjs";
6
- import { withFileLockSync } from "./lock.mjs";
7
- import { atomicWriteFileIfChangedSync, atomicWriteFilePairSync } from "./atomic-file.mjs";
8
7
  import { terminalCell } from "./cli-table.mjs";
9
- import { computeImageMcpCodexConfig } from "./config.mjs";
10
8
  import { probeImageTool } from "./image-readiness.mjs";
11
- import { updateImageSkill } from "./image-skill.mjs";
12
9
  import { servicePreferences, writeServicePreference } from "./user-settings.mjs";
13
10
  import {
14
11
  imageProviderConfigPath,
15
12
  inspectImageProvider,
16
13
  normalizeImageEndpoint,
17
14
  readImageProviderConfig,
18
- validateImageProviderConfig,
19
15
  } from "./image-provider-config.mjs";
20
16
  async function visibleQuestion(input, output, question) {
21
17
  const prompt = createInterface({ input, output });
@@ -61,17 +57,6 @@ export function hiddenQuestion(input, output, question, { cancelMessage = "Image
61
57
  });
62
58
  }
63
59
 
64
- function fileContent(filePath) {
65
- try { return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(fs.readFileSync(filePath)); }
66
- catch (error) {
67
- if (error?.code === "ENOENT") return "";
68
- if (error?.code === "ERR_ENCODING_INVALID_ENCODED_DATA") {
69
- throw new Error("Codex configuration is not valid UTF-8 TOML; no configuration changes were written");
70
- }
71
- throw error;
72
- }
73
- }
74
-
75
60
  function chooseModelLines(modelIds, selected) {
76
61
  return modelIds.map((model, index) => ` ${index + 1}. ${terminalCell(model)}${model === selected ? " [current]" : ""}`);
77
62
  }
@@ -99,69 +84,6 @@ function configSummary(config) {
99
84
  };
100
85
  }
101
86
 
102
- function enableImageProvider(options) {
103
- return withFileLockSync(`${options.codexPath}.ccdx.lock`, () => enableImageProviderUnlocked(options));
104
- }
105
- function enableImageProviderUnlocked({ providerConfig, providerPath, codexPath, codexContent, adapterPort, adapterHost }) {
106
- const codex = computeImageMcpCodexConfig(codexContent, {
107
- enabled: true,
108
- adapterPort,
109
- adapterHost,
110
- });
111
- const normalized = validateImageProviderConfig(providerConfig, { filePath: providerPath });
112
- const skill = updateImageSkill({ enabled: true, codexPath, adapterPort, adapterHost });
113
- try {
114
- if (fileContent(codexPath) !== codexContent) {
115
- throw new Error("Codex configuration changed during image setup; retry to preserve the newer settings");
116
- }
117
- atomicWriteFilePairSync(
118
- codexPath,
119
- codex.content,
120
- providerPath,
121
- `${JSON.stringify(normalized, null, 2)}\n`,
122
- { mode: 0o600, writeFile: atomicWriteFileIfChangedSync },
123
- );
124
- } catch (error) {
125
- skill.rollback();
126
- throw error;
127
- }
128
- return { codexChanged: codex.changed, config: normalized };
129
- }
130
-
131
- function disableImageProvider(options) {
132
- if (!fs.existsSync(options.codexPath)) return disableImageProviderUnlocked(options);
133
- return withFileLockSync(`${options.codexPath}.ccdx.lock`, () => disableImageProviderUnlocked(options));
134
- }
135
- function disableImageProviderUnlocked({ providerPath, codexPath, codexContent, adapterPort, adapterHost }) {
136
- const codex = computeImageMcpCodexConfig(codexContent, {
137
- enabled: false,
138
- adapterPort,
139
- adapterHost,
140
- });
141
- const providerExists = fs.existsSync(providerPath);
142
- const skill = updateImageSkill({ enabled: false, codexPath, adapterPort, adapterHost });
143
- try {
144
- if (fs.existsSync(codexPath)) {
145
- if (fileContent(codexPath) !== codexContent) {
146
- throw new Error("Codex configuration changed during image cleanup; retry to preserve the newer settings");
147
- }
148
- atomicWriteFilePairSync(codexPath, codex.content, providerPath, null, {
149
- mode: 0o600, writeFile: atomicWriteFileIfChangedSync,
150
- });
151
- } else if (providerExists) {
152
- fs.unlinkSync(providerPath);
153
- }
154
- } catch (error) {
155
- skill.rollback();
156
- throw error;
157
- }
158
- return { changed: providerExists || codex.changed || skill.changed, preservedGuidance: Boolean(skill.preserved) };
159
- }
160
-
161
- export function syncEnabledImageSkill({ home = os.homedir(), env = process.env, codexPath = codexPaths({ env, home }).config, ...options } = {}) {
162
- return updateImageSkill({ ...options, enabled: true, codexPath });
163
- }
164
-
165
87
  function printImageReadiness(readiness, output, commandName) {
166
88
  if (readiness.ready) {
167
89
  output.write("Local image service: ready (generation tool verified; no image generated).\n");
@@ -92,7 +92,7 @@ export function cliCommandName() {
92
92
 
93
93
  const integrationNotes = {
94
94
  prediction:
95
- "Optional native suggestions are off by default. Windows requires the initialized official MSIX App profile, Windows PowerShell and .NET Framework 4.7.2+; Git/OpenSSL is not required. The bridge port persists across restarts/updates; a busy saved port disables predictions only. Setup/removal requires Codex to be closed, then a normal CCDX restart. HTTPS on chatgpt.com and ab.chatgpt.com is decrypted locally; only prediction configuration is changed. App-profile trust and routing are used; no OS trust or client program files are changed. Proxy/PAC policy is preserved. Repair never enables predictions or force-restarts Codex. Environment trust changes require a service restart.",
95
+ "New Codex integrations attempt prediction setup by default and preserve saved off choices. Setup enables native Show predictions; enable/disable synchronizes display, with pending changes while Codex is running. WebUI provides setup, removal, repair and App opening. Windows requires the initialized official MSIX App profile, Windows PowerShell and .NET Framework 4.7.2+; Git/OpenSSL is not required. The bridge port persists across restarts/updates; a busy saved port disables predictions only. Setup/removal requires Codex to be closed; WebUI starts the bridge without a core restart. Offline CLI setup needs the next normal CCDX launch. HTTPS on chatgpt.com and ab.chatgpt.com is decrypted locally; only prediction configuration is changed. App-profile trust and routing are used; no OS trust or client program files are changed. Proxy/PAC policy is preserved. Repair never enables predictions or force-restarts Codex. Environment trust changes require a service restart.",
96
96
  image:
97
97
  "Setup configures the image API and private credential without generating an image. An empty key keeps the saved key only for the same origin. Pause keeps credentials; remove deletes the stored image credential and unchanged CCDX guidance.",
98
98
  review:
@@ -5,17 +5,24 @@ import { runInBackground } from "./startup.mjs";
5
5
  import { createPredictionState } from "./native-prediction-state.mjs";
6
6
  import { supervisePrediction } from "./native-prediction-recovery.mjs";
7
7
  import { operationErrorDetails } from "./operation-error.mjs";
8
+ import { runPredictionOperation } from "./prediction-operations.mjs";
8
9
 
9
10
  // The CLI composes the services; this module owns optional client integration
10
11
  // lifecycle. It never forwards model requests or depends on dashboard rendering.
11
12
  export function createClientIntegration({ port, host, info = () => {}, warning = () => {}, configLog,
12
- startPrediction = async options => (await import("./native-prediction.mjs")).startNativePrediction(options) } = {}) {
13
+ startPrediction = async options => {
14
+ const preparation = options.environment ? { configured: true, environment: options.environment }
15
+ : await runPredictionOperation("startup", { autoSetup: options.autoSetup, env: process.env, platform: process.platform });
16
+ if (!preparation.configured) { options.state?.configure(false);return null; }
17
+ return (await import("./native-prediction.mjs")).startNativePrediction({ ...options, autoSetup: false, environment: preparation.environment });
18
+ } } = {}) {
13
19
  const prediction = createPredictionState();
14
20
  let native = null;
15
21
  let operation = null, operationName = null, closed = false;
16
22
  let pendingRoutePid = null, codexSetup = null;
17
- async function startPredictionBridge(expectedPort, environment) {
23
+ async function startPredictionBridge(expectedPort, environment, autoSetup = false) {
18
24
  const started = await startPrediction({ state: prediction, warning: info,
25
+ autoSetup,
19
26
  ...(environment ? { environment } : {}), ...(expectedPort ? { expectedPort } : {}) });
20
27
  if (!started) return null;
21
28
  if (closed) { await started.close();return null; }
@@ -65,9 +72,9 @@ export function createClientIntegration({ port, host, info = () => {}, warning =
65
72
  }
66
73
  return { imageEnabled: enabled, imageMcpSkipped, compressionSetup: runInBackground(ensureCodexThreadCompression) };
67
74
  },
68
- start() { return serialize("start", async () => {
75
+ start({ autoSetup = true } = {}) { return serialize("start", async () => {
69
76
  try {
70
- native ||= await startPredictionBridge();
77
+ native ||= await startPredictionBridge(undefined, undefined, autoSetup);
71
78
  } catch (error) { prediction.unavailable(error); warning(`${error.message}. Core startup will continue.`); }
72
79
  return native;
73
80
  }); },
@@ -1477,6 +1477,7 @@ export function createConnectionRuntime({
1477
1477
  log,
1478
1478
  performance: legacy.claudePerformance,
1479
1479
  desktopAliases: id === "claude_app",
1480
+ messagesSystemMode: id === "claude_app" ? "legacy" : "passthrough",
1480
1481
  resolveRequest(body) {
1481
1482
  const record = resolveDeployment(id, body.model),
1482
1483
  finish = track(record.provider);
@@ -69,6 +69,10 @@
69
69
  const toggle = node("input");toggle.type = "checkbox";toggle.checked = true;toggle.setAttribute("role", "switch");toggle.setAttribute("aria-label", format("api_disable_source") + " " + provider.name);
70
70
  toggle.addEventListener("change", () => { toggle.checked = true;disableSource(provider); });const hit = node("label", undefined, "switch-hit");hit.append(toggle);actions.append(hit);
71
71
  } else actions.append(button("api_restore", () => void change({ operation: "provider", id: provider.id, enabled: true })));
72
+ if (!provider.builtin && !provider.enabled) {
73
+ const remove = button("api_remove_source", () => { if (window.confirm(format("api_remove_source_confirm"))) void change({ operation: "remove_api", id: provider.id, impact_revision: data.source_impacts?.[provider.id]?.revision }); });
74
+ remove.disabled = data.clients.some(c => c.source === provider.id || c.deployments?.some(item => item.source === provider.id));actions.append(remove);
75
+ }
72
76
  row.append(info, actions);if (!provider.enabled) disabledSources.append(row);else if (provider.id === selectedProvider) providerList.append(row);
73
77
  }
74
78
  const current = editingClient && client(editingClient);
@@ -174,7 +178,7 @@
174
178
  const note = node("p", undefined, "hint");words(note, "cap_metadata_scope");advanced.append(note);
175
179
  const fields = node("div", undefined, "connection-fields");
176
180
  const numeric = ["context_window", "max_input_tokens", "max_output_tokens", "reasoning_budget_min", "reasoning_budget_max"];
177
- const flags = ["reasoning", "reasoning_required", "reasoning_adaptive", "tools", "parallel_tools", "streaming", "structured_output"];
181
+ const flags = ["reasoning", "reasoning_required", "reasoning_adaptive", "tools", "parallel_tools", "streaming", "structured_output", "mid_conversation_system"];
178
182
  const arrays = ["reasoning_efforts", "thinking_modes", "input_modalities", "web_search"];
179
183
  for (const key of [...numeric, ...flags, ...arrays, "reasoning_format"]) {
180
184
  const label = node("label"), title = node("span");words(title, "cap_field_" + key);label.append(title);
@@ -68,13 +68,14 @@
68
68
  async function api(body) {
69
69
  const response = await fetch("/_ccdx/ui/settings", { method: body ? "POST" : "GET", cache: "no-store",
70
70
  headers: { "X-CCDX-Dashboard": "1", ...(body ? { "Content-Type": "application/json" } : {}) },
71
- ...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout(body?.operation === "account" ? 65000 : 15000) });
71
+ ...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout(body?.action === "prediction" ? 210000 : body?.action === "image" || body?.operation === "account" ? 65000 : 15000) });
72
72
  const data = await response.json();if (!response.ok) throw Object.assign(new Error(data.error || `HTTP ${response.status}`), { code: data.code });return data;
73
73
  }
74
74
  const preferences = globalThis.ccdxDashboardPreferences?.create({ element: el, api, applied: applySettings, time,
75
75
  selectAnimation: theme => animationView.select(theme),
76
76
  refreshAnimation() { dashboardRefresh.invalidate("animation");if (current === "system") void dashboardRefresh.refresh("animation", { force: true }); } });
77
77
  globalThis.ccdxSettingsPreferences = preferences;
78
+ const features = globalThis.ccdxDashboardFeatures?.create({ element: el, api, apply: applySettings, change, localize: label });
78
79
  const states = { immediate: "effective_now", terminal_unavailable: "terminal_animation_unavailable_in_this_output_mode", next_start: "next_ccdx_start", next_call: "applies_to_new_calls", needs_setup: "setup_required",
79
80
  next_config_request: "next_configuration_request_cached_suggestions_may_remain", needs_app_relaunch: "reopen_the_client_to_finish", needs_service_restart: "restart_ccdx_to_finish" };
80
81
  const selectedSource = () => providerEntries.find(source => source.id === el("source-provider").value);
@@ -115,6 +116,7 @@
115
116
  function applySettings(data, meta) {
116
117
  globalThis.ccdxPrivacy?.sync(data.local_privacy);
117
118
  settings = data;
119
+ features?.render(data);
118
120
  const nightly = data.nightly_update;
119
121
  el("nightly-update").checked = nightly?.enabled === true;el("nightly-update").disabled = false;
120
122
  el("nightly-rules").hidden = nightly?.enabled !== true;
@@ -125,7 +127,7 @@
125
127
  el("animation-settings").dataset.terminalPalette = data.color_theme || "green";
126
128
  label(el("terminal-color-note"), data.terminal?.mode !== "status"
127
129
  ? "terminal_theme_unavailable" : "terminal_theme_applied");
128
- for (const key of ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled"]) {
130
+ for (const key of ["terminal_animation_enabled", "open_webui", "image_enabled"]) {
129
131
  const input = el(`setting-${key}`), effective = data.effective[key];
130
132
  input.checked = data.saved[key];input.disabled = Boolean(effective.locked);
131
133
  label(el(`effect-${key}`), data.saved[key] === effective.value && !effective.locked ? "preference_effect" : "saved_saved_effective_effective_state", {
@@ -195,9 +197,9 @@
195
197
  if (settingsPending) return;
196
198
  settingsPending = true;
197
199
  syncAccountControls();
198
- const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #terminal-color-theme, #m365-enabled")];
200
+ const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #terminal-color-theme, #m365-enabled, #prediction-continue, #prediction-open, #prediction-setup, #prediction-remove, #image-setup-form input, #image-setup-form select, #image-setup-form button, #decoded-limit, #decoded-limit-save, #decoded-limit-default, #install-update")];
199
201
  controls.forEach(input => { input.disabled = true; });
200
- const note = el(body.action === "nightly_update" ? "nightly-state" : body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
202
+ const note = el(body.action === "prediction" ? "prediction-action-note" : body.action === "image" ? "image-setup-note" : body.action === "update" ? "manual-update-note" : body.action === "decoded_limit" ? "decoded-limit-note" : body.action === "nightly_update" ? "nightly-state" : body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
201
203
  : body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
202
204
  : body.operation === "switch" ? "source-control-note" : body.operation === "auto-review" ? "review-control-note"
203
205
  : body.operation === "account" ? "m365-account-note" : "m365-control-note");
@@ -219,22 +221,26 @@
219
221
  label(el("m365-account-note"), "company_account_checked");
220
222
  }
221
223
  if (body.action !== "color_theme") { await refreshStatus();await dashboardRefresh.refresh("auth", { force: true }); }
224
+ return data;
222
225
  }
223
226
  catch (error) {
224
227
  if (settings) applySettings(settings);
225
228
  if (body.operation === "account") { label(el("m365-account-note"), "company_account_not_saved", { reason: { key: accountReasons.has(error.code) ? error.code : error.message } });return; }
226
229
  if (body.action === "color_theme") { label(el("terminal-color-note"), "not_saved_error", { error: error.message });return; }
227
- note.textContent = error.message;
230
+ if (error.code === "ccdx_prediction_app_open") label(note, error.code);
231
+ else note.textContent = error.message;
228
232
  } finally {
229
233
  settingsPending = false;controls.forEach(input => { input.disabled = false; });
230
234
  syncAccountControls();
231
235
  if (settings) for (const [key, value] of Object.entries(settings.effective)) if (value.locked) el(`setting-${key}`).disabled = true;
232
236
  if (settings?.history.source === "environment") el("save-history").disabled = true;
233
237
  el("apply-source").disabled = !sourceReady();el("source-model").disabled = !selectedSource()?.selection.models_required;syncReviewButton();
238
+ features?.render(settings, { notes: false });
234
239
  button?.removeAttribute("aria-busy");
235
240
  }
236
241
  }
237
242
  for (const input of document.querySelectorAll('[role=switch][id^="setting-"]')) input.addEventListener("change", () => {
243
+ if (input.id === "setting-prediction_enabled") return;
238
244
  if (preferences && input.closest('[data-view="system"]')) return;
239
245
  void change({ action: "preference", key: input.id.slice("setting-".length), value: input.checked }, input);
240
246
  });
@@ -243,7 +249,7 @@
243
249
  el("clean-history").addEventListener("click", () => {
244
250
  if (window.confirm(globalThis.ccdxLanguage.format("clear_inactive_codex_conversation_data_older_continuation_ids_ma"))) void change({ action: "history_clean" }, el("clean-history"));
245
251
  });
246
- el("fix-prediction").addEventListener("click", () => void change({ action: "prediction_fix" }, el("fix-prediction")));
252
+
247
253
  el("m365-enabled").addEventListener("change", () => {
248
254
  const operation = el("m365-enabled").checked ? "on" : "off";
249
255
  if (operation === "off" && !window.confirm(globalThis.ccdxLanguage.format("confirm_disable_m365"))) {
@@ -0,0 +1,73 @@
1
+ (() => {
2
+ function create({ element: el, change, localize }) {
3
+ let saved = null, imageDirty = false, limitDirty = false;
4
+ const prediction = operation => change({ action: "prediction", operation }, el("prediction-continue"));
5
+ el("setting-prediction_enabled").addEventListener("change", () => void prediction(el("setting-prediction_enabled").checked ? "enable" : "disable"));
6
+ el("prediction-continue").addEventListener("click", () => void prediction(saved?.features?.prediction?.enabled ? "enable" : "disable"));
7
+ el("fix-prediction").addEventListener("click", () => void prediction("repair"));
8
+ el("prediction-open").addEventListener("click", () => void prediction("open"));
9
+ el("prediction-setup").addEventListener("click", () => void prediction("setup"));
10
+ el("prediction-remove").addEventListener("click", () => { if (window.confirm(globalThis.ccdxLanguage.format("prediction_remove_confirm"))) void prediction("remove"); });
11
+ const imageInput = operation => ({ action: "image", operation, endpoint: el("image-setup-endpoint").value,
12
+ key: el("image-setup-key").value, model: el("image-setup-model").value || undefined });
13
+ el("image-setup-form").addEventListener("input", () => { imageDirty = true; });
14
+ el("image-setup-inspect").addEventListener("click", async () => {
15
+ const data = await change(imageInput("inspect"), el("image-setup-inspect"));
16
+ const result = data?.last_operation?.result;
17
+ if (!Array.isArray(result?.models)) return;
18
+ imageDirty = true;
19
+ const current = el("image-setup-model").value;
20
+ el("image-setup-model").replaceChildren(...result.models.map(id => { const item = document.createElement("option");item.value = item.textContent = id;return item; }));
21
+ if (result.models.includes(current)) el("image-setup-model").value = current;
22
+ localize(el("image-setup-note"), "image_models_ready");
23
+ });
24
+ el("image-setup-form").addEventListener("submit", async event => {
25
+ event.preventDefault();
26
+ const data = await change(imageInput("setup"), el("image-setup-save"));
27
+ if (data?.last_operation?.result?.configured) { imageDirty = false;el("image-setup-key").value = "";render(data);localize(el("image-setup-note"), "image_setup_saved"); }
28
+ });
29
+ el("image-setup-remove").addEventListener("click", async () => {
30
+ if (!window.confirm(globalThis.ccdxLanguage.format("image_remove_confirm"))) return;
31
+ const data = await change({ action: "image", operation: "remove" }, el("image-setup-remove"));
32
+ if (data) { imageDirty = false;el("image-setup-key").value = "";render(data); }
33
+ });
34
+ el("decoded-limit").addEventListener("input", () => { limitDirty = true; });
35
+ const saveLimit = async mib => {
36
+ const data = await change({ action: "decoded_limit", mib }, el(mib === null ? "decoded-limit-default" : "decoded-limit-save"));
37
+ if (data?.decoded_body) { limitDirty = false;render(data); }
38
+ };
39
+ el("decoded-limit-save").addEventListener("click", () => void saveLimit(Number(el("decoded-limit").value)));
40
+ el("decoded-limit-default").addEventListener("click", () => void saveLimit(null));
41
+ el("install-update").addEventListener("click", () => {
42
+ if (window.confirm(globalThis.ccdxLanguage.format("update_install_confirm"))) void change({ action: "update", confirmed: true }, el("install-update"));
43
+ });
44
+ function render(data, { notes = true } = {}) {
45
+ if (!data) return;
46
+ saved = data;
47
+ const value = data.features?.prediction;
48
+ el("setting-prediction_enabled").checked = value?.enabled === true;
49
+ el("setting-prediction_enabled").disabled = !value || value.status === "unavailable";
50
+ const pending = value?.display_pending || value?.enabled && (!value.configured || value.display?.enabled === false);
51
+ el("prediction-continue").hidden = !pending;
52
+ el("prediction-open").disabled = !value?.configured;
53
+ el("prediction-remove").disabled = !value?.configured;
54
+ if (notes) localize(el("prediction-action-note"), !value ? "feature_unavailable" : value.status === "unavailable" ? "feature_read_failed" : pending ? "prediction_quit_continue" : value.enabled && value.bridge !== "running" ? "prediction_bridge_missing" : value.enabled ? "prediction_ready" : "prediction_disabled");
55
+ localize(el("effect-prediction_enabled"), pending ? "feature_pending" : value?.enabled ? "on" : "off");
56
+ const image = data.features?.image;
57
+ if (!imageDirty) {
58
+ el("image-setup-endpoint").value = image?.endpoint || "";
59
+ const option = document.createElement("option");option.value = option.textContent = image?.model || "";el("image-setup-model").replaceChildren(option);
60
+ }
61
+ el("image-setup-remove").disabled = !image?.configured;
62
+ const limit = data.decoded_body;
63
+ if (!limitDirty && document.activeElement !== el("decoded-limit")) el("decoded-limit").value = limit?.bytes / 1048576 || 128;
64
+ el("decoded-limit").disabled = el("decoded-limit-save").disabled = el("decoded-limit-default").disabled = !limit || limit.source === "environment";
65
+ localize(el("decoded-limit-note"), limit?.source === "environment" ? "controlled_by_environment" : "next_ccdx_start");
66
+ el("install-update").disabled = !data.manual_update?.available;
67
+ const update = data.nightly_update;
68
+ if (notes) localize(el("manual-update-note"), !data.manual_update?.available ? "update_external_launch" : update?.manual ? `manual_update_${update.phase}` : "update_idle_switch");
69
+ }
70
+ return { render };
71
+ }
72
+ globalThis.ccdxDashboardFeatures = { create };
73
+ })();
@@ -23,6 +23,7 @@
23
23
  <script src="/animation.js" defer></script>
24
24
  <script src="/ui.js" defer></script>
25
25
  <script src="/preferences.js" defer></script>
26
+ <script src="/features.js" defer></script>
26
27
  <script src="/console.js" defer></script>
27
28
  <script src="/tools.js" defer></script>
28
29
  <script src="/connections.js" defer></script>
@@ -68,7 +69,7 @@
68
69
  <summary class="panel-heading"><h2 data-i18n="client_connections">APP SETUP</h2><span data-i18n="configuration_observation">SETUP AND ACTIVITY</span></summary>
69
70
  <div class="table-wrap"><table><thead><tr><th data-i18n="client">APP</th><th data-i18n="current_source">Current source</th><th data-i18n="connection_setup" data-i18n-title="configured_not_successful">Setup</th><th data-i18n="local_bridge">Local service</th><th data-i18n="last_request">LAST REQUEST</th></tr></thead><tbody id="provider-clients"></tbody></table></div>
70
71
  </details>
71
- <section class="panel dashboard-section"><h2 data-i18n="this_run_usage">THIS RUN</h2><p id="runtime-usage" class="table-note"></p><p class="table-note"><span data-i18n="approx_cache_hit_rate">Approx. cache hit rate</span>: <strong id="runtime-cache-hit" data-i18n-title="runtime_cache_hit_basis" title="Reused input / input tokens. ~ Partial counts. — Unknown or invalid.">—</strong></p><p class="hint" data-i18n="updated_from_returned_usage_not_a_live_bill_pending_usage_is_not">Counts returned usage only. Pending usage is not included. This is not a live bill.</p></section>
72
+ <section class="panel dashboard-section"><h2 data-i18n="this_run_usage">THIS RUN</h2><p id="runtime-usage" class="table-note"></p><p class="table-note"><span data-i18n="approx_cache_hit_rate">Approx. cache hit rate</span>: <strong id="runtime-cache-hit" data-i18n-title="runtime_cache_hit_basis" title="Reused / input tokens from records with valid counts for both. ~ Partial coverage. — No valid input basis.">—</strong></p><p class="hint" data-i18n="updated_from_returned_usage_not_a_live_bill_pending_usage_is_not">Counts returned usage only. Pending usage is not included. This is not a live bill.</p></section>
72
73
  </div>
73
74
  <div data-view="codex" hidden>
74
75
  <div id="codex-model-management"> <section class="connection-access" id="connection-clients">
@@ -119,15 +120,14 @@
119
120
  </section>
120
121
  <details class="panel dashboard-section" id="prediction-settings" open>
121
122
  <summary class="panel-heading"><h2 data-i18n="codex_input_predictions">INPUT SUGGESTIONS</h2><span data-i18n="codex_only">CODEX ONLY</span></summary>
122
- <div class="setting-row"><label for="setting-prediction_enabled" data-i18n="allow_prediction_configuration">Allow suggestion updates</label><input id="setting-prediction_enabled" type="checkbox" role="switch" disabled><span id="effect-prediction_enabled" class="hint" role="status"></span></div>
123
- <p class="hint" data-i18n="pause_keeps_the_existing_trust_and_route_codex_may_retain_cached">Pause keeps existing trust and routing. Cached suggestions may still appear. First quit Codex, then run ccdx prediction on.</p>
123
+ <div class="setting-row"><label for="setting-prediction_enabled" data-i18n="predictions_enable">Input suggestions</label><input id="setting-prediction_enabled" type="checkbox" role="switch" disabled><span id="effect-prediction_enabled" class="hint" role="status"></span></div>
124
+ <p id="prediction-action-note" class="hint" role="status"></p><div class="section-actions"><button id="prediction-continue" type="button" data-i18n="feature_continue" hidden>Continue setup</button><button id="prediction-open" type="button" data-i18n="prediction_open">Open Codex</button></div>
124
125
  <details class="tool-details"><summary data-i18n="status_and_repair">Status and repair</summary>
125
126
  <dl class="stats"><div><dt data-i18n="prediction_integration_setup">Suggestion setup</dt><dd id="prediction-preference">—</dd></div><div><dt data-i18n="local_bridge">Local service</dt><dd id="prediction-bridge">—</dd></div><div><dt data-i18n="client_route">App settings requests</dt><dd id="prediction-route">—</dd></div><div><dt data-i18n="visible_candidate">Suggestion displayed</dt><dd id="prediction-candidate">—</dd></div></dl>
126
127
  <p id="prediction-note" class="hint">—</p>
127
- <p class="hint" data-i18n="configured_does_not_mean_displayed_use_ccdx_prediction_status_fo">Enabled does not mean a suggestion appeared. Details: ccdx prediction status.</p>
128
128
 
129
- <div class="section-actions"><button id="fix-prediction" type="button" data-i18n="check_and_repair">Check and repair</button></div>
130
- <p class="hint" data-i18n="prediction_first_setup">Quit Codex before first setup: ccdx prediction on</p>
129
+
130
+ <div class="section-actions"><button id="fix-prediction" type="button" data-i18n="check_and_repair">Check and repair</button><button id="prediction-setup" type="button" data-i18n="prediction_setup_again">Set up again</button><button id="prediction-remove" type="button" data-i18n="feature_remove">Remove setup</button></div>
131
131
  </details>
132
132
  </details>
133
133
  <details class="panel dashboard-section" id="additional-capabilities">
@@ -135,7 +135,7 @@
135
135
  <strong id="image">—</strong><p id="image-detail" class="hint">—</p>
136
136
  <div class="setting-row"><label for="setting-image_enabled" data-i18n="allow_new_image_calls">Allow image requests</label><input id="setting-image_enabled" type="checkbox" role="switch" disabled><span id="effect-image_enabled" class="hint" role="status"></span></div>
137
137
  <p class="hint" data-i18n="pause_keeps_the_provider_configuration_running_calls_can_finish_">Existing image requests can finish after pausing.</p>
138
- <details class="tool-details"><summary data-i18n="status_and_repair">Status and repair</summary><p class="hint" data-i18n="image_first_setup">First setup: ccdx enable-image</p></details>
138
+ <details class="tool-details" id="image-setup-panel"><summary data-i18n="image_setup">Configure image generation</summary><form id="image-setup-form"><div class="connection-fields"><label><span data-i18n="api_base">API address</span><input id="image-setup-endpoint" type="url" required maxlength="2048" autocomplete="off" spellcheck="false"></label><label>API Key<input id="image-setup-key" type="password" maxlength="8192" autocomplete="off"><span class="hint" data-i18n="image_key_keep">Leave empty to keep the key for the same address.</span></label><label><span data-i18n="model">Model</span><select id="image-setup-model" required></select></label></div><div class="section-actions"><button id="image-setup-inspect" type="button" data-i18n="api_read_models">Read models</button><button type="submit" id="image-setup-save" data-i18n="api_save">Save</button><button id="image-setup-remove" type="button" data-i18n="feature_remove">Remove setup</button></div></form><p id="image-setup-note" class="hint" role="status"></p></details>
139
139
  </details>
140
140
  <details class="panel dashboard-section" id="runtime-resources">
141
141
  <summary data-i18n="codex_conversation_buffer">CONVERSATION BUFFER</summary>
@@ -284,8 +284,8 @@
284
284
  </details>
285
285
  <details class="panel dashboard-section"><summary data-i18n="more_checks_reports">MORE CHECKS AND REPORTS</summary>
286
286
  <div class="section-actions"><button id="check-network" type="button" data-i18n="tools_network_check">Network settings</button></div><p id="network-check-result" class="hint" role="status"></p>
287
- <h3 data-i18n="tools_compatibility">Model compatibility</h3><p class="hint" data-i18n="tools_compatibility_scope">This test sends model requests and uses quota. Run it explicitly in your terminal:</p><pre class="tool-code">ccdx doctor --compat</pre>
288
- <div class="tool-details"><h3 data-i18n="diagnostic_report">Diagnostic report</h3><p class="hint" data-i18n="tools_report_scope">Reports omit credentials, account details and chat content.</p><div class="section-actions"><button id="export-report" type="button" data-i18n="tools_export_report">Export report</button></div></div>
287
+ <h3 data-i18n="tools_compatibility">Model compatibility</h3><p class="hint" data-i18n="compatibility_scope">Tests Codex Responses, streaming and compaction. Uses quota.</p><p id="compatibility-note" class="hint" role="status"></p>
288
+ <div class="tool-details"><h3 data-i18n="diagnostic_report">Diagnostic report</h3><p class="hint" data-i18n="tools_report_scope">Reports omit credentials, account details and chat content.</p><div class="section-actions"><button id="check-compatibility" type="button" data-i18n="compatibility_test">Test Codex model compatibility</button><button id="export-report" type="button" data-i18n="tools_export_report">Export report</button></div></div>
289
289
  </details>
290
290
  </div>
291
291
  <div data-view="usage" hidden>
@@ -313,9 +313,9 @@
313
313
  <summary class="panel-heading"><h2 data-i18n="usage_totals">USAGE TOTALS</h2><span id="usage-state" data-i18n="reading_log">COUNTING</span></summary>
314
314
  <div class="section-actions"><button id="clear-usage-day" type="button" hidden data-i18n="all_history">Show all</button></div>
315
315
  <p id="usage-note" class="table-note" data-i18n="aggregating_local_usage_metadata">Counting local usage…</p>
316
- <div class="table-wrap"><table class="usage-table"><thead><tr><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="calls">REQUESTS</th><th scope="col" data-i18n="input">INPUT USAGE</th><th scope="col" data-i18n="cache_read">REUSED INPUT</th><th scope="col" data-i18n="output">OUTPUT USAGE</th><th scope="col" data-i18n="total">TOTAL</th><th scope="col" data-i18n="cache_hit">REUSE RATE</th></tr></thead><tbody id="usage-body"><tr><td colspan="7" data-i18n="loading">Loading…</td></tr></tbody></table></div>
317
- <p class="hint" data-i18n="cache_hit_recorded_cached_input_tokens_incomplete_history_unavai">Unit: Token. Reused input is part of input.
318
- ~ Partial records. — Unknown or invalid.</p>
316
+ <div class="table-wrap"><table class="usage-table"><thead><tr><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="calls">REQUESTS</th><th scope="col" data-i18n="input">INPUT USAGE</th><th scope="col" data-i18n="cache_read">REUSED INPUT</th><th scope="col" data-i18n="cache_write">CACHE WRITE</th><th scope="col" data-i18n="output">OUTPUT USAGE</th><th scope="col" data-i18n="total">TOTAL</th><th scope="col" data-i18n="cache_hit">REUSE RATE</th></tr></thead><tbody id="usage-body"><tr><td colspan="8" data-i18n="loading">Loading…</td></tr></tbody></table></div>
317
+ <p class="hint" data-i18n="cache_hit_recorded_cached_input_tokens_incomplete_history_unavai">Unit: Token. Reused input is part of input. Rate uses records with valid input and cache-read counts.
318
+ ~ Partial coverage. — No valid input basis.</p>
319
319
 
320
320
  </details>
321
321
  </div>
@@ -427,7 +427,7 @@
427
427
  <div id="nightly-rules" hidden><dl class="nightly-rules"><div><dt data-i18n="nightly_window">Update window</dt><dd data-i18n="nightly_window_value">00:00–04:00 · Local time</dd></div><div><dt data-i18n="nightly_when">When to update</dt><dd data-i18n="nightly_when_value">Idle for 10 minutes, after checks pass</dd></div><div><dt data-i18n="nightly_versions">Versions</dt><dd data-i18n="nightly_versions_value">Stable patches released at least 24 hours ago</dd></div><div><dt data-i18n="nightly_failure">If an update fails</dt><dd data-i18n="nightly_failure_value">Try restoring the previous version and pause this update</dd></div></dl></div>
428
428
  </div>
429
429
  <p id="update-state" class="hint" role="status" data-i18n="reading">READING</p>
430
- <div id="update-command-row" class="update-command"><code id="update-command">ccdx update github</code><button type="button" id="copy-update" data-i18n="copy_command">Copy command</button></div>
430
+ <div class="section-actions"><button id="install-update" type="button" data-i18n="update_install_now" disabled>Install update</button><span id="manual-update-note" class="hint" role="status"></span></div><details class="tool-details" id="update-advanced"><summary data-i18n="advanced_terminal">Advanced: terminal commands</summary><div id="update-command-row" class="update-command"><code id="update-command">ccdx update github</code><button type="button" id="copy-update" data-i18n="copy_command">Copy command</button></div>
431
431
  <p class="hint" data-i18n="update_restart">Run in your terminal, then restart CCDX.</p>
432
432
  <p id="update-checked" class="refresh-time"></p>
433
433
  <details class="update-install"><summary data-i18n="update_install_help">Update failed? View full installation commands</summary><p class="hint" data-i18n="update_install_hint">Download the official installer. No Git required.</p>
@@ -435,7 +435,7 @@
435
435
  <div class="install-command-heading"><span id="install-shell" class="hint">macOS · Terminal</span><button type="button" id="copy-install" data-i18n="copy_command">Copy command</button></div><pre id="install-command" class="install-command"></pre>
436
436
  <p class="hint" data-i18n="update_install_policy">Reuses compatible Node/npm or installs a private runtime. Keeps your registry, proxy, certificates and shell policy.</p>
437
437
  <p id="install-windows-policy" class="hint" hidden data-i18n="update_windows_policy">If scripts are blocked, use your company’s approved installation method.</p>
438
- </details><p id="update-copy-note" class="hint" role="status"></p>
438
+ </details></details><p id="update-copy-note" class="hint" role="status"></p>
439
439
  </section>
440
440
  <section class="panel dashboard-section" id="privacy-settings" aria-labelledby="privacy-heading">
441
441
  <h2 id="privacy-heading" data-i18n="privacy_heading">ADVANCED</h2>
@@ -449,6 +449,7 @@
449
449
  <div class="section-actions"><button id="privacy-cancel" type="button" hidden data-i18n="cancel">Cancel</button><button id="privacy-retry" type="button" hidden data-i18n="view_retry">Retry</button><button id="privacy-remove" type="button" hidden data-i18n="privacy_remove">Delete model</button><p id="privacy-error" class="hint" role="alert"></p></div>
450
450
  </section>
451
451
  <dialog id="privacy-dialog" class="preferences-dialog" aria-labelledby="privacy-dialog-title"><h2 id="privacy-dialog-title" data-i18n="privacy_enable">Local masking</h2><p data-i18n="privacy_download">Downloads about 39 MB plus the local component. Checks may add delay or mistake ordinary text.</p><p data-i18n="privacy_fail_closed">If a check cannot finish, the request is not sent.</p><div class="section-actions"><button id="privacy-dialog-cancel" type="button" data-i18n="cancel">Cancel</button><button id="privacy-dialog-confirm" type="button" data-i18n="privacy_confirm">Download &amp; enable</button></div></dialog>
452
+ <details class="panel dashboard-section" id="request-limits"><summary data-i18n="advanced_limits">Advanced: request limits</summary><div class="section-actions"><label><span data-i18n="decoded_limit">Decoded request limit (MiB)</span><input id="decoded-limit" type="number" min="128" max="512" step="1"></label><button id="decoded-limit-save" type="button" data-i18n="api_save">Save</button><button id="decoded-limit-default" type="button" data-i18n="limit_default">Use default</button></div><p id="decoded-limit-note" class="hint" role="status"></p></details>
452
453
  <section class="panel dashboard-section" id="settings-preferences" aria-labelledby="preferences-heading">
453
454
  <h2 id="preferences-heading" data-i18n="preferences_heading">SAVE &amp; RESTORE</h2>
454
455
  <div class="preferences-row"><div><label for="preferences-auto" data-i18n="preferences_auto">Save changes automatically</label><p class="hint" data-i18n="preferences_auto_hint">Valid changes on this page save automatically.</p></div><input id="preferences-auto" type="checkbox" role="switch" disabled checked></div>