codex-copilot-dx 1.3.12 → 1.3.14

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 (54) hide show
  1. package/README.md +2 -2
  2. package/bin/cli.mjs +5 -10
  3. package/docs/ARCHITECTURE.md +11 -6
  4. package/docs/REFERENCE.md +21 -37
  5. package/package.json +1 -1
  6. package/src/access-settings.mjs +2 -1
  7. package/src/adapter.mjs +14 -4
  8. package/src/claude-capability-config.mjs +2 -2
  9. package/src/claude-client-config.mjs +5 -3
  10. package/src/cli-command-spec.mjs +4 -11
  11. package/src/cli-image.mjs +24 -180
  12. package/src/cli-management.mjs +21 -6
  13. package/src/cli-options.mjs +1 -1
  14. package/src/cli-secret.mjs +39 -0
  15. package/src/cli-tools.mjs +1 -1
  16. package/src/client-integration.mjs +13 -12
  17. package/src/client-model-plan.mjs +3 -1
  18. package/src/config.mjs +9 -54
  19. package/src/connection-runtime.mjs +24 -3
  20. package/src/copilot-client.mjs +16 -1
  21. package/src/dashboard/connections.js +41 -10
  22. package/src/dashboard/console.js +6 -4
  23. package/src/dashboard/features.js +19 -29
  24. package/src/dashboard/index.html +3 -3
  25. package/src/dashboard/language.js +8 -7
  26. package/src/dashboard/ui.css +6 -0
  27. package/src/dashboard/ui.js +11 -2
  28. package/src/dashboard/usage.js +10 -5
  29. package/src/dashboard-api.mjs +2 -1
  30. package/src/doctor.mjs +4 -5
  31. package/src/image-models.mjs +20 -0
  32. package/src/image-retirement.mjs +33 -0
  33. package/src/image-setup.mjs +16 -105
  34. package/src/legacy-image-guidance.mjs +73 -0
  35. package/src/live-models.mjs +2 -1
  36. package/src/native-images.mjs +111 -0
  37. package/src/observability.mjs +2 -0
  38. package/src/optional-routes.mjs +4 -13
  39. package/src/privacy-detection.mjs +2 -2
  40. package/src/privacy-model.mjs +3 -3
  41. package/src/provider-metadata.mjs +5 -4
  42. package/src/provider-runtime.mjs +2 -1
  43. package/src/service-control.mjs +6 -7
  44. package/src/service-worker.mjs +2 -2
  45. package/src/image-mcp.mjs +0 -328
  46. package/src/image-provider-config.mjs +0 -194
  47. package/src/image-provider.mjs +0 -369
  48. package/src/image-readiness.mjs +0 -55
  49. package/src/image-references.mjs +0 -50
  50. package/src/image-skill/SKILL.md +0 -28
  51. package/src/image-skill/references/editing.md +0 -15
  52. package/src/image-skill/references/helper.md +0 -27
  53. package/src/image-skill.mjs +0 -142
  54. package/src/image-tool-client.mjs +0 -150
@@ -5,7 +5,7 @@ import { debugLog } from "./log.mjs";
5
5
  import { enforceResponsesPayloadByteBudget } from "./responses-byte-budget.mjs";
6
6
  import { status } from "./status.mjs";
7
7
  import { withChatStreamUsage } from "./stream-contract.mjs";
8
- import { markRequestObservation, markUpstreamStarted } from "./stream-performance.mjs";
8
+ import { markRequestObservation, markUpstreamStarted, markUpstreamHeaders } from "./stream-performance.mjs";
9
9
  import { currentRequestContext } from "./request-context.mjs";
10
10
  import { requestOptionsEvidence } from "./response-failures.mjs";
11
11
 
@@ -205,6 +205,20 @@ export function createCopilotClientRuntime({
205
205
  }
206
206
  }
207
207
 
208
+ async function images(operation, body, { signal, fetchImpl } = {}) {
209
+ if (!["generations", "edits"].includes(operation)) throw new Error("Unsupported image operation");
210
+ const token = await tokenSession.getToken({ signal });
211
+ const headers = buildHeaders({ token, version: getVSCodeVersion(), initiator: "user", vision: operation === "edits" });
212
+ const bodyText = JSON.stringify(body);
213
+ markRequestObservation({ payload_bytes: Buffer.byteLength(bodyText), images: body.images?.length || 0 });
214
+ markUpstreamStarted(false);
215
+ const response = await fetchCopilotUpstream(`${tokenSession.getApiBase()}/v1/images/${operation}`, {
216
+ method: "POST", headers, body: bodyText, signal, redirect: "error",
217
+ }, { fetchImpl, retries: 0 });
218
+ markUpstreamHeaders(response.status);
219
+ return response;
220
+ }
221
+
208
222
  function responsesCompact(reqBody, options = {}) {
209
223
  return responses(reqBody, options);
210
224
  }
@@ -239,6 +253,7 @@ export function createCopilotClientRuntime({
239
253
  resetModelListSingleflightForTests,
240
254
  responses,
241
255
  responsesCompact,
256
+ images,
242
257
  resetForTests,
243
258
  });
244
259
  }
@@ -2,7 +2,7 @@
2
2
  const el = id => document.getElementById(id), root = el("connection-sources");if (!root) return;
3
3
  const words = (node, key, args) => globalThis.ccdxLanguage.set(node, key, args), format = key => globalThis.ccdxLanguage.format(key);
4
4
  let data = null, editing = null, editingClient = null, disabling = null, models = [], selectedModels = new Set(), busy = false, generation = 0;
5
- let claudeClient = "claude_app", bindingSelection = new Set(), bindingDefault = null, bindingDirty = false;
5
+ let claudeClient = "claude_app", bindingSelection = new Set(), bindingDefault = null, bindingImageModel = null, bindingImageDirty = false, bindingDirty = false;
6
6
  let memoryAction = null, memoryOrigin = null;
7
7
  let disableRevision = null;
8
8
  const drafts = new Map();let editorOrigin = null, discovery = null, desiredSource = null;
@@ -100,18 +100,23 @@
100
100
  try { const result = await api();if (current !== generation) return;data = result;mountClient();list(); }
101
101
  catch (error) { if (!data) message(error.message); }
