codex-copilot-dx 1.3.13 → 1.3.15

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 (60) hide show
  1. package/README.md +2 -2
  2. package/bin/cli.mjs +7 -10
  3. package/bin/codex-image-host.mjs +11 -0
  4. package/docs/ARCHITECTURE.md +9 -6
  5. package/docs/REFERENCE.md +26 -37
  6. package/package.json +1 -1
  7. package/src/access-settings.mjs +2 -1
  8. package/src/adapter.mjs +14 -4
  9. package/src/claude-capability-config.mjs +5 -4
  10. package/src/claude-client-config.mjs +5 -3
  11. package/src/claude-models.mjs +3 -1
  12. package/src/cli-command-spec.mjs +4 -11
  13. package/src/cli-image.mjs +24 -180
  14. package/src/cli-management.mjs +21 -6
  15. package/src/cli-options.mjs +1 -1
  16. package/src/cli-secret.mjs +39 -0
  17. package/src/cli-tools.mjs +1 -1
  18. package/src/client-integration.mjs +17 -12
  19. package/src/client-model-plan.mjs +3 -1
  20. package/src/clients/claude-models.mjs +3 -3
  21. package/src/codex-image-host-launch.mjs +38 -0
  22. package/src/codex-image-host.mjs +216 -0
  23. package/src/config.mjs +9 -54
  24. package/src/connection-runtime.mjs +24 -3
  25. package/src/copilot-client.mjs +16 -1
  26. package/src/dashboard/connections.js +41 -10
  27. package/src/dashboard/console.js +6 -4
  28. package/src/dashboard/features.js +19 -29
  29. package/src/dashboard/index.html +3 -3
  30. package/src/dashboard/language.js +8 -7
  31. package/src/dashboard/ui.css +6 -0
  32. package/src/dashboard/ui.js +11 -2
  33. package/src/dashboard/usage.js +10 -5
  34. package/src/dashboard-api.mjs +2 -1
  35. package/src/doctor.mjs +4 -5
  36. package/src/image-models.mjs +20 -0
  37. package/src/image-retirement.mjs +33 -0
  38. package/src/image-setup.mjs +16 -105
  39. package/src/launcher.mjs +7 -4
  40. package/src/legacy-image-guidance.mjs +73 -0
  41. package/src/live-models.mjs +2 -1
  42. package/src/model-capabilities.mjs +9 -0
  43. package/src/native-images.mjs +111 -0
  44. package/src/observability.mjs +2 -0
  45. package/src/optional-routes.mjs +4 -13
  46. package/src/prediction-control.mjs +1 -0
  47. package/src/provider-metadata.mjs +5 -4
  48. package/src/provider-runtime.mjs +2 -1
  49. package/src/service-control.mjs +6 -7
  50. package/src/service-worker.mjs +2 -2
  51. package/src/image-mcp.mjs +0 -328
  52. package/src/image-provider-config.mjs +0 -194
  53. package/src/image-provider.mjs +0 -369
  54. package/src/image-readiness.mjs +0 -55
  55. package/src/image-references.mjs +0 -50
  56. package/src/image-skill/SKILL.md +0 -28
  57. package/src/image-skill/references/editing.md +0 -15
  58. package/src/image-skill/references/helper.md +0 -27
  59. package/src/image-skill.mjs +0 -142
  60. package/src/image-tool-client.mjs +0 -150
package/src/cli-image.mjs CHANGED
@@ -1,183 +1,27 @@
1
- import { fileContent, enableImageProvider, disableImageProvider } from "./image-setup.mjs";
2
- export { syncEnabledImageSkill } from "./image-setup.mjs";
3
- import os from "node:os";
4
- import readline from "node:readline";
5
- import { createInterface } from "node:readline/promises";
6
- import { codexPaths } from "./codex-paths.mjs";
7
1
  import { terminalCell } from "./cli-table.mjs";
