codex-copilot-dx 1.3.19 → 1.3.21

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.
@@ -0,0 +1,320 @@
1
+ import { createHash } from "node:crypto";
2
+ import { imageModelCatalog, imageModelSelection } from "./image-models.mjs";
3
+ import { CLIENT_IDS, CLIENT_NAMES } from "./access-settings.mjs";
4
+ import { publicModelCatalog } from "./provider-metadata.mjs";
5
+ import { sourceModels, clientModelExclusion } from "./client-model-plan.mjs";
6
+ import { deploymentModelId, resolveModelCapabilities, deploymentRevision } from "./model-capabilities.mjs";
7
+
8
+ export function createConnectionView({ legacy, env, binding, plan, getSource, enabled, editable, modelDisplay, discoveries,
9
+ setup, credentialStates, lastClients, memoryModel, capabilitySupport, sharedSync, isManaged, getSettings, corePort, permitted }) {
10
+ const summaries = new WeakMap();
11
+ function summary(api) {
12
+ if (!summaries.has(api))
13
+ summaries.set(api, {
14
+ model_count: api.models.length,
15
+ codex_model_count: api.models.filter(model => model.protocols.includes("responses")).length,
16
+ protocols: Object.keys(api.endpoints),
17
+ });
18
+ return summaries.get(api);
19
+ }
20
+ function imageModels() {
21
+ const c = binding("codex");
22
+ return imageModelSelection(enabled("github") && c.allowed.includes("github")
23
+ ? imageModelCatalog(legacy.github?.registry?.models) : [], c.image_model);
24
+ }
25
+ function clientSnapshot(id, config, compact, readPlan) {
26
+ const base = {
27
+ id,
28
+ name: CLIENT_NAMES[id],
29
+ ...config.clients[id],
30
+ setup: setup[id] || null,
31
+ ...(credentialStates[id] ? { credential_state: credentialStates[id] } : {}),
32
+ ...(id === "codex" ? { memory_model: memoryModel.snapshot() } : {}),
33
+ observed_at: lastClients[id] || null,
34
+ };
35
+ if (compact) return base;
36
+ const revision = clientRevision(id),
37
+ compiled = readPlan(id);
38
+ return {
39
+ ...base,
40
+ revision,
41
+ model_plan: {
42
+ ...(id === "codex" ? { image: imageModels() } : {}),
43
+ default_model: compiled.defaultModel,
44
+ default_unavailable: compiled.defaultUnavailable,
45
+ models: compiled.models.map(model => ({
46
+ source: model.source_id,
47
+ id: model.id,
48
+ display_name: model.display_name,
49
+ public_id: model.public_id,
50
+ route_id: model.route_id,
51
+ capability: model.capability,
52
+ })),
53
+ unavailable: (config.clients[id].deployments || [])
54
+ .filter(
55
+ item => !compiled.models.some(model => model.source_id === item.source && model.id === item.model)
56
+ )
57
+ .map(item => ({
58
+ source: item.source,
59
+ id: item.model,
60
+ route_id: deploymentModelId(item.source, item.model),
61
+ reason: modelExclusion(id, item.source, item.model),
62
+ })),
63
+ available: config.clients[id].allowed
64
+ .filter(enabled)
65
+ .flatMap(source =>
66
+ sourceModels(getSource(source), id).map(model => ({
67
+ source,
68
+ id: model.id,
69
+ display_name: model.display_name || model.name || model.id,
70
+ route_id: deploymentModelId(source, model.id),
71
+ capability: model.capability || resolveModelCapabilities(model, { builtin: true }),
72
+ }))
73
+ ),
74
+ sync: sharedSync(),
75
+ support: capabilitySupport,
76
+ },
77
+ };
78
+ }
79
+ function modelExclusion(id, sourceId, modelId, model, selected = false) {
80
+ if (!model) {
81
+ const source = getSource(sourceId), raw = source?.catalog?.() || source?.registry?.models?.data || [];
82
+ model = publicModelCatalog(raw.filter(value => value.id === modelId))[0];
83
+ }
84
+ return clientModelExclusion({ client: id, binding: binding(id), sourceId, sourceEnabled: enabled(sourceId), model, selected });
85
+ }
86
+ function catalogVisibility(catalog, sourceId) {
87
+ if (!catalog || !Array.isArray(catalog.models)) return catalog;
88
+ const selected = new Map(CLIENT_IDS.map(id => [id, new Set(plan(id).models.filter(model => model.source_id === sourceId).map(model => model.id))]));
89
+ return { ...catalog, models: catalog.models.map(model => ({ ...model,
90
+ client_visibility: CLIENT_IDS.map(id => ({ client: id,
91
+ reason: modelExclusion(id, sourceId, model.id, model, selected.get(id).has(model.id) || id === "codex" && sourceId === "github" && model.kind === "image" && imageModels().selected_model === model.id) })) })) };
92
+ }
93
+ function snapshot(compact = false) {
94
+ const state = legacy.snapshot(),
95
+ config = isManaged() ? getSettings() : editable();
96
+ const localPlans = new Map();
97
+ const readPlan = id => {
98
+ if (!localPlans.has(id)) localPlans.set(id, plan(id));
99
+ return localPlans.get(id);
100
+ };
101
+ return structuredClone({
102
+ source: "connections",
103
+ providers: [
104
+ {
105
+ id: "github",
106
+ name: "GitHub Copilot",
107
+ enabled: config.providers.github,
108
+ builtin: true,
109
+ protocols: ["responses"],
110
+ },
111
+ {
112
+ id: "m365",
113
+ name: "Microsoft 365",
114
+ enabled: config.providers.m365,
115
+ builtin: true,
116
+ protocols: ["messages", "responses"],
117
+ },
118
+ ...config.apis.map(api => {
119
+ const { secret_ref, ...publicApi } = api,
120
+ revision = compact ? null : deploymentRevision(api, env);
121
+ return {
122
+ ...(compact ? { id: api.id, name: api.name, enabled: api.enabled } : publicApi),
123
+ ...summary(api),
124
+ ...(compact
125
+ ? {}
126
+ : {
127
+ deployment_revision: revision,
128
+ model_display: Object.fromEntries(
129
+ api.models.map(model => [model.id, modelDisplay.get(api.id, revision, model.id)])
130
+ ),
131
+ }),
132
+ discovery: discoveries.get(api.id) || null,
133
+ builtin: false,
134
+ key_saved: api.key_env ? Boolean(env[api.key_env]) : Boolean(secret_ref),
135
+ };
136
+ }),
137
+ ],
138
+ clients: CLIENT_IDS.map(id => clientSnapshot(id, config, compact, readPlan)),
139
+ ...(!compact
140
+ ? {
141
+ source_impacts: Object.fromEntries(
142
+ ["github", "m365", ...config.apis.map(api => api.id)].map(id => [
143
+ id,
144
+ sourceImpact(id, readPlan),
145
+ ])
146
+ ),
147
+ }
148
+ : {}),
149
+ managed: isManaged(),
150
+ ...(!compact ? { management_version: 1 } : {}),
151
+ m365_state: state.m365.state,
152
+ });
153
+ }
154
+ const clientRevision = id =>
155
+ createHash("sha256")
156
+ .update(JSON.stringify(binding(id)))
157
+ .digest("hex");
158
+ function sourceImpact(source, readPlan = plan) {
159
+ const clients = CLIENT_IDS.flatMap(id => {
160
+ const c = binding(id);
161
+ if (!c.enabled) return [];
162
+ const explicit = Array.isArray(c.deployments),
163
+ removed = explicit ? c.deployments.filter(item => item.source === source) : [];
164
+ if (explicit ? !removed.length : c.source !== source) return [];
165
+ const remaining = explicit ? c.deployments.length - removed.length : 0;
166
+ const defaultSource =
167
+ readPlan(id).routes.get(c.default_model)?.source ||
168
+ removed.find(item => deploymentModelId(source, item.model) === c.default_model)?.source ||
169
+ c.source;
170
+ const default_affected = defaultSource === source;
171
+ return [
172
+ {
173
+ id,
174
+ removed: explicit ? removed.length : sourceModels(getSource(source), id).length,
175
+ remaining,
176
+ default_affected,
177
+ needs_replacement: default_affected || remaining === 0,
178
+ },
179
+ ];
180
+ });
181
+ const api = getSettings().apis.find(item => item.id === source),
182
+ profile = api ? deploymentRevision(api, env) : getSource(source)?.profileId();
183
+ return {
184
+ clients,
185
+ revision: createHash("sha256")
186
+ .update(JSON.stringify([source, enabled(source), profile, CLIENT_IDS.map(id => binding(id))]))
187
+ .digest("hex"),
188
+ };
189
+ }
190
+ const methods = {
191
+ snapshot() {
192
+ const result = legacy.snapshot();
193
+ if (!isManaged()) return result;
194
+ const performance = legacy.claudePerformance.snapshot(),
195
+ totals = performance.by_route.messages.terminal_outcomes.totals;
196
+ const ms = performance.by_route.messages.by_provider.m365;
197
+ const m365Requests = ms
198
+ ? {
199
+ ...ms.terminal_outcomes.totals,
200
+ active: ms.active,
201
+ total: ms.requests,
202
+ performance: {
203
+ by_route: { messages: { by_provider: { m365: ms }, terminal_outcomes: ms.terminal_outcomes } },
204
+ active_total: ms.active,
205
+ active_requests: performance.active_requests.filter(row => row.provider === "m365"),
206
+ recent_requests: performance.recent_requests.filter(row => row.provider === "m365"),
207
+ },
208
+ }
209
+ : null;
210
+ return {
211
+ ...result,
212
+ codex_provider: this.selection().codex,
213
+ connections: snapshot(true),
214
+ m365: {
215
+ ...result.m365,
216
+ ...(binding("codex").source === "m365"
217
+ ? { preference: this.providerPreference(binding("codex").source) }
218
+ : {}),
219
+ claude: {
220
+ ...result.m365.claude,
221
+ requests: m365Requests,
222
+ clients: Object.fromEntries(
223
+ [
224
+ ["app", "claude_app"],
225
+ ["code", "claude_code"],
226
+ ].map(([short, id]) => [
227
+ short,
228
+ binding(id).enabled && binding(id).source === "m365"
229
+ ? setup[id] || result.m365.claude.clients[short]
230
+ : "not_selected",
231
+ ])
232
+ ),
233
+ },
234
+ },
235
+ claude: {
236
+ base_url: `http://127.0.0.1:${corePort}/anthropic`,
237
+ gateway: CLIENT_IDS.some(
238
+ id => id !== "codex" && binding(id).enabled && permitted(id, binding(id).source)
239
+ )
240
+ ? "running"
241
+ : "unavailable",
242
+ clients: { app: setup.claude_app || "not_configured", code: setup.claude_code || "not_configured" },
243
+ requests: {
244
+ ...totals,
245
+ active: performance.active_total,
246
+ total: Object.values(totals).reduce((sum, value) => sum + value, 0) + performance.active_total,
247
+ performance,
248
+ },
249
+ },
250
+ ...Object.fromEntries(
251
+ getSettings().apis.map(api => [api.id, { preference: this.providerPreference(binding("codex").source) }])
252
+ ),
253
+ };
254
+ },
255
+ dashboardProviders() {
256
+ const builtins = legacy.dashboardProviders();
257
+ if (!isManaged()) return builtins.filter(source => source.enabled);
258
+ const definitions = snapshot(true).providers,
259
+ performance = legacy.claudePerformance.snapshot();
260
+ return definitions
261
+ .filter(item => item.enabled)
262
+ .map(item => {
263
+ const old = builtins.find(source => source.id === item.id),
264
+ source = item.builtin ? null : getSource(item.id);
265
+ const clients = CLIENT_IDS.filter(
266
+ id =>
267
+ binding(id).enabled &&
268
+ binding(id).allowed.includes(item.id) &&
269
+ (id === "codex" ? item.protocols.includes("responses") : item.protocols.includes("messages"))
270
+ ).map(id => ({
271
+ id,
272
+ name: CLIENT_NAMES[id],
273
+ selected:
274
+ binding(id).deployments?.some(model => model.source === item.id) ||
275
+ binding(id).source === item.id,
276
+ state: setup[id] || old?.clients?.find(client => client.id === id)?.state || "unknown",
277
+ gateway:
278
+ binding(id).deployments?.some(model => model.source === item.id) ||
279
+ binding(id).source === item.id
280
+ ? "running"
281
+ : "standby",
282
+ last_request_at: lastClients[id] || null,
283
+ }));
284
+ return {
285
+ ...old,
286
+ id: item.id,
287
+ name: item.name,
288
+ enabled: true,
289
+ generation: old?.generation || source?.registry.generation || 1,
290
+ state: old?.state || "configured",
291
+ auth: old?.auth || { state: "saved", token_cached: false },
292
+ selection: {
293
+ codex: clients.some(client => client.id === "codex"),
294
+ models_required: item.id !== "github",
295
+ },
296
+ clients,
297
+ models: old?.models || { count: item.model_count, source: "configured" },
298
+ requests: performance.by_route.messages.by_provider[item.id]
299
+ ? {
300
+ ...performance.by_route.messages.by_provider[item.id].terminal_outcomes.totals,
301
+ active: performance.by_route.messages.by_provider[item.id].active,
302
+ total: performance.by_route.messages.by_provider[item.id].requests,
303
+ }
304
+ : null,
305
+ };
306
+ });
307
+ },
308
+ dashboardCatalog(input = {}) {
309
+ if (!input.provider?.startsWith("api_")) {
310
+ const value = legacy.dashboardCatalog(input), source = input.provider || this.selection().codex;
311
+ return value?.then ? value.then(catalog => catalogVisibility(catalog, source)) : catalogVisibility(value, source);
312
+ }
313
+ if (!enabled(input.provider)) throw accessError("ccdx_client_source_disabled", 503);
314
+ return catalogVisibility(getSource(input.provider).publicCatalog(
315
+ CLIENT_IDS.filter(id => binding(id).enabled && binding(id).allowed.includes(input.provider))
316
+ ), input.provider);
317
+ },
318
+ };
319
+ return { imageModels, snapshot, sourceImpact, clientRevision, catalogVisibility, methods };
320
+ }
@@ -8,6 +8,17 @@
8
8
  let settingsReadAt = null;