102
102
  }
103
+ const imageViewRevision = value => {
104
+ const c = value?.clients.find(client => client.id === "codex"), image = c?.model_plan?.image;
105
+ return JSON.stringify([c?.enabled, image?.selected_model, image?.selected_available, image?.models]);
106
+ };
103
107
  async function change(input, done) {
104
108
  if (busy) return;busy = true;generation++;
105
- const trigger = input.operation === "client" ? clientForm.querySelector('button[type="submit"]') : input.operation === "preview_client" ? el("connection-sync-preview")
109
+ const previousImage = imageViewRevision(data);
110
+ const trigger = ["client", "image_model"].includes(input.operation) ? clientForm.querySelector('button[type="submit"]') : input.operation === "preview_client" ? el("connection-sync-preview")
106
111
  : input.operation === "save_api" ? apiForm.querySelector('button[type="submit"]') : document.activeElement;
107
112
  const oldKey = trigger?.dataset.i18n, oldText = trigger?.textContent;
108
113
  if (trigger?.tagName === "BUTTON") { trigger.setAttribute("aria-busy", "true");trigger.disabled = true;words(trigger, input.operation === "preview_client" ? "api_reading" : "api_saving"); }
109
- try { if (input.operation === "save_api") await stopDiscovery();data = await api(input);if (input.operation === "client") { drafts.delete(input.id);if (editingClient === input.id) bindingDirty = false; }mountClient();list();done?.(data);if (!done) {
114
+ try { if (input.operation === "save_api") await stopDiscovery();data = await api(input);if (["client", "image_model"].includes(input.operation)) { drafts.delete(input.id);if (editingClient === input.id) bindingDirty = false; }mountClient();list();done?.(data);if (!done) {
110
115
  if (input.operation === "save_api") {
111
116
  desiredSource = input.id || data.providers.find(p => !p.builtin && p.name === input.config.name)?.id;
112
117
  stopDiscovery();
113
118
  } else if (input.operation === "provider" && input.enabled) desiredSource = input.id;
114
- panels();let key = input.operation === "save_api" ? "api_config_saved" : input.operation === "provider" ? input.enabled ? "api_provider_enabled" : "api_provider_disabled"
119
+ panels();let key = input.operation === "image_model" ? "api_saved" : input.operation === "save_api" ? "api_config_saved" : input.operation === "provider" ? input.enabled ? "api_provider_enabled" : "api_provider_disabled"
115
120
  : !input.enabled ? "api_client_disabled" : !input.source ? "api_client_enabled" : "api_saved";
116
121
  const setup = data.clients.find(c => c.id === input.id)?.setup;
117
122
  if (input.operation === "client" && ["preserved", "partially_preserved"].includes(setup)) key = "api_client_preserved";
@@ -123,15 +128,15 @@
123
128
  if (input.operation === "save_api" && input.config.models.length) for (const c of data.clients.filter(c => c.enabled && input.allowed.includes(c.id))) {
124
129
  const link = node("a", c.name, "section-link");link.href = c.id === "codex" ? "#codex" : "#claude";link.addEventListener("click", event => { event.preventDefault();editClient(c); });el("connection-note").append(" ", link);
125
130
  }
126
- }window.dispatchEvent(new CustomEvent("ccdx:connections"));void dashboardRefresh.refresh("auth", { force: true });void dashboardRefresh.refresh("status", { force: true }); }
131
+ }if (input.operation !== "preview_client") window.dispatchEvent(new CustomEvent("ccdx:connections", { detail: { imageChanged: imageViewRevision(data) !== previousImage } }));void dashboardRefresh.refresh("auth", { force: true });void dashboardRefresh.refresh("status", { force: true }); }
127
132
  catch (error) {
128
133
  if (input.operation === "provider" && !input.enabled && error.message === "ccdx_connections_conflict") {
129
134
  try { data = await api();list();disableSource(source(input.id));message("api_impact_changed"); } catch { message(error.message); }return;
130
135
  }
131
- if (input.operation === "source_access") accessError = error.message;else if (input.operation === "client") words(el("connection-client-note"), error.message);else message(error.message);return;
136
+ if (input.operation === "source_access") accessError = error.message;else if (["client", "image_model"].includes(input.operation)) words(el("connection-client-note"), error.message);else message(error.message);return;
132
137
  }
133
138
  finally { busy = false;if (trigger?.tagName === "BUTTON") { trigger.removeAttribute("aria-busy");trigger.disabled = false;if (oldKey) words(trigger, oldKey);else trigger.textContent = oldText; }
134
- if (["client", "preview_client"].includes(input.operation)) bindingRows();
139
+ if (["client", "preview_client", "image_model"].includes(input.operation)) bindingRows();
135
140
  if (input.operation === "source_access") renderAccess();
136
141
  if (input.operation === "save_api") words(apiForm.querySelector('button[type="submit"]'), editing ? "api_save" : "api_save_read");
137
142
  }
@@ -226,6 +231,7 @@
226
231
  node("td", count(preview?.shared?.budgets?.[proposed?.public_id])), node("td", reasoningText(values)), node("td", searchText(values)));body.append(row);
227
232
  }
228
233
  const wrap = node("div", undefined, "table-wrap");wrap.append(table);result.append(wrap);
234
+ if (preview?.image?.selected_model) { const image = node("p");image.textContent = `${format("image_model")}: ${preview.image.selected_model}`;result.append(image); }
229
235
  const note = node("p", undefined, "hint");words(note, "cap_preview_scope");result.append(note);
230
236
  const sync = preview?.shared || c.model_plan?.sync;
231
237
  if (c.credential_state === "encrypted_unverified") { const kept = node("p", undefined, "hint");words(kept, "client_key_encrypted_kept");result.append(kept); }
@@ -359,7 +365,7 @@
359
365
  const bindingKey = (source, model) => source + "\0" + model;
360
366
  const routeId = item => item.route_id || item.public_id;
361
367
  function rememberDraft() {
362
- if (editingClient && bindingDirty) drafts.set(editingClient, { selection: new Set(bindingSelection), defaultModel: bindingDefault, autoSync: el("connection-auto-sync").checked });
368
+ if (editingClient && bindingDirty) drafts.set(editingClient, { selection: new Set(bindingSelection), defaultModel: bindingDefault, imageModel: bindingImageModel, imageDirty: bindingImageDirty, autoSync: el("connection-auto-sync").checked });
363
369
  }
