codex-copilot-dx 1.2.0 → 1.2.1

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.
@@ -22,13 +22,14 @@
22
22
  <nav aria-label="Navigation" data-i18n-label="main_navigation">
23
23
  <a href="#overview" data-route="overview" aria-current="page" data-i18n="overview">Overview</a>
24
24
  <span class="nav-group" data-i18n="clients">Apps</span>
25
- <a href="#codex" data-route="codex">Codex</a>
26
- <a href="#claude" data-route="claude">Claude</a>
25
+ <a class="nav-child" href="#codex" data-route="codex">Codex</a>
26
+ <a class="nav-child" href="#claude" data-route="claude">Claude</a>
27
27
  <a href="#models" data-route="models" data-i18n="model_services">Model sources</a>
28
- <a href="#usage" data-route="usage" data-i18n="usage_and_diagnostics">Usage and issues</a>
28
+ <a href="#usage" data-route="usage" data-i18n="usage_and_diagnostics">Usage</a>
29
+ <a href="#requests" data-route="requests" data-i18n="request_records">Requests</a>
29
30
  <a href="#system" data-route="system" data-i18n="system_and_settings">Settings</a>
30
31
  </nav>
31
- <div class="sidebar-bottom"><button id="open-animation" type="button" aria-controls="animation-settings" aria-expanded="false" data-i18n="terminal_appearance">Terminal appearance</button><p data-i18n="local_service_client_specific_capabilities_stay_with_their_clien">Runs on this computer. Each app has its own features.</p></div>
32
+ <div class="sidebar-bottom"><button id="open-animation" type="button" aria-controls="animation-settings" aria-expanded="false" data-i18n="terminal_appearance">Terminal appearance</button></div>
32
33
  </aside>
33
34
 
34
35
  <header class="topbar">
@@ -54,6 +55,27 @@
54
55
  <section class="panel dashboard-section"><h2 data-i18n="this_run_usage">THIS RUN</h2><p id="runtime-usage" class="table-note"></p><p class="hint" data-i18n="updated_from_returned_usage_not_a_live_bill_pending_usage_is_not">Counts returned usage only. Pending usage is not included. This is not a live bill.</p></section>
55
56
  </div>
56
57
  <div data-view="codex" hidden>
58
+ <section class="panel dashboard-section" aria-labelledby="routing-heading">
59
+ <h2 id="routing-heading" data-i18n="codex_model_source">CODEX MODEL SOURCE</h2>
60
+ <p class="hint" data-i18n="source_changes_new_requests">Changes apply to later Codex requests.</p>
61
+ <div class="section-actions">
62
+ <label><span data-i18n="source">Source</span><select id="source-provider"></select></label>
63
+ <label id="source-model-field" hidden><span data-i18n="conversation_model">Conversation model</span><select id="source-model"></select></label>
64
+ <button id="apply-source" type="button" data-i18n="apply_source">Use this source</button>
65
+ </div>
66
+ <p id="source-model-note" class="hint" data-i18n="github_model_in_codex">Choose your conversation model in Codex.</p>
67
+ <div id="source-control-note" class="hint" role="status"></div>
68
+ </section>
69
+ <section class="panel dashboard-section" aria-labelledby="review-heading">
70
+ <h2 id="review-heading" data-i18n="auto_review_settings">AUTO REVIEW</h2>
71
+ <p class="hint" data-i18n="review_uses_selected_source">Reviews use the source selected above. Save the source and review choices separately.</p>
72
+ <div class="section-actions">
73
+ <label><span data-i18n="auto_review_model">Review model</span><select id="source-review"></select></label>
74
+ <label><span data-i18n="thinking_level">Thinking level</span><select id="source-review-effort"></select></label>
75
+ <button id="save-review" type="button" data-i18n="save_review">Save review settings</button>
76
+ </div>
77
+ <p id="review-control-note" class="hint" role="status"></p>
78
+ </section>
57
79
  <section class="overview client-overview"><article class="card"><h2 data-i18n="codex_models">CODEX MODELS</h2><strong id="models">—</strong><p id="model-source">—</p></article></section>
