codex-copilot-dx 1.4.10 → 1.4.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.
Files changed (44) hide show
  1. package/bin/cli.mjs +2 -0
  2. package/docs/ARCHITECTURE.md +1 -1
  3. package/docs/REFERENCE.md +11 -1
  4. package/package.json +1 -1
  5. package/src/access-settings.mjs +3 -1
  6. package/src/adapter.mjs +14 -5
  7. package/src/antigravity-handler.mjs +102 -7
  8. package/src/antigravity-models.mjs +3 -2
  9. package/src/antigravity-runtime.mjs +61 -18
  10. package/src/antigravity-usage.mjs +3 -3
  11. package/src/api-target.mjs +12 -1
  12. package/src/application-configuration.mjs +2 -1
  13. package/src/application-control.mjs +6 -3
  14. package/src/cli-management.mjs +4 -1
  15. package/src/connection-management.mjs +4 -2
  16. package/src/connection-policy.mjs +3 -3
  17. package/src/connection-routing.mjs +28 -10
  18. package/src/connection-runtime.mjs +4 -0
  19. package/src/connection-view.mjs +12 -0
  20. package/src/copilot-client.mjs +3 -2
  21. package/src/copilot.mjs +13 -2
  22. package/src/dashboard/connections.js +5 -5
  23. package/src/dashboard/console.js +9 -4
  24. package/src/dashboard/context.js +15 -5
  25. package/src/dashboard/flow.js +1 -0
  26. package/src/dashboard/gemini.js +40 -10
  27. package/src/dashboard/index.html +10 -7
  28. package/src/dashboard/language.js +14 -3
  29. package/src/dashboard/status.js +15 -2
  30. package/src/dashboard/tool-activity.js +63 -35
  31. package/src/dashboard/ui.css +25 -16
  32. package/src/dashboard-api.mjs +2 -1
  33. package/src/failure-history.mjs +97 -0
  34. package/src/messages-tool-schema.mjs +1 -1
  35. package/src/model-capabilities.mjs +1 -1
  36. package/src/privacy-transform.mjs +22 -4
  37. package/src/provider-metadata.mjs +1 -1
  38. package/src/providers/api-network.mjs +4 -3
  39. package/src/providers/api.mjs +79 -15
  40. package/src/response-failures.mjs +3 -1
  41. package/src/runtime-config.mjs +1 -0
  42. package/src/source-admission.mjs +1 -1
  43. package/src/windows-http-network.mjs +4 -3
  44. package/src/windows-prediction-network.cs +11 -0
@@ -76,7 +76,7 @@
76
76
  const gemini=data.gemini || globalThis.ccdxGeminiStatus;
77
77
  const setup=gemini.enabled&&gemini.source_enabled!==false?"configured":gemini.configured?"access_paused":"not_configured";
78
78
  const service=gemini.configured===true?"running":gemini.configured===false?"unavailable":"unknown";
79
- const row=tableRow(["Antigravity",gemini.enabled&&gemini.source_enabled!==false?"Google + GitHub Copilot":"Google",setup,service,"—"],{labels:[2,3]});
79
+ const row=tableRow(["Antigravity",gemini.model_source||(gemini.enabled&&gemini.source_enabled!==false?"Google + GitHub Copilot":"Google"),setup,service,"—"],{labels:[2,3]});
80
80
  if(globalThis.ccdxIcons){
81
81
  globalThis.ccdxIcons.set(row.children[2],setup,globalThis.ccdxIcons.kind(setup==="access_paused"?"paused":setup));
82
82
  globalThis.ccdxIcons.set(row.children[3],service,globalThis.ccdxIcons.kind(service));
@@ -215,7 +215,7 @@
215
215
  const label = document.createElement("dt");
216
216
  const content = document.createElement("dd");
217
217
  localize(label, key);
218
- const rawValue = String(value).slice(0, 500);
218
+ const rawValue = (typeof value?.key === "string" ? globalThis.ccdxLanguage.format(value.key, value.values) : String(value)).slice(0, 500);
219
219
  if (key === "retry" || (key === "message" && failure.local_message)) localize(content, rawValue);
220
220
  else content.textContent = rawValue;
221
221
  diagnostic.append(label, content);
@@ -351,6 +351,19 @@
351
351
  issueRequests = recentRequests;
352
352
  const kind = element("failure-kind")?.value || "issues";
353
353
  renderFailures(issueGroups[kind] || [], kind === "issues" ? recentRequests : []);
354
+ const history = data.http_errors?.history, historyPanel = element("failure-history");
355
+ if (historyPanel) {
356
+ historyPanel.hidden = !history?.total;
357
+ if (history?.total) {
358
+ text("failure-history-title", "failure_history_count", { count: number(history.total) });
359
+ element("failure-history-body").replaceChildren(...history.groups.map(group => {
360
+ const row = tableRow([phrase(`flow_app_${group.application}`), group.model, phrase(group.phase === "unknown" ? "unknown" : `failure_phase_${group.phase}`),
361
+ number(group.count), time(group.last.at, { date: true }), group.last.request_id || "—"]);
362
+ if (group.last.client_request_id) row.lastElementChild.title = group.last.client_request_id;
363
+ return row;
364
+ }));
365
+ }
366
+ }
354
367
  renderContext({ ...data.stream_performance, recent_requests: recentRequests });
355
368
  }
