codex-copilot-dx 1.4.12 → 1.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,14 +3,13 @@ import { createInterface } from "node:readline/promises";
3
3
  import { dashboardToolRequest } from "./cli-tools.mjs";
4
4
  import { readAdapterStatus } from "./cli-status.mjs";
5
5
  import { CLI_CLIENTS } from "./cli-command-spec.mjs";
6
- import { projectTerminalState, retainedRequests, clientSetup, TERMINAL_CLIENT_NAMES, terminalUptime, terminalRequestState } from "./terminal-state.mjs";
6
+ import { projectTerminalState, retainedRequests, TERMINAL_CLIENT_NAMES, terminalUptime, terminalRequestState } from "./terminal-state.mjs";
7
7
  import { formatResponsiveCliTable, cliOutputWidth, terminalCell } from "./cli-table.mjs";
8
8
  import { redactDiagnosticText } from "./diagnostic-text.mjs";
9
9
  import { settingsPreferencesSnapshot, writeSettingsPreferences, checkedPreferenceValues } from "./settings-preferences.mjs";
10
10
  import { checkedApi } from "./access-settings.mjs";
11
11
  import { hiddenQuestion } from "./cli-secret.mjs";
12
12
  import { readBoundedFileSync } from "./bounded-file.mjs";
13
- import { deploymentModelId } from "./model-capabilities.mjs";
14
13
  import { TERMINAL_COLOR_THEMES } from "./terminal-colors.mjs";
15
14
  import { previewSourceImport } from "./source-import.mjs";
16
15
  import { readAccessSettings } from "./access-settings.mjs";