9
9
  let accountsPending = false;
10
10
  const accountReasons = new Set(["m365_account_ambiguous", "m365_account_unavailable", "m365_account_conflict", "m365_interaction_required", "m365_llm_permission_unavailable", "m365_account_busy", "m365_account_selection_stale"]);
11
+ function renderClientVersions(value) {
12
+ for (const client of ["codex", "claude"]) {
13
+ const node = el(`client-version-${client}`);if (!node) continue;
14
+ const rows = Array.isArray(value?.[client]) ? value[client] : [];
15
+ if (!rows.length) { node.removeAttribute("data-i18n");node.textContent = "—";node.title = "";continue; }
16
+ const version = rows.map(row => `${rows.length > 1 ? `${row.name} ` : ""}${row.version}${row.build && row.build !== row.version ? ` (${row.build})` : ""}${row.cli_version ? ` · CLI ${row.cli_version}` : ""}`).join(" / ");
17
+ label(node, rows.some(row => row.changed_at) ? "client_version_changed" : "client_version_observed", { version });
18
+ node.title = rows.filter(row => row.changed_at).map(row => `${row.previous?.version || "—"} → ${row.version} · ${time(row.changed_at, { date: true })}`).join(" / ");
19
+ }
20
+ }
21
+ globalThis.ccdxClientVersions = { render: renderClientVersions };
11
22
  function syncAccountControls() {
12
23
  el("m365-accounts-refresh").disabled = accountsPending || settingsPending;
13
24
  el("m365-account-choice").disabled = accountsPending || settingsPending;
@@ -115,6 +126,7 @@
115
126
  window.addEventListener("ccdx:providers", () => { syncSources();if (current === "codex") void loadSourceModels(); });
116
127
  function applySettings(data, meta) {
117
128
  globalThis.ccdxPrivacy?.sync(data.local_privacy);
129
+ renderClientVersions(data.client_versions);
118
130
  settings = data;
119
131
  features?.render(data);
120
132
  const nightly = data.nightly_update;
@@ -194,18 +206,18 @@
194
206
  }
195
207
  finally { settingsPending = false;el("m365-enabled").disabled = !settings;el("terminal-color-theme").disabled = !settings;el("apply-source").disabled = !sourceReady();syncReviewButton();syncAccountControls(); }
196
208
  }