356
369
  function renderActivity(data) {
@@ -1,20 +1,78 @@
1
1
  (() => {
2
2
  const root = document.getElementById("tool-activity");if (!root) return;
3
3
  const el = id => document.getElementById(id), canvas = el("tool-canvas"), ctx = canvas.getContext?.("2d");
4
- const styles = new Set(["halo", "grid", "busy", "speed", "assembly", "off"]), storageKey = "ccdx.dashboard.toolMotionStyle";
4
+ const styles = new Set(["halo", "grid", "assembly", "off"]), storageKey = "ccdx.dashboard.toolMotionStyle";
5
5
  const pending = state => ["preparing", "waiting"].includes(state);
6
6
  const phrase = (key, values = {}) => globalThis.ccdxLanguage.format(key, values);
7
7
  const text = (id, key, values) => globalThis.ccdxLanguage.set(el(id), key, values);
8
- const state = { scene: "idle", style: "halo", intensity: .8, reduce: false };
8
+ const state = { scene: "idle", style: "assembly", intensity: .8, reduce: false };
9
9
  try { const saved = localStorage.getItem(storageKey);if (styles.has(saved)) state.style = saved; } catch {}
10
10
  const motion = globalThis.matchMedia?.("(prefers-reduced-motion: reduce)") || { matches: false, addEventListener() {} };
11
11
  let records = [], fresh = false, supported = false, visible = true, raf = 0, last = 0, start = performance.now(), expiry = null;
12
- let signature = "", box = { width: 0, height: 0 }, color = "", omitted = 0, requests = [], requestDeadline = 0;
12
+ let signature = "", box = { width: 0, height: 0 }, color = "", surface = "", omitted = 0, requests = [], requestDeadline = 0;
13
13
  const animating = () => ["calling", "parallel", "waiting", "processing", "responding"].includes(state.scene);
14
14
  const shown = () => document.visibilityState === "visible" && !root.closest("[hidden]") && visible;
15
15
  function measure() {
16
- box = canvas.getBoundingClientRect();color = getComputedStyle(document.documentElement).getPropertyValue("--accent").trim();
16
+ box = canvas.getBoundingClientRect();
17
+ const theme = getComputedStyle(document.documentElement);
18
+ color = theme.getPropertyValue("--accent").trim();surface = theme.getPropertyValue("--surface").trim();
17
19
  refreshAnimation();
20
+ }
21
+ function drawAssembly(dpr,w,h,t,active,waiting,returned,reduced) {
22
+ const scale=Math.min((w-12)/264,(h-12)/118);
23
+ if(scale<=0)return;
24
+ ctx.setTransform(scale*dpr,0,0,scale*dpr,(w-264*scale)*dpr/2,(h-118*scale)*dpr/2);
25
+ const running=active||waiting;
26
+ const phase=reduced?.42:(t*(waiting?.7:1.04))%2.1/2.1;
27
+ const press=running?Math.max(0,1-Math.abs(phase-.5)/.14):0;
28
+ const travel=value=>value*(.7+.3*value);
29
+ const workX=returned?132+91*travel(Math.min(1,t/.85)):
30
+ phase<.34?29+103*travel(phase/.34):phase<.66?132:132+91*travel((phase-.66)/.34);
31
+ const shift=running||returned?(workX-29)%14:0;
32
+ const assembled=returned||phase>=.5;
33
+ function path(points,closed=false){
34
+ ctx.beginPath();ctx.moveTo(points[0],points[1]);
35
+ for(let i=2;i<points.length;i+=2)ctx.lineTo(points[i],points[i+1]);
36
+ if(closed)ctx.closePath();
37
+ }
38
+ // Floor, braced stands and the rear uprights of the press.
39
+ ctx.lineWidth=1.2;ctx.globalAlpha=.22;
40
+ path([18,108,246,108]);ctx.stroke();
41
+ ctx.globalAlpha=.52;
42
+ path([35,88,35,108,55,108,55,88,35,106,55,90]);ctx.stroke();
43
+ path([209,88,209,108,229,108,229,88,209,106,229,90]);ctx.stroke();
44
+ ctx.fillRect(99,22,5,45);ctx.fillRect(160,22,5,45);
45
+ ctx.strokeRect(93,11,78,13);
46
+ ctx.globalAlpha=.23;
47
+ ctx.fillRect(93,11,78,13);
48
+ ctx.globalAlpha=.65;
49
+ ctx.beginPath();
50
+ for(let i=98;i<168;i+=8){ctx.moveTo(i,21);ctx.lineTo(i+4,14);}
51
+ ctx.stroke();
52
+ // Belt deck and rollers, with the drive drums in the front housing.
53
+ ctx.globalAlpha=.18;path([13,77,239,77,252,65,26,65],true);ctx.fill();
54
+ ctx.globalAlpha=.64;ctx.stroke();
55
+ ctx.beginPath();
56
+ for(let i=30;i<235;i+=14){ctx.moveTo(i+shift,75);ctx.lineTo(i+shift+9,67);}
57
+ ctx.stroke();
58
+ ctx.globalAlpha=.16;ctx.fillRect(13,77,226,13);
59
+ ctx.globalAlpha=.72;ctx.strokeRect(13,77,226,13);
60
+ for(const x of [22,230]){ctx.beginPath();ctx.arc(x,83.5,3.8,0,Math.PI*2);ctx.stroke();}
61
+ // Cylinder, piston and platen travel together.
62
+ const piston=press*9;
63
+ ctx.globalAlpha=.82;ctx.strokeRect(123,24,18,13);ctx.fillRect(130,37,4,5+piston);
64
+ ctx.fillRect(120,42+piston,24,3);
65
+ if(running||returned){
66
+ const x=workX-11,y=assembled?57:60;
67
+ ctx.globalAlpha=1;ctx.fillStyle=surface;
68
+ path([x,75,x,y,x+6,y-5,x+27,y-5,x+27,70,x+21,75],true);ctx.fill();
69
+ ctx.fillStyle=color;ctx.globalAlpha=.24;ctx.fill();
70
+ ctx.globalAlpha=.86;ctx.stroke();
71
+ path([x,y,x+21,y,x+27,y-5]);ctx.stroke();
72
+ path([x+21,y,x+21,75]);ctx.stroke();
73
+ if(assembled){ctx.globalAlpha=.62;ctx.fillRect(x+6,y+5,9,3);}
74
+ }
75
+ ctx.globalAlpha=1;
18
76
  }
19
77
  function draw(now=performance.now()){
20
78
  if(!ctx||!box.width||!box.height)return;
@@ -36,38 +94,8 @@
36
94
  }
37
95
  ctx.globalAlpha=1;return;
38
96
  }
39
- if(state.style==='busy'){
40
- const n=7,bw=12,gap=11,left=cx-(n*bw+(n-1)*gap)/2;
41
- for(let i=0;i<n;i++){
42
- const wave=active||waiting?(Math.sin(t*(waiting?6:11)-i*.8)+1)/2:.2;
43
- const bh=quiet?12:returned?22:14+wave*54;
44
- ctx.globalAlpha=quiet?.15:returned?.55:.18+wave*power;ctx.fillRect(left+i*(bw+gap),cy-bh/2,bw,bh);
45
- }
46
- ctx.globalAlpha=1;return;
47
- }
48
- if(state.style==='speed'){
49
- const span=Math.min(w-36,220),left=cx-span/2;
50
- for(let i=0;i<7;i++){
51
- const phase=(t*(waiting?1.5:3.3)+i*.173)%1,len=20+(i%3)*16,y=cy+(i-3)*13;
52
- const x=active||waiting?left+phase*(span+len)-len:left+span*.43;
53
- ctx.globalAlpha=quiet?.12:returned?.5:Math.sin(phase*Math.PI)*power;
54
- ctx.lineWidth=i===3?3:1.5;ctx.beginPath();ctx.moveTo(Math.max(left,x),y);ctx.lineTo(Math.min(left+span,x+len),y);ctx.stroke();
55
- }
56
- ctx.globalAlpha=1;return;
57
- }
58
97
  if(state.style==='assembly'){
59
- const span=Math.min(w-32,218),left=cx-span/2,rail=cy+23;
60
- ctx.globalAlpha=quiet?.12:.26;ctx.lineWidth=1;
61
- ctx.beginPath();ctx.moveTo(left,rail);ctx.lineTo(left+span,rail);ctx.moveTo(left,rail+8);ctx.lineTo(left+span,rail+8);ctx.stroke();
62
- for(let i=0;i<3;i++){
63
- const x=left+span*(i+.5)/3,phase=(t*(waiting?1.5:3.2)-i/3+9)%1,press=active||waiting?Math.max(0,1-Math.abs(phase-.5)*5):0;
64
- ctx.globalAlpha=quiet?.16:.58;ctx.fillRect(x-14,cy-36,28,8);ctx.fillRect(x-2,cy-28,4,16+press*16);ctx.fillRect(x-9,cy-14+press*16,18,4);
65
- }
66
- for(let i=0;i<5;i++){
67
- const phase=active||waiting?(t*(waiting?.7:1.6)+i/5)%1:(i+.5)/5,x=left+phase*span;
68
- ctx.globalAlpha=quiet?.12:returned?.55:.2+Math.sin(phase*Math.PI)*power;ctx.fillRect(x-5,rail-12,10,10);
69
- }
70
- ctx.globalAlpha=1;return;
98
+ drawAssembly(dpr,w,h,t,active,waiting,returned,reduced);return;
71
99
  }
72
100
  arc(r,0,Math.PI*2,.25);arc(r*.85,0,Math.PI*2,.13);arc(r*1.12,0,Math.PI*2,.1);
73
101
  const spin=active?t*1.6:waiting?t*.9:0;
@@ -171,11 +171,11 @@ select option { color: var(--text); background: var(--surface); }
171
171
  .chart-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin: 22px 0 10px; }
172
172
  .chart-heading h3 { margin: 0; color: var(--heading); font-size: 11px; }
173
173
  .chart-heading span, .chart-legend { color: var(--muted); font-size: 10px; }
174
- .daily-bars { display: flex; align-items: end; gap: 3px; height: 130px; border-bottom: 1px solid var(--border); }
175
- .daily-bar { height: 100%; flex: 1; min-width: 0; padding: 0; border: 0; display: flex; flex-direction: column; justify-content: end; background: transparent; border-radius: 0; }
174
+ .daily-bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 130px; border-bottom: 1px solid var(--border); }
175
+ .daily-bar { height: 100%; min-width: 0; padding: 0; border: 0; display: flex; flex-direction: column; justify-content: end; background: transparent; border-radius: 0; }
176
176
  .daily-bar span { display: block; flex-shrink: 0; width: 100%; }
