codex-copilot-dx 1.4.13 → 1.4.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,169 @@
1
+ import { CLI_CLIENTS } from "./cli-command-spec.mjs";
2
+ import { projectTerminalState, retainedRequests, clientSetup, TERMINAL_CLIENT_NAMES } from "./terminal-state.mjs";
3
+ import { terminalCell } from "./cli-table.mjs";
4
+ import { deploymentModelId } from "./model-capabilities.mjs";
5
+
6
+ export async function runAppCommand({ path, ids, flags, output, request, readStatus, ask, print, confirm,
7
+ choose, connection, requireManagement, save, getClient, clientBody, readFile }) {
8
+ const action = path.at(-1);
9
+ if (path.length === 3 && ["open", "focus", "restart", "check"].includes(action)) {
10
+ const id = ["antigravity", "gemini"].includes(path[1]) ? "antigravity" : CLI_CLIENTS[ids.app || path[1]];
11
+ if (!["codex", "claude_app", "antigravity"].includes(id)) throw new Error("This command opens desktop apps. Run Claude Code in your terminal.");
12
+ const settings = await request({ path: "settings?application=" + id + "&fresh=1", timeoutMs: 15000 }), app = settings.applications?.[id];
13
+ if (!app) throw new Error("This command needs the updated running service; no app was changed.");
14
+ if (action === "check" || flags.preview) return print({ id, ...app, ...(flags.preview ? { action, performed: false } : {}) });
15
+ if (action === "restart") await confirm("Reopen " + path[1] + "? This may interrupt its current tasks.");
16
+ const result = await request({ path: "settings", body: { action: "application", id, operation: action,
17
+ ...(action === "restart" ? { confirmed: true, ...(app.pid ? { expected_pid: app.pid, expected_started: app.started } : {}) } : {}) }, timeoutMs: 65000 });
18
+ return print(result.last_operation?.result || result.applications?.[id]);
19
+ }
20
+ if (["gemini", "antigravity"].includes(path[1])) {
21
+ if (["enable", "disable"].includes(action)) {
22
+ const preview = { action, background_source: "GitHub Copilot (all Antigravity summaries, searches and image generation)", ordinary_Gemini_chat: "Google; no routing change" };
23
+ if (flags.preview) return print(preview);
24
+ 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.");
25
+ }
26
+ if(action==="models"&&flags.edit){
27
+ const state=await request({path:"gemini",...(flags.refresh?{body:{action:"refresh"},timeoutMs:20000}:{})});
28
+ let ids, preferred;
29
+ if(flags.file){
30
+ const file=readFile(),listed=file.models;preferred=file.default_model;if(!Array.isArray(listed))throw new Error("Model files require a models array.");
31
+ ids=listed.flatMap(id=>state.model_groups?.find(model=>model.id===id)?.efforts.map(item=>item.id)||[id]);
32
+ }
33
+ else if(Array.isArray(state.model_groups)){
34
+ const groups=state.model_groups,selected=await choose(groups.map(model=>model.name),groups.flatMap((model,index)=>model.efforts.some(item=>item.selected)?[index]:[]));
35
+ ids=[];
36
+ for(const index of selected){
37
+ const model=groups[index],previous=model.efforts.flatMap((item,i)=>item.selected?[i]:[]);
38
+ const efforts=await choose(model.efforts.map(item=>model.name+" / "+(item.effort||"default")),previous.length?previous:model.efforts.map((_,i)=>i));
39
+ ids.push(...efforts.map(i=>model.efforts[i].id));
40
+ }
41
+ }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);
42
+ 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.");
43
+ const available=state.models.filter(model=>ids.includes(model.id));
44
+ if(!flags.file&&available.length&&Object.hasOwn(state,"default_model")){
45
+ available.forEach((model,index)=>output.write(`${index+1}. ${terminalCell(model.name)}${model.id===state.default_model?" (default)":""}\n`));
46
+ const answer=(await ask("Default model number (Enter keeps it; none uses the app default): ")).trim();
47
+ if(answer==="none")preferred=null;
48
+ 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;}
49
+ }
50
+ if(preferred!==undefined&&preferred!==null&&!ids.includes(preferred)){
51
+ const choices=available.filter(item=>item.model===preferred);
52
+ preferred=(choices.find(item=>item.effort==="medium")||choices[0])?.id;
53
+ if(!preferred)throw new Error("Choose a selected Antigravity model as the default.");
54
+ }
55
+ const body={models:ids,...(preferred!==undefined?{default_model:preferred}:{})};
56
+ if(flags.preview)return print({...body,saved:false});
57
+ await confirm("Save Antigravity model settings? Reopen Gemini afterward to reload them.");
58
+ return print(await request({path:"gemini",body:{action:"models",...body}}));
59
+ }
60
+ 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 }) });
61
+ 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,
62
+ efforts:model.efforts.map(item=>(item.effort||"default")+(item.selected?" ✓":"")).join(" / ")})),[["model","Model"],["id","ID"],["source","Source"],["context","Context"],["efforts","Reasoning (selected ✓)"],["default","Default"]]);
63
+ return print(action === "models" ? state.models : state);
64
+ }
65
+ const graph = await connection(), snapshot = (await readStatus()).data, view = projectTerminalState(snapshot);
66
+ if (action === "list") {
67
+ const clients=[...view.clients];
68
+ if(!clients.some(client=>client.id==="antigravity"))clients.push({id:"antigravity",name:"Antigravity",setup:"Not checked",active:null});
69
+ return print(clients, [["id", "ID"], ["name", "Client"], ["setup", "Setup"], ["active", "Active"]]);
70
+ }
71
+ const id = ids.app ? CLI_CLIENTS[ids.app] : "codex", client = getClient(graph, id), modelPlan = client.model_plan;
72
+ if (!flags.preview && (flags.edit || ["sync", "enable", "disable"].includes(action))) requireManagement();
73
+ const feature = path.length > 3 ? path[2] : null;
74
+ if (feature || action === "status") {
75
+ const settings = id === "codex" && (flags.details || feature) ? await request({ path: "settings" }) : null;
76
+ const preference = settings?.providers?.[client.source || "github"]?.preference || {};
77
+ const locked = preference.source === "environment";
78
+ const reviewId = (locked ? preference.model : client.auto_review_model || preference.auto_review_model || preference.model) || null;
79
+ const reviewModel = modelPlan?.models.find(model => [model.id, model.public_id, model.route_id].includes(reviewId));
80
+ const details = { predictions: snapshot.client_integrations?.prediction || null, images: settings?.effective?.image_enabled || null,
81
+ auto_review: { model: reviewModel?.id || reviewId, source: reviewModel?.source || client.source,
82
+ ...(locked ? { mode: "Startup override" } : preference.followModel ? { mode: "Follow conversation model" } : {}),
83
+ effort: (locked && client.auto_review_model !== reviewModel?.route_id ? undefined : client.auto_review_effort)
84
+ ?? (locked ? undefined : preference.auto_review_effort ?? preference.reasoningEffort)
85
+ ?? (reviewModel?.capability?.values?.reasoning_efforts?.includes("low") ? "low if omitted" : "Follows client") }, memory_model: client.memory_model || { model: null } };
86
+ if (feature) return print({ client: "Codex", feature, state: details[{ prediction: "predictions", image: "images", review: "auto_review" }[feature]] });
87
+ const observed = retainedRequests(snapshot).filter(row => id === "codex" ? ["codex", "codex_app", "codex_cli"].includes(row.application) : row.application === id).at(-1);
88
+ 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),
89
+ 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)),
90
+ 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",
91
+ 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" } : {}) });
92
+ }
93
+ if (action === "models" && !flags.edit) {
94
+ if (flags.format === "json") return print(modelPlan);
95
+ 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) })),
96
+ ...(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 })) : []),
97
+ ...(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 }] : []),
98
+ ...(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"]]);
99
+ }
100
+ if (action === "sync") {
101
+ 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,
102
+ current_setup: clientSetup(client), note: "Model/configuration plan only, not a byte-level file diff. Ownership is rechecked on sync; no App is restarted." };
103
+ if (flags.preview) return print(preview);output.write(print(preview) + "\n");await confirm("Write CCDX-owned client settings now?");
104
+ 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" });
105
+ }
106
+ if (["enable", "disable"].includes(action)) {
107
+ const enabled = action === "enable", preview = { client: ids.app, access: enabled ? "Enabled" : "Disabled", retained_source: client.source,
108
+ retained_models: client.deployments || "Legacy source binding retained", note: "Only gateway access changes; the client program stays open." };
109
+ if (flags.preview) return print(preview);output.write(print(preview) + "\n");
110
+ await confirm(enabled ? "Enable gateway access with the saved selection?" : "Disable gateway access? Later turns may fail; saved selections are retained.");
111
+ const result = await save({ operation: "client_state", id, enabled, client_revision: client.revision });
112
+ return print({ client: ids.app, setup: getClient(result, id).setup, saved: true, app_adoption: "Not verified" });
113
+ }
114
+ const body = clientBody(client);
115
+ if (action === "models") {
116
+ if (flags.file) {
117
+ 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.");
118
+ if (!Array.isArray(file.deployments)) throw new Error("Model files require an explicit deployments array; use [] to pause access.");
119
+ Object.assign(body, file);if (!body.deployments.length) body.default_model = null;
120
+ } else {
121
+ const available = [...(modelPlan?.available || [])], selected = Array.isArray(client.deployments) ? client.deployments : modelPlan?.models.map(model => ({ source: model.source, model: model.id })) || [];
122
+ 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 });
123
+ 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] : []));
124
+ 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 }));
125
+ body.default_model = client.default_model || modelPlan?.default_model || null;
126
+ if (body.deployments.length) {
127
+ const defaults = body.deployments.map(item => deploymentModelId(item.source, item.model));
128
+ output.write(body.deployments.map((item, index) => `${index + 1} ${item.source} / ${item.model}`).join("\n") + "\n");
129
+ const value = (await ask(`Default model number [${Math.max(1, defaults.indexOf(body.default_model) + 1)}]: `)).trim();
130
+ if (value && (!/^\d+$/.test(value) || Number(value) < 1 || Number(value) > defaults.length)) throw new Error("Choose a listed default model number.");
131
+ body.default_model = defaults[value ? Number(value) - 1 : Math.max(0, defaults.indexOf(body.default_model))];
132
+ } else body.default_model = null;
133
+ if (id === "claude_app") for (const item of body.deployments) {
134
+ const entry = available.find(row => row.source === item.source && row.id === item.model), levels = entry?.capability?.values.reasoning_efforts || [];
135
+ if (entry?.effort_control !== "gateway" && item.reasoning_effort === undefined) continue;
136
+ output.write(`Reasoning for ${item.source} / ${item.model}: follow-app${levels.length ? ", " + levels.join(", ") : ""}\n`);
137
+ const answer = (await ask(`Default when the app omits effort [${item.reasoning_effort || "follow-app"}]: `)).trim();
138
+ if (answer === "follow-app") delete item.reasoning_effort;
139
+ else if (answer) { if (!levels.includes(answer)) throw new Error("Choose a declared reasoning level or follow-app.");item.reasoning_effort = answer; }
140
+ }
141
+ }
142
+ if (id === "codex" && !flags.file && modelPlan?.image?.models?.length) {
143
+ const images = modelPlan.image.models, current = images.findIndex(model => model.id === modelPlan.image.selected_model);
144
+ output.write(images.map((model, i) => `${i + 1} ${model.name || model.id} [Image]`).join("\n") + "\n");
145
+ const answer = (await ask(`Image model number [${Math.max(1, current + 1)}]: `)).trim();
146
+ if (answer && (!/^\d+$/.test(answer) || Number(answer) < 1 || Number(answer) > images.length)) throw new Error("Choose a listed image model number.");
147
+ body.image_model = images[answer ? Number(answer) - 1 : Math.max(0, current)].id;
148
+ }
149
+ 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.");
150
+ } else throw new Error("Unsupported client action.");
151
+ const memory = id === "codex" ? client.memory_model?.model : null;
152
+ const memoryModels = [...(modelPlan?.models || []), ...(modelPlan?.available || []), ...(modelPlan?.unavailable || [])].filter(row => [row.id, row.route_id, row.public_id].includes(memory));
153
+ const memoryPairs = new Set(memoryModels.map(row => row.source + "\0" + row.id));
154
+ 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);
155
+ if (memory && (client.deployments || modelPlan?.models || []).some(memoryMatch) && Array.isArray(body.deployments) && !body.deployments.some(memoryMatch)) {
156
+ output.write(`Warning: ${terminalCell(memory)} is an observed memory dependency; memory writing may fail if it is unselected.\n`);
157
+ }
158
+ const previousModels = client.deployments || modelPlan?.models.map(model => ({ source: model.source, model: model.id })) || [];
159
+ const previousKeys = new Set(previousModels.map(item => item.source + "\0" + item.model));
160
+ const previousDefault = client.default_model || modelPlan?.models.find(model => model.public_id === modelPlan.default_model)?.route_id || null;
161
+ const imageOnly = id === "codex" && body.image_model && body.image_model !== modelPlan?.image?.selected_model
162
+ && body.deployments?.length === previousKeys.size && body.deployments.every(item => previousKeys.has(item.source + "\0" + item.model))
163
+ && body.default_model === previousDefault && (body.auto_sync !== false) === (client.auto_sync !== false);
164
+ const checked = await save({ ...body, operation: "preview_client" });
165
+ 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");
166
+ if (flags.preview) return "Preview only; no settings changed.";
167
+ await confirm(body.enabled ? "Save this client selection?" : "Disable gateway access? Later turns may fail; the client program stays open.");
168
+ 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" });
169
+ }
@@ -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";
@@ -217,168 +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 locked = preference.source === "environment";
290
- const reviewId = (locked ? preference.model : client.auto_review_model || preference.auto_review_model || preference.model) || null;
291
- const reviewModel = modelPlan?.models.find(model => [model.id, model.public_id, model.route_id].includes(reviewId));
292
- const details = { predictions: snapshot.client_integrations?.prediction || null, images: settings?.effective?.image_enabled || null,
293
- auto_review: { model: reviewModel?.id || reviewId, source: reviewModel?.source || client.source,
294
- ...(locked ? { mode: "Startup override" } : preference.followModel ? { mode: "Follow conversation model" } : {}),
295
- effort: (locked && client.auto_review_model !== reviewModel?.route_id ? undefined : client.auto_review_effort)
296
- ?? (locked ? undefined : preference.auto_review_effort ?? preference.reasoningEffort)
297
- ?? (reviewModel?.capability?.values?.reasoning_efforts?.includes("low") ? "low if omitted" : "Follows client") }, memory_model: client.memory_model || { model: null } };
298
- if (feature) return print({ client: "Codex", feature, state: details[{ prediction: "predictions", image: "images", review: "auto_review" }[feature]] });
299
- const observed = retainedRequests(snapshot).filter(row => id === "codex" ? ["codex", "codex_app", "codex_cli"].includes(row.application) : row.application === id).at(-1);
300
- 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),
301
- 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)),
302
- 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",
303
- 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" } : {}) });
304
- }
305
- if (action === "models" && !flags.edit) {
306
- if (flags.format === "json") return print(modelPlan);
307
- 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) })),
308
- ...(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 })) : []),
309
- ...(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 }] : []),
310
- ...(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"]]);
311
- }
312
- if (action === "sync") {
313
- 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,
314
- current_setup: clientSetup(client), note: "Model/configuration plan only, not a byte-level file diff. Ownership is rechecked on sync; no App is restarted." };
315
- if (flags.preview) return print(preview);output.write(print(preview) + "\n");await confirm("Write CCDX-owned client settings now?");
316
- 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" });
317
- }
318
- if (["enable", "disable"].includes(action)) {
319
- const enabled = action === "enable", preview = { client: ids.app, access: enabled ? "Enabled" : "Disabled", retained_source: client.source,
320
- retained_models: client.deployments || "Legacy source binding retained", note: "Only gateway access changes; the client program stays open." };
321
- if (flags.preview) return print(preview);output.write(print(preview) + "\n");
322
- await confirm(enabled ? "Enable gateway access with the saved selection?" : "Disable gateway access? Later turns may fail; saved selections are retained.");
323
- const result = await save({ operation: "client_state", id, enabled, client_revision: client.revision });
324
- return print({ client: ids.app, setup: getClient(result, id).setup, saved: true, app_adoption: "Not verified" });
325
- }
326
- const body = clientBody(client);
327
- if (action === "models") {
328
- if (flags.file) {
329
- 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.");
330
- if (!Array.isArray(file.deployments)) throw new Error("Model files require an explicit deployments array; use [] to pause access.");
331
- Object.assign(body, file);if (!body.deployments.length) body.default_model = null;
332
- } else {
333
- const available = [...(modelPlan?.available || [])], selected = Array.isArray(client.deployments) ? client.deployments : modelPlan?.models.map(model => ({ source: model.source, model: model.id })) || [];
334
- 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 });
335
- 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] : []));
336
- 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 }));
337
- body.default_model = client.default_model || modelPlan?.default_model || null;
338
- if (body.deployments.length) {
339
- const defaults = body.deployments.map(item => deploymentModelId(item.source, item.model));
340
- output.write(body.deployments.map((item, index) => `${index + 1} ${item.source} / ${item.model}`).join("\n") + "\n");
341
- const value = (await ask(`Default model number [${Math.max(1, defaults.indexOf(body.default_model) + 1)}]: `)).trim();
342
- if (value && (!/^\d+$/.test(value) || Number(value) < 1 || Number(value) > defaults.length)) throw new Error("Choose a listed default model number.");
343
- body.default_model = defaults[value ? Number(value) - 1 : Math.max(0, defaults.indexOf(body.default_model))];
344
- } else body.default_model = null;
345
- if (id === "claude_app") for (const item of body.deployments) {
346
- const entry = available.find(row => row.source === item.source && row.id === item.model), levels = entry?.capability?.values.reasoning_efforts || [];
347
- if (entry?.effort_control !== "gateway" && item.reasoning_effort === undefined) continue;
348
- output.write(`Reasoning for ${item.source} / ${item.model}: follow-app${levels.length ? ", " + levels.join(", ") : ""}\n`);
349
- const answer = (await ask(`Default when the app omits effort [${item.reasoning_effort || "follow-app"}]: `)).trim();
350
- if (answer === "follow-app") delete item.reasoning_effort;
351
- else if (answer) { if (!levels.includes(answer)) throw new Error("Choose a declared reasoning level or follow-app.");item.reasoning_effort = answer; }
352
- }
353
- }
354
- if (id === "codex" && !flags.file && modelPlan?.image?.models?.length) {
355
- const images = modelPlan.image.models, current = images.findIndex(model => model.id === modelPlan.image.selected_model);
356
- output.write(images.map((model, i) => `${i + 1} ${model.name || model.id} [Image]`).join("\n") + "\n");
357
- const answer = (await ask(`Image model number [${Math.max(1, current + 1)}]: `)).trim();
358
- if (answer && (!/^\d+$/.test(answer) || Number(answer) < 1 || Number(answer) > images.length)) throw new Error("Choose a listed image model number.");
359
- body.image_model = images[answer ? Number(answer) - 1 : Math.max(0, current)].id;
360
- }
361
- 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.");
362
- } else throw new Error("Unsupported client action.");
363
- const memory = id === "codex" ? client.memory_model?.model : null;
364
- const memoryModels = [...(modelPlan?.models || []), ...(modelPlan?.available || []), ...(modelPlan?.unavailable || [])].filter(row => [row.id, row.route_id, row.public_id].includes(memory));
365
- const memoryPairs = new Set(memoryModels.map(row => row.source + "\0" + row.id));
366
- 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);
367
- if (memory && (client.deployments || modelPlan?.models || []).some(memoryMatch) && Array.isArray(body.deployments) && !body.deployments.some(memoryMatch)) {
368
- output.write(`Warning: ${terminalCell(memory)} is an observed memory dependency; memory writing may fail if it is unselected.\n`);
369
- }
370
- const previousModels = client.deployments || modelPlan?.models.map(model => ({ source: model.source, model: model.id })) || [];
371
- const previousKeys = new Set(previousModels.map(item => item.source + "\0" + item.model));
372
- const previousDefault = client.default_model || modelPlan?.models.find(model => model.public_id === modelPlan.default_model)?.route_id || null;
373
- const imageOnly = id === "codex" && body.image_model && body.image_model !== modelPlan?.image?.selected_model
374
- && body.deployments?.length === previousKeys.size && body.deployments.every(item => previousKeys.has(item.source + "\0" + item.model))
375
- && body.default_model === previousDefault && (body.auto_sync !== false) === (client.auto_sync !== false);
376
- const checked = await save({ ...body, operation: "preview_client" });
377
- 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");
378
- if (flags.preview) return "Preview only; no settings changed.";
379
- await confirm(body.enabled ? "Save this client selection?" : "Disable gateway access? Later turns may fail; the client program stays open.");
380
- 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" });
381
- }
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
+ });
382
223
  if (group !== "source") throw new Error("Unknown management command.");
