codex-copilot-dx 1.3.16 → 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 +2 -0
- package/docs/ARCHITECTURE.md +6 -0
- package/docs/REFERENCE.md +8 -1
- 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 +29 -9
- 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/management-routes.mjs +2 -0
- package/src/models.mjs +3 -3
- package/src/service-control.mjs +9 -4
- package/src/stream-performance.mjs +6 -2
- package/src/terminal-console.mjs +3 -1
package/README.md
CHANGED
|
@@ -60,6 +60,8 @@ 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).
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -1110,3 +1110,9 @@ The 1.3.13 native helper groups uncached short CPU sequences under the existing
|
|
|
1110
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.
|
|
1111
1111
|
|
|
1112
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
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 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
|
+
|
|
587
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,10 +58,11 @@ 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 () => {
|
|
@@ -140,10 +141,14 @@ export function createImageHostBridge({ baseUrl, codexHome, sendToCodex, fetchIm
|
|
|
140
141
|
|
|
141
142
|
return {
|
|
142
143
|
async client(message) {
|
|
143
|
-
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
|
+
}
|
|
144
148
|
if (["thread/start", "thread/resume", "thread/fork"].includes(message.method)) {
|
|
145
|
-
|
|
146
|
-
|
|
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 || {}) };
|
|
147
152
|
}
|
|
148
153
|
if (message.method === "turn/start") {
|
|
149
154
|
const context = threads.get(message.params?.threadId);
|
|
@@ -157,6 +162,8 @@ export function createImageHostBridge({ baseUrl, codexHome, sendToCodex, fetchIm
|
|
|
157
162
|
const pending = requests.get(JSON.stringify(message.id));
|
|
158
163
|
if (pending && !message.method) {
|
|
159
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);
|
|
160
167
|
if (thread?.id && thread.cwd) threads.set(thread.id, { cwd: thread.cwd, roots: pending.params.runtimeWorkspaceRoots || [], attachments: [], generated: [] });
|
|
161
168
|
}
|
|
162
169
|
if (message.method === "item/completed" && message.params?.item?.type === "imageGeneration" && message.params.item.savedPath) {
|
|
@@ -166,12 +173,12 @@ export function createImageHostBridge({ baseUrl, codexHome, sendToCodex, fetchIm
|
|
|
166
173
|
const controller = new AbortController(), key = JSON.stringify(message.id);
|
|
167
174
|
active.set(key, { controller, threadId: message.params.threadId });
|
|
168
175
|
void runImage(message.params, AbortSignal.any([controller.signal, AbortSignal.timeout(180000)]))
|
|
169
|
-
.then(result => sendToCodex({ id: message.id, result }))
|
|
170
|
-
.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 }] } }); })
|
|
171
178
|
.finally(() => active.delete(key));
|
|
172
179
|
return true;
|
|
173
180
|
},
|
|
174
|
-
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")); },
|
|
175
182
|
};
|
|
176
183
|
}
|
|
177
184
|
|
|
@@ -195,10 +202,23 @@ export async function runCodexImageHost({ codex, argv, baseUrl, env = process.en
|
|
|
195
202
|
const child = spawnImpl(codex, args, { env: childEnv, stdio: ["pipe", "pipe", "pipe"] });
|
|
196
203
|
child.stdin.on("error", () => {});child.stderr.pipe(error, { end: false });
|
|
197
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
|
+
};
|
|
198
218
|
const write = message => { if (!child.stdin.destroyed) child.stdin.write(JSON.stringify(message) + "\n"); };
|
|
199
219
|
if (!stdio) { input.pipe(child.stdin);child.stdout.pipe(output, { end: false }); }
|
|
200
220
|
else {
|
|
201
|
-
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 });
|
|
202
222
|
cleanups.push(lines(input, raw => {
|
|
203
223
|
queue = queue.then(async () => {
|
|
204
224
|
let message;try { message = JSON.parse(raw); } catch { child.stdin.write(raw + "\n");return; }
|
|
@@ -214,5 +234,5 @@ export async function runCodexImageHost({ codex, argv, baseUrl, env = process.en
|
|
|
214
234
|
const interrupt = () => stop("SIGINT"), terminate = () => stop("SIGTERM");
|
|
215
235
|
process.once("SIGINT", interrupt);process.once("SIGTERM", terminate);
|
|
216
236
|
try { const [code, signal] = await once(child, "exit");await queue;return code ?? (signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 1); }
|
|
217
|
-
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); }
|
|
218
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
|
+
}
|
|
@@ -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");
|
|
@@ -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));
|