364
370
  function mountClient(force = false) {
365
371
  if (!data) return;
@@ -374,9 +380,12 @@
374
380
  const selected = Array.isArray(c.deployments) ? c.deployments : (c.model_plan?.models || []).map(model => ({ source: model.source, model: model.id }));
375
381
  bindingSelection = draft ? new Set(draft.selection) : new Set(selected.map(item => bindingKey(item.source, item.model)));
376
382
  bindingDefault = draft ? draft.defaultModel : c.default_model || c.model_plan?.models.find(model => model.public_id === c.model_plan?.default_model)?.route_id || null;
383
+ bindingImageModel = draft?.imageDirty ? draft.imageModel : c.image_model || c.model_plan?.image?.selected_model || null;
384
+ bindingImageDirty = draft?.imageDirty === true;
377
385
  el("connection-auto-sync").checked = draft ? draft.autoSync : c.auto_sync !== false;
378
386
  el("connection-sync-result").hidden = true;el("connection-client-note").textContent = "";
379
387
  }
388
+ if (id === "codex" && !bindingImageDirty) bindingImageModel = c.image_model || c.model_plan?.image?.selected_model || null;
380
389
  bindingRows(document.activeElement?.name === "binding-model" ? { kind: "selection", key: document.activeElement.value } : document.activeElement?.dataset.binding ? { kind: "default", key: document.activeElement.dataset.binding } : null);words(el("connection-client-title"), "cap_visible_model");list();
381
390
  }
382
391
  function bindingRows(focus) {
@@ -408,6 +417,19 @@
408
417
  details.forEach((cell, i) => cell.dataset.label = format(["source", "cap_context", "cap_reasoning"][i]));
409
418
  row.append(name, ...details, cell);body.append(row);
410
419
  }
420
+ if (editingClient === "codex") {
421
+ for (const image of c.model_plan?.image?.models || []) {
422
+ const row = node("tr"), name = node("td"), label = node("label"), radio = node("input");
423
+ radio.type = "radio";radio.name = "binding-image-model";radio.value = image.id;radio.checked = bindingImageModel === image.id;
424
+ radio.addEventListener("change", () => { if (radio.checked) { bindingImageModel = image.id;bindingImageDirty = true;bindingDirty = true;rememberDraft();bindingRows({ kind: "image", key: image.id }); } });
425
+ label.append(radio, node("span", image.name || image.id));name.append(label);
426
+ const purpose = node("td");words(purpose, "image_purpose");
427
+ row.dataset.imageModel = image.id;row.append(name, node("td", source("github")?.name || "GitHub Copilot"), node("td", "—"), node("td", "—"), purpose);body.append(row);
428
+ }
429
+ if (bindingImageModel && !c.model_plan?.image?.models.some(model => model.id === bindingImageModel)) {
430
+ const row = node("tr"), cell = node("td", bindingImageModel);cell.colSpan = 5;const warning = node("span", undefined, "hint binding-unavailable");words(warning, "image_selected_unavailable");cell.append(" ", warning);row.append(cell);body.append(row);
431
+ }
432
+ }
411
433
  const unavailableDefault = bindingSelection.size > 0 && !available.some(item => routeId(item) === bindingDefault && bindingSelection.has(bindingKey(item.source, item.id)));
412
434
  const warning = el("connection-default-note");warning.hidden = !unavailableDefault;words(warning, "cap_default_unavailable");
413
435
  clientForm.querySelector('button[type="submit"]').disabled = unavailableDefault || busy;
@@ -419,7 +441,7 @@
419
441
  const capabilityNote = el("connection-capability-state");capabilityNote.hidden = !c.model_plan?.sync?.limitations?.some(item => item.code === "client_version_unknown");
420
442
  if (!capabilityNote.hidden) words(capabilityNote, "sync_capability_unverified");
421
443
  words(clientForm.querySelector('button[type="submit"]'), el("connection-auto-sync").checked ? "cap_save_sync" : "api_save");
422
- if (focus) { const selector = focus.kind === "selection" ? 'input[name="binding-model"]' : 'button[data-binding]';[...body.querySelectorAll(selector)].find(input => (input.value || input.dataset.binding) === focus.key)?.focus(); }
444
+ if (focus) { const selector = focus.kind === "selection" ? 'input[name="binding-model"]' : focus.kind === "image" ? 'input[name="binding-image-model"]' : 'button[data-binding]';[...body.querySelectorAll(selector)].find(input => (input.value || input.dataset.binding) === focus.key)?.focus(); }
423
445
  if (!body.children.length) { const row = node("tr"), cell = node("td");cell.colSpan = 5;words(cell, "cap_no_models");const link = node("a");link.href = "#models";words(link, "model_services");cell.append(" ", link);row.append(cell);body.append(row); }
424
446
  }
425
447
  function editClient(c) { location.hash = c.id === "codex" ? "codex" : "claude";if (c.id !== "codex") claudeClient = c.id;mountClient(true); }
@@ -430,8 +452,17 @@
430
452
  el("connection-auto-sync").addEventListener("change", () => { bindingDirty = true;rememberDraft();el("connection-client-cancel").disabled = false;words(el("connection-draft-state"), "cap_unsaved");words(clientForm.querySelector('button[type="submit"]'), el("connection-auto-sync").checked ? "cap_save_sync" : "api_save"); });
431
453
  el("connection-client-cancel").addEventListener("click", () => { drafts.delete(editingClient);bindingDirty = false;mountClient(true); });
