codex-copilot-dx 1.2.22 → 1.2.24

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.
@@ -4,6 +4,8 @@ import { accessSettingsPath, readAccessSettings, updateAccessSettings, checkedAp
4
4
  import { createApiSecretStore, checkedApiKey } from "./api-secrets.mjs";
5
5
  import { createApiCatalogRefresh } from "./api-catalog-refresh.mjs";
6
6
  import { createApiProvider } from "./providers/api.mjs";
7
+ import { createApiModelDisplayStore } from "./api-model-display.mjs";
8
+ import { createCodexMemoryModel } from "./codex-memory-model.mjs";
7
9
  import { readClientGatewayKeys, gatewayClient } from "./client-gateway-keys.mjs";
8
10
  import { createClaudeGatewayHandler } from "./claude-gateway.mjs";
9
11
  import { configureClaudeClients, restoreClaudeClients, inspectClaudeDesktopPolicy } from "./claude-client-config.mjs";
@@ -21,12 +23,14 @@ const validObject = (value, keys) => value && typeof value === "object" && !Arra
21
23
  export function createConnectionRuntime({ legacy, home, env = process.env, platform = process.platform, corePort = 2026,
22
24
  secretStore, createApi = createApiProvider, configureClaude = configureClaudeClients, restoreClaude = restoreClaudeClients,
23
25
  configureCodex = configureCodexApi, inspectDesktop = inspectClaudeDesktopPolicy, clientAccessChanged, preserveClientConfiguration, now = Date.now, log = () => {} } = {}) {
24
- const options = { home, env, platform, preserveClientConfiguration }, secrets = secretStore || createApiSecretStore(options);
26
+ const options = { home, env, platform, preserveClientConfiguration }, secrets = secretStore || createApiSecretStore(options), modelDisplay = createApiModelDisplayStore(options);
25
27
  const guardConversation = createConversationSourceGuard(options), acquireClaudeRequest = createRequestAdmission({ maxBytes: 16 * 1024 * 1024, maxQueued: 8 });
28
+ const memoryModel = createCodexMemoryModel({ ...options, corePort });
26
29
  let settings = readAccessSettings(options), managed = fs.existsSync(accessSettingsPath(options)), serial = Promise.resolve(), keys, closed = false;
27
30
  const instances = new Map(), active = new Map(), retired = new Set(), handlers = new Map(), summaries = new WeakMap(), sourceSecrets = new WeakMap(), setup = {}, lastClients = {};
28
31
  const retiredSecrets = new Map(), cleanups = new Set(), plans = new Map(), discoveries = new Map();
29
32
  const catalogRefresh = createApiCatalogRefresh({ config: id => settings.apis.find(api => api.id === id), source: getSource, track,
33
+ complete: api => modelDisplay.has(api.id, deploymentRevision(api, env)),
30
34
  revision: api => deploymentRevision(api, env), now,
31
35
  commit: (...args) => enqueue(() => applyCatalog(...args)),
32
36
  onState: (id, state) => state ? discoveries.set(id, state) : discoveries.delete(id) });
@@ -61,7 +65,7 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
61
65
  const previous = instances.get(id), revision = deploymentRevision(config, env);if (previous?.config === config && previous.revision === revision) return previous.source;
62
66
  const signature = JSON.stringify(config) + revision;
63
67
  if (previous?.signature === signature) return previous.source;
64
- const source = createApi({ config, secrets, env: { ...env }, platform });instances.set(id, { signature, source, config, revision });sourceSecrets.set(source, config.secret_ref);
68
+ const source = createApi({ config, secrets, env: { ...env }, platform, modelDisplay: model => modelDisplay.get(id, revision, model) });instances.set(id, { signature, source, config, revision });sourceSecrets.set(source, config.secret_ref);
65
69
  if (previous) retire(previous.source);return source;
66
70
  }
67
71
  function plan(id) {
@@ -75,7 +79,15 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
75
79
  }
76
80
  function resolveDeployment(id, model) {
77
81
  const value = plan(id), record = value.routes.get(model);
78
- if (!record) throw accessError("ccdx_api_model_unavailable");
82
+ if (!record) {
83
+ const selected = binding(id), configured = selected.deployments || [{ source: selected.source, model: selected.model }];
84
+ const matches = configured.filter(item => item.model === model || deploymentModelId(item.source, item.model) === model);
85
+ const reason = !selected.enabled ? "ccdx_client_source_disabled" : matches.length > 1 ? "ccdx_model_ambiguous"
86
+ : matches.length && !permitted(id, matches[0].source) ? "ccdx_client_source_disabled"
87
+ : matches.length ? "ccdx_model_catalog_unavailable" : "ccdx_model_not_selected";
88
+ const error = accessError("ccdx_api_model_unavailable");error.jsonBody.error.reason = reason;
89
+ currentRequestContext()?.onHttpError?.({ code: error.code, origin: "client_validation", reason });throw error;
90
+ }
79
91
  const provider = requireSource(id, record.source);
80
92
  if (provider !== record.provider) { plans.delete(id);return resolveDeployment(id, model); }
81
93
  return record;
@@ -113,9 +125,11 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
113
125
  return structuredClone({ source: "connections", providers: [
114
126
  { id: "github", name: "GitHub Copilot", enabled: config.providers.github, builtin: true, protocols: ["responses"] },
115
127
  { id: "m365", name: "Microsoft 365", enabled: config.providers.m365, builtin: true, protocols: ["messages", "responses"] },
116
- ...config.apis.map(api => { const { secret_ref, ...publicApi } = api;return { ...(compact ? { id: api.id, name: api.name, enabled: api.enabled } : publicApi),
117
- ...summary(api), ...(compact ? {} : { deployment_revision: deploymentRevision(api, env) }), discovery: discoveries.get(api.id) || null, builtin: false, key_saved: api.key_env ? Boolean(env[api.key_env]) : Boolean(secret_ref) }; }),
128
+ ...config.apis.map(api => { const { secret_ref, ...publicApi } = api, revision = compact ? null : deploymentRevision(api, env);return { ...(compact ? { id: api.id, name: api.name, enabled: api.enabled } : publicApi),
129
+ ...summary(api), ...(compact ? {} : { deployment_revision: revision,
130
+ model_display: Object.fromEntries(api.models.map(model => [model.id, modelDisplay.get(api.id, revision, model.id)])) }), discovery: discoveries.get(api.id) || null, builtin: false, key_saved: api.key_env ? Boolean(env[api.key_env]) : Boolean(secret_ref) }; }),
118
131
  ], clients: CLIENT_IDS.map(id => ({ id, name: CLIENT_NAMES[id], ...config.clients[id], setup: setup[id] || null,
132
+ ...(id === "codex" ? { memory_model: memoryModel.snapshot() } : {}),
119
133
  observed_at: lastClients[id] || null, ...(compact ? {} : { model_plan: { default_model: plan(id).defaultModel, default_unavailable: plan(id).defaultUnavailable,
120
134
  models: plan(id).models.map(model => ({ source: model.source_id, id: model.id, public_id: model.public_id, route_id: model.route_id, capability: model.capability })),
121
135
  unavailable: (config.clients[id].deployments || []).filter(item => !plan(id).models.some(model => model.source_id === item.source && model.id === item.model))
@@ -186,6 +200,7 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
186
200
  const next = editable(), current = next.apis.find(api => api.id === id);
187
201
  if (!current?.enabled || deploymentRevision(current, env) !== revision) throw accessError("ccdx_connections_conflict", 409);
188
202
  const byId = new Map(models.map(model => [model.id, model]));
203
+ try { modelDisplay.set(id, revision, models); } catch { log("warn", "Model maker metadata could not be saved; routing is unchanged"); }
189
204
  for (const model of current.models) if (byId.get(model.id)?.metadata) model.metadata = byId.get(model.id).metadata;
190
205
  current.checked_at = checkedAt;
191
206
  if (JSON.stringify(current) !== JSON.stringify(settings.apis.find(api => api.id === id))) {
@@ -201,7 +216,14 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
201
216
  if (input.operation === "save_api") {
202
217
  const existing = next.apis.find(api => api.id === input.id);
203
218
  if (!existing && next.apis.length >= 16) throw accessError("ccdx_api_limit");
204
- if (!validObject(input.config, ["name", "base_url", "endpoints", "auth_header", "models", "key_env"])) throw accessError("ccdx_api_config_invalid");
219
+ if (!validObject(input.config, ["name", "base_url", "endpoints", "auth_header", "models", "key_env", "model_display"])) throw accessError("ccdx_api_config_invalid");
220
+ // Existing clients round-trip catalog data. New display-only fields must
221
+ // remain readable without becoming editable connection configuration.
222
+ const { model_display, ...editableConfig } = input.config;
223
+ input = { ...input, config: { ...editableConfig, models: Array.isArray(editableConfig.models) ? editableConfig.models.map(model => {
224
+ if (!model || typeof model !== "object" || Array.isArray(model)) return model;
225
+ const { display, ...editable } = model;return editable;
226
+ }) : editableConfig.models } };
205
227
  const id = existing?.id || "api_" + randomBytes(8).toString("hex");
206
228
  if (input.key !== undefined && input.key !== "") { checkedApiKey(input.key);freshRef = randomBytes(16).toString("hex"); }
207
229
  if (input.config.key_env && freshRef || !input.config.key_env && !freshRef && !existing?.secret_ref) throw accessError("ccdx_api_key_invalid");
@@ -328,7 +350,7 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
328
350
  busy: () => operations > 0 || active.size > 0 || Boolean(syncFlight) || catalogRefresh.busy() || legacy.snapshot().m365.account_change_in_flight === true || legacy.snapshot().m365.state === "checking",
329
351
  syncClients,
330
352
  async manageConnections(input) {
331
- if (!input) return snapshot();
353
+ if (!input) { if (binding("codex").enabled) void memoryModel.refresh();return snapshot(); }
332
354
  if (validObject(input, ["operation", "id"]) && input.operation === "discover") {
333
355
  const models = await catalogRefresh.refresh(input.id, true);return { ...snapshot(), discovered: models };
334
356
  }
@@ -340,7 +362,7 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
340
362
  } else if (input.operation === "provider" && input.enabled && input.id?.startsWith("api_")) void catalogRefresh.refresh(input.id).catch(() => {});
341
363
  return input.operation === "save_api" ? snapshot() : result;
342
364
  },
343
- async start() { const old = legacy.start();if (managed) await syncClients();const result = await old;if (managed) await syncClients();void refreshApis();return result; },
365
+ async start() { if (binding("codex").enabled) void memoryModel.refresh();const old = legacy.start();if (managed) await syncClients();const result = await old;if (managed) await syncClients();void refreshApis();return result; },
344
366
  async refresh() { const result = await Promise.allSettled([!managed || settings.providers.m365 ? legacy.refresh() : Promise.resolve(), refreshApis()]);if (result[0].status === "rejected") throw result[0].reason; },
345
367
  selection() { return { ...legacy.selection(), codex: binding("codex").enabled ? binding("codex").source : null }; },
346
368
  providerPreference(id) {
@@ -484,6 +506,6 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
484
506
  if (managed && input.action === "switch") { const next = editable();if (next.clients.codex.source !== input.provider) next.clients.codex.history_isolation = true;next.clients.codex.source = input.provider;next.clients.codex.deployments = null;next.clients.codex.default_model = null;for (const key of ["model", "auto_review_model", "auto_review_effort"]) delete next.clients.codex[key];if (input.provider === "m365") Object.assign(next.clients.codex, legacy.selection().m365);save(next);await syncClients(); }
485
507
  return result;
486
508
  },
487
- async close() { closed = true;await catalogRefresh.close();await serial;await syncFlight;for (const { source } of instances.values()) source.close();for (const source of retired) source.close();active.clear();for (const id of retiredSecrets.keys()) cleanSecrets(id);await Promise.allSettled([...cleanups]);secrets.close();await legacy.close(); },
509
+ async close() { closed = true;await memoryModel.close();await catalogRefresh.close();await serial;await syncFlight;for (const { source } of instances.values()) source.close();for (const source of retired) source.close();active.clear();for (const id of retiredSecrets.keys()) cleanSecrets(id);await Promise.allSettled([...cleanups]);secrets.close();await legacy.close(); },
488
510
  };
489
511
  }
@@ -22,7 +22,9 @@ export function createConversationSourceGuard(options = {}) {
22
22
  const identified = typeof session === "string" && session.length > 0 && session.length <= 512 && !/[\u0000-\u001f\u007f]/.test(session);
23
23
  const first = items.find(item => item?.role === "user"), input = identified ? `session\0${session}` : first ? `first\0${JSON.stringify(first)}` : typeof body.input === "string" ? `first\0${body.input}` : null;
24
24
  if (!input) return;
25
- const key = hash(client + "\0" + input), owner = hash(profile);
25
+ const agent = headers["x-claude-code-agent-id"];
26
+ const child = identified && ["claude_app", "claude_code"].includes(client) && typeof agent === "string" && /^[\w-]{1,128}$/.test(agent) ? `\0agent\0${agent}` : "";
27
+ const key = hash(client + "\0" + input + child), owner = hash(profile);
26
28
  if (cache?.[key] === owner) return;
27
29
  if (cache?.[key] && (identified || hasHistory)) throw accessError("ccdx_conversation_source_changed", 409);
28
30
  fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
@@ -3,6 +3,7 @@
3
3
  const words = (node, key, args) => globalThis.ccdxLanguage.set(node, key, args), format = key => globalThis.ccdxLanguage.format(key);
4
4
  let data = null, editing = null, editingClient = null, disabling = null, models = [], selectedModels = new Set(), busy = false, generation = 0;
5
5
  let claudeClient = "claude_app", bindingSelection = new Set(), bindingDefault = null, bindingDirty = false;
6
+ let memoryAction = null, memoryOrigin = null;
6
7
  const drafts = new Map();let editorOrigin = null, discovery = null, desiredSource = null;
7
8
  const apiForm = el("connection-api-form"), clientForm = el("connection-client-form");
8
9
  const node = (tag, text, className) => { const item = document.createElement(tag);if (text !== undefined) item.textContent = text;if (className) item.className = className;return item; };
@@ -112,6 +113,12 @@
112
113
  const protocol = choice(model.protocols.map(id => ({ id, name: id === "messages" ? "Messages" : id === "responses" ? "Responses" : "Chat" })), model.protocols.includes("messages") ? "messages" : model.protocols[0], false);
113
114
  protocol.setAttribute("aria-label", format("cap_api"));detail.append(protocol);
114
115
  const status = node("p", undefined, "hint"), table = node("table"), body = node("tbody");table.append(body);detail.append(status, table);
116
+ const maker = model.display || source(editing)?.model_display?.[model.id] || {};
117
+ const identity = node("dl", undefined, "model-identity");
118
+ for (const [label, value] of [["vendor", maker.publisher || maker.vendor || format("cap_unknown")], ["model_owner", maker.owned_by]]) {
119
+ if (!value) continue;const term = node("dt");words(term, label);identity.append(term, node("dd", value));
120
+ }
121
+ detail.insertBefore(identity, protocol);
115
122
  const advanced = node("details"), summary = node("summary");words(summary, "cap_manual");advanced.append(summary);detail.append(advanced);
116
123
  const note = node("p", undefined, "hint");words(note, "cap_metadata_scope");advanced.append(note);
117
124
  const fields = node("div", undefined, "connection-fields");
@@ -177,6 +184,8 @@
177
184
  tr.dataset.model = model.id;
178
185
  const selection = check("selected-model", model.id, selectedModels.has(model.id), model.id);
179
186
  selection.firstChild.addEventListener("change", e => { if (e.target.checked) selectedModels.add(model.id);else selectedModels.delete(model.id); });name.append(selection);
187
+ const maker = model.display || source(editing)?.model_display?.[model.id];
188
+ if (maker?.publisher || maker?.vendor) name.append(node("span", maker.publisher || maker.vendor, "model-maker"));
180
189
  for (const protocol of ["messages", "responses", "chat"]) {
181
190
  const label = check("model-api", protocol, model.protocols.includes(protocol), protocol === "chat" ? "Chat" : protocol === "messages" ? "Messages" : "Responses");
182
191
  label.firstChild.disabled = !apiForm.querySelector(`[name="protocol"][value="${protocol}"]`).checked;
@@ -212,7 +221,7 @@
212
221
  apiForm.elements.key_env.addEventListener("input", keyMode);
213
222
  apiForm.addEventListener("submit", e => {
214
223
  e.preventDefault();if (busy || !apiForm.reportValidity()) return;
215
- const chosenModels = models.filter(model => selectedModels.has(model.id));
224
+ const chosenModels = models.filter(model => selectedModels.has(model.id)).map(({ display, ...model }) => model);
216
225
  const invalid = chosenModels.find(model => !model.protocols.length);
217
226
  if (invalid) {
218
227
  message("api_model_protocol_required", { model: invalid.id });
@@ -242,11 +251,43 @@
242
251
  try {
243
252
  const result = await api({ operation: "discover", id: read.id }, read.controller.signal);if (discovery !== read || editing !== read.id) return;
244
253
  data = result;
245
- const known = new Map(models.map(model => [model.id, model]));for (const model of result.discovered || []) { const previous = known.get(model.id);known.set(model.id, previous ? { ...previous, ...(model.metadata ? { metadata: model.metadata } : {}) } : model); }
254
+ const known = new Map(models.map(model => [model.id, model]));for (const model of result.discovered || []) { const previous = known.get(model.id);known.set(model.id, previous ? { ...previous, ...(model.display ? { display: model.display } : {}), ...(model.metadata ? { metadata: model.metadata } : {}) } : model); }
246
255
  models = [...known.values()].slice(0, 500);modelRows();message("api_models_read");
247
256
  } catch (error) { if (discovery === read) message(error.message); }
248
257
  finally { if (discovery === read) { discovery = null;trigger.disabled = false;trigger.removeAttribute("aria-busy");words(trigger, "api_read_models");el("connection-discover-cancel").hidden = true; } }
249
258
  });
259
+ function memoryMatches(item) {
260
+ const model = client("codex")?.memory_model?.model;
261
+ return Boolean(model && [item.id, item.model, item.route_id, item.public_id].includes(model));
262
+ }
263
+ function memoryRender() {
264
+ const area = el("connection-memory-model");if (!area || !data) return;
265
+ area.hidden = editingClient !== "codex";if (area.hidden) return;
266
+ const c = client("codex"), dep = c.memory_model || {};
267
+ el("connection-memory-name").textContent = dep.model || format("memory_not_detected");
268
+ words(el("connection-memory-basis"), dep.model ? `memory_basis_${dep.basis}` : "");
269
+ const selected = (c.deployments || c.model_plan?.models || []).some(memoryMatches);
270
+ const draft = dep.model && [...bindingSelection].some(key => {
271
+ const [source, id] = key.split("\0");return memoryMatches({ id, route_id: c.model_plan?.available?.find(x => x.source === source && x.id === id)?.route_id });
272
+ });
273
+ const pending = bindingDirty && Boolean(draft) !== selected;
274
+ const label = !dep.model ? "memory_not_detected" : dep.enabled === false ? "memory_generation_off" : pending ? draft ? "memory_pending_on" : "memory_pending_off" : selected ? "memory_model_on" : "memory_model_off";
275
+ const state = el("connection-memory-state");state.hidden = !dep.model;
276
+ if (globalThis.ccdxIcons) globalThis.ccdxIcons.set(state, label, dep.enabled === false ? "unavailable" : !selected || pending && !draft ? "warning" : "ok");else words(state, label);
277
+ const warning = el("connection-memory-warning");warning.hidden = !dep.model || dep.enabled === false || selected && !pending;
278
+ words(warning, selected && pending && !draft ? "memory_pending_warning" : "memory_off_warning");
279
+ }
280
+ function confirmMemory(action) {
281
+ memoryAction = action;memoryOrigin = document.activeElement;
282
+ el("connection-memory-confirm").showModal();el("connection-memory-keep").focus();
283
+ }
284
+ function closeMemory(confirm) {
285
+ const action = memoryAction;memoryAction = null;el("connection-memory-confirm").close();
286
+ if (confirm) action?.();else if (memoryOrigin?.isConnected) memoryOrigin.focus();
287
+ }
288
+ el("connection-memory-keep").addEventListener("click", () => closeMemory(false));
289
+ el("connection-memory-close").addEventListener("click", () => closeMemory(true));
290
+ el("connection-memory-confirm").addEventListener("cancel", () => { memoryAction = null; });
250
291
  const bindingKey = (source, model) => source + "\0" + model;
251
292
  const routeId = item => item.route_id || item.public_id;
252
293
  function rememberDraft() {
@@ -271,6 +312,7 @@
271
312
  bindingRows(document.activeElement?.name === "binding-model" ? { kind: "selection", key: document.activeElement.value } : document.activeElement?.dataset.binding ? { kind: "default", key: document.activeElement.dataset.binding } : null);words(el("connection-client-title"), "cap_visible_model");list();
272
313
  }
273
314
  function bindingRows(focus) {
315
+ memoryRender();
274
316
  el("connection-client-cancel").disabled = !bindingDirty;
275
317
  const body = el("connection-bindings"), c = client(editingClient);body.replaceChildren();
276
318
  const available = c.model_plan?.available || [], availableKeys = new Set(available.map(item => bindingKey(item.source, item.id)));
@@ -279,10 +321,16 @@
279
321
  const key = bindingKey(item.source, item.id), row = node("tr"), name = node("td"), capability = item.capability?.values || {};
280
322
  const selection = check("binding-model", key, bindingSelection.has(key), item.id);
281
323
  selection.firstChild.addEventListener("change", event => {
282
- bindingDirty = true;if (event.target.checked) { bindingSelection.add(key);bindingDefault ||= routeId(item); }
283
- else { bindingSelection.delete(key);if (bindingDefault === routeId(item) || !bindingSelection.size) bindingDefault = null; }
284
- rememberDraft();bindingRows({ kind: "selection", key });
324
+ const checked = event.target.checked;
325
+ const apply = () => {
326
+ bindingDirty = true;if (checked) { bindingSelection.add(key);bindingDefault ||= routeId(item); }
327
+ else { bindingSelection.delete(key);if (bindingDefault === routeId(item) || !bindingSelection.size) bindingDefault = null; }
328
+ rememberDraft();bindingRows({ kind: "selection", key });
329
+ };
330
+ if (!checked && editingClient === "codex" && client("codex").memory_model?.enabled !== false && memoryMatches(item)) { event.target.checked = true;confirmMemory(apply); }
331
+ else apply();
285
332
  });name.append(selection);
333
+ if (editingClient === "codex" && memoryMatches(item)) { const badge = node("span", undefined, "memory-model-badge");words(badge, "memory_extract_role");name.append(badge); }
286
334
  const action = button(bindingDefault === routeId(item) && bindingSelection.has(key) ? "cap_default" : "cap_set_default", () => { bindingDirty = true;bindingSelection.add(key);bindingDefault = routeId(item);rememberDraft();bindingRows({ kind: "default", key }); });
287
335
  action.setAttribute("aria-pressed", String(bindingDefault === routeId(item) && bindingSelection.has(key)));
288
336
  action.dataset.binding = key;action.disabled = Boolean(item.unavailable);action.setAttribute("aria-label", item.id + " · " + format(bindingDefault === routeId(item) ? "cap_default" : "cap_set_default"));
@@ -313,7 +361,11 @@
313
361
  }
314
362
  clientForm.addEventListener("submit", event => { event.preventDefault();void change(bindingInput("client")); });
315
363
  el("connection-sync-preview").addEventListener("click", () => void change(bindingInput("preview_client"), result => syncPreview(result.preview)));
316
- function disableSource(provider) {
364
+ function disableSource(provider, confirmed = false) {
365
+ const c = client("codex");
366
+ if (!confirmed && c?.enabled && c.memory_model?.enabled !== false && c.model_plan?.models.some(item => item.source === provider.id && memoryMatches(item))) {
367
+ confirmMemory(() => disableSource(provider, true));return;
368
+ }
317
369
  const affected = data.clients.filter(c => c.enabled && c.source === provider.id);
318
370
  if (!affected.length) { void change({ operation: "provider", id: provider.id, enabled: false });return; }
319
371
  disabling = provider.id;panels("disable");const area = el("connection-replacements");area.replaceChildren();
@@ -323,12 +375,14 @@
323
375
  replacements: Object.fromEntries([...el("connection-replacements").querySelectorAll("select")].map(select => [select.name, select.value || null])) }); });
324
376
  el("connection-add").addEventListener("click", () => { if (data) editApi(); });
325
377
  for (const id of ["connection-cancel", "connection-disable-cancel"]) el(id).addEventListener("click", () => { panels();(editorOrigin?.isConnected ? editorOrigin : el("connection-source-list").querySelector("button") || el("connection-add")).focus(); });
378
+ el("refresh").addEventListener("click", () => { if (["#models", "#codex", "#claude"].includes(location.hash)) void load(); });
326
379
  window.addEventListener("hashchange", () => { apiForm.elements.key.value = "";mountClient();if (["#models", "#claude", "#codex"].includes(location.hash)) void load(); });
327
380
  window.addEventListener("ccdx:choose-source", event => { if (typeof event.detail?.id === "string" && providerEntries.some(p => p.id === event.detail.id)) chooseProvider(event.detail.id); });
328
381
  window.addEventListener("ccdx:source-view", () => { if (data) list(); });
329
382
  window.addEventListener("ccdx:providers", () => { if (desiredSource && providerEntries.some(p => p.id === desiredSource)) { const id = desiredSource;desiredSource = null;chooseProvider(id); }if (data) list(); });
330
383
  new MutationObserver(() => { if (data) list(); }).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
331
- globalThis.ccdxConnections = { load, editClient: id => { if (data && client(id)) { editClient(client(id)); } } };
384
+ globalThis.ccdxConnections = { load,
385
+ updateMemory(snapshot) { const c = snapshot?.clients?.find(c => c.id === "codex");if (data && c?.memory_model) { client("codex").memory_model = c.memory_model;memoryRender(); } }, editClient: id => { if (data && client(id)) { editClient(client(id)); } } };
332
386
  for (const button of document.querySelectorAll("[data-client-access]")) button.addEventListener("click", () => globalThis.ccdxConnections.editClient(button.dataset.clientAccess));
333
387
  void load();
334
388
  })();
@@ -289,7 +289,7 @@
289
289
  // Only the small in-memory status snapshot is read at this cadence. Catalogs
290
290
  // and retained usage keep their existing on-demand, bounded refresh policy.
291
291
  function schedule() {
292
- clearTimeout(timer);if (stopped) return;
292
+ clearTimeout(timer);if (stopped || document.visibilityState !== "visible" || !dashboardRefresh.automatic) return;
293
293
  timer = setTimeout(async () => {
294
294
  if (document.visibilityState === "visible" && dashboardRefresh.automatic) {
295
295
  await dashboardRefresh.refresh("status", { force: true });
@@ -302,6 +302,11 @@
302
302
  }, 2000);
303
303
  }
304
304
  window.addEventListener("hashchange", navigate);
305
+ document.addEventListener("visibilitychange", () => {
306
+ if (!stopped && document.visibilityState === "visible" && dashboardRefresh.automatic) void dashboardRefresh.refresh("status", { force: true });
307
+ schedule();
308
+ });
309
+ el("auto-refresh").addEventListener("click", schedule);
305
310
  el("refresh").addEventListener("click", () => { if (settingsViews.includes(current)) void loadSettings(); });
306
311
  window.addEventListener("pagehide", () => { stopped = true;clearTimeout(timer); });
307
312
  window.addEventListener("pageshow", () => { stopped = false;schedule(); });
@@ -8,8 +8,9 @@
8
8
  const nodes = { apps: new Map(), models: new Map() };
9
9
  const detailRows = new Map();
10
10
  let rows = [], total = null, omitted = 0, fresh = false, deadline = 0, expiry = null;
11
- let selected = null, expanded = false, lastSignature = "", geometry = "", known = false;
11
+ let selected = null, expanded = false, lastSignature = "", geometry = "", wireState = "", positions = null, known = false;
12
12
  let lastApps = [], lastModels = [];
13
+ const resize = new ResizeObserver(() => { positions = null;draw(); });
13
14
  const visible = () => document.visibilityState === "visible" && !root.closest("[hidden]");
14
15
  const integer = value => Number.isSafeInteger(value) && value >= 0;
15
16
  const appName = id => format(`flow_app_${id}`);
@@ -47,7 +48,7 @@
47
48
  function project(type, groups) {
48
49
  const target = el(type === "apps" ? "flow-apps" : "flow-models"), cache = nodes[type], fragments = [];
49
50
  const ids = new Set(groups.map(group => group.id));
50
- for (const [id, node] of cache) if (!ids.has(id)) { node.remove();cache.delete(id); }
51
+ for (const [id, node] of cache) if (!ids.has(id)) { resize.unobserve?.(node);node.remove();cache.delete(id);positions = null; }
51
52
  for (const group of groups) {
52
53
  let node = cache.get(group.id);
53
54
  if (!node) {
@@ -59,15 +60,16 @@
59
60
  });
60
61
  node.append(button, count, note);
61
62
  if (type === "models") node.append(entry("span", "flow-source"));
62
- cache.set(group.id, node);
63
+ cache.set(group.id, node);resize.observe(node);positions = null;
63
64
  }
64
65
  const [button, count, note] = node.children;
65
- button.textContent = type === "apps" ? appName(group.id) : modelName(group.model);
66
+ const title = type === "apps" ? appName(group.id) : modelName(group.model);
67
+ if (button.textContent !== title) { button.textContent = title;positions = null; }
66
68
  button.setAttribute("aria-pressed", String(selected?.type === type && selected.id === group.id));
67
69
  count.hidden = fresh && omitted === 0 && group.rows.length < 2;
68
70
  if (fresh && (group.rows.length || total === 0)) label(count, omitted ? "flow_count_lower" : "flow_count", { count: group.rows.length.toLocaleString() });
69
71
  else count.textContent = "—";
70
- if (type === "models") node.children[3].textContent = sourceName(group.provider);
72
+ if (type === "models" && node.children[3].textContent !== sourceName(group.provider)) { node.children[3].textContent = sourceName(group.provider);positions = null; }
71
73
  const output = group.rows.filter(responding).length;
72
74
  const phase = group.rows.every(row => row.terminal_outcome) ? "flow_finishing"
73
75
  : group.rows.every(row => row.upstream_attempts > 1) ? "flow_retrying" : "flow_waiting";
@@ -77,7 +79,7 @@
77
79
  // Keep existing buttons and their focus when counts or phases change.
78
80
  const wanted = new Set(fragments);
79
81
  for (const node of [...target.children]) if (!wanted.has(node)) node.remove();
80
- fragments.forEach((node, index) => { if (target.children[index] !== node) target.insertBefore(node, target.children[index] || null); });
82
+ fragments.forEach((node, index) => { if (target.children[index] !== node) { target.insertBefore(node, target.children[index] || null);positions = null; } });
81
83
  }
82
84
  function details() {
83
85
  label(el("flow-active-title"), fresh ? "flow_active_count" : "flow_last_count", { count: rows.filter(related).length });
@@ -119,7 +121,7 @@
119
121
  label(el("flow-more"), expanded ? "flow_fewer_models" : "flow_more_models", { count: Math.max(0, models.length - 12) });
120
122
  project("apps", shownApps);
121
123
  project("models", expanded ? models : models.slice(0, 12));
122
- geometry = "";draw();
124
+ draw();
123
125
  }
124
126
  function rounded(x0, y0, x1, y1) {
125
127
  if (Math.abs(y1 - y0) < 2) return `M${x0} ${y0}H${x1}`;
@@ -128,25 +130,37 @@
128
130
  }
129
131
  function draw() {
130
132
  if (!visible()) return;
131
- const network = el("flow-network"), rect = network.getBoundingClientRect(), hub = el("flow-hub").getBoundingClientRect(), edges = [];
132
- const inset = rect.width < 500 ? 2 : 6;
133
- if (!rect.width) return;
134
- for (const type of ["apps", "models"]) for (const [id, node] of nodes[type]) {
135
- if (!node.isConnected) continue;
136
- const box = node.getBoundingClientRect(), button = node.children[0].getBoundingClientRect(), left = type === "apps";
137
- const x0 = (left ? box.right : hub.right) - rect.left + inset, y0 = (left ? button.top + button.height / 2 : hub.top + hub.height / 2) - rect.top;
138
- const x1 = (left ? hub.left : box.left) - rect.left - inset, y1 = (left ? hub.top + hub.height / 2 : button.top + button.height / 2) - rect.top;
139
- if (x1 <= x0) continue;
140
- const matches = rows.filter(row => (left ? row.application : modelKey(row)) === id && related(row));
141
- edges.push({ d: rounded(x0, y0, x1, y1), active: fresh && matches.length > 0, moving: fresh && matches.some(responding), dim: node.dataset.related === "false", x: left ? x0 : x1, y: left ? y0 : y1, left });
133
+ if (!positions) {
134
+ const network = el("flow-network"), rect = network.getBoundingClientRect(), hub = el("flow-hub").getBoundingClientRect(), edges = [];
135
+ const inset = rect.width < 500 ? 2 : 6;
136
+ if (!rect.width) return;
137
+ for (const type of ["apps", "models"]) for (const [id, node] of nodes[type]) {
138
+ if (!node.isConnected) continue;
139
+ const box = node.getBoundingClientRect(), button = node.children[0].getBoundingClientRect(), left = type === "apps";
140
+ const x0 = (left ? box.right : hub.right) - rect.left + inset, y0 = (left ? button.top + button.height / 2 : hub.top + hub.height / 2) - rect.top;
141
+ const x1 = (left ? hub.left : box.left) - rect.left - inset, y1 = (left ? hub.top + hub.height / 2 : button.top + button.height / 2) - rect.top;
142
+ if (x1 <= x0) continue;
143
+ edges.push({ id, type, node, d: rounded(x0, y0, x1, y1), x: left ? x0 : x1, y: left ? y0 : y1, left });
144
+ }
145
+ positions = { width: rect.width, height: rect.height, edges };
142
146
  }
143
- const next = JSON.stringify([rect.width, rect.height, edges]);if (next === geometry) return;geometry = next;
144
- const wires = el("flow-wires");wires.setAttribute("viewBox", `0 0 ${rect.width} ${rect.height}`);wires.replaceChildren();
145
- for (const edge of edges) {
146
- wires.append(svg("path", { d: edge.d, class: `flow-wire${edge.dim ? " flow-dim" : edge.active ? " flow-live" : ""}` }));
147
- if (edge.moving) { const dot = svg("circle", { r: 2.4, class: "flow-packet" });dot.style.offsetPath = `path('${edge.d}')`;dot.style.animationDelay = edge.left ? "-.9s" : "0s";wires.append(dot); }
148
- else if (edge.active) wires.append(svg("circle", { cx: edge.x, cy: edge.y, r: 2.4, class: "flow-wait" }));
147
+ const { width, height, edges } = positions;
148
+ const next = JSON.stringify([width, height, edges.map(edge => [edge.type, edge.id, edge.d])]);
149
+ const states = edges.map(edge => {
150
+ const matches = rows.filter(row => (edge.left ? row.application : modelKey(row)) === edge.id && related(row));
151
+ return { active: fresh && matches.length > 0, moving: fresh && matches.some(responding), dim: edge.node.dataset.related === "false" };
152
+ });
153
+ const state = JSON.stringify(states), wires = el("flow-wires");
154
+ if (next === geometry && state === wireState) return;
155
+ if (next !== geometry) {
156
+ geometry = next;wires.setAttribute("viewBox", `0 0 ${width} ${height}`);wires.replaceChildren();
157
+ for (const edge of edges) wires.append(svg("path", { d: edge.d }));
149
158
  }
159
+ wireState = state;
160
+ edges.forEach((edge, index) => {
161
+ const value = states[index], path = wires.children[index];
162
+ path.setAttribute("class", `flow-wire${value.dim ? " flow-dim" : value.active ? " flow-live" : ""}${value.moving ? " flow-streaming" : value.active ? " flow-waiting" : ""}`);
163
+ });
150
164
  }
151
165
  function unavailable() { clearTimeout(expiry);expiry = null;fresh = false;deadline = 0;render(); }
152
166
  function visibilityChanged() { if (deadline && Date.now() >= deadline) { unavailable();return; }render();draw(); }
@@ -157,8 +171,8 @@
157
171
  document.addEventListener("visibilitychange", visibilityChanged);
158
172
  globalThis.addEventListener("pagehide", () => { root.dataset.paused = "true"; });
159
173
  globalThis.addEventListener("pageshow", visibilityChanged);
160
- new ResizeObserver(draw).observe(el("flow-network"));
161
- new MutationObserver(() => { lastSignature = "";render(); }).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
174
+ resize.observe(el("flow-network"));
175
+ new MutationObserver(() => { lastSignature = "";positions = null;render(); }).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
162
176
  globalThis.ccdxDashboardFlow = {
163
177
  update(data) {
164
178
  const parts = [data?.stream_performance, (data?.providers?.claude || data?.providers?.m365?.claude)?.requests?.performance].filter(Boolean);
@@ -72,6 +72,10 @@
72
72
  <section class="panel dashboard-section" id="connection-client-editor" hidden aria-labelledby="connection-client-title">
73
73
  <div class="panel-heading"><h2 id="connection-client-title"></h2><span id="connection-draft-state" class="hint"></span></div>
74
74
  <form id="connection-client-form">
75
+ <div id="connection-memory-model" hidden>
76
+ <div class="memory-model-row"><span data-i18n="memory_extract_model">Memory extraction model</span><div class="memory-model-value"><strong id="connection-memory-name">—</strong><span id="connection-memory-basis" class="hint"></span><span id="connection-memory-state"></span></div></div>
77
+ <p id="connection-memory-warning" class="memory-model-notice" role="status" hidden></p>
78
+ </div>
75
79
  <p id="connection-default-note" class="hint" role="status" hidden></p>
76
80
  <div class="table-wrap"><table class="binding-table"><thead><tr><th data-i18n="model">Model</th><th data-i18n="source">Source</th><th data-i18n="cap_context">Context</th><th data-i18n="cap_reasoning">Reasoning</th><th data-i18n="cap_default">Default</th></tr></thead><tbody id="connection-bindings"></tbody></table></div>
77
81
  <div class="setting-row"><label for="connection-auto-sync" data-i18n="cap_auto_sync">Sync model settings</label><input id="connection-auto-sync" type="checkbox" role="switch" checked><span class="hint" data-i18n="cap_sync_scope">Preserves your manual settings.</span></div>
@@ -328,6 +332,8 @@
328
332
  </details>
329
333
  <details class="lower" id="recent-failures" open>
330
334
  <summary class="panel-heading"><h2 data-i18n="recent_inference_http_failures">RECENT REQUEST ISSUES</h2><span id="failure-count">requests + events</span></summary>
335
+ <label for="failure-kind" class="sr-only" data-i18n="issue_category">Issue category</label>
336
+ <select id="failure-kind"><option value="issues" data-i18n="issue_replies">Reply issues</option><option value="capability" data-i18n="issue_capabilities">Capability notices</option><option value="connection" data-i18n="issue_connections">Connections and paths</option></select>
331
337
  <ol id="failures"><li class="empty" data-i18n="reading_874bf">Reading…</li></ol>
332
338
  </details>
333
339
  </div>
@@ -412,5 +418,6 @@
412
418
  </main>
413
419
  <footer data-i18n="local_only_visible_page_updates">THIS COMPUTER ONLY / UPDATES WHILE VISIBLE</footer>
414
420
  </div>
421
+ <dialog id="connection-memory-confirm" class="memory-confirm" aria-labelledby="connection-memory-confirm-title"><h2 id="connection-memory-confirm-title" data-i18n="memory_close_title">Turn off the memory extraction model?</h2><p data-i18n="memory_close_body">Codex uses this model to extract new memories. Turning it off may prevent new memory generation.</p><p class="hint" data-i18n="memory_existing_kept">Existing memories will not be deleted.</p><div class="section-actions"><button type="button" id="connection-memory-keep" data-i18n="memory_keep_enabled">Keep enabled</button><button type="button" id="connection-memory-close" data-i18n="memory_close_anyway">Turn off anyway</button></div></dialog>
415
422
  </body>
416
423
  </html>
@@ -1,5 +1,49 @@
1
1
  (() => {
2
2
  const translations = {
3
+ "request_access_blocked": ["Access blocked", "请求已拦截"],
4
+ "not_applicable": ["Not applicable", "不适用"],
5
+ "model_owner": ["Model owner", "模型归属"],
6
+ "memory_extract_model": ["Memory extraction model", "记忆提取模型"],
7
+ "memory_extract_role": ["Memory extraction", "记忆提取"],
8
+ "memory_not_detected": ["Not detected", "未检测到"],
9
+ "memory_basis_configured": ["Configured in Codex", "Codex 已配置"],
10
+ "memory_basis_observed": ["Recently observed", "最近检测到"],
11
+ "memory_model_on": ["Enabled", "已启用"],
12
+ "memory_model_off": ["Not selected", "未选入"],
13
+ "memory_generation_off": ["Memory generation is off", "记忆生成已关闭"],
14
+ "memory_pending_on": ["Enabled after saving", "启用待保存"],
15
+ "memory_pending_off": ["Disabled after saving", "关闭待保存"],
16
+ "memory_off_warning": ["The memory extraction model is not enabled. New memory generation may be affected.", "记忆提取模型未启用,新记忆生成可能受影响。"],
17
+ "memory_pending_warning": ["Saving disables the memory extraction model. New memory generation may be affected.", "保存后将关闭记忆提取模型,新记忆生成可能受影响。"],
18
+ "memory_close_title": ["Turn off the memory extraction model?", "关闭记忆提取模型?"],
19
+ "memory_close_body": ["Codex uses this model to extract new memories. Turning it off may prevent new memory generation.", "Codex 使用此模型提取新记忆。关闭后,可能无法生成新记忆。"],
20
+ "memory_existing_kept": ["Existing memories will not be deleted.", "已有记忆不会因此删除。"],
21
+ "memory_keep_enabled": ["Keep enabled", "保留启用"],
22
+ "memory_close_anyway": ["Turn off anyway", "仍然关闭"],
23
+ "output_requested": ["Requested output budget", "请求输出预算"],
24
+ "output_sent": ["Forwarded output budget", "转发输出预算"],
25
+ "output_used": ["Returned output tokens", "返回输出用量"],
26
+ "stop_reason": ["Stop reason", "停止原因"],
27
+ "transport": ["Network details", "网络详情"],
28
+ "output_limit_reached": ["Output limit reached.", "本次生成达到输出上限。"],
29
+ "source_connection_failed": ["Connection to the model source failed.", "与模型来源的连接失败。"],
30
+ "issue_category": ["Issue category", "问题分类"],
31
+ "issue_replies": ["Reply issues", "回复问题"],
32
+ "issue_capabilities": ["Capabilities and access", "能力与访问"],
33
+ "issue_connections": ["Connections and paths", "连接与路径"],
34
+ "http_categories": ["Generation {inference} · Capabilities/access {capability} · Methods {protocol} · Paths {route} · Other {other}", "生成 {inference} · 能力/访问 {capability} · 方法 {protocol} · 路径 {route} · 其他 {other}"],
35
+ "no_upstream_call": ["No upstream call", "未调用上游"],
36
+ "repeated_issue": ["{detail} · {count} occurrences", "{detail} · 出现 {count} 次"],
37
+ "reason": ["Reason", "具体原因"],
38
+ "occurrences": ["Occurrences", "出现次数"],
39
+ "capability_cached": ["Recent capability result reused", "沿用近期能力结果"],
40
+ "shared_upstream": ["Shared upstream call", "合并上游调用"],
41
+ "model_not_selected_message": ["This model is not selected for this app.", "此应用尚未选入该模型。"],
42
+ "model_ambiguous_message": ["This model name matches multiple sources. Select its source-specific entry.", "模型同名,请选择明确来源。"],
43
+ "model_catalog_unavailable_message": ["The selected model is not currently available in its source catalog.", "来源目录中暂时没有该模型。"],
44
+ "client_source_disabled_message": ["This app or its model source is turned off.", "应用或模型来源已关闭。"],
45
+ "local_validation_message": ["The request was rejected locally before an upstream call.", "本机校验未通过,未调用上游。"],
46
+ "count_endpoint_missing_message": ["The source's token-count endpoint returned HTTP 404. Message generation is separate.", "上游计数接口返回 404,回复另行处理。"],
3
47
  "nightly_update": ["Update overnight", "夜间自动更新"],
4
48
  "nightly_risk": ["Updates install a new version and restart CCDX. Continuing a conversation may be affected.", "开启后会自动安装新版并重启 CCDX,可能影响会话续接。"],
5
49
  "nightly_window": ["Update window", "更新时间"],
@@ -1160,6 +1204,14 @@
1160
1204
  "outcome": "outcome_25a63",
1161
1205
  "origin": "origin",
1162
1206
  "route": "route",
1207
+ "This model is not selected for this app.": "model_not_selected_message",
1208
+ "This model name matches multiple sources. Select its source-specific entry.": "model_ambiguous_message",
1209
+ "The selected model is not currently available in its source catalog.": "model_catalog_unavailable_message",
1210
+ "This app or its model source is turned off.": "client_source_disabled_message",
1211
+ "The request was rejected locally before an upstream call.": "local_validation_message",
1212
+ "The source's token-count endpoint returned HTTP 404. Message generation is separate.": "count_endpoint_missing_message",
1213
+ "Output limit reached.": "output_limit_reached",
1214
+ "Connection to the model source failed.": "source_connection_failed",
1163
1215
  "HTTP request failed; original response was preserved.": "http_request_failed_original_response_was_preserved",
1164
1216
  "phase": "phase",
1165
1217
  "http_status": "http_status",