codex-copilot-dx 1.3.15 → 1.3.17
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 +3 -1
- package/bin/cli.mjs +7 -9
- package/docs/ARCHITECTURE.md +9 -1
- package/docs/REFERENCE.md +10 -3
- package/package.json +1 -1
- package/src/claude-gateway.mjs +7 -0
- package/src/cli-command-spec.mjs +2 -2
- package/src/cli-image.mjs +6 -3
- package/src/codex-image-host.mjs +32 -10
- package/src/dashboard/console.js +2 -2
- package/src/dashboard/features.js +12 -1
- package/src/dashboard/flow.js +4 -0
- package/src/dashboard/index.html +3 -0
- package/src/dashboard/language.js +17 -0
- package/src/image-control.mjs +42 -0
- package/src/image-host-state.mjs +26 -0
- package/src/launcher.mjs +7 -0
- package/src/management-routes.mjs +2 -0
- package/src/models.mjs +3 -3
- package/src/service-control.mjs +9 -4
- package/src/startup-ui.mjs +6 -0
- package/src/stream-performance.mjs +6 -2
- package/src/terminal-console.mjs +3 -1
package/README.md
CHANGED
|
@@ -60,10 +60,12 @@ Use `ccdx help` or `ccdx <command> --help` for options. The CLI uses English; th
|
|
|
60
60
|
|
|
61
61
|
## Features and maintenance
|
|
62
62
|
|
|
63
|
+
Start CCDX to open Codex with native image tools, then use a new chat. If image access is missing, use the Web UI image checks or `ccdx app codex image check`, `repair` and `open`. Running Apps are never forcibly restarted.
|
|
64
|
+
|
|
63
65
|
Use the Web UI for accounts, APIs, models, client access, input suggestions, native images, local masking, appearance, diagnostics and updates. CLI commands remain available for automation and recovery. See the [control reference](docs/REFERENCE.md#webui-and-cli-controls).
|
|
64
66
|
|
|
65
67
|
- **Input suggestions:** new integrations attempt setup by default when Codex is closed. Saved off choices are retained. The Web UI can enable, disable, finish setup, open Codex and repair the bridge. Setup synchronizes Show predictions, adds App-profile trust and locally decrypts the prediction hosts' HTTPS traffic. App/thread eligibility still applies. [Details](docs/REFERENCE.md#optional-native-predictions).
|
|
66
|
-
- **Images:** Codex native host tools use the selected GitHub image model, with GPT Image 2.5 Flare as the default. Images start enabled; saved off choices are retained. On macOS with Codex 0.166+, start Codex through CCDX and use a new chat
|
|
68
|
+
- **Images:** Codex native host tools use the selected GitHub image model, with GPT Image 2.5 Flare as the default. Images start enabled; saved off choices are retained. On macOS with Codex 0.166+, fully quit a running App that lacks the host, start Codex through CCDX, and use a new chat. ChatGPT sign-in and Apps are retained. The Web UI provides model selection without an extra API key, MCP or CCDX image skill. [Details](docs/REFERENCE.md#native-image-generation).
|
|
67
69
|
- **Updates:** Settings → Install update downloads and verifies a stable release, then switches the installed service when idle. Busy work postpones the switch. Unmanaged launches require the installer or an installed command. [Details](docs/REFERENCE.md#installation-and-updates).
|
|
68
70
|
|
|
69
71
|
Web UI activity updates through server push; the terminal uses the same in-process activity feed. Reconnecting restores current state and bounded recent records.
|
package/bin/cli.mjs
CHANGED
|
@@ -282,7 +282,7 @@ const { createProfileModelRuntime } = await import("../src/profile-model-runtime
|
|
|
282
282
|
const { createCodexModelCatalog } = await import("../src/codex-model-catalog.mjs");
|
|
283
283
|
const { createProviderRuntime } = await import("../src/provider-runtime.mjs");
|
|
284
284
|
const { setResponseHistoryMaxBytes } = await import("../src/response-history.mjs");
|
|
285
|
-
const { startupBanner, startupCheck, startupReady, startupLogger, predictionStartupCheck, providerStartupChecks, createStartupPresentation } = await import("../src/startup-ui.mjs");
|
|
285
|
+
const { startupBanner, startupCheck, startupReady, startupLogger, predictionStartupCheck, imageStartupCheck, providerStartupChecks, createStartupPresentation } = await import("../src/startup-ui.mjs");
|
|
286
286
|
const { createTerminalConsole } = await import("../src/terminal-console.mjs");
|
|
287
287
|
const { createServiceControl } = await import("../src/service-control.mjs");
|
|
288
288
|
const { openDashboard } = await import("../src/browser-launch.mjs");
|
|
@@ -375,12 +375,11 @@ async function reuseRunningAdapterIfAvailable() {
|
|
|
375
375
|
if (!predictionPacUrl) console.warn(status("warn", "Restart ccdx to activate the newly enabled prediction bridge"));
|
|
376
376
|
}
|
|
377
377
|
} catch (error) { console.warn(status("warn", error.message)); }
|
|
378
|
-
|
|
379
|
-
|
|
378
|
+
const imageHost = codexEnabled && imageEnabled ? await (await clientIntegrations()).imageHostLaunch() : null;
|
|
379
|
+
if (codexEnabled) await openCodex({ predictionPacUrl, predictionApp, predictionProfile, persistedPredictionRoute, imageHost,
|
|
380
380
|
onPredictionRoute: route => { launchRoute = route; }, log: startupLogger("App") });
|
|
381
381
|
console.log(predictionStartupCheck({ configured: predictionConfigured, bridge: predictionPacUrl ? "running" : "unknown", launch_route: launchRoute }));
|
|
382
|
-
console.log(
|
|
383
|
-
? imageMcpSkipped ? "App setup skipped; see warning" : "Configured; not tested" : "Off"));
|
|
382
|
+
console.log(imageStartupCheck({ enabled: imageEnabled, prepared: Boolean(imageHost), skipped: imageMcpSkipped }));
|
|
384
383
|
console.log(providerStartupChecks((await serviceStatus)?.data));
|
|
385
384
|
console.log(startupReady({ baseUrl: running.baseUrl, commandName: CLI_NAME, reused: true }));
|
|
386
385
|
await launchDashboard();
|
|
@@ -533,13 +532,12 @@ try {
|
|
|
533
532
|
const persistentRoute = await nativePrediction?.prepareRoute();
|
|
534
533
|
|
|
535
534
|
// Launch Codex when available. A running App is never forcibly restarted.
|
|
536
|
-
|
|
537
|
-
|
|
535
|
+
const imageHost = codexEnabled && imageEnabled ? await clientIntegration.imageHostLaunch() : null;
|
|
536
|
+
if (codexEnabled) await openCodex({ predictionPacUrl: nativePrediction?.pacUrl, predictionApp: nativePrediction?.app, predictionProfile: nativePrediction?.profile, imageHost,
|
|
538
537
|
preparePredictionRoute: () => nativePrediction?.prepareRoute(), persistedPredictionRoute: persistentRoute?.status === "installed",
|
|
539
538
|
onPredictionRoute: route => clientIntegration?.launched(route), log: startupLogger("App") });
|
|
540
539
|
console.log(predictionStartupCheck(clientIntegration?.snapshot().prediction));
|
|
541
|
-
console.log(
|
|
542
|
-
? imageMcpSkipped ? "App setup skipped; see warning" : "Configured; not tested" : "Off"));
|
|
540
|
+
console.log(imageStartupCheck({ enabled: imageEnabled, prepared: Boolean(imageHost), skipped: imageMcpSkipped }));
|
|
543
541
|
console.log(providerStartupChecks(activeServer.ccdxSnapshot?.()));
|
|
544
542
|
|
|
545
543
|
// Periodically refresh the model list + endpoint cache so a long-running
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -11,7 +11,7 @@ Client integration, image tools and the dashboard are not a general plugin frame
|
|
|
11
11
|
| Provider composition | `provider-runtime.mjs`, `connection-runtime.mjs`, provider/access settings | Explicit selection, lifecycle, history namespaces and snapshots |
|
|
12
12
|
| Claude clients | `claude-gateway.mjs`, `claude-client-lifecycle.mjs`, `claude-client-config.mjs`, `claude-models.mjs` | Native Messages relay and field-owned reversible client setup |
|
|
13
13
|
| Client integration | `client-integration.mjs`, Codex config, native prediction | Client setup, optional start/stop, diagnostic snapshots |
|
|
14
|
-
| Native images | Images routes, native SDK host tools, GHC client, preference controls and legacy retirement | Native tool progress and
|
|
14
|
+
| Native images | Images routes, native SDK host tools, GHC client, preference controls and legacy retirement | Native tool progress and image content through the existing GitHub account; ChatGPT Apps and sign-in retained, no image MCP or separate credential |
|
|
15
15
|
| Management | CLI, dashboard, observability, package updates | Bounded metadata and explicit user actions |
|
|
16
16
|
| Shared foundations | Codex paths, file locks, atomic files, network routes | No dependency on inference or dashboard rendering |
|
|
17
17
|
|
|
@@ -1077,6 +1077,8 @@ Claude passthrough now holds incomplete SSE frames and validates complete data b
|
|
|
1077
1077
|
|
|
1078
1078
|
`image-setup.mjs` projects native GHC image availability and selection; `service-control.mjs` serializes toggle and model-selection changes. `image-retirement.mjs` removes the independent image credential, recognizable old MCP declarations and unmodified guidance. Customized files are preserved with a warning. Codex’s native image extension sends separate JSON generation/edit requests through its configured provider, saves the resulting pixels and emits image items to the App; CCDX reuses GHC authentication and maps the native alias to the saved GHC image selection. `image-models.mjs` interprets declared image capabilities independently of conversation picker flags; `clients.codex.image_model` is the canonical selection shared by controls, model configuration and the Images route. Image-only selection does not change conversation bindings or history isolation. The browser has no image API address/key form. The model compatibility action uses `doctor-compat.mjs` through local tools and requires explicit quota confirmation.
|
|
1079
1079
|
|
|
1080
|
+
On macOS, the owned Codex launcher supplies the stdio host adapter to a new App process without changing the signed App or account. The host reads the loopback dashboard settings route with its required dashboard header before registering the image tool; disabled or unreadable settings leave it unregistered. A running App retains its old environment, so startup explains how to activate a missing host without restarting that App.
|
|
1081
|
+
|
|
1080
1082
|
The existing supervisor accepts a bounded manual update request as well as its optional nightly scheduler. Both use the same staged package verification, immutable worker, state-transfer, installation commit and rollback path. Manual and scheduled updates are mutually exclusive; settings operations contribute to busy state and stable prediction intent/trust participate in the state fingerprint; the legacy image credential path remains in this fingerprint for old-worker compatibility, and legacy image cleanup runs only after activation; native port allocation and App stat bookkeeping do not. Warm handoff suppresses first-time prediction setup and pending display writes. Explicit prediction reconfiguration replaces the old bridge after committing trust. An unowned installation falls back to the existing standalone launch and exposes that self-update is unavailable. No inference protocol, privacy transport or native authentication path is changed by these controls.
|
|
1081
1083
|
|
|
1082
1084
|
Native discovery, configuration and startup environment inspection run in bounded temporary `prediction-operations.mjs` workers. PowerShell, certificate and filesystem work do not block the gateway event loop. Registered-App discovery precedes default trust/proxy setup; missing Apps leave core startup available. Private environment results feed only bridge initialization and are not returned by WebUI actions.
|
|
@@ -1108,3 +1110,9 @@ The 1.3.13 native helper groups uncached short CPU sequences under the existing
|
|
|
1108
1110
|
Claude App 3.x and 4.x share the inspected effort-capable adapter. Later unknown major versions retain conservative routes and preserve existing shared capability settings. Contiguous effort declarations select the source-qualified reasoning route; a gapped declaration with at least two lower contiguous levels can expose that safe prefix with an App maximum cap, while retaining the complete upstream declaration and reporting the hidden levels as limited. Prior route spellings remain accepted for existing conversations. Resynchronization carries long-context preference and model order between the two known source-qualified spellings, and replaces only owned shared capability fields. No undeclared effort is added. The sidebar brand places its shared atom icon and text in one grid row so the intro icon's two-row span cannot offset the label.
|
|
1109
1111
|
|
|
1110
1112
|
Usage presentation maps configured api_ identifiers to current provider labels after aggregation. Rows, chart filters and historical statistics keep their original keys. Provider-label changes refresh only the table/model labels, preserving the selected raw model key, day and existing chart nodes. The native capability replay disables usage persistence and gives its process a temporary usage path; no production filter recognizes test model names or response IDs.
|
|
1113
|
+
|
|
1114
|
+
## Native image recovery and request correlation (1.3.17)
|
|
1115
|
+
|
|
1116
|
+
`image-control.mjs` owns explicit check/repair/open operations for WebUI and terminal commands, reusing client configuration, host preparation and the existing prediction-aware launcher. Repair cannot kill an App or start another service. `image-host-state.mjs` retains bounded, process-local host evidence; the stdio bridge reports initialization and successful new-thread registration through the protected same-origin settings channel without blocking model traffic. Reporter work is bounded and aborted when the original CLI exits. Runtime evidence never contains prompts, images, paths or raw chat identifiers and cannot establish registration in unobserved chats. Manual loopback checks echo a nonce and explicitly identify their Node-only scope.
|
|
1117
|
+
|
|
1118
|
+
The existing salted session observation is projected into request metadata. Active requests can reference the previous retained request from the same anonymous session, application and provider; this does not change request routing, history or tool caches. Chat endpoint recognition accepts both `/chat/completions` and `/v1/chat/completions`. Bare JSON error lines in a Messages event stream terminate with an explicit protocol diagnostic rather than waiting for message_stop; normal SSE frames retain their bytes.
|
package/docs/REFERENCE.md
CHANGED
|
@@ -580,16 +580,23 @@ was recreated on the original address, not that gray text appeared.
|
|
|
580
580
|
|
|
581
581
|
## Native image generation
|
|
582
582
|
|
|
583
|
-
|
|
583
|
+
The native image host uses the current CCDX address for separate Images API requests. CCDX serves `POST /v1/images/generations` and `POST /v1/images/edits`, reuses the existing GitHub Copilot authentication, and maps the native client’s `gpt-image-2` request to the selected available GHC image model. GPT Image 2.5 Flare is the default when advertised. The `X-CCDX-Image-Model` response header identifies the actual model. Image usage counts toward the GitHub account’s image credits; organization model policies still apply. The image model does not replace the selected conversation model.
|
|
584
584
|
|
|
585
|
-
On macOS with Codex 0.166 or later, CCDX launches the unchanged Codex CLI through a local stdio host adapter. The adapter registers `ccdx_images.imagegen` using Codex’s native `dynamicTools` interface. Codex emits native tool progress and
|
|
585
|
+
On macOS with Codex 0.166 or later, CCDX launches the unchanged Codex CLI through a local stdio host adapter. The adapter registers `ccdx_images.imagegen` using Codex’s native `dynamicTools` interface. Codex emits native tool progress and includes image content in the chat history; display in the signed App depends on the client and requires a real-window check. CCDX saves image files under the active Codex home’s `generated_images/ccdx/` directory and uses these files for later edits, including after a host restart. No separate image address or key, image MCP registration, or CCDX image skill is required. Windows continues to expose the Images API; automatic host activation on Windows is not yet provided.
|
|
586
586
|
|
|
587
|
-
The
|
|
587
|
+
The Web UI image panel and terminal `check`, `repair`, and `open` controls share the service's image controller. `check` verifies the Node loopback response with a fresh nonce and checks the launcher and runtime evidence; it does not prove the Codex App's proxy route. `repair` prepares owned launch files and client configuration without opening or closing the App. `open` preserves the established prediction route and opens Codex only when it is closed. A running App produces `needs_app_relaunch`; finish tasks and quit it yourself, then use `open` and a new chat. Disabled image settings and custom launch routes are preserved.
|
|
588
|
+
|
|
589
|
+
The runtime separately reports host initialization, accepted new-chat registration and image-call outcomes. Reports contain only host PID, anonymous host/chat identifiers, event type and time, remain in bounded process memory, and are not an automatic image-generation probe. Registration evidence applies to observed chats, not every existing conversation. Dead host processes are unconfirmed. The TUI exposes the repair command; terminal image status includes the same host state. Request details show anonymous session correlation and the previous retained request's outcome when supplied session metadata allows it; missing identity stays unassigned.
|
|
590
|
+
|
|
591
|
+
The adapter uses `CODEX_CLI_PATH` only for the App launch requested by CCDX. It does not modify App binaries, ChatGPT authentication files, credential storage mode or account-plan declarations. All other app-server traffic, including Apps and approval requests, passes through to the original CLI. Existing custom CLI routes and unowned launcher files are preserved. A running App retains its existing launch environment. If its image tool is missing, fully quit the App, start Codex through CCDX, and use a new chat. CCDX does not forcibly restart the App. Native built-in image tool availability still depends on the installed client and thread. A successful direct API request alone does not establish visible App behavior.
|
|
588
592
|
|
|
589
593
|
The WebUI’s image switch is on by default and pauses or resumes new requests. A previously saved off choice is preserved. Available GHC image models appear below the switch; multiple models use one radio selection. The same image purpose appears in Model sources and Codex model configuration. Image models stay out of Codex’s conversation-model picker and conversation default selection. Saved pause choices survive upgrades, and active calls may finish. The CLI uses the same preference:
|
|
590
594
|
|
|
591
595
|
```bash
|
|
592
596
|
ccdx app codex image status
|
|
597
|
+
ccdx app codex image check
|
|
598
|
+
ccdx app codex image repair
|
|
599
|
+
ccdx app codex image open
|
|
593
600
|
ccdx app codex image models
|
|
594
601
|
ccdx app codex image select --id gpt-image-2.5-flare
|
|
595
602
|
ccdx app codex image enable
|
package/package.json
CHANGED
package/src/claude-gateway.mjs
CHANGED
|
@@ -75,6 +75,13 @@ export function createMessagesObserver(onEvent, maxBytes = 8 * 1024 * 1024, clie
|
|
|
75
75
|
}
|
|
76
76
|
if (value.endsWith("\r")) value = value.slice(0, -1);
|
|
77
77
|
if (!value) frame();
|
|
78
|
+
else if (value.startsWith("{")) {
|
|
79
|
+
let error;try { error = JSON.parse(value); } catch {}
|
|
80
|
+
if (error?.type === "error" || error?.error && typeof error.error === "object") {
|
|
81
|
+
onEvent({ ...error, type: "error" });
|
|
82
|
+
throw new Error("Upstream returned a JSON error outside an SSE data frame");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
78
85
|
else if (value.startsWith("data:")) {
|
|
79
86
|
const part = value.slice(5).replace(/^ /, "");frameBytes += Buffer.byteLength(part);
|
|
80
87
|
if (frameBytes > maxBytes) throw new Error("Claude stream event exceeds its limit");data.push(part);
|
package/src/cli-command-spec.mjs
CHANGED
|
@@ -132,8 +132,8 @@ export const MANAGED_COMMANDS = [
|
|
|
132
132
|
action: { setup: "on", remove: "off", repair: "fix" }[action] || action,
|
|
133
133
|
}))
|
|
134
134
|
),
|
|
135
|
-
...["status", "models", "enable", "disable"].map(action =>
|
|
136
|
-
command(`app codex image ${action}`, ({ status: "Show native image status", models: "List available GitHub image models", enable: "Enable native images", disable: "Disable native images" })[action], read, flags => ({ command: "image", action, outputFormat: flags.format }))
|
|
135
|
+
...["status", "models", "enable", "disable", "check", "repair", "open"].map(action =>
|
|
136
|
+
command(`app codex image ${action}`, ({ status: "Show native image status", models: "List available GitHub image models", enable: "Enable native images", disable: "Disable native images", check: "Check native image access", repair: "Repair image launch configuration", open: "Open Codex with native image tools" })[action], read, flags => ({ command: "image", action, outputFormat: flags.format }))
|
|
137
137
|
),
|
|
138
138
|
command("app codex image select", "Choose the native image model", { "--id": "value", ...read }, flags => ({ command: "image", action: "select", imageModel: flags.id, outputFormat: flags.format })),
|
|
139
139
|
command("app codex review status", "Show the Codex Auto-review selection", read),
|
package/src/cli-image.mjs
CHANGED
|
@@ -4,20 +4,23 @@ import { dashboardToolRequest, pauseServiceFeature } from "./cli-tools.mjs";
|
|
|
4
4
|
|
|
5
5
|
export async function runImageCommand({ action, model, output = process.stdout, home, env = process.env,
|
|
6
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");
|
|
7
|
+
if (!["status", "models", "enable", "disable", "select", "check", "repair", "open"].includes(action)) throw new Error("Choose image status, models, enable, disable, check, repair, open or select --id MODEL");
|
|
8
8
|
const local = { home, env }, address = { port: adapterPort, host: adapterHost };
|
|
9
9
|
if (["enable", "disable"].includes(action)) output.write(await pauseServiceFeature({ ...local, ...address, feature: "image", action: action === "enable" ? "resume" : "pause", request }) + "\n");
|
|
10
10
|
let result;
|
|
11
11
|
try {
|
|
12
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,
|
|
13
|
+
const data = await request({ ...address, path: "settings", timeoutMs: action === "open" ? 210000 : action === "repair" ? 15000 : action === "status" ? 1000 : 5000,
|
|
14
|
+
...(["check", "repair", "open"].includes(action) ? { body: { action: "image", operation: action } } : {}),
|
|
14
15
|
...(action === "select" ? { body: { action: "image", operation: "select", model } } : {}) });
|
|
15
16
|
result = data.features.image;
|
|
17
|
+
if (data.last_operation?.feature === "image") output.write(JSON.stringify(data.last_operation.result, null, 2) + "\n");
|
|
16
18
|
} catch (error) {
|
|
17
|
-
if (["models", "select"].includes(action)) throw error;
|
|
19
|
+
if (["models", "select", "check", "repair", "open"].includes(action)) throw error;
|
|
18
20
|
result = imageSetupSummary(local);
|
|
19
21
|
}
|
|
20
22
|
output.write(`Native Codex images: ${!result.enabled ? "disabled" : result.configured ? "enabled" : "needs GitHub access"}\n`);
|
|
23
|
+
if (result.runtime) output.write(`App host: ${result.runtime.connected ? "connected" : "unconfirmed"}; chat tool: ${result.runtime.tool_registration}\n`);
|
|
21
24
|
output.write(`Image model: ${terminalCell(result.selected_model || "Automatic; catalog unavailable")}\n`);
|
|
22
25
|
if (result.availability === "selected_unavailable") output.write("Saved image model is unavailable; choose an available model.\n");
|
|
23
26
|
for (const item of result.models || []) output.write(`${item.id === result.selected_model ? "*" : " "} ${terminalCell(item.name || item.id)} (${terminalCell(item.id)})\n`);
|
package/src/codex-image-host.mjs
CHANGED
|
@@ -58,15 +58,18 @@ function imageType(bytes) {
|
|
|
58
58
|
const inside = (root, file) => file === root || file.startsWith(root + path.sep);
|
|
59
59
|
|
|
60
60
|
export function createImageHostBridge({ baseUrl, codexHome, sendToCodex, fetchImpl = fetch, imageEnabled,
|
|
61
|
-
now = Date.now } = {}) {
|
|
61
|
+
now = Date.now, onEvent = () => {} } = {}) {
|
|
62
62
|
baseUrl = imageHostBaseUrl(baseUrl);
|
|
63
63
|
const requests = new Map(), threads = new Map(), active = new Map();
|
|
64
64
|
let experimental = false, sequence = 0;
|
|
65
|
+
const observe = (event, thread) => { try { onEvent({ event, ...(thread ? { thread: createHash("sha256").update(thread).digest("hex").slice(0, 32) } : {}) }); } catch {} };
|
|
65
66
|
const root = path.join(codexHome, "generated_images", "ccdx");
|
|
66
67
|
const folder = id => path.join(root, createHash("sha256").update(id).digest("hex").slice(0, 32));
|
|
67
68
|
const enabled = imageEnabled || (async () => {
|
|
68
69
|
try {
|
|
69
|
-
const response = await fetchImpl(baseUrl.replace(/\/v1$/, "/_ccdx/settings"), {
|
|
70
|
+
const response = await fetchImpl(baseUrl.replace(/\/v1$/, "/_ccdx/ui/settings"), {
|
|
71
|
+
headers: { "X-CCDX-Dashboard": "1" }, signal: AbortSignal.timeout(1000),
|
|
72
|
+
});
|
|
70
73
|
if (!response.ok) return false;
|
|
71
74
|
const settings = await boundedJson(response);return settings.features?.image?.enabled === true;
|
|
72
75
|
} catch { return false; }
|
|
@@ -138,10 +141,14 @@ export function createImageHostBridge({ baseUrl, codexHome, sendToCodex, fetchIm
|
|
|
138
141
|
|
|
139
142
|
return {
|
|
140
143
|
async client(message) {
|
|
141
|
-
if (message.method === "initialize")
|
|
144
|
+
if (message.method === "initialize") {
|
|
145
|
+
experimental = message.params?.capabilities?.experimentalApi === true;
|
|
146
|
+
requests.set(JSON.stringify(message.id), { method: "initialize" });
|
|
147
|
+
}
|
|
142
148
|
if (["thread/start", "thread/resume", "thread/fork"].includes(message.method)) {
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
const registered = message.method === "thread/start" && experimental && await enabled();
|
|
150
|
+
requests.set(JSON.stringify(message.id), { method: message.method, params: message.params || {}, registered });
|
|
151
|
+
if (registered) return { ...message, params: addImageHostTool(message.params || {}) };
|
|
145
152
|
}
|
|
146
153
|
if (message.method === "turn/start") {
|
|
147
154
|
const context = threads.get(message.params?.threadId);
|
|
@@ -155,6 +162,8 @@ export function createImageHostBridge({ baseUrl, codexHome, sendToCodex, fetchIm
|
|
|
155
162
|
const pending = requests.get(JSON.stringify(message.id));
|
|
156
163
|
if (pending && !message.method) {
|
|
157
164
|
requests.delete(JSON.stringify(message.id));const thread = message.result?.thread;
|
|
165
|
+
if (!message.error && message.result && pending.method === "initialize") observe("connected");
|
|
166
|
+
if (thread?.id && pending.registered) observe("registered", thread.id);
|
|
158
167
|
if (thread?.id && thread.cwd) threads.set(thread.id, { cwd: thread.cwd, roots: pending.params.runtimeWorkspaceRoots || [], attachments: [], generated: [] });
|
|
159
168
|
}
|
|
160
169
|
if (message.method === "item/completed" && message.params?.item?.type === "imageGeneration" && message.params.item.savedPath) {
|
|
@@ -164,12 +173,12 @@ export function createImageHostBridge({ baseUrl, codexHome, sendToCodex, fetchIm
|
|
|
164
173
|
const controller = new AbortController(), key = JSON.stringify(message.id);
|
|
165
174
|
active.set(key, { controller, threadId: message.params.threadId });
|
|
166
175
|
void runImage(message.params, AbortSignal.any([controller.signal, AbortSignal.timeout(180000)]))
|
|
167
|
-
.then(result => sendToCodex({ id: message.id, result }))
|
|
168
|
-
.catch(error => sendToCodex({ id: message.id, result: { success: false, contentItems: [{ type: "inputText", text: error.message }] } }))
|
|
176
|
+
.then(result => { observe("generated", message.params.threadId);sendToCodex({ id: message.id, result }); })
|
|
177
|
+
.catch(error => { observe("failed", message.params.threadId);sendToCodex({ id: message.id, result: { success: false, contentItems: [{ type: "inputText", text: error.message }] } }); })
|
|
169
178
|
.finally(() => active.delete(key));
|
|
170
179
|
return true;
|
|
171
180
|
},
|
|
172
|
-
close() { for (const value of active.values()) value.controller.abort(new Error("Image host closed")); },
|
|
181
|
+
close() { observe("closed");for (const value of active.values()) value.controller.abort(new Error("Image host closed")); },
|
|
173
182
|
};
|
|
174
183
|
}
|
|
175
184
|
|
|
@@ -193,10 +202,23 @@ export async function runCodexImageHost({ codex, argv, baseUrl, env = process.en
|
|
|
193
202
|
const child = spawnImpl(codex, args, { env: childEnv, stdio: ["pipe", "pipe", "pipe"] });
|
|
194
203
|
child.stdin.on("error", () => {});child.stderr.pipe(error, { end: false });
|
|
195
204
|
let bridge, queue = Promise.resolve();const cleanups = [];
|
|
205
|
+
const reportingAbort = new AbortController();
|
|
206
|
+
const hostId = randomUUID();let reporting = Promise.resolve(), pendingReports = 0;
|
|
207
|
+
const report = evidence => {
|
|
208
|
+
if (pendingReports >= 16) return;
|
|
209
|
+
pendingReports++;
|
|
210
|
+
reporting = reporting.then(async () => {
|
|
211
|
+
const url = new URL(baseUrl);url.pathname = "/_ccdx/ui/settings";
|
|
212
|
+
const response = await fetch(url, { method: "POST", redirect: "error", signal: AbortSignal.any([reportingAbort.signal, AbortSignal.timeout(1000)]),
|
|
213
|
+
headers: { "X-CCDX-Dashboard": "1", Origin: url.origin, "Content-Type": "application/json" },
|
|
214
|
+
body: JSON.stringify({ action: "image", operation: "report", evidence: { ...evidence, id: hostId, pid: process.pid } }) });
|
|
215
|
+
await response.body?.cancel();
|
|
216
|
+
}).catch(() => {}).finally(() => { pendingReports--; });
|
|
217
|
+
};
|
|
196
218
|
const write = message => { if (!child.stdin.destroyed) child.stdin.write(JSON.stringify(message) + "\n"); };
|
|
197
219
|
if (!stdio) { input.pipe(child.stdin);child.stdout.pipe(output, { end: false }); }
|
|
198
220
|
else {
|
|
199
|
-
bridge = createImageHostBridge({ baseUrl, codexHome: path.resolve(env.CODEX_HOME || path.join(env.HOME || process.env.HOME, ".codex")), sendToCodex: write });
|
|
221
|
+
bridge = createImageHostBridge({ baseUrl, codexHome: path.resolve(env.CODEX_HOME || path.join(env.HOME || process.env.HOME, ".codex")), sendToCodex: write, onEvent: report });
|
|
200
222
|
cleanups.push(lines(input, raw => {
|
|
201
223
|
queue = queue.then(async () => {
|
|
202
224
|
let message;try { message = JSON.parse(raw); } catch { child.stdin.write(raw + "\n");return; }
|
|
@@ -212,5 +234,5 @@ export async function runCodexImageHost({ codex, argv, baseUrl, env = process.en
|
|
|
212
234
|
const interrupt = () => stop("SIGINT"), terminate = () => stop("SIGTERM");
|
|
213
235
|
process.once("SIGINT", interrupt);process.once("SIGTERM", terminate);
|
|
214
236
|
try { const [code, signal] = await once(child, "exit");await queue;return code ?? (signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 1); }
|
|
215
|
-
finally { bridge?.close();for (const cleanup of cleanups) cleanup();input.unpipe(child.stdin);input.pause();process.removeListener("SIGINT", interrupt);process.removeListener("SIGTERM", terminate); }
|
|
237
|
+
finally { bridge?.close();reportingAbort.abort();for (const cleanup of cleanups) cleanup();input.unpipe(child.stdin);input.pause();process.removeListener("SIGINT", interrupt);process.removeListener("SIGTERM", terminate); }
|
|
216
238
|
}
|
package/src/dashboard/console.js
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
async function api(body) {
|
|
69
69
|
const response = await fetch("/_ccdx/ui/settings", { method: body ? "POST" : "GET", cache: "no-store",
|
|
70
70
|
headers: { "X-CCDX-Dashboard": "1", ...(body ? { "Content-Type": "application/json" } : {}) },
|
|
71
|
-
...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout(body?.action === "prediction" ? 210000 : body?.action === "image" || body?.operation === "account" ? 65000 : 15000) });
|
|
71
|
+
...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout((body?.action === "prediction" || body?.action === "image" && body?.operation === "open") ? 210000 : body?.action === "image" || body?.operation === "account" ? 65000 : 15000) });
|
|
72
72
|
const data = await response.json();if (!response.ok) throw Object.assign(new Error(data.error || `HTTP ${response.status}`), { code: data.code });return data;
|
|
73
73
|
}
|
|
74
74
|
const preferences = globalThis.ccdxDashboardPreferences?.create({ element: el, api, applied: applySettings, time,
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
if (settingsPending) return;
|
|
199
199
|
settingsPending = true;
|
|
200
200
|
syncAccountControls();
|
|
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
|
+
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, #image-check, #image-repair, #image-open, #decoded-limit, #decoded-limit-save, #decoded-limit-default, #install-update")];
|
|
202
202
|
controls.forEach(input => { input.disabled = true; });
|
|
203
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"
|
|
204
204
|
: body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
function create({ element: el, change, localize }) {
|
|
3
3
|
let saved = null, limitDirty = false, imageSignature = "";
|
|
4
|
+
for (const operation of ["check", "repair", "open"]) el("image-" + operation).addEventListener("click", async () => {
|
|
5
|
+
const data = await change({ action: "image", operation }, el("image-" + operation));
|
|
6
|
+
const result = data?.last_operation?.feature === "image" ? data.last_operation.result : null;
|
|
7
|
+
if (result) {
|
|
8
|
+
el("image-action-note").dataset.operation = operation;
|
|
9
|
+
el("image-action-note").hidden = false;
|
|
10
|
+
localize(el("image-action-note"), operation === "check" ? "image_connection_" + result.connection?.state : "image_action_" + result.status);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
4
13
|
const prediction = operation => change({ action: "prediction", operation }, el("prediction-continue"));
|
|
5
14
|
el("setting-prediction_enabled").addEventListener("change", () => void prediction(el("setting-prediction_enabled").checked ? "enable" : "disable"));
|
|
6
15
|
el("prediction-continue").addEventListener("click", () => void prediction(saved?.features?.prediction?.enabled ? "enable" : "disable"));
|
|
@@ -31,7 +40,9 @@
|
|
|
31
40
|
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");
|
|
32
41
|
el("effect-prediction_enabled").hidden = !pending;
|
|
33
42
|
if (pending) localize(el("effect-prediction_enabled"), "feature_pending");
|
|
34
|
-
const
|
|
43
|
+
const runtime = data.features?.image?.runtime;
|
|
44
|
+
localize(el("image-host-note"), runtime?.tool_registration === "observed" ? "image_host_registered" : runtime?.connected ? "image_host_connected" : "image_host_unconfirmed");
|
|
45
|
+
const image = data.features?.image, signature = JSON.stringify(image ? { ...image, runtime: undefined } : null);
|
|
35
46
|
if (signature !== imageSignature) {
|
|
36
47
|
imageSignature = signature;
|
|
37
48
|
const list = el("image-models"), focus = list.contains(document.activeElement) ? document.activeElement.value : null;
|
package/src/dashboard/flow.js
CHANGED
|
@@ -92,6 +92,8 @@
|
|
|
92
92
|
let tr = detailRows.get(id);
|
|
93
93
|
if (!tr) { tr = entry("tr");for (let i = 0; i < 6; i++) tr.append(entry("td"));detailRows.set(id, tr); }
|
|
94
94
|
const values = [appName(row.application), sourceName(row.provider), modelName(row.model), format(fresh ? status(row) : "flow_last_observed"), `${((row.elapsed_ms + Math.max(0, Date.now() - sampledAt)) / 1000).toFixed(1)} s`, row.upstream_attempts.toLocaleString()];
|
|
95
|
+
if (row.previous_request) values[3] += " · " + format("flow_previous_result", { reason: row.previous_request.stop_reason || row.previous_request.outcome || "—", seconds: (row.previous_request.elapsed_ms / 1000).toFixed(1) });
|
|
96
|
+
tr.title = row.session_id ? format("flow_session_previous", { session: row.session_id, reason: row.previous_request?.stop_reason || row.previous_request?.outcome || "—", seconds: row.previous_request ? (row.previous_request.elapsed_ms / 1000).toFixed(1) : "—" }) : format("flow_session_unknown");
|
|
95
97
|
values.forEach((value, i) => { if (tr.children[i].textContent !== value) tr.children[i].textContent = value; });
|
|
96
98
|
if (body.children[index] !== tr) body.insertBefore(tr, body.children[index] || null);
|
|
97
99
|
}
|
|
@@ -189,6 +191,8 @@
|
|
|
189
191
|
if (!parts.length || parts.some(part => !integer(part.active_total) || !Array.isArray(part.active_requests))) { unavailable();return; }
|
|
190
192
|
const values = parts.flatMap(part => part.active_requests).slice(0, 128);
|
|
191
193
|
rows = values.filter(row => row && typeof row.model === "string" && integer(row.upstream_attempts) && Number.isFinite(row.elapsed_ms) && row.elapsed_ms >= 0).map(row => ({
|
|
194
|
+
session_id: typeof row.session_id === "string" && /^[a-f0-9]{16}$/.test(row.session_id) ? row.session_id : null,
|
|
195
|
+
previous_request: row.previous_request && Number.isFinite(row.previous_request.elapsed_ms) ? { elapsed_ms: row.previous_request.elapsed_ms, stop_reason: row.previous_request.stop_reason, outcome: row.previous_request.outcome } : null,
|
|
192
196
|
request_id: typeof row.request_id === "string" ? row.request_id.slice(0, 80) : null,
|
|
193
197
|
application: clients.has(row.application) ? row.application : "api", provider: typeof row.provider === "string" && /^[a-z][a-z0-9_-]{0,63}$/.test(row.provider) ? row.provider : "unknown",
|
|
194
198
|
model: row.model.slice(0, 160), phase: String(row.phase || "").slice(0, 40), elapsed_ms: row.elapsed_ms,
|
package/src/dashboard/index.html
CHANGED
|
@@ -134,6 +134,9 @@
|
|
|
134
134
|
<summary class="panel-heading"><h2 data-i18n="codex_image_generation">IMAGE GENERATION</h2></summary>
|
|
135
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>
|
|
136
136
|
<div id="image-models" class="image-models" role="group" aria-label="Image model" data-i18n-label="image_model"></div>
|
|
137
|
+
<div class="section-actions"><button id="image-check" type="button" data-i18n="image_check">Check access</button><button id="image-repair" type="button" data-i18n="image_repair">Repair access</button><button id="image-open" type="button" data-i18n="image_open">Open Codex</button></div>
|
|
138
|
+
<p id="image-host-note" class="hint" role="status"></p>
|
|
139
|
+
<p id="image-action-note" class="hint" role="status" hidden></p>
|
|
137
140
|
<p id="image-model-note" class="hint" role="status" hidden></p>
|
|
138
141
|
<div class="image-metrics hint"><strong id="image">—</strong><span id="image-detail">—</span></div>
|
|
139
142
|
</details>
|
|
@@ -7,6 +7,23 @@
|
|
|
7
7
|
feature_continue: ["Continue setup", "继续配置"],
|
|
8
8
|
prediction_open: ["Open Codex", "打开 Codex"],
|
|
9
9
|
feature_remove: ["Remove setup", "移除接入"],
|
|
10
|
+
flow_previous_result: ["Previous: {reason}, {seconds} s", "上次:{reason},{seconds} 秒"],
|
|
11
|
+
flow_session_previous: ["Session {session} · previous: {reason}, {seconds} s", "会话 {session} · 上次请求:{reason},{seconds} 秒"],
|
|
12
|
+
flow_session_unknown: ["Session correlation unavailable", "无法关联会话"],
|
|
13
|
+
image_check: ["Check access", "检查接入"],
|
|
14
|
+
image_repair: ["Repair access", "修复接入"],
|
|
15
|
+
image_open: ["Open Codex", "打开 Codex"],
|
|
16
|
+
image_host_unconfirmed: ["App host connection unconfirmed.", "尚未确认 App 图片宿主连接。"],
|
|
17
|
+
image_host_connected: ["App host connected; new chat tool registration unconfirmed.", "App 宿主已连接;尚未确认新聊天工具注册。"],
|
|
18
|
+
image_host_registered: ["Image tool registration observed in a connected host. Other chats may differ.", "已在连接的宿主中观察到图片工具注册,其他聊天可能不同。"],
|
|
19
|
+
image_connection_verified: ["Local Node route verified. Codex network path unconfirmed.", "本机 Node 连接与服务身份已验证;Codex 网络路径尚未确认。"],
|
|
20
|
+
image_connection_unreachable: ["Local check could not reach CCDX.", "本机检查未能连接 CCDX。"],
|
|
21
|
+
image_connection_identity_mismatch: ["Local response did not match this CCDX check.", "本机响应身份不符合本次 CCDX 检查。"],
|
|
22
|
+
image_action_prepared: ["Launch configuration repaired. Open Codex, then use a new chat.", "启动配置已修复。请打开 Codex,再使用新聊天。"],
|
|
23
|
+
image_action_needs_app_relaunch: ["Launch configuration prepared. Quit Codex when your tasks finish, then open it here and use a new chat.", "启动配置已准备。请在任务完成后退出 Codex,再从这里打开并使用新聊天。"],
|
|
24
|
+
image_action_opened_new_chat_required: ["Codex launch requested. Use a new chat; registration remains unconfirmed until observed.", "已请求打开 Codex。请使用新聊天;观察到注册前仍显示未确认。"],
|
|
25
|
+
image_action_open_failed: ["Could not open Codex. Check the App installation.", "未能打开 Codex,请检查 App 安装。"],
|
|
26
|
+
image_action_unsupported: ["Native image host launch is unavailable on this platform.", "当前平台无法准备原生图片宿主启动。"],
|
|
10
27
|
image_model: ["Image model", "图片模型"],
|
|
11
28
|
image_models: ["Image models", "图片模型"],
|
|
12
29
|
image_needs_github: ["Allow GitHub Copilot access for Codex.", "请允许 Codex 使用 GitHub Copilot。"],
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { adapterBaseUrl, ADAPTER_PROTOCOL_VERSION } from "./running-adapter.mjs";
|
|
4
|
+
import { imageHostLauncherPath, prepareImageHostLaunch } from "./codex-image-host-launch.mjs";
|
|
5
|
+
import { imageSetupSummary } from "./image-setup.mjs";
|
|
6
|
+
import { openCodex, macPredictionAppProcesses } from "./launcher.mjs";
|
|
7
|
+
import { readBoundedResponseText } from "./upstream-body.mjs";
|
|
8
|
+
|
|
9
|
+
export async function checkImageConnection({ host = "127.0.0.1", port = 2026, fetchImpl = fetch } = {}) {
|
|
10
|
+
const nonce = randomUUID();
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetchImpl(adapterBaseUrl(host, port) + "/_ccdx/health?nonce=" + nonce,
|
|
13
|
+
{ redirect: "error", headers: { Accept: "application/json" }, signal: AbortSignal.timeout(2000) });
|
|
14
|
+
const value = JSON.parse(await readBoundedResponseText(response, { maxBytes: 8192, label: "Local image check" }));
|
|
15
|
+
return { state: response.ok && value.name === "codex-copilot-dx" && value.ok === true && value.nonce === nonce
|
|
16
|
+
&& value.protocol_version === ADAPTER_PROTOCOL_VERSION ? "verified" : "identity_mismatch", scope: "node_loopback", app_path: "unconfirmed" };
|
|
17
|
+
} catch { return { state: "unreachable", scope: "node_loopback", app_path: "unconfirmed" }; }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function controlImage(operation, { integration, state, host, port, models = [], prepare = prepareImageHostLaunch,
|
|
21
|
+
launch = openCodex, appProcesses = macPredictionAppProcesses, connection = checkImageConnection, ...options } = {}) {
|
|
22
|
+
if (!["check", "repair", "open"].includes(operation)) throw new Error("Unknown image control");
|
|
23
|
+
const summary = imageSetupSummary({ ...options, models });
|
|
24
|
+
if (operation === "check") return { status: "checked", connection: await connection({ host, port }),
|
|
25
|
+
launcher_present: fs.existsSync(imageHostLauncherPath(options)), runtime: state?.snapshot(), ...summary };
|
|
26
|
+
if (!summary.enabled) throw new Error("Enable images before repairing image access");
|
|
27
|
+
if (!integration) throw new Error("Start CCDX before repairing image access");
|
|
28
|
+
const env = { ...(options.env || process.env), CCDX_AUTO_LAUNCH: "1" };
|
|
29
|
+
await integration.configure();
|
|
30
|
+
const imageHost = await prepare({ ...options, env, host, port });
|
|
31
|
+
if (!imageHost) return { status: "unsupported", prepared: false };
|
|
32
|
+
const running = appProcesses(imageHost.app).length > 0;
|
|
33
|
+
if (running) return { status: "needs_app_relaunch", prepared: true, runtime: state?.snapshot() };
|
|
34
|
+
if (operation === "repair") return { status: "prepared", prepared: true, runtime: state?.snapshot() };
|
|
35
|
+
// Share the established prediction launch route; never strip it during repair.
|
|
36
|
+
const native = await integration.start();
|
|
37
|
+
await native?.prepareRoute?.();
|
|
38
|
+
const opened = await launch({ env, imageHost, predictionPacUrl: native?.pacUrl, predictionApp: native?.app,
|
|
39
|
+
predictionProfile: native?.profile, preparePredictionRoute: () => native?.prepareRoute?.(),
|
|
40
|
+
onPredictionRoute: value => integration.launched?.(value) });
|
|
41
|
+
return { status: opened ? "opened_new_chat_required" : "open_failed", prepared: true, runtime: state?.snapshot() };
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Runtime evidence only. No prompts, image paths, credentials or raw chat IDs.
|
|
2
|
+
export function createImageHostState({ now = Date.now, alive = pid => { try { process.kill(pid, 0);return true; } catch { return false; } } } = {}) {
|
|
3
|
+
const hosts = new Map();
|
|
4
|
+
return {
|
|
5
|
+
report(value) {
|
|
6
|
+
if (!value || Object.keys(value).some(key => !["id", "pid", "event", "thread"].includes(key))
|
|
7
|
+
|| !/^[a-f0-9-]{36}$/.test(value.id || "") || !Number.isSafeInteger(value.pid) || value.pid < 1
|
|
8
|
+
|| !["connected", "registered", "generated", "failed", "closed"].includes(value.event)
|
|
9
|
+
|| value.thread !== undefined && !/^[a-f0-9]{32}$/.test(value.thread)) throw new Error("Invalid image host evidence");
|
|
10
|
+
const previous = hosts.get(value.id);
|
|
11
|
+
if (previous && previous.pid !== value.pid) throw new Error("Image host identity changed");
|
|
12
|
+
const host = previous || { id: value.id, pid: value.pid, connected: false, threads: [] };
|
|
13
|
+
if (value.event === "connected") host.connected = true;
|
|
14
|
+
if (value.event === "closed") host.connected = false;
|
|
15
|
+
if (value.event === "registered" && value.thread && !host.threads.includes(value.thread)) host.threads = [...host.threads, value.thread].slice(-32);
|
|
16
|
+
host.event = value.event;host.updated_at = now();
|
|
17
|
+
hosts.delete(value.id);hosts.set(value.id, host);
|
|
18
|
+
if (hosts.size > 16) hosts.delete(hosts.keys().next().value);
|
|
19
|
+
},
|
|
20
|
+
snapshot() {
|
|
21
|
+
const values = [...hosts.values()].map(host => ({ ...host, threads: [...host.threads], connected: host.connected && alive(host.pid) }));
|
|
22
|
+
const connected = values.filter(host => host.connected);
|
|
23
|
+
return { connected: connected.length > 0, tool_registration: connected.some(host => host.threads.length) ? "observed" : "unconfirmed", hosts: values };
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
package/src/launcher.mjs
CHANGED
|
@@ -127,6 +127,8 @@ export async function openCodex({ env = process.env, spawnImpl = spawn, platform
|
|
|
127
127
|
const imageArgs = platform === "darwin" && imageHost?.env?.CODEX_CLI_PATH
|
|
128
128
|
? ["--env", "CODEX_CLI_PATH=" + imageHost.env.CODEX_CLI_PATH] : [];
|
|
129
129
|
if (imageArgs.length) log(status("info", "Image host configured for the next Codex launch and new chats; a running App is not restarted"));
|
|
130
|
+
const imageApp = imageArgs.length && APP_PATH_CANDIDATES.includes(imageHost.app) ? imageHost.app : null;
|
|
131
|
+
const warnRunningImageApp = () => log(status("warn", "Codex is already running. If the image tool is missing, fully quit the App and start it through CCDX."));
|
|
130
132
|
const extraArgs = isPredictionPacUrl(predictionPacUrl)
|
|
131
133
|
&& APP_PATH_CANDIDATES.includes(predictionApp)
|
|
132
134
|
? ["--args", `--proxy-pac-url=${predictionPacUrl}`] : [];
|
|
@@ -134,6 +136,7 @@ export async function openCodex({ env = process.env, spawnImpl = spawn, platform
|
|
|
134
136
|
try {
|
|
135
137
|
const running = macAppProcesses(predictionApp);
|
|
136
138
|
if (running.length) {
|
|
139
|
+
if (imageApp === predictionApp) warnRunningImageApp();
|
|
137
140
|
if (running.length === 1 && running[0].readable && running[0].route === predictionPacUrl) {
|
|
138
141
|
onPredictionRoute("verified");log(status("ok", "Codex already running"));return true;
|
|
139
142
|
}
|
|
@@ -160,6 +163,10 @@ export async function openCodex({ env = process.env, spawnImpl = spawn, platform
|
|
|
160
163
|
onPredictionRoute("unverified");log(status("warn", `Optional macOS prediction launch skipped: ${error.message}`));return false;
|
|
161
164
|
}
|
|
162
165
|
}
|
|
166
|
+
if (imageApp) {
|
|
167
|
+
try { if (macAppProcesses(imageApp).length) warnRunningImageApp(); }
|
|
168
|
+
catch { log(status("warn", "Could not check the running Codex App. If the image tool is missing, start the App through CCDX after quitting it.")); }
|
|
169
|
+
}
|
|
163
170
|
const attempts = imageArgs.length && APP_PATH_CANDIDATES.includes(imageHost.app) ? [[imageHost.app]] : launchAttempts();
|
|
164
171
|
for (const attempt of attempts) {
|
|
165
172
|
const args = [...attempt, ...imageArgs, ...extraArgs];
|
|
@@ -42,7 +42,9 @@ export function createManagementHandler({ statusSnapshot, activityEvents, native
|
|
|
42
42
|
const predictionPac = isLoopbackAddress(req.socket?.remoteAddress) && isLoopbackHostHeader(req.headers?.host)
|
|
43
43
|
? options.nativePredictionPac?.() : null;
|
|
44
44
|
const health = adapterHealthPayload();
|
|
45
|
+
const nonce = new URL(req.url, "http://localhost").searchParams.get("nonce");
|
|
45
46
|
res.end(JSON.stringify({ ...health,
|
|
47
|
+
...(/^[a-f0-9-]{36}$/.test(nonce || "") ? { nonce } : {}),
|
|
46
48
|
capabilities: [...health.capabilities, ...(typeof options.fixPrediction === "function" ? [PREDICTION_FIX_CAPABILITY] : [])],
|
|
47
49
|
...(predictionPac ? { native_prediction_pac: predictionPac } : {}) }));
|
|
48
50
|
return;
|
package/src/models.mjs
CHANGED
|
@@ -14,7 +14,7 @@ export function autoReviewReasoningEfforts(model) {
|
|
|
14
14
|
|
|
15
15
|
function hasOpenAIEndpoint(model) {
|
|
16
16
|
const endpoints = Array.isArray(model?.supported_endpoints) ? model.supported_endpoints : [];
|
|
17
|
-
return endpoints.includes("/responses") || endpoints.includes("/v1/responses") || endpoints.includes("/chat/completions");
|
|
17
|
+
return endpoints.includes("/responses") || endpoints.includes("/v1/responses") || (endpoints.includes("/chat/completions") || endpoints.includes("/v1/chat/completions"));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// Endpoint-based routing helpers. A model is "responses-only" when it exposes a
|
|
@@ -25,13 +25,13 @@ export function modelEndpoints(model) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function modelSupportsChatCompletions(model) {
|
|
28
|
-
return modelEndpoints(model).
|
|
28
|
+
return modelEndpoints(model).some(path => ["/chat/completions", "/v1/chat/completions"].includes(path));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function modelIsResponsesOnly(model) {
|
|
32
32
|
const endpoints = modelEndpoints(model);
|
|
33
33
|
const hasResponses = endpoints.includes("/responses") || endpoints.includes("/v1/responses");
|
|
34
|
-
return hasResponses && !endpoints.includes("/chat/completions");
|
|
34
|
+
return hasResponses && !(endpoints.includes("/chat/completions") || endpoints.includes("/v1/chat/completions"));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export function resolveCopilotPriorityTierModel(model, serviceTier, models) {
|
package/src/service-control.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createImageHostState } from "./image-host-state.mjs";
|
|
2
|
+
import { controlImage } from "./image-control.mjs";
|
|
1
3
|
import { serviceSettingsSnapshot, servicePreferences, writeServicePreference,
|
|
2
4
|
writeTerminalAnimationTheme, writeTerminalColorTheme, responseHistoryLimitPreference, writeResponseHistoryLimitMib,
|
|
3
5
|
nightlyUpdatePreference, writeNightlyUpdatePreference, decodedBodyLimitPreference, writeDecodedBodyLimitMib } from "./user-settings.mjs";
|
|
@@ -10,10 +12,11 @@ import { imageSetupSummary, configureImageSetup } from "./image-setup.mjs";
|
|
|
10
12
|
|
|
11
13
|
export function createServiceControl({ env = process.env, home, providerRuntime, clientIntegration, terminal,
|
|
12
14
|
nightlyStatus = () => null, nightlyChanged = () => {},
|
|
13
|
-
manualUpdate, predictionControl = controlPrediction, imageControl = configureImageSetup,
|
|
15
|
+
manualUpdate, predictionControl = controlPrediction, imageControl = configureImageSetup, imageHostControl = controlImage,
|
|
14
16
|
adapterPort = 2026, adapterHost = "127.0.0.1",
|
|
15
17
|
readImages = () => imageSetupSummary({ env, home }).configured, readPrediction = () => readPredictionSettings({ env, home }) } = {}) {
|
|
16
18
|
const options = { env, home };
|
|
19
|
+
const imageHostState = createImageHostState();
|
|
17
20
|
let serial = Promise.resolve(), lastOperation = null, pending = 0;
|
|
18
21
|
const featureSnapshot = read => { try { return read(options); } catch { return { status: "unavailable" }; } };
|
|
19
22
|
function snapshot() {
|
|
@@ -25,7 +28,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
25
28
|
const enabled = nightlyUpdatePreference(options), nightly = nightlyStatus();
|
|
26
29
|
const localPrivacy = providerRuntime?.privacy?.snapshot();
|
|
27
30
|
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 },
|
|
31
|
+
features: { prediction: { ...featureSnapshot(predictionControlSnapshot), bridge: prediction?.bridge || "stopped", active: prediction?.active === true }, image: { ...image, runtime: imageHostState.snapshot() } },
|
|
29
32
|
decoded_body: decodedBodyLimitPreference(options), manual_update: { available: typeof manualUpdate === "function" }, last_operation: lastOperation,
|
|
30
33
|
nightly_update: { enabled, ...nightly, effect: enabled && !nightly ? "next_start" : "immediate" },
|
|
31
34
|
effective: {
|
|
@@ -43,7 +46,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
43
46
|
if (!input || typeof input !== "object" || Array.isArray(input)) throw new Error("Invalid setting action");
|
|
44
47
|
const allowed = { preference: ["action", "key", "value"], nightly_update: ["action", "enabled"], animation: ["action", "theme"], color_theme: ["action", "theme"],
|
|
45
48
|
history_limit: ["action", "mib"], history_clean: ["action"], prediction_fix: ["action"],
|
|
46
|
-
prediction: ["action", "operation"], image: ["action", "operation", "model"],
|
|
49
|
+
prediction: ["action", "operation"], image: ["action", "operation", "model", "evidence"],
|
|
47
50
|
update: ["action", "confirmed"], decoded_limit: ["action", "mib"],
|
|
48
51
|
preferences: ["action", "values", "revision"], reset_preferences: ["action", "revision", "backup_id", "scope"], restore_preferences: ["action", "revision", "backup_id", "scope"],
|
|
49
52
|
provider: ["action", "operation", "provider", "model", "auto_review_model", "auto_review_effort", "account_id"] }[input.action];
|
|
@@ -52,7 +55,9 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
|
|
|
52
55
|
if (input.action === "prediction") {
|
|
53
56
|
lastOperation = { feature: "prediction", result: await predictionControl(input.operation, { ...options, integration: clientIntegration }) };
|
|
54
57
|
} else if (input.action === "image") {
|
|
55
|
-
if (
|
|
58
|
+
if (input.operation === "report") { imageHostState.report(input.evidence);terminal?.image?.(imageHostState.snapshot()); }
|
|
59
|
+
else if (["check", "repair", "open"].includes(input.operation)) lastOperation = { feature: "image", result: await imageHostControl(input.operation, { ...options, host: adapterHost, port: adapterPort, integration: clientIntegration, state: imageHostState, models: providerRuntime?.imageModels?.().models || [] }) };
|
|
60
|
+
else if (["pause", "resume"].includes(input.operation)) writeServicePreference("image_enabled", input.operation === "resume", options);
|
|
56
61
|
else lastOperation = { feature: "image", result: await imageControl(input, { ...options, providerRuntime, adapterPort, adapterHost }) };
|
|
57
62
|
} else if (input.action === "update") {
|
|
58
63
|
if (input.confirmed !== true) throw new Error("Confirm installation and the idle service switch");
|
package/src/startup-ui.mjs
CHANGED
|
@@ -89,6 +89,12 @@ export function predictionStartupCheck(prediction) {
|
|
|
89
89
|
return lines.join("\n");
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
export function imageStartupCheck({ enabled, prepared, skipped } = {}) {
|
|
93
|
+
if (!enabled) return startupCheck("info", "Images", "Off");
|
|
94
|
+
if (!prepared || skipped) return startupCheck("warn", "Images", "App host not prepared");
|
|
95
|
+
return startupCheck("info", "Images", "App launch prepared; not tested");
|
|
96
|
+
}
|
|
97
|
+
|
|
92
98
|
// Catalog discovery, client configuration and inference access are distinct.
|
|
93
99
|
export function providerStartupSummary(data = {}) {
|
|
94
100
|
if (!data.providers) return { catalogs: "Status unavailable; see WebUI", claude: "Configuration not checked", warning: false };
|
|
@@ -260,9 +260,13 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
260
260
|
let stopReason = null;
|
|
261
261
|
const elapsed = (time) => time === null ? null : Number(Math.max(0, time - requestStartedAt).toFixed(1));
|
|
262
262
|
if (activeRequests.size < MAX_ACTIVE_REQUESTS) activeRequests.set(activeId, () => ({
|
|
263
|
-
request_id: safeRequestId, application: client, route: routeName, provider, model, phase,
|
|
263
|
+
request_id: safeRequestId, session_id: session ? session.slice(0, 16) : null, application: client, route: routeName, provider, model, phase,
|
|
264
264
|
started_at: at, elapsed_ms: elapsed(now()), first_output_ms: elapsed(firstOutputAt),
|
|
265
265
|
upstream_attempts: attempts, terminal_outcome: terminalOutcome,
|
|
266
|
+
previous_request: session ? (() => {
|
|
267
|
+
const previous = recentRequests.findLast(row => row.session_id === session.slice(0, 16) && row.application === client && row.provider === provider);
|
|
268
|
+
return previous ? { request_id: previous.request_id, stop_reason: previous.stop_reason || null, outcome: previous.outcome, elapsed_ms: previous.timings_ms.finished } : null;
|
|
269
|
+
})() : null,
|
|
266
270
|
attempts: attemptTimings.map(attempt => ({ ...attempt })),
|
|
267
271
|
}));
|
|
268
272
|
changes.changed();
|
|
@@ -404,7 +408,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
404
408
|
finished: finishedAt, request_id: safeRequestId, outcome, context, cached_input_tokens: cachedInput });
|
|
405
409
|
// Only scalar, allowlisted metadata survives the request; never retain payloads.
|
|
406
410
|
recentRequests.push({
|
|
407
|
-
request_id: safeRequestId, application: client,
|
|
411
|
+
request_id: safeRequestId, ...(session ? { session_id: session.slice(0, 16) } : {}), application: client,
|
|
408
412
|
at, route: routeName, model, outcome, origin, phase,
|
|
409
413
|
...(["ccdx_model_not_selected", "ccdx_client_source_disabled"].includes(rejectionReason) ? { rejection_reason: rejectionReason } : {}),
|
|
410
414
|
...(stopReason ? { stop_reason: stopReason } : {}),
|
package/src/terminal-console.mjs
CHANGED
|
@@ -15,6 +15,7 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
|
|
|
15
15
|
snapshot = () => ({}), subscribe, preferences = () => ({}), baseUrl = "", verbose = false,
|
|
16
16
|
timers = { setTimeout, clearTimeout }, now = Date.now } = {}) {
|
|
17
17
|
let running = false, timer = null, lines = 0, frame = 0, lastRead = 0, data = {}, projection = projectTerminalState();
|
|
18
|
+
let imageRuntime = null;
|
|
18
19
|
let notices = 0, lastNotice = "", lastPrintedNotice = "", previous = [];
|
|
19
20
|
let content = [], dirty = true, readFailed = false, updatedAt = null, fits = true;
|
|
20
21
|
let current = { theme: DEFAULT_TERMINAL_ANIMATION_THEME, color_theme: "green", terminal_animation_enabled: true };
|
|
@@ -87,7 +88,7 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
|
|
|
87
88
|
const appSize = width < 64 ? 13 : 15, setupSize = Math.max(10, Math.min(20, width - appSize - 7));
|
|
88
89
|
const appRows = view.clients.map(client => `${clip(client.name, appSize - 1).padEnd(appSize)}${clip(client.setup, setupSize - 1).padEnd(setupSize)}${String(readFailed || client.active === null ? "—" : client.active).padStart(6)}`);
|
|
89
90
|
const issue = view.issue?.label;
|
|
90
|
-
const notice = notices ? `${notices} ${notices === 1 ? "notice" : "notices"}${issue ? ` · last model issue: ${issue}` : " · ccdx status --details"}` : issue ? `Last model issue: ${issue}` : "
|
|
91
|
+
const notice = notices ? `${notices} ${notices === 1 ? "notice" : "notices"}${issue ? ` · last model issue: ${issue}` : " · ccdx status --details"}` : issue ? `Last model issue: ${issue}` : `Image evidence: ${imageRuntime?.tool_registration === "observed" ? "tool registered" : imageRuntime?.connected ? "host connected" : "unconfirmed"} · ccdx app codex image repair`;
|
|
91
92
|
content = [clip(heading, width), clip(webAddress, width), sourceHeader,
|
|
92
93
|
...(view.sources ? wrap(view.sources.map(source => source.name).join(" · "), width) : []),
|
|
93
94
|
`${"App".padEnd(appSize)}${"Setup".padEnd(setupSize)}${"Active".padStart(6)}`, ...appRows,
|
|
@@ -144,6 +145,7 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
|
|
|
144
145
|
});
|
|
145
146
|
},
|
|
146
147
|
pause() { running = false;unsubscribe?.();unsubscribe = null;if (timer) timers.clearTimeout(timer);timer = null;if (lines) output.write("\n");lines = 0;previous = [];dirty = true; },
|
|
148
|
+
image(value) { imageRuntime = value;dirty = true; },
|
|
147
149
|
beginRequest() { dirty = true;return () => { dirty = true; }; },
|
|
148
150
|
log(method, args) {
|
|
149
151
|
const message = redactDiagnosticText(format(...args));
|