432
454
  function bindingInput(operation) {
433
- const c = client(editingClient);return { operation, id: c.id, enabled: true, allowed: c.allowed,
455
+ const c = client(editingClient);
456
+ if (operation === "client" && editingClient === "codex" && bindingImageModel && bindingImageModel !== c.model_plan?.image?.selected_model) {
457
+ const selected = c.deployments || c.model_plan?.models.map(model => ({ source: model.source, model: model.id })) || [];
458
+ const keys = selected.map(item => bindingKey(item.source, item.model));
459
+ const defaultModel = c.default_model || c.model_plan?.models.find(model => model.public_id === c.model_plan?.default_model)?.route_id || null;
460
+ if (keys.length === bindingSelection.size && keys.every(key => bindingSelection.has(key)) && defaultModel === bindingDefault && (c.auto_sync !== false) === el("connection-auto-sync").checked)
461
+ return { operation: "image_model", id: "codex", model: bindingImageModel, client_revision: c.revision };
462
+ }
463
+ return { operation, id: c.id, enabled: true, allowed: c.allowed,
434
464
  deployments: [...bindingSelection].map(key => { const [source, model] = key.split("\0");return { source, model }; }),
465
+ ...(editingClient === "codex" && bindingImageModel ? { image_model: bindingImageModel } : {}),
435
466
  default_model: bindingDefault, auto_sync: el("connection-auto-sync").checked };
436
467
  }
437
468
  clientForm.addEventListener("submit", event => { event.preventDefault();void change(bindingInput("client")); });
@@ -76,7 +76,7 @@
76
76
  refreshAnimation() { dashboardRefresh.invalidate("animation");if (current === "system") void dashboardRefresh.refresh("animation", { force: true }); } });
77
77
  globalThis.ccdxSettingsPreferences = preferences;
78
78
  const features = globalThis.ccdxDashboardFeatures?.create({ element: el, api, apply: applySettings, change, localize: label });
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
+ const states = { needs_github_access: "image_needs_github", image_model_unavailable: "image_no_models", 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",
80
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" };
81
81
  const selectedSource = () => providerEntries.find(source => source.id === el("source-provider").value);
82
82
  const sourceReady = () => Boolean(selectedSource()) && (!selectedSource().selection.models_required || Boolean(modelsSource === selectedSource().id && el("source-model").value && el("source-review").value));
@@ -178,6 +178,7 @@
178
178
  el("process-notice").textContent = data.terminal?.last_notice || "";
179
179
  preferences?.sync(data, meta);
180
180
  }
