codex-copilot-dx 1.2.33 → 1.3.0

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.
Files changed (42) hide show
  1. package/README.md +64 -110
  2. package/bin/cli.mjs +38 -102
  3. package/docs/ARCHITECTURE.md +23 -7
  4. package/docs/README.md +9 -76
  5. package/docs/REFERENCE.md +137 -1936
  6. package/package.json +11 -4
  7. package/src/access-settings.mjs +2 -2
  8. package/src/adapter.mjs +1 -1
  9. package/src/auth-credentials.mjs +1 -1
  10. package/src/auto-review-model.mjs +2 -2
  11. package/src/cli-animation.mjs +2 -2
  12. package/src/cli-auth.mjs +3 -3
  13. package/src/cli-cache.mjs +2 -2
  14. package/src/cli-command-spec.mjs +260 -58
  15. package/src/cli-image.mjs +2 -2
  16. package/src/cli-limits.mjs +2 -2
  17. package/src/cli-m365.mjs +1 -1
  18. package/src/cli-management.mjs +7 -3
  19. package/src/cli-options.mjs +71 -408
  20. package/src/connection-runtime.mjs +1408 -377
  21. package/src/copilot-token-session.mjs +1 -1
  22. package/src/dashboard/connections.js +23 -4
  23. package/src/dashboard/ui.css +9 -2
  24. package/src/dashboard-api.mjs +5 -5
  25. package/src/doctor.mjs +4 -4
  26. package/src/image-mcp.mjs +2 -2
  27. package/src/native-prediction-fix.mjs +1 -1
  28. package/src/native-prediction-profile.mjs +1 -1
  29. package/src/native-prediction-windows.mjs +1 -1
  30. package/src/native-prediction.mjs +6 -6
  31. package/src/nightly-update.mjs +2 -2
  32. package/src/provider-runtime.mjs +1 -1
  33. package/src/providers/m365-accounts.mjs +1 -1
  34. package/src/release-install.mjs +11 -15
  35. package/src/startup-ui.mjs +15 -11
  36. package/src/terminal-console.mjs +5 -4
  37. package/src/terminal-state.mjs +1 -1
  38. package/src/usage.mjs +5 -5
  39. package/src/windows-command.mjs +2 -2
  40. package/bin/codex-copilot-dx.mjs +0 -11
  41. package/src/cli-models.mjs +0 -94
  42. package/src/legacy-command-warning.mjs +0 -38
@@ -128,7 +128,7 @@ export function createCopilotTokenSession({
128
128
  });
129
129
  }
130
130
  if (usesDefaultTokenStore) return githubReauthMessage(reason, resolveHome(home));
131
- return `${reason}\nRun \`ccdx auth login ${profile} --reauth\`, then restart ccdx.`;
131
+ return `${reason}\nReconnect the affected account in its application; other saved accounts were kept.`;
132
132
  };
133
133
 
134
134
  async function loadCredentials(home) {
@@ -144,9 +144,23 @@
144
144
  const count = value => !value ? format("cap_unknown") : value >= 1000000 ? `${Number((value / 1000000).toFixed(2))}M` : value >= 1000 ? `${Number((value / 1000).toFixed(1))}K` : String(value);
145
145
  const reasoningText = values => values.reasoning === false ? format("cap_unsupported") : values.reasoning_efforts?.length ? values.reasoning_efforts.join(" / ") : values.reasoning === true ? format("cap_supported") : format("cap_unknown");
146
146
  const searchText = values => values.web_search === undefined ? format("cap_unknown") : values.web_search.length ? values.web_search.map(protocol => protocol === "messages" ? "Messages" : protocol === "responses" ? "Responses" : "Chat").join(" / ") : format("cap_unsupported");
147
- function modelDetail(model) {
147
+ function closeModelDetail() {
148
+ const detail = el("connection-model-detail");
149
+ const row = detail.closest(".connection-detail-row");
150
+ detail.hidden = true;
151
+ el("connection-models").closest("fieldset").append(detail);
152
+ row?.remove();
153
+ for (const button of el("connection-models").querySelectorAll("[data-model-details]")) button.setAttribute("aria-expanded", "false");
154
+ }
155
+ function modelDetail(model, modelRow, trigger) {
156
+ if (trigger.getAttribute("aria-expanded") === "true") { closeModelDetail();return; }
157
+ closeModelDetail();
148
158
  const detail = el("connection-model-detail");detail.hidden = false;detail.replaceChildren();
149
- const heading = node("div", undefined, "panel-heading");heading.append(node("h3", model.id), button("close", () => { detail.hidden = true; }));detail.append(heading);
159
+ const row = node("tr", undefined, "connection-detail-row"), cell = node("td");
160
+ cell.colSpan = modelRow.children.length;
161
+ cell.append(detail);row.append(cell);modelRow.after(row);
162
+ trigger.setAttribute("aria-expanded", "true");
163
+ const heading = node("div", undefined, "panel-heading");heading.append(node("h3", model.id), button("close", () => { closeModelDetail();trigger.focus(); }));detail.append(heading);
150
164
  const protocol = choice(model.protocols.map(id => ({ id, name: id === "messages" ? "Messages" : id === "responses" ? "Responses" : "Chat" })), model.protocols.includes("messages") ? "messages" : model.protocols[0], false);
151
165
  protocol.setAttribute("aria-label", format("cap_api"));detail.append(protocol);
152
166
  const status = node("p", undefined, "hint"), table = node("table"), body = node("tbody");table.append(body);detail.append(status, table);
@@ -196,7 +210,7 @@
196
210
  override[key] = numeric.includes(key) ? Number(text) : flags.includes(key) ? text === "true" : arrays.includes(key) ? text === "[]" ? [] : text.split(/[,,]\s*/).filter(Boolean) : text;
197
211
  }
198
212
  model.capabilities = override;delete model.context_window;delete model.reasoning_efforts;modelRows();detail.hidden = true;message("cap_details_draft");
199
- });advanced.append(save);detail.scrollIntoView({ block: "nearest", behavior: "auto" });
213
+ });advanced.append(save);
200
214
  }
