codex-copilot-dx 1.1.1 → 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.
Files changed (46) hide show
  1. package/README.md +10 -11
  2. package/bin/cli.mjs +23 -23
  3. package/docs/ARCHITECTURE.md +40 -6
  4. package/docs/REFERENCE.md +128 -94
  5. package/package.json +6 -4
  6. package/src/auth-device-flow.mjs +1 -1
  7. package/src/auth-status.mjs +1 -1
  8. package/src/auto-review-model.mjs +2 -2
  9. package/src/claude-client-lifecycle.mjs +33 -0
  10. package/src/claude-gateway.mjs +15 -6
  11. package/src/cli-auth.mjs +6 -6
  12. package/src/cli-cache.mjs +5 -5
  13. package/src/cli-image.mjs +1 -1
  14. package/src/cli-m365.mjs +5 -5
  15. package/src/cli-models.mjs +2 -2
  16. package/src/cli-options.mjs +26 -26
  17. package/src/cli-status.mjs +6 -1
  18. package/src/dashboard/console.js +112 -38
  19. package/src/dashboard/index.html +122 -90
  20. package/src/dashboard/language.js +791 -362
  21. package/src/dashboard/status.js +53 -41
  22. package/src/dashboard/ui.css +13 -0
  23. package/src/dashboard/ui.js +31 -28
  24. package/src/dashboard/usage.js +16 -16
  25. package/src/dashboard-api.mjs +2 -0
  26. package/src/doctor.mjs +4 -4
  27. package/src/http-transport.mjs +3 -2
  28. package/src/launcher.mjs +8 -8
  29. package/src/native-prediction.mjs +3 -3
  30. package/src/operation-error.mjs +12 -7
  31. package/src/package-update.mjs +43 -11
  32. package/src/prediction-retirement.mjs +2 -7
  33. package/src/provider-metadata.mjs +2 -1
  34. package/src/provider-registry.mjs +19 -0
  35. package/src/provider-runtime.mjs +42 -33
  36. package/src/provider-settings.mjs +2 -1
  37. package/src/release-install.mjs +192 -0
  38. package/src/response-failures.mjs +2 -1
  39. package/src/service-control.mjs +7 -8
  40. package/src/startup-ui.mjs +17 -9
  41. package/src/stream-performance.mjs +29 -1
  42. package/src/terminal-console.mjs +43 -15
  43. package/src/usage-store.mjs +10 -5
  44. package/src/user-settings.mjs +16 -3
  45. package/src/version.mjs +2 -6
  46. package/src/windows-command.mjs +13 -1
@@ -56,7 +56,7 @@ function parseOptions(args, schema) {
56
56
 
57
57
  const value = args[index + 1];
58
58
  if (value === undefined || !String(value).trim() || String(value).startsWith("-")) {
59
- throw new Error(`Missing value for ${option}`);
59
+ throw new Error(`Enter a value for ${option}`);
60
60
  }
61
61
  parsed[option] = value;
62
62
  index += 1;
@@ -162,7 +162,7 @@ export function parseCliArgs(args = []) {
162
162
  if (!["status", "models", "switch", "on", "off", "remove"].includes(action)) throw new Error("M365 action must be status, models, switch, on, off or remove");
163
163
  let provider, remaining = args;
164
164
  if (action === "switch" && args[0] && !args[0].startsWith("--")) { provider = args[0];remaining = args.slice(1); }
165
- if (provider && !["github", "m365"].includes(provider)) throw new Error("Provider must be github or m365");
165
+ if (provider && !["github", "m365"].includes(provider)) throw new Error("Choose github or m365");
166
166
  const values = parseOptions(remaining, new Map(action === "switch" ? [["--model", "value"], ["--auto-review-model", "value"]] : []));
167
167
  return baseCommand("m365", { action, provider, model: values["--model"], autoReviewModel: values["--auto-review-model"] });
168
168
  }
@@ -172,7 +172,7 @@ export function parseCliArgs(args = []) {
172
172
  }
173
173
  if (command === "usage") {
174
174
  const options = parseOptions(rest, new Map([["--format", "value"], ["--provider", "value"]]));
175
- if (options["--provider"] && !isProviderId(options["--provider"])) throw new Error("Usage provider must be a valid provider ID");
175
+ if (options["--provider"] && !isProviderId(options["--provider"])) throw new Error("Enter a valid source ID.");
176
176
  return baseCommand("usage", { ...outputFormatOption(options["--format"]), ...(options["--provider"] ? { provider: options["--provider"] } : {}) });
177
177
  }
178
178
  if (command === "cache") {
@@ -189,7 +189,7 @@ export function parseCliArgs(args = []) {
189
189
  ["--yes", "flag"],
190
190
  ]));
191
191
  if (options["--limit"] && options["--clean"]) {
192
- throw new Error("Use --limit or --clean in one cache command, not both");
192
+ throw new Error("Use either --limit or --clean.");
193
193
  }