@@ -144,9 +143,9 @@ export async function runManagementCommand(command, options = {}) {
144
143
  if (ids.request) {
145
144
  const found = rows.find(row => row.request_id === ids.request);if (!found) throw new Error("Request not retained. No full-history lookup is available.");return print(found);
146
145
  }
147
- rows = rows.filter(row => (!flags.active || row.active) && (!flags.failed || row.state !== "cancelled" && (row.state === "failed" || row.error))
146
+ rows = rows.filter(row => (!flags.active || row.active) && (!flags.failed || row.state !== "cancelled" && row.failure_category !== "capability" && (row.state === "failed" || row.error))
148
147
  && (!flags.purpose || (row.purpose || "unknown") === flags.purpose) && (!flags.source || row.provider === flags.source) && (!flags.app || (flags.app === "codex" ? ["codex", "codex_app", "codex_cli"].includes(row.application) : row.application === (flags.app === "antigravity" ? "gemini_app" : CLI_CLIENTS[flags.app])))).slice(-(flags.limit || 20));
149
- return print(flags.format === "json" ? rows : rows.map(row => ({ ...row, state_label: terminalRequestState(row) })), [["request_id", "Request"], ["application", "Client"], ["provider", "Source"], ["model", "Model"], ["route", "Route"], ["state_label", "State"]]);
148
+ return print(flags.format === "json" ? rows : rows.map(row => ({ ...row, state_label: terminalRequestState(row) })), [["request_id", "Request"], ["application", "Client"], ["provider", "Source"], ["model", "Model"], ["state_label", "State"], ["upstream_attempts", "Attempts"]]);
150
149
  }
151
150
  if (group === "usage") {
152
151
  if (flags.scope === "run") {
@@ -217,166 +216,10 @@ export async function runManagementCommand(command, options = {}) {
217
216
  if (running) { const result = await request({ path: "settings", body });return print({ saved: result.preferences.values, effective: effective(result), nightly_update: result.nightly_update, effect: "Saved; restart requirements are shown in effective state" }); }
218
217
  writeSettingsPreferences(body, preferenceOptions);return print({ saved: settingsPreferencesSnapshot(preferenceOptions).values, effect: "Saved for the next CCDX start; no service was started" });
219
218
  }
220
- if (group === "app") {
221
- if (path.length === 3 && ["open", "focus", "restart", "check"].includes(action)) {
222
- const id = ["antigravity", "gemini"].includes(path[1]) ? "antigravity" : CLI_CLIENTS[ids.app || path[1]];
223
- if (!["codex", "claude_app", "antigravity"].includes(id)) throw new Error("This command opens desktop apps. Run Claude Code in your terminal.");
224
- const settings = await request({ path: "settings?application=" + id + "&fresh=1", timeoutMs: 15000 }), app = settings.applications?.[id];
225
- if (!app) throw new Error("This command needs the updated running service; no app was changed.");
226
- if (action === "check" || flags.preview) return print({ id, ...app, ...(flags.preview ? { action, performed: false } : {}) });
227
- if (action === "restart") await confirm("Reopen " + path[1] + "? This may interrupt its current tasks.");
228
- const result = await request({ path: "settings", body: { action: "application", id, operation: action,
229
- ...(action === "restart" ? { confirmed: true, ...(app.pid ? { expected_pid: app.pid, expected_started: app.started } : {}) } : {}) }, timeoutMs: 65000 });
230
- return print(result.last_operation?.result || result.applications?.[id]);
231
- }
232
- if (["gemini", "antigravity"].includes(path[1])) {
233
- if (["enable", "disable"].includes(action)) {
234
- const preview = { action, background_source: "GitHub Copilot (all Antigravity summaries, searches and image generation)", ordinary_Gemini_chat: "Google; no routing change" };
235
- if (flags.preview) return print(preview);
236
- output.write(print(preview) + "\n");await confirm(action === "enable" ? "Enable this Antigravity-only routing scope?" : "Pause Copilot access? Reopen Gemini afterward to restore its native route.");
237
- }
238
- if(action==="models"&&flags.edit){
239
- const state=await request({path:"gemini",...(flags.refresh?{body:{action:"refresh"},timeoutMs:20000}:{})});
240
- let ids, preferred;
241
- if(flags.file){
242
- const file=readFile(),listed=file.models;preferred=file.default_model;if(!Array.isArray(listed))throw new Error("Model files require a models array.");
243
- ids=listed.flatMap(id=>state.model_groups?.find(model=>model.id===id)?.efforts.map(item=>item.id)||[id]);
244
- }
245
- else if(Array.isArray(state.model_groups)){
246
- const groups=state.model_groups,selected=await choose(groups.map(model=>model.name),groups.flatMap((model,index)=>model.efforts.some(item=>item.selected)?[index]:[]));
247
- ids=[];
248
- for(const index of selected){
249
- const model=groups[index],previous=model.efforts.flatMap((item,i)=>item.selected?[i]:[]);
250
- const efforts=await choose(model.efforts.map(item=>model.name+" / "+(item.effort||"default")),previous.length?previous:model.efforts.map((_,i)=>i));
251
- ids.push(...efforts.map(i=>model.efforts[i].id));
252
- }
253
- }else ids=(await choose(state.models.map(model=>model.name),state.models.flatMap((model,index)=>model.selected!==false?[index]:[]))).map(index=>state.models[index].id);
254
- if(!Array.isArray(ids)||new Set(ids).size!==ids.length||ids.some(id=>!state.models.some(model=>model.id===id)))throw new Error("Choose listed Antigravity model IDs.");
255
- const available=state.models.filter(model=>ids.includes(model.id));
256
- if(!flags.file&&available.length&&Object.hasOwn(state,"default_model")){
257
- available.forEach((model,index)=>output.write(`${index+1}. ${terminalCell(model.name)}${model.id===state.default_model?" (default)":""}\n`));
258
- const answer=(await ask("Default model number (Enter keeps it; none uses the app default): ")).trim();
259
- if(answer==="none")preferred=null;
260
- else if(answer){if(!/^\d+$/.test(answer)||!available[Number(answer)-1])throw new Error("Choose a listed default model number.");preferred=available[Number(answer)-1].id;}
261
- }
262
- if(preferred!==undefined&&preferred!==null&&!ids.includes(preferred)){
263
- const choices=available.filter(item=>item.model===preferred);
264
- preferred=(choices.find(item=>item.effort==="medium")||choices[0])?.id;
265
- if(!preferred)throw new Error("Choose a selected Antigravity model as the default.");
266
- }
267
- const body={models:ids,...(preferred!==undefined?{default_model:preferred}:{})};
268
- if(flags.preview)return print({...body,saved:false});
269
- await confirm("Save Antigravity model settings? Reopen Gemini afterward to reload them.");
270
- return print(await request({path:"gemini",body:{action:"models",...body}}));
271
- }
272
- const state = await request({ path: "gemini", ...(action==="models"&&flags.refresh?{body:{action:"refresh"},timeoutMs:20000}:["status", "models"].includes(action) ? {} : { body: { action: flags.preview ? "preview" : action, ...(action === "enable" ? { accept_background_copilot: true } : {}) }, timeoutMs: 20000 }) });
273
- if(action==="models"&&flags.format!=="json"&&state.model_groups)return print(state.model_groups.map(model=>({model:model.name,id:model.id,source:"GitHub Copilot",context:model.context_window,default:model.default===true,
274
- efforts:model.efforts.map(item=>(item.effort||"default")+(item.selected?" ✓":"")).join(" / ")})),[["model","Model"],["id","ID"],["source","Source"],["context","Context"],["efforts","Reasoning (selected ✓)"],["default","Default"]]);
275
- return print(action === "models" ? state.models : state);
276
- }
277
- const graph = await connection(), snapshot = (await readStatus()).data, view = projectTerminalState(snapshot);
278
- if (action === "list") {
279
- const clients=[...view.clients];
280
- if(!clients.some(client=>client.id==="antigravity"))clients.push({id:"antigravity",name:"Antigravity",setup:"Not checked",active:null});
281
- return print(clients, [["id", "ID"], ["name", "Client"], ["setup", "Setup"], ["active", "Active"]]);
282
- }
283
- const id = ids.app ? CLI_CLIENTS[ids.app] : "codex", client = getClient(graph, id), modelPlan = client.model_plan;
284
- if (!flags.preview && (flags.edit || ["sync", "enable", "disable"].includes(action))) requireManagement();
285
- const feature = path.length > 3 ? path[2] : null;
286
- if (feature || action === "status") {
287
- const settings = id === "codex" && (flags.details || feature) ? await request({ path: "settings" }) : null;
288
- const preference = settings?.providers?.[client.source || "github"]?.preference || {};
289
- const reviewId = client.auto_review_model || preference.auto_review_model || preference.model || null;
290
- const reviewModel = modelPlan?.models.find(model => [model.id, model.public_id, model.route_id].includes(reviewId));
291
- const details = { predictions: snapshot.client_integrations?.prediction || null, images: settings?.effective?.image_enabled || null,
292
- auto_review: { model: reviewModel?.id || reviewId, source: reviewModel?.source || client.source,
293
- ...(preference.followModel ? { mode: "Follow conversation model" } : {}),
294
- effort: client.auto_review_effort ?? preference.auto_review_effort ?? preference.reasoningEffort
295
- ?? (preference.followModel && reviewModel?.capability?.values?.reasoning_efforts?.includes("low") ? "low if omitted" : "Follows client") }, memory_model: client.memory_model || { model: null } };
296
- if (feature) return print({ client: "Codex", feature, state: details[{ prediction: "predictions", image: "images", review: "auto_review" }[feature]] });
297
- const observed = retainedRequests(snapshot).filter(row => id === "codex" ? ["codex", "codex_app", "codex_cli"].includes(row.application) : row.application === id).at(-1);
298
- return print({ id: ids.app, access: client.enabled ? clientSetup(client) === "Paused" ? "Paused" : "Enabled" : "Disabled", setup: view.clients.find(row => row.id === id)?.setup || clientSetup(client),
299
- selected_models: Array.isArray(client.deployments) ? client.deployments.length : modelPlan?.models.length ?? null, unavailable_selection: (modelPlan?.unavailable || []).filter(model => !modelPlan?.available.some(candidate => candidate.source === model.source && candidate.id === model.id)),
300
- app_adoption: view.clients.find(row => row.id === id)?.active > 0 ? "Active gateway request observed; process liveness not checked" : observed ? `Gateway request observed${observed.at || observed.time ? ` at ${observed.at || observed.time}` : ""}; process liveness not checked` : client.observed_at ? `Gateway request observed at ${client.observed_at}; process liveness not checked` : "Not observed",
301
- active: view.clients.find(row => row.id === id)?.active ?? null, ...(id.startsWith("claude_") && flags.details ? { capability_support: modelPlan?.support, capability_adoption: client.capability_adoption, capability_sync: modelPlan?.sync } : {}), ...(id === "codex" && flags.details ? { features: details, chatgpt_sign_in: "Managed by Codex; not inferred from GitHub credentials" } : {}) });
302
- }
303
- if (action === "models" && !flags.edit) {
304
- if (flags.format === "json") return print(modelPlan);
305
- return print([...(modelPlan?.models || []).map(model => ({ source: model.source, model: model.display_name || model.id, id: model.id, state: "Selected", default: [model.route_id, model.public_id].includes(modelPlan.default_model) })),
306
- ...(id === "codex" ? (modelPlan?.image?.models || []).map(model => ({ source: "github", model: model.name, id: model.id, state: modelPlan.image.selected_model === model.id ? "Selected image" : "Image", default: false })) : []),
307
- ...(id === "codex" && modelPlan?.image?.selected_model && !modelPlan.image.selected_available ? [{ source: "github", model: modelPlan.image.selected_model, id: modelPlan.image.selected_model, state: "Image unavailable; retained", default: false }] : []),
308
- ...(modelPlan?.unavailable || []).map(model => ({ source: model.source, model: model.id, id: model.id, state: !client.enabled && modelPlan?.available.some(item => item.source === model.source && item.id === model.id) ? "Retained; access disabled" : "Unavailable; retained", default: model.route_id === modelPlan.default_model }))], [["model", "Model"], ["source", "Source"], ["state", "Selection"], ["default", "Default"]]);
309
- }
310
- if (action === "sync") {
311
- const preview = { client: ids.app, models: modelPlan?.models.map(model => ({ source: model.source, model: model.display_name || model.id, id: model.id, context_window: model.capability?.values.context_window ?? null, reasoning_efforts: model.capability?.values.reasoning_efforts ?? null })), unavailable: modelPlan?.unavailable, default_model: modelPlan?.default_model, image: modelPlan?.image,
312
- current_setup: clientSetup(client), note: "Model/configuration plan only, not a byte-level file diff. Ownership is rechecked on sync; no App is restarted." };
313
- if (flags.preview) return print(preview);output.write(print(preview) + "\n");await confirm("Write CCDX-owned client settings now?");
314
- const result = await save({ operation: "sync_client", id, client_revision: client.revision });return print({ client: ids.app, setup: getClient(result, id).setup, image: getClient(result, id).model_plan?.image, app_adoption: "Not verified by writing configuration" });
315
- }
316
- if (["enable", "disable"].includes(action)) {
317
- const enabled = action === "enable", preview = { client: ids.app, access: enabled ? "Enabled" : "Disabled", retained_source: client.source,
318
- retained_models: client.deployments || "Legacy source binding retained", note: "Only gateway access changes; the client program stays open." };
319
- if (flags.preview) return print(preview);output.write(print(preview) + "\n");
320
- await confirm(enabled ? "Enable gateway access with the saved selection?" : "Disable gateway access? Later turns may fail; saved selections are retained.");
321
- const result = await save({ operation: "client_state", id, enabled, client_revision: client.revision });
322
- return print({ client: ids.app, setup: getClient(result, id).setup, saved: true, app_adoption: "Not verified" });
323
- }
324
- const body = clientBody(client);
325
- if (action === "models") {
326
- if (flags.file) {
327
- const file = readFile();if (Object.keys(file).some(key => !["deployments", "default_model", "auto_sync", "image_model"].includes(key))) throw new Error("Model files allow deployments, default_model, auto_sync and image_model only.");
328
- if (!Array.isArray(file.deployments)) throw new Error("Model files require an explicit deployments array; use [] to pause access.");
329
- Object.assign(body, file);if (!body.deployments.length) body.default_model = null;
330
- } else {
331
- const available = [...(modelPlan?.available || [])], selected = Array.isArray(client.deployments) ? client.deployments : modelPlan?.models.map(model => ({ source: model.source, model: model.id })) || [];
332
- for (const old of selected) if (!available.some(row => row.source === old.source && row.id === old.model)) available.push({ source: old.source, id: old.model, unavailable: true });
333
- const indexes = await choose(available.map(row => `${row.source} / ${row.id}${row.unavailable ? " (unavailable; selection retained)" : ""}`), available.flatMap((row, index) => selected.some(item => item.source === row.source && item.model === row.id) ? [index] : []));
334
- body.deployments = indexes.map(index => ({ ...selected.find(item => item.source === available[index].source && item.model === available[index].id), source: available[index].source, model: available[index].id }));
335
- body.default_model = client.default_model || modelPlan?.default_model || null;
336
- if (body.deployments.length) {
337
- const defaults = body.deployments.map(item => deploymentModelId(item.source, item.model));
338
- output.write(body.deployments.map((item, index) => `${index + 1} ${item.source} / ${item.model}`).join("\n") + "\n");
339
- const value = (await ask(`Default model number [${Math.max(1, defaults.indexOf(body.default_model) + 1)}]: `)).trim();
340
- if (value && (!/^\d+$/.test(value) || Number(value) < 1 || Number(value) > defaults.length)) throw new Error("Choose a listed default model number.");
341
- body.default_model = defaults[value ? Number(value) - 1 : Math.max(0, defaults.indexOf(body.default_model))];
342
- } else body.default_model = null;
343
- if (id === "claude_app") for (const item of body.deployments) {
344
- const entry = available.find(row => row.source === item.source && row.id === item.model), levels = entry?.capability?.values.reasoning_efforts || [];
345
- if (entry?.effort_control !== "gateway" && item.reasoning_effort === undefined) continue;
346
- output.write(`Reasoning for ${item.source} / ${item.model}: follow-app${levels.length ? ", " + levels.join(", ") : ""}\n`);
347
- const answer = (await ask(`Default when the app omits effort [${item.reasoning_effort || "follow-app"}]: `)).trim();
348
- if (answer === "follow-app") delete item.reasoning_effort;
349
- else if (answer) { if (!levels.includes(answer)) throw new Error("Choose a declared reasoning level or follow-app.");item.reasoning_effort = answer; }
350
- }
351
- }
352
- if (id === "codex" && !flags.file && modelPlan?.image?.models?.length) {
353
- const images = modelPlan.image.models, current = images.findIndex(model => model.id === modelPlan.image.selected_model);
354
- output.write(images.map((model, i) => `${i + 1} ${model.name || model.id} [Image]`).join("\n") + "\n");
355
- const answer = (await ask(`Image model number [${Math.max(1, current + 1)}]: `)).trim();
356
- if (answer && (!/^\d+$/.test(answer) || Number(answer) < 1 || Number(answer) > images.length)) throw new Error("Choose a listed image model number.");
357
- body.image_model = images[answer ? Number(answer) - 1 : Math.max(0, current)].id;
358
- }
359
- if (body.deployments?.some(item => modelPlan?.unavailable.some(row => row.source === item.source && row.id === item.model))) throw new Error("Unavailable selections were kept. Wait for the catalog or explicitly deselect them before saving a changed plan.");
360
- } else throw new Error("Unsupported client action.");
361
- const memory = id === "codex" ? client.memory_model?.model : null;
362
- const memoryModels = [...(modelPlan?.models || []), ...(modelPlan?.available || []), ...(modelPlan?.unavailable || [])].filter(row => [row.id, row.route_id, row.public_id].includes(memory));
363
- const memoryPairs = new Set(memoryModels.map(row => row.source + "\0" + row.id));
364
- const memoryMatch = row => memoryPairs.size ? memoryPairs.has(row.source + "\0" + (row.model || row.id)) : [row.model, row.id, row.route_id, row.public_id].includes(memory);
365
- if (memory && (client.deployments || modelPlan?.models || []).some(memoryMatch) && Array.isArray(body.deployments) && !body.deployments.some(memoryMatch)) {
366
- output.write(`Warning: ${terminalCell(memory)} is an observed memory dependency; memory writing may fail if it is unselected.\n`);
367
- }
368
- const previousModels = client.deployments || modelPlan?.models.map(model => ({ source: model.source, model: model.id })) || [];
369
- const previousKeys = new Set(previousModels.map(item => item.source + "\0" + item.model));
370
- const previousDefault = client.default_model || modelPlan?.models.find(model => model.public_id === modelPlan.default_model)?.route_id || null;
371
- const imageOnly = id === "codex" && body.image_model && body.image_model !== modelPlan?.image?.selected_model
372
- && body.deployments?.length === previousKeys.size && body.deployments.every(item => previousKeys.has(item.source + "\0" + item.model))
373
- && body.default_model === previousDefault && (body.auto_sync !== false) === (client.auto_sync !== false);
374
- const checked = await save({ ...body, operation: "preview_client" });
375
- output.write(print({ client: ids.app, planned_models: checked.preview?.models.map(model => ({ source: model.source, id: model.id })), change: action, enabled: body.enabled, deployments: body.deployments, default_model: body.default_model }) + "\n");
376
- if (flags.preview) return "Preview only; no settings changed.";
377
- await confirm(body.enabled ? "Save this client selection?" : "Disable gateway access? Later turns may fail; the client program stays open.");
378
- const result = await save(imageOnly ? { operation: "image_model", id: "codex", model: body.image_model, client_revision: client.revision } : body);return print({ client: ids.app, setup: getClient(result, id).setup, saved: true, app_adoption: "Not verified" });
379
- }
219
+ if (group === "app") return (await import("./cli-management-app.mjs")).runAppCommand({
220
+ path, ids, flags, output, request, readStatus, ask, print, confirm, choose,
221
+ connection, requireManagement, save, getClient, clientBody, readFile,
222
+ });
380
223
  if (group !== "source") throw new Error("Unknown management command.");
381
224
  if (action === "import") {
382
225
  if (Boolean(flags.file) === Boolean(flags.from)) throw new Error("Use --file FILE or --from cc-switch|magpie.");
@@ -193,6 +193,8 @@ export function createConnectionManagement({ binding, catalogRefresh, save, disc
193
193
  const c = binding("codex"),
194
194
  compiled = plan("codex");
195
195
  if (!c.enabled || input.provider !== c.source) throw accessError("ccdx_client_source_mismatch", 409);
196
+ if (c.source === "github" && String(env.CCDX_AUTO_REVIEW_MODEL || "").trim())
197
+ throw accessError("ccdx_review_environment_override", 409);
196
198
  const follow = input.model === "";
197
199
  const record = follow ? compiled.routes.get(compiled.defaultModel) : [...compiled.routes.values()].find(
198
200
  record => record.source === input.provider && record.upstreamModel === input.model
@@ -102,19 +102,28 @@ export function createConnectionRouting({ legacy, legacyClaudeAccess, isManaged,
102
102
  if (!Array.isArray(codex.deployments)) return null;
103
103
  if (codexRequiresKey()) requireCodexKey(req);
104
104
  const context = currentRequestContext(), review = body.model === "codex-auto-review";
105
- const key = !codex.auto_review_model && (review || context?.purpose === "conversation") ? reviewSession(req.headers, context?.application) : null;
105
+ const override = review && codex.source === "github" ? String(env.CCDX_AUTO_REVIEW_MODEL || "").trim() : "";
106
+ const key = !override && !codex.auto_review_model && (review || context?.purpose === "conversation") ? reviewSession(req.headers, context?.application) : null;
106
107
  let requested = body.model;
107
108
  if (review) {
108
109
  const compiled = plan("codex"), remembered = key && reviewSessions.get(key);
109
- const candidate = remembered && Date.now() - remembered.at <= 1800000 && compiled.routes.get(remembered.route);
110
- const sameProfile = candidate && typeof remembered.profile === "string" && candidate.provider.profileId?.("responses") === remembered.profile;
111
- requested = codex.auto_review_model || (sameProfile ? remembered.route : compiled.defaultModel);
110
+ if (override) {
111
+ const selected = [...compiled.routes.values()].find(record => record.source === "github"
112
+ && (record.upstreamModel === override || record.model.route_id === override));
113
+ if (!selected) throw accessError("ccdx_api_model_unavailable", 503);
114
+ requested = selected.model.route_id;
115
+ } else {
116
+ const candidate = remembered && Date.now() - remembered.at <= 1800000 && compiled.routes.get(remembered.route);
117
+ const sameProfile = candidate && typeof remembered.profile === "string" && candidate.provider.profileId?.("responses") === remembered.profile;
118
+ requested = codex.auto_review_model || (sameProfile ? remembered.route : compiled.defaultModel);
119
+ }
112
120
  delete body.service_tier;
113
121
  }
114
122
  const record = resolveDeployment("codex", requested);
115
123
  if (review) {
116
124
  const supports = record.model.capability.values.reasoning_efforts || [];
117
- const chosen = codex.auto_review_effort && supports.includes(codex.auto_review_effort) ? codex.auto_review_effort
125
+ const configured = !override || codex.auto_review_model === requested ? codex.auto_review_effort : undefined;
126
+ const chosen = configured && supports.includes(configured) ? configured
118
127
  : body.reasoning?.effort === undefined && supports.includes("low") ? "low" : undefined;
119
128
  if (chosen) body.reasoning = { ...body.reasoning, effort: chosen };
120
129
  } else if (key && context) context.noteReviewModel = () => {
@@ -22,10 +22,10 @@ export function summaryRequest(body, protocol, text) {
22
22
  throw fail("The compression interface is unsupported.");
23
23
  }
24
24
 
25
- export function compactionSummarizer(body, protocol, call) {
25
+ export function compactionSummarizer(body, protocol, call, { requireChatDone = false } = {}) {
26
26
  return async (text, options) => {
27
27
  const response = await call(summaryRequest(body, protocol, text), { ...options, sourceBodyManaged: true, bodyText: undefined, payloadPrepared: false, currentInputStart: 0, countTokens: false, retryOptions: { ...options.retryOptions, retries: 0 } });
28
- return readCompactionSummary(response, protocol, { signal: options.signal, onActivity: options.onActivity, onUsage: options.onUsage });
28
+ return readCompactionSummary(response, protocol, { signal: options.signal, onActivity: options.onActivity, onUsage: options.onUsage, requireChatDone });
29
29
  };
30
30
  }
31
31
 
@@ -44,7 +44,7 @@ function safeResponse(response, signal) {
44
44
  return { body, headers: response.headers };
45
45
  }
46
46
 
47
- export async function readCompactionSummary(response, protocol, { signal, onActivity = () => {}, onUsage = () => {} } = {}) {
47
+ export async function readCompactionSummary(response, protocol, { signal, onActivity = () => {}, onUsage = () => {}, requireChatDone = false } = {}) {
48
48
  if (!response.ok) {
49
49
  try { void cancelSourceResponse(response).catch(() => {}); } catch {}
50
50
  throw Object.assign(new Error("The source rejected an internal compression request."), { code: "ccdx_compaction_upstream_error", statusCode: response.status });
@@ -115,9 +115,9 @@ export async function readCompactionSummary(response, protocol, { signal, onActi
115
115
  onActivity();const raw = await readBoundedResponseText(incoming, { maxBytes: MAX_WIRE, label: "Compression response", signal });
116
116
  let value;try { value = JSON.parse(raw); } catch { throw fail("The compression response is not valid JSON."); }accept(value);
117
117
  } else {
118
- let data = [], frameBytes = 0;
118
+ let data = [], frameBytes = 0, chatDone = false;
119
119
  const flush = () => {
120
- if (!data.length) return;const raw = data.join("\n");data = [];frameBytes = 0;if (raw === "[DONE]") return;
120
+ if (!data.length) return;const raw = data.join("\n");data = [];frameBytes = 0;if (raw === "[DONE]") { chatDone = true;return; }
121
121
  let value;try { value = JSON.parse(raw); } catch { throw fail("The compression stream contains invalid JSON."); }accept(value);
122
122
  };
123
123
  for await (const line of webStreamLines(incoming, { maxBufferBytes: MAX_TEXT, onChunk(chunk) {
@@ -129,7 +129,7 @@ export async function readCompactionSummary(response, protocol, { signal, onActi
129
129
  const value = line.slice(5).replace(/^ /, "");frameBytes += Buffer.byteLength(value);if (frameBytes > MAX_TEXT) throw fail("The compression event exceeds its budget.");data.push(value);
130
130
  }
131
131
  flush();
132
- if (protocol === "messages" && !messageStopped) complete = false;
132
+ if (protocol === "messages" && !messageStopped || protocol === "chat" && requireChatDone && !chatDone) complete = false;
133
133
  }
134
134
  if (protocol === "messages" && parts.size) { reset();for (const [, part] of [...parts].sort(([a], [b]) => a - b)) for (const fragment of part.fragments) append(fragment); }
135
135
  const text = fragments.join("");
@@ -109,7 +109,7 @@
109
109
  toggle.addEventListener("change", () => { toggle.checked = true;disableSource(provider); });const hit = node("label", undefined, "switch-hit");hit.append(toggle);actions.append(hit);
110
110
  } else actions.append(button("api_restore", () => void change({ operation: "provider", id: provider.id, enabled: true })));
111
111
  if (!provider.builtin && !provider.enabled) {
112
- const remove = button("api_remove_source", () => { if (window.confirm(format("api_remove_source_confirm"))) void change({ operation: "remove_api", id: provider.id, impact_revision: data.source_impacts?.[provider.id]?.revision }); });
112
+ const remove = button("api_remove_source", async () => { if (await globalThis.ccdxConfirmAction("api_remove_source", "api_remove_source_confirm")) void change({ operation: "remove_api", id: provider.id, impact_revision: data.source_impacts?.[provider.id]?.revision }); });
113
113
  remove.disabled = data.clients.some(c => c.source === provider.id || c.deployments?.some(item => item.source === provider.id));actions.append(remove);
114
114
  }
115
115
  row.dataset.source = provider.id;row.append(info, actions);if (!provider.enabled) disabledSources.append(row);else if (provider.id === selectedProvider) providerList.append(row);
@@ -323,7 +323,7 @@
323
323
  for (const input of apiForm.querySelectorAll('[name="protocol"]')) input.checked = provider ? Boolean(provider.endpoints?.[input.value]) : ["messages", "responses"].includes(input.value);
324
324
  setEndpoints(provider?.base_url || "", provider?.endpoints);
325
325
  el("connection-model-detail").hidden = true;
326
- models = structuredClone(provider?.models || []);selectedModels = new Set(models.map(model => model.id));modelRows();el("connection-manual-model").open = false;el("connection-discover").disabled = !editing;el("connection-model-id").value = "";apiForm.elements.name.focus();
326
+ models = structuredClone(provider?.models || []);selectedModels = new Set(models.map(model => model.id));modelRows();el("connection-manual-model").open = false;el("connection-discover").disabled = !editing;el("connection-discover-note").hidden = editing;el("connection-model-id").value = "";apiForm.elements.name.focus();
327
327
  words(apiForm.querySelector('button[type="submit"]'), provider ? "api_save" : "api_save_read");
328
328
  }
329
329
  apiForm.elements.base.addEventListener("change", () => setEndpoints(apiForm.elements.base.value));
@@ -507,7 +507,17 @@
507
507
  function editClient(c) { location.hash = c.id === "codex" ? "codex" : "claude";if (c.id !== "codex") claudeClient = c.id;mountClient(true); }
508
508
  for (const segment of document.querySelectorAll("[data-claude-client]")) segment.addEventListener("click", () => {
509
509
  rememberDraft();claudeClient = segment.dataset.claudeClient;
510
- for (const button of document.querySelectorAll("[data-claude-client]")) button.setAttribute("aria-pressed", String(button === segment));mountClient(true);
510
+ for (const button of document.querySelectorAll("[data-claude-client]")) {
511
+ button.setAttribute("aria-selected", String(button === segment));button.tabIndex = button === segment ? 0 : -1;
512
+ }
513
+ el("claude-model-management").setAttribute("aria-labelledby", segment.id);mountClient(true);
514
+ });
515
+ const claudeTabs = [...document.querySelectorAll("[data-claude-client]")];
516
+ for (const [index, tab] of claudeTabs.entries()) tab.addEventListener("keydown", event => {
517
+ if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
518
+ event.preventDefault();
519
+ const next = claudeTabs[event.key === "Home" ? 0 : event.key === "End" ? claudeTabs.length - 1 : 1 - index];
520
+ next.click();next.focus();
511
521
  });
512
522
  el("connection-auto-sync").addEventListener("change", () => { bindingDirty = true;rememberDraft();el("connection-client-cancel").disabled = false;words(el("connection-draft-state"), "cap_unsaved");words(clientForm.querySelector('button[type="submit"]'), el("connection-auto-sync").checked ? "cap_save_sync" : "api_save"); });
513
523
  el("connection-client-cancel").addEventListener("click", () => { drafts.delete(editingClient);bindingDirty = false;mountClient(true); });
@@ -83,8 +83,8 @@
83
83
  inflightField.addEventListener("keydown", event => {
84
84
  if (event.key === "Enter") { event.preventDefault();void saveInflight(false); }
85
85
  });
86
- el("install-update").addEventListener("click", () => {
87
- if (window.confirm(globalThis.ccdxLanguage.format("update_install_confirm"))) void change({ action: "update", confirmed: true }, el("install-update"));
86
+ el("install-update").addEventListener("click", async () => {
87
+ if (await globalThis.ccdxConfirmAction("update_install_now", "update_install_confirm")) void change({ action: "update", confirmed: true }, el("install-update"));
88
88
  });
89
89
  function render(data, { notes = true } = {}) {
90
90
  if (!data) return;