177
- .daily-bar .bar-stack { display:flex; flex-direction:column; justify-content:end; height:100%; transform-origin:center bottom; }
178
- .daily-lines { position:relative; gap:0; }
177
+ .daily-bar .bar-stack { display:flex; flex-direction:column; justify-content:end; align-self:center; width:max(calc(100% - 3px), min(100%, 2px)); height:100%; transform-origin:center bottom; }
178
+ .daily-lines { position:relative; }
179
179
  .daily-line-plot { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; overflow:visible; }
180
180
  .daily-curve { fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:1; stroke-dashoffset:0; }
181
181
  .curve-input { stroke:var(--accent-soft); }
@@ -196,7 +196,7 @@ select option { color: var(--text); background: var(--surface); }
196
196
  .calendar-grid { width: max-content; }
197
197
  .calendar-months { display: grid; grid-auto-columns: 12px; gap: 4px; margin-bottom: 7px; color: var(--muted); font-size: 9px; height: 14px; }
198
198
  .activity-calendar { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 4px; width: max-content; }
199
- .calendar-day { padding: 0; border: 1px solid var(--border); width: 12px; height: 12px; background: var(--button-bg); }
199
+ .calendar-day { padding: 0; border: 1px solid var(--border); width: 12px; height: 12px; min-height: 0; background: var(--button-bg); }
200
200
  .calendar-day[data-level="1"] { background: color-mix(in srgb, var(--accent-soft) 25%, var(--surface)); }
