codex-copilot-dx 1.1.1 → 1.2.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.
- package/README.md +4 -4
- package/bin/cli.mjs +23 -23
- package/docs/ARCHITECTURE.md +20 -6
- package/docs/REFERENCE.md +12 -13
- package/package.json +1 -1
- package/src/auth-device-flow.mjs +1 -1
- package/src/auth-status.mjs +1 -1
- package/src/auto-review-model.mjs +2 -2
- package/src/claude-client-lifecycle.mjs +33 -0
- package/src/claude-gateway.mjs +15 -6
- package/src/cli-auth.mjs +6 -6
- package/src/cli-cache.mjs +5 -5
- package/src/cli-image.mjs +1 -1
- package/src/cli-m365.mjs +5 -5
- package/src/cli-models.mjs +2 -2
- package/src/cli-options.mjs +26 -26
- package/src/cli-status.mjs +6 -1
- package/src/dashboard/console.js +58 -26
- package/src/dashboard/index.html +95 -87
- package/src/dashboard/language.js +779 -362
- package/src/dashboard/status.js +53 -41
- package/src/dashboard/ui.js +31 -28
- package/src/dashboard/usage.js +16 -16
- package/src/dashboard-api.mjs +1 -0
- package/src/doctor.mjs +4 -4
- package/src/http-transport.mjs +3 -2
- package/src/launcher.mjs +8 -8
- package/src/native-prediction.mjs +3 -3
- package/src/operation-error.mjs +12 -7
- package/src/package-update.mjs +3 -3
- package/src/provider-registry.mjs +19 -0
- package/src/provider-runtime.mjs +22 -27
- package/src/provider-settings.mjs +2 -1
- package/src/response-failures.mjs +2 -1
- package/src/service-control.mjs +4 -5
- package/src/startup-ui.mjs +17 -9
- package/src/stream-performance.mjs +29 -1
- package/src/terminal-console.mjs +43 -15
- package/src/usage-store.mjs +10 -5
- package/src/user-settings.mjs +16 -3
package/src/cli-options.mjs
CHANGED
|
@@ -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(`
|
|
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("
|
|
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("
|
|
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
|
|
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("
|
|
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("
|
|
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("
|
|
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(`
|
|
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\
|
|
384
|
-
auth: `Usage:\n ${name} auth status [--online] [--format table|plain]\n\
|
|
385
|
-
"auth status": `Usage:\n ${name} auth status [--online] [--format table|plain]\n\
|
|
386
|
-
doctor: `Usage:\n ${name} doctor [--online] [--compat] [--fix] [--json]\n ${name} doctor config\n\
|
|
387
|
-
"doctor config": `Usage:\n ${name} doctor config\n\
|
|
388
|
-
status: `Usage:\n ${name} status\n\
|
|
389
|
-
models: `Usage:\n ${name} models [--format table|plain]\n\
|
|
390
|
-
usage: `Usage:\n ${name} usage [--format table|plain] [--provider ID]\n\
|
|
391
|
-
cache: `Usage:\n ${name} cache\n ${name} cache --limit <MiB|default>\n ${name} cache --clean [--history] [--yes]\n\
|
|
392
|
-
limits: `Usage:\n ${name} limits\n ${name} limits --decoded <MiB|default>\n\
|
|
393
|
-
animation: `Usage:\n ${name} animation\n\
|
|
394
|
-
"enable-image": `Usage:\n ${name} enable-image\n\
|
|
395
|
-
"disable-image": `Usage:\n ${name} disable-image\n\
|
|
396
|
-
"image-status": `Usage:\n ${name} image-status\n\
|
|
397
|
-
"auto-review-model": `Usage:\n ${name} auto-review-model\n\
|
|
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\
|
|
400
|
-
prediction: `Usage:\n ${name} prediction [status|on|off|fix]\n\
|
|
401
|
-
update: `Usage:\n ${name} update [npm|github] [--allow-remote]\n\
|
|
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 installs require Git on PATH and dependencies may still 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];
|
package/src/cli-status.mjs
CHANGED
|
@@ -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", `
|
|
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;
|
package/src/dashboard/console.js
CHANGED
|
@@ -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: "
|
|
4
|
+
const titles = { overview: "overview", codex: "Codex", claude: "Claude", models: "model_services", usage: "usage_and_diagnostics", 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, 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,55 @@
|
|
|
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: "
|
|
29
|
-
next_config_request: "
|
|
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(el("source-model").value && el("source-review").value));
|
|
32
|
+
function syncSources() {
|
|
33
|
+
const selector = el("source-provider"), selected = sourceDirty ? selector.value : settings?.providers?.codex_provider || selector.value;
|
|
34
|
+
const entries = providerEntries.filter(source => source.selection?.codex);
|
|
35
|
+
const signature = JSON.stringify(entries.map(source => [source.id, source.name]));
|
|
36
|
+
if (selector.dataset.sources !== signature) {
|
|
37
|
+
selector.replaceChildren(...entries.map(source => {
|
|
38
|
+
const option = document.createElement("option");option.value = source.id;option.textContent = source.name;return option;
|
|
39
|
+
}));selector.dataset.sources = signature;
|
|
40
|
+
}
|
|
41
|
+
if (entries.some(source => source.id === selected)) selector.value = selected;
|
|
42
|
+
el("apply-source").disabled = settingsPending || !sourceReady();
|
|
43
|
+
}
|
|
44
|
+
window.addEventListener("ccdx:providers", () => { syncSources();void loadSourceModels(); });
|
|
30
45
|
function applySettings(data) {
|
|
31
46
|
settings = data;
|
|
32
47
|
for (const key of ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled"]) {
|
|
33
48
|
const input = el(`setting-${key}`), effective = data.effective[key];
|
|
34
49
|
input.checked = data.saved[key];input.disabled = Boolean(effective.locked);
|
|
35
|
-
label(el(`effect-${key}`),
|
|
36
|
-
saved: { key: data.saved[key] ? "
|
|
37
|
-
state: { key: effective.locked ? "
|
|
50
|
+
label(el(`effect-${key}`), effective.state === "next_start" ? "saved_saved_state" : "saved_saved_effective_effective_state", {
|
|
51
|
+
saved: { key: data.saved[key] ? "on" : "off" }, effective: { key: effective.value ? "on" : "off" },
|
|
52
|
+
state: { key: effective.locked ? "controlled_by_environment" : states[effective.state] || effective.state } });
|
|
38
53
|
}
|
|
39
54
|
if (document.activeElement !== el("history-limit")) el("history-limit").value = data.history.maxBytes / 1048576;
|
|
40
55
|
el("history-limit").disabled = data.history.source === "environment";
|
|
41
56
|
el("save-history").disabled = data.history.source === "environment";
|
|
42
|
-
label(el("effect-history"), data.history.source === "environment" ? "
|
|
43
|
-
label(el("settings-note"), "
|
|
57
|
+
label(el("effect-history"), data.history.source === "environment" ? "controlled_by_environment" : "applies_to_new_calls");
|
|
58
|
+
label(el("settings-note"), "settings_read_from_the_running_service");
|
|
44
59
|
el("page-settings-note").textContent = "";
|
|
45
|
-
const state = data.providers;
|
|
46
|
-
|
|
47
|
-
|
|
60
|
+
const state = data.providers, previousSource = el("source-provider").value;
|
|
61
|
+
syncSources();
|
|
62
|
+
if (state && !sourceDirty && (previousSource !== state.codex_provider || selectedSource()?.selection.models_required && !el("source-model").value)) {
|
|
63
|
+
void loadSourceModels();
|
|
64
|
+
}
|
|
65
|
+
el("source-control-note").replaceChildren();
|
|
66
|
+
if (state) {
|
|
67
|
+
const source = document.createElement("span"), m365 = document.createElement("span");
|
|
68
|
+
label(source, "codex_source_source", { source: providerEntries.find(entry => entry.id === state.codex_provider)?.name || state.codex_provider });
|
|
69
|
+
const status = { ready: "ready", checking: "checking", disabled: "disabled", unsupported: "unsupported", idle: "unknown", unavailable: "unavailable" }[state.m365?.state] || "unknown";
|
|
70
|
+
label(m365, "microsoft_365_state", { state: { key: status } });
|
|
71
|
+
el("source-control-note").append(source, document.createElement("br"), m365);
|
|
72
|
+
if (state.m365?.reason) {
|
|
73
|
+
const detail = document.createElement("details"), summary = document.createElement("summary"), code = document.createElement("code");
|
|
74
|
+
label(summary, "message");code.textContent = state.m365.reason;detail.append(summary, code);el("source-control-note").append(detail);
|
|
75
|
+
}
|
|
48
76
|
}
|
|
49
|
-
el("source-control-note").textContent = state ? `Codex → ${state.codex_provider} / Microsoft 365: ${state.m365.state}${state.m365.reason ? ` / ${state.m365.reason}` : ""}` : "—";
|
|
50
77
|
el("process-notice").textContent = data.terminal?.last_notice || "";
|
|
51
78
|
}
|
|
52
79
|
async function loadSettings() {
|
|
@@ -54,17 +81,19 @@
|
|
|
54
81
|
settingsPending = true;
|
|
55
82
|
try { applySettings(await api());settingsReadAt = new Date().toLocaleTimeString(); }
|
|
56
83
|
catch (error) {
|
|
57
|
-
const
|
|
58
|
-
|
|
84
|
+
for (const id of ["settings-note", "page-settings-note"]) {
|
|
85
|
+
label(el(id), settingsReadAt ? "showing_previous_data_updated_time" : "could_not_read_settings", { time: settingsReadAt });
|
|
86
|
+
el(id).title = error.message;
|
|
87
|
+
}
|
|
59
88
|
}
|
|
60
|
-
finally { settingsPending = false; }
|
|
89
|
+
finally { settingsPending = false;el("apply-source").disabled = !sourceReady(); }
|
|
61
90
|
}
|
|
62
91
|
async function change(body, button) {
|
|
63
92
|
if (settingsPending) return;
|
|
64
93
|
settingsPending = true;
|
|
65
94
|
const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #m365-on, #m365-off")];
|
|
66
95
|
controls.forEach(input => { input.disabled = true; });
|
|
67
|
-
label(el("settings-note"), "
|
|
96
|
+
label(el("settings-note"), "applying");
|
|
68
97
|
if (button) button.setAttribute("aria-busy", "true");
|
|
69
98
|
try {
|
|
70
99
|
const data = await api(body);if (body.action === "provider" && body.operation === "switch") sourceDirty = false;
|
|
@@ -78,7 +107,7 @@
|
|
|
78
107
|
settingsPending = false;controls.forEach(input => { input.disabled = false; });
|
|
79
108
|
if (settings) for (const [key, value] of Object.entries(settings.effective)) if (value.locked) el(`setting-${key}`).disabled = true;
|
|
80
109
|
if (settings?.history.source === "environment") el("save-history").disabled = true;
|
|
81
|
-
|
|
110
|
+
el("apply-source").disabled = !selectedSource() || selectedSource()?.selection.models_required && (!el("source-model").value || !el("source-review").value);
|
|
82
111
|
button?.removeAttribute("aria-busy");
|
|
83
112
|
}
|
|
84
113
|
}
|
|
@@ -87,27 +116,30 @@
|
|
|
87
116
|
});
|
|
88
117
|
el("save-history").addEventListener("click", () => void change({ action: "history_limit", mib: Number(el("history-limit").value) }, el("save-history")));
|
|
89
118
|
el("clean-history").addEventListener("click", () => {
|
|
90
|
-
if (window.confirm(globalThis.ccdxLanguage.format("
|
|
119
|
+
if (window.confirm(globalThis.ccdxLanguage.format("clear_inactive_codex_conversation_data_older_continuation_ids_ma"))) void change({ action: "history_clean" }, el("clean-history"));
|
|
91
120
|
});
|
|
92
121
|
el("fix-prediction").addEventListener("click", () => void change({ action: "prediction_fix" }, el("fix-prediction")));
|
|
93
122
|
for (const operation of ["on", "off"]) el(`m365-${operation}`).addEventListener("click", () => void change({ action: "provider", operation }, el(`m365-${operation}`)));
|
|
94
123
|
async function loadSourceModels() {
|
|
95
124
|
const generation = ++sourceGeneration;
|
|
96
|
-
const
|
|
97
|
-
el("source-model").disabled = el("source-review").disabled = !
|
|
98
|
-
if (!
|
|
125
|
+
const source = selectedSource(), needsModels = source?.selection.models_required;
|
|
126
|
+
el("source-model").disabled = el("source-review").disabled = !needsModels;
|
|
127
|
+
if (!needsModels) { el("apply-source").disabled = settingsPending || !source;return; }
|
|
128
|
+
const unsaved = sourceDirty && modelsSource === source.id ? { model: el("source-model").value, auto_review_model: el("source-review").value } : null;
|
|
99
129
|
el("apply-source").disabled = true;
|
|
100
130
|
el("source-model").replaceChildren();el("source-review").replaceChildren();
|
|
101
131
|
try {
|
|
102
|
-
const response = await fetch(
|
|
132
|
+
const response = await fetch(`/_ccdx/ui/models/live?provider=${encodeURIComponent(source.id)}`, { headers: { "X-CCDX-Dashboard": "1" }, cache: "no-store", signal: AbortSignal.timeout(15000) });
|
|
103
133
|
const data = await response.json();if (!response.ok) throw new Error(data.error);
|
|
104
134
|
if (generation !== sourceGeneration) return;
|
|
105
135
|
const models = data.models.filter(model => model.selectable && model.clients.includes("codex"));
|
|
106
136
|
for (const [id, list] of [["source-model", models], ["source-review", models.filter(model => model.reasoning_efforts?.includes("low"))]]) {
|
|
107
137
|
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?.
|
|
109
|
-
|
|
138
|
+
const saved = settings?.providers?.[source.id]?.preference?.[id === "source-model" ? "model" : "auto_review_model"];
|
|
139
|
+
const chosen = unsaved?.[id === "source-model" ? "model" : "auto_review_model"] || (!sourceDirty ? saved : null);
|
|
140
|
+
if (chosen && list.some(model => model.id === chosen)) el(id).value = chosen;
|
|
110
141
|
}
|
|
142
|
+
modelsSource = source.id;
|
|
111
143
|
el("apply-source").disabled = !el("source-model").value || !el("source-review").value;
|
|
112
144
|
} catch (error) { if (generation === sourceGeneration) el("source-control-note").textContent = error.message; }
|
|
113
145
|
}
|
|
@@ -115,7 +147,7 @@
|
|
|
115
147
|
for (const id of ["source-model", "source-review"]) el(id).addEventListener("change", () => { sourceDirty = true; });
|
|
116
148
|
el("apply-source").addEventListener("click", () => {
|
|
117
149
|
const provider = el("source-provider").value;
|
|
118
|
-
void change({ action: "provider", operation: "switch", provider, ...(
|
|
150
|
+
void change({ action: "provider", operation: "switch", provider, ...(selectedSource()?.selection.models_required ? { model: el("source-model").value, auto_review_model: el("source-review").value } : {}) }, el("apply-source"));
|
|
119
151
|
});
|
|
120
152
|
// Only the small in-memory status snapshot is read at this cadence. Catalogs
|
|
121
153
|
// and retained usage keep their existing on-demand, bounded refresh policy.
|