58
80
  <details class="panel dashboard-section" id="runtime-resources" open>
59
81
  <summary data-i18n="codex_conversations">CODEX CONVERSATIONS</summary>
@@ -114,20 +136,15 @@
114
136
  <div class="table-wrap"><table><thead><tr><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="vendor">MODEL MAKER</th><th scope="col" data-i18n="api">CONNECTION TYPE</th><th scope="col" data-i18n="client">APP</th><th scope="col" data-i18n="reasoning">THINKING LEVEL</th><th scope="col" data-i18n="state">STATE</th></tr></thead><tbody id="live-models-body" role="tabpanel"><tr><td colspan="6" data-i18n="loading">Loading…</td></tr></tbody></table></div>
115
137
  <p class="hint" data-i18n="catalog_listing_does_not_guarantee_inference_access">Listed does not mean your account can use it.</p>
116
138
  </details>
117
- <section class="panel dashboard-section" aria-labelledby="routing-heading">
118
- <h2 id="routing-heading" data-i18n="codex_model_source">CODEX MODEL SOURCE</h2>
119
- <p class="hint" data-i18n="catalog_tabs_only_change_the_view_apply_explicitly_to_change_the">Tabs only browse models. Apply changes the source for later Codex requests.</p>
120
- <div class="section-actions"><label><span data-i18n="source">Source</span> <select id="source-provider"></select></label><label><span data-i18n="model_5e2c6">Model</span> <select id="source-model" disabled></select></label><label><span data-i18n="auto_review_model">Review model</span> <select id="source-review" disabled></select></label><button id="apply-source" type="button" data-i18n="apply_source">Use this source</button></div>
121
- <div class="section-actions"><span>Microsoft 365</span><button id="m365-on" type="button" data-i18n="enable_service">Enable source</button><button id="m365-off" type="button" data-i18n="disable_service">Disable source</button></div>
122
- <div id="source-control-note" class="hint" role="status"></div>
139
+ <section class="panel dashboard-section" aria-labelledby="source-access-heading">
140
+ <h2 id="source-access-heading">Microsoft 365</h2>
141
+ <p class="hint" data-i18n="m365_source_access">Provides models for Codex and Claude on supported devices.</p>
142
+ <div class="section-actions"><button id="m365-on" type="button" data-i18n="enable_service">Enable source</button><button id="m365-off" type="button" data-i18n="disable_service">Disable source</button></div>
143
+ <div id="m365-control-note" class="hint" role="status"></div>
123
144
  </section>
124
145
  </div>
125
146
  <div data-view="usage" hidden>
126
- <details class="panel dashboard-section" id="source-requests">
127
- <summary data-i18n="requests_by_source">REQUESTS BY SOURCE</summary>
128
- <p class="hint" data-i18n="results_since_startup_partial_usage_is_marked_separately">Results since startup. Partial usage is marked separately.</p>
129
- <div class="table-wrap"><table><thead><tr><th data-i18n="source">Source</th><th data-i18n="protocol">Protocol</th><th data-i18n="active">Active</th><th data-i18n="completed">Completed</th><th data-i18n="incomplete">Incomplete</th><th data-i18n="failed">Failed</th><th data-i18n="cancelled">Cancelled</th><th data-i18n="unknown">Unknown</th></tr></thead><tbody id="source-requests-body"></tbody></table></div>
130
- </details>
147
+
131
148
  <details class="panel dashboard-section" id="model-usage" open>
132
149
  <summary class="panel-heading"><h2 data-i18n="usage">MODEL USAGE</h2><span id="usage-state" data-i18n="reading_log">COUNTING</span></summary>