181
+ window.addEventListener("ccdx:connections", event => { if (current === "codex" && event.detail?.imageChanged) void loadSettings(); });
181
182
  async function loadSettings() {
182
183
  if (settingsPending) return;
183
184
  settingsPending = true;
@@ -197,9 +198,9 @@
197
198
  if (settingsPending) return;
198
199
  settingsPending = true;
199
200
  syncAccountControls();
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")];
201
+ 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-models input, #decoded-limit, #decoded-limit-save, #decoded-limit-default, #install-update")];
201
202
  controls.forEach(input => { input.disabled = true; });
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"
203
+ const note = el(body.action === "prediction" ? "prediction-action-note" : body.action === "image" ? "effect-image_enabled" : 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"
203
204
  : body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
204
205
  : body.operation === "switch" ? "source-control-note" : body.operation === "auto-review" ? "review-control-note"
205
206
  : body.operation === "account" ? "m365-account-note" : "m365-control-note");
@@ -213,6 +214,7 @@
213
214
  if (body.action === "provider" && body.operation === "off") { sourceDirty = false;reviewDirty = false; }
214
215
  el("review-control-note").textContent = "";
215
216
  applySettings(data);
217
+ if (body.action === "image") void globalThis.ccdxConnections?.load();
216
218
  if (initialSourceSave) label(el("source-control-note"), "source_initial_review_saved");
217
219
  if (body.operation === "account") {
218
220
  sourceDirty = false;reviewDirty = false;sourceGeneration++;
@@ -271,7 +273,7 @@
271
273
  try {
272
274
  const data = await readModelCatalog(source.id);
273
275
  if (generation !== sourceGeneration) return;
274
- const models = data.models.filter(model => model.selectable && model.clients.includes("codex"));
276
+ const models = data.models.filter(model => model.kind !== "image" && model.selectable && model.clients.includes("codex"));
275
277
  sourceModels = models;
276
278
  const preference = settings?.providers?.[source.id]?.preference;
277
279
  for (const [id, key] of [["source-model", "model"], ["source-review", "auto_review_model"]]) {
@@ -1,6 +1,6 @@
1
1
  (() => {
2
2
  function create({ element: el, change, localize }) {
3
- let saved = null, imageDirty = false, limitDirty = false;
3
+ let saved = null, limitDirty = false, imageSignature = "";
4
4
  const prediction = operation => change({ action: "prediction", operation }, el("prediction-continue"));
5
5
  el("setting-prediction_enabled").addEventListener("change", () => void prediction(el("setting-prediction_enabled").checked ? "enable" : "disable"));
6
6
  el("prediction-continue").addEventListener("click", () => void prediction(saved?.features?.prediction?.enabled ? "enable" : "disable"));
@@ -8,29 +8,6 @@
8
8
  el("prediction-open").addEventListener("click", () => void prediction("open"));
9
9
  el("prediction-setup").addEventListener("click", () => void prediction("setup"));
10
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
11
  el("decoded-limit").addEventListener("input", () => { limitDirty = true; });
35
12
  const saveLimit = async mib => {
36
13
  const data = await change({ action: "decoded_limit", mib }, el(mib === null ? "decoded-limit-default" : "decoded-limit-save"));
@@ -54,12 +31,25 @@
54
31
  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
32
  el("effect-prediction_enabled").hidden = !pending;
56
33
  if (pending) localize(el("effect-prediction_enabled"), "feature_pending");
57
- const image = data.features?.image;
58
- if (!imageDirty) {
59
- el("image-setup-endpoint").value = image?.endpoint || "";
60
- const option = document.createElement("option");option.value = option.textContent = image?.model || "";el("image-setup-model").replaceChildren(option);
34
+ const image = data.features?.image, signature = JSON.stringify(image || null);
35
+ if (signature !== imageSignature) {
36
+ imageSignature = signature;
37
+ const list = el("image-models"), focus = list.contains(document.activeElement) ? document.activeElement.value : null;
38
+ list.replaceChildren();
39
+ for (const model of image?.models || []) {
40
+ const label = document.createElement("label"), name = document.createElement("span");name.textContent = model.name || model.id;
41
+ label.className = "image-model-choice";label.dataset.model = model.id;
42
+ if (image.models.length > 1 || image.selected_model !== model.id) {
43
+ const radio = document.createElement("input");radio.type = "radio";radio.name = "image-model";radio.value = model.id;radio.checked = image.selected_model === model.id;
44
+ radio.addEventListener("change", () => { if (radio.checked) void change({ action: "image", operation: "select", model: model.id }, radio); });label.append(radio);
45
+ }
46
+ label.append(name);list.append(label);
47
+ }
48
+ const note = el("image-model-note");note.hidden = image?.availability === "ready";
49
+ if (!note.hidden) localize(note, image?.availability === "needs_github_access" ? "image_needs_github" : image?.availability === "selected_unavailable" ? "image_selected_unavailable" : "image_no_models");
50
+ if (focus) [...list.querySelectorAll("input")].find(input => input.value === focus)?.focus();
61
51
  }
62
- el("image-setup-remove").disabled = !image?.configured;
52
+ for (const radio of el("image-models").querySelectorAll('input[name="image-model"]')) radio.checked = radio.value === image?.selected_model;
63
53
  const limit = data.decoded_body;
64
54
  if (!limitDirty && document.activeElement !== el("decoded-limit")) el("decoded-limit").value = limit?.bytes / 1048576 || 128;
65
55
  el("decoded-limit").disabled = el("decoded-limit-save").disabled = el("decoded-limit-default").disabled = !limit || limit.source === "environment";
@@ -132,10 +132,10 @@
132
132
  </details>
133
133
  <details class="panel dashboard-section" id="additional-capabilities">
134
134
  <summary class="panel-heading"><h2 data-i18n="codex_image_generation">IMAGE GENERATION</h2></summary>
135
- <strong id="image">—</strong><p id="image-detail" class="hint">—</p>
136
135
  <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
- <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" 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>
136
+ <div id="image-models" class="image-models" role="group" aria-label="Image model" data-i18n-label="image_model"></div>
137
+ <p id="image-model-note" class="hint" role="status" hidden></p>
138
+ <div class="image-metrics hint"><strong id="image">—</strong><span id="image-detail">—</span></div>
139
139
  </details>
140
140
  <details class="panel dashboard-section" id="runtime-resources">
141
141
  <summary data-i18n="codex_conversation_buffer">CONVERSATION BUFFER</summary>
@@ -7,8 +7,12 @@
7
7
  feature_continue: ["Continue setup", "继续配置"],
8
8
  prediction_open: ["Open Codex", "打开 Codex"],
9
9
  feature_remove: ["Remove setup", "移除接入"],
10
- image_setup: ["Configure image generation", "配置图片生成"],
11
- image_key_keep: ["Leave empty to keep the key for the same address.", "同一地址留空可保留原密钥。"],
10
+ image_model: ["Image model", "图片模型"],
11
+ image_models: ["Image models", "图片模型"],
12
+ image_needs_github: ["Allow GitHub Copilot access for Codex.", "请允许 Codex 使用 GitHub Copilot。"],
13
+ image_no_models: ["No image models available. Refresh the GitHub model catalog in Model sources.", "暂无可用图片模型。请在模型来源中刷新 GitHub 模型目录。"],
14
+ image_selected_unavailable: ["The saved image model is unavailable. Choose an available model.", "已保存的图片模型当前不可用,请选择可用模型。"],
15
+ image_purpose: ["Image", "图片"],
12
16
  update_install_now: ["Install update", "安装更新"],
13
17
  advanced_terminal: ["Advanced: terminal commands", "高级:终端命令"],
14
18
  compatibility_test: ["Test Codex model compatibility", "测试 Codex 模型兼容性"],
@@ -16,10 +20,7 @@
16
20
  advanced_limits: ["Advanced: request limits", "高级:请求限制"],
17
21
  decoded_limit: ["Decoded request limit (MiB)", "解码后请求上限(MiB)"],
18
22
  prediction_remove_confirm: ["Remove the CCDX prediction trust and route? Quit Codex to finish cleanup.", "移除 CCDX 预测信任与路由?退出 Codex 后才能完成清理。"],
19
- image_remove_confirm: ["Remove the image service key and CCDX image integration?", "移除图片服务密钥与 CCDX 图片接入?"],
20
23
  update_install_confirm: ["Install the latest stable release and switch CCDX when idle? Active work postpones the switch.", "安装最新稳定版并在空闲时切换 CCDX?有执行中的工作时会推迟切换。"],
21
- image_models_ready: ["Models read. Choose a model, then save.", "已读取模型。选择模型后保存。"],
22
- image_setup_saved: ["Image generation configured. Existing App tasks may need to refresh their tools.", "图片生成已配置。现有 App 任务可能需要刷新工具。"],
23
24
  feature_unavailable: ["Restart the updated CCDX to use these controls.", "重启更新后的 CCDX 以使用这些控制。"],
24
25
  prediction_quit_continue: ["Quit Codex, then continue setup here. No terminal command is needed.", "请退出 Codex,再在此继续配置。无需终端命令。"],
25
26
  prediction_ready: ["App and thread eligibility still apply.", "仍受 App 与会话适用条件限制。"],
@@ -399,7 +400,7 @@
399
400
  "flow_count_lower": ["≥{count} requests", "≥{count} 个请求"],
400
401
  "flow_app_codex": ["Codex", "Codex"],
401
402
  "prediction_first_setup": ["Quit Codex before first setup: ccdx app codex prediction setup", "首次配置前请退出 Codex:ccdx app codex prediction setup"],
402
- "image_first_setup": ["First setup: ccdx app codex image setup", "首次配置:ccdx app codex image setup"],
403
+ "image_first_setup": ["Uses the existing GitHub account", "使用现有 GitHub 账号"],
403
404
  "record_scope": ["Record scope", "记录范围"],
404
405
  "estimated_percentiles": ["Approx. first-output P50 / P95", "首个输出 P50 / P95(约)"],
405
406
  "percentile_values": ["{p50} / {p95} ms · {samples} samples", "{p50} / {p95} ms · {samples} 次样本"],
@@ -955,7 +956,7 @@
955
956
  "count_succeeded": ["{count} succeeded", "成功:{count}次"],
956
957
  "not_initialized": ["NOT CONFIRMED", "未确认"],
957
958
  "active_active_failed_failed_delivery_failures_delivery": ["Running: {active} / generation failed: {failed}\nFile delivery failed: {delivery}", "进行中:{active}/生成失败:{failed}\n文件交付失败:{delivery}"],
958
- "setup_state_unknown_ccdx_image_status": ["Use Configure image generation below.", "请在下方配置图片生成。"],
959
+ "setup_state_unknown_ccdx_image_status": ["Uses the existing GitHub Copilot account.", "使用现有 GitHub Copilot 账号。"],
959
960
  "snapshot_time": ["Status updated {time}", "状态更新:{time}"],
960
961
  "status_unavailable_check_ccdx_then_refresh": ["Cannot read status. Check CCDX and refresh.", "无法读取状态。\n请检查 CCDX 后刷新。"],
961
962
  "count_retained_requests_events": ["{count} records retained", "保留:{count}条"],
@@ -233,6 +233,7 @@ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color:
233
233
  .shell { max-width: 1520px; min-height: 100vh; display: grid; grid-template-columns: 204px minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr) auto; column-gap: 34px; padding: 0 28px; }
234
234
  .sidebar { grid-row: 1 / 4; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 22px 24px 0; border-right: 1px solid var(--border); }
235
235
  .sidebar-brand { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; column-gap: 12px; color: var(--accent); text-decoration: none; font-size: 23px; font-weight: 750; letter-spacing: .04em; }
236
+ .sidebar-brand > .status-icon, .sidebar-brand > .brand-name { grid-row: 1; }
236
237
 
237
238
  .sidebar nav { display: flex; flex-direction: column; gap: 5px; margin-top: 28px; }
238
239
  .sidebar nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; font-size: 13px; border-left: 2px solid transparent; }
@@ -668,3 +669,8 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
668
669
  @media (max-width:640px) { .context-metrics { grid-template-columns:repeat(2,minmax(0,1fr));gap:18px; } .context-metrics dd { font-size:21px; } }
669
670
 
670
671
  @media (pointer:coarse) { :root { --control-height:44px; --inline-control-height:44px; } }
672
+
673
+ .image-models { display: grid; gap: 8px; margin-block: 12px; }
674
+ .image-model-choice { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
675
+ .image-model-choice input { flex: 0 0 auto; }
676
+ .image-metrics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
@@ -16,10 +16,10 @@ const finite = (value) => value !== null && value !== undefined && Number.isFini
16
16
  const number = (value) => finite(value) ? Math.max(0, Math.round(Number(value))).toLocaleString() : "—";
17
17
  const mib = (value) => finite(value) ? `${(Number(value) / 1048576).toFixed(1)} MiB` : "—";
18
18
  const time = (value, options) => globalThis.ccdxTime?.format(value, options) ?? (value ? new Date(value).toLocaleTimeString() : "—");
19
- const viewHelpers = { time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator: globalThis.navigator,
19
+ const viewHelpers = { time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator: globalThis.navigator, modelLabel: usageModelLabel,
20
20
  motionAllowed: () => !reducedMotion.matches && document.visibilityState === "visible" && element("usage-analytics").open && !element("usage-analytics").closest("[hidden]") };
21
21
  const { render, renderActivity, renderProviders, renderFailures, renderContext } = globalThis.ccdxViewBoundary.create("client-features", () => globalThis.ccdxDashboardStatus.create(viewHelpers), ["render", "renderActivity", "renderProviders", "renderFailures", "renderContext"]);
22
- const usageView = globalThis.ccdxViewBoundary.create("usage-analytics", () => globalThis.ccdxDashboardUsage.create(viewHelpers), ["applyUsage", "renderUsageState", "renderAnalytics", "renderUsageTable", "selectUsageDay", "usageValues", "setChartVisible", "revealChart", "stopMotion"]);
22
+ const usageView = globalThis.ccdxViewBoundary.create("usage-analytics", () => globalThis.ccdxDashboardUsage.create(viewHelpers), ["applyUsage", "renderUsageState", "renderAnalytics", "renderUsageTable", "selectUsageDay", "usageValues", "setChartVisible", "revealChart", "stopMotion", "refreshModelLabels"]);
23
23
  const { applyUsage, renderUsageState, renderAnalytics, renderUsageTable, selectUsageDay } = usageView;
24
24
  const loadAuth = () => dashboardRefresh.refresh("auth", { force: true });
25
25
 
@@ -74,6 +74,13 @@ function tableRow(values, { total = false, labels = [] } = {}) {
74
74
  let providerEntries = [];
75
75
  let usageProviders = {};
76
76
  let selectedProvider = "";
77
+ function usageModelLabel(value) {
78
+ if (typeof value !== "string") return value;
79
+ const at = value.indexOf(" / "), id = value.slice(0, at);
80
+ if (at < 0 || !id.startsWith("api_")) return value;
81
+ const name = providerEntries.find(provider => provider.id === id)?.name;
82
+ return name ? name + value.slice(at) : value;
83
+ }
77
84
  const modelSnapshots = new Map();
78
85
  const providerTabs = new Map();
79
86
  try { selectedProvider = localStorage.getItem("ccdx.dashboard.modelProvider") || ""; } catch { /* Page-local choice still works. */ }
@@ -134,6 +141,7 @@ function applyProviders(data, { changed }) {
134
141
  }
135
142
  if (changed || dashboardRefresh.state("auth").error) renderProviders(data);
136
143
  syncUsageProviders();
144
+ if (sourceChoicesChanged) usageView.refreshModelLabels();
137
145
  const available = providerEntries.some(provider => provider.id === selectedProvider);
138
146
  if (!available) selectedProvider = providerEntries.find(provider => provider.clients?.some(client => client.id === "codex" && client.selected))?.id || providerEntries[0]?.id || "";
139
147
  syncProviderDetails();
@@ -203,6 +211,7 @@ function applyModels(data, { changed }) {
203
211
  for (const model of data.models) {
204
212
  const clients = (model.clients || []).map(id => ({ codex: "Codex App", claude_app: "Claude App", claude_code: "Claude Code" })[id] || id).join(" / ") || "—";
205
213
  const row = tableRow([model.display_name || model.id, clients, ""]);row.children[0].className = "model-name";
214
+ if (model.kind === "image") { const badge = document.createElement("span");badge.className = "model-maker";localize(badge, "image_purpose");row.children[0].append(badge); }
206
215
  if (model.vendor && model.vendor !== "Unknown") { const maker = document.createElement("span");maker.className = "model-maker";maker.textContent = model.vendor;row.children[0].append(maker); }
207
216
  const details = document.createElement("details"), summary = document.createElement("summary"), fields = document.createElement("dl");
208
217
  details.dataset.model = model.id;details.open = expanded.has(model.id);fields.className = "failure-detail";
@@ -7,11 +7,11 @@
7
7
  }).join(" ");
8
8
  }
9
9
 
10
- function create({ time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator, motionAllowed = () => false }) {
10
+ function create({ time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator, modelLabel = value => value, motionAllowed = () => false }) {
11
11
  function usageValues(row) {
12
12
  const rate = Number.isFinite(row.cache_hit_rate) && row.cache_hit_rate >= 0 && row.cache_hit_rate <= 1
13
13
  ? `${row.cache_hit_rate_partial ? "~" : ""}${(row.cache_hit_rate * 100).toFixed(1)}%` : "—";
14
- return [row.model, number(row.requests), number(row.input_tokens), number(row.cache_read_tokens), number(row.cache_write_input_tokens), number(row.output_tokens), number(row.total_tokens), rate];
14
+ return [modelLabel(row.model), number(row.requests), number(row.input_tokens), number(row.cache_read_tokens), number(row.cache_write_input_tokens), number(row.output_tokens), number(row.total_tokens), rate];
15
15
  }
16
16
 
17
17
  let usageData = null;
@@ -117,7 +117,7 @@
117
117
  text("usage-state", day ? day.date : "local_log");
118
118
  text("usage-note", "records_records_shown_of_models_models_shown_day", {
119
119
  records: number(total.requests), shown: number(rows.length), models: number(day ? rows.length : usageData.model_count),
120
- day: day ? phrase("zone_model", { zone: usageData.analytics.time_zone, model: model || phrase("all_models") }) : "",
120
+ day: day ? phrase("zone_model", { zone: usageData.analytics.time_zone, model: model ? modelLabel(model) : phrase("all_models") }) : "",
121
121
  });
122
122
  }
123
123
 
@@ -219,7 +219,7 @@
219
219
  for (const model of [...new Set(["", ...usageData.analytics.models, ...(previous ? [previous] : [])])]) {
220
220
  const option = document.createElement("option");
221
221
  option.value = model;
222
- if (model) option.textContent = model;
222
+ if (model) option.textContent = modelLabel(model);
223
223
  else localize(option, "all_models");
224
224
  select.append(option);
225
225
  }
@@ -239,7 +239,12 @@
239
239
  text("analytics-updated", "updated_time", { time: time(Date.now()) });
240
240
  }
241
241
  }
242
- return { applyUsage, renderUsageState, renderAnalytics, renderUsageTable, selectUsageDay, usageValues, setChartVisible, revealChart, stopMotion, get data() { return usageData; }, get selectedDate() { return selectedUsageDate; } };
242
+ function refreshModelLabels() {
243
+ if (!usageData) return;
244
+ if (usageData.analytics) updateAnalyticsModels();
245
+ renderUsageTable();
246
+ }
247
+ return { applyUsage, renderUsageState, renderAnalytics, renderUsageTable, selectUsageDay, usageValues, setChartVisible, revealChart, stopMotion, refreshModelLabels, get data() { return usageData; }, get selectedDate() { return selectedUsageDate; } };
243
248
  }
244
249
  globalThis.ccdxDashboardUsage = { create, curvePath };
245
250
  })();
@@ -339,8 +339,9 @@ export async function handleDashboardApi(req, res, pathname, {
339
339
  selectable: models.filter(model => model.selectable !== false).length,
340
340
  models: models.slice(0, 500).map((model) => ({
341
341
  id: safeText(model.id, 160),
342
+ ...(model.kind === "image" ? { kind: "image", display_name: safeText(model.display_name || model.id, 160) } : {}),
342
343
  vendor: safeText(model.vendor, 80),
343
- endpoints: Array.isArray(model.endpoints) ? model.endpoints.filter((value) => ["responses", "chat", "messages"].includes(value)) : [],
344
+ endpoints: Array.isArray(model.endpoints) ? model.endpoints.filter((value) => ["responses", "chat", "messages", "images", "image_edits"].includes(value)) : [],
344
345
  preview: model.preview === true,
345
346
  selectable: model.selectable !== false,
346
347
  clients: Array.isArray(model.clients) ? model.clients.filter(value => typeof value === "string").slice(0, 8).map(value => safeText(value, 40)) : [],
package/src/doctor.mjs CHANGED
@@ -13,14 +13,13 @@ import { adapterBaseUrl, checkRunningAdapter } from "./running-adapter.mjs";
13
13
  import { inspectCodexConfig } from "./codex-config-doctor.mjs";
14
14
  import { inspectPackageUpdateEnvironment } from "./package-update.mjs";
15
15
  import { inspectCredentialPermissions } from "./credential-permissions.mjs";
16
- import { imageProviderConfigPath } from "./image-provider-config.mjs";
17
16
  import { terminalCell } from "./terminal-text.mjs";
18
17
  import { redactDiagnosticText } from "./diagnostic-text.mjs";
19
18
  import { inspectWindowsCommand } from "./windows-command.mjs";
20
19
  import { readPredictionSettings } from "./native-prediction-profile.mjs";
21
20
  import { inspectPredictionEnvironment } from "./native-prediction-environment.mjs";
22
21
  import { formatPredictionEnvironment } from "./native-prediction-state.mjs";
23
- import { readImageProviderConfig } from "./image-provider-config.mjs";
22
+ import { imageSetupSummary } from "./image-setup.mjs";
24
23
  import { inspectAdapterCompatibility } from "./doctor-compat.mjs";
25
24
  import { readProviderSettings } from "./provider-settings.mjs";
26
25
  export { selectCompatibilityModels, inspectAdapterCompatibility } from "./doctor-compat.mjs";
@@ -197,7 +196,7 @@ export async function collectDoctorChecks({
197
196
  inspectWindowsCommandFn = inspectWindowsCommand,
198
197
  readPredictionSettingsFn = readPredictionSettings,
199
198
  inspectPredictionEnvironmentFn = inspectPredictionEnvironment,
200
- readImageProviderConfigFn = readImageProviderConfig,
199
+ readImageProviderConfigFn = imageSetupSummary,
201
200
  providerControlFn,
202
201
  } = {}) {
203
202
  if (configOnly) return inspectCodexConfig({ home, env, host, port });
@@ -227,7 +226,7 @@ export async function collectDoctorChecks({
227
226
  } catch { checks.push({ kind: "warn", message: "Prediction environment could not be verified; existing routing and trust settings preserved", fix: "ccdx app codex prediction status" }); }
228
227
  try {
229
228
  const image = readImageProviderConfigFn({ home, env, strict: true });
230
- checks.push({ kind: "info", message: image ? "Image generation configured; no provider request was made" : "Image generation is off; optional checks skipped" });
229
+ checks.push({ kind: "info", message: image?.configured ? "Native images use GitHub Copilot; no provider request was made" : "Native images need GitHub Copilot access" });
231
230
  } catch { checks.push({ kind: "warn", message: "Image provider configuration is invalid; core service is unaffected", fix: "ccdx app codex image status" }); }
232
231
  const updateEnvironment = inspectUpdateEnvironmentFn();
233
232
  const updateMessage = updateEnvironment.state === "different" ? "npm update target differs from this CCDX installation; review PATH/prefix before updating"
@@ -237,7 +236,7 @@ export async function collectDoctorChecks({
237
236
  .filter(key => updateEnvironment[key]).map(key => `${key}=${terminalCell(updateEnvironment[key])}`).join(" / ");
238
237
  checks.push({ kind: updateEnvironment.state === "different" || updateEnvironment.state === "unavailable" ? "warn" : "ok",
239
238
  message: `${updateMessage}${updatePaths ? ` / ${updatePaths}` : ""}` });
240
- for (const [label, file] of [["GitHub token", githubTokenPath(home)], ["Image API key", imageProviderConfigPath({ home })]]) {
239
+ for (const [label, file] of [["GitHub token", githubTokenPath(home)]]) {
241
240
  const permissions = inspectCredentialPermissionsFn(file);
242
241
  if (permissions === "missing") continue;
243
242
  checks.push({ kind: permissions === "review" || permissions === "unavailable" ? "warn" : "ok",
@@ -0,0 +1,20 @@
1
+ import { modelDisplayName } from "./model-display.mjs";
2
+
3
+ export const DEFAULT_IMAGE_MODEL = "gpt-image-2.5-flare";
4
+ const paths = { generations: ["/images/generations", "/v1/images/generations"], edits: ["/images/edits", "/v1/images/edits"] };
5
+ export function isImageModel(model) {
6
+ return model?.capabilities?.type === "image";
7
+ }
8
+ export function imageModelCatalog(value) {
9
+ const models = Array.isArray(value) ? value : value?.data;
10
+ if (!Array.isArray(models)) return [];
11
+ return models.filter(model => isImageModel(model) && Array.isArray(model.supported_endpoints) && paths.generations.some(path => model.supported_endpoints?.includes(path)) && (!model.policy?.state || model.policy.state === "enabled")
12
+ && typeof model.id === "string" && model.id.length > 0 && model.id.length <= 200 && !/[\x00-\x1f\x7f]/.test(model.id))
13
+ .map(model => ({ id: model.id, name: modelDisplayName(model), source: "github", kind: "image",
14
+ editing: paths.edits.some(path => model.supported_endpoints?.includes(path)) }));
15
+ }
16
+ export function imageModelSelection(models, saved) {
17
+ const selected = saved || models.find(model => model.id === DEFAULT_IMAGE_MODEL)?.id || models[0]?.id || null;
18
+ return { models, selected_model: selected, selection_source: saved ? "saved" : "default",
19
+ selected_available: Boolean(selected && models.some(model => model.id === selected)) };
20
+ }
@@ -0,0 +1,33 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import { codexPaths } from "./codex-paths.mjs";
5
+ import { withFileLockSync } from "./lock.mjs";
6
+ import { atomicWriteFileIfChangedSync } from "./atomic-file.mjs";
7
+ import { computeImageMcpCodexConfig } from "./config.mjs";
8
+ import { parseCodexToml } from "./config-toml.mjs";
9
+ import { removeLegacyImageGuidance } from "./legacy-image-guidance.mjs";
10
+
11
+ export function legacyImageProviderPath({ env = process.env, home = os.homedir() } = {}) {
12
+ return path.join(String(env.XDG_CONFIG_HOME || "").trim() || path.join(home, ".config"), "codex-copilot-dx", "image-provider.json");
13
+ }
14
+
15
+ export function retireLegacyImages({ env = process.env, home = os.homedir(), codexPath = codexPaths({ env, home }).config,
16
+ adapterPort = 2026, adapterHost = "127.0.0.1" } = {}) {
17
+ const providerPath = legacyImageProviderPath({ env, home });
18
+ const credentialRemoved = fs.existsSync(providerPath);
19
+ fs.rmSync(providerPath, { force: true });
20
+ const guidance = removeLegacyImageGuidance({ codexPath });
21
+ let configChanged = false, preservedMcp = false;
22
+ if (fs.existsSync(codexPath)) withFileLockSync(`${codexPath}.ccdx.lock`, () => {
23
+ const before = new TextDecoder("utf-8", { fatal: true }).decode(fs.readFileSync(codexPath));
24
+ const config = computeImageMcpCodexConfig(before, { enabled: false, adapterPort, adapterHost });
25
+ if (config.changed) {
26
+ if (fs.readFileSync(codexPath, "utf8") !== before) throw new Error("Codex configuration changed during image retirement");
27
+ atomicWriteFileIfChangedSync(codexPath, config.content);configChanged = true;
28
+ }
29
+ preservedMcp = Boolean(parseCodexToml(config.content).mcp_servers?.ccdx_image);
30
+ });
31
+ return { changed: credentialRemoved || configChanged || guidance.changed, credentialRemoved, configChanged,
32
+ preserved: preservedMcp || Boolean(guidance.preserved), preservedMcp, preservedGuidance: Boolean(guidance.preserved) };
33
+ }