197
- async function change(body, button) {
209
+ async function change(body, button, { quiet = false } = {}) {
198
210
  if (settingsPending) return;
199
211
  settingsPending = true;
200
212
  syncAccountControls();
201
213
  const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #terminal-color-theme, #m365-enabled, #prediction-continue, #prediction-open, #prediction-setup, #prediction-remove, #image-models input, #image-check, #image-repair, #image-open, #decoded-limit, #decoded-limit-save, #decoded-limit-default, #install-update")];
202
214
  controls.forEach(input => { input.disabled = true; });
203
- const note = el(body.action === "codex_app" ? body.intent === "prediction" ? "prediction-action-note" : "image-action-note" : body.action === "prediction" ? "prediction-action-note" : body.action === "image" ? "effect-image_enabled" : body.action === "update" ? "manual-update-note" : body.action === "decoded_limit" ? "decoded-limit-note" : body.action === "nightly_update" ? "nightly-state" : body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
215
+ const note = el(body.action === "codex_app" ? body.intent === "prediction" ? "prediction-open-note" : "image-action-note" : body.action === "prediction" ? body.operation === "open" ? "prediction-open-note" : "prediction-action-note" : body.action === "image" ? "effect-image_enabled" : body.action === "update" ? "manual-update-note" : body.action === "decoded_limit" ? "decoded-limit-note" : body.action === "nightly_update" ? "nightly-state" : body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
204
216
  : body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
205
217
  : body.operation === "switch" ? "source-control-note" : body.operation === "auto-review" ? "review-control-note"
206
218
  : body.operation === "account" ? "m365-account-note" : "m365-control-note");
207
219
  const initialSourceSave = body.operation === "switch" && Boolean(body.auto_review_model);
208
- label(note, "applying");
220
+ if (!quiet) { if (note.id === "prediction-open-note") note.hidden = false;label(note, "applying"); }
209
221
  if (button) button.setAttribute("aria-busy", "true");
210
222
  try {
211
223
  const data = await api(body);
@@ -214,6 +226,7 @@
214
226
  if (body.action === "provider" && body.operation === "off") { sourceDirty = false;reviewDirty = false; }
215
227
  el("review-control-note").textContent = "";
216
228
  applySettings(data);
229
+ if (body.action === "prediction" && body.operation === "open") { note.hidden = false;label(note, data.last_operation?.result?.opened ? "codex_action_opened" : "image_action_open_failed"); }
217
230
  if (body.action === "image") void globalThis.ccdxConnections?.load();
218
231
  if (initialSourceSave) label(el("source-control-note"), "source_initial_review_saved");
219
232
  if (body.operation === "account") {
@@ -227,6 +240,7 @@
227
240
  }
228
241
  catch (error) {
229
242
  if (settings) applySettings(settings);
243
+ if (note.id === "prediction-open-note") note.hidden = false;
230
244
  if (body.operation === "account") { label(el("m365-account-note"), "company_account_not_saved", { reason: { key: accountReasons.has(error.code) ? error.code : error.message } });return; }
231
245
  if (body.action === "color_theme") { label(el("terminal-color-note"), "not_saved_error", { error: error.message });return; }
232
246
  if (error.code === "ccdx_prediction_app_open") label(note, error.code);
@@ -43,7 +43,8 @@
43
43
  if (!valid(point.input_tokens)) { continuing = false;return; }
44
44
  path += `${continuing ? "L" : "M"}${x(index)} ${y(point.input_tokens)} `;continuing = true;
45
45
  const dot = shape("circle", { cx: x(index), cy: y(point.input_tokens), r: 3, class: "context-point" });
46
- const title = document.createElementNS(ns, "title");title.textContent = `${time(point.at)} · ${number(point.input_tokens)} tokens`;dot.append(title);
46
+ const description = language.format("context_point_usage", { time: time(point.at), input: number(point.input_tokens), reuse: ratio(point.cached_input_tokens, point.input_tokens) });
47
+ const title = document.createElementNS(ns, "title");title.textContent = description;dot.setAttribute("aria-label", description);dot.append(title);
47
48
  });
48
49
  if (!entry.concurrent) shape("path", { d: path, class: "context-line" });
49
50
  for (const index of new Set([0, Math.floor((points.length - 1) / 2), points.length - 1])) {
@@ -13,12 +13,12 @@
13
13
  : connected ? imageApp.tool_registration === "observed" ? "image_host_registered" : "image_host_connected" : "image_host_unconfirmed");
14
14
  }
15
15
  async function codexAction(operation, intent, button, { quiet = false } = {}) {
16
- const data = await change({ action: "codex_app", operation, intent, ...(operation === "restart" ? { confirmed: true } : {}) }, button);
16
+ const data = await change({ action: "codex_app", operation, intent, ...(operation === "restart" ? { confirmed: true } : {}) }, button, { quiet });
17
17
  const result = data?.last_operation?.feature === "codex_app" ? data.last_operation.result : null;
18
18
  if (!result) return;
19
19
  if (result.app) imageApp = result.app;
20
20
  if (!quiet) {
21
- const note = el(intent === "prediction" ? "prediction-action-note" : "image-action-note");
21
+ const note = el(intent === "prediction" ? "prediction-open-note" : "image-action-note");
22
22
  note.dataset.operation = operation;note.hidden = false;
23
23
  const key = operation === "check" ? "codex_action_checked" : result.status === "opened_with_pending"
24
24
  ? result.prediction_pending && result.image_pending ? "codex_action_both_pending" : result.prediction_pending ? "codex_action_prediction_pending" : "codex_action_image_pending"
@@ -53,7 +53,7 @@
53
53
  el("additional-capabilities").addEventListener("toggle", () => {
54
54
  if (el("additional-capabilities").open) void codexAction("check", "image", el("image-check"), { quiet: true });
55
55
  });
56
- const prediction = operation => change({ action: "prediction", operation }, el("prediction-continue"));
56
+ const prediction = operation => change({ action: "prediction", operation }, el(operation === "open" ? "prediction-open" : "prediction-continue"));
57
57
  el("setting-prediction_enabled").addEventListener("change", () => void prediction(el("setting-prediction_enabled").checked ? "enable" : "disable"));
58
58
  el("prediction-continue").addEventListener("click", () => void prediction(saved?.features?.prediction?.enabled ? "enable" : "disable"));
59
59
  el("fix-prediction").addEventListener("click", () => void prediction("repair"));
@@ -77,10 +77,14 @@
77
77
  el("setting-prediction_enabled").checked = value?.enabled === true;
78
78
  el("setting-prediction_enabled").disabled = !value || value.status === "unavailable";
79
79
  const pending = value?.display_pending || value?.enabled && (!value.configured || value.display?.enabled === false);
80
+ el("prediction-continue-actions").hidden = !pending;
80
81
  el("prediction-continue").hidden = !pending;
81
82
  el("prediction-open").disabled = !value?.configured && !value?.display_pending;
82
83
  el("prediction-remove").disabled = !value?.configured;
83
- if (notes) localize(el("prediction-action-note"), !value ? "feature_unavailable" : value.status === "unavailable" ? "feature_read_failed" : pending ? "prediction_quit_continue" : value.enabled && value.bridge !== "running" ? "prediction_bridge_missing" : value.enabled ? "prediction_ready" : "prediction_disabled");
84
+ if (notes) {
85
+ el("prediction-open-note").hidden = true;
86
+ localize(el("prediction-action-note"), !value ? "feature_unavailable" : value.status === "unavailable" ? "feature_read_failed" : pending ? "prediction_quit_continue" : value.enabled && value.bridge !== "running" ? "prediction_bridge_missing" : value.enabled ? "prediction_ready" : "prediction_disabled");
87
+ }
84
88
  el("effect-prediction_enabled").hidden = !pending;
85
89
  if (pending) localize(el("effect-prediction_enabled"), "feature_pending");
86
90
  renderImageApp();
@@ -121,14 +121,15 @@
121
121
  <details class="panel dashboard-section" id="prediction-settings" open>
122
122
  <summary class="panel-heading"><h2 data-i18n="codex_input_predictions">INPUT SUGGESTIONS</h2></summary>
123
123
  <div class="setting-row"><label for="setting-prediction_enabled" data-i18n="predictions_enable">Input suggestions</label><input id="setting-prediction_enabled" type="checkbox" role="switch" disabled><span id="effect-prediction_enabled" class="hint" role="status"></span></div>
124
- <p id="prediction-action-note" class="hint" role="status"></p><div class="section-actions"><button id="prediction-continue" type="button" data-i18n="feature_continue" hidden>Continue setup</button><button id="prediction-open" type="button" data-i18n="prediction_open">Open Codex</button></div>
125
- <p id="prediction-restart-warning" class="hint" role="status" data-i18n="image_restart_warning" hidden>Restarting Codex interrupts its running tasks. Finish or save them first.</p>
124
+ <p id="prediction-action-note" class="hint" role="status"></p><div id="prediction-continue-actions" class="section-actions" hidden><button id="prediction-continue" type="button" data-i18n="feature_continue" hidden>Continue setup</button></div>
126
125
  <details class="tool-details"><summary data-i18n="status_and_repair">Status and repair</summary>
127
126
  <dl class="stats"><div><dt data-i18n="prediction_integration_setup">Suggestion setup</dt><dd id="prediction-preference">—</dd></div><div><dt data-i18n="local_bridge">Local service</dt><dd id="prediction-bridge">—</dd></div><div><dt data-i18n="client_route">App settings requests</dt><dd id="prediction-route">—</dd></div><div><dt data-i18n="visible_candidate">Suggestion displayed</dt><dd id="prediction-candidate">—</dd></div></dl>
128
127
  <p id="prediction-note" class="hint">—</p>
129
128
 
130
129
 
131
- <div class="section-actions"><button id="fix-prediction" type="button" data-i18n="check_and_repair">Check and repair</button><button id="prediction-setup" type="button" data-i18n="prediction_setup_again">Set up again</button><button id="prediction-remove" type="button" data-i18n="feature_remove">Remove setup</button></div>
130
+ <div class="section-actions"><button id="fix-prediction" type="button" data-i18n="check_and_repair">Check and repair</button><button id="prediction-setup" type="button" data-i18n="prediction_setup_again">Set up again</button><button id="prediction-open" type="button" data-i18n="prediction_open">Open Codex</button><button id="prediction-remove" type="button" data-i18n="feature_remove">Remove setup</button></div>
131
+ <p id="prediction-restart-warning" class="hint" role="status" data-i18n="image_restart_warning" hidden>Restarting Codex interrupts its running tasks. Finish or save them first.</p>
132
+ <p id="prediction-open-note" class="hint" role="status" hidden></p>
132
133
  </details>
133
134
  </details>
134
135
  <details class="panel dashboard-section" id="additional-capabilities">
@@ -270,6 +271,9 @@
270
271
  <section class="panel dashboard-section">
271
272
  <h2 data-i18n="tools_check_local">Check this computer</h2>
272
273
  <p class="hint" data-i18n="tools_local_scope">Local checks do not contact external services.</p>
274
+ <p>Codex App: <strong id="client-version-codex">—</strong></p>
275
+ <p>Claude App: <strong id="client-version-claude">—</strong></p>
276
+ <p class="hint" data-i18n="client_versions_scope">Installed versions only; running App adoption and compatibility are separate.</p>
273
277
  <div class="section-actions"><button id="check-local" type="button" data-i18n="tools_check_local">Check this computer</button></div>
274
278
  <p id="checks-note" class="table-note" role="status" aria-live="polite" data-i18n="tools_checks_empty">Run a check to see the results.</p>
275
279
  <div class="table-wrap" id="checks-results" hidden><table class="checks-table"><thead><tr><th data-i18n="tools_check_item">Check</th><th data-i18n="state">State</th><th data-i18n="tools_details">Details</th></tr></thead><tbody id="checks-body"></tbody></table></div>
@@ -99,6 +99,7 @@
99
99
  "context_latest_input": ["Latest input", "最近输入"],
100
100
  "context_reuse": ["Cache reuse", "缓存复用"],
101
101
  "context_history": ["Input history", "输入变化"],
102
+ "context_point_usage": ["{time} · input {input} tokens · cache reuse {reuse}", "{time} · 输入 {input} Token · 缓存复用 {reuse}"],
102
103
  "context_compactions": ["Gateway compactions", "网关压缩"],
103
104
  "context_elapsed": ["Elapsed", "耗时"],
104
105
  "context_conversation": ["Conversation {id}", "会话 {id}"],
@@ -566,6 +567,9 @@
566
567
  "tools_access_denied": ["GitHub sign-in is valid. Check your Copilot access or company policy.", "GitHub 登录有效。请检查 Copilot 权限或公司策略。"],
567
568
  "tools_network_hint": ["Connection could not be verified. Check network settings; saved sign-in is kept.", "连接未能验证。请检查网络,原登录已保留。"],
568
569
  "tools_local_scope": ["Local checks only", "仅检查本机"],
570
+ "client_versions_scope": ["Installed versions only; running App adoption and compatibility are separate.", "显示已安装版本;运行中的版本和接入状态需分别确认。"],
571
+ "client_version_observed": ["{version}", "{version}"],
572
+ "client_version_changed": ["{version} · updated, access unverified", "{version} · 已更新,接入待确认"],
569
573
  "tools_check_local": ["Check this computer", "本机检查"],
570
574
  "tools_export_report": ["Export report", "导出报告"],
571
575
  "tools_checks_empty": ["Run a local check to see results.", "运行本机检查后查看结果。"],
@@ -999,7 +1003,7 @@
999
1003
  "entries_entries_trees_trees_misses_misses_evicted_evicted": ["Records: {entries} / groups: {trees}\nNot found: {misses} / removed: {evicted}", "暂存:{entries}条/分组:{trees}\n未找到:{misses}\n清理后未找到:{evicted}"],
1000
1004
  "count_succeeded": ["{count} succeeded", "成功:{count}次"],
1001
1005
  "not_initialized": ["NOT CONFIRMED", "未确认"],
1002
- "active_active_failed_failed_delivery_failures_delivery": ["Running: {active} / generation failed: {failed}\nFile delivery failed: {delivery}", "进行中:{active}/生成失败:{failed}\n文件交付失败:{delivery}"],
1006
+ "active_active_failed_failed_delivery_failures_delivery": ["Running: {active} / generation failed: {failed} / file delivery failed: {delivery}", "进行中:{active}/生成失败:{failed}/文件交付失败:{delivery}"],
1003
1007
  "setup_state_unknown_ccdx_image_status": ["Uses the existing GitHub Copilot account.", "使用现有 GitHub Copilot 账号。"],
1004
1008
  "snapshot_time": ["Status updated {time}", "状态更新:{time}"],
1005
1009
  "status_unavailable_check_ccdx_then_refresh": ["Cannot read status. Check CCDX and refresh.", "无法读取状态。\n请检查 CCDX 后刷新。"],
@@ -137,6 +137,7 @@
137
137
  el("github-logout").addEventListener("click", () => { if (window.confirm(language.format("tools_logout_confirm"))) void accountAction({ action: "logout", confirmed: true }); });
138
138
  async function loadAccount() { const generation = accountGeneration;try { const data = await api("account");if (generation === accountGeneration && !pending) renderAccount(data); } catch { if (generation === accountGeneration) text("github-account-note", "tools_read_failed"); } }
139
139
  function renderChecks(data) {
140
+ if (Object.hasOwn(data, "client_versions")) globalThis.ccdxClientVersions?.render(data.client_versions);
140
141
  const body = el("checks-body");body.replaceChildren();
141
142
  const groups = new Map();
142
143
  for (const check of data.checks || []) { if (!groups.has(check.id)) groups.set(check.id, []);groups.get(check.id).push(check); }
package/src/doctor.mjs CHANGED
@@ -315,6 +315,14 @@ export async function runDoctor(options = {}) {
315
315
  ].filter(Boolean);
316
316
  if (!options.json) log(`${options.commandName || "ccdx"} doctor${options.configOnly ? " config" : flags.length ? ` ${flags.join(" ")}` : ""}`);
317
317
  let checks = await collectDoctorChecks(options);
318
+ if (!options.configOnly) {
319
+ try {
320
+ const { createClientVersionMonitor, clientVersionChecks } = await import("./client-versions.mjs");
321
+ const monitor = options.clientVersions || createClientVersionMonitor({ home: options.home, env: options.env, platform: options.platform, persist: false });
322
+ try { checks.push(...clientVersionChecks(await monitor.refresh())); }
323
+ finally { if (!options.clientVersions) monitor.close(); }
324
+ } catch { checks.push({ id: "client-versions", kind: "info", message: "App version observations are unavailable" }); }
325
+ }
318
326
  const before = options.fix ? checks : undefined;
319
327
  if (options.fix && !options.configOnly) {
320
328
  const repair = options.repairDoctorFn || (await import("./doctor-repair.mjs")).repairDoctor;
@@ -12,18 +12,21 @@ import { inspectAdapterCompatibility } from "./doctor-compat.mjs";
12
12
 
13
13
  export function createLocalTools({ home = os.homedir(), env = process.env, host = "127.0.0.1", port = 2026,
14
14
  platform = process.platform, collect = collectDoctorChecks, inspectConfig = inspectCodexConfig, repairConfig = repairCodexConfig,
15
- inspectNetwork = inspectPredictionEnvironment, inspectCompatibility = inspectAdapterCompatibility } = {}) {
15
+ inspectNetwork = inspectPredictionEnvironment, inspectCompatibility = inspectAdapterCompatibility, clientVersions } = {}) {
16
16
  const options = { home, env, host, port, platform };
17
17
  let last = null, flight = null;
18
18
  const safe = text => redactDiagnosticText(String(text || "")).split(home).join("~")
19
19
  .replace(/[\w.+-]+@[\w.-]+/g, "[account]").replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").slice(0, 600);
20
20
  const project = checks => checks.slice(0, 80).map(check => ({ id: /^[a-z-]{1,60}$/.test(check.id || "") ? check.id : "local",
21
21
  kind: ["ok", "info", "warn", "err"].includes(check.kind) ? check.kind : "info", message: safe(check.message) }));
22
- function snapshot() { return { source: "local_tools", ...last }; }
22
+ function snapshot() { let versions = null;try { versions = clientVersions?.snapshot?.() || null; } catch {}return { source: "local_tools", ...last, ...(clientVersions ? { client_versions: versions } : {}) }; }
23
23
  async function check() {
24
24
  if (flight) return flight;
25
25
  flight = Promise.resolve().then(async () => {
26
- last = { checked_at: new Date().toISOString(), checks: project(await collect({ ...options, checkAdapter: false })) };
26
+ const versions = clientVersions?.refresh ? Promise.resolve().then(() => clientVersions.refresh()).catch(() => null) : null;
27
+ const checks = await collect({ ...options, checkAdapter: false });
28
+ await versions;
29
+ last = { checked_at: new Date().toISOString(), checks: project(checks) };
27
30
  return snapshot();
28
31
  }).finally(() => { flight = null; });
29
32
  return flight;
@@ -57,6 +57,14 @@ const WINDOWS_APP_SCRIPT = `$p=@(Get-AppxPackage -Name OpenAI.Codex | Where-Obje
57
57
  if($a.Count -ne 1){throw 'Unknown Windows App executable'};
58
58
  @{root=$p[0].InstallLocation;executable=$a[0].Executable;family=$p[0].PackageFamilyName} | ConvertTo-Json -Compress`;
59
59
 
60
+ export async function inspectWindowsCodexVersion({ env = process.env, exec = execFileAsync } = {}) {
61
+ const script = `$p=@(Get-AppxPackage -Name OpenAI.Codex | Where-Object { [int]$_.Status -eq 0 -and [int]$_.SignatureKind -eq 3 -and $_.Publisher -eq '${WINDOWS_PUBLISHER}' -and $_.PackageFamilyName -eq '${WINDOWS_PACKAGE_FAMILY}' });if($p.Count -ne 1){throw 'Unknown App registration'};[string]$p[0].Version`;
62
+ const [command, args] = powershellCommand(script, env);
63
+ const result = await exec(command, args, { encoding: "utf8", timeout: 2500, maxBuffer: 4096, env: windowsPowerShellEnvironment(env), windowsHide: true });
64
+ const version = String(result?.stdout ?? result).trim();
65
+ return /^\d+(?:\.\d+){1,3}$/.test(version) ? version : null;
66
+ }
67
+
60
68
  function registeredApp(raw) {
61
69
  let metadata;
62
70
  try { metadata = JSON.parse(raw); } catch { throw new Error("Could not read the registered Windows Codex App"); }
@@ -185,8 +185,9 @@ export function runtimeStatusPayload({
185
185
  last_request: observed ? {
186
186
  client_version: version(observed.client_version),
187
187
  application: ["ChatGPT.app", "Codex.app", "custom binary"].includes(observed.application) ? observed.application : null,
188
- source: observed.source === "bundled" ? "bundled" : "unavailable",
188
+ source: ["bundled", "cached_bundled"].includes(observed.source) ? observed.source : "unavailable",
189
189
  matched: observed.matched === true,
190
+ match_precision: ["exact", "core_only"].includes(observed.match_precision) ? observed.match_precision : null,
190
191
  observed_at: typeof observed.observed_at === "string" && /^\d{4}-\d{2}-\d{2}T[0-9:.]+Z$/.test(observed.observed_at) ? observed.observed_at : null,
191
192
  } : null,
192
193
  observed_versions: (Array.isArray(snapshot?.observed_versions) ? snapshot.observed_versions : []).filter(version).slice(0, 8),
@@ -114,12 +114,12 @@ function fragments(session, json, onRetained) {
114
114
 
115
115
  function rewrite(wire, event, named = false) {
116
116
  let written = false;
117
- const output = wire.split(/(?<=\n)/).map(line => {
117
+ const output = wire.split(/(?<=\n)|(?<=\r)(?!\n)/).map(line => {
118
118
  if (!line.startsWith("data:")) return line;
119
119
  if (written) return "";written = true;
120
- return "data: " + JSON.stringify(event) + (line.endsWith("\r\n") ? "\r\n" : line.endsWith("\n") ? "\n" : "");
120
+ return "data: " + JSON.stringify(event) + (line.endsWith("\r\n") ? "\r\n" : line.endsWith("\n") ? "\n" : line.endsWith("\r") ? "\r" : "");
121
121
  }).join("");
122
- return named && !/^event:/m.test(output) ? "event: " + event.type + "\n" + output : output;
122
+ return named && !/^event:/m.test(output) ? "event: " + event.type + (wire.match(/\r\n|\r|\n/)?.[0] || "\n") + output : output;
123
123
  }
124
124
 
125
125
  export function createPrivacyStream(session, { maxBufferedBytes = 32 * 1024 * 1024, maxChannels = 1024 } = {}) {
@@ -184,7 +184,7 @@ export function createPrivacyStream(session, { maxBufferedBytes = 32 * 1024 * 10
184
184
  forget(id);return output;
185
185
  }
186
186
  function transform(wire) {
187
- const lines = wire.split(/\r?\n/), data = lines.filter(line => line.startsWith("data:")).map(line => line.slice(5).replace(/^ /, "")).join("\n");
187
+ const lines = wire.split(/\r\n|\r|\n/), data = lines.filter(line => line.startsWith("data:")).map(line => line.slice(5).replace(/^ /, "")).join("\n");
188
188
  if (!data || data === "[DONE]") return wire;
189
189
  let event;
190
190
  try { event = JSON.parse(data); } catch { throw fail("stream_invalid"); }
@@ -269,8 +269,10 @@ export function createPrivacyStream(session, { maxBufferedBytes = 32 * 1024 * 10
269
269
  pending += decoder.write(chunk);pendingBytes += chunk.length;
270
270
  if (pendingBytes > 8 * 1024 * 1024) throw fail("stream_limit");
271
271
  let output = "", match;
272
- while ((match = /\r?\n\r?\n/.exec(pending))) {
273
- const end = match.index + match[0].length, wire = pending.slice(0, end);pending = pending.slice(end);
272
+ while ((match = /(?:\r\n|\r(?!\n)|(?<!\r)\n){2}/.exec(pending))) {
273
+ const end = match.index + match[0].length;
274
+ if (end === pending.length && match[0].endsWith("\r") && match[0].includes("\n")) break;
275
+ const wire = pending.slice(0, end);pending = pending.slice(end);
274
276
  pendingBytes = Buffer.byteLength(pending);output += transform(wire);
275
277
  }
276
278
  return output;
@@ -278,7 +280,8 @@ export function createPrivacyStream(session, { maxBufferedBytes = 32 * 1024 * 10
278
280
  },
279
281
  finish() {
280
282
  try {
281
- pending += decoder.end();const output = pending ? transform(pending + "\n\n") : "";pending = "";
283
+ pending += decoder.end();const complete = /(?:\r\n|\r(?!\n)|(?<!\r)\n){2}$/.test(pending);
284
+ const output = pending ? transform(pending + (complete ? "" : "\n\n")) : "";pending = "";
282
285
  if (channels.size) throw fail("stream_incomplete");return output;
283
286
  } catch (error) { completed = false;throw error; }
284
287
  finally { clear();pending = "";pendingBytes = 0; }