201
215
  function syncPreview(preview) {
202
216
  const c = client(editingClient), result = el("connection-sync-result");result.hidden = false;result.replaceChildren();
@@ -215,6 +229,7 @@
215
229
  }
216
230
  }
217
231
  function modelRows() {
232
+ closeModelDetail();
218
233
  const body = el("connection-models");body.replaceChildren();
219
234
  for (const model of models) {
220
235
  const tr = node("tr"), name = node("td"), apis = node("td"), actions = node("td"), group = node("div", undefined, "connection-checks");
@@ -233,7 +248,11 @@
233
248
  }
234
249
  const capability = resolved(model);
235
250
  const context = node("td", count(capability.context_window)), reasoning = node("td", reasoningText(capability)), search = node("td", searchText(capability));
236
- apis.append(group);actions.append(button("cap_details", () => modelDetail(model)), button("api_remove_model", () => { models = models.filter(item => item !== model);selectedModels.delete(model.id);modelRows(); }));tr.append(name, apis, context, reasoning, search, actions);body.append(tr);
251
+ const details = button("cap_details", () => modelDetail(model, tr, details));
252
+ details.dataset.modelDetails = "";
253
+ details.setAttribute("aria-expanded", "false");
254
+ details.setAttribute("aria-controls", "connection-model-detail");
255
+ apis.append(group);actions.append(details, button("api_remove_model", () => { models = models.filter(item => item !== model);selectedModels.delete(model.id);modelRows(); }));tr.append(name, apis, context, reasoning, search, actions);body.append(tr);
237
256
  }
238
257
  }
239
258
  function setEndpoints(base, endpoints) { for (const [api, path] of [["messages", "messages"], ["responses", "responses"], ["chat", "chat/completions"]]) apiForm.elements[api + "_url"].value = endpoints?.[api] || base.replace(/\/+$/, "") + "/" + path; }
@@ -207,12 +207,18 @@ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color:
207
207
  .provider-tabs button, .install-platforms button { text-align: center; }
208
208
  .provider-tabs [aria-selected="true"], .provider-tabs [aria-selected="true"]:hover, .install-platforms [aria-pressed="true"], .install-platforms [aria-pressed="true"]:hover { color: var(--page); border-color: var(--accent); background: var(--accent); }
209
209
  .model-catalog table, .model-catalog td { color: var(--text); font-size: 13px; background: var(--surface); }
210
+ .model-catalog table { table-layout: fixed; }
211
+ .model-catalog th:first-child { width: 40%; }
212
+ .model-catalog th:nth-child(2) { width: 25%; }
213
+ .model-catalog th:last-child { width: 35%; }
214
+ .model-catalog td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
210
215
  .model-catalog th { color: var(--text); font-size: 12px; }
211
216
  .model-catalog > summary h2 { color: var(--strong); }
212
217
  .model-catalog .model-name { color: var(--strong); font-weight: 600; }
213
218
  .model-catalog td:last-child { white-space: normal; }
214
219
  .model-catalog td details { margin: 0; }
215
- .model-catalog .failure-detail { min-width: 200px; }
220
+ .model-catalog .failure-detail { min-width: 0; }
221
+ @media (max-width: 700px) { .model-catalog .failure-detail { grid-template-columns: minmax(0, 1fr); gap: 3px; } }
216
222
  #provider-auth td, #provider-clients td { overflow-wrap: anywhere; }
217
223
  .details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
218
224
  @media (max-width: 700px) { .details { grid-template-columns: 1fr; } }
@@ -540,7 +546,8 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
540
546
  /* Model capability and application binding controls share the existing palette. */
541
547
  .client-segments { margin-bottom: 18px; }
542
548
  .client-segments button[aria-pressed="true"], .binding-table button[aria-pressed="true"] { color: var(--page); background: var(--accent); border-color: var(--accent); }
543
- #connection-model-detail { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
549
+ #connection-model-detail { margin: 0; padding: 18px 0; }
550
+ .connection-detail-row > td { white-space: normal; }
544
551
  #connection-model-detail h3 { overflow-wrap: anywhere; }
545
552
  #connection-model-detail .connection-fields { margin-bottom: 18px; }
546
553
  #connection-models td:last-child { min-width: 130px; }
@@ -42,10 +42,10 @@ function safeText(value, length = 160) {
42
42
  function liveModelError(error) {
43
43
  const message = String(error?.message || error || "");
44
44
  const status = /\bHTTP (\d{3})\b/.exec(message)?.[1];
45
- if (status) return `Live model lookup failed (HTTP ${status}). Run ccdx models for details.`;
46
- if (/timed out/i.test(message)) return "Live model lookup timed out. Retry or run ccdx models.";
45
+ if (status) return `Live model lookup failed (HTTP ${status}). Run ccdx app codex models for details.`;
46
+ if (/timed out/i.test(message)) return "Live model lookup timed out. Retry or run ccdx app codex models.";
47
47
  if (/GitHub token not found/i.test(message)) return "GitHub token not found. Start ccdx to sign in.";
48
- return "Live model lookup failed. Run ccdx models for details.";
48
+ return "Live model lookup failed. Run ccdx app codex models for details.";
49
49
  }
50
50
 
51
51
  function animationState(env, home, { includeFrames = false } = {}) {
@@ -252,7 +252,7 @@ export async function handleDashboardApi(req, res, pathname, {
252
252
  const query = new URL(req.url, "http://localhost").searchParams;
253
253
  sendJson(res, 200, animationState(env, home, { includeFrames: query.get("frames") !== "0" }));
254
254
  } catch {
255
- sendJson(res, 409, { error: "Animation settings are invalid; inspect them with ccdx animation" });
255
+ sendJson(res, 409, { error: "Animation settings are invalid; inspect them with ccdx config animation" });
256
256
  }
257
257
  return;
258
258
  }
@@ -286,7 +286,7 @@ export async function handleDashboardApi(req, res, pathname, {
286
286
  applyAnimation?.(body.theme);
287
287
  sendJson(res, 200, { changed: result.changed, ...animationState(env, home) });
288
288
  } catch {
289
- sendJson(res, 409, { error: "Animation setting was not saved; check ccdx animation" });
289
+ sendJson(res, 409, { error: "Animation setting was not saved; check ccdx config animation" });
290
290
  }
291
291
  return;
292
292
  }
package/src/doctor.mjs CHANGED
@@ -224,11 +224,11 @@ export async function collectDoctorChecks({
224
224
  const environment = inspectPredictionEnvironmentFn({ env, platform });
225
225
  checks.push({ kind: environment.summary.tls.extra_ca === "unreadable_or_invalid" ? "warn" : "info", message: formatPredictionEnvironment(environment.summary) });
226
226
  } else checks.push({ kind: "warn", message: "Native predictions require macOS or Windows; existing settings preserved" });
227
- } catch { checks.push({ kind: "warn", message: "Prediction environment could not be verified; existing routing and trust settings preserved", fix: "ccdx prediction status" }); }
227
+ } catch { checks.push({ kind: "warn", message: "Prediction environment could not be verified; existing routing and trust settings preserved", fix: "ccdx app codex prediction status" }); }
228
228
  try {
229
229
  const image = readImageProviderConfigFn({ home, env, strict: true });
230
230
  checks.push({ kind: "info", message: image ? "Image generation configured; no provider request was made" : "Image generation is off; optional checks skipped" });
231
- } catch { checks.push({ kind: "warn", message: "Image provider configuration is invalid; core service is unaffected", fix: "ccdx image-status" }); }
231
+ } catch { checks.push({ kind: "warn", message: "Image provider configuration is invalid; core service is unaffected", fix: "ccdx app codex image status" }); }
232
232
  const updateEnvironment = inspectUpdateEnvironmentFn();