133
150
  <div class="section-actions"><label><span data-i18n="source">Source</span> <select id="usage-provider"><option value="" data-i18n="all_providers">All providers</option></select></label><button id="clear-usage-day" type="button" hidden data-i18n="all_history">Show all</button><button id="refresh-usage" type="button" data-i18n="refresh">Refresh</button></div>
@@ -153,6 +170,13 @@
153
170
  <p id="analytics-selection" class="hint" role="status" data-i18n="select_a_day_to_inspect_its_model_totals_no_history_is_distinct_">Select a day for its usage. No records does not mean zero requests.</p>
154
171
  </details>
155
172
  </details>
173
+ </div>
174
+ <div data-view="requests" hidden>
175
+ <details class="panel dashboard-section" id="source-requests">
176
+ <summary data-i18n="requests_by_source">REQUESTS BY SOURCE</summary>
177
+ <p class="hint" data-i18n="results_since_startup_partial_usage_is_marked_separately">Results since startup. Partial usage is marked separately.</p>
178
+ <div class="table-wrap"><table><thead><tr><th data-i18n="source">Source</th><th data-i18n="protocol">Protocol</th><th data-i18n="active">Active</th><th data-i18n="completed">Completed</th><th data-i18n="incomplete">Incomplete</th><th data-i18n="failed">Failed</th><th data-i18n="cancelled">Cancelled</th><th data-i18n="unknown">Unknown</th></tr></thead><tbody id="source-requests-body"></tbody></table></div>
179
+ </details>
156
180
  <details class="lower" id="recent-failures" open>
157
181
  <summary class="panel-heading"><h2 data-i18n="recent_inference_http_failures">RECENT REQUEST ISSUES</h2><span id="failure-count">requests + events</span></summary>
158
182
  <ol id="failures"><li class="empty" data-i18n="reading_874bf">Reading…</li></ol>
@@ -4,14 +4,27 @@
4
4
  "terminal_animation_unavailable_in_this_output_mode": ["Terminal animation unavailable in this output mode", "当前输出模式不播放终端动效"],
5
5
  "prediction_integration_setup": ["Suggestion setup", "建议设置"],
6
6
  "visible_status_updates_every_2_seconds_catalogs_and_retained_usa": ["Visible status updates every 2 seconds. Catalogs and retained usage refresh on demand or every 30 minutes while open.", "可见状态每2秒更新。\n列表和留存用量按需更新,\n展开时每30分钟刷新。"],
7
+ "request_records": ["Requests", "请求记录"],
8
+ "source_changes_new_requests": ["Changes apply to later Codex requests.", "保存后用于新的 Codex 请求。"],
9
+ "conversation_model": ["Conversation model", "对话模型"],
10
+ "github_model_in_codex": ["Choose your conversation model in Codex.", "在 Codex 中选择对话模型。"],
11
+ "auto_review_settings": ["AUTO REVIEW", "自动审查"],
12
+ "review_uses_selected_source": ["Reviews use the source above. First source setup saves the initial review choices; later review changes save separately.", "审查使用上方所选来源。首次切入时一并保存初始审查设置,之后分别保存。"],
13
+ "thinking_level": ["Thinking level", "思考强度"],
14
+ "follow_client": ["Follow Codex (low if omitted)", "跟随 Codex(未指定时用 low)"],
15
+ "save_review": ["Save review settings", "保存审查设置"],
16
+ "m365_source_access": ["Provides models for Codex and Claude on supported devices.", "在支持的设备上为 Codex 和 Claude 提供模型。"],
17
+ "confirm_disable_m365": ["Disable Microsoft 365? Its Claude connection will stop and unchanged CCDX-owned settings will be restored. Codex will use GitHub Copilot. Your sign-in and usage history will be kept.", "停用 Microsoft 365?Claude 本地连接将关闭,未被您改动的 CCDX 设置将恢复。Codex 将改用 GitHub Copilot。登录信息和用量记录会保留。"],
18
+ "review_environment_override": ["Controlled by CCDX_AUTO_REVIEW_MODEL. Change that startup setting first.", "由 CCDX_AUTO_REVIEW_MODEL 指定。请先调整启动设置。"],
19
+ "review_save_source_first": ["Save this source before saving review settings.", "请先保存所选来源,再保存审查设置。"],
20
+ "model_choices_loading": ["Loading model choices…", "正在读取可选模型…"],
7
21
  "clients": ["Apps", "应用"],
