codex-copilot-dx 1.2.10 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/ARCHITECTURE.md +64 -1
- package/docs/REFERENCE.md +65 -2
- package/package.json +1 -1
- package/src/adapter.mjs +2 -1
- package/src/claude-gateway.mjs +2 -1
- package/src/dashboard/console.js +3 -3
- package/src/dashboard/flow.js +170 -0
- package/src/dashboard/index.html +34 -22
- package/src/dashboard/language.js +77 -41
- package/src/dashboard/status.js +10 -1
- package/src/dashboard/ui.css +70 -18
- package/src/dashboard/ui.js +2 -1
- package/src/dashboard.mjs +1 -0
- package/src/optional-routes.mjs +1 -1
- package/src/request-application.mjs +21 -0
- package/src/stream-performance.mjs +33 -2
package/src/dashboard/ui.css
CHANGED
|
@@ -14,15 +14,17 @@ html { scrollbar-gutter: stable; }
|
|
|
14
14
|
.badge::before { content: "●"; margin-right: 8px; }
|
|
15
15
|
.badge.good { color: var(--accent-soft); }
|
|
16
16
|
.badge.bad { color: var(--bad); }
|
|
17
|
-
button { border: 1px solid var(--button-border); border-radius: 2px; background: var(--button-bg); color: var(--button-fg); padding: 8px 13px; font: inherit; font-size: 11px; font-weight: 700; text-transform: uppercase; cursor: pointer; }
|
|
18
|
-
button:hover { background: var(--button-hover); }
|
|
19
|
-
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
|
|
17
|
+
button, .button-link { border: 1px solid var(--button-border); border-radius: 2px; background: var(--button-bg); color: var(--button-fg); padding: 8px 13px; font: inherit; font-size: 11px; font-weight: 700; text-transform: uppercase; cursor: pointer; }
|
|
18
|
+
button:hover, .button-link:hover { background: var(--button-hover); }
|
|
19
|
+
button:focus-visible, .button-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
|
|
20
|
+
.button-link { display:inline-flex;align-items:center;justify-content:center;text-decoration:none; }
|
|
21
|
+
.account-entry { text-transform:none; }
|
|
20
22
|
button:disabled { opacity: .55; cursor: default; }
|
|
21
23
|
button[aria-busy="true"] { cursor: progress; }
|
|
22
|
-
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 6px; border: 0; background: transparent; }
|
|
24
|
+
.icon-button { display: inline-flex; flex:none; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 6px; border: 0; background: transparent; }
|
|
23
25
|
.icon-button:hover { background: transparent; color: var(--accent); }
|
|
24
26
|
.icon-button svg { width: 18px; height: 18px; }
|
|
25
|
-
.language-button { padding:
|
|
27
|
+
.language-button { width:auto; min-width:40px; padding:4px 6px; white-space:nowrap; word-break:normal; overflow-wrap:normal; line-height:1; }
|
|
26
28
|
.icon-moon, :root[data-theme="light"] .icon-sun { display: none; }
|
|
27
29
|
:root[data-theme="light"] .icon-moon { display: block; }
|
|
28
30
|
.intro { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; padding: 38px 0 25px; }
|
|
@@ -80,6 +82,7 @@ table { width: 100%; border-collapse: collapse; font-size: 11px; }
|
|
|
80
82
|
th { color: var(--heading); text-align: left; font-weight: 700; letter-spacing: .05em; }
|
|
81
83
|
th, td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
|
|
82
84
|
th:last-child, td:last-child { padding-right: 0; }
|
|
85
|
+
tbody tr:last-child td { border-bottom: 0; }
|
|
83
86
|
td { color: var(--table-text); }
|
|
84
87
|
.usage-table th:not(:first-child), .usage-table td:not(:first-child) { text-align: right; }
|
|
85
88
|
.usage-table tr.total-row td { color: var(--accent); font-weight: 700; }
|
|
@@ -186,16 +189,18 @@ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color:
|
|
|
186
189
|
.brand { font-size: 12px; }
|
|
187
190
|
.topbar-actions { gap: 12px; flex-wrap: nowrap; }
|
|
188
191
|
.topbar-actions #connection { width: 154px; flex: none; }
|
|
189
|
-
.topbar-actions #auto-refresh {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
.topbar-actions #auto-refresh { display:inline-grid; flex:none; justify-self:start; white-space:nowrap; }
|
|
193
|
+
#auto-refresh span { grid-column:1; grid-row:1; }
|
|
194
|
+
#auto-refresh .auto-refresh-measure { visibility:hidden; }
|
|
195
|
+
.intro { display: block; padding: 32px 0 26px; min-height: 98px; }
|
|
192
196
|
main { align-self: start; }
|
|
197
|
+
#main-content:focus { outline: none; }
|
|
193
198
|
.section-link { display: inline-block; color: var(--accent); font-size: 12px; text-underline-offset: 3px; }
|
|
194
199
|
.section-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
|
|
195
200
|
.model-summary strong { color: var(--strong); }
|
|
196
201
|
.panel h3 { color: var(--heading); font-size: 12px; font-weight: 650; margin: 0; }
|
|
197
202
|
.setting-row + .tool-details { border-top: 0; padding-top: 0; }
|
|
198
|
-
.diagnostic-section + .diagnostic-section { margin-top:
|
|
203
|
+
.diagnostic-section + .diagnostic-section { margin-top: 26px; }
|
|
199
204
|
.diagnostic-section > strong { display: block; color: var(--strong); font-size: 23px; margin-top: 16px; }
|
|
200
205
|
.usage-source-controls { margin: 0 0 20px; }
|
|
201
206
|
.chart-heading { flex-wrap: wrap; align-items: end; }
|
|
@@ -215,7 +220,7 @@ main { align-self: start; }
|
|
|
215
220
|
.section-actions label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; max-width: 100%; }
|
|
216
221
|
.section-actions input, .section-actions select { max-width: 100%; min-height: 36px; }
|
|
217
222
|
input[type="number"] { width: 120px; font: inherit; color: var(--text); background: var(--page); border: 1px solid var(--border); padding: 7px; }
|
|
218
|
-
.setting-row { display: grid; grid-template-columns: minmax(160px, 1fr) 44px minmax(0, 1.4fr); align-items: center; gap: 16px; padding: 20px 0;
|
|
223
|
+
.setting-row { display: grid; grid-template-columns: minmax(160px, 1fr) 44px minmax(0, 1.4fr); align-items: center; gap: 16px; padding: 20px 0; font-size: 13px; }
|
|
219
224
|
.setting-row .hint { margin: 0; }
|
|
220
225
|
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; }
|
|
221
226
|
input[role="switch"]::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; border-radius: 50%; background: var(--muted); }
|
|
@@ -225,7 +230,7 @@ input[role="switch"]:focus-visible, input[type="number"]:focus-visible { outline
|
|
|
225
230
|
input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
226
231
|
#process-queues { overflow-wrap: anywhere; font-size: 11px; }
|
|
227
232
|
@media (max-width: 1100px) { .topbar .brand { display: none; } .topbar { justify-content: flex-end; } }
|
|
228
|
-
@media (max-width: 900px) { .shell { grid-template-columns: 170px minmax(0, 1fr); column-gap: 20px; padding: 0 20px; } .setting-row { grid-template-columns: minmax(0, 1fr) 44px; } .setting-row .hint { grid-column: 1 / -1; } .overview { grid-template-columns: 1fr; } .shell { grid-template-rows: 96px minmax(0, 1fr) auto; } .topbar { height: 96px; } .topbar-actions { display: grid; grid-template-columns: 32px
|
|
233
|
+
@media (max-width: 900px) { .shell { grid-template-columns: 170px minmax(0, 1fr); column-gap: 20px; padding: 0 20px; } .setting-row { grid-template-columns: minmax(0, 1fr) 44px; } .setting-row .hint { grid-column: 1 / -1; } .overview { grid-template-columns: 1fr; } .shell { grid-template-rows: 96px minmax(0, 1fr) auto; } .topbar { height: 96px; } .topbar-actions { display: grid; grid-template-columns: 32px 40px max-content max-content; justify-content:end; gap: 8px 9px; width: 100%; } .topbar-actions #connection { grid-column: 1 / -1; width: auto; } .topbar-actions #auto-refresh { width: auto; min-width: 0; padding-inline: 8px; } }
|
|
229
234
|
@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; width: fit-content; } .sidebar-brand .brand-caption { margin-top: 4px; } .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 { 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; } }
|
|
230
235
|
|
|
231
236
|
/* Keep forms aligned with the existing dashboard controls. */
|
|
@@ -233,12 +238,13 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
233
238
|
.sidebar nav .nav-child { padding-left: 28px; }
|
|
234
239
|
.section-actions > label { min-width: 0; max-width: 100%; }
|
|
235
240
|
.section-actions select { min-width: 180px; width: 100%; max-width: 320px; }
|
|
236
|
-
.section-actions input:not([type="checkbox"]), .section-actions select, .section-actions button,
|
|
241
|
+
.section-actions input:not([type="checkbox"]), .section-actions select, .section-actions button, .section-actions .button-link,
|
|
237
242
|
.analytics-controls select { box-sizing: border-box; height: 36px; min-height: 36px; line-height: normal; }
|
|
238
|
-
.section-actions button { padding-top: 0; padding-bottom: 0; }
|
|
243
|
+
.section-actions button, .section-actions .button-link { padding-top: 0; padding-bottom: 0; }
|
|
239
244
|
@media (max-width: 640px) {
|
|
240
|
-
.topbar { height: 96px; padding:
|
|
241
|
-
.topbar-actions { justify-content:
|
|
245
|
+
.topbar { height:auto; min-height:96px; padding:8px 0; }
|
|
246
|
+
.topbar-actions { display:flex; flex-wrap:wrap; justify-content:flex-start; gap:8px; }
|
|
247
|
+
.topbar-actions #connection { flex-basis:100%; }
|
|
242
248
|
.section-actions > label { flex: 1 1 180px; }
|
|
243
249
|
.section-actions select { max-width: 100%; }
|
|
244
250
|
}
|
|
@@ -273,7 +279,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
273
279
|
.appearance-label p { margin:4px 0 0; font-size:12px; color:var(--subtle); line-height:1.7; }
|
|
274
280
|
.appearance-select { width:100%; max-width:100%; min-width:0; height:36px; box-sizing:border-box; border-radius:0; padding:0 30px 0 10px; font-size:12px; }
|
|
275
281
|
.appearance-note { color:var(--subtle); margin:17px 0 0; font-size:12px; line-height:1.7; }
|
|
276
|
-
.appearance-animation { margin-top:22px;
|
|
282
|
+
.appearance-animation { margin-top:22px; }
|
|
277
283
|
.terminal-animation-toggle { border-bottom:0; }
|
|
278
284
|
.sidebar nav a { display:flex; align-items:center; gap:10px; }
|
|
279
285
|
.nav-icon { width:17px; height:17px; flex:none; fill:none; stroke:currentColor; stroke-width:1.5; stroke-linecap:round; stroke-linejoin:round; }
|
|
@@ -282,6 +288,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
282
288
|
.version-heading h2 { margin:0; }
|
|
283
289
|
.version-list { margin:18px 0 0; }
|
|
284
290
|
.version-list > div { display:grid; grid-template-columns:minmax(110px,1fr) auto minmax(150px,1fr); align-items:baseline; gap:16px; padding:14px 0; border-bottom:1px solid var(--border); }
|
|
291
|
+
.version-list > div:last-child { border-bottom:0; }
|
|
285
292
|
.version-list dt { font-size:12px; }
|
|
286
293
|
.version-list dd { margin:0; }
|
|
287
294
|
.version-list dd:nth-child(2) { font-size:18px; font-weight:650; color:var(--strong); }
|
|
@@ -377,12 +384,11 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
377
384
|
.state-label.state-unavailable, .state-label.state-unknown { color:var(--muted); }
|
|
378
385
|
.state-label > span { color:inherit; white-space:normal; }
|
|
379
386
|
.badge:has(.state-label)::before { display:none; }
|
|
380
|
-
.source-browse-note { margin:12px 0 20px; }
|
|
381
387
|
.account-name { margin:18px 0 6px; font-size:19px; color:var(--strong); font-weight:650; overflow-wrap:anywhere; }
|
|
382
388
|
.account-fields { display:grid; grid-template-columns:minmax(110px,150px) minmax(0,1fr); gap:10px 18px; margin:20px 0; font-size:12px; line-height:1.7; }
|
|
383
389
|
.account-fields dt { color:var(--muted); }
|
|
384
390
|
.account-fields dd { margin:0; min-width:0; }
|
|
385
|
-
.tool-details, .tool-flow { margin-top:
|
|
391
|
+
.tool-details, .tool-flow { margin-top:22px; }
|
|
386
392
|
.tool-details summary, .tool-flow h3 { color:var(--heading); font-size:12px; }
|
|
387
393
|
.device-code { display:block; color:var(--accent); font-size:23px; letter-spacing:.1em; margin:16px 0; }
|
|
388
394
|
.tool-link { display:inline-flex; min-height:36px; align-items:center; color:var(--accent); margin-right:16px; }
|
|
@@ -400,3 +406,49 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
400
406
|
.account-summary .state-label { gap: 6px; }
|
|
401
407
|
.source-account-actions { margin-top: 18px; }
|
|
402
408
|
@media(max-width:640px) { .account-summary { grid-template-columns:1fr; } }
|
|
409
|
+
|
|
410
|
+
.flow-network { position:relative;display:grid;grid-template-columns:minmax(130px,1fr) 70px minmax(170px,1fr);column-gap:clamp(36px,6vw,92px);align-items:stretch;min-height:236px;margin:26px 0 18px; }
|
|
411
|
+
.flow-wires { position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible; }
|
|
412
|
+
.flow-column,.flow-hub-column { position:relative;min-width:0; }
|
|
413
|
+
.flow-column { display:flex;flex-direction:column; }
|
|
414
|
+
.flow-column-title { height:18px;line-height:18px;margin:0 0 18px;color:var(--muted);font-size:11px;text-align:center; }
|
|
415
|
+
.flow-apps,#flow-models { display:flex;flex:1;flex-direction:column;justify-content:center;align-items:center;gap:68px;padding:32px 0;min-width:0; }
|
|
416
|
+
.flow-hub-column { display:flex;align-items:center;justify-content:center;padding-top:36px; }
|
|
417
|
+
.flow-node { position:relative;display:flex;align-items:center;gap:8px;width:max-content;max-width:100%;min-height:34px; }
|
|
418
|
+
.flow-choice { min-width:0;max-width:100%;min-height:34px;padding:7px 9px;border-color:transparent;background:transparent;color:var(--text);font-size:12px;font-weight:600;text-transform:none;text-align:center;overflow-wrap:anywhere; }
|
|
419
|
+
.flow-choice:hover { background:var(--option-hover); }
|
|
420
|
+
.flow-choice[aria-pressed="true"],.flow-choice[aria-pressed="true"]:hover { color:var(--page);background:var(--accent);border-color:var(--accent); }
|
|
421
|
+
.flow-count { flex:none;color:var(--muted);font-size:11px;font-variant-numeric:tabular-nums;white-space:nowrap; }
|
|
422
|
+
.flow-note { position:absolute;top:calc(100% + 4px);left:9px;max-width:100%;margin:0;color:var(--muted);font-size:10px; }
|
|
423
|
+
.flow-source { position:absolute;bottom:calc(100% + 9px);left:9px;color:var(--muted);font-size:10px;white-space:nowrap; }
|
|
424
|
+
.flow-node[data-related="false"] { opacity:.5; }
|
|
425
|
+
#flow-hub { position:relative;display:flex;align-items:center;justify-content:center;width:40px;height:40px;border:0;background:var(--surface);color:var(--text);padding:0;text-transform:none; }
|
|
426
|
+
#flow-hub b { position:absolute;top:calc(100% + 10px);left:50%;transform:translateX(-50%); }
|
|
427
|
+
#flow-hub:hover { color:var(--accent); }
|
|
428
|
+
.flow-logo { width:34px;height:34px;color:var(--accent); }
|
|
429
|
+
.flow-caption { display:flex;align-items:center;flex-wrap:wrap;gap:10px 16px;min-height:30px;font-size:11px;color:var(--muted); }
|
|
430
|
+
.flow-caption button { padding:5px 9px; }
|
|
431
|
+
.flow-wire { fill:none;stroke:var(--border);stroke-width:1;stroke-linecap:round;stroke-linejoin:round; }
|
|
432
|
+
.flow-live { stroke:var(--accent);opacity:.55; }
|
|
433
|
+
.flow-dim { opacity:.35; }
|
|
434
|
+
.flow-packet,.flow-wait { fill:var(--accent); }
|
|
435
|
+
.flow-packet { offset-distance:100%;animation:flow-travel 2.4s linear infinite; }
|
|
436
|
+
#request-flow[data-paused="true"] .flow-packet,#request-flow[data-paused="true"] #flow-state::before { animation-play-state:paused; }
|
|
437
|
+
#request-flow[data-state="idle"] #flow-state { display:inline-flex;align-items:center;gap:9px; }
|
|
438
|
+
#request-flow[data-state="idle"] #flow-state::before { content:"";width:4px;height:4px;border-radius:50%;background:var(--accent);box-shadow:0 0 10px 3px color-mix(in srgb,var(--accent) 25%,transparent);animation:flow-breathe 3.2s ease-in-out infinite; }
|
|
439
|
+
@keyframes flow-travel { from { offset-distance:100%; } to { offset-distance:0%; } }
|
|
440
|
+
@keyframes flow-breathe { 0%,100% { opacity:.45; } 50% { opacity:1; } }
|
|
441
|
+
@media(max-width:760px) {
|
|
442
|
+
.flow-network { grid-template-columns:minmax(105px,1fr) 66px minmax(120px,1fr);column-gap:18px; }
|
|
443
|
+
.flow-choice { font-size:11px;padding-inline:4px; }
|
|
444
|
+
.flow-node { gap:4px; }
|
|
445
|
+
.flow-apps,#flow-models { gap:92px; }
|
|
446
|
+
.flow-count { position:absolute;top:calc(100% + 46px);left:0;font-size:10px; }
|
|
447
|
+
.flow-source,.flow-note { left:4px; }
|
|
448
|
+
}
|
|
449
|
+
@media(max-width:460px) {
|
|
450
|
+
.flow-network { grid-template-columns:minmax(80px,1fr) 48px minmax(100px,1fr);column-gap:12px; }
|
|
451
|
+
.flow-column-title,.flow-source,.flow-note { font-size:10px; }
|
|
452
|
+
.flow-logo { width:26px;height:26px; }
|
|
453
|
+
}
|
|
454
|
+
@media(prefers-reduced-motion:reduce) { .flow-packet,#request-flow[data-state="idle"] #flow-state::before { animation:none; } }
|
package/src/dashboard/ui.js
CHANGED
|
@@ -255,6 +255,7 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
|
|
|
255
255
|
apply: render,
|
|
256
256
|
state: state => {
|
|
257
257
|
if (state.error || !state.value) globalThis.ccdxDashboardActivity?.unavailable();
|
|
258
|
+
if (state.error || !state.value) globalThis.ccdxDashboardFlow?.unavailable();
|
|
258
259
|
text("connection", state.pending && !state.value ? "reading" : state.error ? "unavailable_eb0be" : "service_reachable");
|
|
259
260
|
element("connection").className = `badge ${state.pending ? "neutral" : state.error ? "bad" : "good"}`;
|
|
260
261
|
globalThis.ccdxIcons?.set(element("connection"), state.pending && !state.value ? "reading" : state.error ? "unavailable_eb0be" : "service_reachable",
|
|
@@ -377,7 +378,7 @@ const dashboardRefresh = globalThis.ccdxRefresh.createController({
|
|
|
377
378
|
const autoRefreshKey = "ccdx.dashboard.autoRefresh";
|
|
378
379
|
const updateAutoRefresh = () => {
|
|
379
380
|
element("auto-refresh").setAttribute("aria-pressed", String(dashboardRefresh.automatic));
|
|
380
|
-
text("auto-refresh", dashboardRefresh.automatic ? "auto_refresh_on" : "auto_refresh_off");
|
|
381
|
+
text("auto-refresh-label", dashboardRefresh.automatic ? "auto_refresh_on" : "auto_refresh_off");
|
|
381
382
|
};
|
|
382
383
|
let automatic = true;
|
|
383
384
|
try { automatic = localStorage.getItem(autoRefreshKey) !== "off"; } catch { /* Keep the default when browser storage is unavailable. */ }
|
package/src/dashboard.mjs
CHANGED
|
@@ -13,6 +13,7 @@ const ASSETS = new Map([
|
|
|
13
13
|
["/time.js", ["./dashboard/time.js", "text/javascript; charset=utf-8"]],
|
|
14
14
|
["/status.js", ["./dashboard/status.js", "text/javascript; charset=utf-8"]],
|
|
15
15
|
["/activity.js", ["./dashboard/activity.js", "text/javascript; charset=utf-8"]],
|
|
16
|
+
["/flow.js", ["./dashboard/flow.js", "text/javascript; charset=utf-8"]],
|
|
16
17
|
["/usage.js", ["./dashboard/usage.js", "text/javascript; charset=utf-8"]],
|
|
17
18
|
["/refresh.js", ["./dashboard/refresh.js", "text/javascript; charset=utf-8"]],
|
|
18
19
|
["/icons.js", ["./dashboard/icons.js", "text/javascript; charset=utf-8"]],
|
package/src/optional-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/time.js", "/animation.js", "/status.js", "/activity.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/icons.js", "/tools.js"]);
|
|
1
|
+
export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/time.js", "/animation.js", "/status.js", "/activity.js", "/flow.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/icons.js", "/tools.js"]);
|
|
2
2
|
export const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth", "/_ccdx/ui/providers", "/_ccdx/ui/settings", "/_ccdx/ui/m365/accounts", "/_ccdx/ui/updates", "/_ccdx/ui/account", "/_ccdx/ui/checks"]);
|
|
3
3
|
|
|
4
4
|
export function isOptionalRoute(method, pathname) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const APPLICATIONS = new Set(["codex_app", "codex_cli", "codex", "claude_app", "claude_code", "claude", "api"]);
|
|
2
|
+
const DECLARED = new Map([["codex-app", "codex_app"], ["codex-cli", "codex_cli"], ["codex", "codex"], ["claude-app", "claude_app"], ["claude-code", "claude_code"]]);
|
|
3
|
+
const ORIGINATORS = new Map([["codex desktop", "codex_app"], ["codex_desktop", "codex_app"], ["codex_app", "codex_app"], ["codex_cli_rs", "codex_cli"], ["codex_exec", "codex_cli"], ["codex-cli", "codex_cli"], ["codex", "codex"], ["codex_vscode", "codex"]]);
|
|
4
|
+
const hint = value => typeof value === "string" && value.length <= 80 ? value.trim().toLowerCase() : "";
|
|
5
|
+
|
|
6
|
+
export function requestApplication(headers = {}, fallback = "api") {
|
|
7
|
+
const declared = DECLARED.get(hint(headers?.["x-ccdx-client"]));
|
|
8
|
+
if (declared) return declared;
|
|
9
|
+
// These are client-reported presentation hints, never routing or auth evidence.
|
|
10
|
+
const originator = ORIGINATORS.get(hint(headers?.originator));
|
|
11
|
+
if (originator) return originator;
|
|
12
|
+
// Accept only a known, versioned Codex agent prefix, never a substring match.
|
|
13
|
+
const agent = headers?.["user-agent"];
|
|
14
|
+
const prefix = typeof agent === "string" && agent.length <= 512
|
|
15
|
+
? /^(codex desktop|codex_desktop|codex_app|codex_cli_rs|codex_exec|codex-cli|codex_vscode|codex)\/\d[\w.+-]{0,63}(?:\s|$)/i.exec(agent)?.[1] : null;
|
|
16
|
+
return ORIGINATORS.get(hint(prefix)) || (APPLICATIONS.has(fallback) ? fallback : "api");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function applicationLabel(value) {
|
|
20
|
+
return APPLICATIONS.has(value) ? value : "api";
|
|
21
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { performance } from "node:perf_hooks";
|
|
2
2
|
import { currentRequestContext } from "./request-context.mjs";
|
|
3
3
|
import { isProviderId } from "./provider-metadata.mjs";
|
|
4
|
+
import { applicationLabel } from "./request-application.mjs";
|
|
4
5
|
|
|
5
6
|
const PERFORMANCE_ROUTES = Object.freeze(["responses", "responses_compact"]);
|
|
6
7
|
const PREPARATION_STAGES = Object.freeze(["admission", "body", "history", "images", "serialization"]);
|
|
@@ -12,6 +13,7 @@ const TERMINAL_ORIGINS = new Set([
|
|
|
12
13
|
]);
|
|
13
14
|
const MAX_MODEL_OUTCOME_LABELS = 32;
|
|
14
15
|
const MAX_RECENT_REQUESTS = 20;
|
|
16
|
+
const MAX_ACTIVE_REQUESTS = 64;
|
|
15
17
|
const MAX_PROVIDER_LABELS = 16;
|
|
16
18
|
const PREPARATION_EDGES_MS = Object.freeze([1, 2, 5, 10, 20, 50, 100, 250, 500, 1_000, 5_000, 30_000, 120_000]);
|
|
17
19
|
const TTFT_EDGES_MS = Object.freeze([
|
|
@@ -119,11 +121,24 @@ function histogramSnapshot(histogram, unit) {
|
|
|
119
121
|
return bucket;
|
|
120
122
|
});
|
|
121
123
|
buckets.push({ lower, upper: null, count: histogram.counts.at(-1) });
|
|
124
|
+
const percentile = fraction => {
|
|
125
|
+
if (!histogram.samples) return null;
|
|
126
|
+
const rank = Math.ceil(histogram.samples * fraction);
|
|
127
|
+
let count = 0;
|
|
128
|
+
for (const bucket of buckets) {
|
|
129
|
+
count += bucket.count;
|
|
130
|
+
if (count >= rank) return Math.min(bucket.upper ?? histogram.max, histogram.max);
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
};
|
|
122
134
|
return {
|
|
123
135
|
unit,
|
|
124
136
|
samples: histogram.samples,
|
|
125
137
|
avg: histogram.samples > 0 ? Number((histogram.total / histogram.samples).toFixed(1)) : 0,
|
|
126
138
|
max: histogram.max,
|
|
139
|
+
p50: percentile(0.5),
|
|
140
|
+
p95: percentile(0.95),
|
|
141
|
+
percentiles_estimated: true,
|
|
127
142
|
buckets,
|
|
128
143
|
};
|
|
129
144
|
}
|
|
@@ -199,12 +214,18 @@ function routeSnapshot(route) {
|
|
|
199
214
|
export function createStreamPerformanceMetrics({ now = () => performance.now(), wallNow = () => new Date().toISOString(), routeNames = PERFORMANCE_ROUTES } = {}) {
|
|
200
215
|
const routes = Object.fromEntries(routeNames.map((name) => [name, createRoutePerformance()]));
|
|
201
216
|
const recentRequests = [];
|
|
217
|
+
const activeRequests = new Map();
|
|
218
|
+
let activeTotal = 0, activeSequence = 0;
|
|
202
219
|
|
|
203
220
|
return {
|
|
204
|
-
begin(routeName, { requestId } = {}) {
|
|
221
|
+
begin(routeName, { requestId, application } = {}) {
|
|
205
222
|
const route = routes[routeName];
|
|
206
223
|
if (!route) return null;
|
|
207
224
|
const requestStartedAt = now();
|
|
225
|
+
const activeId = ++activeSequence;
|
|
226
|
+
const safeRequestId = typeof requestId === "string" && /^[a-zA-Z0-9_-]{1,80}$/.test(requestId) ? requestId : null;
|
|
227
|
+
const client = applicationLabel(application);
|
|
228
|
+
activeTotal++;
|
|
208
229
|
let upstreamStartedAt = null;
|
|
209
230
|
let firstOutputAt = null;
|
|
210
231
|
let firstOutputSource = null;
|
|
@@ -229,6 +250,12 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
229
250
|
let terminalAt = null;
|
|
230
251
|
const context = { payload_bytes: null, images: null, input_tokens: null, context_window_tokens: null };
|
|
231
252
|
const elapsed = (time) => time === null ? null : Number(Math.max(0, time - requestStartedAt).toFixed(1));
|
|
253
|
+
if (activeRequests.size < MAX_ACTIVE_REQUESTS) activeRequests.set(activeId, () => ({
|
|
254
|
+
request_id: safeRequestId, application: client, route: routeName, provider, model, phase,
|
|
255
|
+
started_at: at, elapsed_ms: elapsed(now()), first_output_ms: elapsed(firstOutputAt),
|
|
256
|
+
upstream_attempts: attempts, terminal_outcome: terminalOutcome,
|
|
257
|
+
attempts: attemptTimings.map(attempt => ({ ...attempt })),
|
|
258
|
+
}));
|
|
232
259
|
const assignProvider = value => {
|
|
233
260
|
if (finished || sourceStats || !isProviderId(value)) return;
|
|
234
261
|
provider = value;
|
|
@@ -322,6 +349,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
322
349
|
if (finished) return;
|
|
323
350
|
if (!sourceStats) assignProvider("unknown");
|
|
324
351
|
finished = true;
|
|
352
|
+
activeTotal--;activeRequests.delete(activeId);
|
|
325
353
|
failed ||= finishFailed;
|
|
326
354
|
const outcome = terminalOutcome || (aborted ? "cancelled" : "unknown");
|
|
327
355
|
const emptyStreamCompletion = outcome === "completed" && upstreamStartedAt !== null
|
|
@@ -347,7 +375,7 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
347
375
|
const finishedAt = now();
|
|
348
376
|
// Only scalar, allowlisted metadata survives the request; never retain payloads.
|
|
349
377
|
recentRequests.push({
|
|
350
|
-
request_id:
|
|
378
|
+
request_id: safeRequestId, application: client,
|
|
351
379
|
at, route: routeName, model, outcome, origin, phase,
|
|
352
380
|
...(provider ? { provider } : {}),
|
|
353
381
|
empty_stream_completion: emptyStreamCompletion,
|
|
@@ -394,6 +422,9 @@ export function createStreamPerformanceMetrics({ now = () => performance.now(),
|
|
|
394
422
|
snapshot() {
|
|
395
423
|
return {
|
|
396
424
|
by_route: Object.fromEntries(routeNames.map((name) => [name, routeSnapshot(routes[name])])),
|
|
425
|
+
active_requests: [...activeRequests.values()].map(snapshot => snapshot()),
|
|
426
|
+
active_total: activeTotal,
|
|
427
|
+
active_omitted: Math.max(0, activeTotal - activeRequests.size),
|
|
397
428
|
recent_requests: recentRequests.map((entry) => ({ ...entry, attempts: entry.attempts.map(attempt => ({ ...attempt })), context: { ...entry.context }, timings_ms: { ...entry.timings_ms } })),
|
|
398
429
|
};
|
|
399
430
|
},
|