201
201
  .calendar-day[data-level="2"] { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
202
202
  .calendar-day[data-level="3"] { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
@@ -499,7 +499,8 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
499
499
  .source-account-actions { margin-top: 18px; }
500
500
  @media(max-width:640px) { .account-summary { grid-template-columns:1fr; } }
501
501
 
502
- .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:218px;margin:16px 0 12px; }
502
+ .flow-viewport { height:290px; overflow:auto; scrollbar-gutter:stable; margin:16px 0 12px; }
503
+ .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:100%; }
503
504
  .flow-wires { position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible; }
504
505
  .flow-activity { will-change:transform; }
505
506
  .flow-wires .flow-split { visibility:hidden;animation:none; }
@@ -512,7 +513,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
512
513
  #flow-apps .flow-choice { text-align:right; }
513
514
  #flow-apps .flow-count { margin-right:9px; }
514
515
  #flow-apps .flow-note { left:auto;right:9px;text-align:right; }
515
- .flow-hub-column { display:flex;align-items:center;justify-content:center;padding-top:32px; }
516
+ .flow-hub-column { position:sticky;top:0;align-self:start;display:flex;align-items:center;justify-content:center;height:290px;padding-top:32px; }
516
517
  .flow-node { position:relative;display:flex;align-items:center;gap:8px;width:max-content;max-width:100%;min-height:34px; }
517
518
  .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; }
518
519
  .flow-choice:hover { background:var(--option-hover); }
@@ -533,7 +534,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
533
534
  #request-flow[data-state="unknown"] .flow-halo-track { opacity:.15; }
534
535
  #request-flow[data-paused="true"] .flow-halo-turn { animation-play-state:paused; }
535
536
  @keyframes flow-orbit { from { transform:rotate(-90deg); } to { transform:rotate(270deg); } }
536
- .flow-caption { display:flex;align-items:center;flex-wrap:wrap;gap:10px 16px;min-height:30px;font-size:11px;color:var(--muted); }
537
+ .flow-caption { display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;height:40px;overflow:auto;font-size:11px;color:var(--muted); }
537
538
  .flow-caption button { padding:5px 9px; }
538
539
  .flow-wire { fill:none;stroke:var(--border);stroke-width:1;stroke-linecap:round;stroke-linejoin:round; }
539
540
  .flow-live { stroke:var(--accent);opacity:.68; }
@@ -546,6 +547,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
546
547
  @keyframes flow-dash { from { stroke-dashoffset:0; } to { stroke-dashoffset:24; } }
547
548
  @keyframes flow-breathe { 0%,100% { opacity:.45; } 50% { opacity:1; } }
548
549
  @media(max-width:760px) {
550
+ .flow-caption { height:72px; }
549
551
  .flow-network { grid-template-columns:minmax(105px,1fr) 66px minmax(120px,1fr);column-gap:18px; }
550
552
  .flow-choice { font-size:11px;padding-inline:4px; }
551
553
  .flow-node { gap:4px; }
@@ -556,7 +558,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
556
558
  #flow-apps .flow-note { left:auto;right:4px; }
557
559
  }
