codex-copilot-dx 0.10.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +18 -17
  2. package/bin/cli.mjs +24 -3
  3. package/docs/ARCHITECTURE.md +60 -14
  4. package/docs/README.md +3 -0
  5. package/docs/REFERENCE.md +186 -45
  6. package/package.json +2 -2
  7. package/src/adapter.mjs +19 -4
  8. package/src/browser-launch.mjs +22 -0
  9. package/src/claude-client-config.mjs +22 -5
  10. package/src/claude-gateway.mjs +30 -8
  11. package/src/claude-models.mjs +26 -0
  12. package/src/cli-animation.mjs +1 -1
  13. package/src/cli-image.mjs +3 -0
  14. package/src/cli-m365.mjs +1 -1
  15. package/src/cli-options.mjs +11 -6
  16. package/src/cli-table.mjs +1 -1
  17. package/src/client-integration.mjs +5 -1
  18. package/src/dashboard/console.js +141 -0
  19. package/src/dashboard/index.html +105 -52
  20. package/src/dashboard/language.js +103 -0
  21. package/src/dashboard/refresh.js +2 -1
  22. package/src/dashboard/status.js +60 -29
  23. package/src/dashboard/ui.css +49 -0
  24. package/src/dashboard/ui.js +113 -26
  25. package/src/dashboard-api.mjs +72 -7
  26. package/src/dashboard.mjs +1 -0
  27. package/src/image-mcp.mjs +9 -6
  28. package/src/live-models.mjs +11 -3
  29. package/src/log.mjs +13 -11
  30. package/src/m365-settings.mjs +0 -2
  31. package/src/native-prediction-recovery.mjs +1 -0
  32. package/src/native-prediction.mjs +6 -2
  33. package/src/observability.mjs +8 -1
  34. package/src/optional-routes.mjs +2 -2
  35. package/src/provider-metadata.mjs +21 -0
  36. package/src/provider-runtime.mjs +80 -26
  37. package/src/providers/m365-auth.mjs +4 -4
  38. package/src/providers/m365.mjs +10 -2
  39. package/src/response-failures.mjs +1 -1
  40. package/src/service-control.mjs +60 -0
  41. package/src/startup-ui.mjs +4 -3
  42. package/src/terminal-console.mjs +87 -0
  43. package/src/usage-analysis.mjs +1 -1
  44. package/src/usage-analytics.mjs +3 -3
  45. package/src/usage-store.mjs +40 -17
  46. package/src/usage.mjs +14 -7
  47. package/src/user-settings.mjs +21 -0