8
22
  "model_services": ["Model sources", "模型来源"],
9
- "usage_and_diagnostics": ["Usage and issues", "用量排查"],
23
+ "usage_and_diagnostics": ["Usage", "用量统计"],
10
24
  "system_and_settings": ["Settings", "设置"],
11
25
  "main_navigation": ["Navigation", "页面导航"],
12
26
  "local_control": ["LOCAL CONTROL", "本机控制"],
13
27
  "terminal_appearance": ["Terminal appearance", "终端外观"],
14
- "local_service_client_specific_capabilities_stay_with_their_clien": ["Runs on this computer. Each app has its own features.", "在本机运行。\n各应用功能分别列出。"],
15
28
  "configuration_observation": ["SETUP AND ACTIVITY", "接入状态"],
16
29
  "codex_conversations": ["CODEX CONVERSATIONS", "对话处理"],
17
30
  "codex_conversation_buffer": ["CONVERSATION BUFFER", "对话暂存"],
@@ -31,11 +44,11 @@
31
44
  "service_settings": ["SERVICE SETTINGS", "服务设置"],
32
45
  "saved_preference_and_effective_state_are_separate_environment_ov": ["Saved choices and current behavior are shown separately. Startup overrides and required restarts are listed.", "已保存与已生效分别显示。\n启动限制与重启要求会注明。"],
33
46
  "terminal_animation": ["Terminal animation", "终端动效"],
34
- "open_webui_at_startup": ["Open dashboard on startup", "启动打开"],
47
+ "open_webui_at_startup": ["Open dashboard on startup", "启动时打开网页"],
35
48
  "reading_settings": ["Reading settings…", "读取设置中…"],
36
49
  "codex_model_source": ["CODEX MODEL SOURCE", "模型来源"],
37
50
  "catalog_tabs_only_change_the_view_apply_explicitly_to_change_the": ["Tabs only browse models. Apply changes the source for later Codex requests.", "切换标签只查看模型。\n保存后更改后续请求的来源。"],
38
- "auto_review_model": ["Review model", "审查模型"],
51
+ "auto_review_model": ["Review model", "自动审查模型"],
39
52
  "apply_source": ["Use this source", "使用来源"],
40
53
  "enable_service": ["Enable source", "开启接入"],
41
54
  "disable_service": ["Disable source", "停用接入"],
@@ -413,7 +426,6 @@
413
426
  "Main navigation": "main_navigation",
414
427
  "LOCAL CONTROL": "local_control",
415
428
  "Terminal appearance": "terminal_appearance",
416
- "Local service. Client-specific capabilities stay with their client.": "local_service_client_specific_capabilities_stay_with_their_clien",
417
429
  "CONFIGURATION + OBSERVATION": "configuration_observation",
418
430
  "CODEX CONVERSATIONS": "codex_conversations",
419
431
  "CODEX CONVERSATION BUFFER": "codex_conversation_buffer",