558
560
  @media(max-width:460px) {
559
- .flow-network { grid-template-columns:minmax(80px,1fr) 48px minmax(100px,1fr);column-gap:12px; }
561
+ .flow-network { grid-template-columns:minmax(0,1fr) 48px minmax(0,1.25fr);column-gap:12px; }
560
562
  .flow-column-title,.flow-source,.flow-note { font-size:10px; }
561
563
  .flow-logo { width:26px;height:26px; }
562
564
  #flow-hub,.flow-halo { width:48px;height:48px; }
@@ -607,9 +609,16 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
607
609
 
608
610
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
609
611
 
610
- #flow-models { align-items:stretch; }
611
- #flow-models .flow-node { width:100%; }
612
- #flow-models .flow-choice { text-align:left; }
612
+ #flow-models { align-items:stretch; gap:20px; }
613
+ #flow-models .flow-node { --model-inset:9px; display:grid; grid-template-columns:minmax(0,1fr) max-content; gap:3px 8px; width:100%; }
614
+ #flow-models .flow-choice { grid-area:2/1; justify-self:start; text-align:left; }
615
+ #flow-models .flow-count { grid-area:2/2; position:static; }
616
+ #flow-models :is(.flow-source,.flow-note) { position:static; grid-column:1/-1; margin-inline:var(--model-inset); white-space:normal; overflow-wrap:anywhere; }
617
+ #flow-models .flow-source { grid-row:1; }
618
+ #flow-models .flow-note { grid-row:3; }
619
+ @media(max-width:760px) {
620
+ #flow-models .flow-node { --model-inset:4px; }
621
+ }
613
622
  .flow-column:last-child .flow-column-title { text-align:left;padding-left:9px; }
614
623
  .model-maker { display:block;margin-top:5px;color:var(--muted);font-size:11px;font-weight:400; }
615
624
  .model-identity { display:grid;grid-template-columns:auto 1fr;gap:8px 16px;font-size:12px;margin:18px 0; }
@@ -666,8 +675,8 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
666
675
  .context-metrics { display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;margin:18px 0; }
667
676
  .context-metrics dt { color:var(--muted);font-size:11px; }
668
677
  .context-metrics dd { margin:8px 0 0;font-size:23px;font-variant-numeric:tabular-nums; }
669
- .context-history-chart { min-height:210px;color:var(--muted);margin-top:14px; }
670
- .context-history-chart svg { width:100%;height:210px;display:block; }
678
+ .context-history-chart { min-height:225px;color:var(--muted);margin-top:14px; }
679
+ .context-history-chart svg { width:100%;height:225px;display:block; }
671
680
  .context-history-chart text { font-size:11px;fill:var(--muted); }
672
681
  .context-grid { stroke:var(--border);stroke-width:1; }
673
682
  .context-line { fill:none;stroke:var(--accent);stroke-width:1.6; }
@@ -684,7 +693,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
684
693
 
685
694
  .tool-style { display:flex;align-items:center;gap:8px;font-size:12px;color:var(--muted);white-space:nowrap; }
686
695
  .tool-style select { max-width:160px; }
687
- .tool-stage { display:grid;grid-template-columns:minmax(180px,250px) minmax(0,1fr);align-items:center;gap:24px;min-height:230px; }
696
+ .tool-stage { display:grid;grid-template-columns:minmax(180px,250px) minmax(0,1fr);align-items:start;gap:24px;min-height:230px; }
688
697
  .tool-visual,.tool-content { min-width:0; }
689
698
  .tool-orbit { width:100%;height:190px;position:relative; }
690
699
  .tool-orbit canvas { display:block;width:100%;height:100%; }
@@ -706,7 +715,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
706
715
  #tool-cursor { display:inline-block;animation:tool-cursor 1s steps(1) infinite; }
707
716
  #tool-activity[data-paused="true"] #tool-cursor { animation:none; }
708
717
  @keyframes tool-cursor { 50% { opacity:0; } }
709
- @media(max-width:620px) { .tool-stage { grid-template-columns:1fr;gap:8px; }.tool-visual { width:100%;max-width:330px;margin:auto; }.tool-content { padding-bottom:8px; }.tool-context { margin-bottom:4px; } }
718
+ @media(max-width:620px) { .tool-stage { grid-template-columns:1fr;grid-template-rows:auto 1fr;gap:8px; }.tool-stage[data-style="off"] { grid-template-rows:1fr; }.tool-visual { width:100%;max-width:330px;margin-inline:auto; }.tool-content { padding-bottom:8px; }.tool-context { margin-bottom:4px; } }
710
719
  @media(prefers-reduced-motion:reduce) { #tool-cursor { animation:none; } }
711
720
 
712
721
  /* Compact request statistics in the existing diagnostics panel. */
@@ -412,7 +412,8 @@ export async function handleDashboardApi(req, res, pathname, {
412
412
  return selection.matches(record);
413
413
  };
414
414
  const analysis = (analytics || filtered) && !usageSummaryFn
415
- ? await analyzeUsageLogs(undefined, { provider, model: selection.filters.model, from: selection.filters.from, to: selection.filters.to, timeZone: selection.filters.time_zone, signal: abort.signal }) : null;
415
+ ? await analyzeUsageLogs(undefined, { provider, model: selection.filters.model, purpose: selection.filters.purpose,
416
+ from: selection.filters.from, to: selection.filters.to, timeZone: selection.filters.time_zone, signal: abort.signal }) : null;
416
417
  const summary = analysis?.summary || await (usageSummaryFn || (options => summarizeUsageLogs(undefined, { ...options, signal: abort.signal })))({ provider,
417
418
  ...(filtered ? { recordFilter } : {}), ...(analytics ? { onRecord: analytics.record } : {}) });
418
419
  const availableModels = analysis?.analytics.models || (observedModels.size ? [...observedModels].sort() : Object.keys(provider ? summary.byModel : summary.bySourceModel || summary.byModel).sort().slice(0, 100));
@@ -0,0 +1,97 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+ import { atomicWriteFile } from "./atomic-file.mjs";
4
+ import { readBoundedFile, readBoundedFileSync } from "./bounded-file.mjs";
5
+ import { withFileLock } from "./lock.mjs";
6
+ import { redactDiagnosticText } from "./diagnostic-text.mjs";
7
+
8
+ const HOUR = 3600000, HOURS = 24, PER_HOUR = 32, MAX_BYTES = 512 * 1024;
9
+ const APPS = new Set(["codex_app", "codex_cli", "codex", "claude_app", "claude_code", "claude", "gemini_app", "api"]);
10
+ const PHASES = new Set(["local", "send", "headers", "stream", "upstream", "unknown"]);
11
+ export const failureHistoryPath = (home = os.homedir()) => path.join(home, ".local", "share", "codex-copilot-dx", "failure-history.json");
12
+ const requestId = value => typeof value === "string" && /^[\da-f-]{36}$/i.test(value) ? value : null;
13
+ const modelName = value => typeof value === "string" && /^[\w][\w./:@+-]{0,119}$/.test(value) && redactDiagnosticText(value) === value ? value : "unknown";
14
+ const groupKey = value => JSON.stringify([value.application, value.model, value.phase]);
15
+ const hour = now => Math.floor(now / HOUR) * HOUR;
16
+ const keep = (now, value) => Number.isSafeInteger(value) && value >= hour(now) - (HOURS - 1) * HOUR && value <= hour(now) && value % HOUR === 0;
17
+
18
+ function put(buckets, row) {
19
+ let groups = buckets.get(row.hour);
20
+ if (!groups) buckets.set(row.hour, groups = new Map());
21
+ let key = groupKey(row);
22
+ if (!groups.has(key) && groups.size >= PER_HOUR - 1) {
23
+ row = { ...row, application: "api", model: "unknown", phase: "unknown" };
24
+ key = groupKey(row);
25
+ }
26
+ const previous = groups.get(key);
27
+ groups.set(key, { ...row, count: Math.min(Number.MAX_SAFE_INTEGER, (previous?.count || 0) + row.count),
28
+ last: !previous || row.last.at >= previous.last.at ? row.last : previous.last });
29
+ }
30
+
31
+ function parse(text, now) {
32
+ const result = new Map();
33
+ for (const row of JSON.parse(text)?.rows || []) {
34
+ if (!row || !keep(now, row.hour) || !APPS.has(row.application) || !PHASES.has(row.phase) ||
35
+ !Number.isSafeInteger(row.count) || row.count < 1 || !Number.isSafeInteger(row.last?.at) || hour(row.last.at) !== row.hour) continue;
36
+ put(result, { hour: row.hour, application: row.application, model: modelName(row.model), phase: row.phase, count: row.count,
37
+ last: { at: row.last.at, status: Number.isInteger(row.last.status) && row.last.status >= 400 && row.last.status <= 599 ? row.last.status : null,
38
+ request_id: requestId(row.last.request_id), client_request_id: requestId(row.last.client_request_id) } });
39
+ }
40
+ return result;
41
+ }
42
+
43
+ const options = { encoding: "utf8", maxBytes: MAX_BYTES };
44
+ const values = buckets => [...buckets.values()].flatMap(group => [...group.values()]);
45
+ const prune = (buckets, now) => { for (const key of buckets.keys()) if (!keep(now, key)) buckets.delete(key); };
46
+ function phase(details) {
47
+ const attempt = details.attempt_timings?.at(-1);
48
+ if (details.origin === "upstream_http") return "upstream";
49
+ if (details.origin === "upstream_event" || attempt?.headers_ms != null) return "stream";
50
+ if (attempt?.body_sent_ms != null) return "headers";
51
+ return details.upstream_attempts > 0 ? "send" : "local";
52
+ }
53
+
54
+ export function createFailureHistory({ file, now = Date.now } = {}) {
55
+ let buckets = new Map(), pending = new Map(), saving, cached, clock;
56
+ if (file) try { buckets = parse(readBoundedFileSync(file, options), now()); } catch { /* Optional local history is not required for startup. */ }
57
+ function flush() {
58
+ if (!file || saving || !pending.size) return saving;
59
+ const batch = pending;
60
+ pending = new Map();
61
+ saving = withFileLock(file + ".lock", async () => {
62
+ const current = now();
63
+ let disk = new Map();
64
+ try { disk = parse(await readBoundedFile(file, options), current); }
65
+ catch { /* Start a fresh bounded projection on unreadable history. */ }
66
+ for (const row of values(batch)) if (keep(current, row.hour)) put(disk, row);
67
+ await atomicWriteFile(file, JSON.stringify({ rows: values(disk) }), { mode: 0o600, preserveMode: false });
68
+ }, { timeoutMs: 1000 }).catch(() => { /* An I/O error cannot delay or fail inference. */ })
69
+ .finally(() => { saving = undefined;flush(); });
70
+ return saving;
71
+ }
72
+ return {
73
+ record(details) {
74
+ const at = now(), row = { hour: hour(at), application: APPS.has(details.application) ? details.application : "api",
75
+ model: modelName(details.model), phase: phase(details), count: 1,
76
+ last: { at, status: Number.isInteger(details.http_status) && details.http_status >= 400 ? details.http_status : null,
77
+ request_id: requestId(details.request_id), client_request_id: requestId(details.attempt_timings?.at(-1)?.client_request_id) } };
78
+ put(buckets, row);prune(buckets, at);cached = null;
79
+ if (file) { put(pending, row);prune(pending, at);flush(); }
80
+ },
81
+ snapshot() {
82
+ const at = now(), current = hour(at);
83
+ if (cached && clock === current) return cached;
84
+ prune(buckets, at);clock = current;
85
+ const groups = new Map();
86
+ for (const row of values(buckets)) {
87
+ const key = groupKey(row), previous = groups.get(key);
88
+ groups.set(key, { application: row.application, model: row.model, phase: row.phase, count: (previous?.count || 0) + row.count,
89
+ last: !previous || row.last.at >= previous.last.at ? row.last : previous.last });
90
+ }
91
+ const all = [...groups.values()].sort((a, b) => b.count - a.count || b.last.at - a.last.at);
92
+ return cached = { from: new Date(clock - (HOURS - 1) * HOUR).toISOString(),
93
+ total: all.reduce((sum, group) => sum + group.count, 0), groups: all.slice(0, 40), omitted: Math.max(0, all.length - 40) };
94
+ },
95
+ async flush() { while (flush()) await saving; },
96
+ };
97
+ }
@@ -111,7 +111,7 @@ function makeGuard(validators, maxBytes) {
111
111
  const state = pending.get(event?.index);
112
112
  if (state && event.type === "content_block_delta") {
113
113
  if (event.delta?.type !== "input_json_delta" || typeof event.delta.partial_json !== "string") throw invalidToolInput();
114
- state.parts.push(event.delta.partial_json);
114
+ if (event.delta.partial_json) state.parts.push(event.delta.partial_json);
115
115
  }
116
116
  if (state && event.type === "content_block_stop") {
117
117
  let value = state.initial, unsafe = state.unsafe;
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
 
3
- export const MODEL_PROTOCOLS = Object.freeze(["messages", "responses", "chat"]);
3
+ export const MODEL_PROTOCOLS = Object.freeze(["messages", "responses", "chat", "gemini"]);
4
4
  export const REASONING_EFFORTS = Object.freeze(["none", "minimal", "low", "medium", "high", "xhigh", "max"]);
5
5
  const limits = ["context_window", "max_input_tokens", "max_output_tokens", "reasoning_budget_min", "reasoning_budget_max", "max_tool_definitions"];
6
6
  export const MODEL_PARAMETERS = Object.freeze(["max_tokens", "max_output_tokens", "max_completion_tokens", "temperature", "top_p", "tools", "tool_choice", "parallel_tool_calls", "thinking", "output_config", "reasoning", "reasoning_effort", "response_format", "text", "stop", "stop_sequences", "stream", "stream_options"]);
@@ -71,7 +71,17 @@ function requestTexts(body, protocol) {
71
71
  for (const [key, item] of Object.entries(value)) { if (key === "description" && typeof item === "string") add(value, key, item);else if (item && typeof item === "object") descriptions(item); }
72
72
  };
73
73
  descriptions(body.tools);
74
- if (protocol === "messages" || protocol === "chat") {
74
+ if (protocol === "gemini") {
75
+ const request = body.request || {};
76
+ descriptions(request.tools);
77
+ for (const part of request.systemInstruction?.parts || []) if (typeof part?.text === "string") add(part, "text", part.text);
78
+ for (const content of request.contents || []) for (const part of content.parts || []) {
79
+ if (part?.thoughtSignature || part?.thought) continue;
80
+ if (typeof part?.text === "string") add(part, "text", part.text);
81
+ if (part?.functionCall?.args) leaves(part.functionCall.args, add, true);
82
+ if (part?.functionResponse?.response) leaves(part.functionResponse.response, add, true);
83
+ }
84
+ } else if (protocol === "messages" || protocol === "chat") {
75
85
  text(body, "system");
76
86
  for (const message of body.messages || []) {
77
87
  text(message, "content");
@@ -86,6 +96,9 @@ function requestTexts(body, protocol) {
86
96
  if (typeof body.input === "string") add(body, "input", body.input);
87
97
  else for (const item of body.input || []) {
88
98
  if (["additional_tools", "tool_search_output"].includes(item.type)) descriptions(item.tools);
99
+ else if (item.type === "mcp_list_tools" && Array.isArray(item.tools)) {
100
+ for (const tool of item.tools) if (typeof tool?.description === "string") add(tool, "description", tool.description);
101
+ }
89
102
  else if (item.type === "function_call") args(item, "arguments");
90
103
  else if (["function_call_output", "custom_tool_call_output"].includes(item.type)) text(item, "output");
91
104
  else if (item.type === "custom_tool_call") text(item, "input");
@@ -147,8 +160,13 @@ function modelSpanFits(text, start, end, label) {
147
160
  && /\b(?:function|class|const|let|var)\s+$/.test(text.slice(Math.max(0, start - 32), start))) return false;
148
161
  return true;
149
162
  }
163
+ // JSON.rawJSON values are immutable and may hold exact tool numbers.
164
+ function cloneGemini(value) {
165
+ if (!value || typeof value !== "object" || JSON.isRawJSON(value)) return value;
166
+ return Array.isArray(value) ? value.map(cloneGemini) : Object.fromEntries(Object.entries(value).map(([key, item]) => [key, cloneGemini(item)]));
167
+ }
150
168
  export async function maskPrivacyRequest(body, { protocol, client = "api", personal = false, secret, find, signal, onPlan, rules = ruleSpans, seedMappings }) {
151
- const copy = structuredClone(body), { items, nested } = requestTexts(copy, protocol), texts = items.map(item => item.text);
169
+ const copy = protocol === "gemini" ? cloneGemini(body) : structuredClone(body), { items, nested } = requestTexts(copy, protocol), texts = items.map(item => item.text);
152
170
  if (items.length > 8192 || texts.reduce((n, text) => n + Buffer.byteLength(text), 0) > 8 * 1024 * 1024) throw privacyFailure("request_too_large");
153
171
  const found = texts.length ? await find(texts, { signal, onPlan }) : [], values = new Map(seedMappings), kinds = {}, total = { count: 0, bytes: 0 };
154
172
  if (!Array.isArray(found) || found.length !== texts.length) throw privacyFailure("engine_invalid");
@@ -186,10 +204,10 @@ export async function maskPrivacyRequest(body, { protocol, client = "api", perso
186
204
  if (typeof value === "string") return restoreText(value);
187
205
  if (Array.isArray(value)) return value.map(item => restoreValue(item, inToolData));
188
206
  if (!value || typeof value !== "object" || JSON.isRawJSON(value)) return value;
189
- if (!inToolData && (value.encrypted_content || ["thinking", "redacted_thinking", "reasoning"].includes(value.type))) return value;
207
+ if (!inToolData && (value.encrypted_content || ["thinking", "redacted_thinking", "reasoning"].includes(value.type) || protocol === "gemini" && (value.thoughtSignature || value.thought))) return value;
190
208
  return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, !inToolData && kept.has(key) ? item
191
209
  : !inToolData && key === "arguments" && typeof item === "string" && item ? restoreArguments(item)
192
- : restoreValue(item, inToolData || key === "input" && ["tool_use", "server_tool_use", "mcp_tool_use"].includes(value.type))]));
210
+ : restoreValue(item, inToolData || key === "input" && ["tool_use", "server_tool_use", "mcp_tool_use"].includes(value.type) || protocol === "gemini" && key === "args")]));
193
211
  }
194
212
  function restoreArguments(text) {
195
213
  if (!text.includes(TOKEN_START) && !text.includes("\\u")) return text;
@@ -15,7 +15,7 @@ export function publicModelCatalog(models, { clients = () => [], selectable = ()
15
15
  return uniqueModelEntries(models.slice(0, 1000)).filter(model => typeof model?.id === "string").map(model => ({
16
16
  id: model.id, ...(isImageModel(model) ? { kind: "image" } : {}), display_name: modelDisplayName(model), vendor: maker(model), ...(model.owned_by ? { owned_by: model.owned_by } : {}),
17
17
  endpoints: [["responses", ["/responses", "/v1/responses"]], ["chat", ["/chat/completions", "/v1/chat/completions"]],
18
- ["messages", ["/v1/messages"]], ["images", ["/images/generations", "/v1/images/generations"]], ["image_edits", ["/images/edits", "/v1/images/edits"]]].filter(([, paths]) => paths.some(path => model.supported_endpoints?.includes(path))).map(([label]) => label),
18
+ ["messages", ["/v1/messages"]], ["gemini", ["/v1beta/models:generateContent"]], ["images", ["/images/generations", "/v1/images/generations"]], ["image_edits", ["/images/edits", "/v1/images/edits"]]].filter(([, paths]) => paths.some(path => model.supported_endpoints?.includes(path))).map(([label]) => label),
19
19
  preview: model.preview === true, selectable: selectable(model), clients: clients(model),
20
20
  reasoning_efforts: isImageModel(model) ? null : modelReasoningEfforts(model), auto_review_efforts: isImageModel(model) ? [] : model.capability ? modelReasoningEfforts(model) || [] : autoReviewReasoningEfforts(model),
21
21
  context_window: model.capability?.values.context_window ?? (Number.isSafeInteger(model.capabilities?.limits?.max_context_window_tokens)
@@ -9,10 +9,11 @@ import { privateHelperEnvironment } from "../private-helper-environment.mjs";
9
9
  import { transportErrorDetails } from "../operation-error.mjs";
10
10
  import { apiTargetAllowed } from "../api-target.mjs";
11
11
 
12
- export async function createApiNetwork({ targets, env = process.env, platform = process.platform, signal,
12
+ export async function createApiNetwork({ targets, geminiModelsUrl, env = process.env, platform = process.platform, signal,
13
13
  requestImpl = https.request, exec = promisify(execFile), startWindowsNetwork } = {}) {
14
14
  const urls = new Set(targets.map(raw => new URL(apiUrl(raw)).href));if (!urls.size || urls.size > 8) throw accessError("ccdx_api_url_invalid");
15
15
  const first = new URL([...urls][0]);
16
+ if (geminiModelsUrl && !urls.has(new URL(apiUrl(geminiModelsUrl)).href)) throw accessError("ccdx_api_url_invalid");
16
17
  let plan = resolveNetworkRoute({ env, checkApi: false }), worker;
17
18
  if (!networkProxyFor(first, plan) && !bypassNetworkProxy(first.hostname, first.port || 443, plan)) {
18
19
  if (platform === "darwin") {
@@ -20,7 +21,7 @@ export async function createApiNetwork({ targets, env = process.env, platform =
20
21
  plan = resolveNetworkRoute({ env, systemProxy: stdout, checkApi: false });
21
22
  } else if (platform === "win32") {
22
23
  const start = startWindowsNetwork || (await import("../windows-http-network.mjs")).startWindowsHttpNetwork;
23
- worker = await start({ target: "api", apiTargets: [...urls], env: privateHelperEnvironment(env), signal, timeoutMs: 120000 });
24
+ worker = await start({ target: "api", apiTargets: [...urls], geminiModelsUrl, env: privateHelperEnvironment(env), signal, timeoutMs: 120000 });
24
25
  requestImpl = worker.requestImpl;
25
26
  }
26
27
  }
@@ -31,7 +32,7 @@ export async function createApiNetwork({ targets, env = process.env, platform =
31
32
  fetch(raw, init = {}) {
32
33
  return new Promise((resolve, reject) => {
33
34
  let url;try { url = new URL(raw); } catch { reject(accessError("ccdx_api_url_invalid"));return; }
34
- if (closed || retiring || !apiTargetAllowed(url.href, [...urls], init.method || "GET") || !["GET", "POST"].includes(init.method || "GET")) { reject(accessError("ccdx_api_url_invalid"));return; }
35
+ if (closed || retiring || !apiTargetAllowed(url.href, [...urls], init.method || "GET", geminiModelsUrl) || !["GET", "POST"].includes(init.method || "GET")) { reject(accessError("ccdx_api_url_invalid"));return; }
35
36
  if (init.signal?.aborted) { reject(init.signal.reason);return; }
36
37
  active++;
37
38
  let req, incoming, socket, phase = "request", handedOff = false, released = false;