@@ -1,5 +1,108 @@
1
1
  (() => {
2
2
  const translations = {
3
+ "Codex body admission: active {active} / queued {queued} / queue limit {limit}": ["Codex body admission: active {active} / queued {queued} / queue limit {limit}", "Codex请求体:进行中{active}\n排队{queued} / 队列上限{limit}"],
4
+ "Terminal animation unavailable in this output mode": ["Terminal animation unavailable in this output mode", "当前输出模式不播放终端动效"],
5
+ "Prediction integration setup": ["Prediction integration setup", "预测集成配置"],
6
+ "Visible status updates every 2 seconds. Catalogs and retained usage refresh on demand or every 30 minutes while open.": ["Visible status updates every 2 seconds. Catalogs and retained usage refresh on demand or every 30 minutes while open.", "可见状态每2秒更新。\n目录和留存用量按需更新,\n展开时每30分钟刷新。"],
7
+ "Clients": ["Clients", "客户端"],
8
+ "Model services": ["Model services", "模型服务"],
9
+ "Usage and diagnostics": ["Usage and diagnostics", "用量与诊断"],
10
+ "System and settings": ["System and settings", "系统与设置"],
11
+ "Main navigation": ["Main navigation", "主导航"],
12
+ "LOCAL CONTROL": ["LOCAL CONTROL", "本机控制台"],
13
+ "Terminal appearance": ["Terminal appearance", "终端外观"],
14
+ "Local service. Client-specific capabilities stay with their client.": ["Local service. Client-specific capabilities stay with their client.", "本机服务;专属能力归属各自客户端。"],
15
+ "CONFIGURATION + OBSERVATION": ["CONFIGURATION + OBSERVATION", "配置与观察"],
16
+ "CODEX CONVERSATIONS": ["CODEX CONVERSATIONS", "Codex 对话与暂存"],
17
+ "CODEX CONVERSATION BUFFER": ["CODEX CONVERSATION BUFFER", "Codex 对话暂存"],
18
+ "CODEX INPUT PREDICTIONS": ["CODEX INPUT PREDICTIONS", "Codex 输入预测"],
19
+ "CODEX ONLY": ["CODEX ONLY", "Codex 专属"],
20
+ "CODEX IMAGE GENERATION": ["CODEX IMAGE GENERATION", "Codex 图片生成"],
21
+ "Image service": ["Image service", "生图服务"],
22
+ "Allow new image calls": ["Allow new image calls", "允许新的生图调用"],
23
+ "Allow prediction configuration": ["Allow prediction configuration", "允许预测配置适配"],
24
+ "Check and repair": ["Check and repair", "检查并修复"],
25
+ "Temporary local data for Responses continuation, not a conversation archive.": ["Temporary local data for Responses continuation, not a conversation archive.", "用于 Responses 对话续接的本机\n临时数据,并非聊天归档。"],
26
+ "Buffer limit MiB": ["Buffer limit MiB", "暂存上限 MiB"],
27
+ "Apply limit": ["Apply limit", "应用上限"],
28
+ "Clear inactive buffer": ["Clear inactive buffer", "清理未使用暂存"],
29
+ "Pause keeps the provider configuration. Running calls can finish. First-time setup: ccdx enable-image.": ["Pause keeps the provider configuration. Running calls can finish. First-time setup: ccdx enable-image.", "暂停保留 Provider 配置,进行中\n的调用可以完成。首次配置:ccdx\nenable-image。"],
30
+ "Pause keeps the existing trust and route. Codex may retain cached suggestions. First-time setup: quit Codex, then ccdx prediction on.": ["Pause keeps the existing trust and route. Codex may retain cached suggestions. First-time setup: quit Codex, then ccdx prediction on.", "暂停保留已有信任和路由,Codex 可能\n保留已缓存的建议。首次配置:退出\nCodex 后执行 ccdx\nprediction on。"],
31
+ "SERVICE SETTINGS": ["SERVICE SETTINGS", "服务设置"],
32
+ "Saved preference and effective state are separate. Environment overrides and client restarts are shown explicitly.": ["Saved preference and effective state are separate. Environment overrides and client restarts are shown explicitly.", "保存的偏好与实际生效状态分别显示;环境覆\n盖和客户端重启要求会明确标注。"],
33
+ "Terminal animation": ["Terminal animation", "终端动效"],
34
+ "Open WebUI at startup": ["Open WebUI at startup", "启动时打开 WebUI"],
35
+ "Reading settings…": ["Reading settings…", "正在读取设置…"],
36
+ "CODEX MODEL SOURCE": ["CODEX MODEL SOURCE", "Codex 模型来源"],
37
+ "Catalog tabs only change the view. Apply explicitly to change the source for future Codex requests.": ["Catalog tabs only change the view. Apply explicitly to change the source for future Codex requests.", "目录标签仅切换查看对象。点击应用才会改变\n后续 Codex 请求的来源。"],
38
+ "Auto-review model": ["Auto-review model", "自动审查模型"],
39
+ "Apply source": ["Apply source", "应用来源"],
40
+ "Enable service": ["Enable service", "启用服务"],
41
+ "Disable service": ["Disable service", "停用服务"],
42
+ "Since this service started. Configuration, authorization, model discovery and successful inference are separate evidence.": ["Since this service started. Configuration, authorization, model discovery and successful inference are separate evidence.", "自本次服务启动起统计。配置、授权、模型发\n现和成功推理是不同证据。"],
43
+ "PROCESS + LISTENER": ["PROCESS + LISTENER", "进程与监听器"],
44
+ "HTTP TRAFFIC": ["HTTP TRAFFIC", "主入口 HTTP 流量"],
45
+ "THIS RUN USAGE": ["THIS RUN USAGE", "本次运行用量"],
46
+ "Updated from returned usage, not a live bill. Pending usage is not included.": ["Updated from returned usage, not a live bill. Pending usage is not included.", "根据已返回的用量更新,不代表实时账单;尚\n未返回的用量不计入。"],
47
+ "Applies to the running terminal.": ["Applies to the running terminal.", "应用到运行中的终端。"],
48
+ "RECENT INFERENCE + HTTP FAILURES": ["RECENT INFERENCE + HTTP FAILURES", "近期推理与 HTTP 故障"],
49
+ "Codex Responses timing since startup. Output speed is estimated.": ["Codex Responses timing since startup. Output speed is estimated.", "自启动起的 Codex\nResponses 时序;输出速度为估计\n值。"],
50
+ "SERVICE REACHABLE": ["SERVICE REACHABLE", "服务可访问"],
51
+ "Saved choice applies to the running terminal.": ["Saved choice applies to the running terminal.", "保存后应用到运行中的终端。"],
52
+ "Effective now": ["Effective now", "即时生效"],
53
+ "Next CCDX start": ["Next CCDX start", "下次启动 CCDX 生效"],
54
+ "Applies to new calls": ["Applies to new calls", "对后续调用生效"],
55
+ "Setup required": ["Setup required", "需要先配置"],
56
+ "Next configuration request; cached suggestions may remain": ["Next configuration request; cached suggestions may remain", "对后续配置请求生效;已缓存建议可能仍存在"],
57
+ "Reopen the client to finish": ["Reopen the client to finish", "需要重新打开客户端"],
58
+ "Restart CCDX to finish": ["Restart CCDX to finish", "需要重启 CCDX"],
59
+ "Saved {saved} / effective {effective} / {state}": ["Saved {saved} / effective {effective} / {state}", "保存:{saved} / 实际:{effective} / {state}"],
60
+ "On": ["On", "开启"],
61
+ "Off": ["Off", "关闭"],
62
+ "Controlled by environment": ["Controlled by environment", "由环境变量控制"],
63
+ "Settings read from the running service.": ["Settings read from the running service.", "已读取运行中服务的设置。"],
64
+ "Applying…": ["Applying…", "正在应用…"],
65
+ "Clear inactive Codex conversation data? Older continuation IDs may stop working.": ["Clear inactive Codex conversation data? Older continuation IDs may stop working.", "清理未使用的 Codex 对话暂存?旧的\n续接 ID 可能失效。"],
66
+ "{records} usage records / input {input} / cache read {cached} / output {output}{partial}": ["{records} usage records / input {input} / cache read {cached} / output {output}{partial}", "{records} 条用量记录 / 输入 {input} / 缓存读取 {cached}\n / 输出 {output}{partial}"],
67
+ "RSS {rss} / heap {heap}": ["RSS {rss} / heap {heap}", "常驻内存 {rss} / 堆内存 {heap}"],
68
+ "CODEX MODELS": ["CODEX MODELS", "Codex 模型"],
69
+ "CODEX REQUESTS": ["CODEX REQUESTS", "Codex 请求"],
70
+ "{state} / {reason}": ["{state} / {reason}", "{state} / {reason}"],
71
+ "RUNTIME RESOURCES": ["RUNTIME RESOURCES", "运行资源"],
72
+ "ADDITIONAL CAPABILITIES": ["ADDITIONAL CAPABILITIES", "附加能力"],
73
+ "SOURCES": ["SOURCES", "模型来源"],
74
+ "ACCOUNT AUTHORIZATION": ["ACCOUNT AUTHORIZATION", "账号授权"],
75
+ "BY PROVIDER": ["BY PROVIDER", "按来源列出"],
76
+ "ACCOUNT": ["ACCOUNT", "账号"],
77
+ "AUTHORIZATION": ["AUTHORIZATION", "授权状态"],
78
+ "SERVICE": ["SERVICE", "服务状态"],
79
+ "LAST VERIFIED": ["LAST VERIFIED", "最近验证"],
80
+ "CLIENT": ["CLIENT", "客户端"],
81
+ "STATE": ["STATE", "状态"],
82
+ "GATEWAY": ["GATEWAY", "网关"],
83
+ "LAST REQUEST": ["LAST REQUEST", "最近请求"],
84
+ "CLIENT CONNECTIONS": ["CLIENT CONNECTIONS", "客户端接入"],
85
+ "MODEL CATALOG": ["MODEL CATALOG", "模型目录"],
86
+ "REASONING": ["REASONING", "推理档位"],
87
+ "Model providers": ["Model providers", "模型来源"],
88
+ "Reading provider catalog…": ["Reading provider catalog…", "正在读取模型目录…"],
89
+ "No models advertised.": ["No models advertised.", "目录未返回模型。"],
90
+ "No catalog available.": ["No catalog available.", "模型目录不可用。"],
91
+ "Saved locally": ["Saved locally", "本机已保存"],
92
+ "Authorized": ["Authorized", "已授权"],
93
+ "Ready": ["Ready", "就绪"],
94
+ "Checking": ["Checking", "检查中"],
95
+ "Unsupported": ["Unsupported", "当前平台不支持"],
96
+ "Standby": ["Standby", "备用未启用"],
97
+ "listed": ["Listed", "目录已列出"],
98
+ "restricted": ["Restricted", "受限制"],
99
+ "hidden": ["Hidden upstream", "上游已隐藏"],
100
+ "running": ["Running", "运行中"],
101
+ "unavailable": ["Unavailable", "不可用"],
102
+ "{count} providers": ["{count} providers", "{count}个来源"],
103
+ "{provider}: {done} done / {incomplete} incomplete / {failed} failed": ["{provider}: {done} done / {incomplete} incomplete / {failed} failed", "{provider}:完成{done}·未完成{incomplete}·失败{failed}"],
104
+ "Provider status / authorization and inference are separate.": ["Provider status / authorization and inference are separate.", "来源状态。\n授权与推理分别验证。"],
105
+ "Saved credentials, authorization, model access and client requests are separate evidence.": ["Saved credentials, authorization, model access and client requests are separate evidence.", "凭据、授权、模型访问\n和客户端请求分别验证。"],
3
106
  "CLIENT FEATURES": ["CLIENT FEATURES", "接入能力"],
4
107
  "OBSERVED STATE": ["OBSERVED STATE", "实际状态"],
5
108
  "Native predictions": ["Native predictions", "输入建议"],
@@ -82,7 +82,7 @@
82
82
  .map(key => refresh(key, { force })));
83
83
  }
84
84
 
85
- function invalidate(key) {
85
+ function invalidate(key, { clear = false } = {}) {
86
86
  const entry = state(key);
87
87
  entry.generation += 1;
88
88
  entry.abort?.abort();
@@ -90,6 +90,7 @@
90
90
  entry.abort = null;
91
91
  entry.attemptedAt = null;
92
92
  entry.variant = undefined;
93
+ if (clear) { entry.value = undefined;entry.signature = undefined;entry.updatedAt = null;entry.error = null; }
93
94
  notify(key);
94
95
  }
95
96
 
@@ -5,13 +5,41 @@
5
5
  let failureSignature;
6
6
  let contextSignature;
7
7
 
8
- function renderAuth(data, { failed = false } = {}) {
9
- const account = data.login ? `@${data.login}` : data.id ? `ID ${data.id}` : phrase("account unknown");
10
- const label = data.reason === "credential_read_failed" ? "UNAVAILABLE"
11
- : !data.configured ? "NOT CONFIGURED" : !data.valid ? "INVALID" : "SAVED";
12
- text("auth-account", failed ? "GitHub / {account} / UPDATE FAILED" : label === "SAVED" ? "GitHub / {account} / SAVED" : `GitHub / ${label}`, { account });
8
+ function renderProviders(data) {
9
+ const providers = data.providers || [];
10
+ const states = { saved: "Saved locally", authorized: "Authorized", disabled: "Disabled", unavailable: "Unavailable",
11
+ unknown: "Unknown", unconfigured: "Not configured", ready: "Ready", checking: "Checking", unsupported: "Unsupported",
12
+ configured: "Configured", preserved: "Existing settings kept", partially_preserved: "Existing settings kept",
13
+ not_installed: "Not installed", configuration_unavailable: "Setup unavailable", not_configured: "Not configured", standby: "Standby" };
14
+ const auth = element("provider-auth"), clients = element("provider-clients"), requests = element("provider-requests");
15
+ auth.replaceChildren();clients.replaceChildren();requests.replaceChildren();
16
+ const routes = [];
17
+ for (const provider of providers) {
18
+ const identity = provider.auth || {};
19
+ const authRow = tableRow([provider.name, identity.account || "—", states[identity.state] || "Unknown",
20
+ states[provider.state] || "Unknown", identity.checked_at || "—", duration(identity.expires_in_ms)], { labels: [2, 3] });
21
+ if (provider.reason) localize(authRow.children[3], "{state} / {reason}", { state: phrase(states[provider.state] || "Unknown"), reason: provider.reason });
22
+ auth.append(authRow);
23
+ for (const client of provider.clients || []) {
24
+ const row = tableRow([provider.name, client.name, states[client.state] || client.state,
25
+ client.gateway || "—", client.last_request_at || "—"], { labels: [2, 3] });
26
+ if (client.reason) localize(row.children[2], "{state} / {reason}", { state: phrase(states[client.state] || "Unknown"), reason: client.reason });
27
+ clients.append(row);
28
+ if (client.selected && client.id === "codex") routes.push(`${client.name} → ${provider.name}`);
29
+ }
30
+ if (provider.requests) {
31
+ const item = document.createElement("p");
32
+ localize(item, "{provider}: {done} done / {incomplete} incomplete / {failed} failed", { provider: `${provider.name} · ${provider.request_scope || "Claude Messages"}`,
33
+ done: number(provider.requests.completed), incomplete: number(provider.requests.incomplete), failed: number(provider.requests.failed) });
34
+ requests.append(item);
35
+ }
36
+ }
37
+ text("source-summary", "{count} providers", { count: providers.filter(provider => provider.enabled).length });
38
+ element("source-detail").textContent = routes.join(" / ") || "—";
39
+ element("auth-account").textContent = providers.flatMap(provider => (provider.clients || [])
40
+ .filter(client => client.selected).map(client => `${client.name} → ${provider.name}`)).join(" / ") || "—";
13
41
  }
14
-
42
+
15
43
  function duration(value) {
16
44
  if (!finite(value)) return "—";
17
45
  const seconds = Math.max(0, Math.round(Number(value) / 1000));
@@ -114,10 +142,6 @@
114
142
  text("version", `v${data.version || "?"}`);
115
143
  text("uptime", "pid {pid} / uptime {duration}", { pid: number(data.pid), duration: duration(data.uptime_ms) });
116
144
 
117
- const copilot = data.copilot || {};
118
- text("copilot", copilot.account_bound ? "BOUND" : "UNCONFIRMED");
119
- text("token", copilot.token_cached ? "service token / TTL {duration}" : "service token not cached", { duration: duration(copilot.token_expires_in_ms) });
120
-
121
145
  const models = data.models || {};
122
146
  text("models", number(models.models));
123
147
  text("model-source", "source {source} / live: ccdx models", { source: phrase(String(models.source || "unknown").slice(0, 80)) });
@@ -151,26 +175,33 @@
151
175
  ? "active {active} / failed {failed} / delivery failures {delivery}"
152
176
  : "Setup state unknown / ccdx image-status", { active: number(image?.active), failed: number(image?.failed), delivery: number(image?.delivery_failures) });
153
177
 
154
- if (element("m365-state")) {
155
- const providers = data.providers || {}, m365 = providers.m365 || {}, claude = m365.claude || {};
156
- const state = { ready: "M365 READY", checking: "M365 CHECKING", disabled: "M365 OFF", unsupported: "M365 UNSUPPORTED", unavailable: "M365 UNAVAILABLE", idle: "M365 CHECKING" };
157
- text("m365-state", state[m365.state] || "M365 UNKNOWN");
158
- text("m365-account", m365.account?.login || "Account unavailable");
159
- text("m365-models", "Claude {claude} / GPT {gpt}", { claude: number(m365.models?.claude), gpt: number(m365.models?.gpt) });
160
- text("m365-claude", claude.gateway === "running" ? "Claude gateway running" : "Claude gateway unavailable");
161
- if (element("m365-requests")) text("m365-requests", claude.requests ? "Claude: {done} done / {incomplete} incomplete / {failed} failed" : "Claude requests unavailable",
162
- { done: number(claude.requests?.completed), incomplete: number(claude.requests?.incomplete), failed: number(claude.requests?.failed) });
163
- const labels = { configured: "Configured", preserved: "Existing settings kept", partially_preserved: "Existing settings kept", restored: "Restored", not_installed: "Not installed", configuration_unavailable: "Setup unavailable", not_configured: "Not configured" };
164
- text("m365-clients", "Code: {code} / App: {app}", { code: phrase(labels[claude.clients?.code] || "Unknown"), app: phrase(labels[claude.clients?.app] || "Unknown") });
165
- text("m365-codex", providers.codex_provider === "m365" ? "Codex source: Microsoft 365" : "Codex source: GitHub Copilot");
166
- }
167
-
178
+ const claude = data.providers?.m365?.claude, claudeMetrics = claude?.requests?.performance;
179
+ const recentRequests = [...(data.stream_performance?.recent_requests || []), ...(claudeMetrics?.recent_requests || [])]
180
+ .sort((a, b) => (Date.parse(a.at) || 0) - (Date.parse(b.at) || 0));
168
181
  renderFailures([...(data.response_failures?.recent || []), ...(data.http_errors?.actionable_recent || data.http_errors?.recent || [])]
169
- .sort((a, b) => (Date.parse(a.at) || 0) - (Date.parse(b.at) || 0)), data.stream_performance?.recent_requests);
170
- renderContext(data.stream_performance);
182
+ .sort((a, b) => (Date.parse(a.at) || 0) - (Date.parse(b.at) || 0)), recentRequests);
183
+ renderContext({ ...data.stream_performance, recent_requests: recentRequests });
184
+ if (element("claude-route")) {
185
+ element("claude-route").textContent = claude?.base_url || "—";
186
+ element("claude-client-state").textContent = Object.entries(claude?.clients || {}).map(([key, value]) => `${key}: ${value}`).join(" / ") || "—";
187
+ const totals = claudeMetrics?.by_route?.messages?.terminal_outcomes?.totals || claude?.requests || {};
188
+ for (const key of ["completed", "incomplete", "failed", "cancelled"]) text(`claude-${key}`, totals[key] === undefined ? "—" : number(totals[key]));
189
+ for (const [id, metric, unit] of [["claude-ttft", claudeMetrics?.by_route?.messages?.ttft_ms, "ms"], ["claude-speed", claudeMetrics?.by_route?.messages?.output_tokens_per_second, "token/s"]]) {
190
+ text(id, metric?.samples > 0 ? `${Number(metric.avg).toFixed(1)} ${unit} / ${metric.samples}` : "—");
191
+ }
192
+ }
193
+ if (element("runtime-usage")) {
194
+ const usage = data.runtime_usage;
195
+ text("runtime-usage", usage ? "{records} usage records / input {input} / cache read {cached} / output {output}{partial}" : "—",
196
+ usage ? { records: number(usage.records), input: number(usage.input_tokens), cached: number(usage.cached_input_tokens), output: number(usage.output_tokens), partial: usage.partial_records ? " ~" : "" } : {});
197
+ element("process-state").textContent = `PID ${data.pid || "—"} / ${globalThis.location?.origin || ""}`;
198
+ text("process-memory", "RSS {rss} / heap {heap}", { rss: mib(data.process?.rss_bytes), heap: mib(data.process?.heap_used_bytes) });
199
+ text("process-queues", "Codex body admission: active {active} / queued {queued} / queue limit {limit}", {
200
+ active: number(data.admission?.activeRequests), queued: number(data.admission?.queued), limit: number(data.admission?.maxQueued) });
201
+ }
171
202
  if (element("prediction-preference")) {
172
203
  const prediction = data.client_integrations?.prediction;
173
- text("prediction-preference", prediction ? prediction.configured ? "Enabled" : "Disabled" : "Unknown");
204
+ text("prediction-preference", prediction ? prediction.configured ? "Configured" : "Not configured" : "Unknown");
174
205
  text("prediction-bridge", ({ running: "Running", recovering: "Recovering", stopped: "Stopped", unavailable: "Unavailable" })[prediction?.bridge] || "Unknown");
175
206
  text("prediction-route", prediction?.client_route === "observed" ? "Observed" : "Unknown");
176
207
  text("prediction-candidate", "Unknown");
@@ -201,14 +232,14 @@
201
232
  ? request.outcome[0].toUpperCase() + request.outcome.slice(1) : "Unknown";
202
233
  const ratio = finite(context.input_tokens) && finite(context.context_window_tokens) && Number(context.context_window_tokens) > 0
203
234
  ? `${(100 * Number(context.input_tokens) / Number(context.context_window_tokens)).toFixed(1)}%` : "—";
204
- body.append(tableRow([String(request.model || "unknown").slice(0, 80) + (request.provider === "m365" ? " / M365" : ""),
235
+ body.append(tableRow([String(request.model || "unknown").slice(0, 80) + (request.provider ? ` / ${request.provider}` : ""),
205
236
  finite(context.payload_bytes) ? (Number(context.payload_bytes) / 1048576).toFixed(2) : "—",
206
237
  number(context.images), number(context.input_tokens), number(context.context_window_tokens), ratio,
207
238
  outcome], { labels: [6] }));
208
239
  }
209
240
  if (!contextRequests.length) emptyTable("context-body", 7, "No observed request metadata.");
210
241
  }
211
- return { render, renderAuth, renderFailures, renderContext };
242
+ return { render, renderProviders, renderFailures, renderContext };
212
243
  }
213
244
  globalThis.ccdxDashboardStatus = { create };
214
245
  })();
@@ -140,3 +140,52 @@ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color:
140
140
  @media (max-width: 460px) { .topbar { flex-wrap: wrap; padding: 12px 0; gap: 10px; } .topbar-actions { gap: 9px; } .panel-heading { flex-wrap: wrap; } .heading-actions { gap: 10px; } .failure-detail { grid-template-columns: 1fr; gap: 3px; } .failure-detail dd { margin-bottom: 7px; } select { max-width: 210px; } }
141
141
  .timing-stats { grid-template-columns: 1fr; }
142
142
  .timing-stats dt { white-space: nowrap; }
143
+
144
+ .provider-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
145
+ .provider-tabs [aria-selected="true"] { color: var(--accent); border-color: var(--accent-soft); background: var(--selected-bg); }
146
+ #provider-auth td, #provider-clients td { overflow-wrap: anywhere; }
147
+ .details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
148
+ @media (max-width: 700px) { .details { grid-template-columns: 1fr; } }
149
+
150
+ /* Each view has one scope. The sidebar stays separate from business data. */
151
+ [hidden] { display: none !important; }
152
+ .shell { max-width: 1520px; display: grid; grid-template-columns: 204px minmax(0, 1fr); column-gap: 34px; padding: 0 28px; }
153
+ .sidebar { grid-row: 1 / 4; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 22px 24px 0; border-right: 1px solid var(--border); }
154
+ .sidebar-brand { color: var(--accent); text-decoration: none; font-size: 23px; font-weight: 750; letter-spacing: .04em; }
155
+ .sidebar-brand span { display: block; color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: .1em; margin-top: 8px; }
156
+ .sidebar nav { display: flex; flex-direction: column; gap: 5px; margin-top: 36px; }
157
+ .sidebar nav a { color: var(--muted); text-decoration: none; padding: 11px 12px; font-size: 13px; border-left: 2px solid transparent; }
158
+ .sidebar nav a:hover { background: var(--option-hover); color: var(--text); }
159
+ .sidebar nav a[aria-current="page"] { color: var(--accent); background: var(--selected-bg); border-left-color: var(--accent); }
160
+ .sidebar nav a:focus-visible, .sidebar-brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
161
+ .nav-group { color: var(--subtle); font-size: 10px; padding: 18px 12px 4px; text-transform: uppercase; letter-spacing: .08em; }
162
+ .sidebar-bottom { margin-top: auto; padding-top: 24px; }
163
+ .sidebar-bottom button { width: 100%; text-align: left; }
164
+ .sidebar-bottom p { color: var(--subtle); font-size: 11px; line-height: 1.7; }
165
+ .topbar, main, footer { grid-column: 2; min-width: 0; }
166
+ .topbar { min-height: 76px; gap: 14px; }
167
+ .brand { font-size: 12px; }
168
+ .topbar-actions { gap: 12px; }
169
+ .intro { display: block; padding: 32px 0 26px; }
170
+ .snapshot-meta { justify-content: flex-start; margin-top: 14px; line-height: 1.7; }
171
+ .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
172
+ .client-overview { grid-template-columns: 1fr; }
173
+ .card { min-height: 130px; }
174
+ .panel, .lower { padding: 22px; }
175
+ .panel h2, .lower h2, .panel > summary { font-size: 12px; letter-spacing: .045em; }
176
+ .hint, .table-note, td, th, .stats dt { font-size: 12px; line-height: 1.7; }
177
+ .section-actions { flex-wrap: wrap; align-items: end; }
178
+ .section-actions label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; max-width: 100%; }
179
+ .section-actions input, .section-actions select { max-width: 100%; min-height: 36px; }
180
+ input[type="number"] { width: 120px; font: inherit; color: var(--text); background: var(--page); border: 1px solid var(--border); padding: 7px; }
181
+ .setting-row { display: grid; grid-template-columns: minmax(160px, 1fr) 44px minmax(0, 1.4fr); align-items: center; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
182
+ .setting-row .hint { margin: 0; }
183
+ input[role="switch"] { appearance: none; width: 38px; height: 22px; border: 1px solid var(--button-border); border-radius: 20px; background: var(--border); cursor: pointer; margin: 0; position: relative; }
184
+ input[role="switch"]::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: var(--muted); }
185
+ input[role="switch"]:checked { background: var(--selected-bg); border-color: var(--accent); }
186
+ input[role="switch"]:checked::before { left: 19px; background: var(--accent); }
187
+ input[role="switch"]:focus-visible, input[type="number"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
188
+ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
189
+ #process-queues { overflow-wrap: anywhere; font-size: 11px; }
190
+ @media (max-width: 900px) { .shell { grid-template-columns: 170px minmax(0, 1fr); column-gap: 20px; padding: 0 20px; } .topbar .brand { display: none; } .topbar { justify-content: flex-end; } .setting-row { grid-template-columns: minmax(0, 1fr) 44px; } .setting-row .hint { grid-column: 1 / -1; } .overview { grid-template-columns: 1fr; } }
191
+ @media (max-width: 640px) { .shell { display: block; padding: 0 16px; } .sidebar { position: static; height: auto; padding: 20px 0 14px; border-right: 0; border-bottom: 1px solid var(--border); } .sidebar-brand { font-size: 20px; } .sidebar-brand span { display: inline; margin-left: 12px; } .sidebar nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; margin-top: 16px; } .sidebar nav a { padding: 9px 10px; font-size: 12px; border-left: 0; border-bottom: 2px solid transparent; } .sidebar nav a[aria-current="page"] { border-bottom-color: var(--accent); } .nav-group, .sidebar-bottom { display: none; } .topbar { min-height: 62px; justify-content: flex-start; } .topbar-actions { justify-content: flex-start; gap: 9px; } .intro { padding: 24px 0 18px; } .panel, .lower { padding: 17px; } .section-actions > label { width: 100%; } .stats { gap: 12px; } }
@@ -16,7 +16,7 @@ const finite = (value) => value !== null && value !== undefined && Number.isFini
16
16
  const number = (value) => finite(value) ? Math.max(0, Math.round(Number(value))).toLocaleString() : "—";