@@ -189,3 +189,16 @@ 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
+ }
@@ -273,6 +273,7 @@ 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),
@@ -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";
@@ -0,0 +1,192 @@
1
+ // Also shipped as the standalone bootstrap helper. Keep imports built-in only.
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { createRequire } from "node:module";
6
+ import { Readable } from "node:stream";
7
+ import { createHash } from "node:crypto";
8
+ import { gunzipSync } from "node:zlib";
9
+ import { execFileSync } from "node:child_process";
10
+ import { fileURLToPath, pathToFileURL } from "node:url";
11
+
12
+ export const RELEASE_BASE = "https://github.com/DaleXiao/codex-copilot-dx/releases/download";
13
+ export function stableVersion(tag) {
14
+ const match = typeof tag === "string" && tag.length <= 64 && /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.exec(tag);
15
+ return match && match.slice(1).every(part => Number.isSafeInteger(Number(part))) ? match.slice(1).join(".") : null;
16
+ }
17
+ // Use the downloader already shipped with the selected npm, rather than adding
18
+ // a second runtime dependency or bypassing its proxy/CA/offline settings.
19
+ export function createNpmReleaseFetch(npmCli, { env = process.env, exec = execFileSync } = {}) {
20
+ try {
21
+ const npmFetch = createRequire(npmCli)("make-fetch-happen");
22
+ const keys = ["https-proxy", "proxy", "noproxy", "cafile", "strict-ssl", "offline"];
23
+ const output = exec(process.execPath, [npmCli, "config", "get", "--global", ...keys], {
24
+ env, encoding: "utf8", timeout: 5000, maxBuffer: 128 * 1024, stdio: ["ignore", "pipe", "pipe"] });
25
+ const values = Object.fromEntries(output.trim().split(/\r?\n/).map(line => /^(https-proxy|proxy|noproxy|cafile|strict-ssl|offline)=(.*)$/.exec(line)).filter(Boolean).map(match => [match[1], match[2]]));
26
+ if (values.offline === "true") throw new Error("offline");
27
+ const present = value => value && !["null", "undefined"].includes(value) ? value : undefined;
28
+ const caFile = present(values.cafile);let ca;
29
+ if (caFile) {
30
+ if (!fs.statSync(caFile).isFile() || fs.statSync(caFile).size > 1024 * 1024) throw new Error("CA file");
31
+ ca = fs.readFileSync(caFile, "utf8");
32
+ }
33
+ return async (url, options = {}) => {
34
+ try {
35
+ const response = await npmFetch(url, { ...options, retry: 0, cache: "no-store", ca,
36
+ proxy: present(values["https-proxy"]) || present(values.proxy) || env.https_proxy || env.HTTPS_PROXY || env.http_proxy || env.HTTP_PROXY,
37
+ noProxy: present(values.noproxy) || env.no_proxy || env.NO_PROXY,
38
+ strictSSL: values["strict-ssl"] !== "false" });
39
+ const body = [204, 205, 304].includes(response.status) ? null : Readable.toWeb(Readable.from(response.body));
40
+ const result = new Response(body, { status: response.status, headers: Object.fromEntries(response.headers) });
41
+ Object.defineProperty(result, "url", { value: response.url });return result;
42
+ } catch { throw new Error("Release download failed. Check the configured npm proxy, CA file and approved GitHub access; no fallback was attempted."); }
43
+ };
44
+ } catch (error) {
45
+ if (error.message === "offline") throw new Error("npm offline mode is enabled. Use an approved local Release package/cache; no download was started.");
46
+ throw new Error("Could not use this npm's download component or network settings. Keep its proxy/CA policy; use an approved local Release package or a complete supported npm distribution.");
47
+ }
48
+ }
49
+
50
+ export async function releaseBytes(url, { fetchImpl = fetch, maxBytes, timeoutMs = 60000 } = {}) {
51
+ const response = await fetchImpl(url, { redirect: "follow", signal: AbortSignal.timeout(timeoutMs), headers: { "User-Agent": "codex-copilot-dx", Accept: "application/octet-stream" } });
52
+ const final = response.url && new URL(response.url);
53
+ if (!response.ok || final && (final.protocol !== "https:" || !["github.com", "release-assets.githubusercontent.com", "objects.githubusercontent.com"].includes(final.hostname))) {
54
+ await response.body?.cancel();throw new Error(`Release download refused (HTTP ${response.status}). Check company proxy, certificates and approved download access. No fallback was attempted.`);
55
+ }
56
+ const chunks = [];let size = 0;
57
+ try {
58
+ for await (const chunk of response.body || []) {
59
+ size += chunk.length;if (size > maxBytes) throw new Error("Release download exceeds its size limit");chunks.push(chunk);
60
+ }
61
+ return Buffer.concat(chunks, size);
62
+ } catch (error) { throw new Error("Release download did not finish; the existing installation was preserved", { cause: error }); }
63
+ }
64
+ export function releaseChecksum(manifest, name) {
65
+ const lines = manifest.toString("utf8").split(/\r?\n/).filter(line => line.endsWith(` ${name}`));
66
+ if (lines.length !== 1 || !/^[a-f0-9]{64} [\w.-]+$/.test(lines[0])) throw new Error("Release checksum is missing or invalid");
67
+ return lines[0].slice(0, 64);
68
+ }
69
+ export function packageMetadata(bytes) {
70
+ const tar = gunzipSync(bytes, { maxOutputLength: 64 * 1024 * 1024 });
71
+ let metadata;
72
+ for (let offset = 0; offset + 512 <= tar.length;) {
73
+ const header = tar.subarray(offset, offset + 512), name = header.subarray(0, 100).toString().replace(/\0.*$/s, "");
74
+ if (!name) break;
75
+ const sizeText = header.subarray(124, 136).toString().replace(/\0.*$/s, "").trim();
76
+ if (!/^[0-7]+$/.test(sizeText)) throw new Error("Invalid release package header");
77
+ const size = Number.parseInt(sizeText, 8);
78
+ if (!Number.isSafeInteger(size) || offset + 512 + size > tar.length) throw new Error("Invalid release package size");
79
+ if (name === "package/package.json") {
80
+ if (metadata || size > 65536 || ![0, 48].includes(header[156])) throw new Error("Invalid release package metadata");
81
+ metadata = JSON.parse(tar.subarray(offset + 512, offset + 512 + size));
82
+ }
83
+ offset += 512 + Math.ceil(size / 512) * 512;
84
+ }
85
+ if (metadata?.name !== "codex-copilot-dx" || !stableVersion(metadata.version)) throw new Error("Release package identity is invalid");
86
+ return metadata;
87
+ }
88
+ export async function downloadRelease(tag, { fetchImpl = fetch, directory } = {}) {
89
+ const version = stableVersion(tag);if (!version) throw new Error("A valid stable GitHub release tag is required");
90
+ const name = `codex-copilot-dx-${version}.tgz`, base = `${RELEASE_BASE}/v${version}`;
91
+ const manifest = await releaseBytes(`${base}/SHA256SUMS`, { fetchImpl, maxBytes: 65536 });
92
+ const expected = releaseChecksum(manifest, name);
93
+ const bytes = await releaseBytes(`${base}/${name}`, { fetchImpl, maxBytes: 16 * 1024 * 1024 });
94
+ if (createHash("sha256").update(bytes).digest("hex") !== expected) throw new Error("Release checksum mismatch; no installation was started");
95
+ if (packageMetadata(bytes).version !== version) throw new Error("Release package version does not match its tag");
96
+ const file = path.join(directory, name);fs.writeFileSync(file, bytes, { flag: "wx", mode: 0o600 });return { file, name, version };
97
+ }
98
+
99
+ // Preserve only this package and its command entries. Never snapshot credentials
100
+ // or change npm settings. A busy/readonly Windows installation fails in place.
101
+ export function protectInstallation({ target, prefix, platform = process.platform } = {}) {
102
+ if (!target || !prefix) return { commit() {}, rollback() {} };
103
+ const parent = path.dirname(target);fs.mkdirSync(parent, { recursive: true });
104
+ const lock = path.join(parent, ".ccdx-install.lock");let fd;
105
+ try { fd = fs.openSync(lock, "wx", 0o600); } catch { throw new Error("Another install may be running. Check the CCDX install lock before retrying."); }
106
+ let backup;
107
+ try { backup = fs.mkdtempSync(path.join(parent, ".ccdx-backup-")); }
108
+ catch (error) { fs.closeSync(fd);fs.unlinkSync(lock);throw error; }
109
+ const entries = [target, ...["ccdx", "codex-copilot-dx"].flatMap(name => platform === "win32"
110
+ ? [name, `${name}.cmd`, `${name}.ps1`].map(file => path.join(prefix, file)) : [path.join(prefix, "bin", name)])];
111
+ const saved = [];
112
+ const clean = () => { fs.rmSync(backup, { recursive: true, force: true });fs.closeSync(fd);fs.unlinkSync(lock); };
113
+ try {
114
+ entries.forEach((file, index) => {
115
+ let stat;try { stat = fs.lstatSync(file); } catch (error) { if (error.code !== "ENOENT") throw error; }
116
+ if (file === target && stat && (!stat.isDirectory() || stat.isSymbolicLink())) throw new Error("The npm target is linked or not a regular installation; use its owning installer");
117
+ const copy = path.join(backup, String(index));
118
+ if (stat) fs.cpSync(file, copy, { recursive: true, verbatimSymlinks: true, preserveTimestamps: true });
119
+ saved.push({ file, copy, existed: Boolean(stat) });
120
+ });
121
+ } catch (error) { clean();throw error; }
122
+ let finalized = false;
123
+ return {
124
+ commit() {
125
+ finalized = true;
126
+ try { clean(); }
127
+ catch { console.error(`CCDX was installed, but backup cleanup needs attention: ${backup}; check ${lock} before retrying.`); }
128
+ },
129
+ rollback() {
130
+ if (finalized) return;
131
+ try {
132
+ for (const { file, copy, existed } of saved) {
133
+ fs.rmSync(file, { recursive: true, force: true });
134
+ if (existed) fs.cpSync(copy, file, { recursive: true, verbatimSymlinks: true, preserveTimestamps: true });
135
+ }
136
+ clean();
137
+ } catch (error) {
138
+ fs.closeSync(fd);
139
+ throw new Error(`Restore could not finish. Previous package and commands remain at ${backup}; do not delete the install lock until restored.`, { cause: error });
140
+ }
141
+ },
142
+ };
143
+ }
144
+
145
+ export function verifyPackageRuntime(target, version, { brokerRequired = false } = {}) {
146
+ const code = `const {createRequire}=require('node:module');const r=createRequire(${JSON.stringify(path.join(target, "package.json"))});const pkg=r('./package.json');if(pkg.name!=='codex-copilot-dx'||pkg.version!==${JSON.stringify(version)})throw Error('Version mismatch');r('sharp')({create:{width:1,height:1,channels:3,background:'white'}}).png().toBuffer().then(()=>{${brokerRequired ? "if(!r('@azure/msal-node-runtime').msalNodeRuntime)throw Error('Native broker unavailable');" : ""}}).catch(e=>{console.error(e.message);process.exitCode=1});`;
147
+ execFileSync(process.execPath, ["-e", code], { timeout: 30000, stdio: ["ignore", "pipe", "pipe"] });
148
+ const output = execFileSync(process.execPath, [path.join(target, "bin", "cli.mjs"), "version"], { encoding: "utf8", timeout: 15000, stdio: ["ignore", "pipe", "pipe"] });
149
+ if (!output.includes(`ccdx v${version} `)) throw new Error("Installed command version could not be verified");
150
+ }
151
+
152
+ export async function writePrivateLaunchers({ prefix, target }) {
153
+ const quote = value => "'" + value.replaceAll("'", "'\\''") + "'";
154
+ const windows = process.platform === "win32"
155
+ ? await import(pathToFileURL(path.join(target, "src", "windows-command.mjs")).href) : null;
156
+ for (const name of ["ccdx", "codex-copilot-dx"]) {
157
+ const cli = path.join(target, "bin", name === "ccdx" ? "cli.mjs" : "codex-copilot-dx.mjs");
158
+ if (windows) {
159
+ fs.writeFileSync(path.join(prefix, `${name}.cmd`), windows.privateWindowsCommand({ node: process.execPath, cli, prefix }));
160
+ } else {
161
+ const file = path.join(prefix, "bin", name);fs.rmSync(file, { force: true });
162
+ fs.writeFileSync(file, `#!/bin/sh\nPATH=${quote(path.dirname(process.execPath))}:"$PATH"\nexport PATH\nCCDX_PRIVATE_INSTALL_PREFIX=${quote(prefix)}\nexport CCDX_PRIVATE_INSTALL_PREFIX\nif [ -z "\${npm_config_prefix:-}\${NPM_CONFIG_PREFIX:-}" ]; then npm_config_prefix=${quote(prefix)}; export npm_config_prefix; fi\nexec ${quote(process.execPath)} ${quote(cli)} "$@"\n`, { mode: 0o755 });
163
+ }
164
+ }
165
+ if (windows && windows.inspectWindowsCommand({ packageRoot: target, repair: true }).status !== "ready") throw new Error("Private Windows commands could not be verified");
166
+ }
167
+
168
+ async function bootstrap() {
169
+ const [tag, prefix, npmCli, ...flags] = process.argv.slice(2);
170
+ const permission = flags.includes("--allow-remote"), privateRuntime = flags.includes("--private-runtime");
171
+ if (!stableVersion(tag) || !prefix || !path.isAbsolute(prefix) || !npmCli || !path.isAbsolute(npmCli) || flags.some(flag => !["--allow-remote", "--private-runtime"].includes(flag))) throw new Error("Use: node ccdx-install.mjs vVERSION /absolute/prefix /absolute/npm-cli.js [--allow-remote]");
172
+ const target = path.join(prefix, ...(process.platform === "win32" ? [] : ["lib"]), "node_modules", "codex-copilot-dx");
173
+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), "ccdx-install-"));let transaction;
174
+ try {
175
+ const release = await downloadRelease(tag, { directory, fetchImpl: createNpmReleaseFetch(npmCli) });
176
+ transaction = protectInstallation({ target, prefix });
177
+ const npmVersion = execFileSync(process.execPath, [npmCli, "--version"], { encoding: "utf8", timeout: 10000 }).trim();
178
+ const args = [npmCli, "install", "--global", "--prefix", prefix, "--ignore-scripts", "--no-audit", "--no-fund"];
179
+ if (permission && Number(npmVersion.split(".")[0]) >= 12) args.push("--allow-remote=all");
180
+ args.push(release.file);
181
+ execFileSync(process.execPath, args, { stdio: "inherit", timeout: 300000 });
182
+ verifyPackageRuntime(target, release.version, { brokerRequired: ["darwin", "win32"].includes(process.platform) });
183
+ if (privateRuntime || process.platform === "win32") await writePrivateLaunchers({ prefix, target });
184
+ transaction.commit();transaction = null;
185
+ console.log(`Installed CCDX ${release.version}. Existing services keep running until restarted.`);
186
+ } catch (error) {
187
+ transaction?.rollback();throw new Error("Installation failed. Previous CCDX package and commands were restored. Check approved registry, proxy, certificates and npm policy; dependencies still need registry access.", { cause: error });
188
+ } finally { fs.rmSync(directory, { recursive: true, force: true }); }
189
+ }
190
+ if (process.argv[1] && path.basename(process.argv[1]) === "ccdx-install.mjs" && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
191
+ try { await bootstrap(); } catch (error) { console.error(error.message);if (error.cause) console.error(error.cause.message);process.exitCode = 1; }
192
+ }