codex-copilot-dx 1.4.11 → 1.4.13
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 +3 -3
- package/bin/cli.mjs +2 -0
- package/docs/ARCHITECTURE.md +6 -0
- package/docs/REFERENCE.md +21 -10
- package/package.json +1 -1
- package/src/access-settings.mjs +4 -1
- package/src/adapter.mjs +14 -5
- package/src/antigravity-chat-bridge.mjs +38 -8
- package/src/antigravity-handler.mjs +141 -26
- package/src/antigravity-models.mjs +3 -2
- package/src/antigravity-runtime.mjs +129 -36
- package/src/antigravity-usage.mjs +3 -3
- package/src/api-target.mjs +12 -1
- package/src/application-configuration.mjs +2 -1
- package/src/application-control.mjs +6 -3
- package/src/cli-command-spec.mjs +1 -1
- package/src/cli-management.mjs +9 -4
- package/src/connection-management.mjs +6 -2
- package/src/connection-policy.mjs +3 -3
- package/src/connection-routing.mjs +37 -10
- package/src/connection-runtime.mjs +4 -0
- package/src/connection-view.mjs +12 -0
- package/src/context-compaction-wire.mjs +6 -6
- package/src/copilot-client.mjs +3 -2
- package/src/copilot.mjs +13 -2
- package/src/dashboard/connections.js +18 -8
- package/src/dashboard/console.js +9 -4
- package/src/dashboard/context.js +15 -5
- package/src/dashboard/features.js +2 -2
- package/src/dashboard/flow.js +1 -0
- package/src/dashboard/gemini.js +40 -10
- package/src/dashboard/index.html +47 -40
- package/src/dashboard/language.js +44 -16
- package/src/dashboard/status.js +35 -30
- package/src/dashboard/tool-activity-machines.js +362 -0
- package/src/dashboard/tool-activity.js +24 -115
- package/src/dashboard/tools.js +3 -4
- package/src/dashboard/ui.css +44 -14
- package/src/dashboard/ui.js +14 -0
- package/src/dashboard/usage.js +9 -1
- package/src/dashboard.mjs +1 -0
- package/src/failure-history.mjs +97 -0
- package/src/model-capabilities.mjs +1 -1
- package/src/privacy-transform.mjs +22 -4
- package/src/provider-metadata.mjs +1 -1
- package/src/providers/api-network.mjs +4 -3
- package/src/providers/api.mjs +79 -15
- package/src/response-failures.mjs +10 -4
- package/src/runtime-config.mjs +1 -0
- package/src/safe-upstream-error.mjs +2 -2
- package/src/source-admission.mjs +1 -1
- package/src/stream-performance.mjs +1 -1
- package/src/terminal-state.mjs +8 -2
- package/src/windows-http-network.mjs +4 -3
- package/src/windows-prediction-network.cs +11 -0
|
@@ -1,14 +1,16 @@
|
|
|
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(["
|
|
4
|
+
const styles = new Set(["assembly", "sorter", "gantry", "rotary", "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: "assembly"
|
|
8
|
+
const state = { scene: "idle", style: "assembly" };
|
|
9
|
+
const drawMachine = ctx && globalThis.ccdxToolMachines(ctx);
|
|
9
10
|
try { const saved = localStorage.getItem(storageKey);if (styles.has(saved)) state.style = saved; } catch {}
|
|
10
11
|
const motion = globalThis.matchMedia?.("(prefers-reduced-motion: reduce)") || { matches: false, addEventListener() {} };
|
|
11
12
|
let records = [], fresh = false, supported = false, visible = true, raf = 0, last = 0, start = performance.now(), expiry = null;
|
|
13
|
+
let drawnTime = null;
|
|
12
14
|
let signature = "", box = { width: 0, height: 0 }, color = "", surface = "", omitted = 0, requests = [], requestDeadline = 0;
|
|
13
15
|
const animating = () => ["calling", "parallel", "waiting", "processing", "responding"].includes(state.scene);
|
|
14
16
|
const shown = () => document.visibilityState === "visible" && !root.closest("[hidden]") && visible;
|
|
@@ -18,120 +20,27 @@
|
|
|
18
20
|
color = theme.getPropertyValue("--accent").trim();surface = theme.getPropertyValue("--surface").trim();
|
|
19
21
|
refreshAnimation();
|
|
20
22
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
phase<.34?29+103*phase/.34:phase<.66?132:132+91*(phase-.66)/.34;
|
|
30
|
-
const moving=running&&(phase<.34||phase>=.66)||returned;
|
|
31
|
-
const shift=moving?(reduced?0:t*78)%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;
|
|
23
|
+
function draw(now = performance.now()) {
|
|
24
|
+
if (!drawMachine || !box.width || !box.height) return;
|
|
25
|
+
const dpr = Math.min(devicePixelRatio || 1, 1.5), width = box.width, height = box.height;
|
|
26
|
+
const w = Math.round(width * dpr), h = Math.round(height * dpr);
|
|
27
|
+
if (canvas.width !== w || canvas.height !== h) { canvas.width = w;canvas.height = h; }
|
|
28
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);ctx.clearRect(0, 0, w, h);
|
|
29
|
+
if (animating() && !motion.matches) drawnTime = (now - start) / 1000;
|
|
30
|
+
drawMachine(state.style, { time: drawnTime ?? 0, running: drawnTime !== null, reduced: motion.matches, width, height, dpr, ink: color, surface });
|
|
76
31
|
}
|
|
77
|
-
function draw(now=performance.now()){
|
|
78
|
-
if(!ctx||!box.width||!box.height)return;
|
|
79
|
-
const dpr=Math.min(devicePixelRatio||1,1.5),w=box.width,h=box.height;
|
|
80
|
-
if(canvas.width!==Math.round(w*dpr)||canvas.height!==Math.round(h*dpr)){canvas.width=Math.round(w*dpr);canvas.height=Math.round(h*dpr);}
|
|
81
|
-
ctx.setTransform(dpr,0,0,dpr,0,0);ctx.clearRect(0,0,w,h);
|
|
82
|
-
const cx=w/2,cy=h/2,r=Math.min(w,h)*.31;
|
|
83
|
-
const reduced=motion.matches||state.reduce,t=reduced?0:(now-start)/1000,active=['calling','parallel','processing','responding'].includes(state.scene),waiting=state.scene==='waiting',returned=state.scene==='returned';
|
|
84
|
-
const quiet=!active&&!waiting&&!returned,power=quiet?.12:waiting?.5:returned?.5:state.intensity;
|
|
85
|
-
ctx.strokeStyle=color;ctx.fillStyle=color;ctx.lineWidth=.8;
|
|
86
|
-
function arc(radius,a,b,alpha){ctx.globalAlpha=alpha;ctx.beginPath();ctx.arc(cx,cy,radius,a,b);ctx.stroke();}
|
|
87
|
-
if(state.style==='grid'){
|
|
88
|
-
const cols=12,rows=3,gap=5,size=Math.min(13,(w-32)/cols-gap),left=cx-(cols*size+(cols-1)*gap)/2,top=cy-(rows*size+(rows-1)*gap)/2;
|
|
89
|
-
const head=active||waiting?(t*(waiting?11:19))%(cols*rows):-8;
|
|
90
|
-
for(let row=0;row<rows;row++)for(let col=0;col<cols;col++){
|
|
91
|
-
const index=row*cols+(row%2?cols-col-1:col),distance=(head-index+cols*rows)%(cols*rows),wave=Math.max(0,1-distance/8);
|
|
92
|
-
ctx.globalAlpha=quiet?.1:returned?.16+Math.max(0,1-(now-start)/900)*.42:.1+wave*power;
|
|
93
|
-
ctx.fillRect(left+col*(size+gap),top+row*(size+gap),size,size);
|
|
94
|
-
}
|
|
95
|
-
ctx.globalAlpha=1;return;
|
|
96
|
-
}
|
|
97
|
-
if(state.style==='assembly'){
|
|
98
|
-
drawAssembly(dpr,w,h,t,active,waiting,returned,reduced);return;
|
|
99
|
-
}
|
|
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);
|
|
101
|
-
const spin=active?t*1.6:waiting?t*.9:0;
|
|
102
|
-
if(state.style==='halo'){
|
|
103
|
-
for(let i=0;i<64;i++){
|
|
104
|
-
const a=i/64*Math.PI*2+spin,pulse=active||waiting?(Math.sin(t*7+i*.7)*.5+.5):returned?.6:.05;
|
|
105
|
-
const length=3+(i%4===0?8:3)+pulse*(active?20:waiting?9:2)*state.intensity;
|
|
106
|
-
ctx.globalAlpha=(.16+pulse*.55)*power;ctx.lineWidth=i%8===0?1.4:.75;
|
|
107
|
-
ctx.beginPath();ctx.moveTo(cx+Math.cos(a)*r*1.17,cy+Math.sin(a)*r*1.17);ctx.lineTo(cx+Math.cos(a)*(r*1.17+length),cy+Math.sin(a)*(r*1.17+length));ctx.stroke();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if(state.style==='halo'){
|
|
111
|
-
ctx.lineWidth=.65;const strands=28;
|
|
112
|
-
for(let i=0;i<strands;i++){
|
|
113
|
-
const a=i/strands*Math.PI*2+spin*.6,b=a+2.35+Math.sin(i*.68+t*1.7)*.48,inner=r*.68;
|
|
114
|
-
ctx.globalAlpha=(.1+power*.2)*(quiet?.45:1);ctx.beginPath();ctx.moveTo(cx+Math.cos(a)*inner,cy+Math.sin(a)*inner);ctx.quadraticCurveTo(cx+Math.sin(t*1.3+i)*r*.35,cy+Math.cos(i*.5+t*.7)*r*.3,cx+Math.cos(b)*inner,cy+Math.sin(b)*inner);ctx.stroke();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
for(let i=0;i<3;i++){
|
|
118
|
-
const a=spin*(i%2?-1:1)+i*2.08,track=r*(.89+i*.06);
|
|
119
|
-
ctx.lineWidth=1.3;arc(track,a,a+(active?1.25:waiting?.75:.18),quiet?.15:.75);
|
|
120
|
-
}
|
|
121
|
-
if(active||waiting){for(let i=0;i<3;i++){const q=(t*.85+i/3)%1;arc(r*(.55+q*.5),0,Math.PI*2,(1-q)*.12*power);}}
|
|
122
|
-
if(returned&&!reduced){const q=Math.min((now-start)/850,1);arc(r*(1+q*.32),0,Math.PI*2,(1-q)*.5);}
|
|
123
|
-
ctx.globalAlpha=1;
|
|
124
|
-
}
|
|
125
32
|
|
|
126
33
|
function animate(now) {
|
|
127
34
|
raf = 0;
|
|
128
|
-
if (!shown() || motion.matches || state.style === "off" || !animating()
|
|
129
|
-
if (now - last >= 1000 / 30) { last = now;draw(now); }
|
|
35
|
+
if (!shown() || motion.matches || state.style === "off" || !animating()) return;
|
|
36
|
+
if (now - last >= 1000 / 30) { last = now;draw(now); }
|
|
37
|
+
raf = requestAnimationFrame(animate);
|
|
130
38
|
}
|
|
131
39
|
function refreshAnimation() {
|
|
132
|
-
cancelAnimationFrame(raf);raf = 0;
|
|
40
|
+
cancelAnimationFrame(raf);raf = 0;
|
|
41
|
+
root.dataset.paused = String(!shown() || motion.matches || !animating() || state.style === "off");
|
|
133
42
|
if (!shown() || state.style === "off") return;
|
|
134
|
-
draw();if (!motion.matches &&
|
|
43
|
+
draw();if (!motion.matches && animating()) raf = requestAnimationFrame(animate);
|
|
135
44
|
}
|
|
136
45
|
function category(name) {
|
|
137
46
|
const value = String(name || "").toLowerCase().split(/__|\./).at(-1);
|
|
@@ -163,7 +72,8 @@
|
|
|
163
72
|
const scene = !fresh ? "idle" : active.length ? preparing ? active.length > 1 ? "parallel" : "calling" : "waiting"
|
|
164
73
|
: agents.length ? responding ? "responding" : "processing"
|
|
165
74
|
: rows.some(row => row.state === "returned") && !rows.some(row => ["failed", "cancelled", "unknown"].includes(row.state)) ? "returned" : "idle";
|
|
166
|
-
|
|
75
|
+
const wasAnimating = animating();state.scene = scene;
|
|
76
|
+
if (animating() && !wasAnimating) { start = performance.now();drawnTime = null; }
|
|
167
77
|
const key = !supported || !fresh ? "flow_status_unknown" : active.length ? preparing ? active.length > 1 ? "tool_preparing_many" : "tool_preparing" : "tool_waiting"
|
|
168
78
|
: agents.length ? agents.length > 1 ? "tool_requests_many" : responding ? "tool_responding" : "tool_processing"
|
|
169
79
|
: rows.some(row => row.state === "failed") ? "tool_failed" : rows.some(row => row.state === "cancelled") ? "tool_cancelled"
|
|
@@ -189,11 +99,10 @@
|
|
|
189
99
|
el("tool-details").hidden = !rows.length;
|
|
190
100
|
el("tool-technical").replaceChildren();
|
|
191
101
|
for (const row of rows) {
|
|
192
|
-
const line = document.createElement("
|
|
193
|
-
for (const
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
term.textContent = phrase(label);detail.textContent = value;line.append(term, detail);
|
|
102
|
+
const line = document.createElement("tr");
|
|
103
|
+
for (const value of [appName(row.application), sourceName(row.provider), row.model,
|
|
104
|
+
row.name || phrase("tool_action_generic"), phrase(`tool_row_${row.state}`)]) {
|
|
105
|
+
const cell = document.createElement("td");cell.textContent = value;line.append(cell);
|
|
197
106
|
}
|
|
198
107
|
el("tool-technical").append(line);
|
|
199
108
|
}
|
package/src/dashboard/tools.js
CHANGED
|
@@ -132,9 +132,9 @@
|
|
|
132
132
|
el("github-check").addEventListener("click", () => void accountAction({ action: "check" }));
|
|
133
133
|
el("github-cancel").addEventListener("click", () => { if (account?.operation) void accountAction({ action: "cancel", id: account.operation.id }); });
|
|
134
134
|
el("github-copy-code").addEventListener("click", () => void copyCode());
|
|
135
|
-
el("github-authorize").addEventListener("click", event => { if (pending || !userCode())
|
|
135
|
+
el("github-authorize").addEventListener("click", event => { if (pending || !userCode()) event.preventDefault(); });
|
|
136
136
|
window.addEventListener("pagehide", finishCodeCopy);
|
|
137
|
-
el("github-logout").addEventListener("click", () => { if (
|
|
137
|
+
el("github-logout").addEventListener("click", async () => { if (await globalThis.ccdxConfirmAction("tools_logout", "tools_logout_confirm")) void accountAction({ action: "logout", confirmed: true }); });
|
|
138
138
|
async function loadAccount() { const generation = accountGeneration;try { const data = await api("account");if (generation === accountGeneration && !pending) renderAccount(data); } catch { if (generation === accountGeneration) text("github-account-note", "tools_read_failed"); } }
|
|
139
139
|
function renderChecks(data) {
|
|
140
140
|
if (Object.hasOwn(data, "client_versions")) globalThis.ccdxClientVersions?.render(data.client_versions);
|
|
@@ -184,10 +184,9 @@
|
|
|
184
184
|
for (const [id, action] of [["check-local", "check"], ["check-network", "network"], ["export-report", "report"], ["preview-config-repair", "preview"]]) {
|
|
185
185
|
el(id).addEventListener("click", () => void localAction({ action }, el(id)));
|
|
186
186
|
}
|
|
187
|
-
el("check-compatibility")?.addEventListener("click", () => { if (
|
|
187
|
+
el("check-compatibility")?.addEventListener("click", async () => { if (await globalThis.ccdxConfirmAction("compatibility_test", "compatibility_scope")) void localAction({ action: "compatibility", confirmed: true }, el("check-compatibility")); });
|
|
188
188
|
el("apply-config-repair").addEventListener("click", () => { if (repairPreview) void localAction({ action: "repair", revision: repairPreview.revision }, el("apply-config-repair")); });
|
|
189
189
|
el("cancel-config-repair").addEventListener("click", () => { repairPreview = null;el("config-repair-preview").hidden = true; });
|
|
190
|
-
el("check-account-link").addEventListener("click", () => { chooseProvider("github");location.hash = "models"; });
|
|
191
190
|
async function navigate() {
|
|
192
191
|
syncSource();
|
|
193
192
|
if (location.hash === "#models") await loadAccount();
|
package/src/dashboard/ui.css
CHANGED
|
@@ -489,7 +489,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
489
489
|
.checks-table th:first-child { width:23%; }
|
|
490
490
|
.checks-table th:nth-child(2) { width:21%; }
|
|
491
491
|
.checks-table details p { margin:8px 0; }
|
|
492
|
-
@media(max-width:640px) { .account-fields { grid-template-columns:100px minmax(0,1fr); gap:10px; }
|
|
492
|
+
@media(max-width:640px) { .account-fields { grid-template-columns:100px minmax(0,1fr); gap:10px; } }
|
|
493
493
|
|
|
494
494
|
.account-summary { margin: 20px 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 20px; }
|
|
495
495
|
.account-summary div { min-width: 0; }
|
|
@@ -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-
|
|
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:
|
|
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(
|
|
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; }
|
|
@@ -657,7 +666,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
657
666
|
.context-tabs { display:flex;gap:8px;margin-bottom:18px; }
|
|
658
667
|
.context-tabs button { min-width:80px;text-align:center; }
|
|
659
668
|
.context-tabs button[aria-selected="true"], .context-session[aria-pressed="true"] { color:var(--surface);background:var(--accent);border-color:var(--accent); }
|
|
660
|
-
.context-sessions { table-layout:fixed;
|
|
669
|
+
.context-sessions { table-layout:fixed; }
|
|
661
670
|
.context-sessions th:first-child { width:27%; }
|
|
662
671
|
.context-sessions th:nth-child(2) { width:23%; }
|
|
663
672
|
.context-sessions th:nth-child(3) { width:32%; }
|
|
@@ -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:
|
|
670
|
-
.context-history-chart svg { width:100%;height:
|
|
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,11 +693,10 @@ 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:
|
|
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%; }
|
|
691
|
-
.tool-stage[data-style="grid"] .tool-orbit { max-height:140px; }
|
|
692
700
|
.tool-stage[data-style="off"] { grid-template-columns:1fr;min-height:110px; }
|
|
693
701
|
.tool-stage[data-style="off"] .tool-orbit { display:none; }
|
|
694
702
|
.tool-stage[data-style="off"] .tool-narration { text-align:left; }
|
|
@@ -706,7 +714,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
706
714
|
#tool-cursor { display:inline-block;animation:tool-cursor 1s steps(1) infinite; }
|
|
707
715
|
#tool-activity[data-paused="true"] #tool-cursor { animation:none; }
|
|
708
716
|
@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; } }
|
|
717
|
+
@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
718
|
@media(prefers-reduced-motion:reduce) { #tool-cursor { animation:none; } }
|
|
711
719
|
|
|
712
720
|
/* Compact request statistics in the existing diagnostics panel. */
|
|
@@ -734,3 +742,25 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
734
742
|
[data-view="system"] .setting-row { gap: 10px; padding-block: 8px; }
|
|
735
743
|
[data-view="overview"] .card { min-height: 0; padding-block: 12px; }
|
|
736
744
|
[data-view="overview"] .card strong { margin-top: 6px; }
|
|
745
|
+
|
|
746
|
+
/* Fit long identifiers without widening the dashboard. */
|
|
747
|
+
.dense-table { table-layout: fixed; }
|
|
748
|
+
.dense-table :is(th,td) { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
|
|
749
|
+
.usage-table th:first-child { width: 26%; }
|
|
750
|
+
.failure-table th:last-child { width: 38%; }
|
|
751
|
+
.failure-table td :is(dt,dd) { overflow-wrap: anywhere; }
|
|
752
|
+
.failure-table details > :is(dl,p) { contain: none; }
|
|
753
|
+
.failure-table .failure-detail { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
|
|
754
|
+
.usage-row-details { display: none; margin-block-start: 4px; }
|
|
755
|
+
.usage-row-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px; margin: 6px 0; }
|
|
756
|
+
.usage-row-stats dt { color: var(--muted); }
|
|
757
|
+
.usage-row-stats dd { margin: 0; }
|
|
758
|
+
@media (max-width: 700px) {
|
|
759
|
+
.usage-table :is(th,td):not(:first-child):not(:nth-child(7)):not([colspan]) { display: none; }
|
|
760
|
+
.usage-table th:first-child { width: 70%; }
|
|
761
|
+
.usage-row-details { display: block; }
|
|
762
|
+
.recent-requests-table :is(th,td):is(:nth-child(1),:nth-child(2),:nth-child(5)):not([colspan]) { display: none; }
|
|
763
|
+
.recent-requests-table th:nth-child(3) { width: 40%; }
|
|
764
|
+
.failure-table th:last-child { width: 40%; }
|
|
765
|
+
}
|
|
766
|
+
#action-confirm-apply { background:var(--accent); color:var(--page); border-color:var(--accent); }
|
package/src/dashboard/ui.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
const element = (id) => document.getElementById(id);
|
|
2
|
+
globalThis.ccdxConfirmAction = (title, detail) => {
|
|
3
|
+
const dialog = element("action-confirm");
|
|
4
|
+
if (!dialog?.showModal) return Promise.resolve(window.confirm(globalThis.ccdxLanguage?.format(detail) || english(detail)));
|
|
5
|
+
if (dialog.open) return Promise.resolve(false);
|
|
6
|
+
localize(element("action-confirm-title"), title);
|
|
7
|
+
localize(element("action-confirm-detail"), detail);
|
|
8
|
+
localize(element("action-confirm-apply"), title);
|
|
9
|
+
dialog.returnValue = "";
|
|
10
|
+
return new Promise(resolve => {
|
|
11
|
+
dialog.addEventListener("close", () => resolve(dialog.returnValue === "confirm"), { once: true });
|
|
12
|
+
dialog.showModal();
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
|
|
2
16
|
const phrase = (key, values = {}) => ({ key, values });
|
|
3
17
|
const english = (key, values = {}) => String(key).replace(/\{(\w+)\}/g, (match, name) => {
|
|
4
18
|
if (!Object.hasOwn(values, name)) return match;
|
package/src/dashboard/usage.js
CHANGED
|
@@ -112,7 +112,15 @@
|
|
|
112
112
|
body.replaceChildren();
|
|
113
113
|
if (total.requests > 0) {
|
|
114
114
|
for (const [index, row] of [total, ...rows].entries()) {
|
|
115
|
-
const
|
|
115
|
+
const values = usageValues(row), entry = tableRow(values, { total: index === 0 });
|
|
116
|
+
const mobile = document.createElement("details"), summary = document.createElement("summary"), stats = document.createElement("dl");
|
|
117
|
+
mobile.className = "usage-row-details";stats.className = "usage-row-stats";
|
|
118
|
+
localize(summary, "tools_details");
|
|
119
|
+
for (const [column, key] of [[1, "usage_records"], [2, "input"], [3, "cache_read"], [4, "cache_write"], [5, "output"], [7, "cache_hit"]]) {
|
|
120
|
+
const field = document.createElement("div"), name = document.createElement("dt"), value = document.createElement("dd");
|
|
121
|
+
localize(name, key);value.textContent = values[column];field.append(name, value);stats.append(field);
|
|
122
|
+
}
|
|
123
|
+
mobile.append(summary, stats);entry.children[0].append(mobile);
|
|
116
124
|
localize(entry.children[7], "usage_cache_coverage", { known: number(row.cache_hit_known_requests), unknown: number(row.cache_hit_unknown_requests) }, "title");body.append(entry);
|
|
117
125
|
}
|
|
118
126
|
} else { emptyTable("usage-body", 8, usageData.filters ? "usage_empty_selection" : "no_usage_records"); }
|
package/src/dashboard.mjs
CHANGED
|
@@ -17,6 +17,7 @@ const ASSETS = new Map([
|
|
|
17
17
|
["/status.js", ["./dashboard/status.js", "text/javascript; charset=utf-8"]],
|
|
18
18
|
["/activity.js", ["./dashboard/activity.js", "text/javascript; charset=utf-8"]],
|
|
19
19
|
["/flow.js", ["./dashboard/flow.js", "text/javascript; charset=utf-8"]],
|
|
20
|
+
["/tool-activity-machines.js", ["./dashboard/tool-activity-machines.js", "text/javascript; charset=utf-8"]],
|
|
20
21
|
["/tool-activity.js", ["./dashboard/tool-activity.js", "text/javascript; charset=utf-8"]],
|
|
21
22
|
["/usage.js", ["./dashboard/usage.js", "text/javascript; charset=utf-8"]],
|
|
22
23
|
["/context.js", ["./dashboard/context.js", "text/javascript; charset=utf-8"]],
|
|
@@ -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
|
+
}
|
|
@@ -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 === "
|
|
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;
|