codex-copilot-dx 1.2.0 → 1.2.2

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.
@@ -1,35 +1,58 @@
1
1
  (() => {
2
- const key = "ccdx.dashboard.theme";
3
- let theme = "dark";
2
+ const key = "ccdx.dashboard.theme", paletteKey = "ccdx.dashboard.palette";
3
+ const valid = value => value === "green" || value === "klein";
4
+ let theme = "dark", palette = "green", saved = true;
4
5
  try {
5
6
  if (localStorage.getItem(key) === "light") theme = "light";
6
- } catch { /* Private browsing may disable storage. */ }
7
+ const value = localStorage.getItem(paletteKey);if (valid(value)) palette = value;
8
+ } catch { saved = false; }
9
+ const label = (node, message) => {
10
+ if (!node) return;
11
+ if (globalThis.ccdxLanguage) globalThis.ccdxLanguage.set(node, message);
12
+ else node.textContent = message;
13
+ };
14
+ function sync() {
15
+ const select = document.getElementById("web-color-theme");if (select) select.value = palette;
16
+ label(document.getElementById("web-color-note"), saved ? "theme_saved_browser" : "theme_tab_only");
17
+ }
7
18
  const applyTheme = () => {
8
19
  document.documentElement.dataset.theme = theme;
9
- const color = theme === "dark" ? "#a6f5a8" : "#176b3a";
20
+ document.documentElement.dataset.palette = palette;
21
+ const color = palette === "klein" ? theme === "dark" ? "#789aff" : "#002fa7" : theme === "dark" ? "#a6f5a8" : "#176b3a";
10
22
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g fill="none" stroke="${color}" stroke-width="3" stroke-linecap="round"><ellipse cx="32" cy="32" rx="26" ry="10"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(60 32 32)"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(120 32 32)"/></g><circle cx="32" cy="32" r="4.5" fill="${color}"/></svg>`;
11
23
  document.getElementById("favicon").href = `data:image/svg+xml,${encodeURIComponent(svg)}`;
12
24
  };
13
25
  applyTheme();
14
-
26
+ function persist() {
27
+ try { localStorage.setItem(key, theme);localStorage.setItem(paletteKey, palette);saved = true; }
28
+ catch { saved = false; }
29
+ sync();
30
+ }
15
31
  document.addEventListener("DOMContentLoaded", () => {
16
32
  const button = document.getElementById("theme-toggle");
17
33
  const updateLabel = () => {
18
- const label = `Switch to ${theme === "dark" ? "light" : "dark"} mode`;
34
+ const value = `Switch to ${theme === "dark" ? "light" : "dark"} mode`;
19
35
  if (globalThis.ccdxLanguage) {
20
- globalThis.ccdxLanguage.set(button, label, {}, "aria-label");
21
- globalThis.ccdxLanguage.set(button, label, {}, "title");
22
- } else {
23
- button.setAttribute("aria-label", label);
24
- button.title = label;
25
- }
36
+ globalThis.ccdxLanguage.set(button, value, {}, "aria-label");
37
+ globalThis.ccdxLanguage.set(button, value, {}, "title");
38
+ } else { button.setAttribute("aria-label", value);button.title = value; }
26
39
  };
27
- updateLabel();
40
+ updateLabel();sync();
28
41
  button.addEventListener("click", () => {
29
- theme = theme === "dark" ? "light" : "dark";
30
- applyTheme();
31
- try { localStorage.setItem(key, theme); } catch { /* Keep the current selection. */ }
42
+ theme = theme === "dark" ? "light" : "dark";applyTheme();
43
+ persist();
32
44
  updateLabel();
33
45
  });
46
+ document.getElementById("web-color-theme")?.addEventListener("change", event => {
47
+ if (!valid(event.target.value)) return;
48
+ palette = event.target.value;applyTheme();
49
+ persist();
50
+ });
51
+ globalThis.addEventListener?.("storage", event => {
52
+ if (event.key !== paletteKey && event.key !== key) return;
53
+ if (event.key === paletteKey) palette = valid(event.newValue) ? event.newValue : "green";
54
+ else theme = event.newValue === "light" ? "light" : "dark";
55
+ applyTheme();updateLabel();sync();
56
+ });
34
57
  });
35
58
  })();
@@ -189,3 +189,74 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
189
189
  #process-queues { overflow-wrap: anywhere; font-size: 11px; }
190
190
  @media (max-width: 900px) { .shell { grid-template-columns: 170px minmax(0, 1fr); column-gap: 20px; padding: 0 20px; } .topbar .brand { display: none; } .topbar { justify-content: flex-end; } .setting-row { grid-template-columns: minmax(0, 1fr) 44px; } .setting-row .hint { grid-column: 1 / -1; } .overview { grid-template-columns: 1fr; } }
191
191
  @media (max-width: 640px) { .shell { display: block; padding: 0 16px; } .sidebar { position: static; height: auto; padding: 20px 0 14px; border-right: 0; border-bottom: 1px solid var(--border); } .sidebar-brand { font-size: 20px; width: fit-content; } .sidebar-brand .brand-caption { margin-top: 4px; } .sidebar nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; margin-top: 16px; } .sidebar nav a { padding: 9px 10px; font-size: 12px; border-left: 0; border-bottom: 2px solid transparent; } .sidebar nav a[aria-current="page"] { border-bottom-color: var(--accent); } .nav-group, .sidebar-bottom { display: none; } .topbar { min-height: 62px; justify-content: flex-start; } .topbar-actions { justify-content: flex-start; gap: 9px; } .intro { padding: 24px 0 18px; } .panel, .lower { padding: 17px; } .section-actions > label { width: 100%; } .stats { gap: 12px; } }
192
+
193
+ /* Keep forms aligned with the existing dashboard controls. */
194
+ .dashboard-section + .client-overview { margin-top: 10px; }
195
+ .sidebar nav .nav-child { padding-left: 28px; }
196
+ .section-actions > label { min-width: 0; max-width: 100%; }
197
+ .section-actions select { min-width: 180px; width: 100%; max-width: 320px; }
198
+ .section-actions input:not([type="checkbox"]), .section-actions select, .section-actions button,
199
+ .analytics-controls select { box-sizing: border-box; height: 36px; min-height: 36px; line-height: normal; }
200
+ .section-actions button { padding-top: 0; padding-bottom: 0; }
201
+ @media (max-width: 640px) {
202
+ .section-actions > label { flex: 1 1 180px; }
203
+ .section-actions select { max-width: 100%; }
204
+ }
205
+
206
+ /* Independent color palettes; green remains the unchanged default. */
207
+ :root[data-palette="klein"][data-theme="light"] {
208
+ color-scheme: light;
209
+ --page:#F3F6FF; --surface:#ffffff; --text:#19354F; --strong:#102E4C;
210
+ --muted:#4b607a; --badge:#4b607a; --subtle:#4f6681; --quiet:#5d718b; --footer:#5d718b;
211
+ --border:#C5CFEA; --top-border:#B8C6E6; --accent:#002FA7; --accent-soft:#002FA7; --heading:#002FA7;
212
+ --button-border:#819AD4; --button-bg:#EDF2FF; --button-fg:#002FA7; --button-hover:#DAE4FF;
213
+ --selected-bg:#E3EAFF; --option-hover:#EBF0FF; --table-text:#24405E; --preview:#586f8b;
214
+ --ansi-white:#0752A6; --ansi-159:#002FA7; --ansi-123:#1678FF; --ansi-87:#2493FF;
215
+ --ansi-51:#47B6FF; --ansi-45:#438FFF; --ansi-39:#547AFF; --ansi-33:#5D6CDB;
216
+ --bad:#a33625; --failed:#a33625; --incomplete:#835600;
217
+ }
218
+ :root[data-palette="klein"]:not([data-theme="light"]) {
219
+ color-scheme:dark;
220
+ --page:#081625; --surface:#0F2236; --text:#dde7f4; --strong:#eff6ff;
221
+ --muted:#9caec6; --badge:#adbed4; --subtle:#91a8c5; --quiet:#829bb9; --footer:#829bb9;
222
+ --border:#244663; --top-border:#244663; --accent:#789AFF; --accent-soft:#89A7FF; --heading:#93ADFF;
223
+ --button-border:#526CA9; --button-bg:#1B2B4C; --button-fg:#A5BBFF; --button-hover:#273D68;
224
+ --selected-bg:#1C315C; --option-hover:#14334F; --table-text:#d1dfef; --preview:#8da7c9;
225
+ --ansi-white:#edf5ff; --ansi-159:#acd6ff; --ansi-123:#91c7ff; --ansi-87:#7bb9f4;
226
+ --ansi-51:#68a9e5; --ansi-45:#6095d1; --ansi-39:#678ac4; --ansi-33:#707eb1;
227
+ --bad:#ff947e; --failed:#ff9f91; --incomplete:#e3c77c;
228
+ }
229
+
230
+ .appearance-row { display:grid; grid-template-columns:minmax(0,1fr) 200px; align-items:center; gap:18px; margin-top:20px; }
231
+ .appearance-label { min-width:0; }
232
+ .appearance-label label { display:block; font-size:13px; color:var(--text); line-height:1.65; }
233
+ .appearance-label p { margin:4px 0 0; font-size:12px; color:var(--subtle); line-height:1.7; }
234
+ .appearance-select { width:100%; max-width:100%; min-width:0; height:36px; box-sizing:border-box; border-radius:2px; padding:0 10px; font-size:12px; }
235
+ .appearance-note { color:var(--subtle); margin:17px 0 0; font-size:12px; line-height:1.7; }
236
+ .appearance-animation { margin-top:22px; border-top:1px solid var(--border); padding-top:18px; }
237
+ .appearance-animation > summary { color:var(--heading); font-size:12px; font-weight:700; }
238
+ .terminal-sample { --sample-bg:#0F151D; --sample-text:#DFE7F2; --sample-muted:#A2B0C2; --sample-line:#304054; --sample-logo:#A6F5A8; --sample-table:#DFE7F2; --sample-motion:#84E99E; padding:16px; margin-top:20px; border:1px solid var(--sample-line); border-radius:2px; background:var(--sample-bg); color:var(--sample-text); }
239
+ .terminal-sample[data-terminal-palette="klein"] { --sample-logo:#4C9FFF; --sample-table:#4C9FFF; --sample-motion:#4C9FFF; }
240
+ .terminal-caption { display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; color:var(--sample-muted); font-size:11px; line-height:1.6; margin-bottom:16px; }
241
+ .terminal-brand { display:flex; align-items:center; flex-wrap:wrap; gap:14px; margin-bottom:15px; }
242
+ .terminal-brand strong { color:var(--sample-text); display:block; font-size:12px; font-weight:500; line-height:1.7; }
243
+ .terminal-brand div>span { display:block; color:var(--sample-muted); font-size:11px; line-height:1.7; }
244
+ .terminal-sample pre { font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace; padding:0; margin:0; background:transparent; border:0; border-radius:0; letter-spacing:0; }
245
+ .terminal-sample .terminal-logo { color:var(--sample-logo); font-size:12px; line-height:1.15; white-space:pre; }
246
+ .terminal-sample .terminal-table { color:var(--sample-table); font-size:11px; line-height:1.45; white-space:pre; }
247
+ .terminal-sample .terminal-notices { margin-top:10px; font-size:11px; line-height:1.6; white-space:pre-wrap; color:var(--sample-muted); }
248
+ .terminal-sample .terminal-motion { color:var(--sample-text); font-size:11px; line-height:1.6; white-space:pre-wrap; }
249
+ #terminal-sample-frame { color:var(--sample-motion); }
250
+ .terminal-compact { display:none; }
251
+ @media(max-width:700px) { .appearance-row { grid-template-columns:minmax(0,1fr) 180px; gap:12px; } }
252
+ @media(max-width:480px) { .appearance-row { grid-template-columns:minmax(0,1fr) auto; gap:12px; } .appearance-row:has(select) { grid-template-columns:minmax(0,1fr); } .appearance-select { width:100%; } .terminal-wide { display:none; } .terminal-compact { display:block; } .terminal-sample { padding:12px 9px; } .terminal-sample .terminal-table { font-size:11px; } }
253
+ @media(pointer:coarse) { .appearance-select { min-height:44px; font-size:16px; } }
254
+ .model-check-details { margin:14px 0; color:var(--text); }
255
+ .model-check-details > summary { color:var(--heading); font-size:12px; }
256
+ #models-note p { margin:4px 0; }
257
+
258
+ :root:not([data-theme="light"]) #animation-settings { --ansi-white:#f5fff5;--ansi-159:#9af5e9;--ansi-123:#75e4d9;--ansi-87:#5ad0d4;--ansi-51:#42b9d8;--ansi-45:#3ca2d0;--ansi-39:#4389c2;--ansi-33:#4775b2; }
259
+ :root:not([data-theme="light"]) #animation-settings[data-terminal-palette="klein"] { --ansi-white:#789aff;--ansi-159:#789aff;--ansi-123:#789aff;--ansi-87:#789aff;--ansi-51:#789aff;--ansi-45:#789aff;--ansi-39:#789aff;--ansi-33:#789aff; }
260
+
261
+ :root[data-theme="light"] #animation-settings { --ansi-white:#234231;--ansi-159:#116b64;--ansi-123:#0d7771;--ansi-87:#116b75;--ansi-51:#14697e;--ansi-45:#1a6183;--ansi-39:#265f8d;--ansi-33:#365a8d; }
262
+ :root[data-theme="light"] #animation-settings[data-terminal-palette="klein"] { --ansi-white:#002fa7;--ansi-159:#002fa7;--ansi-123:#002fa7;--ansi-87:#002fa7;--ansi-51:#002fa7;--ansi-45:#002fa7;--ansi-39:#002fa7;--ansi-33:#002fa7; }
@@ -340,7 +340,9 @@ async function readDashboard(url, { signal, timeout = 15000, source } = {}) {
340
340
  const response = await fetch(url, { cache: "no-store", headers: { "X-CCDX-Dashboard": "1", Accept: "application/json" },
341
341
  signal: AbortSignal.any([signal, AbortSignal.timeout(timeout)]) });
342
342
  const data = await response.json();
343
- if (!response.ok || (source && !(Array.isArray(source) ? source : [source]).includes(data.source))) throw new Error(data.error || `HTTP ${response.status}`);
343
+ if (!response.ok || (source && !(Array.isArray(source) ? source : [source]).includes(data.source))) {
344
+ throw Object.assign(new Error(data.error || `HTTP ${response.status}`), { diagnostic: data.diagnostic });
345
+ }
344
346
  return data;
345
347
  }
346
348
 
@@ -410,11 +412,35 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
410
412
  state: state => {
411
413
  element("refresh-models").disabled = Boolean(state.pending);
412
414
  text("models-state", state.pending ? "checking_live" : state.error ? "live_lookup_failed" : state.value?.source === "catalog" ? "catalog_snapshot" : "live_snapshot");
415
+ element("model-check-details").hidden = !state.error;
413
416
  if (state.error) {
414
417
  const message = String(state.error.message || state.error).slice(0, 240);
415
418
  const httpError = /^Live model lookup failed \(HTTP (\d{3})\)\. Run ccdx models for details\.$/.exec(message);
416
419
  if (httpError) text("models-note", "live_model_lookup_failed_http_status_run_ccdx_models_for_details", { status: httpError[1] });
417
420
  else text("models-note", message);
421
+ const sourceReason = /^Model catalog unavailable \/ (m365_[a-z0-9_]+)$/.exec(message);
422
+ const reason = httpError ? phrase("live_model_lookup_failed_http_status_run_ccdx_models_for_details", { status: httpError[1] })
423
+ : sourceReason ? phrase("source_catalog_unavailable", { code: sourceReason[1] }) : phrase(message);
424
+ const source = providerEntries.find(entry => entry.id === selectedProvider)?.name || selectedProvider;
425
+ const previous = modelSnapshots.get(selectedProvider);
426
+ element("models-note").replaceChildren();
427
+ const summary = document.createElement("span"), kept = document.createElement("span");
428
+ localize(summary, "source_check_failed", { source });
429
+ localize(kept, previous?.checked_at ? "source_check_previous" : "source_check_none", { time: previous?.checked_at ? new Date(previous.checked_at).toLocaleTimeString() : "" });
430
+ element("models-note").append(summary, document.createElement("br"), kept);
431
+ const fields = element("model-check-fields");fields.replaceChildren();
432
+ const diagnostic = state.error.diagnostic || {};
433
+ for (const [key, value] of [["source", source], ["source_check_time", diagnostic.checked_at], ["source_check_reason", reason], ["http_status", diagnostic.http_status]]) {
434
+ if (value === null || value === undefined || value === "") continue;
435
+ const term = document.createElement("dt"), detail = document.createElement("dd");localize(term, key);
436
+ if (value?.key) localize(detail, value.key, value.values);else detail.textContent = String(value).slice(0, 300);
437
+ fields.append(term, detail);
438
+ }
439
+ if (Number.isFinite(diagnostic.retry_after_ms) && diagnostic.retry_after_ms > 0) {
440
+ const term = document.createElement("dt"), detail = document.createElement("dd");localize(term, "retry");
441
+ const checked = Date.parse(diagnostic.checked_at);
442
+ if (Number.isFinite(checked)) { localize(detail, "source_retry_time", { time: new Date(checked + diagnostic.retry_after_ms).toLocaleTimeString() });fields.append(term, detail); }
443
+ }
418
444
  }
419
445
  if (state.error && !modelSnapshots.has(selectedProvider)) emptyTable("live-models-body", 6, "no_catalog_available");
420
446
  for (const node of timestamps.get("models")) refreshTime(node, state);
@@ -249,8 +249,8 @@ export async function handleDashboardApi(req, res, pathname, {
249
249
 
250
250
  if (pathname === MODELS_PATH && req.method === "GET") {
251
251
  const abort = createRequestAbort(req, res);
252
+ const provider = new URL(req.url, "http://localhost").searchParams.get("provider") || "";
252
253
  try {
253
- const provider = new URL(req.url, "http://localhost").searchParams.get("provider") || "";
254
254
  if (provider && (!isProviderId(provider) || !dashboardProviders(providerStateFn, authStatusFn).some(entry => entry.id === provider))) {
255
255
  sendJson(res, 400, { error: "Select a registered provider" });return;
256
256
  }
@@ -273,13 +273,18 @@ export async function handleDashboardApi(req, res, pathname, {
273
273
  preview: model.preview === true,
274
274
  selectable: model.selectable !== false,
275
275
  clients: Array.isArray(model.clients) ? model.clients.filter(value => typeof value === "string").slice(0, 8).map(value => safeText(value, 40)) : [],
276
+ auto_review_efforts: Array.isArray(model.auto_review_efforts) ? model.auto_review_efforts.slice(0, 16).map(value => safeText(value, 16)) : [],
276
277
  reasoning_efforts: Array.isArray(model.reasoning_efforts) ? model.reasoning_efforts.slice(0, 16).map(value => safeText(value, 16)) : null,
277
278
  state: ["listed", "restricted", "hidden"].includes(model.state) ? model.state : "listed",
278
279
  context_window: finite(model.context_window),
279
280
  })),
280
281
  });
281
282
  } catch (error) {
282
- if (!res.destroyed && !res.writableEnded) sendJson(res, error.statusCode || 502, { error: /^m365_[a-z0-9_]+$/.test(error.code || "") ? `Model catalog unavailable / ${error.code}` : liveModelError(error) });
283
+ const message = /^m365_[a-z0-9_]+$/.test(error.code || "") ? `Model catalog unavailable / ${error.code}` : liveModelError(error);
284
+ if (!res.destroyed && !res.writableEnded) sendJson(res, error.statusCode || 502, { error: message,
285
+ diagnostic: { provider: provider || null, checked_at: new Date().toISOString(), message,
286
+ http_status: Number(/\bHTTP (\d{3})\b/.exec(message)?.[1]) || finite(error.statusCode),
287
+ retry_after_ms: finite(error.retryAfterMs) } });
283
288
  } finally { abort.cleanup(); }
284
289
  return;
285
290
  }
@@ -1,5 +1,7 @@
1
1
  import { spawn, execFileSync } from "node:child_process";
2
2
  import fs from "node:fs";
3
+ import os from "node:os";
4
+ import { downloadRelease, protectInstallation, verifyPackageRuntime, writePrivateLaunchers, createNpmReleaseFetch } from "./release-install.mjs";
3
5
  import path from "node:path";
4
6
  import { fileURLToPath } from "node:url";
5
7
  import { createInterface } from "node:readline/promises";
@@ -10,7 +12,7 @@ import { readBoundedFileSync } from "./bounded-file.mjs";
10
12
  const PACKAGE_NAME = "codex-copilot-dx";
11
13
  const UPDATE_SPECS = {
12
14
  npm: `${PACKAGE_NAME}@latest`,
13
- github: "github:DaleXiao/codex-copilot-dx",
15
+ github: "https://github.com/DaleXiao/codex-copilot-dx/releases/download",
14
16
  };
15
17
 
16
18
  function npmLaunch(args, { platform, env }) {
@@ -75,7 +77,7 @@ export function inspectNpmDownloadPolicy({ env = process.env, platform = process
75
77
  return result;
76
78
  }
77
79
 
78
- export function globalUpdateCommand(source, { platform = process.platform, releaseTag, allowRemote = false } = {}) {
80
+ export function globalUpdateCommand(source, { platform = process.platform, releaseTag, releaseFile, allowRemote = false } = {}) {
79
81
  if (typeof allowRemote !== "boolean") throw new Error("Remote download permission must be a boolean");
80
82
  const normalized = normalizeUpdateSource(source);
81
83
  if (!normalized) throw new Error(`Choose npm or github. Received: ${source}`);
@@ -83,7 +85,9 @@ export function globalUpdateCommand(source, { platform = process.platform, relea
83
85
  if (allowRemote) args.push("--allow-remote=all");
84
86
  if (normalized === "github") {
85
87
  if (!githubReleaseVersion(releaseTag)) throw new Error("A valid stable GitHub release tag is required");
86
- args.push("--allow-git=all", `${UPDATE_SPECS.github}#${releaseTag}`);
88
+ const version = githubReleaseVersion(releaseTag), name = `codex-copilot-dx-${version}.tgz`;
89
+ if (releaseFile !== undefined && releaseFile !== `./${name}`) throw new Error("Invalid verified release filename");
90
+ args.push(releaseFile || `${UPDATE_SPECS.github}/v${version}/${name}`);
87
91
  } else {
88
92
  args.push(UPDATE_SPECS[normalized]);
89
93
  }
@@ -137,6 +141,9 @@ export async function runPackageUpdateCommand({
137
141
  inspectPolicyFn = inspectNpmDownloadPolicy,
138
142
  verifyInstalledFn = verifyInstalledPackage,
139
143
  repairCommandFn,
144
+ downloadReleaseFn = downloadRelease,
145
+ protectInstallationFn = protectInstallation,
146
+ verifyRuntimeFn = verifyPackageRuntime,
140
147
  } = {}) {
141
148
  if (typeof allowRemote !== "boolean") throw new Error("Remote download permission must be a boolean");
142
149
  let selectedSource = normalizeUpdateSource(source);
@@ -172,6 +179,14 @@ export async function runPackageUpdateCommand({
172
179
  }
173
180
  }
174
181
 
182
+ const environment = inspectEnvironmentFn({ env, platform });
183
+ if (selectedSource === "github" && fetchImpl === globalThis.fetch) {
184
+ let npmCli;
185
+ try {
186
+ npmCli = platform === "win32" ? path.win32.join(path.win32.dirname(environment.npm), "node_modules", "npm", "bin", "npm-cli.js") : fs.realpathSync(environment.npm);
187
+ } catch { throw new Error("Cannot locate npm for verified Release downloads. Use an approved local package or the platform installer."); }
188
+ fetchImpl = createNpmReleaseFetch(npmCli, { env });
189
+ }
175
190
  let release;
176
191
  if (selectedSource === "github") {
177
192
  output.write("Checking the latest stable GitHub release...\n");
@@ -180,21 +195,33 @@ export async function runPackageUpdateCommand({
180
195
  const policy = inspectPolicyFn({ env, platform });
181
196
  if (allowRemote && policy.supported === null) throw new Error("Could not verify npm's remote-download option; no installation was started. Check npm --version and npm config get allow-remote.");
182
197
  const permitRemote = allowRemote && policy.supported === true;
183
- const update = globalUpdateCommand(selectedSource, { platform, releaseTag: release?.tagName, allowRemote: permitRemote });
198
+ let directory, artifact;
199
+ if (release) {
200
+ directory = fs.mkdtempSync(path.join(os.tmpdir(), "ccdx-update-"));
201
+ try { artifact = await downloadReleaseFn(release.tagName, { fetchImpl, directory }); }
202
+ catch (error) { fs.rmSync(directory, { recursive: true, force: true });throw error; }
203
+ output.write("Release package verified; Git is not required. Dependencies use the configured npm registry.\n");
204
+ }
205
+ try {
206
+ const update = globalUpdateCommand(selectedSource, { platform, releaseTag: release?.tagName, releaseFile: artifact ? `./${artifact.name}` : undefined, allowRemote: permitRemote });
184
207
  const sourceLabel = selectedSource === "npm" ? "npm registry" : `GitHub release ${release.tagName}`;
185
208
  output.write(`Updating ${PACKAGE_NAME} from ${sourceLabel}...\n`);
186
209
  if (policy.allowRemote) output.write(`npm ${terminalCell(policy.version)}: saved allow-remote=${policy.allowRemote}${policy.registryOrigin ? `; registry ${terminalCell(policy.registryOrigin)}` : ""}.\n`);
187
210
  if (permitRemote) output.write("Explicit permission for this update only: npm may download URL dependencies throughout the selected package's dependency tree. Registry and persistent npm settings are unchanged.\n");
188
211
  else if (allowRemote) output.write("This npm does not expose the remote-download restriction; no unsupported permission flag was added.\n");
189
- const environment = inspectEnvironmentFn({ env, platform });
190
212
  if (environment?.state === "different") {
191
213
  output.write(`Warning: npm targets ${terminalCell(environment.target)}, not the running package at ${terminalCell(environment.package_root)}. Existing PATH and prefix choices were preserved.\n`);
192
214
  }
193
- // npm.cmd needs cmd.exe. Only fixed install arguments and a validated stable
194
- // release tag enter this command line; no user-supplied command is evaluated.
215
+ // The verified tarball basename is fixed and safe for cmd.exe. Its directory
216
+ // is passed as cwd, never interpolated into the Windows command string.
195
217
  const launch = npmLaunch(update.args, { platform, env });
218
+ const brokerRequired = Boolean(environment?.target && fs.existsSync(path.join(environment.target, "node_modules", "@azure", "msal-node-runtime")));
219
+ const transaction = protectInstallationFn({ ...environment, platform });
220
+ let installedVersion;
221
+ try {
196
222
  const child = spawnImpl(launch.command, launch.args, {
197
223
  env,
224
+ ...(directory ? { cwd: directory } : {}),
198
225
  shell: false,
199
226
  stdio: "inherit",
200
227
  ...launch.options,
@@ -206,7 +233,11 @@ export async function runPackageUpdateCommand({
206
233
  }
207
234
  throw error;
208
235
  }
209
- const installedVersion = verifyInstalledFn(environment?.target, { expectedVersion: release?.version });
236
+ installedVersion = verifyInstalledFn(environment?.target, { expectedVersion: release?.version });
237
+ if (environment?.target && installedVersion) verifyRuntimeFn(environment.target, installedVersion, { brokerRequired });
238
+ if (env.CCDX_PRIVATE_INSTALL_PREFIX && environment?.prefix && (platform === "win32" ? path.win32.resolve(env.CCDX_PRIVATE_INSTALL_PREFIX).toLowerCase() === path.win32.resolve(environment.prefix).toLowerCase() : path.resolve(env.CCDX_PRIVATE_INSTALL_PREFIX) === path.resolve(environment.prefix))) await writePrivateLaunchers(environment);
239
+ transaction.commit();
240
+ } catch (error) { transaction.rollback();throw error; }
210
241
  if (installedVersion) {
211
242
  output.write(`Updated ${PACKAGE_NAME}: installed v${terminalCell(installedVersion)} at ${terminalCell(environment.target)}.\n`);
212
243
  if (platform === "win32") {
@@ -221,4 +252,5 @@ export async function runPackageUpdateCommand({
221
252
  }
222
253
  output.write("Restart the running adapter to use the installed version; an existing service is not replaced automatically.\n");
223
254
  return { cancelled: false, source: selectedSource };
255
+ } finally { if (directory) fs.rmSync(directory, { recursive: true, force: true }); }
224
256
  }
@@ -14,12 +14,7 @@ const same = (left, right) => isDeepStrictEqual(left, right);
14
14
 
15
15
  export function computeRetiredPredictionConfig(content, filePath) {
16
16
  const before = parseCodexToml(content);
17
- const expected = {
18
- command: process.execPath,
19
- args: [fileURLToPath(new URL("./suggestion-mcp.mjs", import.meta.url))],
20
- env: { CCDX_SUGGESTION_CONFIG: filePath },
21
- tool_timeout_sec: 40n,
22
- };
17
+ const expected = parseCodexToml(`command = ${JSON.stringify(process.execPath)}\nargs = ${JSON.stringify([fileURLToPath(new URL("./suggestion-mcp.mjs", import.meta.url))])}\nenv = { CCDX_SUGGESTION_CONFIG = ${JSON.stringify(filePath)} }\ntool_timeout_sec = 40\n`);
23
18
  const existing = before.mcp_servers?.ccdx_suggestion;
24
19
  const owned = existing && typeof existing.enabled === "boolean"
25
20
  && same({ ...existing, enabled: undefined }, { ...expected, enabled: undefined });
@@ -46,7 +41,7 @@ export function computeRetiredPredictionConfig(content, filePath) {
46
41
  const after = parseCodexToml(updated);
47
42
  const remaining = [...(before.hooks?.Stop || [])];
48
43
  if (hookOwned) {
49
- const index = remaining.findIndex(group => same(group, { hooks: [{ type: "command", command, async: true, timeout: 35n }] }));
44
+ const index = remaining.findIndex(group => same(group, parseCodexToml(block).hooks.Stop[0]));
50
45
  if (index < 0) throw new Error("Retired prediction hook could not be safely removed");
51
46
  remaining.splice(index, 1);
52
47
  }
@@ -1,3 +1,4 @@
1
+ import { autoReviewReasoningEfforts } from "./models.mjs";
1
2
  // Public metadata only. Credentials and provider transport never enter this layer.
2
3
  export const isProviderId = value => typeof value === "string" && /^[a-z][a-z0-9_-]{0,63}$/.test(value)
3
4
  && !["constructor", "prototype"].includes(value);
@@ -13,7 +14,7 @@ export function publicModelCatalog(models, { clients = () => [], selectable = ()
13
14
  endpoints: [["responses", ["/responses", "/v1/responses"]], ["chat", ["/chat/completions", "/v1/chat/completions"]],
14
15
  ["messages", ["/v1/messages"]]].filter(([, paths]) => paths.some(path => model.supported_endpoints?.includes(path))).map(([label]) => label),
15
16
  preview: model.preview === true, selectable: selectable(model), clients: clients(model),
16
- reasoning_efforts: modelReasoningEfforts(model),
17
+ reasoning_efforts: modelReasoningEfforts(model), auto_review_efforts: autoReviewReasoningEfforts(model),
17
18
  context_window: Number.isSafeInteger(model.capabilities?.limits?.max_context_window_tokens)
18
19
  && model.capabilities.limits.max_context_window_tokens > 0 ? model.capabilities.limits.max_context_window_tokens : null,
19
20
  state: model.policy?.state && model.policy.state !== "enabled" ? "restricted" : model.model_picker_enabled === false ? "hidden" : "listed",
@@ -1,4 +1,6 @@
1
1
  import fs from "node:fs";
2
+ import { autoReviewPreference, writeAutoReviewModel } from "./user-settings.mjs";
3
+ import { autoReviewReasoningEfforts, DEFAULT_CODEX_AUTO_REVIEW_MODEL, responsesModelIdsFromCopilotModels } from "./models.mjs";
2
4
  import { publicModelCatalog } from "./provider-metadata.mjs";
3
5
  import { createGithubProvider } from "./providers/github.mjs";
4
6
  import { readProviderSettings, writeProviderSettings } from "./provider-settings.mjs";
@@ -80,7 +82,7 @@ export function createProviderRuntime({ githubClient, githubRegistry, githubCred
80
82
  }
81
83
 
82
84
  const snapshot = () => ({ codex_provider: selection.codex,
83
- github: { state: "configured", profile: "codex" },
85
+ github: { state: "configured", profile: "codex", preference: autoReviewPreference(options) },
84
86
  m365: { ...(m365?.snapshot() || {}), enabled, state: !enabled ? "disabled" : pending ? "checking"
85
87
  : !["darwin", "win32"].includes(platform) ? "unsupported" : m365?.snapshot().state || (reason ? "unavailable" : "idle"),
86
88
  reason: reason || m365?.snapshot().reason || null,
@@ -108,8 +110,10 @@ export function createProviderRuntime({ githubClient, githubRegistry, githubCred
108
110
  if (!preference || !ids.has(preference.model) || !ids.has(preference.auto_review_model)) {
109
111
  throw Object.assign(new Error("Choose available M365 GPT and auto-review models before switching"), { code: "m365_model_selection_required", statusCode: 400 });
110
112
  }
111
- if (!m365.models("gpt").find(model => model.id === preference.auto_review_model)?.capabilities?.supports?.reasoning_effort?.includes("low")) {
112
- throw Object.assign(new Error("Choose an M365 Auto-review model that advertises low reasoning"), { code: "m365_review_effort_unavailable", statusCode: 400 });
113
+ const review = m365.models("gpt").find(model => model.id === preference.auto_review_model);
114
+ const effort = preference.auto_review_effort === undefined ? "low" : preference.auto_review_effort;
115
+ if (effort !== null && !autoReviewReasoningEfforts(review).includes(effort)) {
116
+ throw Object.assign(new Error("Choose an M365 review model with the selected thinking level"), { code: "m365_review_effort_unavailable", statusCode: 400 });
113
117
  }
114
118
  }
115
119
  if (closed) throw unavailable("m365_runtime_closed");
@@ -206,16 +210,26 @@ export function createProviderRuntime({ githubClient, githubRegistry, githubCred
206
210
  if (closed) throw unavailable("m365_runtime_closed");
207
211
  if (input.action === "models") { await startM365();return { state: snapshot(), models: m365?.models(input.family === "claude" ? "claude" : "gpt") || [] }; }
208
212
  if (input.action === "auto-review") {
209
- if (selection.codex !== "m365" || !m365) throw unavailable("m365_not_selected");
213
+ if (input.provider && input.provider !== selection.codex) throw new Error("Save the source before changing review settings");
214
+ if (selection.codex === "github") {
215
+ if (String(env.CCDX_AUTO_REVIEW_MODEL || "").trim()) throw new Error("Review model is controlled by CCDX_AUTO_REVIEW_MODEL");
216
+ const models = githubRegistry?.models?.data || [];
217
+ const model = models.find(model => model.id === input.model);
218
+ if (!responsesModelIdsFromCopilotModels(models).includes(input.model)
219
+ || input.effort !== null && !autoReviewReasoningEfforts(model).includes(input.effort)) throw new Error("Choose an available review model and thinking level");
220
+ const result = writeAutoReviewModel(input.model === DEFAULT_CODEX_AUTO_REVIEW_MODEL ? "" : input.model, { ...options, reasoningEffort: input.effort });
221
+ return { changed: result.changed, ...snapshot() };
222
+ }
223
+ if (!m365) throw unavailable("m365_not_selected");
210
224
  const model = m365.models("gpt").find(model => model.id === input.model);
211
- if (!model || input.effort !== null && !model.capabilities?.supports?.reasoning_effort?.includes(input.effort)) {
225
+ if (!model || input.effort !== null && !autoReviewReasoningEfforts(model).includes(input.effort)) {
212
226
  throw Object.assign(new Error("The selected M365 review model or effort is not available"), { statusCode: 400, code: "m365_review_effort_unavailable" });
213
227
  }
214
228
  const preference = { ...selection.m365, auto_review_model: input.model, auto_review_effort: input.effort };
215
229
  const changed = JSON.stringify(preference) !== JSON.stringify(selection.m365);
216
230
  selection = writeProviderSettings("m365", preference, options);return { changed, ...snapshot() };
217
231
  }
218
- if (input.action === "switch") return switchSource(input.provider, { model: input.model, auto_review_model: input.auto_review_model });
232
+ if (input.action === "switch") return switchSource(input.provider, { model: input.model, auto_review_model: input.auto_review_model ?? selection.m365?.auto_review_model, ...(input.auto_review_effort !== undefined ? { auto_review_effort: input.auto_review_effort } : selection.m365?.auto_review_effort !== undefined ? { auto_review_effort: selection.m365.auto_review_effort } : {}) });
219
233
  if (input.action === "off" || input.action === "remove") return disable(input.action === "remove");
220
234
  if (input.action === "on") {
221
235
  updateM365Settings({ enabled: true }, options);enabled = env.CCDX_M365 !== "0";