codex-copilot-dx 0.9.27 → 0.9.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/ARCHITECTURE.md +23 -4
- package/docs/README.md +2 -0
- package/docs/REFERENCE.md +57 -4
- package/package.json +1 -1
- package/src/adapter.mjs +1 -1
- package/src/copilot-responses-compat.mjs +72 -43
- package/src/dashboard/index.html +4 -2
- package/src/dashboard/language.js +10 -0
- package/src/dashboard/refresh.js +103 -0
- package/src/dashboard/theme.js +1 -1
- package/src/dashboard/ui.css +3 -1
- package/src/dashboard/ui.js +203 -117
- package/src/dashboard.mjs +1 -0
- package/src/http-transport.mjs +5 -136
- package/src/live-models.mjs +6 -9
- package/src/local-compaction-recovery.mjs +246 -0
- package/src/responses-handler.mjs +10 -1
- package/src/responses-proxy.mjs +8 -4
- package/src/responses-request.mjs +1 -1
- package/src/upstream-body.mjs +137 -0
- package/src/upstream-headers.mjs +6 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ enabled. The configured `dummy` API key is a placeholder, not a credential.
|
|
|
23
23
|
|
|
24
24
|
Open [the local dashboard](http://127.0.0.1:2026/) for status, model discovery,
|
|
25
25
|
usage, cache/limits, recent failures, request context and animation settings.
|
|
26
|
-
|
|
26
|
+
Auto refresh runs every 30 minutes while visible and can be switched off. Hidden pages pause; opening sections and manual refresh still work.
|
|
27
27
|
|
|
28
28
|
## Commands
|
|
29
29
|
|
|
@@ -57,7 +57,7 @@ The dashboard does not poll in the background; refresh when needed.
|
|
|
57
57
|
CCDX does not claim it can verify the App's internal model cache externally.
|
|
58
58
|
- After a package upgrade, restart the running CCDX adapter. Choosing a model or
|
|
59
59
|
effort on a current adapter takes effect on its next Auto-review request.
|
|
60
|
-
- Request-body bytes, local-history bytes and the model's token window are
|
|
60
|
+
- `0.9.28` adds verified local plaintext recovery after connection-owned compaction rejection; see the reference for strict source and safety limits. Request-body bytes, local-history bytes and the model's token window are
|
|
61
61
|
different limits. Request-context figures are observed metadata, not exact
|
|
62
62
|
live session occupancy. Prompts and images are not retained by that panel.
|
|
63
63
|
- `ccdx cache --clean --history` also clears active response history and can
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -47,10 +47,29 @@ optional boundary. Core inference keeps its existing service port and lifecycle.
|
|
|
47
47
|
|
|
48
48
|
Connection-ownership replay rejection is a provider-owned retry policy. It
|
|
49
49
|
removes only unavailable reasoning once, preserving visible history and tools.
|
|
50
|
-
Opaque compaction cannot be assumed equivalent to remaining plaintext
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
Opaque compaction cannot be assumed equivalent to remaining plaintext. The
|
|
51
|
+
`0.9.28` injects a lazy, asynchronous local recovery capability
|
|
52
|
+
at the HTTP boundary, while preserving the synchronous provider-selector API.
|
|
53
|
+
`local-compaction-recovery.mjs` owns source lookup, readonly decoding and verified
|
|
54
|
+
reassembly; it is not a general transcript service or startup scanner. The
|
|
55
|
+
provider policy decides whether to retry. HTTP and pre-output SSE/JSON failures
|
|
56
|
+
share the single-use policy, byte admission and cancellation boundaries.
|
|
57
|
+
Without a complete verified local source, rejection still returns
|
|
58
|
+
`ccdx_history_rebuild_required`, without modifying stored history. Diagnostic
|
|
59
|
+
metadata cannot reconstruct unavailable encrypted memory. LAN/browser callers
|
|
60
|
+
and referenced/split histories do not gain filesystem recovery access.
|
|
61
|
+
|
|
62
|
+
## Dashboard reads
|
|
63
|
+
|
|
64
|
+
`dashboard/refresh.js` owns the browser-only read lifecycle: one visible-page
|
|
65
|
+
timer, per-group in-flight deduplication, attempt freshness, cancellation and
|
|
66
|
+
last-good snapshots. `ui.js` owns rendering and user selections. Models, usage,
|
|
67
|
+
status/account and animation metadata remain independent resources; no timer
|
|
68
|
+
or data watcher is added to the Node service. Animation frames load once per
|
|
69
|
+
page when opened, and read refresh does not overwrite an unsaved choice.
|
|
70
|
+
`upstream-body.mjs` is the shared bounded response reader. The transport retains
|
|
71
|
+
its existing exports; live model lookup uses the same 8 MiB catalog limit as
|
|
72
|
+
core model discovery, without importing the request lifecycle or UI layer.
|
|
54
73
|
|
|
55
74
|
## Configuration ownership
|
|
56
75
|
|
package/docs/README.md
CHANGED
|
@@ -17,6 +17,8 @@ These reports record a specific release and test environment. Their version,
|
|
|
17
17
|
test counts, timings, live-provider observations, and limitations remain
|
|
18
18
|
historical facts rather than current guarantees.
|
|
19
19
|
|
|
20
|
+
- [0.9.29: visible-page refresh, atom favicon and safe reasoning declarations](RELEASE_0.9.29.md)
|
|
21
|
+
- [0.9.28: verified local plaintext recovery and validation boundaries](RELEASE_0.9.28.md)
|
|
20
22
|
- [0.9.27: Windows certificate setup without Git/OpenSSL](RELEASE_0.9.27.md)
|
|
21
23
|
- [0.9.26: Windows native predictions, safe ownership recovery and dashboard disclosures](RELEASE_0.9.26.md)
|
|
22
24
|
- [Windows prediction validation history](WINDOWS_PREDICTION_PREVIEW.md)
|
package/docs/REFERENCE.md
CHANGED
|
@@ -203,6 +203,59 @@ Responses-only models and compaction use Copilot's Responses transport directly.
|
|
|
203
203
|
|
|
204
204
|
The adapter handles response history, encrypted reasoning state, function/custom tools, images, compaction, cancellation, retries, and usage metadata within the compatibility boundaries below. Routing prefers endpoint metadata from Copilot's live or cached catalog; when metadata is unavailable, a small built-in set identifies known Responses-only GPT models.
|
|
205
205
|
|
|
206
|
+
### Local compaction recovery
|
|
207
|
+
|
|
208
|
+
`0.9.28` adds bounded local recovery; the affected user's real chat still needs
|
|
209
|
+
verification. After the exact decoded HTTP 400 `input item does not belong
|
|
210
|
+
to this connection` rejection, or its HTTP-200/pre-output Responses failure
|
|
211
|
+
equivalent, a request containing encrypted compaction can attempt one verified
|
|
212
|
+
plaintext rebuild. Healthy encrypted histories remain unchanged.
|
|
213
|
+
|
|
214
|
+
The reader is loaded only after this failure. It requires a loopback peer and
|
|
215
|
+
Host, no browser Origin, and LAN mode disabled. It binds a UUID from native
|
|
216
|
+
`thread-id` / `client_metadata.thread_id`, or an exact UUID session/cache key
|
|
217
|
+
when primary metadata is absent. Conflicting primary IDs are rejected. It reads
|
|
218
|
+
only UUID-matching rollout filenames under the service's configured
|
|
219
|
+
`CODEX_HOME/sessions` and `archived_sessions`; it does not search by conversation
|
|
220
|
+
title, similarity, arbitrary request paths or another machine's filesystem.
|
|
221
|
+
|
|
222
|
+
Supported source files are complete JSONL logs and their `.jsonl.zst` variants,
|
|
223
|
+
decoded with Node's built-in Zstandard support. Header identity, the exact
|
|
224
|
+
compaction ciphertext, retained message order and function/custom-tool pairs
|
|
225
|
+
must match. A history-base reference, fork reference, rollback/reset marker,
|
|
226
|
+
missing plaintext tool content, malformed data or multiple matching sources
|
|
227
|
+
stops recovery. Referenced/split histories are not assembled by this recovery;
|
|
228
|
+
the caller must have a complete standalone source prefix.
|
|
229
|
+
|
|
230
|
+
The request replaces the rejected compaction with recorded plaintext before it,
|
|
231
|
+
retains current instructions and post-compaction input, and removes unavailable
|
|
232
|
+
reasoning. It does not decrypt or claim to reproduce hidden encrypted reasoning.
|
|
233
|
+
Normal preparation, image limits and upstream model/context limits still apply.
|
|
234
|
+
The reader has a five-second deadline, a 4,096-entry directory lookup bound and
|
|
235
|
+
a 16-candidate bound. Decoded reads and the rebuilt body are bounded by the
|
|
236
|
+
running adapter's decoded-body limit; history admission reservations cover
|
|
237
|
+
recovery preparation. Requests cannot retry after visible output has begun.
|
|
238
|
+
|
|
239
|
+
Neither the original rollout nor client configuration is rewritten. Recovery
|
|
240
|
+
diagnostics contain type/count/status metadata, not transcript text, ciphertext
|
|
241
|
+
or file paths. If verification fails, `ccdx_history_rebuild_required` includes
|
|
242
|
+
`recovery.local_status`; "not modified" does not imply CCDX has backed up complete
|
|
243
|
+
plaintext. Cross-machine/LAN recovery is intentionally unavailable. A full
|
|
244
|
+
plaintext replay can still exceed the upstream context window; this recovery
|
|
245
|
+
does not silently truncate it or add chunked re-compaction.
|
|
246
|
+
|
|
247
|
+
### Reasoning usage declaration
|
|
248
|
+
|
|
249
|
+
Native Responses success replies preserve `X-Reasoning-Included: true` only
|
|
250
|
+
when the upstream explicitly returns a case-insensitive literal `true`.
|
|
251
|
+
Missing, false or other values are not forwarded: current Codex treats header
|
|
252
|
+
presence as a declaration that historical reasoning is already counted.
|
|
253
|
+
CCDX does not infer that declaration from `output_tokens_details`, invent it,
|
|
254
|
+
add it to Chat-converted replies or HTTP/JSON failures, or change token totals.
|
|
255
|
+
Streaming headers describe the upstream declaration, not a guarantee that the
|
|
256
|
+
stream will later complete. This is compatibility metadata, not proof of lower
|
|
257
|
+
context use, faster inference or fewer compactions on every client.
|
|
258
|
+
|
|
206
259
|
### Fast and Standard modes
|
|
207
260
|
|
|
208
261
|
Codex can select Standard or Fast without changing CCDX configuration. When the client requests a model with `service_tier: "priority"`, CCDX uses its exact `-fast` model only when the live Copilot catalog advertises that variant as enabled, selectable, OpenAI-owned, and Responses-only. Standard mode continues to use the base model; CCDX does not invent Fast availability when the upstream catalog does not provide it. This retains the established `gpt-5.6-sol` / `gpt-5.6-sol-fast` mapping and applies the same exact-match rule to future models.
|
|
@@ -481,19 +534,19 @@ JSON reply to a streaming request is still not silently converted to SSE.
|
|
|
481
534
|
|
|
482
535
|
After starting `ccdx`, open [http://127.0.0.1:2026/](http://127.0.0.1:2026/) in a browser. If `ADAPTER_PORT` is customized, use that port instead. The dashboard shares the existing adapter listener; CCDX does not open a browser automatically or start another service. The page and its assets require both a loopback connection and a loopback Host header, even when LAN binding is enabled.
|
|
483
536
|
|
|
484
|
-
The dashboard loads local status, a live GitHub Copilot model directory, and a summary of local usage metadata once when opened.
|
|
537
|
+
The dashboard loads local status, a live GitHub Copilot model directory, and a summary of local usage metadata once when opened. The top Refresh updates status/account and expanded data groups; model and usage sections retain their own Refresh controls. Auto refresh is on by default, saved only in this browser, and updates status/account plus expanded groups every 30 minutes while the page is visible. Opening a data section updates its group unless it was attempted within 30 seconds. Hidden pages pause; returning after 30 minutes catches up once, without replaying missed intervals. Turning automatic updates off retains manual and open-section refresh. No server background task is added. In-flight reads are shared per group; failures retain the prior snapshot and success timestamp. Unchanged model rows and charts are retained rather than rebuilt. The appearance button switches between the default dark terminal theme (sun icon) and a light theme (moon icon); the choice is stored only in that browser. The Requests card shows the running adapter's active raw and decoded per-request body limits, not request-body usage; Local History shows its in-memory Responses history use and active limit. Limit changes remain CLI-only (`ccdx limits` and `ccdx cache`). The live model table uses the same fresh account validation and selectable GPT filtering as `ccdx models`, never labels cached fallback data as online, and makes no inference request. A catalog listing does not guarantee inference access. The Model Usage table combines the current and rotated local usage logs, shows totals and up to 100 model rows, and contains no prompt, response body, or credential fields. The animation selector previews the existing themes and saves through the same settings writer as `ccdx animation`; changes take effect on the next adapter start, and `CCDX_TERMINAL_ANIMATION=off` still disables terminal motion. Dashboard data requests require a custom header that cross-site simple requests cannot send; animation writes also require a matching same-origin `Origin`. The dashboard does not initialize the optional image handler. The overview's known-model count is the adapter's current in-memory catalog, not the live table. A missing image-generation status does not prove the feature is disabled: use `ccdx image-status` to check setup. Recent upstream error prose may contain sensitive details, so review the page before sharing screenshots.
|
|
485
538
|
|
|
486
539
|
The dashboard labels the upstream token cache hit metric **Reuse Rate** and cached input **Reused Input**, separate from **Local History**. Chinese uses short functional names such as “对话暂存”, “重用输入” and “重用比例”. English and Chinese preserve model IDs, commands, units, HTTP status codes and raw diagnostic values. Animation display names translate in place; theme IDs and CLI parameters do not change.
|
|
487
540
|
|
|
488
|
-
The transparent, single-color
|
|
541
|
+
The transparent, single-color atom-orbit favicon follows the dashboard's saved light/dark choice without a separate network request.
|
|
489
542
|
|
|
490
|
-
The saved GitHub Copilot account appears immediately to the left of the Status updated time. It uses the same local credentials and fingerprint-bound identity metadata as `ccdx auth status`, with username (or numeric ID fallback) and a `SAVED` label; this is not an online entitlement check. Missing, invalid, unidentified, or unreadable credentials are shown explicitly. The account read runs
|
|
543
|
+
The saved GitHub Copilot account appears immediately to the left of the Status updated time. It uses the same local credentials and fingerprint-bound identity metadata as `ccdx auth status`, with username (or numeric ID fallback) and a `SAVED` label; this is not an online entitlement check. Missing, invalid, unidentified, or unreadable credentials are shown explicitly. The account read runs on page load, top Refresh and visible-page automatic updates, independently of adapter status and without upstream authentication calls. Its timestamp is in the account tooltip; failed updates retain the prior account and explicitly label the failure. Its loopback-only, custom-header-protected API exposes no token, fingerprint, credential path, or raw metadata. The general status endpoint retains its existing identity-free contract.
|
|
491
544
|
|
|
492
545
|
Account names containing underscores are supported, including `dingxiao_microsoft`. A numeric ID is a fallback, not a replacement for an available, safely displayable username; the existing length bounds and credential-shaped text suppression still apply.
|
|
493
546
|
|
|
494
547
|
The language button immediately right of the appearance button switches between English and Simplified Chinese. English remains the default; the choice is saved only in the current browser, separately from light/dark mode. Switching translates the existing page in place: it does not fetch API data, rebuild charts, change selected filters, discard unsaved animation choices, or reset expanded failure details. Static labels, live status text, chart tooltips and accessibility labels follow the selected language. Model IDs, account names, dates, numeric values and upstream diagnostic prose stay unchanged; copied diagnostic fields retain their original names and values. The local translation asset adds no dependency, external service, polling or inference-path work.
|
|
495
548
|
|
|
496
|
-
Usage Trends is collapsed by default. Opening it adds daily input/output token bars (7/30/90 days) and a 365-day calendar of recorded usage calls or tokens, grouped in the browser's time zone. Cache-read tokens are already part of input and are not added again. Model and range filters use the current snapshot without additional requests; selecting a day shows its filtered model totals in the Model Usage table, and Show all restores the original table. Analytics shares the existing current/rotated-log scan and exposes only bounded metadata (365 days, up to 100 model filters). Days before retained history are hatched, not presented as zero; the oldest retained day may be partial. Counts describe retained usage records, not messages, session time, or all HTTP requests.
|
|
549
|
+
Usage Trends is collapsed by default. Opening it adds daily input/output token bars (7/30/90 days) and a 365-day calendar of recorded usage calls or tokens, grouped in the browser's time zone. Cache-read tokens are already part of input and are not added again. Model and range filters use the current snapshot without additional requests; selecting a day shows its filtered model totals in the Model Usage table, and Show all restores the original table. Analytics shares the existing current/rotated-log scan and exposes only bounded metadata (365 days, up to 100 model filters). Days before retained history are hatched, not presented as zero; the oldest retained day may be partial. Counts describe retained usage records, not messages, session time, or all HTTP requests. Open-section, manual and visible-page automatic refresh update the snapshot. Analytics are requested only while expanded inside the open usage section or while a day filter needs them. Filters and selected dates survive refresh; a closed unfiltered chart reuses its displayed data until reopened. There is no server background collection.
|
|
497
550
|
|
|
498
551
|
Terminal Animation is collapsed at the bottom of the page, with an Animation shortcut in the header. Preview frames load only when opened; closing it, hiding the page, or requesting reduced motion stops the preview timer. Unsaved choices survive folding and reopening. Recent response failures expand to diagnostic fields (time, model, code, message, response/request IDs, and retry policy) with a Copy details control. The view combines the last 10 retained `response.failed` events with failures from the 20 most recently finished Responses/compact requests, showing at most 10 entries. Matching local request IDs attach the final outcome and timing metadata, so a recovered event can show `completed`; an uncorrelated retry attempt does not prove recovery. Transport failures and incomplete/cancelled requests can appear without a `response.failed` event. These are bounded runtime observations, not complete session histories. Diagnostic prose is redacted by the existing recorder but can still contain sensitive context: review before copying or sharing.
|
|
499
552
|
|
package/package.json
CHANGED
package/src/adapter.mjs
CHANGED
|
@@ -63,7 +63,7 @@ export {
|
|
|
63
63
|
} from "./responses-request.mjs";
|
|
64
64
|
|
|
65
65
|
const ADAPTER_RUNTIME_CONFIG = loadRuntimeConfig();
|
|
66
|
-
const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/ui.js"]);
|
|
66
|
+
const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/ui.js"]);
|
|
67
67
|
const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth"]);
|
|
68
68
|
|
|
69
69
|
export function requestPath(reqUrl) {
|
|
@@ -72,53 +72,82 @@ export function selectCopilotResponseRetry(
|
|
|
72
72
|
return null;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// Preserve the synchronous selector contract; disk recovery is an explicitly
|
|
76
|
+
// injected, asynchronous capability at the HTTP boundary, never a blanket retry.
|
|
77
|
+
export async function selectCopilotResponseRetryWithHistory(reqContext, statusCode, errorText, usedPolicies = new Set(), options = {}) {
|
|
78
|
+
try { return selectCopilotResponseRetry(reqContext, statusCode, errorText, usedPolicies); }
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (error.code !== "ccdx_history_rebuild_required" || !options.restorePlaintextHistory) throw error;
|
|
81
|
+
let restored;
|
|
82
|
+
try { restored = await options.restorePlaintextHistory(reqContext, { reserveHistory: options.reserveHistory }); }
|
|
83
|
+
catch (failure) {
|
|
84
|
+
options.assertPrepareActive?.();
|
|
85
|
+
if (options.signal?.aborted) throw options.signal.reason || failure;
|
|
86
|
+
const reason = /^[a-z][a-z_]{1,60}$/.test(failure.code || "") ? failure.code : "local_history_unavailable";
|
|
87
|
+
error.jsonBody.error.recovery.local_status = reason;
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
usedPolicies.add("encrypted-connection-rejected");
|
|
91
|
+
return { ...restored, policyId: "encrypted-connection-rejected", usedPolicies,
|
|
92
|
+
warning: "saved compaction rejected; retrying once with verified complete local plaintext history" };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
75
96
|
export async function openCopilotResponse(reqContext, upstream = copilotResponses, options = {}) {
|
|
76
97
|
const usedPolicies = options.usedRetryPolicies || new Set();
|
|
77
98
|
let payloadPrepared = false;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
99
|
+
let releaseRecovery;
|
|
100
|
+
try {
|
|
101
|
+
for (let attempt = 0; attempt <= RETRY_POLICIES.length; attempt += 1) {
|
|
102
|
+
let resp;
|
|
103
|
+
try {
|
|
104
|
+
options.assertPrepareActive?.();
|
|
105
|
+
resp = await upstream(reqContext.body, {
|
|
106
|
+
assertActive: options.assertPrepareActive,
|
|
107
|
+
signal: options.signal,
|
|
108
|
+
currentInputStart: reqContext.currentInputStart,
|
|
109
|
+
onUpstreamStart: options.onUpstreamStart,
|
|
110
|
+
payloadPrepared,
|
|
111
|
+
});
|
|
112
|
+
} finally { releaseRecovery?.();releaseRecovery = null; }
|
|
113
|
+
markUpstreamHeaders();
|
|
114
|
+
options.assertPrepareActive?.();
|
|
115
|
+
payloadPrepared = true;
|
|
116
|
+
if (resp.ok) {
|
|
117
|
+
reqContext = finalizeEncryptedHistoryRebase(reqContext);
|
|
118
|
+
return { resp, reqContext, usedRetryPolicies: usedPolicies };
|
|
119
|
+
}
|
|
94
120
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
const errorText = await readBoundedResponseText(resp, {
|
|
122
|
+
maxBytes: MAX_UPSTREAM_ERROR_BODY_BYTES,
|
|
123
|
+
label: "Copilot Responses error body",
|
|
124
|
+
});
|
|
125
|
+
options.assertPrepareActive?.();
|
|
126
|
+
let retry;
|
|
127
|
+
try { retry = await selectCopilotResponseRetryWithHistory(reqContext, resp.status, errorText, usedPolicies, options); }
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (error.code === "ccdx_history_rebuild_required") {
|
|
130
|
+
const details = responseFailureDetails({ error: error.jsonBody.error }, "upstream.http_error", {
|
|
131
|
+
model: reqContext.body.model, headers: resp.headers, retrySkipped: error.code });
|
|
132
|
+
error.jsonBody.error.upstream_request_id = details.upstream_request_id;
|
|
133
|
+
options.responseFailures?.record?.({ ...details, recovery: error.jsonBody.error.recovery });
|
|
134
|
+
}
|
|
135
|
+
throw error;
|
|
108
136
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
137
|
+
releaseRecovery = retry?.releasePreparation;
|
|
138
|
+
if (retry?.policyId === "encrypted-connection-rejected") {
|
|
139
|
+
options.responseFailures?.record?.({ ...responseFailureDetails(JSON.parse(errorText), "upstream.http_error", {
|
|
140
|
+
model: reqContext.body.model, headers: resp.headers, retried: true, retryPolicy: retry.policyId }),
|
|
141
|
+
recovery: retry.recovery });
|
|
142
|
+
}
|
|
143
|
+
if (retry) {
|
|
144
|
+
reqContext = retry.reqContext;
|
|
145
|
+
if (retry.recovery?.source === "local_codex_rollout") payloadPrepared = false;
|
|
146
|
+
console.warn(status("warn", retry.warning));
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
return { resp, reqContext, errorText, usedRetryPolicies: usedPolicies };
|
|
120
150
|
}
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
throw httpError("Responses compatibility retry limit exceeded", 502);
|
|
151
|
+
throw httpError("Responses compatibility retry limit exceeded", 502);
|
|
152
|
+
} finally { releaseRecovery?.(); }
|
|
124
153
|
}
|
package/src/dashboard/index.html
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
<script src="/language.js"></script>
|
|
9
9
|
<script src="/theme.js"></script>
|
|
10
10
|
<link rel="stylesheet" href="/ui.css">
|
|
11
|
+
<script src="/refresh.js" defer></script>
|
|
11
12
|
<script src="/ui.js" defer></script>
|
|
12
13
|
<title data-i18n>CCDX · Local dashboard</title>
|
|
13
14
|
</head>
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
<div class="shell">
|
|
16
17
|
<header class="topbar">
|
|
17
18
|
<div class="brand">CCDX <span class="brand-detail" data-i18n>/ LOCAL STATUS</span></div>
|
|
18
|
-
<div class="topbar-actions"><span id="connection" class="badge neutral" role="status" data-i18n>READING</span><button id="theme-toggle" class="icon-button" type="button" aria-label="Switch to light mode" title="Switch to light mode"><svg class="icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"/></svg><svg class="icon-moon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false"><path d="M12 3A9 9 0 1 0 21 12 7 7 0 0 1 12 3Z"/></svg></button><button id="language-toggle" class="icon-button language-button" type="button" aria-label="Switch to Chinese" title="Switch to Chinese">中文</button><button id="open-animation" type="button" aria-controls="animation-settings" aria-expanded="false" data-i18n>Animation</button><button id="refresh" type="button" data-i18n>Refresh</button></div>
|
|
19
|
+
<div class="topbar-actions"><span id="connection" class="badge neutral" role="status" data-i18n>READING</span><button id="theme-toggle" class="icon-button" type="button" aria-label="Switch to light mode" title="Switch to light mode"><svg class="icon-sun" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"/></svg><svg class="icon-moon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false"><path d="M12 3A9 9 0 1 0 21 12 7 7 0 0 1 12 3Z"/></svg></button><button id="language-toggle" class="icon-button language-button" type="button" aria-label="Switch to Chinese" title="Switch to Chinese">中文</button><button id="open-animation" type="button" aria-controls="animation-settings" aria-expanded="false" data-i18n>Animation</button><button id="auto-refresh" type="button" aria-pressed="true" data-i18n data-i18n-title title="Every 30 minutes while visible. Open sections update on demand.">Auto refresh</button><button id="refresh" type="button" data-i18n>Refresh</button></div>
|
|
19
20
|
</header>
|
|
20
21
|
|
|
21
22
|
<main>
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
<label><span data-i18n>Activity</span> <select id="analytics-metric"><option value="requests" data-i18n>Calls</option><option value="tokens" data-i18n>Tokens</option></select></label>
|
|
87
88
|
</div>
|
|
88
89
|
<p id="analytics-note" class="table-note" role="status" data-i18n>Open to read retained usage history.</p>
|
|
90
|
+
<p id="analytics-updated" class="refresh-time"></p>
|
|
89
91
|
<div class="chart-heading"><h3 data-i18n>DAILY TOKENS</h3><span data-i18n>INPUT + OUTPUT / CACHE INCLUDED IN INPUT</span></div>
|
|
90
92
|
<div id="daily-bars" class="daily-bars" aria-label="Daily token usage" data-i18n-label></div>
|
|
91
93
|
<div class="daily-axis"><span id="daily-from"></span><span id="daily-to"></span></div>
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
</details>
|
|
110
112
|
</main>
|
|
111
113
|
|
|
112
|
-
<footer data-i18n>LOCAL ONLY /
|
|
114
|
+
<footer data-i18n>LOCAL ONLY / VISIBLE PAGE UPDATES</footer>
|
|
113
115
|
</div>
|
|
114
116
|
</body>
|
|
115
117
|
</html>
|
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
"LOCAL OK": ["LOCAL OK", "本机正常"],
|
|
24
24
|
"UNAVAILABLE": ["UNAVAILABLE", "无法读取"],
|
|
25
25
|
"Refresh": ["Refresh", "刷新"],
|
|
26
|
+
"Auto refresh": ["Auto refresh", "自动更新"],
|
|
27
|
+
"Auto refresh / ON": ["Auto refresh · ON", "自动更新 · 开"],
|
|
28
|
+
"Auto refresh / OFF": ["Auto refresh · OFF", "自动更新 · 关"],
|
|
29
|
+
"Every 30 minutes while visible. Open sections update on demand.": ["Every 30 minutes while visible. Opening a section updates it.", "可见时每30分钟更新。\n展开区域也会更新。"],
|
|
30
|
+
"LOCAL ONLY / VISIBLE PAGE UPDATES": ["LOCAL ONLY / UPDATES WHILE VISIBLE", "仅限本机 / 页面可见时更新"],
|
|
31
|
+
"Updated {time}": ["Updated {time}", "更新于{time}"],
|
|
32
|
+
"Saved account / updated {time}": ["Saved account only / updated {time}", "本机保存账号 / 更新于{time}"],
|
|
33
|
+
"Update failed / last {time}": ["Update failed / last {time}", "更新失败 / 上次{time}"],
|
|
34
|
+
"Update failed": ["Update failed", "更新失败"],
|
|
35
|
+
"GitHub / {account} / UPDATE FAILED": ["GitHub / {account} / UPDATE FAILED", "GitHub / {account} / 更新失败"],
|
|
26
36
|
"Animation": ["Animation", "动效"],
|
|
27
37
|
"Switch to light mode": ["Light mode", "白天模式"],
|
|
28
38
|
"Switch to dark mode": ["Dark mode", "夜间模式"],
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const interval = 30 * 60 * 1000;
|
|
3
|
+
const freshness = 30 * 1000;
|
|
4
|
+
|
|
5
|
+
function createController({ resources, visible, now = Date.now, setTimer = setTimeout, clearTimer = clearTimeout }) {
|
|
6
|
+
const states = new Map(Object.keys(resources).map(key => [key, {
|
|
7
|
+
value: undefined, signature: undefined, variant: undefined, pending: null,
|
|
8
|
+
updatedAt: null, attemptedAt: null, error: null, generation: 0, abort: null,
|
|
9
|
+
}]));
|
|
10
|
+
let timer = null;
|
|
11
|
+
let active = true;
|
|
12
|
+
let automatic = true;
|
|
13
|
+
const state = key => states.get(key);
|
|
14
|
+
const stopTimer = () => { if (timer !== null) clearTimer(timer); timer = null; };
|
|
15
|
+
const notify = key => resources[key].state?.(state(key));
|
|
16
|
+
|
|
17
|
+
function schedule() {
|
|
18
|
+
stopTimer();
|
|
19
|
+
if (!active || !automatic || !visible()) return;
|
|
20
|
+
timer = setTimer(() => {
|
|
21
|
+
timer = null;
|
|
22
|
+
refreshVisible();
|
|
23
|
+
schedule();
|
|
24
|
+
}, interval);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function refresh(key, { force = false } = {}) {
|
|
28
|
+
if (!active) return;
|
|
29
|
+
const resource = resources[key];
|
|
30
|
+
const entry = state(key);
|
|
31
|
+
const variant = resource.variant?.() || "";
|
|
32
|
+
if (entry.pending) {
|
|
33
|
+
const pending = entry.pending;
|
|
34
|
+
const generation = entry.generation;
|
|
35
|
+
if (entry.pendingVariant === variant) return pending;
|
|
36
|
+
await pending;
|
|
37
|
+
if (!active || generation !== entry.generation) return entry.pending;
|
|
38
|
+
return refresh(key, { force: true });
|
|
39
|
+
}
|
|
40
|
+
if (!force && entry.attemptVariant === variant && entry.attemptedAt !== null && now() - entry.attemptedAt < freshness) return entry.value;
|
|
41
|
+
const generation = ++entry.generation;
|
|
42
|
+
const abort = new AbortController();
|
|
43
|
+
entry.abort = abort;
|
|
44
|
+
entry.attemptedAt = now();
|
|
45
|
+
entry.attemptVariant = variant;
|
|
46
|
+
entry.pendingVariant = variant;
|
|
47
|
+
entry.error = null;
|
|
48
|
+
entry.pending = Promise.resolve().then(async () => {
|
|
49
|
+
try {
|
|
50
|
+
const value = await resource.load({ variant, signal: abort.signal });
|
|
51
|
+
if (!active || generation !== entry.generation) return;
|
|
52
|
+
const signature = JSON.stringify(resource.project ? resource.project(value) : value);
|
|
53
|
+
const changed = signature !== entry.signature;
|
|
54
|
+
resource.apply(value, { changed });
|
|
55
|
+
entry.value = value;
|
|
56
|
+
entry.signature = signature;
|
|
57
|
+
entry.variant = variant;
|
|
58
|
+
entry.updatedAt = now();
|
|
59
|
+
return value;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (active && generation === entry.generation) entry.error = error;
|
|
62
|
+
} finally {
|
|
63
|
+
if (generation === entry.generation) {
|
|
64
|
+
entry.pending = null;
|
|
65
|
+
entry.abort = null;
|
|
66
|
+
notify(key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
notify(key);
|
|
71
|
+
return entry.pending;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function refreshVisible({ force = false } = {}) {
|
|
75
|
+
if (!active || !visible()) return Promise.resolve([]);
|
|
76
|
+
return Promise.all(Object.keys(resources).filter(key => resources[key].visible())
|
|
77
|
+
.filter(key => force || state(key).attemptedAt === null || now() - state(key).attemptedAt >= interval)
|
|
78
|
+
.map(key => refresh(key, { force })));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function invalidate(key) {
|
|
82
|
+
const entry = state(key);
|
|
83
|
+
entry.generation += 1;
|
|
84
|
+
entry.abort?.abort();
|
|
85
|
+
entry.pending = null;
|
|
86
|
+
entry.abort = null;
|
|
87
|
+
entry.attemptedAt = null;
|
|
88
|
+
entry.variant = undefined;
|
|
89
|
+
notify(key);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
refresh, refreshVisible, state, invalidate,
|
|
94
|
+
setAutomatic(value) { automatic = value === true; if (automatic) refreshVisible(); schedule(); },
|
|
95
|
+
visibilityChanged() { if (automatic && visible()) refreshVisible(); schedule(); },
|
|
96
|
+
resume() { active = true; if (automatic) refreshVisible(); schedule(); },
|
|
97
|
+
suspend() { active = false; stopTimer(); for (const key of states.keys()) if (state(key).pending) invalidate(key); },
|
|
98
|
+
get automatic() { return automatic; },
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
globalThis.ccdxRefresh = { createController };
|
|
103
|
+
})();
|
package/src/dashboard/theme.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
const applyTheme = () => {
|
|
8
8
|
document.documentElement.dataset.theme = theme;
|
|
9
9
|
const color = theme === "dark" ? "#a6f5a8" : "#176b3a";
|
|
10
|
-
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><
|
|
10
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><g fill="none" stroke="${color}" stroke-width="3" stroke-linecap="round"><ellipse cx="32" cy="32" rx="26" ry="10"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(60 32 32)"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(120 32 32)"/></g><circle cx="32" cy="32" r="4.5" fill="${color}"/></svg>`;
|
|
11
11
|
document.getElementById("favicon").href = `data:image/svg+xml,${encodeURIComponent(svg)}`;
|
|
12
12
|
};
|
|
13
13
|
applyTheme();
|
package/src/dashboard/ui.css
CHANGED
|
@@ -129,7 +129,9 @@ select { max-width: 260px; padding: 5px; font: inherit; color: var(--text); back
|
|
|
129
129
|
.calendar-day[data-level="3"] { background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface)); }
|
|
130
130
|
.calendar-day[data-level="4"] { background: var(--accent-soft); }
|
|
131
131
|
.calendar-day:disabled, .daily-bar:disabled { background: repeating-linear-gradient(135deg, transparent, transparent 3px, var(--border) 3px, var(--border) 4px); opacity: .5; cursor: default; }
|
|
132
|
-
footer { color: var(--footer); font-size: 10px; letter-spacing: .05em; padding: 22px 0 30px; }
|
|
132
|
+
footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color: var(--footer); font-size: 10px; letter-spacing: .05em; padding: 22px 0 30px; }
|
|
133
|
+
#auto-refresh[aria-pressed="false"] { background: transparent; color: var(--muted); border-color: var(--border); }
|
|
134
|
+
.refresh-time { display: block; margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
|
|
133
135
|
@media (max-width: 1000px) { .animation-options { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
134
136
|
@media (max-width: 900px) { .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); } .details { grid-template-columns: repeat(2, minmax(0, 1fr)); } .details .panel:last-child { grid-column: 1 / -1; } }
|
|
135
137
|
@media (max-width: 680px) { .animation-options { grid-template-columns: 1fr; } }
|