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.
- package/README.md +2 -2
- package/bin/cli.mjs +7 -10
- package/bin/codex-image-host.mjs +11 -0
- package/docs/ARCHITECTURE.md +9 -6
- package/docs/REFERENCE.md +26 -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 +5 -4
- package/src/claude-client-config.mjs +5 -3
- package/src/claude-models.mjs +3 -1
- 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 +17 -12
- package/src/client-model-plan.mjs +3 -1
- package/src/clients/claude-models.mjs +3 -3
- package/src/codex-image-host-launch.mjs +38 -0
- package/src/codex-image-host.mjs +216 -0
- 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/launcher.mjs +7 -4
- package/src/legacy-image-guidance.mjs +73 -0
- package/src/live-models.mjs +2 -1
- package/src/model-capabilities.mjs +9 -0
- package/src/native-images.mjs +111 -0
- package/src/observability.mjs +2 -0
- package/src/optional-routes.mjs +4 -13
- package/src/prediction-control.mjs +1 -0
- 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/dashboard/console.js
CHANGED
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
refreshAnimation() { dashboardRefresh.invalidate("animation");if (current === "system") void dashboardRefresh.refresh("animation", { force: true }); } });
|
|
77
77
|
globalThis.ccdxSettingsPreferences = preferences;
|
|
78
78
|
const features = globalThis.ccdxDashboardFeatures?.create({ element: el, api, apply: applySettings, change, localize: label });
|
|
79
|
-
const states = { immediate: "effective_now", terminal_unavailable: "terminal_animation_unavailable_in_this_output_mode", next_start: "next_ccdx_start", next_call: "applies_to_new_calls", needs_setup: "setup_required",
|
|
79
|
+
const states = { needs_github_access: "image_needs_github", image_model_unavailable: "image_no_models", immediate: "effective_now", terminal_unavailable: "terminal_animation_unavailable_in_this_output_mode", next_start: "next_ccdx_start", next_call: "applies_to_new_calls", needs_setup: "setup_required",
|
|
80
80
|
next_config_request: "next_configuration_request_cached_suggestions_may_remain", needs_app_relaunch: "reopen_the_client_to_finish", needs_service_restart: "restart_ccdx_to_finish" };
|
|
81
81
|
const selectedSource = () => providerEntries.find(source => source.id === el("source-provider").value);
|
|
82
82
|
const sourceReady = () => Boolean(selectedSource()) && (!selectedSource().selection.models_required || Boolean(modelsSource === selectedSource().id && el("source-model").value && el("source-review").value));
|
|
@@ -178,6 +178,7 @@
|
|
|
178
178
|
el("process-notice").textContent = data.terminal?.last_notice || "";
|
|
179
179
|
preferences?.sync(data, meta);
|
|
180
180
|
}
|
|
181
|
+
window.addEventListener("ccdx:connections", event => { if (current === "codex" && event.detail?.imageChanged) void loadSettings(); });
|
|
181
182
|
async function loadSettings() {
|
|
182
183
|
if (settingsPending) return;
|
|
183
184
|
settingsPending = true;
|
|
@@ -197,9 +198,9 @@
|
|
|
197
198
|
if (settingsPending) return;
|
|
198
199
|
settingsPending = true;
|
|
199
200
|
syncAccountControls();
|
|
200
|
-
const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #terminal-color-theme, #m365-enabled, #prediction-continue, #prediction-open, #prediction-setup, #prediction-remove, #image-
|
|
201
|
+
const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #terminal-color-theme, #m365-enabled, #prediction-continue, #prediction-open, #prediction-setup, #prediction-remove, #image-models input, #decoded-limit, #decoded-limit-save, #decoded-limit-default, #install-update")];
|
|
201
202
|
controls.forEach(input => { input.disabled = true; });
|
|
202
|
-
const note = el(body.action === "prediction" ? "prediction-action-note" : body.action === "image" ? "
|
|
203
|
+
const note = el(body.action === "prediction" ? "prediction-action-note" : body.action === "image" ? "effect-image_enabled" : body.action === "update" ? "manual-update-note" : body.action === "decoded_limit" ? "decoded-limit-note" : body.action === "nightly_update" ? "nightly-state" : body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
|
|
203
204
|
: body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
|
|
204
205
|
: body.operation === "switch" ? "source-control-note" : body.operation === "auto-review" ? "review-control-note"
|
|
205
206
|
: body.operation === "account" ? "m365-account-note" : "m365-control-note");
|
|
@@ -213,6 +214,7 @@
|
|
|
213
214
|
if (body.action === "provider" && body.operation === "off") { sourceDirty = false;reviewDirty = false; }
|
|
214
215
|
el("review-control-note").textContent = "";
|
|
215
216
|
applySettings(data);
|
|
217
|
+
if (body.action === "image") void globalThis.ccdxConnections?.load();
|
|
216
218
|
if (initialSourceSave) label(el("source-control-note"), "source_initial_review_saved");
|
|
217
219
|
if (body.operation === "account") {
|
|
218
220
|
sourceDirty = false;reviewDirty = false;sourceGeneration++;
|
|
@@ -271,7 +273,7 @@
|
|
|
271
273
|
try {
|
|
272
274
|
const data = await readModelCatalog(source.id);
|
|
273
275
|
if (generation !== sourceGeneration) return;
|
|
274
|
-
const models = data.models.filter(model => model.selectable && model.clients.includes("codex"));
|
|
276
|
+
const models = data.models.filter(model => model.kind !== "image" && model.selectable && model.clients.includes("codex"));
|
|
275
277
|
sourceModels = models;
|
|
276
278
|
const preference = settings?.providers?.[source.id]?.preference;
|
|
277
279
|
for (const [id, key] of [["source-model", "model"], ["source-review", "auto_review_model"]]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
function create({ element: el, change, localize }) {
|
|
3
|
-
let saved = null,
|
|
3
|
+
let saved = null, limitDirty = false, imageSignature = "";
|
|
4
4
|
const prediction = operation => change({ action: "prediction", operation }, el("prediction-continue"));
|
|
5
5
|
el("setting-prediction_enabled").addEventListener("change", () => void prediction(el("setting-prediction_enabled").checked ? "enable" : "disable"));
|
|
6
6
|
el("prediction-continue").addEventListener("click", () => void prediction(saved?.features?.prediction?.enabled ? "enable" : "disable"));
|
|
@@ -8,29 +8,6 @@
|
|
|
8
8
|
el("prediction-open").addEventListener("click", () => void prediction("open"));
|
|
9
9
|
el("prediction-setup").addEventListener("click", () => void prediction("setup"));
|
|
10
10
|
el("prediction-remove").addEventListener("click", () => { if (window.confirm(globalThis.ccdxLanguage.format("prediction_remove_confirm"))) void prediction("remove"); });
|
|
11
|
-
const imageInput = operation => ({ action: "image", operation, endpoint: el("image-setup-endpoint").value,
|
|
12
|
-
key: el("image-setup-key").value, model: el("image-setup-model").value || undefined });
|
|
13
|
-
el("image-setup-form").addEventListener("input", () => { imageDirty = true; });
|
|
14
|
-
el("image-setup-inspect").addEventListener("click", async () => {
|
|
15
|
-
const data = await change(imageInput("inspect"), el("image-setup-inspect"));
|
|
16
|
-
const result = data?.last_operation?.result;
|
|
17
|
-
if (!Array.isArray(result?.models)) return;
|
|
18
|
-
imageDirty = true;
|
|
19
|
-
const current = el("image-setup-model").value;
|
|
20
|
-
el("image-setup-model").replaceChildren(...result.models.map(id => { const item = document.createElement("option");item.value = item.textContent = id;return item; }));
|
|
21
|
-
if (result.models.includes(current)) el("image-setup-model").value = current;
|
|
22
|
-
localize(el("image-setup-note"), "image_models_ready");
|
|
23
|
-
});
|
|
24
|
-
el("image-setup-form").addEventListener("submit", async event => {
|
|
25
|
-
event.preventDefault();
|
|
26
|
-
const data = await change(imageInput("setup"), el("image-setup-save"));
|
|
27
|
-
if (data?.last_operation?.result?.configured) { imageDirty = false;el("image-setup-key").value = "";render(data);localize(el("image-setup-note"), "image_setup_saved"); }
|
|
28
|
-
});
|
|
29
|
-
el("image-setup-remove").addEventListener("click", async () => {
|
|
30
|
-
if (!window.confirm(globalThis.ccdxLanguage.format("image_remove_confirm"))) return;
|
|
31
|
-
const data = await change({ action: "image", operation: "remove" }, el("image-setup-remove"));
|
|
32
|
-
if (data) { imageDirty = false;el("image-setup-key").value = "";render(data); }
|
|
33
|
-
});
|
|
34
11
|
el("decoded-limit").addEventListener("input", () => { limitDirty = true; });
|
|
35
12
|
const saveLimit = async mib => {
|
|
36
13
|
const data = await change({ action: "decoded_limit", mib }, el(mib === null ? "decoded-limit-default" : "decoded-limit-save"));
|
|
@@ -54,12 +31,25 @@
|
|
|
54
31
|
if (notes) localize(el("prediction-action-note"), !value ? "feature_unavailable" : value.status === "unavailable" ? "feature_read_failed" : pending ? "prediction_quit_continue" : value.enabled && value.bridge !== "running" ? "prediction_bridge_missing" : value.enabled ? "prediction_ready" : "prediction_disabled");
|
|
55
32
|
el("effect-prediction_enabled").hidden = !pending;
|
|
56
33
|
if (pending) localize(el("effect-prediction_enabled"), "feature_pending");
|
|
57
|
-
const image = data.features?.image;
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
const
|
|
34
|
+
const image = data.features?.image, signature = JSON.stringify(image || null);
|
|
35
|
+
if (signature !== imageSignature) {
|
|
36
|
+
imageSignature = signature;
|
|
37
|
+
const list = el("image-models"), focus = list.contains(document.activeElement) ? document.activeElement.value : null;
|
|
38
|
+
list.replaceChildren();
|
|
39
|
+
for (const model of image?.models || []) {
|
|
40
|
+
const label = document.createElement("label"), name = document.createElement("span");name.textContent = model.name || model.id;
|
|
41
|
+
label.className = "image-model-choice";label.dataset.model = model.id;
|
|
42
|
+
if (image.models.length > 1 || image.selected_model !== model.id) {
|
|
43
|
+
const radio = document.createElement("input");radio.type = "radio";radio.name = "image-model";radio.value = model.id;radio.checked = image.selected_model === model.id;
|
|
44
|
+
radio.addEventListener("change", () => { if (radio.checked) void change({ action: "image", operation: "select", model: model.id }, radio); });label.append(radio);
|
|
45
|
+
}
|
|
46
|
+
label.append(name);list.append(label);
|
|
47
|
+
}
|
|
48
|
+
const note = el("image-model-note");note.hidden = image?.availability === "ready";
|
|
49
|
+
if (!note.hidden) localize(note, image?.availability === "needs_github_access" ? "image_needs_github" : image?.availability === "selected_unavailable" ? "image_selected_unavailable" : "image_no_models");
|
|
50
|
+
if (focus) [...list.querySelectorAll("input")].find(input => input.value === focus)?.focus();
|
|
61
51
|
}
|
|
62
|
-
el("image-
|
|
52
|
+
for (const radio of el("image-models").querySelectorAll('input[name="image-model"]')) radio.checked = radio.value === image?.selected_model;
|
|
63
53
|
const limit = data.decoded_body;
|
|
64
54
|
if (!limitDirty && document.activeElement !== el("decoded-limit")) el("decoded-limit").value = limit?.bytes / 1048576 || 128;
|
|
65
55
|
el("decoded-limit").disabled = el("decoded-limit-save").disabled = el("decoded-limit-default").disabled = !limit || limit.source === "environment";
|
package/src/dashboard/index.html
CHANGED
|
@@ -132,10 +132,10 @@
|
|
|
132
132
|
</details>
|
|
133
133
|
<details class="panel dashboard-section" id="additional-capabilities">
|
|
134
134
|
<summary class="panel-heading"><h2 data-i18n="codex_image_generation">IMAGE GENERATION</h2></summary>
|
|
135
|
-
<strong id="image">—</strong><p id="image-detail" class="hint">—</p>
|
|
136
135
|
<div class="setting-row"><label for="setting-image_enabled" data-i18n="allow_new_image_calls">Allow image requests</label><input id="setting-image_enabled" type="checkbox" role="switch" disabled><span id="effect-image_enabled" class="hint" role="status"></span></div>
|
|
137
|
-
<
|
|
138
|
-
<
|
|
136
|
+
<div id="image-models" class="image-models" role="group" aria-label="Image model" data-i18n-label="image_model"></div>
|
|
137
|
+
<p id="image-model-note" class="hint" role="status" hidden></p>
|
|
138
|
+
<div class="image-metrics hint"><strong id="image">—</strong><span id="image-detail">—</span></div>
|
|
139
139
|
</details>
|
|
140
140
|
<details class="panel dashboard-section" id="runtime-resources">
|
|
141
141
|
<summary data-i18n="codex_conversation_buffer">CONVERSATION BUFFER</summary>
|
|
@@ -7,8 +7,12 @@
|
|
|
7
7
|
feature_continue: ["Continue setup", "继续配置"],
|
|
8
8
|
prediction_open: ["Open Codex", "打开 Codex"],
|
|
9
9
|
feature_remove: ["Remove setup", "移除接入"],
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
image_model: ["Image model", "图片模型"],
|
|
11
|
+
image_models: ["Image models", "图片模型"],
|
|
12
|
+
image_needs_github: ["Allow GitHub Copilot access for Codex.", "请允许 Codex 使用 GitHub Copilot。"],
|
|
13
|
+
image_no_models: ["No image models available. Refresh the GitHub model catalog in Model sources.", "暂无可用图片模型。请在模型来源中刷新 GitHub 模型目录。"],
|
|
14
|
+
image_selected_unavailable: ["The saved image model is unavailable. Choose an available model.", "已保存的图片模型当前不可用,请选择可用模型。"],
|
|
15
|
+
image_purpose: ["Image", "图片"],
|
|
12
16
|
update_install_now: ["Install update", "安装更新"],
|
|
13
17
|
advanced_terminal: ["Advanced: terminal commands", "高级:终端命令"],
|
|
14
18
|
compatibility_test: ["Test Codex model compatibility", "测试 Codex 模型兼容性"],
|
|
@@ -16,10 +20,7 @@
|
|
|
16
20
|
advanced_limits: ["Advanced: request limits", "高级:请求限制"],
|
|
17
21
|
decoded_limit: ["Decoded request limit (MiB)", "解码后请求上限(MiB)"],
|
|
18
22
|
prediction_remove_confirm: ["Remove the CCDX prediction trust and route? Quit Codex to finish cleanup.", "移除 CCDX 预测信任与路由?退出 Codex 后才能完成清理。"],
|
|
19
|
-
image_remove_confirm: ["Remove the image service key and CCDX image integration?", "移除图片服务密钥与 CCDX 图片接入?"],
|
|
20
23
|
update_install_confirm: ["Install the latest stable release and switch CCDX when idle? Active work postpones the switch.", "安装最新稳定版并在空闲时切换 CCDX?有执行中的工作时会推迟切换。"],
|
|
21
|
-
image_models_ready: ["Models read. Choose a model, then save.", "已读取模型。选择模型后保存。"],
|
|
22
|
-
image_setup_saved: ["Image generation configured. Existing App tasks may need to refresh their tools.", "图片生成已配置。现有 App 任务可能需要刷新工具。"],
|
|
23
24
|
feature_unavailable: ["Restart the updated CCDX to use these controls.", "重启更新后的 CCDX 以使用这些控制。"],
|
|
24
25
|
prediction_quit_continue: ["Quit Codex, then continue setup here. No terminal command is needed.", "请退出 Codex,再在此继续配置。无需终端命令。"],
|
|
25
26
|
prediction_ready: ["App and thread eligibility still apply.", "仍受 App 与会话适用条件限制。"],
|
|
@@ -399,7 +400,7 @@
|
|
|
399
400
|
"flow_count_lower": ["≥{count} requests", "≥{count} 个请求"],
|
|
400
401
|
"flow_app_codex": ["Codex", "Codex"],
|
|
401
402
|
"prediction_first_setup": ["Quit Codex before first setup: ccdx app codex prediction setup", "首次配置前请退出 Codex:ccdx app codex prediction setup"],
|
|
402
|
-
"image_first_setup": ["
|
|
403
|
+
"image_first_setup": ["Uses the existing GitHub account", "使用现有 GitHub 账号"],
|
|
403
404
|
"record_scope": ["Record scope", "记录范围"],
|
|
404
405
|
"estimated_percentiles": ["Approx. first-output P50 / P95", "首个输出 P50 / P95(约)"],
|
|
405
406
|
"percentile_values": ["{p50} / {p95} ms · {samples} samples", "{p50} / {p95} ms · {samples} 次样本"],
|
|
@@ -955,7 +956,7 @@
|
|
|
955
956
|
"count_succeeded": ["{count} succeeded", "成功:{count}次"],
|
|
956
957
|
"not_initialized": ["NOT CONFIRMED", "未确认"],
|
|
957
958
|
"active_active_failed_failed_delivery_failures_delivery": ["Running: {active} / generation failed: {failed}\nFile delivery failed: {delivery}", "进行中:{active}/生成失败:{failed}\n文件交付失败:{delivery}"],
|
|
958
|
-
"setup_state_unknown_ccdx_image_status": ["
|
|
959
|
+
"setup_state_unknown_ccdx_image_status": ["Uses the existing GitHub Copilot account.", "使用现有 GitHub Copilot 账号。"],
|
|
959
960
|
"snapshot_time": ["Status updated {time}", "状态更新:{time}"],
|
|
960
961
|
"status_unavailable_check_ccdx_then_refresh": ["Cannot read status. Check CCDX and refresh.", "无法读取状态。\n请检查 CCDX 后刷新。"],
|
|
961
962
|
"count_retained_requests_events": ["{count} records retained", "保留:{count}条"],
|
package/src/dashboard/ui.css
CHANGED
|
@@ -233,6 +233,7 @@ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color:
|
|
|
233
233
|
.shell { max-width: 1520px; min-height: 100vh; display: grid; grid-template-columns: 204px minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr) auto; column-gap: 34px; padding: 0 28px; }
|
|
234
234
|
.sidebar { grid-row: 1 / 4; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 22px 24px 0; border-right: 1px solid var(--border); }
|
|
235
235
|
.sidebar-brand { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; column-gap: 12px; color: var(--accent); text-decoration: none; font-size: 23px; font-weight: 750; letter-spacing: .04em; }
|
|
236
|
+
.sidebar-brand > .status-icon, .sidebar-brand > .brand-name { grid-row: 1; }
|
|
236
237
|
|
|
237
238
|
.sidebar nav { display: flex; flex-direction: column; gap: 5px; margin-top: 28px; }
|
|
238
239
|
.sidebar nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; font-size: 13px; border-left: 2px solid transparent; }
|
|
@@ -668,3 +669,8 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
668
669
|
@media (max-width:640px) { .context-metrics { grid-template-columns:repeat(2,minmax(0,1fr));gap:18px; } .context-metrics dd { font-size:21px; } }
|
|
669
670
|
|
|
670
671
|
@media (pointer:coarse) { :root { --control-height:44px; --inline-control-height:44px; } }
|
|
672
|
+
|
|
673
|
+
.image-models { display: grid; gap: 8px; margin-block: 12px; }
|
|
674
|
+
.image-model-choice { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
|
|
675
|
+
.image-model-choice input { flex: 0 0 auto; }
|
|
676
|
+
.image-metrics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
|
package/src/dashboard/ui.js
CHANGED
|
@@ -16,10 +16,10 @@ const finite = (value) => value !== null && value !== undefined && Number.isFini
|
|
|
16
16
|
const number = (value) => finite(value) ? Math.max(0, Math.round(Number(value))).toLocaleString() : "—";
|
|
17
17
|
const mib = (value) => finite(value) ? `${(Number(value) / 1048576).toFixed(1)} MiB` : "—";
|
|
18
18
|
const time = (value, options) => globalThis.ccdxTime?.format(value, options) ?? (value ? new Date(value).toLocaleTimeString() : "—");
|
|
19
|
-
const viewHelpers = { time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator: globalThis.navigator,
|
|
19
|
+
const viewHelpers = { time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator: globalThis.navigator, modelLabel: usageModelLabel,
|
|
20
20
|
motionAllowed: () => !reducedMotion.matches && document.visibilityState === "visible" && element("usage-analytics").open && !element("usage-analytics").closest("[hidden]") };
|
|
21
21
|
const { render, renderActivity, renderProviders, renderFailures, renderContext } = globalThis.ccdxViewBoundary.create("client-features", () => globalThis.ccdxDashboardStatus.create(viewHelpers), ["render", "renderActivity", "renderProviders", "renderFailures", "renderContext"]);
|
|
22
|
-
const usageView = globalThis.ccdxViewBoundary.create("usage-analytics", () => globalThis.ccdxDashboardUsage.create(viewHelpers), ["applyUsage", "renderUsageState", "renderAnalytics", "renderUsageTable", "selectUsageDay", "usageValues", "setChartVisible", "revealChart", "stopMotion"]);
|
|
22
|
+
const usageView = globalThis.ccdxViewBoundary.create("usage-analytics", () => globalThis.ccdxDashboardUsage.create(viewHelpers), ["applyUsage", "renderUsageState", "renderAnalytics", "renderUsageTable", "selectUsageDay", "usageValues", "setChartVisible", "revealChart", "stopMotion", "refreshModelLabels"]);
|
|
23
23
|
const { applyUsage, renderUsageState, renderAnalytics, renderUsageTable, selectUsageDay } = usageView;
|
|
24
24
|
const loadAuth = () => dashboardRefresh.refresh("auth", { force: true });
|
|
25
25
|
|
|
@@ -74,6 +74,13 @@ function tableRow(values, { total = false, labels = [] } = {}) {
|
|
|
74
74
|
let providerEntries = [];
|
|
75
75
|
let usageProviders = {};
|
|
76
76
|
let selectedProvider = "";
|
|
77
|
+
function usageModelLabel(value) {
|
|
78
|
+
if (typeof value !== "string") return value;
|
|
79
|
+
const at = value.indexOf(" / "), id = value.slice(0, at);
|
|
80
|
+
if (at < 0 || !id.startsWith("api_")) return value;
|
|
81
|
+
const name = providerEntries.find(provider => provider.id === id)?.name;
|
|
82
|
+
return name ? name + value.slice(at) : value;
|
|
83
|
+
}
|
|
77
84
|
const modelSnapshots = new Map();
|
|
78
85
|
const providerTabs = new Map();
|
|
79
86
|
try { selectedProvider = localStorage.getItem("ccdx.dashboard.modelProvider") || ""; } catch { /* Page-local choice still works. */ }
|
|
@@ -134,6 +141,7 @@ function applyProviders(data, { changed }) {
|
|
|
134
141
|
}
|
|
135
142
|
if (changed || dashboardRefresh.state("auth").error) renderProviders(data);
|
|
136
143
|
syncUsageProviders();
|
|
144
|
+
if (sourceChoicesChanged) usageView.refreshModelLabels();
|
|
137
145
|
const available = providerEntries.some(provider => provider.id === selectedProvider);
|
|
138
146
|
if (!available) selectedProvider = providerEntries.find(provider => provider.clients?.some(client => client.id === "codex" && client.selected))?.id || providerEntries[0]?.id || "";
|
|
139
147
|
syncProviderDetails();
|
|
@@ -203,6 +211,7 @@ function applyModels(data, { changed }) {
|
|
|
203
211
|
for (const model of data.models) {
|
|
204
212
|
const clients = (model.clients || []).map(id => ({ codex: "Codex App", claude_app: "Claude App", claude_code: "Claude Code" })[id] || id).join(" / ") || "—";
|
|
205
213
|
const row = tableRow([model.display_name || model.id, clients, ""]);row.children[0].className = "model-name";
|
|
214
|
+
if (model.kind === "image") { const badge = document.createElement("span");badge.className = "model-maker";localize(badge, "image_purpose");row.children[0].append(badge); }
|
|
206
215
|
if (model.vendor && model.vendor !== "Unknown") { const maker = document.createElement("span");maker.className = "model-maker";maker.textContent = model.vendor;row.children[0].append(maker); }
|
|
207
216
|
const details = document.createElement("details"), summary = document.createElement("summary"), fields = document.createElement("dl");
|
|
208
217
|
details.dataset.model = model.id;details.open = expanded.has(model.id);fields.className = "failure-detail";
|
package/src/dashboard/usage.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
}).join(" ");
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function create({ time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator, motionAllowed = () => false }) {
|
|
10
|
+
function create({ time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator, modelLabel = value => value, motionAllowed = () => false }) {
|
|
11
11
|
function usageValues(row) {
|
|
12
12
|
const rate = Number.isFinite(row.cache_hit_rate) && row.cache_hit_rate >= 0 && row.cache_hit_rate <= 1
|
|
13
13
|
? `${row.cache_hit_rate_partial ? "~" : ""}${(row.cache_hit_rate * 100).toFixed(1)}%` : "—";
|
|
14
|
-
return [row.model, number(row.requests), number(row.input_tokens), number(row.cache_read_tokens), number(row.cache_write_input_tokens), number(row.output_tokens), number(row.total_tokens), rate];
|
|
14
|
+
return [modelLabel(row.model), number(row.requests), number(row.input_tokens), number(row.cache_read_tokens), number(row.cache_write_input_tokens), number(row.output_tokens), number(row.total_tokens), rate];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
let usageData = null;
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
text("usage-state", day ? day.date : "local_log");
|
|
118
118
|
text("usage-note", "records_records_shown_of_models_models_shown_day", {
|
|
119
119
|
records: number(total.requests), shown: number(rows.length), models: number(day ? rows.length : usageData.model_count),
|
|
120
|
-
day: day ? phrase("zone_model", { zone: usageData.analytics.time_zone, model: model
|
|
120
|
+
day: day ? phrase("zone_model", { zone: usageData.analytics.time_zone, model: model ? modelLabel(model) : phrase("all_models") }) : "",
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
for (const model of [...new Set(["", ...usageData.analytics.models, ...(previous ? [previous] : [])])]) {
|
|
220
220
|
const option = document.createElement("option");
|
|
221
221
|
option.value = model;
|
|
222
|
-
if (model) option.textContent = model;
|
|
222
|
+
if (model) option.textContent = modelLabel(model);
|
|
223
223
|
else localize(option, "all_models");
|
|
224
224
|
select.append(option);
|
|
225
225
|
}
|
|
@@ -239,7 +239,12 @@
|
|
|
239
239
|
text("analytics-updated", "updated_time", { time: time(Date.now()) });
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
|
|
242
|
+
function refreshModelLabels() {
|
|
243
|
+
if (!usageData) return;
|
|
244
|
+
if (usageData.analytics) updateAnalyticsModels();
|
|
245
|
+
renderUsageTable();
|
|
246
|
+
}
|
|
247
|
+
return { applyUsage, renderUsageState, renderAnalytics, renderUsageTable, selectUsageDay, usageValues, setChartVisible, revealChart, stopMotion, refreshModelLabels, get data() { return usageData; }, get selectedDate() { return selectedUsageDate; } };
|
|
243
248
|
}
|
|
244
249
|
globalThis.ccdxDashboardUsage = { create, curvePath };
|
|
245
250
|
})();
|
package/src/dashboard-api.mjs
CHANGED
|
@@ -339,8 +339,9 @@ export async function handleDashboardApi(req, res, pathname, {
|
|
|
339
339
|
selectable: models.filter(model => model.selectable !== false).length,
|
|
340
340
|
models: models.slice(0, 500).map((model) => ({
|
|
341
341
|
id: safeText(model.id, 160),
|
|
342
|
+
...(model.kind === "image" ? { kind: "image", display_name: safeText(model.display_name || model.id, 160) } : {}),
|
|
342
343
|
vendor: safeText(model.vendor, 80),
|
|
343
|
-
endpoints: Array.isArray(model.endpoints) ? model.endpoints.filter((value) => ["responses", "chat", "messages"].includes(value)) : [],
|
|
344
|
+
endpoints: Array.isArray(model.endpoints) ? model.endpoints.filter((value) => ["responses", "chat", "messages", "images", "image_edits"].includes(value)) : [],
|
|
344
345
|
preview: model.preview === true,
|
|
345
346
|
selectable: model.selectable !== false,
|
|
346
347
|
clients: Array.isArray(model.clients) ? model.clients.filter(value => typeof value === "string").slice(0, 8).map(value => safeText(value, 40)) : [],
|
package/src/doctor.mjs
CHANGED
|
@@ -13,14 +13,13 @@ import { adapterBaseUrl, checkRunningAdapter } from "./running-adapter.mjs";
|
|
|
13
13
|
import { inspectCodexConfig } from "./codex-config-doctor.mjs";
|
|
14
14
|
import { inspectPackageUpdateEnvironment } from "./package-update.mjs";
|
|
15
15
|
import { inspectCredentialPermissions } from "./credential-permissions.mjs";
|
|
16
|
-
import { imageProviderConfigPath } from "./image-provider-config.mjs";
|
|
17
16
|
import { terminalCell } from "./terminal-text.mjs";
|
|
18
17
|
import { redactDiagnosticText } from "./diagnostic-text.mjs";
|
|
19
18
|
import { inspectWindowsCommand } from "./windows-command.mjs";
|
|
20
19
|
import { readPredictionSettings } from "./native-prediction-profile.mjs";
|
|
21
20
|
import { inspectPredictionEnvironment } from "./native-prediction-environment.mjs";
|
|
22
21
|
import { formatPredictionEnvironment } from "./native-prediction-state.mjs";
|
|
23
|
-
import {
|
|
22
|
+
import { imageSetupSummary } from "./image-setup.mjs";
|
|
24
23
|
import { inspectAdapterCompatibility } from "./doctor-compat.mjs";
|
|
25
24
|
import { readProviderSettings } from "./provider-settings.mjs";
|
|
26
25
|
export { selectCompatibilityModels, inspectAdapterCompatibility } from "./doctor-compat.mjs";
|
|
@@ -197,7 +196,7 @@ export async function collectDoctorChecks({
|
|
|
197
196
|
inspectWindowsCommandFn = inspectWindowsCommand,
|
|
198
197
|
readPredictionSettingsFn = readPredictionSettings,
|
|
199
198
|
inspectPredictionEnvironmentFn = inspectPredictionEnvironment,
|
|
200
|
-
readImageProviderConfigFn =
|
|
199
|
+
readImageProviderConfigFn = imageSetupSummary,
|
|
201
200
|
providerControlFn,
|
|
202
201
|
} = {}) {
|
|
203
202
|
if (configOnly) return inspectCodexConfig({ home, env, host, port });
|
|
@@ -227,7 +226,7 @@ export async function collectDoctorChecks({
|
|
|
227
226
|
} catch { checks.push({ kind: "warn", message: "Prediction environment could not be verified; existing routing and trust settings preserved", fix: "ccdx app codex prediction status" }); }
|
|
228
227
|
try {
|
|
229
228
|
const image = readImageProviderConfigFn({ home, env, strict: true });
|
|
230
|
-
checks.push({ kind: "info", message: image ? "
|
|
229
|
+
checks.push({ kind: "info", message: image?.configured ? "Native images use GitHub Copilot; no provider request was made" : "Native images need GitHub Copilot access" });
|
|
231
230
|
} catch { checks.push({ kind: "warn", message: "Image provider configuration is invalid; core service is unaffected", fix: "ccdx app codex image status" }); }
|
|
232
231
|
const updateEnvironment = inspectUpdateEnvironmentFn();
|
|
233
232
|
const updateMessage = updateEnvironment.state === "different" ? "npm update target differs from this CCDX installation; review PATH/prefix before updating"
|
|
@@ -237,7 +236,7 @@ export async function collectDoctorChecks({
|
|
|
237
236
|
.filter(key => updateEnvironment[key]).map(key => `${key}=${terminalCell(updateEnvironment[key])}`).join(" / ");
|
|
238
237
|
checks.push({ kind: updateEnvironment.state === "different" || updateEnvironment.state === "unavailable" ? "warn" : "ok",
|
|
239
238
|
message: `${updateMessage}${updatePaths ? ` / ${updatePaths}` : ""}` });
|
|
240
|
-
for (const [label, file] of [["GitHub token", githubTokenPath(home)]
|
|
239
|
+
for (const [label, file] of [["GitHub token", githubTokenPath(home)]]) {
|
|
241
240
|
const permissions = inspectCredentialPermissionsFn(file);
|
|
242
241
|
if (permissions === "missing") continue;
|
|
243
242
|
checks.push({ kind: permissions === "review" || permissions === "unavailable" ? "warn" : "ok",
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { modelDisplayName } from "./model-display.mjs";
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_IMAGE_MODEL = "gpt-image-2.5-flare";
|
|
4
|
+
const paths = { generations: ["/images/generations", "/v1/images/generations"], edits: ["/images/edits", "/v1/images/edits"] };
|
|
5
|
+
export function isImageModel(model) {
|
|
6
|
+
return model?.capabilities?.type === "image";
|
|
7
|
+
}
|
|
8
|
+
export function imageModelCatalog(value) {
|
|
9
|
+
const models = Array.isArray(value) ? value : value?.data;
|
|
10
|
+
if (!Array.isArray(models)) return [];
|
|
11
|
+
return models.filter(model => isImageModel(model) && Array.isArray(model.supported_endpoints) && paths.generations.some(path => model.supported_endpoints?.includes(path)) && (!model.policy?.state || model.policy.state === "enabled")
|
|
12
|
+
&& typeof model.id === "string" && model.id.length > 0 && model.id.length <= 200 && !/[\x00-\x1f\x7f]/.test(model.id))
|
|
13
|
+
.map(model => ({ id: model.id, name: modelDisplayName(model), source: "github", kind: "image",
|
|
14
|
+
editing: paths.edits.some(path => model.supported_endpoints?.includes(path)) }));
|
|
15
|
+
}
|
|
16
|
+
export function imageModelSelection(models, saved) {
|
|
17
|
+
const selected = saved || models.find(model => model.id === DEFAULT_IMAGE_MODEL)?.id || models[0]?.id || null;
|
|
18
|
+
return { models, selected_model: selected, selection_source: saved ? "saved" : "default",
|
|
19
|
+
selected_available: Boolean(selected && models.some(model => model.id === selected)) };
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { codexPaths } from "./codex-paths.mjs";
|
|
5
|
+
import { withFileLockSync } from "./lock.mjs";
|
|
6
|
+
import { atomicWriteFileIfChangedSync } from "./atomic-file.mjs";
|
|
7
|
+
import { computeImageMcpCodexConfig } from "./config.mjs";
|
|
8
|
+
import { parseCodexToml } from "./config-toml.mjs";
|
|
9
|
+
import { removeLegacyImageGuidance } from "./legacy-image-guidance.mjs";
|
|
10
|
+
|
|
11
|
+
export function legacyImageProviderPath({ env = process.env, home = os.homedir() } = {}) {
|
|
12
|
+
return path.join(String(env.XDG_CONFIG_HOME || "").trim() || path.join(home, ".config"), "codex-copilot-dx", "image-provider.json");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function retireLegacyImages({ env = process.env, home = os.homedir(), codexPath = codexPaths({ env, home }).config,
|
|
16
|
+
adapterPort = 2026, adapterHost = "127.0.0.1" } = {}) {
|
|
17
|
+
const providerPath = legacyImageProviderPath({ env, home });
|
|
18
|
+
const credentialRemoved = fs.existsSync(providerPath);
|
|
19
|
+
fs.rmSync(providerPath, { force: true });
|
|
20
|
+
const guidance = removeLegacyImageGuidance({ codexPath });
|
|
21
|
+
let configChanged = false, preservedMcp = false;
|
|
22
|
+
if (fs.existsSync(codexPath)) withFileLockSync(`${codexPath}.ccdx.lock`, () => {
|
|
23
|
+
const before = new TextDecoder("utf-8", { fatal: true }).decode(fs.readFileSync(codexPath));
|
|
24
|
+
const config = computeImageMcpCodexConfig(before, { enabled: false, adapterPort, adapterHost });
|
|
25
|
+
if (config.changed) {
|
|
26
|
+
if (fs.readFileSync(codexPath, "utf8") !== before) throw new Error("Codex configuration changed during image retirement");
|
|
27
|
+
atomicWriteFileIfChangedSync(codexPath, config.content);configChanged = true;
|
|
28
|
+
}
|
|
29
|
+
preservedMcp = Boolean(parseCodexToml(config.content).mcp_servers?.ccdx_image);
|
|
30
|
+
});
|
|
31
|
+
return { changed: credentialRemoved || configChanged || guidance.changed, credentialRemoved, configChanged,
|
|
32
|
+
preserved: preservedMcp || Boolean(guidance.preserved), preservedMcp, preservedGuidance: Boolean(guidance.preserved) };
|
|
33
|
+
}
|
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
|
}
|
package/src/launcher.mjs
CHANGED
|
@@ -61,7 +61,7 @@ export function macPredictionAppProcesses(app, { exec = execFileSync } = {}) {
|
|
|
61
61
|
return rows;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export async function openCodex({ env = process.env, spawnImpl = spawn, platform = process.platform, predictionPacUrl = null, predictionApp = null, predictionProfile = null,
|
|
64
|
+
export async function openCodex({ env = process.env, spawnImpl = spawn, platform = process.platform, predictionPacUrl = null, predictionApp = null, predictionProfile = null, imageHost = null,
|
|
65
65
|
preparePredictionRoute, persistedPredictionRoute = false, onPredictionRoute = () => {}, log = console.log,
|
|
66
66
|
resolveWindowsApp = installedWindowsPredictionApp, windowsAppProcesses = windowsPredictionAppProcesses,
|
|
67
67
|
macAppProcesses = macPredictionAppProcesses } = {}) {
|
|
@@ -124,6 +124,9 @@ export async function openCodex({ env = process.env, spawnImpl = spawn, platform
|
|
|
124
124
|
return false;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
const imageArgs = platform === "darwin" && imageHost?.env?.CODEX_CLI_PATH
|
|
128
|
+
? ["--env", "CODEX_CLI_PATH=" + imageHost.env.CODEX_CLI_PATH] : [];
|
|
129
|
+
if (imageArgs.length) log(status("info", "Image host configured for the next Codex launch and new chats; a running App is not restarted"));
|
|
127
130
|
const extraArgs = isPredictionPacUrl(predictionPacUrl)
|
|
128
131
|
&& APP_PATH_CANDIDATES.includes(predictionApp)
|
|
129
132
|
? ["--args", `--proxy-pac-url=${predictionPacUrl}`] : [];
|
|
@@ -140,7 +143,7 @@ export async function openCodex({ env = process.env, spawnImpl = spawn, platform
|
|
|
140
143
|
throw new Error("Running Codex App uses an old or unverified prediction route. Fully quit the App, then run ccdx again; no process was stopped");
|
|
141
144
|
}
|
|
142
145
|
await preparePredictionRoute?.();
|
|
143
|
-
if (!await tryOpen([predictionApp, ...extraArgs], { spawnImpl })) {
|
|
146
|
+
if (!await tryOpen([predictionApp, ...imageArgs, ...extraArgs], { spawnImpl })) {
|
|
144
147
|
onPredictionRoute("unverified");log(status("warn", "Could not open Codex App"));return false;
|
|
145
148
|
}
|
|
146
149
|
for (let attempt = 0; attempt < 10; attempt++) {
|
|
@@ -157,9 +160,9 @@ export async function openCodex({ env = process.env, spawnImpl = spawn, platform
|
|
|
157
160
|
onPredictionRoute("unverified");log(status("warn", `Optional macOS prediction launch skipped: ${error.message}`));return false;
|
|
158
161
|
}
|
|
159
162
|
}
|
|
160
|
-
const attempts = launchAttempts();
|
|
163
|
+
const attempts = imageArgs.length && APP_PATH_CANDIDATES.includes(imageHost.app) ? [[imageHost.app]] : launchAttempts();
|
|
161
164
|
for (const attempt of attempts) {
|
|
162
|
-
const args = [...attempt, ...extraArgs];
|
|
165
|
+
const args = [...attempt, ...imageArgs, ...extraArgs];
|
|
163
166
|
if (await tryOpen(args, { spawnImpl })) {
|
|
164
167
|
log(status("ok", "Codex opened"));
|
|
165
168
|
return true;
|