194
194
  if ((options["--history"] || options["--yes"]) && !options["--clean"]) {
195
195
  throw new Error("--history and --yes require --clean");
@@ -241,7 +241,7 @@ export function parseCliArgs(args = []) {
241
241
  }
242
242
  if (command === "auth") {
243
243
  const [action, ...authArgs] = rest;
244
- if (!action) throw new Error("Missing auth action: expected status or login");
244
+ if (!action) throw new Error("Choose auth status or auth login.");
245
245
  if (action === "status") {
246
246
  const options = parseOptions(authArgs, new Map([
247
247
  ["--online", "flag"],
@@ -259,7 +259,7 @@ export function parseCliArgs(args = []) {
259
259
  }
260
260
  if (action === "login") {
261
261
  const [profile, ...loginArgs] = authArgs;
262
- if (!profile) throw new Error("Missing auth login profile: expected claude");
262
+ if (!profile) throw new Error("Choose the claude sign-in profile.");
263
263
  if (profile !== "claude") throw new Error(`Auth login profile must be claude: ${profile}`);
264
264
  return baseCommand("retired", { integration: "Claude App and Claude Code" });
265
265
  }
@@ -271,7 +271,7 @@ export function parseCliArgs(args = []) {
271
271
  }
272
272
  if (command === "prediction") {
273
273
  const [action = "status", ...extra] = rest;
274
- if (!["on", "off", "status", "fix"].includes(action)) throw new Error("Prediction action must be on, off, status, or fix");
274
+ if (!["on", "off", "status", "fix"].includes(action)) throw new Error("Choose prediction on, off, status or fix.");
275
275
  if (extra.length) unexpectedArgs(extra);
276
276
  return baseCommand("prediction", { action });
277
277
  }
@@ -299,7 +299,7 @@ export function parseCliArgs(args = []) {
299
299
  if (sources.length > 1) unexpectedArgs(sources.slice(1));
300
300
  const source = sources[0];
301
301
  if (source && !new Set(["npm", "github", "gh"]).has(source)) {
302
- throw new Error(`Update source must be npm or github: ${source}`);
302
+ throw new Error(`Choose npm or github. Received: ${source}`);
303
303
  }
304
304
  return {
305
305
  ...baseCommand("update"),
@@ -380,25 +380,25 @@ export function cliCommandName() {
380
380
 
381
381
  function topicHelp(name, topic) {
382
382
  const sections = {
383
- start: `Usage:\n ${name} [start] [--show-request-id] [--no-browser] [--verbose]\n\nStarts or reuses the local adapter, updates Codex configuration, and attempts to open Codex App when auto-launch is enabled and supported. Interactive desktop starts also open WebUI once; --no-browser skips that attempt. After startup the terminal shows fixed status/returned usage; --verbose or --show-request-id retains request detail.`,
384
- auth: `Usage:\n ${name} auth status [--online] [--format table|plain]\n\nShows the saved GitHub Copilot account without exposing credentials. --online also verifies its entitlement and model catalog.`,
385
- "auth status": `Usage:\n ${name} auth status [--online] [--format table|plain]\n\nShows the saved GitHub Copilot account without exposing credentials. --online also verifies its entitlement and model catalog. Interactive terminals use a table by default.`,
386
- doctor: `Usage:\n ${name} doctor [--online] [--compat] [--fix] [--json]\n ${name} doctor config\n\nChecks credentials, managed configuration, command launchers, adapter, enabled optional features and observed client catalog. Default is read-only; no inference requests. --online validates account entitlement; --compat sends minimal inference requests and consumes a small amount of Copilot usage, requiring successful model completion rather than HTTP 200 alone. --fix repairs owned Windows launchers and managed config, imports a verified existing credential only if none is saved, and asks the running adapter to repair enabled predictions once. No interactive login, client program edits, forced App restarts, policy changes or optional feature activation. Missing-credential repair can contact GitHub without --online. Changed existing config is backed up to config.toml.ccdx-doctor.bak. Partial repairs exit 1. --json emits a redacted report, including before_checks for repairs. App-internal cache and visible predictions are not externally verified. The config subcommand remains strictly read-only.`,
387
- "doctor config": `Usage:\n ${name} doctor config\n\nReads ~/.codex/config.toml, checks TOML syntax and CCDX-managed settings, and previews the existing startup writer's changes. Does not merge Codex profiles or validate the complete installed Codex schema. No authentication, network requests, file writes, or adapter/GUI startup. Existing context_management=false is valid. Exit 1 for errors, 0 for OK/warnings; unsupported arguments exit 2.`,
388
- status: `Usage:\n ${name} status\n\nShows bounded runtime, routing, performance, queue, and cache metrics from a running adapter.`,
389
- models: `Usage:\n ${name} models [--format table|plain]\n\nShows GPT models for the selected Codex provider. GitHub performs a fresh read-only lookup; M365 uses its isolated catalog in the running service. Interactive terminals use a table by default.`,
390
- usage: `Usage:\n ${name} usage [--format table|plain] [--provider ID]\n\nSummarizes local token usage metadata without reading prompt or completion content. Optional provider filtering separates sources; default totals include all recorded sources. Interactive terminals use a table by default.`,
391
- cache: `Usage:\n ${name} cache\n ${name} cache --limit <MiB|default>\n ${name} cache --clean [--history] [--yes]\n\nShows runtime cache use, saves and applies the shared response-history limit, or clears the rebuildable image-transform cache. --history also clears in-memory response history for all tasks and can make their next continuation fail, so interactive confirmation or --yes is required. Generated image files and saved Codex transcripts are never deleted. Short aliases: -128 sets 128 MiB and -clean equals --clean.`,
392
- limits: `Usage:\n ${name} limits\n ${name} limits --decoded <MiB|default>\n\nShows configured and running request-body limits, or saves a decoded request-body limit from 128 to 512 MiB. The raw-body limit is unchanged. Restart ccdx to apply a saved change; no conversation or cache is cleared. Short alias: -256 sets 256 MiB.`,
393
- animation: `Usage:\n ${name} animation\n\nPreviews all terminal activity animations together and selects the saved theme. Running CCDX 1.1.0+ applies it live; older services need a restart.`,
394
- "enable-image": `Usage:\n ${name} enable-image\n\nInteractively configures an HTTPS image API endpoint (base URLs are also accepted) and API key, detects its supported image model and protocol, installs CCDX image guidance, and checks the local image tool for Codex App without generating an image. A blank key preserves the saved key only for the same origin; a new origin requires explicit key entry. Concurrent unrelated config edits are preserved.`,
395
- "disable-image": `Usage:\n ${name} disable-image\n\nDisables the local CCDX image tool and removes its stored API credential and unmodified CCDX image guidance.`,
396
- "image-status": `Usage:\n ${name} image-status\n\nShows provider configuration and locally advertised generation/editing tools without generating an image or exposing its API key.`,
397
- "auto-review-model": `Usage:\n ${name} auto-review-model\n\nSelect a Responses model, then an advertised reasoning effort. Enter keeps the default/current choice; q cancels both steps without saving. Effort 0 follows the client (low when omitted). Settings apply only to Auto-review on the next request; no client patch or restart is required for adapters running 0.9.13 or newer.`,
383
+ start: `Usage:\n ${name} [start] [--show-request-id] [--no-browser] [--verbose]\n\n- Starts or reuses the local adapter, updates Codex configuration, and attempts to open Codex App when auto-launch is enabled and supported.\n- Interactive desktop starts also open WebUI once; --no-browser skips that attempt.\n- After startup the terminal shows fixed status/returned usage; --verbose or --show-request-id retains request detail.`,
384
+ auth: `Usage:\n ${name} auth status [--online] [--format table|plain]\n\n- Shows the saved GitHub Copilot account without exposing credentials.\n- --online also verifies its entitlement and model catalog.`,
385
+ "auth status": `Usage:\n ${name} auth status [--online] [--format table|plain]\n\n- Shows the saved GitHub Copilot account without exposing credentials.\n- --online also verifies its entitlement and model catalog.\n- Interactive terminals use a table by default.`,
386
+ doctor: `Usage:\n ${name} doctor [--online] [--compat] [--fix] [--json]\n ${name} doctor config\n\n- Checks credentials, managed configuration, command launchers, adapter, enabled optional features and observed client catalog.\n- Default is read-only; no inference requests.\n- --online validates account entitlement; --compat sends minimal inference requests and consumes a small amount of Copilot usage, requiring successful model completion rather than HTTP 200 alone.\n- --fix repairs owned Windows launchers and managed config, imports a verified existing credential only if none is saved, and asks the running adapter to repair enabled predictions once.\n- No interactive login, client program edits, forced App restarts, policy changes or optional feature activation.\n- Missing-credential repair can contact GitHub without --online.\n- Changed existing config is backed up to config.toml.ccdx-doctor.bak.\n- Partial repairs exit 1.\n- --json emits a redacted report, including before_checks for repairs.\n- App-internal cache and visible predictions are not externally verified.\n- The config subcommand remains strictly read-only.`,
387
+ "doctor config": `Usage:\n ${name} doctor config\n\n- Reads ~/.codex/config.toml, checks TOML syntax and CCDX-managed settings, and previews the existing startup writer's changes.\n- Does not merge Codex profiles or validate the complete installed Codex schema.\n- No authentication, network requests, file writes, or adapter/GUI startup.\n- Existing context_management=false is valid.\n- Exit 1 for errors, 0 for OK/warnings; unsupported arguments exit 2.`,
388
+ status: `Usage:\n ${name} status\n\n- Shows bounded runtime, routing, performance, queue, and cache metrics from a running adapter.`,
389
+ models: `Usage:\n ${name} models [--format table|plain]\n\n- Shows GPT models for the selected Codex provider.\n- GitHub performs a fresh read-only lookup; M365 uses its isolated catalog in the running service.\n- Interactive terminals use a table by default.`,
390
+ usage: `Usage:\n ${name} usage [--format table|plain] [--provider ID]\n\n- Summarizes local token usage metadata without reading prompt or completion content.\n- Optional provider filtering separates sources; default totals include all recorded sources.\n- Interactive terminals use a table by default.`,
391
+ cache: `Usage:\n ${name} cache\n ${name} cache --limit <MiB|default>\n ${name} cache --clean [--history] [--yes]\n\n- Shows runtime cache use, saves and applies the shared response-history limit, or clears the rebuildable image-transform cache.\n- --history also clears in-memory response history for all tasks and can make their next continuation fail, so interactive confirmation or --yes is required.\n- Generated image files and saved Codex transcripts are never deleted.\n- Short aliases: -128 sets 128 MiB and -clean equals --clean.`,
392
+ limits: `Usage:\n ${name} limits\n ${name} limits --decoded <MiB|default>\n\n- Shows configured and running request-body limits, or saves a decoded request-body limit from 128 to 512 MiB.\n- The raw-body limit is unchanged.\n- Restart ccdx to apply a saved change; no conversation or cache is cleared.\n- Short alias: -256 sets 256 MiB.`,
393
+ animation: `Usage:\n ${name} animation\n\n- Previews all terminal activity animations together and selects the saved theme.\n- Running CCDX 1.1.0+ applies it live; older services need a restart.`,
394
+ "enable-image": `Usage:\n ${name} enable-image\n\n- Interactively configures an HTTPS image API endpoint (base URLs are also accepted) and API key, detects its supported image model and protocol, installs CCDX image guidance, and checks the local image tool for Codex App without generating an image.\n- A blank key preserves the saved key only for the same origin; a new origin requires explicit key entry.\n- Concurrent unrelated config edits are preserved.`,
395
+ "disable-image": `Usage:\n ${name} disable-image\n\n- Disables the local CCDX image tool and removes its stored API credential and unmodified CCDX image guidance.`,
396
+ "image-status": `Usage:\n ${name} image-status\n\n- Shows provider configuration and locally advertised generation/editing tools without generating an image or exposing its API key.`,
397
+ "auto-review-model": `Usage:\n ${name} auto-review-model\n\n- Select a Responses model, then an advertised reasoning effort.\n- Enter keeps the default/current choice; q cancels both steps without saving.\n- Effort 0 follows the client (low when omitted).\n- Settings apply only to Auto-review on the next request; no client patch or restart is required for adapters running 0.9.13 or newer.`,
398
398
  "suggestion": `The CCDX prediction panel has been retired. Run ${name} suggestion off to safely remove unchanged CCDX registrations. This cleanup does not change native predictions; see ${name} prediction --help for that separate opt-in feature.`,
399
- m365: `Usage:\n ${name} m365 [status|models|on|off|remove]\n ${name} m365 switch [github|m365] [--model ID] [--auto-review-model ID]\n\nM365 is discovered silently at startup on supported managed environments. Claude uses its separate local gateway. Codex stays on GitHub unless you explicitly switch. M365 switching requires a running compatible adapter and available GPT/Auto-review choices; it never substitutes unavailable models. Select an available model in Codex after switching an existing thread. Off restores only owned Claude settings and selects GitHub. Remove also clears the CCDX M365 profile, retaining a disabled preference and historical usage. System Microsoft sign-in, GitHub credentials, predictions and images are preserved.`,
400
- prediction: `Usage:\n ${name} prediction [status|on|off|fix]\n\nOptional native next-message predictions; off by default. macOS and Windows. Windows requires the registered official MSIX App, an initialized profile, Windows PowerShell and .NET Framework 4.7.2+; Git/OpenSSL is not required for prediction setup. Quit Codex before on/off, then restart ccdx. On adds private App-profile certificate trust and an App-only route for chatgpt.com and ab.chatgpt.com. HTTPS on those hosts is decrypted locally; only prediction configuration is changed. No client program files, OS trust, account permissions, MCP or Hooks are changed. Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are preserved. Windows supports company PAC/WPAD; macOS dynamic PAC/WPAD remains unsupported. Static IPv4/IPv6 CIDRs match URL IP literals without DNS. The bridge port persists across restarts/updates; a busy saved port disables only predictions. Launch/reuse checks the App's actual route; an older random or missing route may require one full App quit. Official prediction configuration is preserved; the conversation's model is used. App updates require another compatibility check. Status distinguishes saved preference and observed config traffic from unverified candidate visibility.\n\nFix asks a compatible running CCDX adapter to repair the enabled bridge once on its saved port. It never enables predictions, renews certificates or force-restarts Codex. Healthy unchanged bridges are retained. Fix rechecks system proxy settings. Changed routes may need a normal App relaunch to reload cached PAC; failed rechecks preserve the previous bridge with a nonzero exit. Process environment variables and Node trust are not hot-reloaded; changed trust inputs need a CCDX service restart. Startup, status and doctor share sanitized environment diagnostics. Missing App routes require a normal full quit and ccdx launch; partial repair exits 1. An older adapter must first be upgraded and restarted once to gain this repair endpoint.`,
401
- update: `Usage:\n ${name} update [npm|github] [--allow-remote]\n\nUpdates the global package from the configured npm registry or the latest stable GitHub release. With no source, an interactive terminal prompts for one. Windows uses system cmd.exe to run npm.cmd without changing PowerShell policy; use the .cmd entrypoint if scripts are blocked. GitHub installs require Git on PATH and dependencies may still use the configured npm registry. By default npm's remote-download policy is preserved. If npm reports EALLOWREMOTE for a trusted mirror tarball, --allow-remote explicitly permits URL dependencies for this one installation's entire dependency tree; it is not a hostname allowlist. No .npmrc, registry or persistent policy is changed, and failed installations are not retried automatically. Use this only if company policy permits it. Restart the running adapter after installation.`,
399
+ m365: `Usage:\n ${name} m365 [status|models|on|off|remove]\n ${name} m365 switch [github|m365] [--model ID] [--auto-review-model ID]\n\n- M365 is discovered silently at startup on supported managed environments.\n- Claude uses /anthropic on the same local port.\n- Codex stays on GitHub unless you explicitly switch.\n- M365 switching requires a running compatible adapter and available GPT/Auto-review choices; it never substitutes unavailable models.\n- Select an available model in Codex after switching an existing thread.\n- Off restores only owned Claude settings and selects GitHub.\n- Remove also clears the CCDX M365 profile, retaining a disabled preference and historical usage.\n- System Microsoft sign-in, GitHub credentials, predictions and images are preserved.`,
400
+ prediction: `Usage:\n ${name} prediction [status|on|off|fix]\n\n- Optional native next-message predictions; off by default. macOS and Windows.\n- Windows requires the registered official MSIX App, an initialized profile, Windows PowerShell and .NET Framework 4.7.2+; Git/OpenSSL is not required for prediction setup.\n- Quit Codex before on/off, then restart ccdx.\n- On adds private App-profile certificate trust and an App-only route for chatgpt.com and ab.chatgpt.com.\n- HTTPS on those hosts is decrypted locally; only prediction configuration is changed.\n- No client program files, OS trust, account permissions, MCP or Hooks are changed.\n- Static HTTP/HTTPS/SOCKS5 proxies and bypass rules are preserved.\n- Windows supports company PAC/WPAD; macOS dynamic PAC/WPAD remains unsupported.\n- Static IPv4/IPv6 CIDRs match URL IP literals without DNS.\n- The bridge port persists across restarts/updates; a busy saved port disables only predictions.\n- Launch/reuse checks the App's actual route; an older random or missing route may require one full App quit.\n- Official prediction configuration is preserved; the conversation's model is used.\n- App updates require another compatibility check.\n- Status distinguishes saved preference and observed config traffic from unverified candidate visibility.\n- Fix asks a compatible running CCDX adapter to repair the enabled bridge once on its saved port.\n- It never enables predictions, renews certificates or force-restarts Codex.\n- Healthy unchanged bridges are retained.\n- Fix rechecks system proxy settings.\n- Changed routes may need a normal App relaunch to reload cached PAC; failed rechecks preserve the previous bridge with a nonzero exit.\n- Process environment variables and Node trust are not hot-reloaded; changed trust inputs need a CCDX service restart.\n- Startup, status and doctor share sanitized environment diagnostics.\n- Missing App routes require a normal full quit and ccdx launch; partial repair exits 1.\n- An older adapter must first be upgraded and restarted once to gain this repair endpoint.`,
401
+ update: `Usage:\n ${name} update [npm|github] [--allow-remote]\n\n- Updates the global package from the configured npm registry or the latest stable GitHub release.\n- With no source, an interactive terminal prompts for one.\n- Windows uses system cmd.exe to run npm.cmd without changing PowerShell policy; use the .cmd entrypoint if scripts are blocked.\n- GitHub verifies a Release tarball; Git is not required. Dependencies use the configured npm registry.\n- By default npm's remote-download policy is preserved.\n- If npm reports EALLOWREMOTE for a trusted mirror tarball, --allow-remote explicitly permits URL dependencies for this one installation's entire dependency tree; it is not a hostname allowlist.\n- No .npmrc, registry or persistent policy is changed, and failed installations are not retried automatically.\n- Use this only if company policy permits it.\n- Restart the running adapter after installation.`,
402
402
  version: `Usage:\n ${name} --version`,
403
403
  };
404
404
  return sections[topic];
@@ -159,9 +159,14 @@ export function formatAdapterStatus({ baseUrl, data }, { commandName = "ccdx", c
159
159
  ...(terminalOutcomes ? [status("info", `Model outcomes: ${count(terminalOutcomes.completed)} completed, ${count(terminalOutcomes.incomplete)} incomplete, ${count(terminalOutcomes.failed)} failed, ${count(terminalOutcomes.cancelled)} cancelled, ${count(terminalOutcomes.unknown)} without terminal`)] : []),
160
160
  status("info", `Admission: ${count(admission.activeRequests)} active, ${count(admission.queued)} queued, ${count(admission.rejected)} rejected, ${count(admission.timedOut)} timed out, wait avg ${latency(admission.waitMsAvg)}`),
161
161
  status("info", `Memory: RSS ${mebibytes(processStats.rss_bytes)}, heap ${mebibytes(processStats.heap_used_bytes)}`),
162
- status("info", `History: ${mebibytes(history.bytes)} / ${mebibytes(limits.response_history_max_bytes)}, ${count(history.entries)} entries, ${count(history.evicted)} evicted ID markers`),
162
+ status("info", `Conversation buffer: ${mebibytes(history.bytes)} / ${mebibytes(limits.response_history_max_bytes)}, ${count(history.entries)} entries, ${count(history.evicted)} evicted ID markers`),
163
163
  status("info", `Image cache: ${count(images.cache_entries)} entries, ${cacheHitRate(images)} hits, ${mebibytes(images.cache_bytes)} / ${mebibytes(images.cache_max_bytes)}`),
164
164
  ];
165
+ const sourceRoutes = { ...data.stream_performance?.by_route, ...data.providers?.m365?.claude?.requests?.performance?.by_route };
166
+ for (const [route, metrics] of Object.entries(sourceRoutes)) for (const [source, stats] of Object.entries(metrics.by_provider || {})) {
167
+ const totals = stats.terminal_outcomes.totals;
168
+ lines.push(status("info", `Source ${source} / ${route}: ${count(stats.active)} active, ${count(totals.completed)} completed, ${count(totals.incomplete)} incomplete, ${count(totals.failed)} failed, ${count(totals.cancelled)} cancelled, ${count(totals.unknown)} unknown`));
169
+ }
165
170
  if (Number.isFinite(history.tree_count)) {
166
171
  const limit = Number(limits.response_history_max_bytes || history.maxBytes);
167
172
  const nearLimit = Number.isFinite(limit) && limit > 0 && history.bytes / limit >= 0.9;
@@ -1,9 +1,9 @@
1
1
  (() => {
2
2
  const el = id => document.getElementById(id);
3
3
  const label = (node, key, values = {}) => globalThis.ccdxLanguage.set(node, key, values);
4
- const titles = { overview: "Overview", codex: "Codex", claude: "Claude", models: "Model services", usage: "Usage and diagnostics", system: "System and settings" };
4
+ const titles = { overview: "overview", codex: "Codex", claude: "Claude", models: "model_services", usage: "usage_and_diagnostics", requests: "request_records", system: "system_and_settings" };
5
5
  let current = "overview", settings = null, settingsPending = false, stopped = false, timer = null, ticks = 0;
6
- let sourceDirty = false, sourceGeneration = 0;
6
+ let sourceDirty = false, reviewDirty = false, sourceModels = [], modelsPreference = null, sourceGeneration = 0, modelsSource = null;
7
7
  let settingsReadAt = null;
8
8
  function navigate() {
9
9
  const route = location.hash.slice(1), next = Object.hasOwn(titles, route) ? route : "overview";
@@ -25,28 +25,71 @@
25
25
  ...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout(15000) });
26
26
  const data = await response.json();if (!response.ok) throw new Error(data.error || `HTTP ${response.status}`);return data;
27
27
  }
28
- const states = { immediate: "Effective now", terminal_unavailable: "Terminal animation unavailable in this output mode", next_start: "Next CCDX start", next_call: "Applies to new calls", needs_setup: "Setup required",
29
- next_config_request: "Next configuration request; cached suggestions may remain", needs_app_relaunch: "Reopen the client to finish", needs_service_restart: "Restart CCDX to finish" };
28
+ const states = { immediate: "effective_now", terminal_unavailable: "terminal_animation_unavailable_in_this_output_mode", next_start: "next_ccdx_start", next_call: "applies_to_new_calls", needs_setup: "setup_required",
29
+ next_config_request: "next_configuration_request_cached_suggestions_may_remain", needs_app_relaunch: "reopen_the_client_to_finish", needs_service_restart: "restart_ccdx_to_finish" };
30
+ const selectedSource = () => providerEntries.find(source => source.id === el("source-provider").value);
31
+ const sourceReady = () => Boolean(selectedSource()) && (!selectedSource().selection.models_required || Boolean(modelsSource === selectedSource().id && el("source-model").value && el("source-review").value));
32
+ const reviewLocked = () => selectedSource()?.id === "github" && settings?.providers?.github?.preference?.source === "environment";
33
+ function syncReviewButton() {
34
+ const sameSource = selectedSource()?.id === settings?.providers?.codex_provider;
35
+ el("save-review").disabled = settingsPending || !sameSource || reviewLocked() || modelsSource !== selectedSource()?.id || !el("source-review").value;
36
+ el("source-review").disabled = settingsPending || reviewLocked() || !sourceModels.length;
37
+ el("source-review-effort").disabled = el("source-review").disabled;
38
+ if (reviewLocked()) label(el("review-control-note"), "review_environment_override");
39
+ else if (!sameSource) label(el("review-control-note"), "review_save_source_first");
40
+ }
41
+ function syncEfforts(chosen) {
42
+ const model = sourceModels.find(model => model.id === el("source-review").value);
43
+ const efforts = model?.auto_review_efforts || model?.reasoning_efforts || [];
44
+ const follow = document.createElement("option");follow.value = "";label(follow, "follow_client");
45
+ el("source-review-effort").replaceChildren(follow, ...efforts.map(effort => { const option = document.createElement("option");option.value = effort;option.textContent = effort;return option; }));
46
+ el("source-review-effort").value = efforts.includes(chosen) ? chosen : "";
47
+ syncReviewButton();
48
+ }
49
+ function syncSources() {
50
+ const selector = el("source-provider"), selected = sourceDirty ? selector.value : settings?.providers?.codex_provider || selector.value;
51
+ const entries = providerEntries.filter(source => source.selection?.codex);
52
+ const signature = JSON.stringify(entries.map(source => [source.id, source.name]));
53
+ if (selector.dataset.sources !== signature) {
54
+ selector.replaceChildren(...entries.map(source => {
55
+ const option = document.createElement("option");option.value = source.id;option.textContent = source.name;return option;
56
+ }));selector.dataset.sources = signature;
57
+ }
58
+ if (entries.some(source => source.id === selected)) selector.value = selected;
59
+ el("apply-source").disabled = settingsPending || !sourceReady();
60
+ syncReviewButton();
61
+ }
62
+ window.addEventListener("ccdx:providers", () => { syncSources();if (current === "codex") void loadSourceModels(); });
30
63
  function applySettings(data) {
31
64
  settings = data;
32
65
  for (const key of ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled"]) {
33
66
  const input = el(`setting-${key}`), effective = data.effective[key];
34
67
  input.checked = data.saved[key];input.disabled = Boolean(effective.locked);
35
- label(el(`effect-${key}`), "Saved {saved} / effective {effective} / {state}", {
36
- saved: { key: data.saved[key] ? "On" : "Off" }, effective: { key: effective.value ? "On" : "Off" },
37
- state: { key: effective.locked ? "Controlled by environment" : states[effective.state] || effective.state } });
68
+ label(el(`effect-${key}`), effective.state === "next_start" ? "saved_saved_state" : "saved_saved_effective_effective_state", {
69
+ saved: { key: data.saved[key] ? "on" : "off" }, effective: { key: effective.value ? "on" : "off" },
70
+ state: { key: effective.locked ? "controlled_by_environment" : states[effective.state] || effective.state } });
38
71
  }
39
72
  if (document.activeElement !== el("history-limit")) el("history-limit").value = data.history.maxBytes / 1048576;
40
73
  el("history-limit").disabled = data.history.source === "environment";
41
74
  el("save-history").disabled = data.history.source === "environment";
42
- label(el("effect-history"), data.history.source === "environment" ? "Controlled by environment" : "Applies to new calls");
43
- label(el("settings-note"), "Settings read from the running service.");
75
+ label(el("effect-history"), data.history.source === "environment" ? "controlled_by_environment" : "applies_to_new_calls");
76
+ label(el("settings-note"), "settings_read_from_the_running_service");
44
77
  el("page-settings-note").textContent = "";
45
78
  const state = data.providers;
46
- if (state && !sourceDirty && el("source-provider").value !== state.codex_provider) {
47
- el("source-provider").value = state.codex_provider;void loadSourceModels();
79
+ syncSources();
80
+ if (current === "codex" && state && (modelsSource !== el("source-provider").value || !sourceDirty && !reviewDirty && modelsPreference !== JSON.stringify(state[el("source-provider").value]?.preference))) void loadSourceModels();
81
+ el("m365-control-note").replaceChildren();
82
+ if (state) {
83
+ const source = document.createElement("span"), m365 = document.createElement("span");
84
+ label(source, "codex_source_source", { source: providerEntries.find(entry => entry.id === state.codex_provider)?.name || state.codex_provider });
85
+ const status = { ready: "ready", checking: "checking", disabled: "disabled", unsupported: "unsupported", idle: "unknown", unavailable: "unavailable" }[state.m365?.state] || "unknown";
86
+ label(m365, "microsoft_365_state", { state: { key: status } });
87
+ el("source-control-note").replaceChildren(source);el("m365-control-note").append(m365);
88
+ if (state.m365?.reason) {
89
+ const detail = document.createElement("details"), summary = document.createElement("summary"), code = document.createElement("code");
90
+ label(summary, "message");code.textContent = state.m365.reason;detail.append(summary, code);el("m365-control-note").append(detail);
91
+ }
48
92
  }
49
- el("source-control-note").textContent = state ? `Codex → ${state.codex_provider} / Microsoft 365: ${state.m365.state}${state.m365.reason ? ` / ${state.m365.reason}` : ""}` : "—";
50
93
  el("process-notice").textContent = data.terminal?.last_notice || "";
51
94
  }
52
95
  async function loadSettings() {
@@ -54,31 +97,37 @@
54
97
  settingsPending = true;
55
98
  try { applySettings(await api());settingsReadAt = new Date().toLocaleTimeString(); }
56
99
  catch (error) {
57
- const detail = `${error.message}${settingsReadAt ? ` / ${settingsReadAt}` : ""}`;
58
- el("settings-note").textContent = detail;el("page-settings-note").textContent = detail;
100
+ for (const id of ["settings-note", "page-settings-note"]) {
101
+ label(el(id), settingsReadAt ? "showing_previous_data_updated_time" : "could_not_read_settings", { time: settingsReadAt });
102
+ el(id).title = error.message;
103
+ }
59
104
  }
60
- finally { settingsPending = false; }
105
+ finally { settingsPending = false;el("apply-source").disabled = !sourceReady();syncReviewButton(); }
61
106
  }
62
107
  async function change(body, button) {
63
108
  if (settingsPending) return;
64
109
  settingsPending = true;
65
- const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #m365-on, #m365-off")];
110
+ const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #m365-on, #m365-off")];
66
111
  controls.forEach(input => { input.disabled = true; });
67
- label(el("settings-note"), "Applying…");
112
+ label(el("settings-note"), "applying");
68
113
  if (button) button.setAttribute("aria-busy", "true");
69
114
  try {
70
- const data = await api(body);if (body.action === "provider" && body.operation === "switch") sourceDirty = false;
115
+ const data = await api(body);
116
+ if (body.action === "provider" && body.operation === "switch") sourceDirty = false;
117
+ if (body.action === "provider" && body.operation === "auto-review") reviewDirty = false;
118
+ if (body.action === "provider" && body.operation === "off") { sourceDirty = false;reviewDirty = false; }
119
+ el("review-control-note").textContent = "";
71
120
  applySettings(data);await dashboardRefresh.refresh("status", { force: true });await dashboardRefresh.refresh("auth", { force: true });
72
121
  }
73
122
  catch (error) {
74
123
  if (settings) applySettings(settings);
75
- el("settings-note").textContent = error.message;el("source-control-note").textContent = error.message;el("effect-history").textContent = error.message;
124
+ el("settings-note").textContent = error.message;el("source-control-note").textContent = error.message;el("m365-control-note").textContent = error.message;el("review-control-note").textContent = error.message;el("effect-history").textContent = error.message;
76
125
  if (body.key) el(`effect-${body.key}`).textContent = error.message;
77
126
  } finally {
78
127
  settingsPending = false;controls.forEach(input => { input.disabled = false; });
79
128
  if (settings) for (const [key, value] of Object.entries(settings.effective)) if (value.locked) el(`setting-${key}`).disabled = true;
80
129
  if (settings?.history.source === "environment") el("save-history").disabled = true;
81
- if (el("source-provider").value === "m365") el("apply-source").disabled = !el("source-model").value || !el("source-review").value;
130
+ el("apply-source").disabled = !sourceReady();el("source-model").disabled = !selectedSource()?.selection.models_required;syncReviewButton();
82
131
  button?.removeAttribute("aria-busy");
83
132
  }
84
133
  }
@@ -87,36 +136,61 @@
87
136
  });
88
137
  el("save-history").addEventListener("click", () => void change({ action: "history_limit", mib: Number(el("history-limit").value) }, el("save-history")));
89
138
  el("clean-history").addEventListener("click", () => {
90
- if (window.confirm(globalThis.ccdxLanguage.format("Clear inactive Codex conversation data? Older continuation IDs may stop working."))) void change({ action: "history_clean" }, el("clean-history"));
139
+ if (window.confirm(globalThis.ccdxLanguage.format("clear_inactive_codex_conversation_data_older_continuation_ids_ma"))) void change({ action: "history_clean" }, el("clean-history"));
91
140
  });
92
141
  el("fix-prediction").addEventListener("click", () => void change({ action: "prediction_fix" }, el("fix-prediction")));
93
- for (const operation of ["on", "off"]) el(`m365-${operation}`).addEventListener("click", () => void change({ action: "provider", operation }, el(`m365-${operation}`)));
142
+ for (const operation of ["on", "off"]) el(`m365-${operation}`).addEventListener("click", () => {
143
+ if (operation === "off" && !window.confirm(globalThis.ccdxLanguage.format("confirm_disable_m365"))) return;
144
+ void change({ action: "provider", operation }, el(`m365-${operation}`));
145
+ });
94
146
  async function loadSourceModels() {
95
147
  const generation = ++sourceGeneration;
96
- const m365 = el("source-provider").value === "m365";
97
- el("source-model").disabled = el("source-review").disabled = !m365;
98
- if (!m365) { el("apply-source").disabled = settingsPending;return; }
99
- el("apply-source").disabled = true;
100
- el("source-model").replaceChildren();el("source-review").replaceChildren();
148
+ const source = selectedSource(), needsModels = source?.selection.models_required;
149
+ el("source-model-field").hidden = !needsModels;el("source-model-note").hidden = Boolean(needsModels);
150
+ el("source-model").disabled = !needsModels;
151
+ if (!source) { sourceModels = [];syncReviewButton();return; }
152
+ const unsaved = (sourceDirty || reviewDirty) && modelsSource === source.id ? {
153
+ model: el("source-model").value, auto_review_model: el("source-review").value, auto_review_effort: el("source-review-effort").value } : null;
154
+ el("save-review").disabled = true;el("source-review").disabled = true;el("source-review-effort").disabled = true;
155
+ el("apply-source").disabled = settingsPending || Boolean(needsModels);
156
+ label(el("review-control-note"), "model_choices_loading");
101
157
  try {
102
- const response = await fetch("/_ccdx/ui/models/live?provider=m365", { headers: { "X-CCDX-Dashboard": "1" }, cache: "no-store", signal: AbortSignal.timeout(15000) });
103
- const data = await response.json();if (!response.ok) throw new Error(data.error);
158
+ const response = await fetch(`/_ccdx/ui/models/live?provider=${encodeURIComponent(source.id)}`, { headers: { "X-CCDX-Dashboard": "1" }, cache: "no-store", signal: AbortSignal.timeout(15000) });
159
+ const data = await response.json();if (!response.ok || !Array.isArray(data.models)) throw new Error(data.error || "Invalid model list");
104
160
  if (generation !== sourceGeneration) return;
105
161
  const models = data.models.filter(model => model.selectable && model.clients.includes("codex"));
106
- for (const [id, list] of [["source-model", models], ["source-review", models.filter(model => model.reasoning_efforts?.includes("low"))]]) {
107
- el(id).replaceChildren(...list.map(model => { const option = document.createElement("option");option.value = model.id;option.textContent = model.id;return option; }));
108
- const saved = settings?.providers?.m365?.preference?.[id === "source-model" ? "model" : "auto_review_model"];
109
- if (!sourceDirty && saved && list.some(model => model.id === saved)) el(id).value = saved;
162
+ sourceModels = models;
163
+ const preference = settings?.providers?.[source.id]?.preference;
164
+ for (const [id, key] of [["source-model", "model"], ["source-review", "auto_review_model"]]) {
165
+ el(id).replaceChildren(...models.map(model => { const option = document.createElement("option");option.value = model.id;option.textContent = model.id;return option; }));
166
+ const saved = key === "auto_review_model" && source.id === "github" ? preference?.model : preference?.[key];
167
+ const chosen = unsaved?.[key] || saved;
168
+ if (chosen && models.some(model => model.id === chosen)) el(id).value = chosen;
110
169
  }
111
- el("apply-source").disabled = !el("source-model").value || !el("source-review").value;
112
- } catch (error) { if (generation === sourceGeneration) el("source-control-note").textContent = error.message; }
170
+ modelsSource = source.id;modelsPreference = JSON.stringify(preference);
171
+ const savedEffort = source.id === "github" ? preference?.reasoningEffort : preference?.auto_review_effort === undefined ? "low" : preference.auto_review_effort;
172
+ el("review-control-note").textContent = "";
173
+ syncEfforts(unsaved ? unsaved.auto_review_effort : savedEffort);
174
+ el("apply-source").disabled = settingsPending || !sourceReady();
175
+ } catch (error) {
176
+ if (generation === sourceGeneration) {
177
+ modelsSource = null;sourceModels = [];el("source-review").replaceChildren();el("source-review-effort").replaceChildren();
178
+ el("review-control-note").textContent = error.message;el("apply-source").disabled = settingsPending || !sourceReady();
179
+ }
180
+ }
113
181
  }
114
- el("source-provider").addEventListener("change", () => { sourceDirty = true;void loadSourceModels(); });
115
- for (const id of ["source-model", "source-review"]) el(id).addEventListener("change", () => { sourceDirty = true; });
182
+ el("source-provider").addEventListener("change", () => { sourceDirty = true;reviewDirty = false;void loadSourceModels(); });
183
+ el("source-model").addEventListener("change", () => { sourceDirty = true; });
184
+ el("source-review").addEventListener("change", () => { reviewDirty = true;syncEfforts("low"); });
185
+ el("source-review-effort").addEventListener("change", () => { reviewDirty = true; });
116
186
  el("apply-source").addEventListener("click", () => {
117
187
  const provider = el("source-provider").value;
118
- void change({ action: "provider", operation: "switch", provider, ...(provider === "m365" ? { model: el("source-model").value, auto_review_model: el("source-review").value } : {}) }, el("apply-source"));
188
+ void change({ action: "provider", operation: "switch", provider, ...(selectedSource()?.selection.models_required ? {
189
+ model: el("source-model").value, ...(settings?.providers?.codex_provider === provider ? {} : {
190
+ auto_review_model: el("source-review").value, auto_review_effort: el("source-review-effort").value || null }) } : {}) }, el("apply-source"));
119
191
  });
192
+ el("save-review").addEventListener("click", () => void change({ action: "provider", operation: "auto-review", provider: el("source-provider").value,
193
+ model: el("source-review").value, auto_review_effort: el("source-review-effort").value || null }, el("save-review")));
120
194
  // Only the small in-memory status snapshot is read at this cadence. Catalogs
121
195
  // and retained usage keep their existing on-demand, bounded refresh policy.
122
196
  function schedule() {