17
17
  const mib = (value) => finite(value) ? `${(Number(value) / 1048576).toFixed(1)} MiB` : "—";
18
18
  const viewHelpers = { element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator: globalThis.navigator };
19
- const { render, renderAuth, renderFailures, renderContext } = globalThis.ccdxDashboardStatus.create(viewHelpers);
19
+ const { render, renderProviders, renderFailures, renderContext } = globalThis.ccdxDashboardStatus.create(viewHelpers);
20
20
  const usageView = globalThis.ccdxDashboardUsage.create(viewHelpers);
21
21
  const { applyUsage, renderUsageState, renderAnalytics, renderUsageTable, selectUsageDay } = usageView;
22
22
  const loadAuth = () => dashboardRefresh.refresh("auth", { force: true });
@@ -82,14 +82,14 @@ function stopAnimationPreview() {
82
82
 
83
83
  function tickAnimationPreview() {
84
84
  previewTimer = null;
85
- if (!animationTimelines.length || !element("animation-settings").open || !previewVisible || document.visibilityState !== "visible" || reducedMotion.matches || previewDisabledByEnvironment) return;
85
+ if (!animationTimelines.length || !element("animation-settings").open || element("animation-settings").closest("[hidden]") || !previewVisible || document.visibilityState !== "visible" || reducedMotion.matches || previewDisabledByEnvironment) return;
86
86
  renderAnimationFrames(performance.now() - previewStarted);
87
87
  previewTimer = setTimeout(tickAnimationPreview, 32);
88
88
  }
89
89
 
90
90
  function syncAnimationPreview() {
91
91
  stopAnimationPreview();
92
- if (!animationTimelines.length || !element("animation-settings").open || !previewVisible || document.visibilityState !== "visible" || reducedMotion.matches || previewDisabledByEnvironment) {
92
+ if (!animationTimelines.length || !element("animation-settings").open || element("animation-settings").closest("[hidden]") || !previewVisible || document.visibilityState !== "visible" || reducedMotion.matches || previewDisabledByEnvironment) {
93
93
  for (const timeline of animationTimelines) timeline.lastFrame = -2;
94
94
  renderAnimationFrames(0);
95
95
  return;
@@ -155,7 +155,7 @@ function buildAnimationOptions(data) {
155
155
  function animationNote(data) {
156
156
  return data.disabled_by_environment
157
157
  ? "Disabled by CCDX_TERMINAL_ANIMATION; saved choice applies after override removal and next start."
158
- : "Saved choice applies on next ccdx start.";
158
+ : "Saved choice applies to the running terminal.";
159
159
  }
160
160
 
161
161
  function loadAnimation(options) {
@@ -235,16 +235,98 @@ function tableRow(values, { total = false, labels = [] } = {}) {
235
235
  return row;
236
236
  }
237
237
 
238
+ let providerEntries = [];
239
+ let usageProviders = {};
240
+ let selectedProvider = "";
241
+ const modelSnapshots = new Map();
242
+ const providerTabs = new Map();
243
+ try { selectedProvider = localStorage.getItem("ccdx.dashboard.modelProvider") || ""; } catch { /* Page-local choice still works. */ }
244
+
245
+ function syncUsageProviders() {
246
+ const selector = element("usage-provider"), selected = selector.value;
247
+ const entries = new Map(providerEntries.map(provider => [provider.id, provider.name]));
248
+ for (const id of Object.keys(usageProviders)) if (usageProviders[id] > 0 && !entries.has(id)) entries.set(id, id);
249
+ const signature = JSON.stringify([...entries]);
250
+ if (selector.dataset.providers === signature) return;
251
+ selector.dataset.providers = signature;
252
+ selector.replaceChildren();
253
+ const all = document.createElement("option");all.value = "";localize(all, "All providers");selector.append(all);
254
+ for (const [id, name] of entries) { const option = document.createElement("option");option.value = id;option.textContent = name;selector.append(option); }
255
+ selector.value = entries.has(selected) ? selected : "";
256
+ }
257
+
258
+ function chooseProvider(id) {
259
+ if (selectedProvider === id) return;
260
+ selectedProvider = id;
261
+ try { localStorage.setItem("ccdx.dashboard.modelProvider", id); } catch { /* Keep the current choice. */ }
262
+ for (const [key, button] of providerTabs) { button.setAttribute("aria-selected", String(key === id));button.tabIndex = key === id ? 0 : -1; }
263
+ dashboardRefresh.invalidate("models", { clear: true });
264
+ const previous = modelSnapshots.get(id);
265
+ if (previous) applyModels(previous, { changed: true });
266
+ else { emptyTable("live-models-body", 6, "Reading provider catalog…");text("models-note", "Reading provider catalog…"); }
267
+ element("live-models-body").setAttribute("aria-labelledby", `model-provider-${id}`);
268
+ void loadModels();
269
+ }
270
+
271
+ function applyProviders(data, { changed }) {
272
+ const wasInitialized = providerEntries.length > 0, previousSelection = selectedProvider;
273
+ let reloadModels = false;
274
+ const previous = new Map(providerEntries.map(entry => [entry.id, JSON.stringify([entry.generation, entry.auth?.account])]));
275
+ providerEntries = data.providers;
276
+ for (const [id] of modelSnapshots) {
277
+ const provider = providerEntries.find(entry => entry.id === id);
278
+ if (!provider) {
279
+ modelSnapshots.delete(id);
280
+ if (id === selectedProvider) { reloadModels = true;dashboardRefresh.invalidate("models", { clear: true });emptyTable("live-models-body", 6, "Reading provider catalog…"); }
281
+ }
282
+ }
283
+ for (const provider of providerEntries) {
284
+ if (previous.has(provider.id) && previous.get(provider.id) !== JSON.stringify([provider.generation, provider.auth?.account])) {
285
+ modelSnapshots.delete(provider.id);
286
+ if (provider.id === selectedProvider) { reloadModels = true;dashboardRefresh.invalidate("models", { clear: true });emptyTable("live-models-body", 6, "Reading provider catalog…"); }
287
+ }
288
+ }
289
+ if (changed || dashboardRefresh.state("auth").error) renderProviders(data);
290
+ syncUsageProviders();
291
+ const available = providerEntries.some(provider => provider.id === selectedProvider);
292
+ if (!available) selectedProvider = providerEntries.find(provider => provider.clients?.some(client => client.id === "codex" && client.selected))?.id || providerEntries[0]?.id || "";
293
+ const container = element("model-providers");
294
+ for (const [id, button] of providerTabs) if (!providerEntries.some(provider => provider.id === id)) { button.remove();providerTabs.delete(id); }
295
+ for (const provider of providerEntries) {
296
+ let button = providerTabs.get(provider.id);
297
+ if (!button) {
298
+ button = document.createElement("button");button.type = "button";button.setAttribute("role", "tab");
299
+ button.id = `model-provider-${provider.id}`;button.setAttribute("aria-controls", "live-models-body");
300
+ button.addEventListener("click", () => chooseProvider(provider.id));
301
+ button.addEventListener("keydown", event => {
302
+ if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
303
+ event.preventDefault();
304
+ const ids = [...providerTabs.keys()], index = ids.indexOf(provider.id);
305
+ const next = event.key === "Home" ? 0 : event.key === "End" ? ids.length - 1 : (index + (event.key === "ArrowRight" ? 1 : -1) + ids.length) % ids.length;
306
+ chooseProvider(ids[next]);providerTabs.get(ids[next]).focus();
307
+ });
308
+ providerTabs.set(provider.id, button);container.append(button);
309
+ }
310
+ button.textContent = provider.name;button.setAttribute("aria-selected", String(provider.id === selectedProvider));button.tabIndex = provider.id === selectedProvider ? 0 : -1;
311
+ }
312
+ element("live-models-body").setAttribute("aria-labelledby", `model-provider-${selectedProvider}`);
313
+ if (wasInitialized && (reloadModels || selectedProvider !== previousSelection)) { dashboardRefresh.invalidate("models", { clear: true });void loadModels(); }
314
+ }
315
+
238
316
  async function loadModels() { return dashboardRefresh.refresh("models", { force: true }); }
239
317
 
240
318
  function applyModels(data, { changed }) {
319
+ if (data.provider && data.provider !== selectedProvider) return;
320
+ modelSnapshots.set(selectedProvider, data);
241
321
  if (changed) {
242
- const body = element("live-models-body");
243
- body.replaceChildren();
322
+ const body = element("live-models-body");body.replaceChildren();
244
323
  for (const model of data.models) {
245
- body.append(tableRow([model.id, model.vendor, model.endpoints.join(" / "), model.preview ? "preview" : "—"], { labels: [3] }));
324
+ const clients = (model.clients || []).map(id => ({ codex: "Codex App", claude_app: "Claude App", claude_code: "Claude Code" })[id] || id).join(" / ") || "—";
325
+ body.append(tableRow([model.id, model.vendor, model.endpoints.join(" / "), clients,
326
+ model.reasoning_efforts === null || model.reasoning_efforts === undefined ? "—" : model.reasoning_efforts.join(" / ") || "—",
327
+ model.preview ? "preview" : model.state || "listed"], { labels: [5] }));
246
328
  }
247
- if (!data.models.length) emptyTable("live-models-body", 4, "No selectable GPT models advertised.");
329
+ if (!data.models.length) emptyTable("live-models-body", 6, "No models advertised.");
248
330
  }
249
331
  text("models-note", "{selectable} selectable / {advertised} advertised / {host} / {time}", { selectable: number(data.selectable), advertised: number(data.advertised), host: data.upstream_host, time: data.checked_at ? new Date(data.checked_at).toLocaleTimeString() : phrase("Unknown") });
250
332
  }
@@ -266,7 +348,7 @@ function refreshTime(target, state) {
266
348
  }
267
349
 
268
350
  const timestamps = new Map();
269
- for (const [key, ids] of [["status", ["client-features", "request-context", "recent-failures"]], ["models", ["upstream-models"]], ["usage", ["model-usage"]], ["animation", ["animation-settings"]]]) {
351
+ for (const [key, ids] of [["auth", ["account-authorization"]], ["status", ["client-features", "request-context", "recent-failures", "runtime-resources", "additional-capabilities"]], ["models", ["upstream-models"]], ["usage", ["model-usage"]], ["animation", ["animation-settings"]]]) {
270
352
  timestamps.set(key, ids.map(id => {
271
353
  const node = document.createElement("p");
272
354
  node.className = "refresh-time";
@@ -293,7 +375,7 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
293
375
  },
294
376
  apply: render,
295
377
  state: state => {
296
- text("connection", state.pending || (!state.value && !state.error) ? "READING" : state.error ? "UNAVAILABLE" : "LOCAL OK");
378
+ text("connection", state.pending && !state.value ? "READING" : state.error ? "UNAVAILABLE" : "SERVICE REACHABLE");
297
379
  element("connection").className = `badge ${state.pending ? "neutral" : state.error ? "bad" : "good"}`;
298
380
  if (state.error) refreshTime(element("updated"), state);
299
381
  for (const node of timestamps.get("status")) refreshTime(node, state);
@@ -301,22 +383,26 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
301
383
  },
302
384
  auth: {
303
385
  visible: () => true,
304
- load: ({ signal }) => readDashboard("/_ccdx/ui/auth", { signal, timeout: 5000, source: "local_auth_status" }),
305
- apply: renderAuth,
386
+ load: ({ signal }) => readDashboard("/_ccdx/ui/providers", { signal, timeout: 5000, source: "provider_status" }),
387
+ apply: applyProviders,
306
388
  state: state => {
307
- if (state.value) renderAuth(state.value, { failed: Boolean(state.error) });
308
- else text("auth-account", state.error ? "GitHub / UNAVAILABLE" : "GitHub / READING");
309
- if (state.updatedAt !== null) localize(element("auth-account"), "Saved account / updated {time}", { time: new Date(state.updatedAt).toLocaleTimeString() }, "title");
389
+ if (state.error) {
390
+ if (state.value) localize(element("auth-account"), "Update failed / last {time}", { time: new Date(state.updatedAt).toLocaleTimeString() });
391
+ else text("auth-account", "UNAVAILABLE");
392
+ }
393
+ for (const node of timestamps.get("auth")) refreshTime(node, state);
310
394
  },
311
395
  },
312
396
  models: {
313
- visible: () => element("upstream-models").open,
314
- load: async ({ signal }) => {
315
- const data = await readDashboard("/_ccdx/ui/models/live", { signal, source: ["live", "catalog"] });
397
+ visible: () => providerEntries.length > 0 && element("upstream-models").open && !element("upstream-models").closest("[hidden]"),
398
+ variant: () => selectedProvider,
399
+ load: async ({ signal, variant }) => {
400
+ if (!variant) throw new Error("Reading provider catalog…");
401
+ const data = await readDashboard(`/_ccdx/ui/models/live?provider=${encodeURIComponent(variant)}`, { signal, source: ["live", "catalog"] });
316
402
  if (!Array.isArray(data.models) || data.models.some(model => !model || typeof model.id !== "string" || !Array.isArray(model.endpoints))) throw new Error("Invalid model snapshot");
317
- return data;
403
+ return { ...data, provider: variant };
318
404
  },
319
- project: data => [data.models, data.selectable, data.advertised, data.upstream_host],
405
+ project: data => [data.provider, data.models, data.selectable, data.advertised, data.upstream_host],
320
406
  apply: applyModels,
321
407
  state: state => {
322
408
  element("refresh-models").disabled = Boolean(state.pending);
@@ -327,12 +413,12 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
327
413
  if (httpError) text("models-note", "Live model lookup failed (HTTP {status}). Run ccdx models for details.", { status: httpError[1] });
328
414
  else text("models-note", message);
329
415
  }
330
- if (state.error && !state.value) emptyTable("live-models-body", 4, "No live catalog available.");
416
+ if (state.error && !modelSnapshots.has(selectedProvider)) emptyTable("live-models-body", 6, "No catalog available.");
331
417
  for (const node of timestamps.get("models")) refreshTime(node, state);
332
418
  },
333
419
  },
334
420
  usage: {
335
- visible: () => element("model-usage").open,
421
+ visible: () => element("model-usage").open && !element("model-usage").closest("[hidden]"),
336
422
  variant: () => {
337
423
  const mode = ((element("model-usage").open && element("usage-analytics").open) || Boolean(usageView.selectedDate)) ? "analytics" : "summary";
338
424
  const provider = element("usage-provider")?.value || "";
@@ -346,7 +432,10 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
346
432
  if (!data.total || !Array.isArray(data.rows) || (mode === "analytics" && (!Array.isArray(data.analytics?.days) || !data.analytics.days.length))) throw new Error("Invalid usage snapshot");
347
433
  return data;
348
434
  },
349
- apply: applyUsage,
435
+ apply: (data, options) => {
436
+ usageProviders = data.provider && data.provider !== "all" ? { ...usageProviders, ...data.providers } : data.providers || {};
437
+ syncUsageProviders();applyUsage(data, options);
438
+ },
350
439
  state: state => {
351
440
  element("refresh-usage").disabled = Boolean(state.pending);
352
441
  if (element("usage-provider")) element("usage-provider").disabled = Boolean(state.pending);
@@ -394,7 +483,7 @@ document.addEventListener("visibilitychange", () => dashboardRefresh.visibilityC
394
483
  window.addEventListener("pagehide", () => { dashboardRefresh.suspend(); stopAnimationPreview(); });
395
484
  window.addEventListener("pageshow", () => { dashboardRefresh.resume(); syncAnimationPreview(); });
396
485
 
397
- for (const [id, key] of [["client-features", "status"], ["request-context", "status"], ["recent-failures", "status"], ["upstream-models", "models"], ["model-usage", "usage"]]) {
486
+ for (const [id, key] of [["account-authorization", "auth"], ["client-features", "status"], ["request-context", "status"], ["recent-failures", "status"], ["upstream-models", "models"], ["model-usage", "usage"]]) {
398
487
  element(id).addEventListener("toggle", () => {
399
488
  if (element(id).open) {
400
489
  if (id === "request-context") renderContext();
@@ -427,8 +516,6 @@ element("usage-provider")?.addEventListener("change", () => { dashboardRefresh.i
427
516
  element("refresh-models").addEventListener("click", loadModels);
428
517
  element("refresh-usage").addEventListener("click", loadUsage);
429
518
  loadAnimation();
430
- loadModels();
431
- loadUsage();
432
519
  refresh();
433
520
  loadAuth();
434
521
  animateRefresh();