codex-copilot-dx 1.2.21 → 1.2.23
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 +7 -7
- package/bin/cli.mjs +77 -14
- package/docs/ARCHITECTURE.md +94 -3
- package/docs/REFERENCE.md +142 -6
- package/package.json +2 -1
- package/src/account-tools.mjs +1 -1
- package/src/adapter.mjs +23 -6
- package/src/api-catalog-refresh.mjs +6 -2
- package/src/api-secrets.mjs +28 -9
- package/src/auth.mjs +2 -0
- package/src/bounded-result-cache.mjs +12 -0
- package/src/claude-gateway.mjs +19 -3
- package/src/cli-status.mjs +2 -2
- package/src/client-gateway-keys.mjs +7 -3
- package/src/client-integration.mjs +3 -0
- package/src/connection-runtime.mjs +25 -6
- package/src/conversation-source-guard.mjs +3 -1
- package/src/dashboard/console.js +12 -2
- package/src/dashboard/flow.js +62 -33
- package/src/dashboard/index.html +8 -0
- package/src/dashboard/language.js +47 -0
- package/src/dashboard/status.js +29 -8
- package/src/dashboard/ui.css +18 -2
- package/src/dashboard/ui.js +4 -4
- package/src/dashboard/view-boundary.js +41 -0
- package/src/dashboard-tools.mjs +1 -0
- package/src/dashboard.mjs +26 -5
- package/src/image-mcp.mjs +3 -0
- package/src/image-references.mjs +9 -0
- package/src/local-tools.mjs +1 -1
- package/src/m365-settings.mjs +5 -0
- package/src/nightly-update.mjs +107 -0
- package/src/optional-routes.mjs +19 -5
- package/src/provider-runtime.mjs +3 -2
- package/src/providers/api-token-count.mjs +61 -0
- package/src/providers/api.mjs +17 -7
- package/src/release-install.mjs +24 -12
- package/src/request-context.mjs +8 -0
- package/src/response-failures.mjs +25 -5
- package/src/response-history.mjs +50 -0
- package/src/responses-handler.mjs +3 -0
- package/src/service-control.mjs +9 -3
- package/src/service-supervisor.mjs +168 -0
- package/src/service-worker.mjs +87 -0
- package/src/stream-performance.mjs +3 -1
- package/src/terminal-console.mjs +1 -0
- package/src/user-settings.mjs +15 -0
package/src/dashboard/flow.js
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
const label = (node, key, values = {}) => globalThis.ccdxLanguage.set(node, key, values);
|
|
7
7
|
const format = (key, values = {}) => globalThis.ccdxLanguage.format(key, values);
|
|
8
8
|
const nodes = { apps: new Map(), models: new Map() };
|
|
9
|
+
const detailRows = new Map();
|
|
9
10
|
let rows = [], total = null, omitted = 0, fresh = false, deadline = 0, expiry = null;
|
|
10
|
-
let selected = null, expanded = false, lastSignature = "", geometry = "", known = false;
|
|
11
|
+
let selected = null, expanded = false, lastSignature = "", geometry = "", wireState = "", positions = null, known = false;
|
|
11
12
|
let lastApps = [], lastModels = [];
|
|
13
|
+
const resize = new ResizeObserver(() => { positions = null;draw(); });
|
|
12
14
|
const visible = () => document.visibilityState === "visible" && !root.closest("[hidden]");
|
|
13
15
|
const integer = value => Number.isSafeInteger(value) && value >= 0;
|
|
14
16
|
const appName = id => format(`flow_app_${id}`);
|
|
@@ -27,6 +29,11 @@
|
|
|
27
29
|
function svg(tag, values) { const node = document.createElementNS(ns, tag);for (const [key, value] of Object.entries(values)) node.setAttribute(key, value);return node; }
|
|
28
30
|
const logo = el("status-icon")?.cloneNode(true);
|
|
29
31
|
if (logo) { logo.removeAttribute("id");logo.setAttribute("class", "flow-logo");el("flow-hub").prepend(logo); }
|
|
32
|
+
const halo = svg("svg", { class: "flow-halo", viewBox: "0 0 60 60", "aria-hidden": "true" });
|
|
33
|
+
halo.append(svg("circle", { class: "flow-halo-track", cx: 30, cy: 30, r: 28 }));
|
|
34
|
+
const orbit = svg("svg", { class: "flow-halo flow-halo-turn", viewBox: "0 0 60 60", "aria-hidden": "true" });
|
|
35
|
+
orbit.append(svg("circle", { cx: 30, cy: 30, r: 28 }));
|
|
36
|
+
el("flow-hub").append(halo, orbit);
|
|
30
37
|
|
|
31
38
|
function group(type) {
|
|
32
39
|
const map = new Map();
|
|
@@ -41,7 +48,7 @@
|
|
|
41
48
|
function project(type, groups) {
|
|
42
49
|
const target = el(type === "apps" ? "flow-apps" : "flow-models"), cache = nodes[type], fragments = [];
|
|
43
50
|
const ids = new Set(groups.map(group => group.id));
|
|
44
|
-
for (const [id, node] of cache) if (!ids.has(id)) { node.remove();cache.delete(id); }
|
|
51
|
+
for (const [id, node] of cache) if (!ids.has(id)) { resize.unobserve?.(node);node.remove();cache.delete(id);positions = null; }
|
|
45
52
|
for (const group of groups) {
|
|
46
53
|
let node = cache.get(group.id);
|
|
47
54
|
if (!node) {
|
|
@@ -53,15 +60,16 @@
|
|
|
53
60
|
});
|
|
54
61
|
node.append(button, count, note);
|
|
55
62
|
if (type === "models") node.append(entry("span", "flow-source"));
|
|
56
|
-
cache.set(group.id, node);
|
|
63
|
+
cache.set(group.id, node);resize.observe(node);positions = null;
|
|
57
64
|
}
|
|
58
65
|
const [button, count, note] = node.children;
|
|
59
|
-
|
|
66
|
+
const title = type === "apps" ? appName(group.id) : modelName(group.model);
|
|
67
|
+
if (button.textContent !== title) { button.textContent = title;positions = null; }
|
|
60
68
|
button.setAttribute("aria-pressed", String(selected?.type === type && selected.id === group.id));
|
|
61
69
|
count.hidden = fresh && omitted === 0 && group.rows.length < 2;
|
|
62
70
|
if (fresh && (group.rows.length || total === 0)) label(count, omitted ? "flow_count_lower" : "flow_count", { count: group.rows.length.toLocaleString() });
|
|
63
71
|
else count.textContent = "—";
|
|
64
|
-
if (type === "models") node.children[3].textContent = sourceName(group.provider);
|
|
72
|
+
if (type === "models" && node.children[3].textContent !== sourceName(group.provider)) { node.children[3].textContent = sourceName(group.provider);positions = null; }
|
|
65
73
|
const output = group.rows.filter(responding).length;
|
|
66
74
|
const phase = group.rows.every(row => row.terminal_outcome) ? "flow_finishing"
|
|
67
75
|
: group.rows.every(row => row.upstream_attempts > 1) ? "flow_retrying" : "flow_waiting";
|
|
@@ -71,19 +79,23 @@
|
|
|
71
79
|
// Keep existing buttons and their focus when counts or phases change.
|
|
72
80
|
const wanted = new Set(fragments);
|
|
73
81
|
for (const node of [...target.children]) if (!wanted.has(node)) node.remove();
|
|
74
|
-
fragments.forEach((node, index) => { if (target.children[index] !== node) target.insertBefore(node, target.children[index] || null); });
|
|
82
|
+
fragments.forEach((node, index) => { if (target.children[index] !== node) { target.insertBefore(node, target.children[index] || null);positions = null; } });
|
|
75
83
|
}
|
|
76
84
|
function details() {
|
|
77
85
|
label(el("flow-active-title"), fresh ? "flow_active_count" : "flow_last_count", { count: rows.filter(related).length });
|
|
78
86
|
if (!el("flow-active").open) return;
|
|
79
|
-
const body = el("flow-active-body"), records = rows.filter(related)
|
|
80
|
-
for (const row of records) {
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
87
|
+
const body = el("flow-active-body"), records = rows.filter(related), wanted = new Set();
|
|
88
|
+
for (const [index, row] of records.entries()) {
|
|
89
|
+
const id = row.request_id || JSON.stringify([row.application, row.provider, row.model, index]);wanted.add(id);
|
|
90
|
+
let tr = detailRows.get(id);
|
|
91
|
+
if (!tr) { tr = entry("tr");for (let i = 0; i < 6; i++) tr.append(entry("td"));detailRows.set(id, tr); }
|
|
92
|
+
const values = [appName(row.application), sourceName(row.provider), modelName(row.model), format(fresh ? status(row) : "flow_last_observed"), `${(row.elapsed_ms / 1000).toFixed(1)} s`, row.upstream_attempts.toLocaleString()];
|
|
93
|
+
values.forEach((value, i) => { if (tr.children[i].textContent !== value) tr.children[i].textContent = value; });
|
|
94
|
+
if (body.children[index] !== tr) body.insertBefore(tr, body.children[index] || null);
|
|
86
95
|
}
|
|
96
|
+
for (const [id, tr] of detailRows) if (!wanted.has(id)) { tr.remove();detailRows.delete(id); }
|
|
97
|
+
const kept = new Set(detailRows.values());
|
|
98
|
+
for (const tr of [...body.children]) if (!kept.has(tr)) tr.remove();
|
|
87
99
|
if (!records.length) { const tr = entry("tr"), td = entry("td");td.colSpan = 6;label(td, known ? "flow_no_active" : "flow_status_unknown");tr.append(td);body.append(tr); }
|
|
88
100
|
}
|
|
89
101
|
function render() {
|
|
@@ -109,7 +121,7 @@
|
|
|
109
121
|
label(el("flow-more"), expanded ? "flow_fewer_models" : "flow_more_models", { count: Math.max(0, models.length - 12) });
|
|
110
122
|
project("apps", shownApps);
|
|
111
123
|
project("models", expanded ? models : models.slice(0, 12));
|
|
112
|
-
|
|
124
|
+
draw();
|
|
113
125
|
}
|
|
114
126
|
function rounded(x0, y0, x1, y1) {
|
|
115
127
|
if (Math.abs(y1 - y0) < 2) return `M${x0} ${y0}H${x1}`;
|
|
@@ -118,25 +130,42 @@
|
|
|
118
130
|
}
|
|
119
131
|
function draw() {
|
|
120
132
|
if (!visible()) return;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
if (!positions) {
|
|
134
|
+
const network = el("flow-network"), rect = network.getBoundingClientRect(), hub = el("flow-hub").getBoundingClientRect(), edges = [];
|
|
135
|
+
const inset = rect.width < 500 ? 2 : 6;
|
|
136
|
+
if (!rect.width) return;
|
|
137
|
+
for (const type of ["apps", "models"]) for (const [id, node] of nodes[type]) {
|
|
138
|
+
if (!node.isConnected) continue;
|
|
139
|
+
const box = node.getBoundingClientRect(), button = node.children[0].getBoundingClientRect(), left = type === "apps";
|
|
140
|
+
const x0 = (left ? box.right : hub.right) - rect.left + inset, y0 = (left ? button.top + button.height / 2 : hub.top + hub.height / 2) - rect.top;
|
|
141
|
+
const x1 = (left ? hub.left : box.left) - rect.left - inset, y1 = (left ? hub.top + hub.height / 2 : button.top + button.height / 2) - rect.top;
|
|
142
|
+
if (x1 <= x0) continue;
|
|
143
|
+
edges.push({ id, type, node, d: rounded(x0, y0, x1, y1), x: left ? x0 : x1, y: left ? y0 : y1, left });
|
|
144
|
+
}
|
|
145
|
+
positions = { width: rect.width, height: rect.height, edges };
|
|
132
146
|
}
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
147
|
+
const { width, height, edges } = positions;
|
|
148
|
+
const next = JSON.stringify([width, height, edges.map(edge => [edge.type, edge.id, edge.d])]);
|
|
149
|
+
const states = edges.map(edge => {
|
|
150
|
+
const matches = rows.filter(row => (edge.left ? row.application : modelKey(row)) === edge.id && related(row));
|
|
151
|
+
return { active: fresh && matches.length > 0, moving: fresh && matches.some(responding), dim: edge.node.dataset.related === "false" };
|
|
152
|
+
});
|
|
153
|
+
const state = JSON.stringify(states), wires = el("flow-wires");
|
|
154
|
+
if (next === geometry && state === wireState) return;
|
|
155
|
+
if (next !== geometry) {
|
|
156
|
+
geometry = next;wires.setAttribute("viewBox", `0 0 ${width} ${height}`);wires.replaceChildren();
|
|
157
|
+
for (const edge of edges) wires.append(svg("path", { d: edge.d }), svg("circle", { r: 2.4 }));
|
|
139
158
|
}
|
|
159
|
+
wireState = state;
|
|
160
|
+
edges.forEach((edge, index) => {
|
|
161
|
+
const value = states[index], path = wires.children[index * 2], dot = wires.children[index * 2 + 1];
|
|
162
|
+
path.setAttribute("class", `flow-wire${value.dim ? " flow-dim" : value.active ? " flow-live" : ""}`);
|
|
163
|
+
dot.setAttribute("class", value.moving ? "flow-packet" : "flow-wait");
|
|
164
|
+
dot.style.display = value.active ? "" : "none";
|
|
165
|
+
dot.style.offsetPath = value.moving ? `path('${edge.d}')` : "none";
|
|
166
|
+
dot.style.animationDelay = edge.left ? "-.9s" : "0s";
|
|
167
|
+
dot.setAttribute("cx", value.moving ? 0 : edge.x);dot.setAttribute("cy", value.moving ? 0 : edge.y);
|
|
168
|
+
});
|
|
140
169
|
}
|
|
141
170
|
function unavailable() { clearTimeout(expiry);expiry = null;fresh = false;deadline = 0;render(); }
|
|
142
171
|
function visibilityChanged() { if (deadline && Date.now() >= deadline) { unavailable();return; }render();draw(); }
|
|
@@ -147,8 +176,8 @@
|
|
|
147
176
|
document.addEventListener("visibilitychange", visibilityChanged);
|
|
148
177
|
globalThis.addEventListener("pagehide", () => { root.dataset.paused = "true"; });
|
|
149
178
|
globalThis.addEventListener("pageshow", visibilityChanged);
|
|
150
|
-
|
|
151
|
-
new MutationObserver(() => { lastSignature = "";render(); }).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
|
|
179
|
+
resize.observe(el("flow-network"));
|
|
180
|
+
new MutationObserver(() => { lastSignature = "";positions = null;render(); }).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
|
|
152
181
|
globalThis.ccdxDashboardFlow = {
|
|
153
182
|
update(data) {
|
|
154
183
|
const parts = [data?.stream_performance, (data?.providers?.claude || data?.providers?.m365?.claude)?.requests?.performance].filter(Boolean);
|
package/src/dashboard/index.html
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<script src="/refresh.js" defer></script>
|
|
12
12
|
<script src="/icons.js" defer></script>
|
|
13
13
|
<script src="/time.js" defer></script>
|
|
14
|
+
<script src="/view-boundary.js" defer></script>
|
|
14
15
|
<script src="/status.js" defer></script>
|
|
15
16
|
<script src="/activity.js" defer></script>
|
|
16
17
|
<script src="/flow.js" defer></script>
|
|
@@ -327,6 +328,8 @@
|
|
|
327
328
|
</details>
|
|
328
329
|
<details class="lower" id="recent-failures" open>
|
|
329
330
|
<summary class="panel-heading"><h2 data-i18n="recent_inference_http_failures">RECENT REQUEST ISSUES</h2><span id="failure-count">requests + events</span></summary>
|
|
331
|
+
<label for="failure-kind" class="sr-only" data-i18n="issue_category">Issue category</label>
|
|
332
|
+
<select id="failure-kind"><option value="issues" data-i18n="issue_replies">Reply issues</option><option value="capability" data-i18n="issue_capabilities">Capability notices</option><option value="connection" data-i18n="issue_connections">Connections and paths</option></select>
|
|
330
333
|
<ol id="failures"><li class="empty" data-i18n="reading_874bf">Reading…</li></ol>
|
|
331
334
|
</details>
|
|
332
335
|
</div>
|
|
@@ -391,6 +394,11 @@
|
|
|
391
394
|
<section class="panel dashboard-section" id="version-updates" aria-labelledby="version-updates-title">
|
|
392
395
|
<div class="version-heading"><h2 id="version-updates-title" data-i18n="version_updates">VERSION & UPDATES</h2><button id="check-updates" type="button" data-i18n="check_updates">Check for updates</button></div>
|
|
393
396
|
<dl class="version-list"><div><dt data-i18n="current_version">Current version</dt><dd id="update-current-version">—</dd><dd id="update-current-date" class="hint">—</dd></div><div id="update-latest-row" hidden><dt data-i18n="available_update">Update available</dt><dd id="update-latest-version">—</dd><dd id="update-latest-date" class="hint">—</dd></div></dl>
|
|
397
|
+
<div class="nightly-update">
|
|
398
|
+
<div class="setting-row"><label for="nightly-update" data-i18n="nightly_update">Update overnight</label><input id="nightly-update" type="checkbox" role="switch" aria-describedby="nightly-risk" disabled><span id="nightly-state" class="hint" role="status"></span></div>
|
|
399
|
+
<p id="nightly-risk" class="hint" data-i18n="nightly_risk">Updates install a new version and restart CCDX. Continuing a conversation may be affected.</p>
|
|
400
|
+
<div id="nightly-rules" hidden><dl class="nightly-rules"><div><dt data-i18n="nightly_window">Update window</dt><dd data-i18n="nightly_window_value">00:00–04:00 · Local time</dd></div><div><dt data-i18n="nightly_when">When to update</dt><dd data-i18n="nightly_when_value">Idle for 10 minutes, after checks pass</dd></div><div><dt data-i18n="nightly_versions">Versions</dt><dd data-i18n="nightly_versions_value">Stable patches released at least 24 hours ago</dd></div><div><dt data-i18n="nightly_failure">If an update fails</dt><dd data-i18n="nightly_failure_value">Try restoring the previous version and pause this update</dd></div></dl></div>
|
|
401
|
+
</div>
|
|
394
402
|
<p id="update-state" class="hint" role="status" data-i18n="reading">READING</p>
|
|
395
403
|
<div id="update-command-row" class="update-command"><code id="update-command">ccdx update github</code><button type="button" id="copy-update" data-i18n="copy_command">Copy command</button></div>
|
|
396
404
|
<p class="hint" data-i18n="update_restart">Run in your terminal, then restart CCDX.</p>
|
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const translations = {
|
|
3
|
+
"issue_category": ["Issue category", "问题分类"],
|
|
4
|
+
"issue_replies": ["Reply issues", "回复问题"],
|
|
5
|
+
"issue_capabilities": ["Capability notices", "能力提示"],
|
|
6
|
+
"issue_connections": ["Connections and paths", "连接与路径"],
|
|
7
|
+
"http_categories": ["Generation {inference} · Capabilities {capability} · Methods {protocol} · Paths {route} · Other {other}", "生成 {inference} · 能力 {capability} · 方法 {protocol} · 路径 {route} · 其他 {other}"],
|
|
8
|
+
"no_upstream_call": ["No upstream call", "未调用上游"],
|
|
9
|
+
"repeated_issue": ["{detail} · {count} occurrences", "{detail} · 出现 {count} 次"],
|
|
10
|
+
"reason": ["Reason", "具体原因"],
|
|
11
|
+
"occurrences": ["Occurrences", "出现次数"],
|
|
12
|
+
"capability_cached": ["Recent capability result reused", "沿用近期能力结果"],
|
|
13
|
+
"shared_upstream": ["Shared upstream call", "合并上游调用"],
|
|
14
|
+
"model_not_selected_message": ["This model is not selected for this app.", "此应用尚未选入该模型。"],
|
|
15
|
+
"model_ambiguous_message": ["This model name matches multiple sources. Select its source-specific entry.", "模型同名,请选择明确来源。"],
|
|
16
|
+
"model_catalog_unavailable_message": ["The selected model is not currently available in its source catalog.", "来源目录中暂时没有该模型。"],
|
|
17
|
+
"client_source_disabled_message": ["This app or its model source is turned off.", "应用或模型来源已关闭。"],
|
|
18
|
+
"local_validation_message": ["The request was rejected locally before an upstream call.", "本机校验未通过,未调用上游。"],
|
|
19
|
+
"count_endpoint_missing_message": ["The source's token-count endpoint returned HTTP 404. Message generation is separate.", "上游计数接口返回 404,回复另行处理。"],
|
|
20
|
+
"nightly_update": ["Update overnight", "夜间自动更新"],
|
|
21
|
+
"nightly_risk": ["Updates install a new version and restart CCDX. Continuing a conversation may be affected.", "开启后会自动安装新版并重启 CCDX,可能影响会话续接。"],
|
|
22
|
+
"nightly_window": ["Update window", "更新时间"],
|
|
23
|
+
"nightly_window_value": ["00:00–04:00 · Local time", "00:00–04:00 · 本机时间"],
|
|
24
|
+
"nightly_when": ["When to update", "执行条件"],
|
|
25
|
+
"nightly_when_value": ["Idle for 10 minutes, after checks pass", "持续空闲 10 分钟,且检查通过"],
|
|
26
|
+
"nightly_versions": ["Versions", "更新范围"],
|
|
27
|
+
"nightly_versions_value": ["Stable patches released at least 24 hours ago", "仅发布满 24 小时的稳定补丁版"],
|
|
28
|
+
"nightly_failure": ["If an update fails", "更新失败"],
|
|
29
|
+
"nightly_failure_value": ["Try restoring the previous version and pause this update", "尝试恢复原版,并暂停该版本"],
|
|
30
|
+
"nightly_off": ["Off by default", "默认关闭"],
|
|
31
|
+
"nightly_next_start": ["On · Starts next time you run CCDX", "已开启 · 下次启动 CCDX 生效"],
|
|
32
|
+
"nightly_watching": ["On · Waiting for an idle overnight window", "已开启 · 等待夜间空闲时段"],
|
|
33
|
+
"nightly_checking": ["Checking for updates", "正在检查更新"],
|
|
34
|
+
"nightly_preparing": ["Preparing an update; service stays available", "正在准备新版,当前服务继续运行"],
|
|
35
|
+
"nightly_deferred": ["Deferred until another idle window", "已延后,等待下个空闲时段"],
|
|
36
|
+
"nightly_switching": ["Switching versions", "正在切换版本"],
|
|
37
|
+
"nightly_updated": ["Update complete", "更新完成"],
|
|
38
|
+
"nightly_cancelled": ["Automatic update cancelled", "已取消自动更新"],
|
|
39
|
+
"nightly_paused": ["Update paused; check the terminal for details", "更新已暂停,请查看终端"],
|
|
40
|
+
"nightly_unavailable": ["Automatic update unavailable; service is unaffected", "自动更新不可用,服务不受影响"],
|
|
41
|
+
|
|
42
|
+
"view_unavailable": ["This area is unavailable.", "此区域暂时不可用。"],
|
|
43
|
+
"view_retry": ["Try again", "重试"],
|
|
3
44
|
"api_saving": ["Saving…", "保存中…"],
|
|
4
45
|
"api_reading": ["Reading…", "读取中…"],
|
|
5
46
|
"api_read_cancelled": ["Read cancelled. Saved metadata is kept.", "已取消读取,保留已存资料。"],
|
|
@@ -1136,6 +1177,12 @@
|
|
|
1136
1177
|
"outcome": "outcome_25a63",
|
|
1137
1178
|
"origin": "origin",
|
|
1138
1179
|
"route": "route",
|
|
1180
|
+
"This model is not selected for this app.": "model_not_selected_message",
|
|
1181
|
+
"This model name matches multiple sources. Select its source-specific entry.": "model_ambiguous_message",
|
|
1182
|
+
"The selected model is not currently available in its source catalog.": "model_catalog_unavailable_message",
|
|
1183
|
+
"This app or its model source is turned off.": "client_source_disabled_message",
|
|
1184
|
+
"The request was rejected locally before an upstream call.": "local_validation_message",
|
|
1185
|
+
"The source's token-count endpoint returned HTTP 404. Message generation is separate.": "count_endpoint_missing_message",
|
|
1139
1186
|
"HTTP request failed; original response was preserved.": "http_request_failed_original_response_was_preserved",
|
|
1140
1187
|
"phase": "phase",
|
|
1141
1188
|
"http_status": "http_status",
|
package/src/dashboard/status.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
let contextRequests = [];
|
|
4
4
|
let contextCompactions = {};
|
|
5
5
|
let failureSignature;
|
|
6
|
+
let issueGroups = { issues: [], capability: [], connection: [] }, issueRequests = [];
|
|
7
|
+
element("failure-kind")?.addEventListener?.("change", () => renderFailures(issueGroups[element("failure-kind").value] || [], element("failure-kind").value === "issues" ? issueRequests : []));
|
|
6
8
|
let contextSignature;
|
|
7
9
|
const sourceNames = new Map([["github", "GitHub Copilot"], ["m365", "Microsoft 365"]]);
|
|
8
10
|
|
|
@@ -85,7 +87,7 @@
|
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
function renderFailures(recent, recentRequests = []) {
|
|
88
|
-
const signature = JSON.stringify([recent, recentRequests]);
|
|
90
|
+
const signature = JSON.stringify([element("failure-kind")?.value, recent, recentRequests]);
|
|
89
91
|
if (signature === failureSignature) return;
|
|
90
92
|
failureSignature = signature;
|
|
91
93
|
const list = element("failures");
|
|
@@ -93,7 +95,15 @@
|
|
|
93
95
|
list.replaceChildren();
|
|
94
96
|
const requests = Array.isArray(recentRequests) ? recentRequests.slice(-20) : [];
|
|
95
97
|
const byRequest = new Map(requests.filter((request) => request.request_id).map((request) => [request.request_id, request]));
|
|
96
|
-
const
|
|
98
|
+
const kind = element("failure-kind")?.value || "issues", grouped = new Map();
|
|
99
|
+
const entries = Array.isArray(recent) ? recent : [];
|
|
100
|
+
for (const failure of entries) {
|
|
101
|
+
const key = kind === "issues" ? failure.request_id || `${failure.at}/${failure.code}`
|
|
102
|
+
: JSON.stringify([failure.provider, failure.model, failure.route, failure.code, kind === "capability" ? null : failure.origin, failure.reason]);
|
|
103
|
+
const old = grouped.get(key);
|
|
104
|
+
grouped.set(key, { ...failure, occurrences: (old?.occurrences || 0) + 1, timeline: byRequest.get(failure.request_id) });
|
|
105
|
+
}
|
|
106
|
+
const failures = [...grouped.values()].slice(-10);
|
|
97
107
|
const recorded = new Set(failures.map((failure) => failure.request_id).filter(Boolean));
|
|
98
108
|
for (const request of requests) {
|
|
99
109
|
if (!request.failed || recorded.has(request.request_id)) continue;
|
|
@@ -124,9 +134,13 @@
|
|
|
124
134
|
model: failure.model ? String(failure.model).slice(0, 80) : phrase("unknown_model"),
|
|
125
135
|
code: failure.code ? String(failure.code).slice(0, 80) : phrase("unknown_error"),
|
|
126
136
|
}),
|
|
127
|
-
retry: phrase(failure.retried ? "retry_attempted" : "no_retry"),
|
|
137
|
+
retry: phrase(failure.upstream_attempts === 0 ? "no_upstream_call" : failure.retried ? "retry_attempted" : "no_retry"),
|
|
128
138
|
};
|
|
129
139
|
localize(title, "detail_retry", summary);
|
|
140
|
+
if (failure.occurrences > 1) {
|
|
141
|
+
summary.detail = phrase("repeated_issue", { detail: summary.detail, count: failure.occurrences });
|
|
142
|
+
localize(title, "detail_retry", summary);
|
|
143
|
+
}
|
|
130
144
|
const timeline = failure.timeline;
|
|
131
145
|
const provider = failure.provider || timeline?.provider;
|
|
132
146
|
if (provider) {
|
|
@@ -137,7 +151,7 @@
|
|
|
137
151
|
const timings = timeline?.timings_ms || {};
|
|
138
152
|
const timingText = ["admission", "body", "history", "images", "serialization", "upstream_start", "upstream_headers", "first_output", "last_activity", "terminal", "finished"]
|
|
139
153
|
.filter((key) => finite(timings[key])).map((key) => `${key}=${Number(timings[key]).toFixed(1)}`).join(" / ");
|
|
140
|
-
const fields = { time: failure.at, model: failure.model, event: failure.event_type, code: failure.code,
|
|
154
|
+
const fields = { time: failure.at, model: failure.model, event: failure.event_type, code: failure.code, reason: failure.reason, application: failure.application, occurrences: failure.occurrences > 1 ? failure.occurrences : undefined, capability_cached: failure.capability_cached, shared_upstream: failure.shared_upstream,
|
|
141
155
|
message: failure.message, response_id: failure.response_id, upstream_request_id: failure.upstream_request_id,
|
|
142
156
|
retry: failure.retried ? (timeline ? "attempted" : "attempted (outcome not recorded here)") : "not attempted",
|
|
143
157
|
retry_policy: failure.retry_policy, retry_skipped: failure.retry_skipped,
|
|
@@ -197,8 +211,8 @@
|
|
|
197
211
|
text("requests", number(requests.total));
|
|
198
212
|
text("request-errors", "4xx_client_5xx_server_active_active", { client: number(requests.status_4xx), server: number(requests.status_5xx), active: number(requests.active) });
|
|
199
213
|
const categories = data.http_errors?.by_category;
|
|
200
|
-
text("http-error-breakdown", categories ? "
|
|
201
|
-
categories ? Object.fromEntries(
|
|
214
|
+
text("http-error-breakdown", categories ? "http_categories" : "—",
|
|
215
|
+
categories ? Object.fromEntries(["inference", "capability", "protocol", "route", "other"].map(key => [key, number(categories[key] || 0)])) : {});
|
|
202
216
|
text("body-limits", "raw_raw_decoded_decoded", { raw: mib(data.limits?.max_body_bytes), decoded: mib(data.limits?.max_decoded_body_bytes) });
|
|
203
217
|
|
|
204
218
|
const outcomes = data.stream_performance?.by_route?.responses?.terminal_outcomes?.totals || {};
|
|
@@ -241,8 +255,15 @@
|
|
|
241
255
|
}
|
|
242
256
|
const recentRequests = [...(data.stream_performance?.recent_requests || []), ...(claudeMetrics?.recent_requests || [])]
|
|
243
257
|
.sort((a, b) => (Date.parse(a.at) || 0) - (Date.parse(b.at) || 0));
|
|
244
|
-
|
|
245
|
-
|
|
258
|
+
issueGroups = {
|
|
259
|
+
issues: [...(data.response_failures?.recent || []), ...(data.http_errors?.actionable_recent || data.http_errors?.recent || [])],
|
|
260
|
+
capability: data.http_errors?.capability_recent || [],
|
|
261
|
+
connection: [...(data.http_errors?.protocol_recent || []), ...(data.http_errors?.route_recent || [])],
|
|
262
|
+
};
|
|
263
|
+
for (const rows of Object.values(issueGroups)) rows.sort((a, b) => (Date.parse(a.at) || 0) - (Date.parse(b.at) || 0));
|
|
264
|
+
issueRequests = recentRequests;
|
|
265
|
+
const kind = element("failure-kind")?.value || "issues";
|
|
266
|
+
renderFailures(issueGroups[kind] || [], kind === "issues" ? recentRequests : []);
|
|
246
267
|
renderContext({ ...data.stream_performance, recent_requests: recentRequests });
|
|
247
268
|
if (element("claude-route")) {
|
|
248
269
|
element("claude-route").textContent = claude?.base_url || "—";
|
package/src/dashboard/ui.css
CHANGED
|
@@ -446,10 +446,18 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
446
446
|
.flow-note { position:absolute;top:calc(100% + 4px);left:9px;max-width:100%;margin:0;color:var(--muted);font-size:10px; }
|
|
447
447
|
.flow-source { position:absolute;bottom:calc(100% + 9px);left:9px;color:var(--muted);font-size:10px;white-space:nowrap; }
|
|
448
448
|
.flow-node[data-related="false"] { opacity:.5; }
|
|
449
|
-
#flow-hub { position:relative;display:flex;align-items:center;justify-content:center;width:
|
|
449
|
+
#flow-hub { position:relative;display:flex;align-items:center;justify-content:center;width:60px;height:60px;border:0;background:var(--surface);color:var(--text);padding:0;text-transform:none; }
|
|
450
450
|
#flow-hub b { position:absolute;top:calc(100% + 10px);left:50%;transform:translateX(-50%); }
|
|
451
451
|
#flow-hub:hover { color:var(--accent); }
|
|
452
452
|
.flow-logo { width:34px;height:34px;color:var(--accent); }
|
|
453
|
+
.flow-halo { position:absolute;inset:0;width:60px;height:60px;color:var(--accent);pointer-events:none; }
|
|
454
|
+
.flow-halo-track { fill:none;stroke:currentColor;stroke-width:1;opacity:.26; }
|
|
455
|
+
.flow-halo-turn { transform-origin:center;animation:flow-orbit 5s linear infinite;animation-play-state:paused;opacity:0;transition:opacity 180ms ease-out; }
|
|
456
|
+
.flow-halo-turn circle { fill:none;stroke:currentColor;stroke-width:1.15;stroke-linecap:round;stroke-dasharray:155.93 20; }
|
|
457
|
+
#request-flow[data-state="active"] .flow-halo-turn { animation-play-state:running;opacity:.9; }
|
|
458
|
+
#request-flow[data-state="unknown"] .flow-halo-track { opacity:.15; }
|
|
459
|
+
#request-flow[data-paused="true"] .flow-halo-turn { animation-play-state:paused; }
|
|
460
|
+
@keyframes flow-orbit { from { transform:rotate(-90deg); } to { transform:rotate(270deg); } }
|
|
453
461
|
.flow-caption { display:flex;align-items:center;flex-wrap:wrap;gap:10px 16px;min-height:30px;font-size:11px;color:var(--muted); }
|
|
454
462
|
.flow-caption button { padding:5px 9px; }
|
|
455
463
|
.flow-wire { fill:none;stroke:var(--border);stroke-width:1;stroke-linecap:round;stroke-linejoin:round; }
|
|
@@ -474,8 +482,9 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
474
482
|
.flow-network { grid-template-columns:minmax(80px,1fr) 48px minmax(100px,1fr);column-gap:12px; }
|
|
475
483
|
.flow-column-title,.flow-source,.flow-note { font-size:10px; }
|
|
476
484
|
.flow-logo { width:26px;height:26px; }
|
|
485
|
+
#flow-hub,.flow-halo { width:48px;height:48px; }
|
|
477
486
|
}
|
|
478
|
-
@media(prefers-reduced-motion:reduce) { .flow-packet,#request-flow[data-state="idle"] #flow-state::before { animation:none; } }
|
|
487
|
+
@media(prefers-reduced-motion:reduce) { .flow-packet,.flow-halo-turn,#request-flow[data-state="idle"] #flow-state::before { animation:none;transition:none; } }
|
|
479
488
|
|
|
480
489
|
/* Model capability and application binding controls share the existing palette. */
|
|
481
490
|
.client-segments { margin-bottom: 18px; }
|
|
@@ -512,3 +521,10 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
512
521
|
.binding-table td:last-child button { min-width: 88px; padding: 9px; }
|
|
513
522
|
.binding-table td[colspan] { grid-column: 1 / -1; }
|
|
514
523
|
}
|
|
524
|
+
|
|
525
|
+
.view-error { display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-top:18px;color:var(--bad);font-size:11px; }
|
|
526
|
+
|
|
527
|
+
.nightly-update { margin:26px 0; }.nightly-rules { display:grid;grid-template-columns:1fr 1fr;gap:20px 30px;margin:22px 0; }.nightly-rules dt { color:var(--muted);font-size:11px;margin-bottom:8px; }.nightly-rules dd { margin:0;font-size:12px;line-height:1.7; }
|
|
528
|
+
@media(max-width:640px) { .nightly-rules { grid-template-columns:1fr; } }
|
|
529
|
+
|
|
530
|
+
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
|
package/src/dashboard/ui.js
CHANGED
|
@@ -18,8 +18,8 @@ const mib = (value) => finite(value) ? `${(Number(value) / 1048576).toFixed(1)}
|
|
|
18
18
|
const time = (value, options) => globalThis.ccdxTime?.format(value, options) ?? (value ? new Date(value).toLocaleTimeString() : "—");
|
|
19
19
|
const viewHelpers = { time, element, phrase, localize, text, finite, number, mib, tableRow, emptyTable, document, navigator: globalThis.navigator,
|
|
20
20
|
motionAllowed: () => !reducedMotion.matches && document.visibilityState === "visible" && element("usage-analytics").open && !element("usage-analytics").closest("[hidden]") };
|
|
21
|
-
const { render, renderProviders, renderFailures, renderContext } = globalThis.ccdxDashboardStatus.create(viewHelpers);
|
|
22
|
-
const usageView = globalThis.ccdxDashboardUsage.create(viewHelpers);
|
|
21
|
+
const { render, renderProviders, renderFailures, renderContext } = globalThis.ccdxViewBoundary.create("client-features", () => globalThis.ccdxDashboardStatus.create(viewHelpers), ["render", "renderProviders", "renderFailures", "renderContext"]);
|
|
22
|
+
const usageView = globalThis.ccdxViewBoundary.create("usage-analytics", () => globalThis.ccdxDashboardUsage.create(viewHelpers), ["applyUsage", "renderUsageState", "renderAnalytics", "renderUsageTable", "selectUsageDay", "usageValues", "setChartVisible", "revealChart", "stopMotion"]);
|
|
23
23
|
const { applyUsage, renderUsageState, renderAnalytics, renderUsageTable, selectUsageDay } = usageView;
|
|
24
24
|
const loadAuth = () => dashboardRefresh.refresh("auth", { force: true });
|
|
25
25
|
|
|
@@ -38,8 +38,8 @@ element("refresh").addEventListener("click", () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
41
|
-
const animationView = globalThis.ccdxDashboardAnimation.create({ element, phrase, localize, text, reducedMotion,
|
|
42
|
-
getRefresh: () => dashboardRefresh, document });
|
|
41
|
+
const animationView = globalThis.ccdxViewBoundary.create("animation-settings", () => globalThis.ccdxDashboardAnimation.create({ element, phrase, localize, text, reducedMotion,
|
|
42
|
+
getRefresh: () => dashboardRefresh, document }), ["apply", "load", "save", "sync", "stop"]);
|
|
43
43
|
const { apply: applyAnimation, load: loadAnimation, save: saveAnimation, sync: syncAnimationPreview, stop: stopAnimationPreview } = animationView;
|
|
44
44
|
reducedMotion.addEventListener("change", () => { if (reducedMotion.matches) usageView.stopMotion(); });
|
|
45
45
|
document.addEventListener("visibilitychange", () => { if (document.visibilityState !== "visible") usageView.stopMotion(); });
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
// One optional view owns its failure and retry; the shell and other views keep running.
|
|
3
|
+
function create(rootId, factory, methods) {
|
|
4
|
+
let view, failure, notice;
|
|
5
|
+
const wrappers = new Map(), pending = new Map();
|
|
6
|
+
function failed() {
|
|
7
|
+
if (notice) return;
|
|
8
|
+
const root = document.getElementById(rootId);if (!root) return;
|
|
9
|
+
notice = document.createElement('div');notice.className = 'view-error';notice.setAttribute('role', 'alert');
|
|
10
|
+
const message = document.createElement('span'), retry = document.createElement('button');retry.type = 'button';
|
|
11
|
+
globalThis.ccdxLanguage.set(message, 'view_unavailable');globalThis.ccdxLanguage.set(retry, 'view_retry');
|
|
12
|
+
retry.addEventListener('click', () => {
|
|
13
|
+
failure = false;notice.remove();notice = null;
|
|
14
|
+
if (!initialize()) return;
|
|
15
|
+
const calls = [...pending];pending.clear();
|
|
16
|
+
for (const [name, args] of calls) invoke(name, args);
|
|
17
|
+
});
|
|
18
|
+
notice.append(message, retry);root.append(notice);
|
|
19
|
+
}
|
|
20
|
+
function initialize() {
|
|
21
|
+
if (view) return true;
|
|
22
|
+
try { view = factory();return true; } catch { failure = true;failed();return false; }
|
|
23
|
+
}
|
|
24
|
+
function invoke(name, args) {
|
|
25
|
+
if (failure && !['stop', 'stopMotion'].includes(name)) { pending.set(name, args);return; }
|
|
26
|
+
if (!initialize()) { pending.set(name, args);return; }
|
|
27
|
+
const fail = () => { pending.set(name, args);failure = true;failed(); };
|
|
28
|
+
try {
|
|
29
|
+
const value = view[name](...args);
|
|
30
|
+
return value?.then ? value.catch(fail) : value;
|
|
31
|
+
} catch { fail(); }
|
|
32
|
+
}
|
|
33
|
+
initialize();
|
|
34
|
+
return new Proxy({}, { get(_target, name) {
|
|
35
|
+
if (!methods.includes(name)) return view?.[name];
|
|
36
|
+
if (!wrappers.has(name)) wrappers.set(name, (...args) => invoke(name, args));
|
|
37
|
+
return wrappers.get(name);
|
|
38
|
+
} });
|
|
39
|
+
}
|
|
40
|
+
globalThis.ccdxViewBoundary = { create };
|
|
41
|
+
})();
|
package/src/dashboard-tools.mjs
CHANGED
|
@@ -7,6 +7,7 @@ export function createDashboardTools(options = {}) {
|
|
|
7
7
|
const accounts = options.accountTools || createAccountTools({ ...options, onChanged: options.credentialsChanged });
|
|
8
8
|
const local = options.localTools || createLocalTools(options);
|
|
9
9
|
return {
|
|
10
|
+
busy: () => accounts.busy?.() === true || local.busy?.() === true,
|
|
10
11
|
dispose() { accounts.dispose(); },
|
|
11
12
|
async handle(req, res, pathname, sendJson, sameOrigin) {
|
|
12
13
|
const account = pathname === "/_ccdx/ui/account";
|
package/src/dashboard.mjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { isLoopbackAddress, isLoopbackHostHeader } from "./security.mjs";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { ADAPTER_VERSION } from "./running-adapter.mjs";
|
|
3
5
|
|
|
4
6
|
const ASSETS = new Map([
|
|
5
7
|
["/", ["./dashboard/index.html", "text/html; charset=utf-8"]],
|
|
@@ -11,6 +13,7 @@ const ASSETS = new Map([
|
|
|
11
13
|
["/console.js", ["./dashboard/console.js", "text/javascript; charset=utf-8"]],
|
|
12
14
|
["/updates.js", ["./dashboard/updates.js", "text/javascript; charset=utf-8"]],
|
|
13
15
|
["/time.js", ["./dashboard/time.js", "text/javascript; charset=utf-8"]],
|
|
16
|
+
["/view-boundary.js", ["./dashboard/view-boundary.js", "text/javascript; charset=utf-8"]],
|
|
14
17
|
["/status.js", ["./dashboard/status.js", "text/javascript; charset=utf-8"]],
|
|
15
18
|
["/activity.js", ["./dashboard/activity.js", "text/javascript; charset=utf-8"]],
|
|
16
19
|
["/flow.js", ["./dashboard/flow.js", "text/javascript; charset=utf-8"]],
|
|
@@ -20,6 +23,19 @@ const ASSETS = new Map([
|
|
|
20
23
|
["/tools.js", ["./dashboard/tools.js", "text/javascript; charset=utf-8"]],
|
|
21
24
|
["/connections.js", ["./dashboard/connections.js", "text/javascript; charset=utf-8"]],
|
|
22
25
|
]);
|
|
26
|
+
let bundle;
|
|
27
|
+
function assets() {
|
|
28
|
+
bundle ||= Promise.all([...ASSETS].map(async ([name, [file, type]]) => {
|
|
29
|
+
let body = await readFile(new URL(file, import.meta.url));
|
|
30
|
+
if (name === "/") body = Buffer.from(body.toString().replace(/(src|href)="(\/[a-z-]+\.(?:js|css))"/g, `$1="$2?v=${ADAPTER_VERSION}"`));
|
|
31
|
+
return [name, { body, type, etag: `"${createHash("sha256").update(body).digest("hex")}"` }];
|
|
32
|
+
})).then(async entries => {
|
|
33
|
+
const installed = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
|
|
34
|
+
if (installed.version !== ADAPTER_VERSION) throw new Error("Dashboard files changed; restart CCDX before loading the new dashboard");
|
|
35
|
+
return new Map(entries);
|
|
36
|
+
}).catch(error => { bundle = null;throw error; });
|
|
37
|
+
return bundle;
|
|
38
|
+
}
|
|
23
39
|
|
|
24
40
|
export async function serveDashboard(req, res, pathname) {
|
|
25
41
|
if (!isLoopbackAddress(req.socket?.remoteAddress)
|
|
@@ -30,15 +46,20 @@ export async function serveDashboard(req, res, pathname) {
|
|
|
30
46
|
return;
|
|
31
47
|
}
|
|
32
48
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
49
|
+
const version = new URL(req.url || pathname, "http://localhost").searchParams.get("v");
|
|
50
|
+
if (version && version !== ADAPTER_VERSION) {
|
|
51
|
+
res.writeHead(409, { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "no-store" });res.end("Dashboard version changed. Reload this page.");return;
|
|
52
|
+
}
|
|
53
|
+
const { body, type: contentType, etag } = (await assets()).get(pathname);
|
|
54
|
+
const unchanged = pathname !== "/" && String(req.headers?.["if-none-match"] || "").split(/\s*,\s*/).includes(etag);
|
|
55
|
+
res.writeHead(unchanged ? 304 : 200, {
|
|
36
56
|
"Content-Type": contentType,
|
|
37
|
-
"Cache-Control": "no-store",
|
|
57
|
+
"Cache-Control": pathname === "/" ? "no-store" : "no-cache",
|
|
58
|
+
...(pathname === "/" ? {} : { ETag: etag }),
|
|
38
59
|
"Content-Security-Policy": "default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src data:; base-uri 'none'; form-action 'none'; frame-ancestors 'none'",
|
|
39
60
|
"X-Content-Type-Options": "nosniff",
|
|
40
61
|
"X-Frame-Options": "DENY",
|
|
41
62
|
"Referrer-Policy": "no-referrer",
|
|
42
63
|
});
|
|
43
|
-
res.end(req.method === "HEAD" ? undefined : body);
|
|
64
|
+
res.end(unchanged || req.method === "HEAD" ? undefined : body);
|
|
44
65
|
}
|
package/src/image-mcp.mjs
CHANGED
|
@@ -321,5 +321,8 @@ export function createImageMcpHandler({
|
|
|
321
321
|
};
|
|
322
322
|
// Status never reads credentials, loads image guidance, or probes a provider.
|
|
323
323
|
handler.stats = () => ({ ...metrics, active, max_concurrent: maxConcurrent });
|
|
324
|
+
handler.exportState = () => { if (active) throw new Error("Image requests are active");return imageReferences.exportState(); };
|
|
325
|
+
handler.importState = state => imageReferences.importState(state);
|
|
326
|
+
handler.referenceBytes = () => imageReferences.stats().bytes;
|
|
324
327
|
return handler;
|
|
325
328
|
}
|
package/src/image-references.mjs
CHANGED
|
@@ -36,6 +36,15 @@ export function createImageReferenceStore({ maxBytes = 64 * 1024 * 1024 } = {})
|
|
|
36
36
|
return JSON.parse(value);
|
|
37
37
|
},
|
|
38
38
|
clear() { cache.clear(); },
|
|
39
|
+
exportState() { return cache.exportEntries(); },
|
|
40
|
+
importState(values) {
|
|
41
|
+
if (!Array.isArray(values) || values.some(pair => !Array.isArray(pair) || !/^[a-f0-9]{64}:ccdx_img_[0-9a-f-]{36}$/.test(pair[0]) || typeof pair[1] !== "string")) throw new Error("Invalid image-reference handoff");
|
|
42
|
+
for (const [, value] of values) {
|
|
43
|
+
const item = JSON.parse(value);
|
|
44
|
+
if (typeof item.image !== "string" || !/^data:image\/(png|jpeg|webp);base64,[A-Za-z0-9+/=]+$/.test(item.image)) throw new Error("Invalid image-reference handoff");
|
|
45
|
+
}
|
|
46
|
+
cache.importEntries(values);
|
|
47
|
+
},
|
|
39
48
|
stats() { return cache.stats(); },
|
|
40
49
|
};
|
|
41
50
|
}
|
package/src/local-tools.mjs
CHANGED
|
@@ -48,6 +48,6 @@ export function createLocalTools({ home = os.homedir(), env = process.env, host
|
|
|
48
48
|
const value = inspectNetwork({ env, platform });
|
|
49
49
|
return { source: "network_check", checked_at: new Date().toISOString(), summary: safe(formatPredictionEnvironment(value.summary)) };
|
|
50
50
|
}
|
|
51
|
-
return { snapshot, check, preview, repair, network, report: () => ({ version: localPackageVersion(),
|
|
51
|
+
return { snapshot, check, preview, repair, network, busy: () => Boolean(flight), report: () => ({ version: localPackageVersion(),
|
|
52
52
|
exported_at: new Date().toISOString(), scope: "local checks only; accounts and credentials omitted", ...snapshot() }) };
|
|
53
53
|
}
|
package/src/m365-settings.mjs
CHANGED
|
@@ -95,6 +95,11 @@ export function writeM365Binding(account, catalog, { expectedAccount, ...options
|
|
|
95
95
|
|
|
96
96
|
export function ensureM365GatewayKey(options = {}) {
|
|
97
97
|
const file = m365Paths(options).gateway;
|
|
98
|
+
if (options.create === false) {
|
|
99
|
+
const saved = readM365Json(file);
|
|
100
|
+
if (!/^ccdx_m365_[a-f0-9]{64}$/.test(saved?.key || "")) throw Object.assign(new Error("Saved M365 gateway key is unavailable"), { code: "m365_gateway_key_invalid" });
|
|
101
|
+
return saved.key;
|
|
102
|
+
}
|
|
98
103
|
fs.mkdirSync(path.dirname(file), { recursive: true, mode: 0o700 });
|
|
99
104
|
return withFileLockSync(`${file}.lock`, () => {
|
|
100
105
|
const saved = readM365Json(file);
|