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/image-setup.mjs
CHANGED
|
@@ -1,110 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { computeImageMcpCodexConfig } from "./config.mjs";
|
|
7
|
-
import { updateImageSkill } from "./image-skill.mjs";
|
|
8
|
-
import { servicePreferences, writeServicePreference } from "./user-settings.mjs";
|
|
9
|
-
import { imageProviderConfigPath, inspectImageProvider, normalizeImageEndpoint, readImageProviderConfig, validateImageProviderConfig } from "./image-provider-config.mjs";
|
|
10
|
-
export function fileContent(filePath) {
|
|
11
|
-
try { return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(fs.readFileSync(filePath)); }
|
|
12
|
-
catch (error) {
|
|
13
|
-
if (error?.code === "ENOENT") return "";
|
|
14
|
-
if (error?.code === "ERR_ENCODING_INVALID_ENCODED_DATA") {
|
|
15
|
-
throw new Error("Codex configuration is not valid UTF-8 TOML; no configuration changes were written");
|
|
16
|
-
}
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function enableImageProvider(options) {
|
|
22
|
-
return withFileLockSync(`${options.codexPath}.ccdx.lock`, () => enableImageProviderUnlocked(options));
|
|
23
|
-
}
|
|
24
|
-
function enableImageProviderUnlocked({ providerConfig, providerPath, codexPath, codexContent, adapterPort, adapterHost }) {
|
|
25
|
-
const codex = computeImageMcpCodexConfig(codexContent, {
|
|
26
|
-
enabled: true,
|
|
27
|
-
adapterPort,
|
|
28
|
-
adapterHost,
|
|
29
|
-
});
|
|
30
|
-
const normalized = validateImageProviderConfig(providerConfig, { filePath: providerPath });
|
|
31
|
-
const skill = updateImageSkill({ enabled: true, codexPath, adapterPort, adapterHost });
|
|
32
|
-
try {
|
|
33
|
-
if (fileContent(codexPath) !== codexContent) {
|
|
34
|
-
throw new Error("Codex configuration changed during image setup; retry to preserve the newer settings");
|
|
35
|
-
}
|
|
36
|
-
atomicWriteFilePairSync(
|
|
37
|
-
codexPath,
|
|
38
|
-
codex.content,
|
|
39
|
-
providerPath,
|
|
40
|
-
`${JSON.stringify(normalized, null, 2)}\n`,
|
|
41
|
-
{ mode: 0o600, writeFile: atomicWriteFileIfChangedSync },
|
|
42
|
-
);
|
|
43
|
-
} catch (error) {
|
|
44
|
-
skill.rollback();
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
return { codexChanged: codex.changed, config: normalized };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function disableImageProvider(options) {
|
|
51
|
-
if (!fs.existsSync(options.codexPath)) return disableImageProviderUnlocked(options);
|
|
52
|
-
return withFileLockSync(`${options.codexPath}.ccdx.lock`, () => disableImageProviderUnlocked(options));
|
|
53
|
-
}
|
|
54
|
-
function disableImageProviderUnlocked({ providerPath, codexPath, codexContent, adapterPort, adapterHost }) {
|
|
55
|
-
const codex = computeImageMcpCodexConfig(codexContent, {
|
|
56
|
-
enabled: false,
|
|
57
|
-
adapterPort,
|
|
58
|
-
adapterHost,
|
|
59
|
-
});
|
|
60
|
-
const providerExists = fs.existsSync(providerPath);
|
|
61
|
-
const skill = updateImageSkill({ enabled: false, codexPath, adapterPort, adapterHost });
|
|
62
|
-
try {
|
|
63
|
-
if (fs.existsSync(codexPath)) {
|
|
64
|
-
if (fileContent(codexPath) !== codexContent) {
|
|
65
|
-
throw new Error("Codex configuration changed during image cleanup; retry to preserve the newer settings");
|
|
66
|
-
}
|
|
67
|
-
atomicWriteFilePairSync(codexPath, codex.content, providerPath, null, {
|
|
68
|
-
mode: 0o600, writeFile: atomicWriteFileIfChangedSync,
|
|
69
|
-
});
|
|
70
|
-
} else if (providerExists) {
|
|
71
|
-
fs.unlinkSync(providerPath);
|
|
72
|
-
}
|
|
73
|
-
} catch (error) {
|
|
74
|
-
skill.rollback();
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
77
|
-
return { changed: providerExists || codex.changed || skill.changed, preservedGuidance: Boolean(skill.preserved) };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export function syncEnabledImageSkill({ home = os.homedir(), env = process.env, codexPath = codexPaths({ env, home }).config, ...options } = {}) {
|
|
81
|
-
return updateImageSkill({ ...options, enabled: true, codexPath });
|
|
82
|
-
}
|
|
83
|
-
|
|
1
|
+
import { readAuthProfileCredentials } from "./auth-profile.mjs";
|
|
2
|
+
import { readAccessSettings } from "./access-settings.mjs";
|
|
3
|
+
import { servicePreferences } from "./user-settings.mjs";
|
|
4
|
+
import { nativeImageAccess } from "./native-images.mjs";
|
|
5
|
+
import { imageModelSelection } from "./image-models.mjs";
|
|
84
6
|
|
|
85
7
|
export function imageSetupSummary(options = {}) {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
8
|
+
const configured = readAuthProfileCredentials("codex", options).valid && nativeImageAccess(options);
|
|
9
|
+
const selection = imageModelSelection(options.models || [], readAccessSettings(options).clients.codex.image_model);
|
|
10
|
+
return { configured, native: true, provider: "github", ...selection, model: selection.selected_model,
|
|
11
|
+
enabled: servicePreferences(options).image_enabled,
|
|
12
|
+
availability: !configured ? "needs_github_access" : !selection.models.length ? "no_models" : !selection.selected_available ? "selected_unavailable" : "ready" };
|
|
90
13
|
}
|
|
91
14
|
|
|
92
|
-
export async function configureImageSetup(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const normalized = normalizeImageEndpoint(endpoint || current?.endpoint);
|
|
99
|
-
const sameOrigin = current && new URL(normalized).origin === new URL(current.endpoint).origin;
|
|
100
|
-
const apiKey = String(key || "").trim() || (sameOrigin ? current.api_key : "");
|
|
101
|
-
if (!apiKey) throw new Error("Enter an image API key for this address");
|
|
102
|
-
const inspected = await inspectImageProvider({ endpoint: normalized, apiKey, fetchImpl,
|
|
103
|
-
selectModel: ids => model || (ids.includes(current?.model) ? current.model : ids[0]) });
|
|
104
|
-
if (operation === "inspect") return { endpoint: inspected.endpoint, models: inspected.modelIds, protocol: inspected.protocol };
|
|
105
|
-
if (!model || !inspected.modelIds.includes(model)) throw new Error("Choose a listed image model");
|
|
106
|
-
enableImageProvider({ providerPath, codexPath, codexContent: fileContent(codexPath), adapterPort, adapterHost,
|
|
107
|
-
providerConfig: { endpoint: inspected.endpoint, api_key: apiKey, model, protocol: inspected.protocol } });
|
|
108
|
-
if (!servicePreferences({ env, home }).image_enabled) writeServicePreference("image_enabled", true, { env, home });
|
|
109
|
-
return imageSetupSummary({ env, home });
|
|
15
|
+
export async function configureImageSetup(input, options = {}) {
|
|
16
|
+
if (!input || input.operation !== "select" || typeof input.model !== "string") throw new Error("Choose an image model; manual image API setup is retired");
|
|
17
|
+
if (!options.providerRuntime) throw new Error("Start CCDX to choose a model from its GitHub catalog");
|
|
18
|
+
const client = options.providerRuntime.connections().clients.find(client => client.id === "codex");
|
|
19
|
+
await options.providerRuntime.manageConnections({ operation: "image_model", id: "codex", model: input.model, client_revision: client.revision });
|
|
20
|
+
return imageSetupSummary({ ...options, models: options.providerRuntime.imageModels().models });
|
|
110
21
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
|
|
5
|
+
const SKILL_MARKER = /<!-- ccdx:image-skill:([a-f0-9]{64}) -->\n/;
|
|
6
|
+
const HELPER_MARKER = /^\/\/ ccdx:image-helper:([a-f0-9]{64})\n/;
|
|
7
|
+
const REFERENCE_MARKER = /^<!-- ccdx:image-reference:([a-f0-9]{64}) -->\n/;
|
|
8
|
+
const REFERENCE_FILES = ["editing.md", "helper.md"];
|
|
9
|
+
|
|
10
|
+
function digest(content) {
|
|
11
|
+
return createHash("sha256").update(content).digest("hex");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function conflict(message) {
|
|
15
|
+
return Object.assign(new Error(message), { code: "CCDX_IMAGE_SKILL_CONFLICT" });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function directoryCheck(directory) {
|
|
19
|
+
try {
|
|
20
|
+
if (!fs.lstatSync(directory).isDirectory()) throw conflict(`CCDX image skill path is not a regular directory: ${directory}`);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (error?.code !== "ENOENT") throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function ownedSnapshot(filePath, marker, preserveUnowned = false) {
|
|
27
|
+
try {
|
|
28
|
+
const stat = fs.lstatSync(filePath);
|
|
29
|
+
if (!stat.isFile()) throw conflict(`Refusing to replace an unowned CCDX image skill path: ${filePath}`);
|
|
30
|
+
const content = fs.readFileSync(filePath, "utf8");
|
|
31
|
+
const match = marker.exec(content);
|
|
32
|
+
if (!match || digest(content.replace(marker, "")) !== match[1]) {
|
|
33
|
+
throw conflict(`Preserving an existing or modified image skill file: ${filePath}`);
|
|
34
|
+
}
|
|
35
|
+
return { content };
|
|
36
|
+
} catch (error) {
|
|
37
|
+
if (error?.code === "ENOENT") return null;
|
|
38
|
+
if (preserveUnowned && error?.code === "CCDX_IMAGE_SKILL_CONFLICT") return { unowned: true };
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function removeFile(filePath) {
|
|
44
|
+
try { fs.unlinkSync(filePath); }
|
|
45
|
+
catch (error) { if (error?.code !== "ENOENT") throw error; }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function removeEmptyDirectories(skillDirectory) {
|
|
49
|
+
for (const directory of [path.join(skillDirectory, "scripts"), path.join(skillDirectory, "references"), skillDirectory]) {
|
|
50
|
+
try { fs.rmdirSync(directory); }
|
|
51
|
+
catch (error) { if (!["ENOENT", "ENOTEMPTY", "EEXIST"].includes(error?.code)) throw error; }
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function removeLegacyImageGuidance({ codexPath } = {}) {
|
|
56
|
+
const skillDirectory = path.join(path.dirname(codexPath), "skills", "ccdx-image");
|
|
57
|
+
const files = [["SKILL.md", SKILL_MARKER], ["scripts/generate.mjs", HELPER_MARKER],
|
|
58
|
+
...REFERENCE_FILES.map(name => [`references/${name}`, REFERENCE_MARKER])];
|
|
59
|
+
try {
|
|
60
|
+
for (const directory of [skillDirectory, path.join(skillDirectory, "scripts"), path.join(skillDirectory, "references")]) directoryCheck(directory);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (error.code === "CCDX_IMAGE_SKILL_CONFLICT" || error.code === "ENOTDIR") return { changed: false, preserved: true };
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
let changed = false, preserved = false;
|
|
66
|
+
for (const [relative, marker] of files) {
|
|
67
|
+
const file = path.join(skillDirectory, relative), snapshot = ownedSnapshot(file, marker, true);
|
|
68
|
+
if (snapshot?.unowned) preserved = true;
|
|
69
|
+
else if (snapshot) { removeFile(file);changed = true; }
|
|
70
|
+
}
|
|
71
|
+
removeEmptyDirectories(skillDirectory);
|
|
72
|
+
return { changed, preserved };
|
|
73
|
+
}
|
package/src/live-models.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isImageModel, imageModelCatalog } from "./image-models.mjs";
|
|
1
2
|
import os from "node:os";
|
|
2
3
|
import { publicModelCatalog } from "./provider-metadata.mjs";
|
|
3
4
|
import { createAbortAwareSingleflight } from "./bounded-result-cache.mjs";
|
|
@@ -140,7 +141,7 @@ async function lookupLiveModels(credentials, { fetchImpl, timeoutMs, vscodeVersi
|
|
|
140
141
|
if (includeAll) {
|
|
141
142
|
const selected = new Set(catalog.models.map(model => model.id));
|
|
142
143
|
catalog.models = publicModelCatalog(Array.isArray(payload) ? payload : payload.data, {
|
|
143
|
-
selectable: model => selected.has(model.id), clients: model => selected.has(model.id) ? ["codex"] : [],
|
|
144
|
+
selectable: model => selected.has(model.id) || imageModelCatalog([model]).length > 0, clients: model => selected.has(model.id) || isImageModel(model) ? ["codex"] : [],
|
|
144
145
|
});
|
|
145
146
|
}
|
|
146
147
|
let upstreamHost = "GitHub Copilot";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createRequestAbort, readJsonBody, readBoundedResponseText, sendJsonError, sendUpstreamError, logRequestFailure } from "./http-transport.mjs";
|
|
2
|
+
import { httpError } from "./http-errors.mjs";
|
|
3
|
+
import { isLoopbackAddress, isLoopbackHostHeader } from "./security.mjs";
|
|
4
|
+
import { DEFAULT_IMAGE_MODEL, imageModelSelection } from "./image-models.mjs";
|
|
5
|
+
import { readAccessSettings } from "./access-settings.mjs";
|
|
6
|
+
import { servicePreferences } from "./user-settings.mjs";
|
|
7
|
+
import { observeRequestedModel, currentRequestContext } from "./request-context.mjs";
|
|
8
|
+
import { recordResponsesUsage } from "./usage-store.mjs";
|
|
9
|
+
|
|
10
|
+
export const NATIVE_IMAGE_MODEL = DEFAULT_IMAGE_MODEL;
|
|
11
|
+
export const IMAGE_MAX_BYTES = 32 * 1024 * 1024;
|
|
12
|
+
const INPUT_MAX_BYTES = 10 * 1024 * 1024;
|
|
13
|
+
const BODY_MAX_BYTES = 64 * 1024 * 1024;
|
|
14
|
+
const RESPONSE_MAX_BYTES = 48 * 1024 * 1024;
|
|
15
|
+
const SIZES = new Set(["auto", "1024x1024", "1536x1024", "1024x1536"]);
|
|
16
|
+
const FIELDS = new Set(["model", "prompt", "images", "background", "quality", "size", "n"]);
|
|
17
|
+
|
|
18
|
+
async function checkedImage(value, maxBytes, mime) {
|
|
19
|
+
if (typeof value !== "string" || !value || value.length > 4 * Math.ceil(maxBytes / 3)
|
|
20
|
+
|| value.length % 4 !== 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(value)) throw httpError("Invalid image data", 400);
|
|
21
|
+
const bytes = Buffer.from(value, "base64");
|
|
22
|
+
if (!bytes.length || bytes.length > maxBytes || bytes.toString("base64") !== value) throw httpError("Invalid image data", 400);
|
|
23
|
+
let info;
|
|
24
|
+
try { const { default: sharp } = await import("sharp");info = await sharp(bytes, { limitInputPixels: 40_000_000 }).metadata(); }
|
|
25
|
+
catch { throw httpError("Image must be a valid PNG, JPEG or WebP", 400); }
|
|
26
|
+
const type = { png: "image/png", jpeg: "image/jpeg", webp: "image/webp" }[info.format];
|
|
27
|
+
if (!type || mime && mime !== type) throw httpError("Image format does not match its data", 400);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function nativeImageRequest(body, operation, selectedModel = DEFAULT_IMAGE_MODEL) {
|
|
31
|
+
if (!body || typeof body !== "object" || Array.isArray(body) || Object.keys(body).some(key => !FIELDS.has(key))) throw httpError("Unsupported image request field", 400);
|
|
32
|
+
if (!["gpt-image-2", selectedModel].includes(body.model)) throw httpError("Choose an available image model", 400);
|
|
33
|
+
if (typeof body.prompt !== "string" || !body.prompt.trim() || Buffer.byteLength(body.prompt) > 128 * 1024) throw httpError("Image prompt is required and must not exceed 128 KiB", 400);
|
|
34
|
+
if (body.n !== undefined && body.n !== 1) throw httpError("Request one image at a time", 400);
|
|
35
|
+
if (body.quality !== undefined && !["auto", "low", "medium", "high"].includes(body.quality)) throw httpError("Unsupported image quality", 400);
|
|
36
|
+
if (body.size !== undefined && !SIZES.has(body.size)) throw httpError("Unsupported image size", 400);
|
|
37
|
+
if (body.background !== undefined && !["auto", "opaque", "transparent"].includes(body.background)) throw httpError("Unsupported image background", 400);
|
|
38
|
+
if (operation === "generations" && body.images !== undefined) throw httpError("Use images/edits for image inputs", 400);
|
|
39
|
+
if (operation === "edits") {
|
|
40
|
+
if (!Array.isArray(body.images) || !body.images.length || body.images.length > 5) throw httpError("Image editing requires one to five input images", 400);
|
|
41
|
+
for (const image of body.images) {
|
|
42
|
+
if (!image || Object.keys(image).length !== 1 || typeof image.image_url !== "string") throw httpError("Image editing requires inline image data; file IDs are unavailable through GHC", 400);
|
|
43
|
+
const match = /^data:(image\/(?:png|jpeg|webp));base64,(.*)$/s.exec(image.image_url);
|
|
44
|
+
if (!match) throw httpError("Image editing requires PNG, JPEG or WebP data URLs", 400);
|
|
45
|
+
await checkedImage(match[2], INPUT_MAX_BYTES, match[1]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { ...body, model: selectedModel, n: 1 };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function nativeImageAccess(options = {}) {
|
|
52
|
+
const access = readAccessSettings(options), codex = access.clients.codex;
|
|
53
|
+
return access.providers.github && codex.enabled && codex.allowed.includes("github");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function createNativeImagesHandler({ client, acquireRequest, privacy, env = process.env, home,
|
|
57
|
+
models = () => [], selection = () => readAccessSettings({ env, home }).clients.codex.image_model,
|
|
58
|
+
requestBodyTimeoutMs = 120000, timeoutMs = 180000, enabled = () => servicePreferences({ env, home }).image_enabled,
|
|
59
|
+
allowed = () => nativeImageAccess({ env, home }) } = {}) {
|
|
60
|
+
let active = 0;
|
|
61
|
+
const metrics = { total: 0, succeeded: 0, failed: 0, busy: 0, cancelled: 0 };
|
|
62
|
+
const handler = async (req, res, operation) => {
|
|
63
|
+
const abort = createRequestAbort(req, res);
|
|
64
|
+
let release = () => {}, admitted = false;
|
|
65
|
+
metrics.total++;
|
|
66
|
+
try {
|
|
67
|
+
if (!isLoopbackAddress(req.socket?.remoteAddress) || req.headers.host !== undefined && !isLoopbackHostHeader(req.headers.host)
|
|
68
|
+
|| Object.hasOwn(req.headers, "origin")) throw httpError("Images require a native local Codex client", 403);
|
|
69
|
+
if (String(req.headers["content-type"] || "").split(";", 1)[0].trim().toLowerCase() !== "application/json") throw httpError("Images require application/json", 415);
|
|
70
|
+
if (!allowed()) throw httpError("GitHub Copilot access is disabled for Codex", 403);
|
|
71
|
+
if (!enabled()) throw httpError("Image requests are paused", 503);
|
|
72
|
+
if (active >= 2) { metrics.busy++;throw httpError("Two image requests are already active", 503); }
|
|
73
|
+
active++;admitted = true;
|
|
74
|
+
abort.setTimeout(requestBodyTimeoutMs, "request_body_timeout");
|
|
75
|
+
release = await acquireRequest(req, { signal: abort.signal });
|
|
76
|
+
const parsed = await readJsonBody(req, { admission: release, signal: abort.signal, maxBodyBytes: BODY_MAX_BYTES, maxDecodedBodyBytes: BODY_MAX_BYTES });
|
|
77
|
+
const available = models();
|
|
78
|
+
const image = parsed?.model === "gpt-image-2" ? imageModelSelection(available, selection()).selected_model : parsed?.model;
|
|
79
|
+
const selected = available.find(model => model.id === image);
|
|
80
|
+
if (!selected) throw httpError("The selected image model is unavailable; refresh the GitHub catalog or choose another image model", parsed?.model === "gpt-image-2" ? 503 : 400);
|
|
81
|
+
if (operation === "edits" && !selected.editing) throw httpError("The selected image model does not support editing", 400);
|
|
82
|
+
const body = await nativeImageRequest(parsed, operation, image);
|
|
83
|
+
observeRequestedModel(body);
|
|
84
|
+
const context = currentRequestContext();
|
|
85
|
+
if (context) { context.provider = "github";context.streamPerformance?.setProvider?.("github"); }
|
|
86
|
+
abort.setTimeout(timeoutMs);
|
|
87
|
+
const forward = input => client.images(operation, { ...body, prompt: input.input }, { signal: abort.signal });
|
|
88
|
+
const call = privacy?.wrap ? privacy.wrap(forward, { res, protocol: "responses", client: "codex" }) : forward;
|
|
89
|
+
const response = await call({ input: body.prompt }, { signal: abort.signal });
|
|
90
|
+
if (!response.ok) { metrics.failed++;await sendUpstreamError(res, response, "images", { signal: abort.signal });return; }
|
|
91
|
+
const text = await readBoundedResponseText(response, { maxBytes: RESPONSE_MAX_BYTES, signal: abort.signal, label: "Copilot image response" });
|
|
92
|
+
let result;
|
|
93
|
+
try { result = JSON.parse(text); } catch { throw httpError("Copilot returned invalid image JSON", 502); }
|
|
94
|
+
if (!Number.isSafeInteger(result.created) || !Array.isArray(result.data) || result.data.length !== 1) throw httpError("Copilot returned an invalid image response", 502);
|
|
95
|
+
try { await checkedImage(result.data[0]?.b64_json, IMAGE_MAX_BYTES); }
|
|
96
|
+
catch { throw httpError("Copilot returned invalid image data", 502); }
|
|
97
|
+
abort.signal.throwIfAborted();
|
|
98
|
+
void recordResponsesUsage({ surface: "images", mode: operation, model: body.model, response: result });
|
|
99
|
+
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store", "X-CCDX-Image-Model": body.model });
|
|
100
|
+
res.end(text);
|
|
101
|
+
metrics.succeeded++;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
metrics.failed++;
|
|
104
|
+
if (abort.reason === "client_closed" || abort.reason === "client_aborted") metrics.cancelled++;
|
|
105
|
+
logRequestFailure("images", error, abort);
|
|
106
|
+
sendJsonError(res, error, error.statusCode || 502);
|
|
107
|
+
} finally { release();if (admitted) active--;abort.cleanup(); }
|
|
108
|
+
};
|
|
109
|
+
handler.stats = () => ({ ...metrics, active, native: true, model: imageModelSelection(models(), selection()).selected_model });
|
|
110
|
+
return handler;
|
|
111
|
+
}
|
package/src/observability.mjs
CHANGED
|
@@ -22,6 +22,7 @@ const ROUTE_NAMES = Object.freeze([
|
|
|
22
22
|
"messages_count_tokens",
|
|
23
23
|
"claude_models",
|
|
24
24
|
"image_mcp",
|
|
25
|
+
"images",
|
|
25
26
|
"not_found",
|
|
26
27
|
]);
|
|
27
28
|
|
|
@@ -110,6 +111,7 @@ export function classifyAdapterRoute(method, pathname) {
|
|
|
110
111
|
if (method === "POST" && pathname === "/v1/responses") return "responses";
|
|
111
112
|
if (method === "POST" && pathname === "/v1/responses/compact") return "responses_compact";
|
|
112
113
|
if (method === "GET" && pathname === "/v1/models") return "models";
|
|
114
|
+
if (["/v1/images/generations", "/v1/images/edits"].includes(pathname)) return "images";
|
|
113
115
|
if (pathname === "/mcp/image") return "image_mcp";
|
|
114
116
|
return "not_found";
|
|
115
117
|
}
|
package/src/optional-routes.mjs
CHANGED
|
@@ -9,22 +9,16 @@ export function isOptionalRoute(method, pathname) {
|
|
|
9
9
|
// Optional handlers load only on their own routes. Failure is contained by the
|
|
10
10
|
// shared HTTP dispatcher and cannot initialize or change core inference.
|
|
11
11
|
export function createOptionalRoutes(options = {}) {
|
|
12
|
-
let imageMcpHandler = options.imageMcpHandler || null;
|
|
13
12
|
let tools = null;
|
|
14
13
|
let pending = 0;
|
|
15
14
|
return {
|
|
16
15
|
dispose() { tools?.dispose(); },
|
|
17
16
|
busy: () => pending > 0 || tools?.busy?.() === true,
|
|
18
|
-
exportState() {
|
|
17
|
+
exportState() { return { images: [], bytes: 0 }; },
|
|
19
18
|
async importState(state) {
|
|
20
19
|
if (!state || !Array.isArray(state.images)) throw new Error("Invalid optional-service handoff");
|
|
21
|
-
|
|
22
|
-
const { createImageMcpHandler } = await import("./image-mcp.mjs");
|
|
23
|
-
imageMcpHandler ||= createImageMcpHandler({ localHostname: options.imageMcpHostname });
|
|
24
|
-
imageMcpHandler.importState(state.images);
|
|
25
|
-
}
|
|
20
|
+
// Old edit handles are retired; completed files remain user artifacts.
|
|
26
21
|
},
|
|
27
|
-
imageStats() { return imageMcpHandler?.stats?.(); },
|
|
28
22
|
async handle(req, res, pathname) {
|
|
29
23
|
pending++;
|
|
30
24
|
try {
|
|
@@ -41,11 +35,8 @@ export function createOptionalRoutes(options = {}) {
|
|
|
41
35
|
return await serveDashboard(req, res, pathname);
|
|
42
36
|
}
|
|
43
37
|
if (pathname === "/mcp/image") {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
imageMcpHandler ||= createImageMcpHandler({ localHostname: options.imageMcpHostname });
|
|
47
|
-
return imageMcpHandler(req, res);
|
|
48
|
-
});
|
|
38
|
+
res.writeHead(410, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
39
|
+
res.end(JSON.stringify({ error: { code: "ccdx_image_mcp_retired", message: "Use Codex's built-in image tool through CCDX. The image MCP is retired." } }));
|
|
49
40
|
}
|
|
50
41
|
} finally { pending--; }
|
|
51
42
|
},
|
|
@@ -14,7 +14,7 @@ export function createPrivacyDetection(model, {
|
|
|
14
14
|
if (!Number.isSafeInteger(maxConcurrent) || maxConcurrent < 1 || maxConcurrent > 8) throw new Error("Invalid privacy concurrency budget");
|
|
15
15
|
const cache = new Map(), flights = new Map(), turns = [];
|
|
16
16
|
let cacheBytes = 0, pendingBytes = 0, running = 0, closed = false;
|
|
17
|
-
const stats = { submitted_batches: 0, submitted_bytes: 0, cache_hits: 0, shared_hits: 0, skipped_texts: 0, window_evaluations: 0, window_hits: 0, window_shared: 0 };
|
|
17
|
+
const stats = { submitted_batches: 0, submitted_bytes: 0, cache_hits: 0, shared_hits: 0, skipped_texts: 0, window_evaluations: 0, window_hits: 0, window_shared: 0, cpu_batch_groups: 0, cpu_batch_windows: 0 };
|
|
18
18
|
const copy = value => value.map(span => ({ ...span }));
|
|
19
19
|
function get(key) {
|
|
20
20
|
const entry = cache.get(key);if (!entry) return undefined;
|
|
@@ -53,7 +53,7 @@ export function createPrivacyDetection(model, {
|
|
|
53
53
|
const onSubmitted = () => { if (!submitted) { submitted = true;stats.submitted_batches++;stats.submitted_bytes += bytes; } };
|
|
54
54
|
const input = batch.map(entry => entry.text), result = await model.find(input, {
|
|
55
55
|
isNeeded: () => batch.some(entry => entry.waiters > 0), workSignal: lease.controller.signal, onSubmitted,
|
|
56
|
-
onWindowWork(work) { stats.window_evaluations += work.evaluated || 0;stats.window_hits += work.hits || 0;stats.window_shared += work.shared || 0; },
|
|
56
|
+
onWindowWork(work) { stats.window_evaluations += work.evaluated || 0;stats.window_hits += work.hits || 0;stats.window_shared += work.shared || 0;stats.cpu_batch_groups += work.cpu_batch_groups || 0;stats.cpu_batch_windows += work.cpu_batch_windows || 0; },
|
|
57
57
|
onPlan(plan) {
|
|
58
58
|
const entry = batch[plan.text_index];if (!entry || entry.done) return;
|
|
59
59
|
entry.nativePlan = { pending_windows: plan.pending_windows, total_windows: plan.total_windows };
|
package/src/privacy-model.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { promisify } from "node:util";
|
|
|
8
8
|
import { createNpmReleaseFetch, releaseBytes, releaseChecksum, RELEASE_BASE, stableVersion } from "./release-install.mjs";
|
|
9
9
|
|
|
10
10
|
export const PRIVACY_MODEL_REVISION = "7216b6a3b897ef903d4b1ba367ae6fb95b0fa5e4";
|
|
11
|
-
export const PRIVACY_COMPONENT_RELEASE = "1.3.
|
|
11
|
+
export const PRIVACY_COMPONENT_RELEASE = "1.3.13";
|
|
12
12
|
export const PRIVACY_COMPONENT_ABI = 1;
|
|
13
13
|
export const PRIVACY_MODEL_FILES = Object.freeze([
|
|
14
14
|
{ name: "model_int8.onnx", bytes: 330781, sha256: "0a070d3113615e33ba3b84d6bd486f663a377c04c4b056e7381732179f51832a" },
|
|
@@ -153,7 +153,7 @@ export function createPrivacyModel(options = {}) {
|
|
|
153
153
|
const part = line.slice(0, end);line = line.slice(end + 1);
|
|
154
154
|
try {
|
|
155
155
|
const value = JSON.parse(part);
|
|
156
|
-
if (value.ready === true) { clearTimeout(timer);set({ state: "ready", backend: value.backend === "CoreML" ? "CoreML" : "CPU", device: ["CPU", "GPU", "Neural Engine"].includes(value.device) ? value.device : null, window_cache: value.window_cache === true, window_plan: value.window_plan === true, cancel_between_windows: value.cancel_between_windows === true, window_cache_entries: Number.isSafeInteger(value.window_cache_entries) ? value.window_cache_entries : null, window_cache_bytes: Number.isSafeInteger(value.window_cache_bytes) ? value.window_cache_bytes : null });resolve();if (componentRelease !== PRIVACY_COMPONENT_RELEASE && !upgradeAttempted) { upgradeAttempted = true;void download({ background: true }).catch(() => {}); } }
|
|
156
|
+
if (value.ready === true) { clearTimeout(timer);set({ state: "ready", backend: value.backend === "CoreML" ? "CoreML" : "CPU", device: ["CPU", "GPU", "Neural Engine"].includes(value.device) ? value.device : null, window_cache: value.window_cache === true, window_plan: value.window_plan === true, cancel_between_windows: value.cancel_between_windows === true, cpu_short_batch: value.cpu_short_batch === true, window_cache_entries: Number.isSafeInteger(value.window_cache_entries) ? value.window_cache_entries : null, window_cache_bytes: Number.isSafeInteger(value.window_cache_bytes) ? value.window_cache_bytes : null });resolve();if (componentRelease !== PRIVACY_COMPONENT_RELEASE && !upgradeAttempted) { upgradeAttempted = true;void download({ background: true }).catch(() => {}); } }
|
|
157
157
|
else if (jobs.has(value.id)) {
|
|
158
158
|
const job = jobs.get(value.id);
|
|
159
159
|
if (value.phase === "plan") {
|
|
@@ -165,7 +165,7 @@ export function createPrivacyModel(options = {}) {
|
|
|
165
165
|
}
|
|
166
166
|
jobs.delete(value.id);clearTimeout(job.timer);
|
|
167
167
|
if (value.window_work && typeof value.window_work === "object") {
|
|
168
|
-
const work = Object.fromEntries(["evaluated", "hits", "shared", "total"].filter(key => Number.isSafeInteger(value.window_work[key]) && value.window_work[key] >= 0).map(key => [key, value.window_work[key]]));
|
|
168
|
+
const work = Object.fromEntries(["evaluated", "hits", "shared", "total", "cpu_batch_groups", "cpu_batch_windows"].filter(key => Number.isSafeInteger(value.window_work[key]) && value.window_work[key] >= 0).map(key => [key, value.window_work[key]]));
|
|
169
169
|
set({ last_window_work: work, window_cache_entries: Number.isSafeInteger(value.window_cache_entries) ? value.window_cache_entries : null,
|
|
170
170
|
window_cache_bytes: Number.isSafeInteger(value.window_cache_bytes) ? value.window_cache_bytes : null });
|
|
171
171
|
job.onWindowWork?.(work);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isImageModel } from "./image-models.mjs";
|
|
1
2
|
import { autoReviewReasoningEfforts } from "./models.mjs";
|
|
2
3
|
import { modelDisplayName } from "./model-display.mjs";
|
|
3
4
|
// Public metadata only. Credentials and provider transport never enter this layer.
|
|
@@ -11,13 +12,13 @@ export function modelReasoningEfforts(model) {
|
|
|
11
12
|
|
|
12
13
|
export function publicModelCatalog(models, { clients = () => [], selectable = () => false, maker = model => model.publisher || model.vendor || model.owned_by || "Unknown" } = {}) {
|
|
13
14
|
return models.slice(0, 1000).filter(model => typeof model?.id === "string").map(model => ({
|
|
14
|
-
id: model.id, display_name: modelDisplayName(model), vendor: maker(model), ...(model.owned_by ? { owned_by: model.owned_by } : {}),
|
|
15
|
+
id: model.id, ...(isImageModel(model) ? { kind: "image" } : {}), display_name: modelDisplayName(model), vendor: maker(model), ...(model.owned_by ? { owned_by: model.owned_by } : {}),
|
|
15
16
|
endpoints: [["responses", ["/responses", "/v1/responses"]], ["chat", ["/chat/completions", "/v1/chat/completions"]],
|
|
16
|
-
["messages", ["/v1/messages"]]].filter(([, paths]) => paths.some(path => model.supported_endpoints?.includes(path))).map(([label]) => label),
|
|
17
|
+
["messages", ["/v1/messages"]], ["images", ["/images/generations", "/v1/images/generations"]], ["image_edits", ["/images/edits", "/v1/images/edits"]]].filter(([, paths]) => paths.some(path => model.supported_endpoints?.includes(path))).map(([label]) => label),
|
|
17
18
|
preview: model.preview === true, selectable: selectable(model), clients: clients(model),
|
|
18
|
-
reasoning_efforts: modelReasoningEfforts(model), auto_review_efforts: model.capability ? modelReasoningEfforts(model) || [] : autoReviewReasoningEfforts(model),
|
|
19
|
+
reasoning_efforts: isImageModel(model) ? null : modelReasoningEfforts(model), auto_review_efforts: isImageModel(model) ? [] : model.capability ? modelReasoningEfforts(model) || [] : autoReviewReasoningEfforts(model),
|
|
19
20
|
context_window: model.capability?.values.context_window ?? (Number.isSafeInteger(model.capabilities?.limits?.max_context_window_tokens)
|
|
20
21
|
&& model.capabilities.limits.max_context_window_tokens > 0 ? model.capabilities.limits.max_context_window_tokens : null),
|
|
21
|
-
state: model.policy?.state && model.policy.state !== "enabled" ? "restricted" : model.model_picker_enabled === false ? "hidden" : "listed",
|
|
22
|
+
state: model.policy?.state && model.policy.state !== "enabled" ? "restricted" : model.model_picker_enabled === false && !isImageModel(model) ? "hidden" : "listed",
|
|
22
23
|
}));
|
|
23
24
|
}
|
package/src/provider-runtime.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isImageModel, imageModelCatalog } from "./image-models.mjs";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import { providerDescriptors } from "./provider-descriptors.mjs";
|
|
3
4
|
import { autoReviewPreference, writeAutoReviewModel } from "./user-settings.mjs";
|
|
@@ -251,7 +252,7 @@ function createBuiltinProviderRuntime({ githubClient, githubRegistry, refreshGit
|
|
|
251
252
|
const selected = new Set(selectableCopilotModels(catalog).models.map(model => model.id));
|
|
252
253
|
const upstreamHost = githubClient.runtimeStatus?.().upstream_host;
|
|
253
254
|
return { source: "live", checkedAt: new Date().toISOString(), upstreamHost: upstreamHost && upstreamHost !== "unknown" ? upstreamHost : "GitHub Copilot", advertised: catalog.data.length,
|
|
254
|
-
models: publicModelCatalog(catalog.data, { selectable: model => selected.has(model.id), clients: model => selected.has(model.id) ? ["codex"] : [] }) };
|
|
255
|
+
models: publicModelCatalog(catalog.data, { selectable: model => selected.has(model.id) || imageModelCatalog([model]).length > 0, clients: model => selected.has(model.id) || isImageModel(model) ? ["codex"] : [] }) };
|
|
255
256
|
}
|
|
256
257
|
if (provider !== "m365") throw Object.assign(new Error("Unknown provider"), { statusCode: 400 });
|
|
257
258
|
if (!enabled || !["darwin", "win32"].includes(platform)) throw unavailable(!enabled ? "m365_disabled" : "m365_unsupported");
|
package/src/service-control.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { serviceSettingsSnapshot, servicePreferences, writeServicePreference,
|
|
2
2
|
writeTerminalAnimationTheme, writeTerminalColorTheme, responseHistoryLimitPreference, writeResponseHistoryLimitMib,
|
|
3
3
|
nightlyUpdatePreference, writeNightlyUpdatePreference, decodedBodyLimitPreference, writeDecodedBodyLimitMib } from "./user-settings.mjs";
|
|
4
|
-
import { readImageProviderConfig } from "./image-provider-config.mjs";
|
|
5
4
|
import { readPredictionSettings } from "./native-prediction-profile.mjs";
|
|
6
5
|
import { cacheRuntimeSnapshot, cleanRuntimeCaches, setHistoryCacheLimit } from "./cache-control.mjs";
|
|
7
6
|
import { isTerminalAnimationTheme } from "./terminal-animation.mjs";
|
|
@@ -13,7 +12,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
13
12
|
nightlyStatus = () => null, nightlyChanged = () => {},
|
|
14
13
|
manualUpdate, predictionControl = controlPrediction, imageControl = configureImageSetup,
|
|
15
14
|
adapterPort = 2026, adapterHost = "127.0.0.1",
|
|
16
|
-
readImages = () =>
|
|
15
|
+
readImages = () => imageSetupSummary({ env, home }).configured, readPrediction = () => readPredictionSettings({ env, home }) } = {}) {
|
|
17
16
|
const options = { env, home };
|
|
18
17
|
let serial = Promise.resolve(), lastOperation = null, pending = 0;
|
|
19
18
|
const featureSnapshot = read => { try { return read(options); } catch { return { status: "unavailable" }; } };
|
|
@@ -22,10 +21,11 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
22
21
|
let imageConfigured = false, predictionConfigured = false;
|
|
23
22
|
try { imageConfigured = Boolean(readImages()); } catch {}
|
|
24
23
|
try { predictionConfigured = readPrediction().enabled === true; } catch {}
|
|
24
|
+
const image = featureSnapshot(() => imageSetupSummary({ ...options, models: providerRuntime?.imageModels?.().models || [] }));
|
|
25
25
|
const enabled = nightlyUpdatePreference(options), nightly = nightlyStatus();
|
|
26
26
|
const localPrivacy = providerRuntime?.privacy?.snapshot();
|
|
27
27
|
return { source: "service_settings", saved, theme, color_theme, preferences: settingsPreferencesSnapshot(options), local_privacy: localPrivacy,
|
|
28
|
-
features: { prediction: { ...featureSnapshot(predictionControlSnapshot), bridge: prediction?.bridge || "stopped", active: prediction?.active === true }, image
|
|
28
|
+
features: { prediction: { ...featureSnapshot(predictionControlSnapshot), bridge: prediction?.bridge || "stopped", active: prediction?.active === true }, image },
|
|
29
29
|
decoded_body: decodedBodyLimitPreference(options), manual_update: { available: typeof manualUpdate === "function" }, last_operation: lastOperation,
|
|
30
30
|
nightly_update: { enabled, ...nightly, effect: enabled && !nightly ? "next_start" : "immediate" },
|
|
31
31
|
effective: {
|
|
@@ -33,7 +33,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
33
33
|
terminal_animation_enabled: { value: terminal?.enabled === true && saved.terminal_animation_enabled && !/^(0|false|no|off)$/i.test(env.CCDX_TERMINAL_ANIMATION || ""),
|
|
34
34
|
state: terminal?.enabled === true ? "immediate" : "terminal_unavailable", locked: /^(0|false|no|off)$/i.test(env.CCDX_TERMINAL_ANIMATION || "") },
|
|
35
35
|
open_webui: { value: saved.open_webui, state: "next_start" },
|
|
36
|
-
image_enabled: { value: saved.image_enabled && imageConfigured, state: imageConfigured ? "next_call" : "
|
|
36
|
+
image_enabled: { value: saved.image_enabled && imageConfigured && image.selected_available === true, state: !imageConfigured ? "needs_github_access" : image.selected_available ? "next_call" : "image_model_unavailable", configured: imageConfigured },
|
|
37
37
|
prediction_enabled: { value: prediction?.active === true, state: !predictionConfigured ? "needs_setup"
|
|
38
38
|
: prediction?.environment?.status === "needs_app_relaunch" ? "needs_app_relaunch" : prediction?.bridge !== "running" ? "needs_service_restart" : "next_config_request", configured: predictionConfigured },
|
|
39
39
|
}, history: { ...historyLimit, ...cacheRuntimeSnapshot().response_history },
|
|
@@ -43,7 +43,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
43
43
|
if (!input || typeof input !== "object" || Array.isArray(input)) throw new Error("Invalid setting action");
|
|
44
44
|
const allowed = { preference: ["action", "key", "value"], nightly_update: ["action", "enabled"], animation: ["action", "theme"], color_theme: ["action", "theme"],
|
|
45
45
|
history_limit: ["action", "mib"], history_clean: ["action"], prediction_fix: ["action"],
|
|
46
|
-
prediction: ["action", "operation"], image: ["action", "operation", "
|
|
46
|
+
prediction: ["action", "operation"], image: ["action", "operation", "model"],
|
|
47
47
|
update: ["action", "confirmed"], decoded_limit: ["action", "mib"],
|
|
48
48
|
preferences: ["action", "values", "revision"], reset_preferences: ["action", "revision", "backup_id", "scope"], restore_preferences: ["action", "revision", "backup_id", "scope"],
|
|
49
49
|
provider: ["action", "operation", "provider", "model", "auto_review_model", "auto_review_effort", "account_id"] }[input.action];
|
|
@@ -52,9 +52,8 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
52
52
|
if (input.action === "prediction") {
|
|
53
53
|
lastOperation = { feature: "prediction", result: await predictionControl(input.operation, { ...options, integration: clientIntegration }) };
|
|
54
54
|
} else if (input.action === "image") {
|
|
55
|
-
for (const [key, limit] of [["endpoint", 2048], ["key", 8192], ["model", 200]]) if (input[key] !== undefined && (typeof input[key] !== "string" || input[key].length > limit)) throw new Error("Invalid image setup input");
|
|
56
55
|
if (["pause", "resume"].includes(input.operation)) writeServicePreference("image_enabled", input.operation === "resume", options);
|
|
57
|
-
else lastOperation = { feature: "image", result: await imageControl(input, { ...options, adapterPort, adapterHost }) };
|
|
56
|
+
else lastOperation = { feature: "image", result: await imageControl(input, { ...options, providerRuntime, adapterPort, adapterHost }) };
|
|
58
57
|
} else if (input.action === "update") {
|
|
59
58
|
if (input.confirmed !== true) throw new Error("Confirm installation and the idle service switch");
|
|
60
59
|
if (!manualUpdate) throw new Error("This launch cannot update itself; use the installer or start CCDX from its installed command");
|
package/src/service-worker.mjs
CHANGED
|
@@ -8,15 +8,15 @@ import { userSettingsPath } from './user-settings.mjs';
|
|
|
8
8
|
import { readBoundedFileSync } from './bounded-file.mjs';
|
|
9
9
|
import { authProfilePaths, readAuthProfileCredentials } from './auth-profile.mjs';
|
|
10
10
|
import { m365Paths } from './m365-settings.mjs';
|
|
11
|
-
import { imageProviderConfigPath } from './image-provider-config.mjs';
|
|
12
11
|
import { readPredictionSettings } from './native-prediction-profile.mjs';
|
|
12
|
+
import { legacyImageProviderPath } from './image-retirement.mjs';
|
|
13
13
|
|
|
14
14
|
export const HANDOFF_MAX_BYTES = 64 * 1024 * 1024;
|
|
15
15
|
export function clientStateFingerprint(options = {}) {
|
|
16
16
|
const codex = codexPaths(options), connections = accessSettingsPath(options);
|
|
17
17
|
const github = authProfilePaths('codex', options);
|
|
18
18
|
const files = [codex.config, path.join(codex.directory, 'auth.json'), connections, userSettingsPath(options),
|
|
19
|
-
github.tokenPath,
|
|
19
|
+
github.tokenPath, legacyImageProviderPath(options), m365Paths(options).settings, m365Paths(options).gateway,
|
|
20
20
|
path.join(path.dirname(connections), 'client-gateway-keys.json'), path.join(path.dirname(connections), 'codex-gateway-owner.json'), ...Object.values(claudeClientPaths(options))];
|
|
21
21
|
const hash = createHash('sha256');
|
|
22
22
|
const credentials = readAuthProfileCredentials('codex', options);
|