233
233
  const updateMessage = updateEnvironment.state === "different" ? "npm update target differs from this CCDX installation; review PATH/prefix before updating"
234
234
  : updateEnvironment.state === "unavailable" ? "npm update environment could not be verified; installer settings were not changed"
@@ -252,8 +252,8 @@ export async function collectDoctorChecks({
252
252
  const ready = result.state?.m365?.state === "ready" && result.models?.length > 0;
253
253
  checks.push({ kind: ready ? "ok" : "warn", id: "provider", message: ready
254
254
  ? `Microsoft 365 is ready; ${result.models.length} GPT models available`
255
- : "Microsoft 365 is not ready; inspect ccdx m365 status. No GitHub fallback was selected" });
256
- } catch { checks.push({ kind: "warn", id: "provider", message: "Microsoft 365 could not be checked through the running adapter; start ccdx and inspect ccdx m365 status" }); }
255
+ : "Microsoft 365 is not ready; inspect ccdx source m365 status. No GitHub fallback was selected" });
256
+ } catch { checks.push({ kind: "warn", id: "provider", message: "Microsoft 365 could not be checked through the running adapter; start ccdx and inspect ccdx source m365 status" }); }
257
257
  } else if (!sourceError) checks.push(...await inspectAuthProfilesOnline({
258
258
  home,
259
259
  profile,
package/src/image-mcp.mjs CHANGED
@@ -221,7 +221,7 @@ export function createImageMcpHandler({
221
221
  instructions: config && isEnabled()
222
222
  ? `CCDX handles the configured image API and credentials; no Python or SDK setup. Embed returned image Markdown in the final reply. Redisplay reuses it without tool calls. Keep each image_id with its own image. Do not automatically retry failed/timed-out requests or switch providers.${supportsImageEditing(config) ? " Use generate_image for new images; edit_image requires the exact retained source ID." : " Use generate_image for new images. Editing is unsupported; do not substitute generation."}`
223
223
  : config ? "Image calls are paused. Resume them in the CCDX WebUI; the provider and retained edit handles are preserved."
224
- : "Image generation is disabled. Enable it with ccdx enable-image before requesting images.",
224
+ : "Image generation is disabled. Enable it with ccdx app codex image setup before requesting images.",
225
225
  });
226
226
  return;
227
227
  }
@@ -248,7 +248,7 @@ export function createImageMcpHandler({
248
248
  if (!config || !isEnabled()) {
249
249
  metrics.failed += 1;
250
250
  if (!config) imageReferences.clear();
251
- reply({ content: [{ type: "text", text: config ? "Image calls are paused. Resume them in the CCDX WebUI." : "Image generation is disabled. Run ccdx enable-image first." }], isError: true });
251
+ reply({ content: [{ type: "text", text: config ? "Image calls are paused. Resume them in the CCDX WebUI." : "Image generation is disabled. Run ccdx app codex image setup first." }], isError: true });
252
252
  return;
253
253
  }
254
254
  const editing = request.params.name === EDIT_TOOL_NAME;
@@ -9,7 +9,7 @@ export async function requestPredictionFix({ host = "127.0.0.1", port = 2026, fe
9
9
  requiredCapabilities: [PREDICTION_FIX_CAPABILITY] });
10
10
  if (!probe.ok) throw new Error(probe.incompatible
11
11
  ? "The running adapter lacks compatible prediction repair. Upgrade and restart the CCDX service once; the App was not restarted."
12
- : "Could not reach a running CCDX adapter. Start ccdx, then retry ccdx prediction fix.");
12
+ : "Could not reach a running CCDX adapter. Start ccdx, then retry ccdx app codex prediction repair.");
13
13
  const signal = AbortSignal.timeout(timeoutMs);
14
14
  const response = await fetchImpl(probe.baseUrl + ADAPTER_PREDICTION_FIX_PATH, {
15
15
  method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" },
@@ -114,7 +114,7 @@ export function readPredictionCertificate(directory, { allowExpired = false, pla
114
114
  if (!x509.publicKey.export({ type: "spki", format: "der" }).equals(publicKey)
115
115
  || (!allowExpired && Date.parse(x509.validTo) <= Date.now()) || !x509.checkHost("chatgpt.com") || !x509.checkHost("ab.chatgpt.com")
116
116
  || !x509.verify(ca.publicKey) || !ca.ca || x509.ca) {
117
- throw new Error("Prediction certificate needs renewal; quit Codex and run ccdx prediction on");
117
+ throw new Error("Prediction certificate needs renewal; quit Codex and run ccdx app codex prediction setup");
118
118
  }
119
119
  return { cert, key, ca: ca.toString(), hash: createHash("sha256").update(ca.raw).digest("hex").toUpperCase(), der: ca.raw };
120
120
  }
@@ -88,7 +88,7 @@ export function windowsPredictionProfile({ app, env = process.env, preferredProf
88
88
  const profiles = [...new Set(candidates)].filter(candidate => fs.existsSync(path.win32.join(candidate, "Local State")));
89
89
  if (profiles.length !== 1) throw new Error(profiles.length
90
90
  ? "Multiple Codex App profiles found; set CODEX_ELECTRON_USER_DATA_PATH to the active profile"
91
- : "Open Codex App once, fully quit it, then run ccdx prediction on; its Windows profile was not found");
91
+ : "Open Codex App once, fully quit it, then run ccdx app codex prediction setup; its Windows profile was not found");
92
92
  return profiles[0];
93
93
  }
94
94
 
@@ -35,7 +35,7 @@ async function runPredictionCommandUnlocked({ action = "status", env = process.e
35
35
  const settings = readPredictionSettings(opts);
36
36
  if (action === "fix") {
37
37
  if (!settings.enabled) {
38
- output("Input suggestions are off. Nothing changed.\nTo enable: ccdx prediction on");
38
+ output("Input suggestions are off. Nothing changed.\nTo enable: ccdx app codex prediction setup");
39
39
  return { status: "disabled", exitCode: 0 };
40
40
  }
41
41
  if (!repairRuntime) throw new Error("Start a CCDX version that supports suggestion repair.");
@@ -45,12 +45,12 @@ async function runPredictionCommandUnlocked({ action = "status", env = process.e
45
45
  if (prediction.environment) output(formatPredictionEnvironment(prediction.environment));
46
46
  if (result.status === "disabled") output("The running adapter has predictions off; no feature was enabled.");
47
47
  else if (result.status === "needs_service_restart") output("Node trust settings changed. Restart the CCDX service to apply them; no certificate or App was changed.");
48
- else if (result.status === "environment_preserved") output(`Network recheck failed; the existing bridge and routes were preserved. ${result.environment_error?.message || "Check ccdx prediction status."}`);
48
+ else if (result.status === "environment_preserved") output(`Network recheck failed; the existing bridge and routes were preserved. ${result.environment_error?.message || "Check ccdx app codex prediction status."}`);
49
49
  else if (prediction.bridge !== "running") output(prediction.reason || "Prediction bridge is unavailable; core service was not changed.");
50
50
  else if (prediction.environment?.status === "needs_app_relaunch") output("Network settings changed. The bridge uses the new snapshot, but the App may cache its earlier PAC. Fully quit Codex, then run ccdx; no App was restarted.");
51
51
  else if (result.app_route === "verified") output("App launch route verified. A visible suggestion still needs an App-side check.");
52
52
  else if (result.app_route === "closed") output("Bridge is ready. Run ccdx to open Codex with its prediction route.");
53
- else if (result.status === "route_unverified") output("Bridge is ready, but App route inspection was unavailable or ambiguous. Check ccdx prediction status; no App was restarted.");
53
+ else if (result.status === "route_unverified") output("Bridge is ready, but App route inspection was unavailable or ambiguous. Check ccdx app codex prediction status; no App was restarted.");
54
54
  else output("Bridge is ready, but the running App route is not verified. No App was restarted. Fully quit Codex, then run ccdx to attach the route.");
55
55
  return { ...result, exitCode: ["ready", "disabled"].includes(result.status) ? 0 : 1 };
56
56
  }
@@ -88,7 +88,7 @@ async function runPredictionCommandUnlocked({ action = "status", env = process.e
88
88
  if (certificate.hash !== settings.certificateHash) throw new Error("Prediction certificate changed; trust cleanup was skipped");
89
89
  await updatePredictionTrust(settings.store, certificate, { remove: true });
90
90
  } catch (error) {
91
- output(`Predictions disabled. ${error.message}. Quit Codex and run ccdx prediction off again to finish cleanup.`);
91
+ output(`Predictions disabled. ${error.message}. Quit Codex and run ccdx app codex prediction remove again to finish cleanup.`);
92
92
  return { ...settings, enabled: false, cleanupPending: true };
93
93
  }
94
94
  }
@@ -171,7 +171,7 @@ export async function startNativePrediction({ env = process.env, platform = proc
171
171
  const current = (options.resolveApp || installedPredictionApp)({ ...opts,
172
172
  ...(platform === "win32" && settings.app?.profile ? { preferredProfile: settings.app.profile } : {}) });
173
173
  if (current.app !== settings.app?.app || (platform === "win32" && current.profile !== settings.app?.profile)) {
174
- throw new Error("Codex App identity/profile changed; run ccdx prediction on after quitting it to recheck compatibility");
174
+ throw new Error("Codex App identity/profile changed; run ccdx app codex prediction setup after quitting it to recheck compatibility");
175
175
  }
176
176
  const settingsFile = predictionPaths(opts).settings;
177
177
  await withFileLock(`${settingsFile}.lock`, () => {
@@ -183,7 +183,7 @@ export async function startNativePrediction({ env = process.env, platform = proc
183
183
  warning("Codex App compatibility rechecked; prediction port and trust were preserved");
184
184
  }
185
185
  const paths = predictionPaths({ ...opts, app: settings.app });
186
- if (settings.store !== paths.store || !fs.existsSync(paths.store)) throw new Error("Prediction profile trust is unavailable; run ccdx prediction on after quitting Codex");
186
+ if (settings.store !== paths.store || !fs.existsSync(paths.store)) throw new Error("Prediction profile trust is unavailable; run ccdx app codex prediction setup after quitting Codex");
187
187
  const certificate = readPredictionCertificate(certificateDirectory(settings, paths), opts);
188
188
  if (certificate.hash !== settings.certificateHash) throw new Error("Prediction certificate changed; setup must be checked again");
189
189
  const [{ startPredictionTransport }, { applyNativePredictionOverlay, normalizeStatsigRequest }, { createProxyAgent }] = await Promise.all([
@@ -30,11 +30,11 @@ export function installedUpdateEnvironment(options = {}) {
30
30
  if (inspectWindowsCommand({ packageRoot: environment.target }).status !== 'ready') throw new Error('command_not_owned');
31
31
  } else {
32
32
  const privateInstall = options.env?.CCDX_PRIVATE_INSTALL_PREFIX || process.env.CCDX_PRIVATE_INSTALL_PREFIX;
33
- for (const name of ['ccdx','codex-copilot-dx']) {
33
+ for (const name of ['ccdx']) {
34
34
  const file = path.join(environment.prefix,'bin',name);
35
35
  if (privateInstall && path.resolve(privateInstall) === path.resolve(environment.prefix)) {
36
36
  if (readBoundedFileSync(file,{encoding:'utf8',maxBytes:16384}) !== privateUnixLauncher({...environment,name})) throw new Error('command_not_owned');
37
- } else if (fs.realpathSync(file) !== fs.realpathSync(path.join(environment.target,'bin',name === 'ccdx' ? 'cli.mjs' : 'codex-copilot-dx.mjs'))) throw new Error('command_not_owned');
37
+ } else if (fs.realpathSync(file) !== fs.realpathSync(path.join(environment.target,'bin','cli.mjs'))) throw new Error('command_not_owned');
38
38
  }
39
39
  }
40
40
  return { ...environment, npmCli: cli };
@@ -132,7 +132,7 @@ function createBuiltinProviderRuntime({ githubClient, githubRegistry, refreshGit
132
132
  return { ...result, binding: readM365Account(options) };
133
133
  }
134
134
  async function selectAccount(id) {
135
- if (typeof id !== "string" || !/^[a-f0-9]{64}$/.test(id)) throw Object.assign(new Error("Use an account ID from ccdx m365 accounts"), { statusCode: 400 });
135
+ if (typeof id !== "string" || !/^[a-f0-9]{64}$/.test(id)) throw Object.assign(new Error("Use an account ID from ccdx source m365 accounts"), { statusCode: 400 });
136
136
  if (!enabled) throw unavailable("m365_disabled");
137
137
  if (activeM365Requests > 0 || gateway?.snapshot?.().active > 0 || pending) {
138
138
  throw Object.assign(new Error(m365AccountMessage("m365_account_busy")), { code: "m365_account_busy", statusCode: 409 });
@@ -54,7 +54,7 @@ export function publicM365Accounts(accounts, { binding, windowsLogin } = {}) {
54
54
  }
55
55
 
56
56
  export function m365AccountMessage(code) {
57
- return ({ m365_account_ambiguous: "Choose a company account in Model sources or run ccdx m365 account.",
57
+ return ({ m365_account_ambiguous: "Choose a company account in Model sources or run ccdx source m365 account.",
58
58
  m365_account_unavailable: "Company account unavailable. Connect it in Windows or macOS, then check again.",
59
59
  m365_account_conflict: "Account records conflict. Check your company sign-in, then check again.",
60
60
  m365_interaction_required: "Complete your company sign-in, then check again.",
@@ -85,26 +85,22 @@ export function packageMetadata(bytes, { complete = false } = {}) {
85
85
  if (metadata?.name !== "codex-copilot-dx" || !stableVersion(metadata.version)) throw new Error("Release package identity is invalid");
86
86
  return metadata;
87
87
  }
88
- export function runtimeReleaseTarget({ platform = process.platform, arch = process.arch, libc } = {}) {
89
- if (!["darwin", "win32", "linux"].includes(platform) || !["x64", "arm64"].includes(arch)) throw new Error("No complete Release package is available for this platform");
90
- if (platform !== "linux") return `${platform}-${arch}`;
91
- libc ||= process.report?.getReport().header.glibcVersionRuntime ? "glibc" : "musl";
92
- if (!["glibc", "musl"].includes(libc)) throw new Error("Unsupported Linux runtime");
93
- return `${platform}-${arch}-${libc}`;
88
+ export function runtimeReleaseTarget({ platform = process.platform, arch = process.arch } = {}) {
89
+ if (!["darwin", "win32"].includes(platform) || !["x64", "arm64"].includes(arch)) {
90
+ throw new Error("CCDX supports macOS and Windows on x64 or arm64");
91
+ }
92
+ return `${platform}-${arch}`;
94
93
  }
95
94
  export function remoteDownloadDenied(error) {
96
95
  return error?.npmCode === "EALLOWREMOTE" || /(?:^|\n)npm (?:error|ERR!) code EALLOWREMOTE(?:\r?\n|$)/.test(String(error?.stderr || ""));
97
96
  }
98
- export async function downloadRelease(tag, { fetchImpl = fetch, directory, signal, complete = false, preferComplete = false, platform, arch, libc } = {}) {
97
+ export async function downloadRelease(tag, { fetchImpl = fetch, directory, signal, complete = false, preferComplete = false, platform, arch } = {}) {
98
+ const target = runtimeReleaseTarget({ platform, arch });
99
99
  const version = stableVersion(tag);if (!version) throw new Error("A valid stable GitHub release tag is required");
100
100
  const base = `${RELEASE_BASE}/v${version}`;
101
101
  const manifest = await releaseBytes(`${base}/SHA256SUMS`, { fetchImpl, maxBytes: 65536, signal });
102
- let name = `codex-copilot-dx-${version}.tgz`, target;
102
+ let name = `codex-copilot-dx-${version}.tgz`;
103
103
  if (complete || preferComplete) {
104
- if (complete) target = runtimeReleaseTarget({ platform, arch, libc });
105
- else {
106
- try { target = runtimeReleaseTarget({ platform, arch, libc }); } catch { /* Other platforms retain the source-only bootstrap path. */ }
107
- }
108
104
  if (target) {
109
105
  const runtimeName = `codex-copilot-dx-${version}-${target}.tgz`;
110
106
  if (complete || manifest.toString("utf8").split(/\r?\n/).some(line => line.endsWith(` ${runtimeName}`))) { name = runtimeName;complete = true; }
@@ -191,14 +187,14 @@ export function verifyPackageRuntime(target, version, { brokerRequired = false }
191
187
 
192
188
  export function privateUnixLauncher({ prefix, target, name, node = process.execPath }) {
193
189
  const quote = value => "'" + value.replaceAll("'", "'\\''") + "'";
194
- const cli = path.join(target, "bin", name === "ccdx" ? "cli.mjs" : "codex-copilot-dx.mjs");
190
+ const cli = path.join(target, "bin", "cli.mjs");
195
191
  return `#!/bin/sh\nPATH=${quote(path.dirname(node))}:"$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(node)} ${quote(cli)} "$@"\n`;
196
192
  }
197
193
  export async function writePrivateLaunchers({ prefix, target }) {
198
194
  const windows = process.platform === "win32"
199
195
  ? await import(pathToFileURL(path.join(target, "src", "windows-command.mjs")).href) : null;
200
- for (const name of ["ccdx", "codex-copilot-dx"]) {
201
- const cli = path.join(target, "bin", name === "ccdx" ? "cli.mjs" : "codex-copilot-dx.mjs");
196
+ for (const name of ["ccdx"]) {
197
+ const cli = path.join(target, "bin", "cli.mjs");
202
198
  if (windows) {
203
199
  fs.writeFileSync(path.join(prefix, `${name}.cmd`), windows.privateWindowsCommand({ node: process.execPath, cli, prefix }));
204
200
  } else {
@@ -55,17 +55,21 @@ export function createStartupPresentation({ output = process.stdout, errorOutput
55
55
  return { enabled, warnings, finish: clear,
56
56
  log(method, args) {
57
57
  const message = redactDiagnosticText(format(...args));
58
- const warning = method === "error" || method === "warn" || /^\s*\[(?:WARN|ERR)\]/.test(message);
59
- const check = /^\[(?:OK|INFO|WAIT)\]\s+([A-Za-z-]+)\s+(.*)$/.exec(message);
60
- if (!enabled || warning || !check || ["Sign-in", "GitHub"].includes(check[1]) && !/GitHub token found|saved sign-in/i.test(check[2])) {
61
- clear();(warning ? errorOutput : output).write(message + "\n");
62
- if (warning && warnings.length < 100) warnings.push([method, args]);return;
58
+ for (const line of message.split("\n")) {
59
+ const warning = method === "error" || method === "warn" || /^\s*\[(?:WARN|ERR)\]/.test(line);
60
+ const check = /^\[(?:OK|INFO|WAIT)\]\s+([A-Za-z-]+)\s+(.*)$/.exec(line);
61
+ if (!enabled || warning || !check || ["Sign-in", "GitHub"].includes(check[1]) && !/GitHub token found|saved sign-in/i.test(check[2])) {
62
+ clear();
63
+ (warning ? errorOutput : output).write(line + "\n");
64
+ if (warning && warnings.length < 100) warnings.push([method, [line]]);
65
+ continue;
66
+ }
67
+ const scope = ["App", "Config", "Suggestions", "Images"].includes(check[1]) ? "Codex" : check[1] === "Claude" ? "Apps" : check[1];
68
+ let text = `Starting · ${scope}`;
69
+ if (["Service", "Models", "Sources", "M365"].includes(scope)) text += ` · ${check[2]}`;
70
+ while (displayWidth(text) >= (output.columns || 80)) text = [...text].slice(0, -1).join("");
71
+ clear();output.write(`\r\x1b[2K${text}`);visible = true;
63
72
  }
64
- const scope = ["App", "Config", "Suggestions", "Images"].includes(check[1]) ? "Codex" : check[1] === "Claude" ? "Apps" : check[1];
65
- let text = `Starting · ${scope}`;
66
- if (["Service", "Models", "Sources", "M365"].includes(scope)) text += ` · ${check[2]}`;
67
- while (displayWidth(text) >= (output.columns || 80)) text = [...text].slice(0, -1).join("");
68
- clear();output.write(`\r\x1b[2K${text}`);visible = true;
69
73
  },
70
74
  };
71
75
  }
@@ -81,7 +85,7 @@ export function predictionStartupCheck(prediction) {
81
85
  const warning = prediction.bridge !== "running" || problem || prediction.launch_route === "unverified";
82
86
  const lines = [startupCheck(warning ? "warn" : "info", "Suggestions", detail)];
83
87
  if (prediction.bridge !== "running" && prediction.reason) lines.push(startupCheck("warn", "Reason", prediction.reason));
84
- if (warning) lines.push(startupCheck("info", "Details", "ccdx prediction status"));
88
+ if (warning) lines.push(startupCheck("info", "Details", "ccdx app codex prediction status"));
85
89
  return lines.join("\n");
86
90
  }
87
91
 
@@ -79,20 +79,21 @@ export function createTerminalConsole({ output = process.stdout, errorOutput = p
79
79
  if (dirty) {
80
80
  const usage = data.runtime_usage || {}, view = projection;
81
81
  const heading = readFailed ? updatedAt === null ? "Status unavailable" : `Previous data / ${new Date(updatedAt).toLocaleTimeString("en-GB")}`
82
- : `${baseUrl ? `Listening · ${baseUrl}` : "Listening"} · up ${terminalUptime(data.uptime_ms)}`;
82
+ : `Running · up ${terminalUptime(data.uptime_ms)}`;
83
+ const webAddress = baseUrl ? `Web UI: ${baseUrl}` : "Web UI: address unavailable";
83
84
  const sourceHeader = view.sources ? `Enabled sources: ${view.sources.length}` : "Enabled sources: unknown";
84
85
  const appSize = width < 64 ? 13 : 15, setupSize = Math.max(10, Math.min(20, width - appSize - 7));
85
86
  const appRows = view.clients.map(client => `${clip(client.name, appSize - 1).padEnd(appSize)}${clip(client.setup, setupSize - 1).padEnd(setupSize)}${String(readFailed || client.active === null ? "—" : client.active).padStart(6)}`);
86
87
  const issue = view.issue?.label;
87
88
  const notice = notices ? `${notices} ${notices === 1 ? "notice" : "notices"}${issue ? ` · last model issue: ${issue}` : " · ccdx status --details"}` : issue ? `Last model issue: ${issue}` : "No notices";
88
- content = [clip(heading, width), sourceHeader,
89
+ content = [clip(heading, width), clip(webAddress, width), sourceHeader,
89
90
  ...(view.sources ? wrap(view.sources.map(source => source.name).join(" · "), width) : []),
90
91
  `${"App".padEnd(appSize)}${"Setup".padEnd(setupSize)}${"Active".padStart(6)}`, ...appRows,
91
92
  ...table(width, usage, view.requests, readFailed ? null : view.active, key => view.outcomes[key]),
92
- clip("Web: ccdx web · Help: ccdx help · Ctrl+C: stop", width), clip(notice, width)];
93
+ clip("Help: ccdx help · Stop: Ctrl+C", width), clip(notice, width)];
93
94
  if (content.length + 1 >= (Number(output.rows) || 24)) {
94
95
  const grouped = Object.entries(view.clients.reduce((counts, client) => ({ ...counts, [client.setup]: (counts[client.setup] || 0) + 1 }), {})).map(([state, count]) => `${count} ${state.toLowerCase()}`).join(" · ");
95
- content = [clip(heading, width), sourceHeader, clip(`Apps: ${grouped}`, width),
96
+ content = [clip(readFailed ? heading : webAddress, width), sourceHeader, clip(`Apps: ${grouped}`, width),
96
97
  ...table(width, usage, view.requests, readFailed ? null : view.active, key => view.outcomes[key], true), clip(notice, width)];
97
98
  }
98
99
  dirty = false;
@@ -4,7 +4,7 @@ const integer = value => Number.isSafeInteger(value) && value >= 0;
4
4
  const appIds = { codex_app: "codex", codex_cli: "codex", codex: "codex", claude_app: "claude_app", claude_code: "claude_code" };
5
5
  export const TERMINAL_CLIENT_NAMES = Object.freeze({ codex: "Codex", claude_app: "Claude App", claude_code: "Claude Code" });
6
6
  const labels = { configured: "Configured", paused: "Paused", disabled: "Disabled", not_configured: "Not configured", not_installed: "Not installed",
7
- preserved: "Preserved", partially_preserved: "Partly preserved", manual_sync: "Manual sync", default_unavailable: "Default unavailable", configuration_unavailable: "Unreadable", unavailable: "Unavailable" };
7
+ preserved: "Unchanged", partially_preserved: "Partly unchanged", manual_sync: "Manual sync", default_unavailable: "Default unavailable", configuration_unavailable: "Unreadable", unavailable: "Unavailable" };
8
8
  export function terminalUptime(milliseconds) {
9
9
  if (!Number.isFinite(milliseconds) || milliseconds < 0) return "unknown";
10
10
  const minutes = Math.floor(milliseconds / 60000), hours = Math.floor(minutes / 60), days = Math.floor(hours / 24);
package/src/usage.mjs CHANGED
@@ -36,28 +36,28 @@ function cacheHitPercent(usage) {
36
36
  }
37
37
 
38
38
  function providerSummaryLines(summary) {
39
- if (summary.provider_filter) return [`Provider: ${summary.provider_filter}`];
39
+ if (summary.provider_filter) return [`Provider: ${terminalCell(summary.provider_filter)}`];
40
40
  const sources = Object.entries(summary.providers || {}).filter(([, count]) => count > 0);
41
41
  return sources.some(([id]) => id !== "github")
42
- ? [`Providers: ${sources.map(([id, count]) => `${id} ${fmt(count)}`).join(" / ")} (combined totals; use --provider to separate)`] : [];
42
+ ? [`Providers: ${sources.map(([id, count]) => `${terminalCell(id)} ${fmt(count)}`).join(" / ")} (combined totals; use --provider to separate)`] : [];
43
43
  }
44
44
 
45
45
  function formatPlainUsageSummary(summary, filePath, { sanitize = false } = {}) {
46
- const lines = [`Usage log: ${filePath}`];
46
+ const lines = [`Usage log: ${terminalCell(filePath)}`];
47
47
  lines.push(...providerSummaryLines(summary));
48
48
  if (summary.requests === 0) {
49
49
  lines.push("No usage records yet.");
50
50
  return (sanitize ? lines.map((line) => terminalCell(line, { fallback: "" })) : lines).join("\n");
51
51
  }
52
52
  lines.push(
53
- `Requests: ${fmt(summary.requests)}`,
53
+ `Records: ${fmt(summary.requests)}`,
54
54
  `Tokens: input=${fmt(summary.totals.input_tokens)} cache_read=${fmt(cacheReadTokens(summary.totals))} output=${fmt(summary.totals.output_tokens)} total=${fmt(summary.totals.total_tokens)}`,
55
55
  `Cache hit: ${cacheHitPercent(summary.totals)} (cached/input tokens)`,
56
56
  "",
57
57
  "By model:",
58
58
  );
59
59
  for (const [model, row] of Object.entries(usageModelGroups(summary))) {
60
- lines.push(` ${model}: requests=${fmt(row.requests)} input=${fmt(row.input_tokens)} cache_read=${fmt(cacheReadTokens(row))} output=${fmt(row.output_tokens)} total=${fmt(row.total_tokens)} cache_hit=${cacheHitPercent(row)}`);
60
+ lines.push(` ${terminalCell(model)}: records=${fmt(row.requests)} input=${fmt(row.input_tokens)} cache_read=${fmt(cacheReadTokens(row))} output=${fmt(row.output_tokens)} total=${fmt(row.total_tokens)} cache_hit=${cacheHitPercent(row)}`);
61
61
  }
62
62
  return (sanitize ? lines.map((line) => terminalCell(line, { fallback: "" })) : lines).join("\n");
63
63
  }
@@ -56,13 +56,13 @@ export function inspectWindowsCommand({ platform = process.platform,
56
56
  try {
57
57
  const pkg = JSON.parse(readBoundedFileSync(path.join(root, "package.json"), { encoding: "utf8", maxBytes: 64 * 1024 }));
58
58
  if (pkg.name !== "codex-copilot-dx" || pkg.bin?.ccdx !== "bin/cli.mjs"
59
- || pkg.bin?.["codex-copilot-dx"] !== "bin/codex-copilot-dx.mjs") throw new Error();
59
+ ) throw new Error();
60
60
  } catch { return { status: "preserved", changed: false }; }
61
61
  if (repair && !locked) return withFileLockSync(path.join(root, ".ccdx-command.lock"),
62
62
  () => inspectWindowsCommand({ platform, packageRoot, repair, locked: true }), { timeoutMs: 1000 });
63
63
  const prefix = path.dirname(path.dirname(root));
64
64
  const results = [];
65
- for (const [name, script] of [["ccdx", "cli.mjs"], ["codex-copilot-dx", "codex-copilot-dx.mjs"]]) {
65
+ for (const [name, script] of [["ccdx", "cli.mjs"]]) {
66
66
  const ps1 = path.join(prefix, `${name}.ps1`), cmd = path.join(prefix, `${name}.cmd`);
67
67
  const target = `node_modules/codex-copilot-dx/bin/${script}`;
68
68
  try {
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const configDoctor = ["doctor", "--doctor"].includes(process.argv[2]) && process.argv[3] === "config";
4
- if (process.stderr.isTTY === true && !configDoctor) {
5
- const {
6
- LEGACY_COMMAND_WARNING,
7
- shouldShowLegacyCommandWarning,
8
- } = await import("../src/legacy-command-warning.mjs");
9
- if (shouldShowLegacyCommandWarning({ interactive: true })) console.warn(LEGACY_COMMAND_WARNING);
10
- }
11
- await import("./cli.mjs");
@@ -1,94 +0,0 @@
1
- import { status } from "./status.mjs";
2
- import {
3
- cliOutputFormat,
4
- cliOutputWidth,
5
- formatResponsiveCliTable,
6
- terminalCell,
7
- } from "./cli-table.mjs";
8
-
9
- export { fetchLiveCopilotModels, selectableCopilotModels } from "./live-models.mjs";
10
-
11
- function safeText(value, fallback = "") {
12
- const text = String(value ?? "")
13
- .replace(/[\u0000-\u001f\u007f-\u009f]/g, " ")
14
- .replace(/\s+/g, " ")
15
- .trim();
16
- return text || fallback;
17
- }
18
-
19
- function liveCatalogHeader(catalog, { commandName, models }) {
20
- const responses = models.filter((model) => model.endpoints.includes("responses")).length;
21
- const chat = models.filter((model) => model.endpoints.includes("chat")).length;
22
- return [
23
- `${commandName} models`,
24
- status("ok", catalog?.source === "configured" ? `Configured models from ${safeText(catalog.upstreamHost)}: ${models.length}; access not checked`
25
- : `${catalog?.source === "catalog" ? "Available catalog" : "Live catalog"} from ${safeText(catalog?.upstreamHost, "GitHub Copilot")}: ${models.length} selectable GPT models of ${Number(catalog?.advertised) || 0} advertised`),
26
- status("info", `Responses: ${responses}; Chat: ${chat}`),
27
- ];
28
- }
29
-
30
- function formatLiveCopilotModelsPlain(catalog, { commandName, models }, { sanitize = false } = {}) {
31
- const lines = liveCatalogHeader(catalog, { commandName, models });
32
- if (!models.length) {
33
- lines.push(status("warn", "No selectable GPT models listed."));
34
- return (sanitize ? lines.map((line) => terminalCell(line, { fallback: "" })) : lines).join("\n");
35
- }
36
-
37
- let vendor = "";
38
- for (const model of models) {
39
- if (model.vendor !== vendor) {
40
- vendor = model.vendor;
41
- lines.push("", `${vendor}:`);
42
- }
43
- const flags = [...model.endpoints, ...(model.preview ? ["preview"] : [])];
44
- lines.push(` ${model.id} [${flags.join(", ")}]`);
45
- }
46
- return (sanitize ? lines.map((line) => terminalCell(line, { fallback: "" })) : lines).join("\n");
47
- }
48
-
49
- export function formatLiveCopilotModels(catalog, {
50
- commandName = "ccdx",
51
- format = "plain",
52
- output = process.stdout,
53
- width = cliOutputWidth(output),
54
- } = {}) {
55
- const models = Array.isArray(catalog?.models) ? catalog.models : [];
56
- const context = { commandName, models };
57
- if (cliOutputFormat(format, output) === "plain") {
58
- return formatLiveCopilotModelsPlain(catalog, context);
59
- }
60
-
61
- const lines = liveCatalogHeader(catalog, context);
62
- if (!models.length) {
63
- lines.push(status("warn", "No selectable GPT models listed."));
64
- return lines.join("\n");
65
- }
66
-
67
- const rows = models.map((model) => ({
68
- vendor: model.vendor,
69
- model: model.id,
70
- vendorModel: `${model.vendor}/${model.id}`,
71
- apis: model.endpoints.join(", "),
72
- preview: model.preview ? "yes" : "no",
73
- }));
74
- const table = formatResponsiveCliTable({
75
- columns: [
76
- { key: "vendor", label: "VENDOR" },
77
- { key: "model", label: "MODEL" },
78
- { key: "apis", label: "APIS" },
79
- { key: "preview", label: "PREVIEW" },
80
- ],
81
- compactColumns: [
82
- { key: "vendorModel", label: "VENDOR/MODEL" },
83
- { key: "apis", label: "APIS" },
84
- { key: "preview", label: "PREVIEW" },
85
- ],
86
- rows,
87
- width,
88
- });
89
- if (format === "auto" && table.overflow) {
90
- return formatLiveCopilotModelsPlain(catalog, context, { sanitize: true });
91
- }
92
- lines.push("", table.output);
93
- return lines.join("\n");
94
- }