383
224
  if (action === "import") {
384
225
  if (Boolean(flags.file) === Boolean(flags.from)) throw new Error("Use --file FILE or --from cc-switch|magpie.");
@@ -403,11 +403,12 @@
403
403
  <div class="flow-caption"><span id="flow-caption" data-i18n="flow_status_unknown">Status unavailable</span><button id="flow-clear" type="button" data-i18n="flow_show_all" hidden>Show all</button><button id="flow-more" type="button" hidden>More models</button></div>
404
404
  </section>
405
405
  <section id="tool-activity" class="panel dashboard-section" aria-labelledby="tool-title" data-paused="true">
406
- <div class="panel-heading"><h2 id="tool-title" data-i18n="tool_heading">TOOL AND AGENT ACTIVITY</h2><label class="tool-style" for="tool-style"><span data-i18n="tool_style">Style</span><select id="tool-style"><option value="assembly" data-i18n="tool_style_assembly">Assembly line</option><option value="sorter" data-i18n="tool_style_sorter">Dual-lane sorter</option><option value="gantry" data-i18n="tool_style_gantry">Gantry transfer</option><option value="rotary" data-i18n="tool_style_rotary">Indexing table</option><option value="off" data-i18n="tool_style_off">Off</option></select></label></div>
407
- <div id="tool-stage" class="tool-stage" data-style="assembly">
406
+ <div class="panel-heading"><h2 id="tool-title" data-i18n="tool_heading">TOOL AND AGENT ACTIVITY</h2><label class="tool-style" for="tool-style"><span data-i18n="tool_style">Style</span><select id="tool-style"><option value="production" data-i18n="tool_style_production">Production line</option><option value="clock" data-i18n="tool_style_clock">Gear clock</option><option value="assembly" data-i18n="tool_style_assembly">Assembly line</option><option value="sorter" data-i18n="tool_style_sorter">Dual-lane sorter</option><option value="gantry" data-i18n="tool_style_gantry">Gantry transfer</option><option value="rotary" data-i18n="tool_style_rotary">Indexing table</option><option value="off" data-i18n="tool_style_off">Off</option></select></label></div>
407
+ <div id="tool-stage" class="tool-stage" data-style="production">
408
408
  <div class="tool-visual"><div class="tool-orbit"><canvas id="tool-canvas" role="img" data-i18n-label="tool_heading" aria-label="Tool and agent activity"></canvas></div><p class="tool-narration"><span id="tool-state" role="status" aria-live="polite" data-i18n="flow_status_unknown">Waiting for a fresh status</span><span id="tool-cursor" aria-hidden="true" hidden> …</span></p></div>
409
- <div class="tool-content"><p id="tool-context" class="tool-context" hidden></p><div id="tool-list"></div><p id="tool-more" class="hint" hidden></p><details id="tool-details" class="tool-details tool-technical" hidden><summary data-i18n="tool_details">Call details</summary><div class="table-wrap"><table class="dense-table"><thead><tr><th data-i18n="client">App</th><th data-i18n="source">Source</th><th data-i18n="model">Model</th><th data-i18n="tool_name">Tool</th><th data-i18n="outcome">Result</th></tr></thead><tbody id="tool-technical"></tbody></table></div></details></div>
409
+ <div class="tool-content"><p id="tool-context" class="tool-context" hidden></p><div id="tool-list"></div><p id="tool-more" class="hint" hidden></p></div>
410
410
  </div>
411
+ <details id="tool-details" class="tool-details tool-technical" hidden><summary data-i18n="tool_details">Call details</summary><div class="table-wrap"><table class="dense-table"><thead><tr><th data-i18n="client">App</th><th data-i18n="source">Source</th><th data-i18n="model">Model</th><th data-i18n="tool_name">Tool</th><th data-i18n="outcome">Result</th></tr></thead><tbody id="tool-technical"></tbody></table></div></details>
411
412
  </section>
412
413
  <details id="flow-active" class="panel dashboard-section"><summary id="flow-active-title" data-i18n="flow_active_requests">Active requests</summary><div class="table-wrap"><table><thead><tr><th data-i18n="client">App</th><th data-i18n="source">Source</th><th data-i18n="model">Model</th><th data-i18n="state">State</th><th data-i18n="flow_elapsed">Elapsed</th><th data-i18n="attempts">Attempts</th></tr></thead><tbody id="flow-active-body"></tbody></table></div></details>
413
414
  <details class="panel dashboard-section" id="source-requests" open>
@@ -418,7 +419,7 @@
418
419
  </details>
419
420
  <details class="panel dashboard-section" id="request-context" open>
420
421
  <summary data-i18n="recent_request_context">RECENT REQUESTS</summary>
421
- <div class="table-wrap"><table class="recent-requests-table dense-table"><thead><tr><th scope="col" data-i18n="time">Time</th><th scope="col" data-i18n="client">App</th><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="outcome">RESULT</th><th scope="col" class="recent-request-duration" data-i18n="request_total_time">Total time</th><th scope="col" data-i18n="tools_details">Details</th></tr></thead><tbody id="context-body"><tr><td colspan="6" data-i18n="no_observed_request_metadata">No request records yet.</td></tr></tbody></table></div>
422
+ <div class="table-wrap"><table class="recent-requests-table dense-table"><thead><tr><th scope="col" class="recent-request-time" data-i18n="time">Time</th><th scope="col" class="recent-request-duration" data-i18n="request_total_time">Total time</th><th scope="col" class="recent-request-app" data-i18n="client">App</th><th scope="col" class="recent-request-model" data-i18n="model">MODEL</th><th scope="col" class="recent-request-result" data-i18n="outcome">RESULT</th><th scope="col" data-i18n="tools_details">Details</th></tr></thead><tbody id="context-body"><tr><td colspan="6" data-i18n="no_observed_request_metadata">No request records yet.</td></tr></tbody></table></div>
422
423
  <details class="tool-details"><summary data-i18n="record_scope">Record scope</summary><p id="context-note" class="table-note">—</p><p class="hint" data-i18n="recent_upstream_request_metadata_not_exact_live_session_occupanc">No prompts or images are stored. — means unavailable data.</p><p class="hint" data-i18n="http_2xx_model_completed">HTTP status and model outcome are recorded separately.</p></details>
423
424
  </details>
424
425
  <details class="lower" id="recent-failures" open>
@@ -6,6 +6,8 @@
6
6
  "tool_style_sorter": ["Dual-lane sorter","双轨分拣"],
7
7
  "tool_style_gantry": ["Gantry transfer","龙门移载"],
8
8
  "tool_style_rotary": ["Indexing table","分度转盘"],
9
+ "tool_style_production": ["Production line", "工业生产线"],
10
+ "tool_style_clock": ["Gear clock", "齿轮钟表"],
9
11
  "tool_style_assembly": ["Assembly line","装配线"],
10
12
  "refresh_models": ["Refresh models", "刷新模型"],
11
13
  "routing_reason": ["Model routing", "选模依据"],
@@ -397,21 +397,21 @@
397
397
  const signature = JSON.stringify(contextRequests);
398
398
  if (signature === contextSignature) return;
399
399
  contextSignature = signature;
400
- const openDetails = [...(body.querySelectorAll?.("details[open]") || [])].filter(details => details.dataset.disclosureClosing !== "true");
401
- const expanded = new Set(openDetails.map(details => details.getAttribute("data-request-key")));
400
+ const openDetails = [...(body.querySelectorAll?.(".request-disclosure[aria-expanded=true]") || [])];
401
+ const expanded = new Set(openDetails.map(button => button.getAttribute("data-request-key")));
402
402
  const viewport = document.defaultView;
403
- const focused = document.activeElement?.closest?.(".request-details > summary");
403
+ const focused = document.activeElement?.closest?.(".request-disclosure");
404
404
  const keepFocus = Boolean(focused && body.contains?.(focused));
405
405
  const topInView = summary => {
406
406
  if (!viewport?.scrollY || !summary) return null;
407
407
  const box = summary.getBoundingClientRect();return box.bottom > 0 && box.top < viewport.innerHeight ? box.top : null;
408
408
  };
409
409
  let reading = keepFocus ? focused : null;
410
- if (!reading && viewport?.scrollY) reading = openDetails.map(details => details.querySelector("summary")).find(summary => topInView(summary) !== null);
411
- const readingKey = reading?.parentElement?.getAttribute("data-request-key"), readingTop = topInView(reading);
410
+ if (!reading && viewport?.scrollY) reading = openDetails.find(button => topInView(button) !== null);
411
+ const readingKey = reading?.getAttribute("data-request-key"), readingTop = topInView(reading);
412
412
  let restoredSummary;
413
413
  body.replaceChildren();
414
- for (const request of contextRequests) {
414
+ for (const [rowIndex, request] of contextRequests.entries()) {
415
415
  const context = request.context || {};
416
416
  const outcome = ["completed", "incomplete", "failed", "cancelled"].includes(request.outcome)
417
417
  ? request.outcome[0].toUpperCase() + request.outcome.slice(1) : "unknown";
@@ -420,22 +420,37 @@
420
420
  const at = Date.parse(request.at);
421
421
  const totalMs = request.timings_ms?.finished;
422
422
  const app = ["codex", "codex_app", "codex_cli", "claude", "claude_app", "claude_code", "gemini_app", "api"].includes(request.application) ? request.application : "api";
423
- const row = tableRow([Number.isFinite(at) ? time(at) : "—", "",
424
- String(request.model || "unknown").slice(0, 80), outcome, Number.isFinite(totalMs) ? requestTime(totalMs) : "—", ""], { labels: [3] });
425
- localize(row.children[1], `flow_app_${app}`);
426
- row.children[4].className = "recent-request-duration";
423
+ const row = tableRow([Number.isFinite(at) ? time(at) : "—", Number.isFinite(totalMs) ? requestTime(totalMs) : "—", "",
424
+ String(request.model || "unknown").slice(0, 80), outcome, ""], { labels: [4] });
425
+ localize(row.children[2], `flow_app_${app}`);
426
+ ["time", "duration", "app", "model", "result"].forEach((name, index) => { row.children[index].className = "recent-request-" + name; });
427
427
  const wireFailure = Number.isInteger(request.http_status) && request.http_status >= 400;
428
428
  if (request.rejection_reason) {
429
- if (globalThis.ccdxIcons) globalThis.ccdxIcons.set(row.children[3], "request_access_blocked", "unavailable");else localize(row.children[3], "request_access_blocked");
430
- } else if (globalThis.ccdxIcons) globalThis.ccdxIcons.set(row.children[3], wireFailure ? "request_http_failure" : outcome.toLowerCase(),
429
+ if (globalThis.ccdxIcons) globalThis.ccdxIcons.set(row.children[4], "request_access_blocked", "unavailable");else localize(row.children[4], "request_access_blocked");
430
+ } else if (globalThis.ccdxIcons) globalThis.ccdxIcons.set(row.children[4], wireFailure ? "request_http_failure" : outcome.toLowerCase(),
431
431
  wireFailure ? "warning" : globalThis.ccdxIcons.kind(outcome.toLowerCase()), wireFailure ? { status: request.http_status } : {});
432
- else if (wireFailure) localize(row.children[3], "request_http_failure", { status: request.http_status });
433
- const details = document.createElement("details"), summary = document.createElement("summary"), fields = document.createElement("dl");
432
+ else if (wireFailure) localize(row.children[4], "request_http_failure", { status: request.http_status });
433
+ const disclosure = document.createElement("button"), detailRow = document.createElement("tr"),
434
+ cell = document.createElement("td"), fields = document.createElement("dl");
434
435
  const key = String(request.request_id || `${request.at || ""}/${request.provider || ""}/${request.model || ""}`).slice(0, 256);
435
- details.setAttribute?.("data-request-key", key);details.open = expanded.has(key);
436
- if (key === readingKey) restoredSummary = summary;
437
- details.className = "request-details";fields.className = "failure-detail";
438
- localize(summary, "tools_details");details.append(summary, fields);
436
+ const id = "request-detail-" + rowIndex;
437
+ disclosure.type = "button";
438
+ disclosure.className = "request-disclosure";
439
+ disclosure.setAttribute("data-request-key", key);
440
+ disclosure.setAttribute("aria-controls", id);
441
+ detailRow.className = "request-detail-row";
442
+ detailRow.id = id;
443
+ cell.colSpan = 6;
444
+ cell.className = "request-detail-cell";
445
+ fields.className = "request-detail-fields";
446
+ localize(disclosure, "tools_details");
447
+ function showDetails(open) {
448
+ disclosure.setAttribute("aria-expanded", String(open));
449
+ detailRow.hidden = !open;
450
+ }
451
+ showDetails(expanded.has(key));
452
+ disclosure.addEventListener("click", () => showDetails(detailRow.hidden));
453
+ if (key === readingKey) restoredSummary = disclosure;
439
454
  const queue = context.body_queue;
440
455
  const queueResult = queue?.outcome === "admitted" ? "body_queue_admitted" : queue?.outcome === "timed_out" ? "body_queue_timed_out"
441
456
  : queue?.outcome === "aborted" ? "body_queue_aborted" : "body_queue_result_unknown";
@@ -471,9 +486,12 @@
471
486
  ...(context.client_tool_errors_received > 0 ? [["client_tool_errors_received", number(context.client_tool_errors_received)]] : [])]) {
472
487
  const term = document.createElement("dt"), detail = document.createElement("dd");localize(term, key);
473
488
  if (value?.key) localize(detail, value.key, value.values);else detail.textContent = value;
474
- fields.append(term, detail);
489
+ const pair = document.createElement("div");
490
+ if (["request_id", "client_request_id", "body_queue_wait", "upstream_transport_error", "requested_model"].includes(key)) pair.className = "request-detail-wide";
491
+ pair.append(term, detail);fields.append(pair);
475
492
  }
476
- row.children[5].append(details);body.append(row);
493
+ cell.append(fields);detailRow.append(cell);
494
+ row.children[5].append(disclosure);body.append(row, detailRow);
477
495
  }
478
496
  if (restoredSummary) {
479
497
  if (keepFocus) restoredSummary.focus({ preventScroll: true });