codex-copilot-dx 1.2.24 → 1.2.26

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.
@@ -3,6 +3,7 @@ import { ADAPTER_CACHE_PATH, cacheRuntimeSnapshot, cleanRuntimeCaches, setHistor
3
3
  import { createRequestAbort, readJsonBody, sendJsonError } from "./http-transport.mjs";
4
4
  import { httpError } from "./http-errors.mjs";
5
5
  import { isLoopbackAddress, isLoopbackHostHeader } from "./security.mjs";
6
+ import { statusSummary } from "./status-summary.mjs";
6
7
 
7
8
  export function isManagementRoute(method, pathname) {
8
9
  return (method === "GET" && [ADAPTER_STATUS_PATH, ADAPTER_HEALTH_PATH].includes(pathname))
@@ -21,7 +22,8 @@ export function createManagementHandler({ statusSnapshot, nativePredictionPac, f
21
22
  return;
22
23
  }
23
24
  res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
24
- res.end(JSON.stringify(statusSnapshot()));
25
+ const snapshot = statusSnapshot();
26
+ res.end(JSON.stringify(new URL(req.url, "http://localhost").searchParams.get("scope") === "summary" ? statusSummary(snapshot) : snapshot));
25
27
  return;
26
28
  }
27
29
 
@@ -1,4 +1,4 @@
1
- export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/time.js", "/animation.js", "/status.js", "/view-boundary.js", "/activity.js", "/flow.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/icons.js", "/tools.js", "/connections.js"]);
1
+ export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/time.js", "/animation.js", "/status.js", "/view-boundary.js", "/activity.js", "/flow.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/preferences.js", "/icons.js", "/tools.js", "/connections.js"]);
2
2
  export const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth", "/_ccdx/ui/providers", "/_ccdx/ui/settings", "/_ccdx/ui/m365/accounts", "/_ccdx/ui/updates", "/_ccdx/ui/account", "/_ccdx/ui/checks", "/_ccdx/ui/connections"]);
3
3
 
4
4
  export function isOptionalRoute(method, pathname) {
@@ -14,6 +14,7 @@ import { m365NetworkMessage } from "./providers/m365-network-diagnostic.mjs";
14
14
  import { createConnectionRuntime } from "./connection-runtime.mjs";
15
15
  import { accessSettingsPath, readAccessSettings } from "./access-settings.mjs";
16
16
  import { createStreamPerformanceMetrics } from "./stream-performance.mjs";
17
+ import { M365_API_HOST } from "./providers/m365-endpoint.mjs";
17
18
 
18
19
  const unavailable = reason => Object.assign(new Error(`Microsoft 365 is unavailable (${reason}); GitHub routing was not substituted`),
19
20
  { code: reason, statusCode: 503 });
@@ -250,7 +251,7 @@ function createBuiltinProviderRuntime({ githubClient, githubRegistry, githubCred
250
251
  if (closed || !enabled || source !== m365 || changingAccount) throw unavailable("m365_refresh_cancelled");
251
252
  reason = null;
252
253
  const eligible = new Set([...source.models("gpt"), ...source.models("claude")]);
253
- return { source: "catalog", checkedAt: m365.snapshot().models.refreshed_at, upstreamHost: "Microsoft 365",
254
+ return { source: "catalog", checkedAt: m365.snapshot().models.refreshed_at, upstreamHost: M365_API_HOST,
254
255
  advertised: m365.catalog().length, models: publicModelCatalog(m365.catalog(), {
255
256
  selectable: model => eligible.has(model),
256
257
  clients: model => !eligible.has(model) ? [] : model.publisher?.toLowerCase() === "anthropic" ? ["claude_code", "claude_app"] : ["codex"],
@@ -56,8 +56,11 @@ export function createApiProvider({ config, secrets, env = process.env, platform
56
56
  if (!model?.supported_endpoints.includes(paths[api])) throw accessError("ccdx_api_model_unavailable");return model;
57
57
  };
58
58
  async function request(url, body, options = {}, api = "responses") {
59
+ if (closed) throw accessError("ccdx_api_closed", 503);
59
60
  if (config.key_env && !env[config.key_env]) throw accessError("ccdx_api_environment_key_missing", 503);
60
- const key = config.key_env ? checkedApiKey(env[config.key_env]) : await secrets.get(config.secret_ref), transport = await getNetwork(options.signal);
61
+ const key = config.key_env ? checkedApiKey(env[config.key_env]) : await initialization.run("credential", () => secrets.get(config.secret_ref),
62
+ { signal: options.signal ? AbortSignal.any([options.signal, lifetime.signal]) : lifetime.signal });
63
+ const transport = await getNetwork(options.signal);
61
64
  const headers = { "Content-Type": "application/json", Accept: body?.stream ? "text/event-stream" : "application/json" };
62
65
  headers[api === "messages" && config.auth_header === "x-api-key" ? "x-api-key" : "Authorization"] = api === "messages" && config.auth_header === "x-api-key" ? key : `Bearer ${key}`;
63
66
  if (api === "messages") {
@@ -0,0 +1,4 @@
1
+ export const M365_API_ORIGIN = "https://loki.delve.office.com";
2
+ export const M365_API_HOST = new URL(M365_API_ORIGIN).hostname;
3
+ export const M365_API_PATH = "/api/v1/llmapi";
4
+ export const M365_API_BASE = `${M365_API_ORIGIN}${M365_API_PATH}`;
@@ -7,16 +7,16 @@ import { createProxyAgent } from "../proxy-tunnel.mjs";
7
7
  import { loadRuntimeConfig } from "../runtime-config.mjs";
8
8
  import { m365HelperEnvironment } from "./m365-auth.mjs";
9
9
  import { m365ProxyFailure } from "./m365-network-diagnostic.mjs";
10
+ import { M365_API_HOST as HOST, M365_API_BASE, M365_API_PATH } from "./m365-endpoint.mjs";
10
11
 
11
- const HOST = "df.loki.delve.office.com";
12
- const targetUrl = new URL(`https://${HOST}/api/v1/llmapi/models`);
12
+ const targetUrl = new URL(`${M365_API_BASE}/models`);
13
13
  const fail = code => Object.assign(new Error(`Microsoft 365 network is unavailable (${code})`), { code: `m365_${code}`, statusCode: 503 });
14
14
 
15
15
  export function requestFetch(requestImpl, agent) {
16
16
  return (raw, init = {}) => new Promise((resolve, reject) => {
17
17
  let url;try { url = new URL(raw); } catch { reject(fail("target_invalid"));return; }
18
18
  if (url.protocol !== "https:" || url.hostname !== HOST || url.port || url.username || url.password || url.hash
19
- || !url.pathname.startsWith("/api/v1/llmapi/") || !["GET", "POST", "HEAD"].includes(init.method || "GET")) { reject(fail("target_invalid"));return; }
19
+ || !url.pathname.startsWith(`${M365_API_PATH}/`) || !["GET", "POST", "HEAD"].includes(init.method || "GET")) { reject(fail("target_invalid"));return; }
20
20
  if (init.signal?.aborted) { reject(init.signal.reason);return; }
21
21
  const headers = Object.fromEntries(new Headers(init.headers));
22
22
  headers["accept-encoding"] = "identity";
@@ -19,7 +19,8 @@ import { createM365ConversationGuard } from "./m365-conversation-accounts.mjs";
19
19
  import { catalogFailure, m365CatalogDiagnostic } from "./m365-catalog-diagnostic.mjs";
20
20
  import { m365NetworkDiagnostic } from "./m365-network-diagnostic.mjs";
21
21
 
22
- export const M365_API_BASE = "https://df.loki.delve.office.com/api/v1/llmapi";
22
+ import { M365_API_BASE, M365_API_ORIGIN } from "./m365-endpoint.mjs";
23
+ export { M365_API_BASE } from "./m365-endpoint.mjs";
23
24
  const SOFT_TTL_MS = 2 * 60 * 60 * 1000;
24
25
  const HARD_TTL_MS = 7 * 24 * 60 * 60 * 1000;
25
26
  const protocolError = (code, message, statusCode = 400) => Object.assign(new Error(message), {
@@ -79,7 +80,7 @@ export function createM365Provider({ home, env = process.env, account: accountOv
79
80
  let networkDiagnostic = null, catalogDiagnostic = null;
80
81
  const registry = { models: null, source: "unavailable", cacheState: "none", cacheSavedAtMs: null,
81
82
  refreshInFlight: false, generation: 0, lastError: null, lastErrorAtMs: null };
82
- const profile = () => account ? `m365:${m365AccountKey(account)}` : "m365:unavailable";
83
+ const profile = () => account ? `m365:${M365_API_ORIGIN}:${m365AccountKey(account)}` : "m365:unavailable";
83
84
  async function transport(signal) {
84
85
  if (network?.healthy()) return network.fetch;
85
86
  if (!networkFlight) {
@@ -103,7 +104,7 @@ export function createM365Provider({ home, env = process.env, account: accountOv
103
104
  try {
104
105
  account = accountOverride || readM365Account({ home });
105
106
  const saved = readM365Json(paths.catalog);
106
- if (account && saved?.account_key === m365AccountKey(account) && Number.isFinite(saved.saved_at)
107
+ if (account && saved?.service_origin === M365_API_ORIGIN && saved.account_key === m365AccountKey(account) && Number.isFinite(saved.saved_at)
107
108
  && now() - saved.saved_at < HARD_TTL_MS) applyCatalog(saved.models, "cache", saved.saved_at);
108
109
  } catch { reason = "m365_cache_unavailable"; }
109
110
 
@@ -154,7 +155,7 @@ export function createM365Provider({ home, env = process.env, account: accountOv
154
155
  if (current !== generation || signal.aborted) throw m365Error("m365_refresh_cancelled");
155
156
  const savedAt = now();
156
157
  const nextAccount = { ...credential.account, ...(account?.history_isolation ? { history_isolation: true } : {}) };
157
- if (persist) writeM365Binding(nextAccount, { account_key: m365AccountKey(nextAccount), saved_at: savedAt, models: value }, { home, expectedAccount: account });
158
+ if (persist) writeM365Binding(nextAccount, { account_key: m365AccountKey(nextAccount), service_origin: M365_API_ORIGIN, saved_at: savedAt, models: value }, { home, expectedAccount: account });
158
159
  account = nextAccount;
159
160
  applyCatalog(value, "live", savedAt);catalogDiagnostic = null;state = "ready";reason = null;registry.lastError = null;registry.lastErrorAtMs = null;
160
161
  try { await onCatalog(value); } catch { log("warn", "M365 models are ready; optional client configuration could not be updated"); }
@@ -252,10 +253,11 @@ export function createM365Provider({ home, env = process.env, account: accountOv
252
253
  },
253
254
  commitSelection(expectedAccount) {
254
255
  if (!catalog || state !== "ready" || !account) throw m365Error("m365_not_ready");
255
- writeM365Binding(account, { account_key: m365AccountKey(account), saved_at: catalogAt, models: catalog }, { home, expectedAccount });
256
+ writeM365Binding(account, { account_key: m365AccountKey(account), service_origin: M365_API_ORIGIN, saved_at: catalogAt, models: catalog }, { home, expectedAccount });
256
257
  persist = true;
257
258
  },
258
259
  snapshot: () => ({ ...auth.snapshot(), state, reason: reason || auth.snapshot().reason, account: account ? { login: account.login, tenant: account.tenant, selection_source: account.selection_source || "legacy" } : null,
260
+ service_origin: M365_API_ORIGIN,
259
261
  network: network?.snapshot() || null,
260
262
  network_diagnostic: networkDiagnostic ? { ...networkDiagnostic } : null,
261
263
  catalog_diagnostic: m365CatalogDiagnostic(catalogDiagnostic),
@@ -102,10 +102,16 @@ export function protectInstallation({ target, prefix, platform = process.platfor
102
102
  if (!target || !prefix) return { commit() {}, rollback() {} };
103
103
  const parent = path.dirname(target);fs.mkdirSync(parent, { recursive: true });
104
104
  const lock = path.join(parent, ".ccdx-install.lock");let fd;
105
- try { fd = fs.openSync(lock, "wx", 0o600); } catch { throw new Error("Another install may be running. Check the CCDX install lock before retrying."); }
105
+ try { fd = fs.openSync(lock, "wx", 0o600); }
106
+ catch (error) {
107
+ if (error.code === "EEXIST") throw new Error(`Another install may be running. CCDX install lock: ${lock}. Inspect its owner and .ccdx-backup-* in ${parent} before recovery; do not remove an active install lock.`, { cause: error });
108
+ throw new Error(`Cannot create the CCDX install lock at ${lock} (${error.code || "I/O error"}). Check directory permissions and free space; no installation was started.`, { cause: error });
109
+ }
106
110
  let backup;
107
- try { backup = fs.mkdtempSync(path.join(parent, ".ccdx-backup-")); }
108
- catch (error) { fs.closeSync(fd);fs.unlinkSync(lock);throw error; }
111
+ try {
112
+ backup = fs.mkdtempSync(path.join(parent, ".ccdx-backup-"));
113
+ fs.writeFileSync(fd, JSON.stringify({ version: 1, pid: process.pid, created_at: new Date().toISOString(), backup }) + "\n");
114
+ } catch (error) { if (backup) fs.rmSync(backup, { recursive: true, force: true });fs.closeSync(fd);fs.unlinkSync(lock);throw error; }
109
115
  const entries = [target, ...["ccdx", "codex-copilot-dx"].flatMap(name => platform === "win32"
110
116
  ? [name, `${name}.cmd`, `${name}.ps1`].map(file => path.join(prefix, file)) : [path.join(prefix, "bin", name)])];
111
117
  const saved = [];
@@ -5,6 +5,7 @@ import { readImageProviderConfig } from "./image-provider-config.mjs";
5
5
  import { readPredictionSettings } from "./native-prediction-profile.mjs";
6
6
  import { cacheRuntimeSnapshot, cleanRuntimeCaches, setHistoryCacheLimit } from "./cache-control.mjs";
7
7
  import { isTerminalAnimationTheme } from "./terminal-animation.mjs";
8
+ import { settingsPreferencesSnapshot, writeSettingsPreferences } from "./settings-preferences.mjs";
8
9
 
9
10
  export function createServiceControl({ env = process.env, home, providerRuntime, clientIntegration, terminal,
10
11
  nightlyStatus = () => null, nightlyChanged = () => {},
@@ -17,7 +18,7 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
17
18
  try { imageConfigured = Boolean(readImages()); } catch {}
18
19
  try { predictionConfigured = readPrediction().enabled === true; } catch {}
19
20
  const enabled = nightlyUpdatePreference(options), nightly = nightlyStatus();
20
- return { source: "service_settings", saved, theme, color_theme,
21
+ return { source: "service_settings", saved, theme, color_theme, preferences: settingsPreferencesSnapshot(options),
21
22
  nightly_update: { enabled, ...nightly, effect: enabled && !nightly ? "next_start" : "immediate" },
22
23
  effective: {
23
24
  terminal_animation_enabled: { value: terminal?.enabled === true && saved.terminal_animation_enabled && !/^(0|false|no|off)$/i.test(env.CCDX_TERMINAL_ANIMATION || ""),
@@ -33,9 +34,16 @@ export function createServiceControl({ env = process.env, home, providerRuntime,
33
34
  if (!input || typeof input !== "object" || Array.isArray(input)) throw new Error("Invalid setting action");
34
35
  const allowed = { preference: ["action", "key", "value"], nightly_update: ["action", "enabled"], animation: ["action", "theme"], color_theme: ["action", "theme"],
35
36
  history_limit: ["action", "mib"], history_clean: ["action"], prediction_fix: ["action"],
37
+ preferences: ["action", "values", "revision"], reset_preferences: ["action", "revision", "backup_id"], restore_preferences: ["action", "revision", "backup_id"],
36
38
  provider: ["action", "operation", "provider", "model", "auto_review_model", "auto_review_effort", "account_id"] }[input.action];
37
39
  if (!allowed || Object.keys(input).some(key => !allowed.includes(key))) throw new Error("Unknown setting action or field");
38
- if (input.action === "nightly_update") {
40
+ if (["preferences", "reset_preferences", "restore_preferences"].includes(input.action)) {
41
+ const before = nightlyUpdatePreference(options);
42
+ writeSettingsPreferences(input, options);
43
+ const current = settingsPreferencesSnapshot(options).values;
44
+ terminal?.apply?.({ ...servicePreferences(options), theme: current.terminal_animation, color_theme: current.terminal_color_theme });
45
+ if (before !== current.nightly_updates) nightlyChanged(current.nightly_updates);
46
+ } else if (input.action === "nightly_update") {
39
47
  writeNightlyUpdatePreference(input.enabled, options);nightlyChanged(input.enabled);
40
48
  } else if (input.action === "preference") {
41
49
  writeServicePreference(input.key, input.value, options);
@@ -0,0 +1,76 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { createHash } from "node:crypto";
4
+ import { readUserSettings, userSettingsPath } from "./user-settings.mjs";
5
+ import { isColorTheme } from "./terminal-colors.mjs";
6
+ import { DEFAULT_TERMINAL_ANIMATION_THEME, isTerminalAnimationTheme } from "./terminal-animation.mjs";
7
+ import { readBoundedFileSync } from "./bounded-file.mjs";
8
+ import { atomicWriteFileIfChangedSync, atomicWriteFilePairSync } from "./atomic-file.mjs";
9
+ import { withFileLockSync } from "./lock.mjs";
10
+
11
+ export const SETTINGS_DEFAULTS = Object.freeze({ terminal_color_theme: "green", terminal_animation: DEFAULT_TERMINAL_ANIMATION_THEME,
12
+ terminal_animation_enabled: true, open_webui: true, nightly_updates: false, auto_save_settings: true });
13
+ const keys = Object.keys(SETTINGS_DEFAULTS);
14
+ const fail = (code, message, statusCode = 409) => Object.assign(new Error(message), { code, statusCode });
15
+ const idValid = value => typeof value === "string" && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(value);
16
+ const valuesFor = settings => Object.fromEntries(keys.map(key => [key, key === "terminal_animation" && !isTerminalAnimationTheme(settings[key])
17
+ ? SETTINGS_DEFAULTS[key] : settings[key] ?? SETTINGS_DEFAULTS[key]]));
18
+ const revisionFor = values => createHash("sha256").update(JSON.stringify(keys.map(key => values[key]))).digest("hex");
19
+ export const settingsBackupPath = options => path.join(path.dirname(userSettingsPath(options)), "settings-preferences-backup.json");
20
+
21
+ function checkedValues(values) {
22
+ if (!values || typeof values !== "object" || Array.isArray(values) || Object.keys(values).some(key => !keys.includes(key)
23
+ || (key === "terminal_color_theme" ? !isColorTheme(values[key]) : key === "terminal_animation" ? !isTerminalAnimationTheme(values[key]) : typeof values[key] !== "boolean"))) {
24
+ throw fail("ccdx_settings_values_invalid", "Choose valid settings on this page", 400);
25
+ }
26
+ return values;
27
+ }
28
+ function readBackup(options) {
29
+ try {
30
+ const value = JSON.parse(readBoundedFileSync(settingsBackupPath(options), { encoding: "utf8", maxBytes: 8192 }));
31
+ if (value?.version !== 1 || !idValid(value.id) || typeof value.created_at !== "string" || !Number.isFinite(Date.parse(value.created_at))
32
+ || Object.keys(value).some(key => !["version", "id", "created_at", "values"].includes(key))
33
+ || keys.some(key => !Object.hasOwn(value.values || {}, key))) throw Error();
34
+ checkedValues(value.values);return value;
35
+ } catch (error) {
36
+ if (error.code === "ENOENT") return null;
37
+ throw fail("ccdx_settings_backup_invalid", "The settings backup could not be read; existing files were preserved");
38
+ }
39
+ }
40
+ export function settingsPreferencesSnapshot(options = {}) {
41
+ const values = valuesFor(readUserSettings({ ...options, strict: true }));
42
+ let backup = null, backup_error = null;
43
+ try { const saved = readBackup(options);if (saved) backup = { id: saved.id, created_at: saved.created_at }; }
44
+ catch (error) { backup_error = error.code; }
45
+ return { values, defaults: SETTINGS_DEFAULTS, revision: revisionFor(values), backup, backup_error };
46
+ }
47
+
48
+ // Only this page's preferences enter its backup. Routing, auth, business flags
49
+ // and unknown settings are retained in the current file, never copied here.
50
+ export function writeSettingsPreferences(input, options = {}) {
51
+ const file = userSettingsPath(options);
52
+ fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
53
+ return withFileLockSync(`${file}.lock`, () => {
54
+ const current = readUserSettings({ ...options, strict: true }), before = valuesFor(current);
55
+ const backup = input.action === "preferences" ? null : readBackup(options);
56
+ if (input.action === "reset_preferences" && backup?.id === input.backup_id && revisionFor(before) === revisionFor(SETTINGS_DEFAULTS)) return;
57
+ if (typeof input.revision !== "string" || input.revision !== revisionFor(before)) {
58
+ throw fail("ccdx_settings_changed", "Settings changed elsewhere. Review the current settings before saving again");
59
+ }
60
+ let values;
61
+ if (input.action === "preferences") values = checkedValues(input.values);
62
+ else {
63
+ if (!idValid(input.backup_id)) throw fail("ccdx_settings_backup_invalid", "Choose the current settings backup", 400);
64
+ if (input.action === "restore_preferences") {
65
+ if (!backup || input.backup_id !== backup.id) throw fail("ccdx_settings_changed", "The settings backup changed. Review it before restoring");
66
+ values = backup.values;
67
+ } else if (input.action === "reset_preferences") values = SETTINGS_DEFAULTS;
68
+ else throw fail("ccdx_settings_action_invalid", "Unknown settings action", 400);
69
+ }
70
+ const next = { ...current, ...values }, data = `${JSON.stringify(next, null, 2)}\n`;
71
+ if (input.action === "reset_preferences") {
72
+ const saved = { version: 1, id: input.backup_id, created_at: new Date().toISOString(), values: before };
73
+ atomicWriteFilePairSync(settingsBackupPath(options), `${JSON.stringify(saved, null, 2)}\n`, file, data);
74
+ } else atomicWriteFileIfChangedSync(file, data, { mode: 0o600 });
75
+ });
76
+ }
@@ -63,7 +63,7 @@ export function providerStartupSummary(data = {}) {
63
63
  const connections = data.providers.connections;
64
64
  if (connections?.managed) {
65
65
  const enabled = connections.providers.filter(provider => provider.enabled);
66
- const states = { configured: "configured", not_configured: "not configured", not_installed: "not installed", preserved: "custom settings kept", configuration_unavailable: "config unavailable", partially_preserved: "partly configured", unavailable: "source unavailable" };
66
+ const states = { configured: "configured", paused: "paused", disabled: "off", not_configured: "not configured", not_installed: "not installed", preserved: "custom settings kept", configuration_unavailable: "config unavailable", partially_preserved: "partly configured", unavailable: "source unavailable" };
67
67
  const sourceLines = enabled.map(provider => `${terminalCell(provider.name)} / ${provider.builtin ? provider.id === "m365" ? terminalCell(connections.m365_state) : "sign-in checked separately" : `${provider.model_count} configured models`}`);
68
68
  const claudeLines = connections.clients.filter(client => client.id !== "codex").map(client => `${client.name}: ${!client.enabled ? "off" : client.source ? states[client.setup] || "not checked" : "paused"}`);
69
69
  return { catalogs: `${enabled.length} enabled source${enabled.length === 1 ? "" : "s"}`, claude: claudeLines.join(" / "), sourceLines, claudeLines,
@@ -0,0 +1,6 @@
1
+ // An explicit projection, never a partial replacement for the full diagnostic
2
+ // snapshot. Old callers keep the complete status contract by default.
3
+ export function statusSummary(snapshot) {
4
+ return Object.fromEntries([...['ok', 'name', 'version', 'pid', 'uptime_ms', 'model_activity', 'runtime_usage']
5
+ .map(key => [key, snapshot[key]]), ['scope', 'summary']]);
6
+ }
@@ -51,9 +51,9 @@ export function readUserSettings({ env = process.env, home = os.homedir(), stric
51
51
  delete parsed[key];
52
52
  }
53
53
  }
54
- if (Object.hasOwn(parsed, "nightly_updates") && typeof parsed.nightly_updates !== "boolean") {
55
- if (strict) throw invalidSettings(filePath, "nightly_updates must be a boolean");
56
- delete parsed.nightly_updates;
54
+ for (const key of ["nightly_updates", "auto_save_settings"]) if (Object.hasOwn(parsed, key) && typeof parsed[key] !== "boolean") {
55
+ if (strict) throw invalidSettings(filePath, `${key} must be a boolean`);
56
+ delete parsed[key];
57
57
  }
58
58
  if (Object.hasOwn(parsed, "terminal_color_theme") && !isColorTheme(parsed.terminal_color_theme)) {
59
59
  if (strict) throw invalidSettings(filePath, "terminal_color_theme must be green, klein or pink");
@@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url";
3
3
  import { spawn } from "node:child_process";
4
4
  import { PassThrough, Writable } from "node:stream";
5
5
  import { windowsPowerShellEnvironment } from "./windows-process.mjs";
6
+ import { M365_API_HOST } from "./providers/m365-endpoint.mjs";
6
7
 
7
8
  function failure(code) {
8
9
  return Object.assign(new Error(`Windows network failed (${code}); existing company routes were preserved`), { code });
@@ -16,7 +17,7 @@ export async function startWindowsHttpNetwork({ settings = {}, target = "predict
16
17
  if (target === "api" && (!Array.isArray(apiTargets) || !apiTargets.length || apiTargets.length > 8 || apiTargets.some(raw => {
17
18
  try { const url = new URL(raw);return url.protocol !== "https:" || url.username || url.password || url.search || url.hash || url.href !== raw; } catch { return true; }
18
19
  }))) throw failure("proxy_target_invalid");
19
- const allowedHosts = target === "api" ? apiTargets.map(raw => new URL(raw).hostname) : target === "m365" ? ["df.loki.delve.office.com"] : ["chatgpt.com", "ab.chatgpt.com"];
20
+ const allowedHosts = target === "api" ? apiTargets.map(raw => new URL(raw).hostname) : target === "m365" ? [M365_API_HOST] : ["chatgpt.com", "ab.chatgpt.com"];
20
21
  const command = path.win32.join(env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
21
22
  const source = fileURLToPath(new URL("./windows-prediction-network.cs", import.meta.url));
22
23
  const child = spawnImpl(command, ["-NoProfile", "-NonInteractive", "-Command",
@@ -84,7 +84,7 @@ public static class CCDXPredictionNetwork {
84
84
  IntPtr connection=IntPtr.Zero;
85
85
  try {
86
86
  var uri=new Uri((string)data["url"]);
87
- if(uri.Scheme!="https" || uri.UserInfo.Length!=0 || uri.Fragment.Length!=0 || (target=="api" ? !ApiTargetAllowed(uri,(string)data["method"]) : (uri.Port!=443 || (target=="m365" ? (uri.Host!="df.loki.delve.office.com" || !uri.AbsolutePath.StartsWith("/api/v1/llmapi/",StringComparison.Ordinal)) : (uri.Host!="chatgpt.com"&&uri.Host!="ab.chatgpt.com"))))) throw new IOException("winhttp_target_invalid");
87
+ if(uri.Scheme!="https" || uri.UserInfo.Length!=0 || uri.Fragment.Length!=0 || (target=="api" ? !ApiTargetAllowed(uri,(string)data["method"]) : (uri.Port!=443 || (target=="m365" ? (uri.Host!="loki.delve.office.com" || !uri.AbsolutePath.StartsWith("/api/v1/llmapi/",StringComparison.Ordinal)) : (uri.Host!="chatgpt.com"&&uri.Host!="ab.chatgpt.com"))))) throw new IOException("winhttp_target_invalid");
88
88
  var method=(string)data["method"];
89
89
  if(method!="GET"&&method!="POST"&&method!="HEAD"&&method!="PUT"&&method!="DELETE"&&method!="OPTIONS"&&method!="PATCH")throw new IOException("winhttp_method_invalid");
90
90
  var headers=(string)data["headers"];