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.
- package/README.md +2 -2
- package/bin/cli.mjs +5 -10
- package/docs/ARCHITECTURE.md +11 -6
- package/docs/REFERENCE.md +21 -37
- package/package.json +1 -1
- package/src/access-settings.mjs +2 -1
- package/src/adapter.mjs +14 -4
- package/src/claude-capability-config.mjs +2 -2
- package/src/claude-client-config.mjs +5 -3
- package/src/cli-command-spec.mjs +4 -11
- package/src/cli-image.mjs +24 -180
- package/src/cli-management.mjs +21 -6
- package/src/cli-options.mjs +1 -1
- package/src/cli-secret.mjs +39 -0
- package/src/cli-tools.mjs +1 -1
- package/src/client-integration.mjs +13 -12
- package/src/client-model-plan.mjs +3 -1
- package/src/config.mjs +9 -54
- package/src/connection-runtime.mjs +24 -3
- package/src/copilot-client.mjs +16 -1
- package/src/dashboard/connections.js +41 -10
- package/src/dashboard/console.js +6 -4
- package/src/dashboard/features.js +19 -29
- package/src/dashboard/index.html +3 -3
- package/src/dashboard/language.js +8 -7
- package/src/dashboard/ui.css +6 -0
- package/src/dashboard/ui.js +11 -2
- package/src/dashboard/usage.js +10 -5
- package/src/dashboard-api.mjs +2 -1
- package/src/doctor.mjs +4 -5
- package/src/image-models.mjs +20 -0
- package/src/image-retirement.mjs +33 -0
- package/src/image-setup.mjs +16 -105
- package/src/legacy-image-guidance.mjs +73 -0
- package/src/live-models.mjs +2 -1
- package/src/native-images.mjs +111 -0
- package/src/observability.mjs +2 -0
- package/src/optional-routes.mjs +4 -13
- package/src/privacy-detection.mjs +2 -2
- package/src/privacy-model.mjs +3 -3
- package/src/provider-metadata.mjs +5 -4
- package/src/provider-runtime.mjs +2 -1
- package/src/service-control.mjs +6 -7
- package/src/service-worker.mjs +2 -2
- package/src/image-mcp.mjs +0 -328
- package/src/image-provider-config.mjs +0 -194
- package/src/image-provider.mjs +0 -369
- package/src/image-readiness.mjs +0 -55
- package/src/image-references.mjs +0 -50
- package/src/image-skill/SKILL.md +0 -28
- package/src/image-skill/references/editing.md +0 -15
- package/src/image-skill/references/helper.md +0 -27
- package/src/image-skill.mjs +0 -142
- 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 {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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 the built-in Codex image tool and existing GitHub account.\n");
|
|
26
|
+
return result;
|
|
183
27
|
}
|
package/src/cli-management.mjs
CHANGED
|
@@ -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-
|
|
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
|
|
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();
|
package/src/cli-options.mjs
CHANGED
|
@@ -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
|
-
"
|
|
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
|
|
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 {
|
|
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,25 @@ 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
|
+
retireImages,
|
|
56
64
|
async configure() {
|
|
57
65
|
try {
|
|
58
66
|
const { retirePredictionIntegration } = await import("./prediction-retirement.mjs");
|
|
59
67
|
retirePredictionIntegration();
|
|
60
68
|
} catch { /* Legacy cleanup is optional; never interrupt or clutter core startup. */ }
|
|
61
|
-
const enabled = Boolean(readImageProviderConfig());
|
|
62
|
-
let imageMcpSkipped;
|
|
63
69
|
try {
|
|
64
|
-
const result = ensureCodexConfig(port, { host,
|
|
65
|
-
|
|
70
|
+
const result = ensureCodexConfig(port, { host, ...(configLog ? { log: configLog } : {}) });
|
|
71
|
+
codexSetup = { setup: result.coreSetup, checked_at: new Date().toISOString() };
|
|
66
72
|
} catch (error) { codexSetup = { setup: "configuration_unavailable", checked_at: new Date().toISOString() };throw error; }
|
|
67
|
-
|
|
68
|
-
|
|
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) };
|
|
73
|
+
retireImages();
|
|
74
|
+
return { imageEnabled: servicePreferences().image_enabled, imageMcpSkipped: false, compressionSetup: runInBackground(ensureCodexThreadCompression) };
|
|
74
75
|
},
|
|
75
76
|
start({ autoSetup = true } = {}) { return serialize("start", async () => {
|
|
76
77
|
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
|
}
|
package/src/config.mjs
CHANGED
|
@@ -12,10 +12,9 @@ const MODEL_CONTEXT_WINDOW = 1_000_000;
|
|
|
12
12
|
const MODEL_AUTO_COMPACT_TOKEN_LIMIT = 900_000;
|
|
13
13
|
const IMAGE_MCP_START = "# ccdx:image-mcp:start";
|
|
14
14
|
const IMAGE_MCP_END = "# ccdx:image-mcp:end";
|
|
15
|
-
const IMAGE_MCP_SECTION = "mcp_servers.ccdx_image";
|
|
16
15
|
const IMAGE_MCP_KEYS = ["enabled", "tool_timeout_sec", "url"];
|
|
17
16
|
|
|
18
|
-
//
|
|
17
|
+
// Legacy setup is rejected; cleanup preserves unowned settings.
|
|
19
18
|
export class ImageMcpConfigError extends Error {}
|
|
20
19
|
const STARTUP_MANAGED_PATHS = [
|
|
21
20
|
"openai_base_url",
|
|
@@ -158,46 +157,20 @@ function removeImageMcpDeclarations(content, statements, markers) {
|
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
function ensureImageMcp(lines, enabled, adapterPort, adapterHost, previousBaseUrl) {
|
|
160
|
+
if (enabled) throw new ImageMcpConfigError("The image MCP is retired; use native Codex images");
|
|
161
161
|
const previous = lines.join("\n");
|
|
162
162
|
const config = parseCodexToml(previous);
|
|
163
163
|
const section = configValue(config, IMAGE_MANAGED_PATH);
|
|
164
164
|
const url = `${adapterBaseUrl(imageMcpHost(adapterHost), adapterPort)}/mcp/image`;
|
|
165
165
|
if (section !== undefined) {
|
|
166
|
-
// Reuse compatible registrations without rewriting comments, formatting,
|
|
167
|
-
// user tool policies, or timeouts. An explicit disabled flag is preserved.
|
|
168
|
-
if (enabled && imageMcpUrl(section?.url)?.href === new URL(url).href
|
|
169
|
-
&& [undefined, true].includes(section?.enabled)) return false;
|
|
170
166
|
const statements = codexTomlStatements(previous);
|
|
171
167
|
const markers = imageMcpMarkers(previous, statements);
|
|
172
|
-
if (!knownImageMcp(section, url, previousBaseUrl, statements, markers))
|
|
173
|
-
if (!enabled) return false;
|
|
174
|
-
throw new ImageMcpConfigError(`Codex config already defines [${IMAGE_MCP_SECTION}] outside the CCDX-managed block; its settings were preserved`);
|
|
175
|
-
}
|
|
168
|
+
if (!knownImageMcp(section, url, previousBaseUrl, statements, markers)) return false;
|
|
176
169
|
const removed = removeImageMcpDeclarations(previous, statements, markers);
|
|
177
|
-
if (removed === null)
|
|
178
|
-
if (!enabled) return false;
|
|
179
|
-
throw new ImageMcpConfigError(`Cannot safely update [${IMAGE_MCP_SECTION}] inside a shared inline table; its settings were preserved`);
|
|
180
|
-
}
|
|
170
|
+
if (removed === null) return false;
|
|
181
171
|
lines.splice(0, lines.length, ...removed.split("\n"));
|
|
182
172
|
while (lines.length && !lines.at(-1).trim()) lines.pop();
|
|
183
173
|
}
|
|
184
|
-
if (enabled) {
|
|
185
|
-
const parent = config.mcp_servers;
|
|
186
|
-
if (parent !== undefined && (typeof parent !== "object" || parent === null || Array.isArray(parent)
|
|
187
|
-
|| codexTomlStatements(previous).some((item) => item.kind === "value" && sameKeys(item.keys, ["mcp_servers"])))) {
|
|
188
|
-
throw new ImageMcpConfigError("Cannot append the image MCP to an inline or non-table mcp_servers setting; its settings were preserved");
|
|
189
|
-
}
|
|
190
|
-
while (lines.length && lines.at(-1).trim() === "") lines.pop();
|
|
191
|
-
if (lines.length) lines.push("");
|
|
192
|
-
lines.push(
|
|
193
|
-
IMAGE_MCP_START,
|
|
194
|
-
`[${IMAGE_MCP_SECTION}]`,
|
|
195
|
-
`url = ${JSON.stringify(url)}`,
|
|
196
|
-
"enabled = true",
|
|
197
|
-
"tool_timeout_sec = 210",
|
|
198
|
-
IMAGE_MCP_END,
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
174
|
return lines.join("\n") !== previous;
|
|
202
175
|
}
|
|
203
176
|
|
|
@@ -227,7 +200,8 @@ export function computeUpdatedCodexConfig(
|
|
|
227
200
|
changed = setTomlKey(lines, "shell_environment_policy.set", "OPENAI_BASE_URL", baseUrl) || changed;
|
|
228
201
|
changed = setTomlKey(lines, "shell_environment_policy.set", "OPENAI_API_KEY", "dummy") || changed;
|
|
229
202
|
changed = ensureContextManagementDefault(lines) || changed;
|
|
230
|
-
if (
|
|
203
|
+
if (imageProviderEnabled === true) throw new ImageMcpConfigError("The image MCP is retired; use native Codex images");
|
|
204
|
+
if (imageProviderEnabled === false) {
|
|
231
205
|
changed = ensureImageMcp(lines, imageProviderEnabled, adapterPort, adapterHost, config.openai_base_url) || changed;
|
|
232
206
|
}
|
|
233
207
|
|
|
@@ -238,7 +212,7 @@ export function computeUpdatedCodexConfig(
|
|
|
238
212
|
return { content: updated, changed };
|
|
239
213
|
}
|
|
240
214
|
|
|
241
|
-
export function initialCodexConfig(adapterPort, adapterHost
|
|
215
|
+
export function initialCodexConfig(adapterPort, adapterHost) {
|
|
242
216
|
const baseUrl = `${adapterBaseUrl(adapterHost, adapterPort)}/v1`;
|
|
243
217
|
const base = `openai_base_url = "${baseUrl}"
|
|
244
218
|
model_context_window = ${MODEL_CONTEXT_WINDOW}
|
|
@@ -254,9 +228,7 @@ OPENAI_API_KEY = "dummy"
|
|
|
254
228
|
[features]
|
|
255
229
|
context_management = true
|
|
256
230
|
`;
|
|
257
|
-
return
|
|
258
|
-
? computeUpdatedCodexConfig(base, adapterPort, adapterHost, { imageProviderEnabled }).content
|
|
259
|
-
: base;
|
|
231
|
+
return base;
|
|
260
232
|
}
|
|
261
233
|
|
|
262
234
|
function computeImageConfig(
|
|
@@ -287,7 +259,6 @@ export function ensureCodexConfig(adapterPort = 2026, options = {}) {
|
|
|
287
259
|
function ensureCodexConfigUnlocked(adapterPort = 2026, {
|
|
288
260
|
filePath,
|
|
289
261
|
host = "127.0.0.1",
|
|
290
|
-
imageProviderEnabled = false,
|
|
291
262
|
log = console.log,
|
|
292
263
|
...options
|
|
293
264
|
} = {}) {
|
|
@@ -313,22 +284,6 @@ function ensureCodexConfigUnlocked(adapterPort = 2026, {
|
|
|
313
284
|
atomicWriteFileIfChangedSync(filePath, core.content);
|
|
314
285
|
log(status("ok", content === undefined ? `Created Codex configuration: ${filePath}` : parseCodexToml(core.content).openai_base_url === baseUrl ? `Configured Codex base URL: ${baseUrl}` : "Codex startup settings updated; existing base URL preserved"));
|
|
315
286
|
}
|
|
316
|
-
// Disabled means no image maintenance, including no implicit removal of old
|
|
317
|
-
// or user-owned entries. Explicit disable-image owns the cleanup operation.
|
|
318
287
|
const coreSetup = parseCodexToml(core.content).openai_base_url === baseUrl ? "configured" : "preserved";
|
|
319
|
-
|
|
320
|
-
try {
|
|
321
|
-
const previousBaseUrl = content === undefined ? undefined : parseCodexToml(content).openai_base_url;
|
|
322
|
-
const image = computeImageConfig(core.content, { enabled: true, adapterPort, adapterHost: host }, previousBaseUrl);
|
|
323
|
-
if (image.changed) {
|
|
324
|
-
if (fs.readFileSync(filePath, "utf8") !== core.content) {
|
|
325
|
-
throw new ImageMcpConfigError("Codex config changed during image setup; the newer configuration was preserved");
|
|
326
|
-
}
|
|
327
|
-
atomicWriteFileIfChangedSync(filePath, image.content);
|
|
328
|
-
}
|
|
329
|
-
return { coreSetup, imageMcpSkipped: false };
|
|
330
|
-
} catch (error) {
|
|
331
|
-
console.warn(status("warn", `Image MCP setup was skipped: ${error.message}. Core proxy startup will continue.`));
|
|
332
|
-
return { coreSetup, imageMcpSkipped: true };
|
|
333
|
-
}
|
|
288
|
+
return { coreSetup, imageMcpSkipped: false };
|
|
334
289
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { imageModelCatalog, imageModelSelection } from "./image-models.mjs";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import { randomBytes, createHash } from "node:crypto";
|
|
3
4
|
import {
|
|
@@ -313,6 +314,11 @@ export function createConnectionRuntime({
|
|
|
313
314
|
});
|
|
314
315
|
return summaries.get(api);
|
|
315
316
|
}
|
|
317
|
+
function imageModels() {
|
|
318
|
+
const c = binding("codex");
|
|
319
|
+
return imageModelSelection(enabled("github") && c.allowed.includes("github")
|
|
320
|
+
? imageModelCatalog(legacy.github?.registry?.models) : [], c.image_model);
|
|
321
|
+
}
|
|
316
322
|
function clientSnapshot(id, config, compact, readPlan) {
|
|
317
323
|
const base = {
|
|
318
324
|
id,
|
|
@@ -330,6 +336,7 @@ export function createConnectionRuntime({
|
|
|
330
336
|
...base,
|
|
331
337
|
revision,
|
|
332
338
|
model_plan: {
|
|
339
|
+
...(id === "codex" ? { image: imageModels() } : {}),
|
|
333
340
|
default_model: compiled.defaultModel,
|
|
334
341
|
default_unavailable: compiled.defaultUnavailable,
|
|
335
342
|
models: compiled.models.map(model => ({
|
|
@@ -378,7 +385,7 @@ export function createConnectionRuntime({
|
|
|
378
385
|
const selected = new Map(CLIENT_IDS.map(id => [id, new Set(plan(id).models.filter(model => model.source_id === sourceId).map(model => model.id))]));
|
|
379
386
|
return { ...catalog, models: catalog.models.map(model => ({ ...model,
|
|
380
387
|
client_visibility: CLIENT_IDS.map(id => ({ client: id,
|
|
381
|
-
reason: modelExclusion(id, sourceId, model.id, model, selected.get(id).has(model.id)) })) })) };
|
|
388
|
+
reason: modelExclusion(id, sourceId, model.id, model, selected.get(id).has(model.id) || id === "codex" && sourceId === "github" && model.kind === "image" && imageModels().selected_model === model.id) })) })) };
|
|
382
389
|
}
|
|
383
390
|
function snapshot(compact = false) {
|
|
384
391
|
const state = legacy.snapshot(),
|
|
@@ -912,6 +919,10 @@ export function createConnectionRuntime({
|
|
|
912
919
|
...(input.auto_review_model ? { auto_review_model: input.auto_review_model } : {}),
|
|
913
920
|
...(input.auto_review_effort !== undefined ? { auto_review_effort: input.auto_review_effort } : {}),
|
|
914
921
|
};
|
|
922
|
+
if (input.image_model !== undefined) {
|
|
923
|
+
if (input.id !== "codex" || input.image_model !== old.image_model && !imageModels().models.some(model => model.id === input.image_model)) throw accessError("ccdx_api_model_unavailable");
|
|
924
|
+
next.clients.codex.image_model = input.image_model;
|
|
925
|
+
}
|
|
915
926
|
if (input.id !== "codex") next.claude_private_keys = true;
|
|
916
927
|
if (old.source !== input.source) next.clients[input.id].history_isolation = true;
|
|
917
928
|
const c = next.clients[input.id];
|
|
@@ -1001,6 +1012,7 @@ export function createConnectionRuntime({
|
|
|
1001
1012
|
return {
|
|
1002
1013
|
...snapshot(),
|
|
1003
1014
|
preview: {
|
|
1015
|
+
...(input.id === "codex" ? { image: imageModelSelection(imageModels().models, c.image_model) } : {}),
|
|
1004
1016
|
models: proposed.models.map(model => ({
|
|
1005
1017
|
source: model.source_id,
|
|
1006
1018
|
id: model.id,
|
|
@@ -1090,22 +1102,30 @@ export function createConnectionRuntime({
|
|
|
1090
1102
|
"deployments",
|
|
1091
1103
|
"default_model",
|
|
1092
1104
|
"auto_sync",
|
|
1105
|
+
"image_model",
|
|
1093
1106
|
"client_revision",
|
|
1094
1107
|
])
|
|
1095
1108
|
)
|
|
1096
1109
|
throw accessError("ccdx_connections_action_invalid");
|
|
1097
1110
|
if (
|
|
1098
|
-
["client", "preview_client", "sync_client", "client_state"].includes(input.operation) &&
|
|
1111
|
+
["client", "preview_client", "sync_client", "client_state", "image_model"].includes(input.operation) &&
|
|
1099
1112
|
input.client_revision !== undefined &&
|
|
1100
1113
|
(!CLIENT_IDS.includes(input.id) || input.client_revision !== clientRevision(input.id))
|
|
1101
1114
|
)
|
|
1102
1115
|
throw accessError("ccdx_connections_conflict", 409);
|
|
1103
1116
|
if (
|
|
1104
|
-
!["client", "preview_client", "sync_client", "client_state"].includes(input.operation) &&
|
|
1117
|
+
!["client", "preview_client", "sync_client", "client_state", "image_model"].includes(input.operation) &&
|
|
1105
1118
|
input.impact_revision !== undefined &&
|
|
1106
1119
|
input.impact_revision !== sourceImpact(input.id).revision
|
|
1107
1120
|
)
|
|
1108
1121
|
throw accessError("ccdx_connections_conflict", 409);
|
|
1122
|
+
if (input.operation === "image_model") {
|
|
1123
|
+
if (!validObject(input, ["operation", "id", "model", "client_revision"]) || input.id !== "codex"
|
|
1124
|
+
|| !imageModels().models.some(model => model.id === input.model)) throw accessError("ccdx_api_model_unavailable");
|
|
1125
|
+
const next = editable();next.clients.codex.image_model = input.model;save(next);
|
|
1126
|
+
await syncClients(["codex"]);
|
|
1127
|
+
return snapshot();
|
|
1128
|
+
}
|
|
1109
1129
|
if (input.operation === "sync_client") {
|
|
1110
1130
|
if (
|
|
1111
1131
|
!validObject(input, ["operation", "id", "client_revision"]) ||
|
|
@@ -1279,6 +1299,7 @@ export function createConnectionRuntime({
|
|
|
1279
1299
|
void catalogRefresh.refresh(input.id).catch(() => {});
|
|
1280
1300
|
return input.operation === "save_api" ? snapshot() : result;
|
|
1281
1301
|
},
|
|
1302
|
+
imageModels,
|
|
1282
1303
|
async start() {
|
|
1283
1304
|
if (binding("codex").enabled) void memoryModel.refresh();
|
|
1284
1305
|
const old = legacy.start();
|