8
- import { probeImageTool } from "./image-readiness.mjs";
9
- import { servicePreferences, writeServicePreference } from "./user-settings.mjs";
10
- import {
11
- imageProviderConfigPath,
12
- inspectImageProvider,
13
- normalizeImageEndpoint,
14
- readImageProviderConfig,
15
- } from "./image-provider-config.mjs";
16
- async function visibleQuestion(input, output, question) {
17
- const prompt = createInterface({ input, output });
18
- try { return await prompt.question(question); }
19
- finally { prompt.close(); }
20
- }
21
-
22
- export function hiddenQuestion(input, output, question, { cancelMessage = "Image provider setup cancelled" } = {}) {
23
- if (!input?.isTTY || !output?.isTTY || typeof input.setRawMode !== "function") {
24
- return Promise.reject(new Error("Hidden API key input requires an interactive terminal"));
25
- }
26
- output.write(question);
27
- const wasRaw = Boolean(input.isRaw);
28
- readline.emitKeypressEvents(input);
29
- input.setRawMode(true);
30
- input.resume();
31
- let value = "";
32
- return new Promise((resolve, reject) => {
33
- const cleanup = () => {
34
- input.off("keypress", onKeypress);
35
- input.setRawMode(wasRaw);
36
- if (!wasRaw) input.pause();
37
- output.write("\n");
38
- };
39
- const onKeypress = (text, key = {}) => {
40
- if (key.ctrl && key.name === "c") {
41
- cleanup();
42
- reject(new Error(cancelMessage));
43
- return;
44
- }
45
- if (key.name === "return" || key.name === "enter") {
46
- cleanup();
47
- resolve(value);
48
- return;
49
- }
50
- if (key.name === "backspace" || key.name === "delete") {
51
- value = value.slice(0, -1);
52
- return;
53
- }
54
- if (!key.ctrl && !key.meta && typeof text === "string" && text >= " " && text !== "\x7f") value += text;
55
- };
56
- input.on("keypress", onKeypress);
57
- });
58
- }
59
-
60
- function chooseModelLines(modelIds, selected) {
61
- return modelIds.map((model, index) => ` ${index + 1}. ${terminalCell(model)}${model === selected ? " [current]" : ""}`);
62
- }
63
-
64
- async function chooseModel(modelIds, current, ask, output) {
65
- if (modelIds.length === 1) return modelIds[0];
66
- const currentIndex = Math.max(0, modelIds.indexOf(current));
67
- output.write("Available image models:\n");
68
- output.write(`${chooseModelLines(modelIds, current).join("\n")}\n`);
69
- while (true) {
70
- const answer = String(await ask(`Select [${currentIndex + 1}]: `) || "").trim();
71
- if (!answer) return modelIds[currentIndex];
72
- const selected = Number(answer) - 1;
73
- if (Number.isInteger(selected) && selected >= 0 && selected < modelIds.length) return modelIds[selected];
74
- output.write(`Enter a number from 1 to ${modelIds.length}.\n`);
75
- }
76
- }
77
-
78
- function configSummary(config) {
79
- const endpoint = new URL(config.endpoint);
80
- return {
81
- endpoint: `${endpoint.origin}${endpoint.pathname}`,
82
- model: config.model,
83
- protocol: config.protocol,
84
- };
85
- }
86
-
87
- function printImageReadiness(readiness, output, commandName) {
88
- if (readiness.ready) {
89
- output.write("Local image service: ready (generation tool verified; no image generated).\n");
90
- output.write(`Generate: available\nEdit: ${readiness.editing ? "available" : "not advertised"}\n`);
91
- }
92
- else output.write(`Local image service: unavailable (${readiness.reason}). Start or restart ${commandName} to use images.\n`);
93
- }
94
-
95
- export async function runImageCommand({
96
- action,
97
- commandName = "ccdx",
98
- env = process.env,
99
- home = os.homedir(),
100
- input = process.stdin,
101
- output = process.stdout,
102
- prompt,
103
- promptSecret,
104
- fetchImpl = fetch,
105
- probeFetchImpl = fetch,
106
- adapterPort = 2026,
107
- adapterHost = "127.0.0.1",
108
- codexPath = codexPaths({ env, home }).config,
109
- } = {}) {
110
- const providerPath = imageProviderConfigPath({ env, home });
111
- if (action === "status") {
112
- const config = readImageProviderConfig({ env, home, strict: true });
113
- if (!config) {
114
- output.write("Image generation: disabled\n");
115
- return { enabled: false };
116
- }
117
- const summary = configSummary(config);
118
- output.write(`Image generation: enabled\nEndpoint: ${terminalCell(summary.endpoint)}\nModel: ${terminalCell(summary.model)}\nProtocol: ${terminalCell(summary.protocol)}\n`);
119
- if (!servicePreferences({ env, home }).image_enabled) output.write("New image calls: paused by the WebUI preference; provider configuration is retained.\n");
120
- const readiness = await probeImageTool(fileContent(codexPath), { fetchImpl: probeFetchImpl });
121
- printImageReadiness(readiness, output, commandName);
122
- return { enabled: true, ...summary, readiness };
2
+ import { imageSetupSummary } from "./image-setup.mjs";
3
+ import { dashboardToolRequest, pauseServiceFeature } from "./cli-tools.mjs";
4
+
5
+ export async function runImageCommand({ action, model, output = process.stdout, home, env = process.env,
6
+ adapterPort = 2026, adapterHost = "127.0.0.1", request = dashboardToolRequest } = {}) {
7
+ if (!["status", "models", "enable", "disable", "select"].includes(action)) throw new Error("Choose image status, models, enable, disable or select --id MODEL");
8
+ const local = { home, env }, address = { port: adapterPort, host: adapterHost };
9
+ if (["enable", "disable"].includes(action)) output.write(await pauseServiceFeature({ ...local, ...address, feature: "image", action: action === "enable" ? "resume" : "pause", request }) + "\n");
10
+ let result;
11
+ try {
12
+ if (action === "select" && !model) throw new Error("Supply --id with an available image model ID");
13
+ const data = await request({ ...address, path: "settings", timeoutMs: action === "status" ? 1000 : 5000,
14
+ ...(action === "select" ? { body: { action: "image", operation: "select", model } } : {}) });
15
+ result = data.features.image;
16
+ } catch (error) {
17
+ if (["models", "select"].includes(action)) throw error;
18
+ result = imageSetupSummary(local);
123
19
  }
124
-
125
- const codexContent = fileContent(codexPath);
126
- if (action === "disable") {
127
- const result = disableImageProvider({ providerPath, codexPath, codexContent, adapterPort, adapterHost });
128
- output.write(`${result.changed ? "Disabled" : "Kept disabled"} image generation.\n`);
129
- output.write(result.preservedGuidance
130
- ? "Kept user-modified image guidance. Existing image tool calls are now disabled.\n"
131
- : "Removed CCDX image guidance. Existing image tool calls are now disabled.\n");
132
- return { enabled: false, ...result };
133
- }
134
- if (action !== "enable") throw new Error(`Unknown image command action: ${action}`);
135
- if (!prompt && (!input.isTTY || !output.isTTY)) {
136
- throw new Error(`${commandName} app codex image setup requires an interactive terminal`);
137
- }
138
-
139
- const current = readImageProviderConfig({ env, home });
140
- const ask = prompt || ((question) => visibleQuestion(input, output, question));
141
- const askSecret = promptSecret || ((question) => hiddenQuestion(input, output, question));
142
- output.write(`${commandName} app codex image setup\n`);
143
- output.write("Enter an HTTPS base URL (for example, https://api.example/v1) or a full /images/generations endpoint.\n");
144
- const endpointAnswer = String(await ask(`Image service URL${current ? ` [${current.endpoint}]` : ""}: `) || "").trim();
145
- if (!endpointAnswer && !current?.endpoint) throw new Error("Image API base URL or endpoint is required");
146
- const endpoint = normalizeImageEndpoint(endpointAnswer || current.endpoint);
147
- const sameOrigin = current && new URL(endpoint).origin === new URL(current.endpoint).origin;
148
- const keyAnswer = String(await askSecret(`API key${sameOrigin ? " [Enter to keep current]" : current ? " [new origin; enter a key]" : ""}: `) || "").trim();
149
- const apiKey = keyAnswer || (sameOrigin ? current.api_key : undefined);
150
- if (!apiKey) throw new Error("Image API key is required");
151
-
152
- output.write("Checking image API...\n");
153
- let model;
154
- const inspected = await inspectImageProvider({
155
- endpoint, apiKey, fetchImpl,
156
- selectModel: async (modelIds) => {
157
- model = await chooseModel(modelIds, current?.model, ask, output);
158
- return model;
159
- },
160
- });
161
- const result = enableImageProvider({
162
- providerConfig: {
163
- endpoint: inspected.endpoint,
164
- api_key: apiKey,
165
- model,
166
- protocol: inspected.protocol,
167
- },
168
- providerPath,
169
- codexPath,
170
- // Prompts and provider validation may take minutes. Merge into the latest
171
- // shared file rather than replacing edits made while we were waiting.
172
- codexContent: fileContent(codexPath),
173
- adapterPort,
174
- adapterHost,
175
- });
176
- if (!servicePreferences({ env, home }).image_enabled) writeServicePreference("image_enabled", true, { env, home });
177
- output.write(`Enabled image generation with ${terminalCell(model)}.\n`);
178
- const readiness = await probeImageTool(fileContent(codexPath), { fetchImpl: probeFetchImpl });
179
- printImageReadiness(readiness, output, commandName);
180
- output.write("Installed CCDX image guidance for new and existing tasks. Ask Codex to draw an image.\n");
181
- output.write("If the open task has not refreshed its skills, restart Codex App once.\n");
182
- return { enabled: true, ...configSummary(result.config), codexChanged: result.codexChanged, readiness };
20
+ output.write(`Native Codex images: ${!result.enabled ? "disabled" : result.configured ? "enabled" : "needs GitHub access"}\n`);
21
+ output.write(`Image model: ${terminalCell(result.selected_model || "Automatic; catalog unavailable")}\n`);
22
+ if (result.availability === "selected_unavailable") output.write("Saved image model is unavailable; choose an available model.\n");
23
+ for (const item of result.models || []) output.write(`${item.id === result.selected_model ? "*" : " "} ${terminalCell(item.name || item.id)} (${terminalCell(item.id)})\n`);
24
+ if (!result.models?.length) output.write("Read the GitHub catalog in Model sources or use source github models --refresh.\n");
25
+ output.write("Uses Codex native host tools and the existing GitHub account. Start Codex through CCDX, then use a new chat.\n");
26
+ return result;
183
27
  }
@@ -8,7 +8,7 @@ import { formatResponsiveCliTable, cliOutputWidth, terminalCell } from "./cli-ta
8
8
  import { redactDiagnosticText } from "./diagnostic-text.mjs";
9
9
  import { settingsPreferencesSnapshot, writeSettingsPreferences, checkedPreferenceValues } from "./settings-preferences.mjs";
10
10
  import { checkedApi } from "./access-settings.mjs";
11
- import { hiddenQuestion } from "./cli-image.mjs";
11
+ import { hiddenQuestion } from "./cli-secret.mjs";
12
12
  import { readBoundedFileSync } from "./bounded-file.mjs";
13
13
  import { deploymentModelId } from "./model-capabilities.mjs";
14
14
  import { TERMINAL_COLOR_THEMES } from "./terminal-colors.mjs";
@@ -89,7 +89,7 @@ export async function runManagementCommand(command, options = {}) {
89
89
  const getClient = (graph, id) => { const client = graph.clients.find(item => item.id === id);if (!client) throw new Error("Client is not registered.");return client; };
90
90
  const getSource = (graph, id) => { const source = graph.providers.find(item => item.id === id);if (!source) throw new Error("Source is not registered.");return source; };
91
91
  const clientBody = client => ({ operation: "client", id: client.id, client_revision: client.revision, enabled: client.enabled, allowed: client.allowed, source: client.source,
92
- ...(Array.isArray(client.deployments) ? { deployments: client.deployments, default_model: client.default_model, auto_sync: client.auto_sync } : {}) });
92
+ ...(Array.isArray(client.deployments) ? { deployments: client.deployments, default_model: client.default_model, auto_sync: client.auto_sync, ...(client.image_model ? { image_model: client.image_model } : {}) } : {}) });
93
93
  const readFile = () => JSON.parse(readBoundedFileSync(flags.file, { encoding: "utf8", maxBytes: 256 * 1024 }));
94
94
  if (group === "status") {
95
95
  const { data, baseUrl } = await readStatus();
@@ -205,13 +205,15 @@ export async function runManagementCommand(command, options = {}) {
205
205
  if (action === "models" && !flags.edit) {
206
206
  if (flags.format === "json") return print(modelPlan);
207
207
  return print([...(modelPlan?.models || []).map(model => ({ source: model.source, model: model.display_name || model.id, id: model.id, state: "Selected", default: [model.route_id, model.public_id].includes(modelPlan.default_model) })),
208
+ ...(id === "codex" ? (modelPlan?.image?.models || []).map(model => ({ source: "github", model: model.name, id: model.id, state: modelPlan.image.selected_model === model.id ? "Selected image" : "Image", default: false })) : []),
209
+ ...(id === "codex" && modelPlan?.image?.selected_model && !modelPlan.image.selected_available ? [{ source: "github", model: modelPlan.image.selected_model, id: modelPlan.image.selected_model, state: "Image unavailable; retained", default: false }] : []),
208
210
  ...(modelPlan?.unavailable || []).map(model => ({ source: model.source, model: model.id, id: model.id, state: !client.enabled && modelPlan?.available.some(item => item.source === model.source && item.id === model.id) ? "Retained; access disabled" : "Unavailable; retained", default: model.route_id === modelPlan.default_model }))], [["model", "Model"], ["source", "Source"], ["state", "Selection"], ["default", "Default"]]);
209
211
  }
210
212
  if (action === "sync") {
211
- const preview = { client: ids.app, models: modelPlan?.models.map(model => ({ source: model.source, model: model.display_name || model.id, id: model.id, context_window: model.capability?.values.context_window ?? null, reasoning_efforts: model.capability?.values.reasoning_efforts ?? null })), unavailable: modelPlan?.unavailable, default_model: modelPlan?.default_model,
213
+ const preview = { client: ids.app, models: modelPlan?.models.map(model => ({ source: model.source, model: model.display_name || model.id, id: model.id, context_window: model.capability?.values.context_window ?? null, reasoning_efforts: model.capability?.values.reasoning_efforts ?? null })), unavailable: modelPlan?.unavailable, default_model: modelPlan?.default_model, image: modelPlan?.image,
212
214
  current_setup: clientSetup(client), note: "Model/configuration plan only, not a byte-level file diff. Ownership is rechecked on sync; no App is restarted." };
213
215
  if (flags.preview) return print(preview);output.write(print(preview) + "\n");await confirm("Write CCDX-owned client settings now?");
214
- const result = await save({ operation: "sync_client", id, client_revision: client.revision });return print({ client: ids.app, setup: getClient(result, id).setup, app_adoption: "Not verified by writing configuration" });
216
+ const result = await save({ operation: "sync_client", id, client_revision: client.revision });return print({ client: ids.app, setup: getClient(result, id).setup, image: getClient(result, id).model_plan?.image, app_adoption: "Not verified by writing configuration" });
215
217
  }
216
218
  if (["enable", "disable"].includes(action)) {
217
219
  const enabled = action === "enable", preview = { client: ids.app, access: enabled ? "Enabled" : "Disabled", retained_source: client.source,
@@ -224,7 +226,7 @@ export async function runManagementCommand(command, options = {}) {
224
226
  const body = clientBody(client);
225
227
  if (action === "models") {
226
228
  if (flags.file) {
227
- const file = readFile();if (Object.keys(file).some(key => !["deployments", "default_model", "auto_sync"].includes(key))) throw new Error("Model files allow deployments, default_model and auto_sync only.");
229
+ const file = readFile();if (Object.keys(file).some(key => !["deployments", "default_model", "auto_sync", "image_model"].includes(key))) throw new Error("Model files allow deployments, default_model, auto_sync and image_model only.");
228
230
  if (!Array.isArray(file.deployments)) throw new Error("Model files require an explicit deployments array; use [] to pause access.");
229
231
  Object.assign(body, file);if (!body.deployments.length) body.default_model = null;
230
232
  } else {
@@ -241,6 +243,13 @@ export async function runManagementCommand(command, options = {}) {
241
243
  body.default_model = defaults[value ? Number(value) - 1 : Math.max(0, defaults.indexOf(body.default_model))];
242
244
  } else body.default_model = null;
243
245
  }
246
+ if (id === "codex" && !flags.file && modelPlan?.image?.models?.length) {
247
+ const images = modelPlan.image.models, current = images.findIndex(model => model.id === modelPlan.image.selected_model);
248
+ output.write(images.map((model, i) => `${i + 1} ${model.name || model.id} [Image]`).join("\n") + "\n");
249
+ const answer = (await ask(`Image model number [${Math.max(1, current + 1)}]: `)).trim();
250
+ if (answer && (!/^\d+$/.test(answer) || Number(answer) < 1 || Number(answer) > images.length)) throw new Error("Choose a listed image model number.");
251
+ body.image_model = images[answer ? Number(answer) - 1 : Math.max(0, current)].id;
252
+ }
244
253
  if (body.deployments?.some(item => modelPlan?.unavailable.some(row => row.source === item.source && row.id === item.model))) throw new Error("Unavailable selections were kept. Wait for the catalog or explicitly deselect them before saving a changed plan.");
245
254
  } else throw new Error("Unsupported client action.");
246
255
  const memory = id === "codex" ? client.memory_model?.model : null;
@@ -250,11 +259,17 @@ export async function runManagementCommand(command, options = {}) {
250
259
  if (memory && (client.deployments || modelPlan?.models || []).some(memoryMatch) && Array.isArray(body.deployments) && !body.deployments.some(memoryMatch)) {
251
260
  output.write(`Warning: ${terminalCell(memory)} is an observed memory dependency; memory writing may fail if it is unselected.\n`);
252
261
  }
262
+ const previousModels = client.deployments || modelPlan?.models.map(model => ({ source: model.source, model: model.id })) || [];
263
+ const previousKeys = new Set(previousModels.map(item => item.source + "\0" + item.model));
264
+ const previousDefault = client.default_model || modelPlan?.models.find(model => model.public_id === modelPlan.default_model)?.route_id || null;
265
+ const imageOnly = id === "codex" && body.image_model && body.image_model !== modelPlan?.image?.selected_model
266
+ && body.deployments?.length === previousKeys.size && body.deployments.every(item => previousKeys.has(item.source + "\0" + item.model))
267
+ && body.default_model === previousDefault && (body.auto_sync !== false) === (client.auto_sync !== false);
253
268
  const checked = await save({ ...body, operation: "preview_client" });
254
269
  output.write(print({ client: ids.app, planned_models: checked.preview?.models.map(model => ({ source: model.source, id: model.id })), change: action, enabled: body.enabled, deployments: body.deployments, default_model: body.default_model }) + "\n");
255
270
  if (flags.preview) return "Preview only; no settings changed.";
256
271
  await confirm(body.enabled ? "Save this client selection?" : "Disable gateway access? Later turns may fail; the client program stays open.");
257
- const result = await save(body);return print({ client: ids.app, setup: getClient(result, id).setup, saved: true, app_adoption: "Not verified" });
272
+ const result = await save(imageOnly ? { operation: "image_model", id: "codex", model: body.image_model, client_revision: client.revision } : body);return print({ client: ids.app, setup: getClient(result, id).setup, saved: true, app_adoption: "Not verified" });
258
273
  }
259
274
  if (group !== "source") throw new Error("Unknown management command.");
260
275
  let graph = await connection();
@@ -94,7 +94,7 @@ const integrationNotes = {
94
94
  prediction:
95
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
- "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.",
97
+ "Native images use the existing GitHub account. Use status or models to inspect, enable/disable to switch image requests, and select --id MODEL to choose an available image model. Manual image API setup is retired.",
98
98
  review:
99
99
  "Select an available model and reasoning level. Enter keeps the choice; q cancels without saving. The next review request uses the saved choice.",
100
100
  doctor:
@@ -0,0 +1,39 @@
1
+ import readline from "node:readline";
2
+
3
+ export function hiddenQuestion(input, output, question, { cancelMessage = "API setup cancelled" } = {}) {
4
+ if (!input?.isTTY || !output?.isTTY || typeof input.setRawMode !== "function") {
5
+ return Promise.reject(new Error("Hidden API key input requires an interactive terminal"));
6
+ }
7
+ output.write(question);
8
+ const wasRaw = Boolean(input.isRaw);
9
+ readline.emitKeypressEvents(input);
10
+ input.setRawMode(true);
11
+ input.resume();
12
+ let value = "";
13
+ return new Promise((resolve, reject) => {
14
+ const cleanup = () => {
15
+ input.off("keypress", onKeypress);
16
+ input.setRawMode(wasRaw);
17
+ if (!wasRaw) input.pause();
18
+ output.write("\n");
19
+ };
20
+ const onKeypress = (text, key = {}) => {
21
+ if (key.ctrl && key.name === "c") {
22
+ cleanup();
23
+ reject(new Error(cancelMessage));
24
+ return;
25
+ }
26
+ if (key.name === "return" || key.name === "enter") {
27
+ cleanup();
28
+ resolve(value);
29
+ return;
30
+ }
31
+ if (key.name === "backspace" || key.name === "delete") {
32
+ value = value.slice(0, -1);
33
+ return;
34
+ }
35
+ if (!key.ctrl && !key.meta && typeof text === "string" && text >= " " && text !== "\x7f") value += text;
36
+ };
37
+ input.on("keypress", onKeypress);
38
+ });
39
+ }
package/src/cli-tools.mjs CHANGED
@@ -22,5 +22,5 @@ export async function pauseServiceFeature({ feature, action, home, env = process
22
22
  writeServicePreference(key, value, { home, env });
23
23
  let applied = false;
24
24
  try { await request({ host, port, path: "settings", body: { action: "preference", key, value } });applied = true; } catch {}
25
- return `${feature === "image" ? "Image requests" : "Prediction adaptation"}: ${value ? "resumed" : "paused"}. Setup and credentials kept.${applied ? "" : " Start or restart CCDX to apply."}`;
25
+ return `${feature === "image" ? "Image requests" : "Prediction adaptation"}: ${value ? "resumed" : "paused"}. ${feature === "image" ? "GitHub account and model selection kept." : "Setup and credentials kept."}${applied ? "" : " Start or restart CCDX to apply."}`;
26
26
  }
@@ -1,5 +1,6 @@
1
+ import { servicePreferences } from "./user-settings.mjs";
1
2
  import { ensureCodexConfig } from "./config.mjs";
2
- import { readImageProviderConfig } from "./image-provider-config.mjs";
3
+ import { retireLegacyImages } from "./image-retirement.mjs";
3
4
  import { ensureCodexThreadCompression } from "./codex-thread-compression.mjs";
4
5
  import { runInBackground } from "./startup.mjs";
5
6
  import { createPredictionState } from "./native-prediction-state.mjs";
@@ -52,25 +53,29 @@ export function createClientIntegration({ port, host, info = () => {}, warning =
52
53
  operation = Promise.resolve().then(task).finally(() => { operation = null;operationName = null; });
53
54
  return operation;
54
55
  }
56
+ function retireImages() {
57
+ try {
58
+ const retired = retireLegacyImages({ adapterPort: port, adapterHost: host });
59
+ if (retired.preserved) warning("User-modified legacy image files were preserved; review them manually. The old image service is retired.");
60
+ } catch { warning("Legacy image cleanup was incomplete; review the old image files before the next CCDX start. The old image service is retired."); }
61
+ }
55
62
  return {
63
+ async imageHostLaunch(options = {}) {
64
+ try { return await (await import("./codex-image-host-launch.mjs")).prepareImageHostLaunch({ host, port, ...options }); }
65
+ catch (error) { warning(error.message);return null; }
66
+ },
67
+ retireImages,
56
68
  async configure() {
57
69
  try {
58
70
  const { retirePredictionIntegration } = await import("./prediction-retirement.mjs");
59
71
  retirePredictionIntegration();
60
72
  } catch { /* Legacy cleanup is optional; never interrupt or clutter core startup. */ }
61
- const enabled = Boolean(readImageProviderConfig());
62
- let imageMcpSkipped;
63
73
  try {
64
- const result = ensureCodexConfig(port, { host, imageProviderEnabled: enabled, ...(configLog ? { log: configLog } : {}) });
65
- imageMcpSkipped = result.imageMcpSkipped;codexSetup = { setup: result.coreSetup, checked_at: new Date().toISOString() };
74
+ const result = ensureCodexConfig(port, { host, ...(configLog ? { log: configLog } : {}) });
75
+ codexSetup = { setup: result.coreSetup, checked_at: new Date().toISOString() };
66
76
  } catch (error) { codexSetup = { setup: "configuration_unavailable", checked_at: new Date().toISOString() };throw error; }
67
- if (enabled && !imageMcpSkipped) {
68
- try {
69
- const { syncEnabledImageSkill } = await import("./cli-image.mjs");
70
- syncEnabledImageSkill({ adapterPort: port, adapterHost: host });
71
- } catch (error) { warning(`Image guidance could not be updated: ${error.message}`); }
72
- }
73
- return { imageEnabled: enabled, imageMcpSkipped, compressionSetup: runInBackground(ensureCodexThreadCompression) };
77
+ retireImages();
78
+ return { imageEnabled: servicePreferences().image_enabled, imageMcpSkipped: false, compressionSetup: runInBackground(ensureCodexThreadCompression) };
74
79
  },
75
80
  start({ autoSetup = true } = {}) { return serialize("start", async () => {
76
81
  try {
@@ -1,3 +1,4 @@
1
+ import { isImageModel } from "./image-models.mjs";
1
2
  import { deploymentModelId, resolveModelCapabilities } from "./model-capabilities.mjs";
2
3
  import { claudeModelEntries } from "./claude-models.mjs";
3
4
  import { claudeDeploymentId, claudeRouteAliases } from "./clients/claude-models.mjs";
@@ -10,6 +11,7 @@ export function clientModelExclusion({ client, binding, sourceId, sourceEnabled,
10
11
  if (!binding.allowed.includes(sourceId)) return "source_not_allowed";
11
12
  if (!model) return "model_missing";
12
13
  if (["restricted", "hidden"].includes(model.state)) return "source_restricted";
14
+ if (model.kind === "image") return client === "codex" && sourceId === "github" && model.endpoints.includes("images") ? selected ? null : "model_not_selected" : "protocol_unsupported";
13
15
  const protocol = client === "codex" ? "responses" : "messages";
14
16
  if (!model.endpoints.includes(protocol) && !(client === "codex" && sourceId === "github" && model.endpoints.includes("chat"))) return "protocol_unsupported";
15
17
  return selected ? null : "model_not_selected";
@@ -17,7 +19,7 @@ export function clientModelExclusion({ client, binding, sourceId, sourceEnabled,
17
19
  export function sourceModels(source, client) {
18
20
  if (!source) return [];
19
21
  const models = source.models?.(client === "codex" ? "gpt" : "claude") || source.registry?.models?.data || [];
20
- return models.filter(model => model.supported_endpoints?.some(endpoint => endpoints[client].includes(endpoint)
22
+ return models.filter(model => !isImageModel(model) && model.supported_endpoints?.some(endpoint => endpoints[client].includes(endpoint)
21
23
  || client === "codex" && source.id === "github" && ["/chat/completions", "/v1/chat/completions"].includes(endpoint)))
22
24
  .map(model => model.protocol_capabilities ? { ...model, capability: model.protocol_capabilities[client === "codex" ? "responses" : "messages"] } : model);
23
25
  }
@@ -1,13 +1,13 @@
1
1
  import { claudeModelEntries } from "../claude-models.mjs";
2
- import { claudeEffortsExpressible } from "../model-capabilities.mjs";
2
+ import { claudeEffortPrefix } from "../model-capabilities.mjs";
3
3
 
4
4
  export function claudeDeploymentId(model, route, { desktopEffortAliases = false } = {}) {
5
5
  const number = route.slice("ccdx/model-".length);
6
6
  const native = /^claude-(?:opus|sonnet|haiku)-\d[\d.-]*(?:-latest)?$/.test(model.id);
7
- // This host alias is used only when its contiguous effort menu is supported.
7
+ // This host alias is used only when a safe contiguous effort menu is supported.
8
8
  // Both spellings remain accepted routes when capability evidence changes.
9
9
  return native ? `ccdx-${number}.anthropic.${model.id.replace(/(\d)\.(\d)/g, "$1-$2")}`
10
- : desktopEffortAliases && claudeEffortsExpressible(model.capability?.values) ? `mythos-ccdx-${number}` : `ccdx/claude-compatible-${number}`;
10
+ : desktopEffortAliases && claudeEffortPrefix(model.capability?.values).length ? `mythos-ccdx-${number}` : `ccdx/claude-compatible-${number}`;
11
11
  }
12
12
 
13
13
  export function claudeRouteAliases(model, route, desktop) {
@@ -0,0 +1,38 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { execFile } from "node:child_process";
4
+ import { promisify } from "node:util";
5
+ import { fileURLToPath } from "node:url";
6
+ import { userSettingsPath, servicePreferences } from "./user-settings.mjs";
7
+ import { atomicWriteFileIfChangedSync } from "./atomic-file.mjs";
8
+ import { installedPredictionApp } from "./native-prediction-app.mjs";
9
+ import { autoLaunchEnabled } from "./launcher.mjs";
10
+ import { adapterBaseUrl } from "./running-adapter.mjs";
11
+
12
+ const execute = promisify(execFile);
13
+ const PREFIX = "#!/bin/sh\n# CCDX native image host\n";
14
+ const quote = value => "'" + value.replaceAll("'", "'\"'\"'") + "'";
15
+
16
+ export function imageHostLauncherPath(options = {}) {
17
+ return path.join(path.dirname(userSettingsPath(options)), "native-image-host", "codex-cli");
18
+ }
19
+
20
+ export async function prepareImageHostLaunch({ env = process.env, home, platform = process.platform, host = "127.0.0.1", port = 2026,
21
+ discoverApp = installedPredictionApp, exec = execute, node = process.execPath,
22
+ entry = fileURLToPath(new URL("../bin/codex-image-host.mjs", import.meta.url)) } = {}) {
23
+ if (platform !== "darwin" || !autoLaunchEnabled(env) || !servicePreferences({ env, home }).image_enabled) return null;
24
+ const wrapper = imageHostLauncherPath({ env, home });
25
+ if (env.CODEX_CLI_PATH?.trim() && path.resolve(env.CODEX_CLI_PATH) !== wrapper) throw new Error("A custom Codex CLI route is already configured; image host setup was preserved");
26
+ const app = await discoverApp({ env, platform });
27
+ const codex = path.join(app.app, "Contents", "Resources", "codex-cli", "CodexCLI.app", "Contents", "MacOS", "codex");
28
+ if (!fs.statSync(codex).isFile()) throw new Error("The verified App has no native Codex runtime");
29
+ const result = await exec(codex, ["--version"], { encoding: "utf8", timeout: 3000, maxBuffer: 4096 });
30
+ const match = /codex-cli\s+0\.(\d+)\./.exec(String(result?.stdout ?? result));
31
+ if (!match || Number(match[1]) < 166) throw new Error("Native host tools require Codex 0.166 or later");
32
+ for (const value of [node, entry, codex]) if (!path.isAbsolute(value) || /[\0\r\n]/.test(value)) throw new Error("Invalid image host executable path");
33
+ if (fs.existsSync(wrapper) && !fs.readFileSync(wrapper, "utf8").startsWith(PREFIX)) throw new Error("Image host launcher ownership conflict; existing file preserved");
34
+ const content = PREFIX + "exec " + [node, entry, "--codex", codex, "--base-url", adapterBaseUrl(host, port) + "/v1", "--"].map(quote).join(" ") + ' "$@"\n';
35
+ fs.mkdirSync(path.dirname(wrapper), { recursive: true, mode: 0o700 });
36
+ atomicWriteFileIfChangedSync(wrapper, content, { mode: 0o700 });fs.chmodSync(wrapper, 0o700);
37
+ return { app: app.app, env: { CODEX_CLI_PATH: wrapper } };
38
+ }