codex-copilot-dx 1.2.30 → 1.2.31
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/docs/ARCHITECTURE.md +11 -0
- package/docs/REFERENCE.md +26 -4
- package/package.json +1 -1
- package/src/adapter.mjs +1 -1
- package/src/api-model-display.mjs +3 -1
- package/src/claude-capability-config.mjs +1 -0
- package/src/claude-gateway.mjs +13 -2
- package/src/claude-models.mjs +2 -1
- package/src/client-model-plan.mjs +10 -7
- package/src/connection-runtime.mjs +27 -8
- package/src/dashboard/connections.js +54 -18
- package/src/dashboard/disclosure.js +37 -0
- package/src/dashboard/index.html +6 -3
- package/src/dashboard/language.js +27 -4
- package/src/dashboard/status.js +9 -4
- package/src/dashboard/tools.js +1 -0
- package/src/dashboard/ui.css +13 -2
- package/src/dashboard/ui.js +3 -3
- package/src/dashboard.mjs +1 -0
- package/src/model-display.mjs +9 -0
- package/src/optional-routes.mjs +1 -1
- package/src/provider-metadata.mjs +2 -1
- package/src/providers/api.mjs +1 -1
- package/src/response-failures.mjs +2 -2
package/README.md
CHANGED
|
@@ -11,13 +11,13 @@ npm install -g codex-copilot-dx@latest
|
|
|
11
11
|
ccdx
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.
|
|
14
|
+
No Node or Git? Download [install.sh](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.31/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.31/install.ps1) (Windows), then run `sh install.sh` or `./install.ps1` under your current shell policy. The bootstrap reuses compatible Node/npm or installs verified official Node 24.22.0 privately for CCDX. It adds no Git, compiler or system package manager. It keeps registry/proxy/certificate policy, verifies the Release package and installed runtime, and restores the prior CCDX package if installation fails. Manifest-listed complete packages install their bundled dependencies offline; older source-only releases need the configured registry. See [installation limits and private command paths](docs/REFERENCE.md#install-without-node-or-git).
|
|
15
15
|
|
|
16
16
|
CCDX reuses a compatible local credential or starts GitHub Device Flow, listens on `127.0.0.1:2026`, configures Codex, and opens the App. Interactive desktop starts also open the local WebUI once; use `ccdx --no-browser` or disable this in WebUI settings. No client binary patch is needed. On Windows, open the App manually unless native prediction setup is enabled. In restricted Windows PowerShell, use `npm.cmd` to install and `ccdx.cmd` for the first launch, or run `ccdx.cmd doctor --fix`. Startup, updates and explicit repair remove only CCDX's exact npm-generated `.ps1` launchers so later calls can use `ccdx`. The npm package adds no install hook or policy change; custom launchers are preserved. npm's own script is untouched. The configured `dummy` API key is a placeholder, not a credential.
|
|
17
17
|
|
|
18
18
|
The [local control console](http://127.0.0.1:2026/) separates Overview, Codex/Claude, Model sources, Usage, Requests, Checks & repairs and Settings, with a stable sticky header. Model sources owns API accounts, keys and model capabilities; application pages own visible models and defaults. Settings owns independent web/terminal colors (classic green, Klein blue or Soft pink), startup and updates. Accounts and model catalogs stay with Model sources; client-specific tools stay with their application. CLI remains English; WebUI supports English/Chinese. Codex shows evidenced memory-model dependencies and warns before closing them; native memory settings remain yours. An interactive terminal shows bounded startup checks, source/client state, a usage table with approximate cache hit rate, notices and animation. Plain/NO_COLOR/narrow output remains supported; `--verbose` retains request detail.
|
|
19
19
|
|
|
20
|
-
Requests shows live app/source/model flow above existing summaries and finished records; a thin theme-colored ring rotates around its atom while requests are active. Usage offers animated bars or curves; reduced motion stays static. Hidden pages stop scheduled reads; status refreshes about every two seconds and source/settings evidence about every 16 seconds. Catalogs and retained usage load on demand or every 30 minutes while open. The UI does not add inference calls. Ready means local service availability, not verified model access. First output uses ms, speed token/s, and partial/unknown usage remains explicit. Images/predictions stay opt-in; their first setup uses CLI. 1.2.18 preserves Codex sign-in and unavailable model selections after saving bindings. See the [control reference](docs/REFERENCE.md#control-console-and-online-settings), [1.2.18 fixes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.18.md) and [copy inventory](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/UX_COPY.md).
|
|
20
|
+
Requests shows live app/source/model flow above existing summaries and finished records; a thin theme-colored ring rotates around its atom while requests are active. Usage offers animated bars or curves; reduced motion stays static. Hidden pages stop scheduled reads; status refreshes about every two seconds and source/settings evidence about every 16 seconds. Catalogs and retained usage load on demand or every 30 minutes while open. Disclosures use down/up chevrons with brief rotation and content transitions; reduced-motion mode remains immediate. Saved model selection and configuration-write results are shown separately; writing does not prove that the App has loaded the change. The UI does not add inference calls. Ready means local service availability, not verified model access. First output uses ms, speed token/s, and partial/unknown usage remains explicit. Images/predictions stay opt-in; their first setup uses CLI. 1.2.18 preserves Codex sign-in and unavailable model selections after saving bindings. See the [control reference](docs/REFERENCE.md#control-console-and-online-settings), [1.2.18 fixes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.18.md) and [copy inventory](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/UX_COPY.md).
|
|
21
21
|
|
|
22
22
|
## Commands
|
|
23
23
|
| Command | Purpose |
|
|
@@ -56,7 +56,7 @@ Run `ccdx web` without GitHub sign-in. In **Model sources → Add API**, enter t
|
|
|
56
56
|
|
|
57
57
|
Keys use system credential protection or an explicit environment reference; clients receive separate local credentials. Saving reads model metadata automatically, without inference. Startup and the existing model refresh cycle also refresh enabled APIs when the 30-minute cache expires; failed reads retain saved configuration. Selecting no models pauses access; enable a source and select models to resume. Closed sources can be restored on Model sources; closed apps remain reachable for restoration on their app pages. Pinned streams finish on their original source. The version-two graph preserves old single-source visibility and saves a byte-for-byte v1 backup before migration. User and managed client settings remain protected. Refreshing GitHub models also updates Codex candidates without changing saved selections or native sign-in.
|
|
58
58
|
|
|
59
|
-
Model lists/details preserve the upstream maker declaration separately from your API source name. Missing maker metadata shows Not provided; model names are never used to guess a maker. Maker evidence
|
|
59
|
+
Model lists/details preserve the upstream maker declaration separately from your API source name. Missing maker metadata shows Not provided; model names are never used to guess a maker. Maker and display-name evidence use a rebuildable cache and do not change the strict connection schema or routing identity. Names follow upstream display name, upstream name, then model ID. Claude compatibility aliases remain internal; mixed sources retain their original visible names regardless of the default source. Closing a source previews all selected consumers, including nondefault models. First-time API setup uses **Save & read models** and keeps the model editor open, including after a failed lookup. Model details show upstream capabilities per API, with optional manual overrides collapsed below. Context, input/output limits, reasoning levels, thinking modes, input types, tools and native search are deployment-specific. Structured Anthropic declarations are mapped to Messages; they do not grant the same capabilities to a gateway's other interfaces. Missing and unrecognized metadata are distinguished, without guessing from model names. Manual overrides, including false, take priority. Claude synchronization projects compatible routes, supported host controls and per-model budgets. Unknown or out-of-range windows and unverified client versions are reported as limited; they are not promoted to 1M. Output requests are bounded by declared limits. Compatibility routes do not prove that every model supports every App tool, search or reasoning mode. See the [capability and synchronization limits](docs/REFERENCE.md#model-capabilities-and-claude-synchronization). [1.2.31 changes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.31.md) cover model display, source impact, error evidence and scoped WebUI improvements. Shared GitHub catalogs and the policy-preserving complete-package update fallback remain included. Existing native Codex sign-in/model protections and the 1.2.27 context-preference fix remain included.
|
|
60
60
|
|
|
61
61
|
## Microsoft 365 access
|
|
62
62
|
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -921,3 +921,14 @@ capability absence and protocol discovery remain distinct. Dashed flow motion
|
|
|
921
921
|
uses CSS stroke offset on retained paths; model nodes share the same left edge.
|
|
922
922
|
Geometry and SVG identity reuse from 1.2.23 remain in place, with hidden/stale/
|
|
923
923
|
reduced-motion behavior and summary tables preserved.
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
## Model presentation and shared source impact (1.2.31)
|
|
927
|
+
|
|
928
|
+
`model-display.mjs` is a pure presentation fallback. `api-model-display.mjs` retains bounded upstream names beside maker declarations in the existing revision-bound, rebuildable cache. `providers/api.mjs` exposes that evidence to `client-model-plan.mjs`, which disambiguates presentation independently of route identity. Claude uses labelOverride for client aliases regardless of the default source. No connection-schema or routing-ID migration is introduced. Existing client-file ordering and manual ownership remain authoritative.
|
|
929
|
+
|
|
930
|
+
The connection snapshot's read-only source_impacts reports actual selected consumers, removed/remaining selection counts, and default-replacement needs. Both source-close validation and the WebUI use that result; the default source alone never represents every selected deployment. An optional impact_revision protects new WebUI confirmations while preserving existing programmatic command compatibility. Settings writes remain serialized and revision checked. Source identity changes also invalidate confirmation.
|
|
931
|
+
|
|
932
|
+
Unknown client capability adapters preserve existing shared settings and report their limitation. The presentation schema and protocol capability evidence do not share an enable gate. HTTP-200 error envelopes and native SSE errors feed the existing bounded diagnostics as model.error; transport bytes and retry policies remain unchanged.
|
|
933
|
+
|
|
934
|
+
`dashboard/disclosure.js` is optional progressive enhancement of native details/summary. It uses cancellable opacity/transform animations, CSS chevrons independent of translated DOM text, and no polling/height animation. Reduced motion and hidden documents finish immediately. A resource integration test covers every script/style referenced by the shell. Flow regression measures layout reads and DOM identity under elapsed-only updates; existing geometry caches, list limits and visibility gates remain the performance mechanism.
|
package/docs/REFERENCE.md
CHANGED
|
@@ -7,8 +7,11 @@ Claude gateway and an explicitly selected Codex backup.
|
|
|
7
7
|
## Manual APIs and client access
|
|
8
8
|
|
|
9
9
|
`ccdx web` starts management without GitHub sign-in or automatic App launch.
|
|
10
|
-
Use **Model sources → Add API**,
|
|
11
|
-
(including a required prefix such as `/v1`), then
|
|
10
|
+
Use **Model sources → Add API**, enter the HTTPS API base address/key
|
|
11
|
+
(including a required prefix such as `/v1`), then choose **Save & read models**.
|
|
12
|
+
The saved source remains available and the editor stays open for model selection.
|
|
13
|
+
A failed directory read keeps the source and draft; retry with **Read models**
|
|
14
|
+
under the existing request-coalescing and cooldown policy.
|
|
12
15
|
Select the models to use and their supported interfaces, save, then choose each
|
|
13
16
|
client's visible models and default on **Codex** or **Claude**. Unselected catalog entries
|
|
14
17
|
are not saved. A selected model needs at least one interface; choosing an
|
|
@@ -1347,7 +1350,7 @@ Unknown support prevents an explicitly requested exception from starting.
|
|
|
1347
1350
|
For an older updater that still requires Git, install the Release tarball directly:
|
|
1348
1351
|
|
|
1349
1352
|
```sh
|
|
1350
|
-
npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.
|
|
1353
|
+
npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.31/codex-copilot-dx-1.2.31.tgz
|
|
1351
1354
|
# Windows PowerShell: use npm.cmd instead of npm.
|
|
1352
1355
|
```
|
|
1353
1356
|
|
|
@@ -2279,7 +2282,7 @@ intermediate proxy honored revalidation.
|
|
|
2279
2282
|
|
|
2280
2283
|
### Upstream maker metadata
|
|
2281
2284
|
|
|
2282
|
-
Manual API discovery accepts bounded text from publisher, vendor and
|
|
2285
|
+
Manual API discovery accepts bounded text from publisher, vendor, owned_by, display_name and name.
|
|
2283
2286
|
The model maker shown in lists/details prefers publisher, then vendor; owned_by
|
|
2284
2287
|
is shown separately as ownership and is not treated as the maker. Absent maker
|
|
2285
2288
|
information is Not provided; no name-based inference is performed. These are
|
|
@@ -2340,3 +2343,22 @@ remain distinct.
|
|
|
2340
2343
|
API transport errors retain fixed safe code, DNS/connect/TLS/request/response
|
|
2341
2344
|
phase and reused-socket state in HTTP diagnostics. They do not retain raw
|
|
2342
2345
|
exceptions or URLs, and do not trigger automatic POST or cross-source retries.
|
|
2346
|
+
|
|
2347
|
+
|
|
2348
|
+
### Model presentation and source impact (1.2.31)
|
|
2349
|
+
|
|
2350
|
+
Model upstream IDs, source-qualified routes and client aliases retain their existing identities. Presentation follows a valid upstream display_name, then name, then the upstream ID. The shared client plan adds a source suffix only for ambiguous display labels; same-source display collisions include the upstream ID. No capability or backend identity is inferred from a name. The display cache stays separate from connection v2 and is bound to the source deployment revision. Display-only changes invalidate the client plan and reconcile selected consumers without changing their grants or defaults. Claude configuration uses labelOverride even when a mixed binding's default source is not an API. Existing client list order, user context preferences and configuration ownership are retained. The gateway directory and written configuration share display labels; user-preserved ordering is not replaced with a vendor-family ranking.
|
|
2351
|
+
|
|
2352
|
+
Application pages distinguish saved selections from configuration-write results. A written configuration is not evidence that an already running App adopted it. Reopen the client to load changes. Manual-sync settings, preserved fields, missing defaults and failed writes retain separate statuses. When client capability controls are unverified, existing shared capability settings are kept; this does not assert support for those controls in the new version.
|
|
2353
|
+
|
|
2354
|
+
Closing a source reviews selected deployments for every enabled app, including nondefault and temporarily unavailable selections. The preview reports selected-model counts and whether the default needs replacement. A still-valid default stays unchanged. Losing the default or the last selection requires an explicit replacement or pause through the existing access semantics. The WebUI submits an impact revision; changes to bindings or source identity invalidate that confirmation. Mere authorization without selected models is not counted as model consumption.
|
|
2355
|
+
|
|
2356
|
+
### Disclosure motion and scoped interface changes (1.2.31)
|
|
2357
|
+
|
|
2358
|
+
Native details/summary controls use one theme-colored SVG chevron: down while closed, up while open. Rotation takes 160 ms; visible content uses a 160 ms opening and 110 ms closing opacity/translation transition, without height animation. Keyboard activation, cancellation by rapid toggling, translated summaries and dynamically inserted disclosures remain supported. Reduced-motion mode uses native immediate toggles, and backgrounding finishes pending transitions. The animation script is a versioned same-origin dashboard asset.
|
|
2359
|
+
|
|
2360
|
+
The existing palettes, sidebar, atom, solid selected controls and usage views remain. All retained usage totals, source/model filters, 7/30/90-day trends, bar/line views and 365-day activity are retained. Checks hide the empty results header until results exist. Animation style has one specific disclosure title; saved/effective differences are expressed on one line. Coarse-pointer switch labels and toolbar icon targets expand without enlarging the drawn switches.
|
|
2361
|
+
|
|
2362
|
+
### Successful HTTP transport carrying model errors (1.2.31)
|
|
2363
|
+
|
|
2364
|
+
A native Messages JSON error envelope under HTTP 200, or an SSE error event under a successful HTTP status, is recorded as model.error with the original HTTP status and a bounded structured error code/type. Existing failed-model accounting remains. The original response bytes/status are preserved; no automatic retry or replay is added. Normal output carrying incidental error-like fields is not reclassified. Token-count errors remain in their separate capability category. Request issue summaries lead with known plain-language causes, while technical codes, IDs, original diagnostic fields and clipboard export remain available in details.
|
package/package.json
CHANGED
package/src/adapter.mjs
CHANGED
|
@@ -419,7 +419,7 @@ export function createAdapterHandler(options = {}) {
|
|
|
419
419
|
const finishRequest = ({ statusCode = 0, aborted = false } = {}) => {
|
|
420
420
|
if (requestFinished) return;
|
|
421
421
|
requestFinished = true;
|
|
422
|
-
if (trackRequest && statusCode >= 400) {
|
|
422
|
+
if (trackRequest && (statusCode >= 400 || httpEvidence.model_error === true)) {
|
|
423
423
|
try { httpErrors.record(buildHttpFailureDetails({ ...httpEvidence, statusCode, route: routeName, requestId, model: context?.model || context?.requestedModel,
|
|
424
424
|
method: ["GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "PATCH"].includes(req.method) ? req.method : "OTHER",
|
|
425
425
|
target: ["/v1/responses", "/v1/responses/compact", "/anthropic/v1/messages", "/anthropic/v1/messages/count_tokens", "/anthropic/v1/models", "/mcp/image", "/.well-known/oauth-authorization-server", "/.well-known/oauth-protected-resource", "/.well-known/oauth-protected-resource/mcp/image"].includes(pathname) ? pathname : "unrecognized_path",
|
|
@@ -6,7 +6,7 @@ import { atomicWriteFileSync } from "./atomic-file.mjs";
|
|
|
6
6
|
import { redactDiagnosticText } from "./diagnostic-text.mjs";
|
|
7
7
|
|
|
8
8
|
export function apiModelDisplay(model) {
|
|
9
|
-
return Object.fromEntries(["publisher", "vendor", "owned_by"].flatMap(key => {
|
|
9
|
+
return Object.fromEntries(["publisher", "vendor", "owned_by", "display_name", "name"].flatMap(key => {
|
|
10
10
|
const value = model?.[key];
|
|
11
11
|
return typeof value === "string" && value.trim() && value.length <= 160
|
|
12
12
|
&& !/[\u0000-\u001f\u007f\u202a-\u202e\u2066-\u2069]/.test(value) && redactDiagnosticText(value) === value ? [[key, value.trim()]] : [];
|
|
@@ -41,7 +41,9 @@ export function createApiModelDisplayStore(options = {}) {
|
|
|
41
41
|
const value = { version: 1, revision, models: models.map(model => ({ id: model.id, ...apiModelDisplay(model.display) })) };
|
|
42
42
|
const checked = validate(value, revision), text = JSON.stringify(value) + "\n";
|
|
43
43
|
if (!checked || Buffer.byteLength(text) > 512 * 1024) throw Error("Invalid model display cache");
|
|
44
|
+
const changed = JSON.stringify([...(read(id, revision) || [])]) !== JSON.stringify([...checked]);
|
|
44
45
|
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });atomicWriteFileSync(file(id), text, { mode: 0o600 });cache.set(id, { revision, models: checked });while (cache.size > 16) cache.delete(cache.keys().next().value);
|
|
46
|
+
return changed;
|
|
45
47
|
},
|
|
46
48
|
};
|
|
47
49
|
}
|
|
@@ -53,6 +53,7 @@ export function claudeSharedCapabilityPlan({ app = [], code = [], support = {} }
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export function syncClaudeCapabilities(plan, options = {}) {
|
|
56
|
+
if (plan.limitations?.some(item => item.code === "client_version_unknown")) return { state: "partially_preserved", changed: false, preserved: 0, restart_required: false };
|
|
56
57
|
const paths = claudeClientPaths(options), env = options.env || process.env;
|
|
57
58
|
let current = {};try { current = JSON.parse(readBoundedFileSync(paths.code, { maxBytes: 1024 * 1024, encoding: "utf8" })); }
|
|
58
59
|
catch (error) { if (error.code !== "ENOENT") throw error; }
|
package/src/claude-gateway.mjs
CHANGED
|
@@ -178,13 +178,20 @@ export function createClaudeGatewayHandler({ provider, apiKey, desktopAliases =
|
|
|
178
178
|
const raw = await readBoundedResponseText(upstream, { maxBytes: upstream.ok ? config.maxUpstreamResponsesResponseBytes : MAX_UPSTREAM_ERROR_BODY_BYTES,
|
|
179
179
|
label: "Claude gateway response", signal: abort.signal });
|
|
180
180
|
let value;try { value = JSON.parse(raw); } catch {}
|
|
181
|
+
const modelFailure = upstream.ok && (!value?.type || value.type === "error") && value?.error && typeof value.error === "object" && !Array.isArray(value.error)
|
|
182
|
+
&& ["code", "type", "message"].some(key => typeof value.error[key] === "string" && value.error[key].trim())
|
|
183
|
+
&& !["content", "output", "choices", "candidates"].some(key => Array.isArray(value[key]) && value[key].length);
|
|
184
|
+
if (modelFailure) {
|
|
185
|
+
const evidence = upstreamErrorEvidence(raw);
|
|
186
|
+
context.onHttpError?.({ ...evidence, code: evidence.code || evidence.error_type || "upstream_error", model_error: true, origin: "upstream_response", headers: upstream.headers });
|
|
187
|
+
}
|
|
181
188
|
if (!upstream.ok) context.onHttpError?.({ ...upstreamErrorEvidence(raw),
|
|
182
189
|
origin: context.countObservation?.cached ? "capability_cache" : "upstream_http", headers: upstream.headers });
|
|
183
190
|
if (!countTokens && upstream.ok && value?.type === "message" && Array.isArray(value.content)) {
|
|
184
191
|
if (value.content.some(hasMessageState)) conversation?.commit?.({ tool: value.content.some(block => block?.type === "tool_use") });
|
|
185
192
|
model = value.model || model;responseId = value.id;usage = value.usage;stopReason = value.stop_reason;
|
|
186
193
|
sawStop = typeof stopReason === "string";outcome = stopReason === "max_tokens" ? "incomplete" : sawStop ? "completed" : "failed";
|
|
187
|
-
} else if (countTokens && upstream.ok) outcome = "completed";
|
|
194
|
+
} else if (countTokens && upstream.ok && !modelFailure) outcome = "completed";
|
|
188
195
|
const outgoing = clientModel && !countTokens && upstream.ok && value?.type === "message" ? JSON.stringify({ ...value, model: clientModel }) : raw;
|
|
189
196
|
if (!res.destroyed && !res.writableEnded) { res.writeHead(upstream.status, headers);res.end(outgoing); }
|
|
190
197
|
} else {
|
|
@@ -192,7 +199,11 @@ export function createClaudeGatewayHandler({ provider, apiKey, desktopAliases =
|
|
|
192
199
|
abort.setTimeout(config.streamIdleTimeoutMs, "stream_idle_timeout");
|
|
193
200
|
res.writeHead(upstream.status, { ...headers, "Cache-Control": "no-cache" });
|
|
194
201
|
const observer = createMessagesObserver(event => {
|
|
195
|
-
if (event.type === "error") {
|
|
202
|
+
if (event.type === "error") {
|
|
203
|
+
failedEvent = true;outcome = "failed";
|
|
204
|
+
const evidence = upstreamErrorEvidence(JSON.stringify(event));
|
|
205
|
+
context.onHttpError?.({ ...evidence, code: evidence.code || evidence.error_type || "upstream_error", model_error: true, origin: "upstream_event", headers: upstream.headers });return;
|
|
206
|
+
}
|
|
196
207
|
if (sawStop || failedEvent) return;
|
|
197
208
|
if (event.type === "content_block_start" && hasMessageState(event.content_block)
|
|
198
209
|
|| event.type === "content_block_delta" && (isMessagesOutputDelta(event.delta) || event.delta?.type === "signature_delta" && event.delta.signature)) conversation?.commit?.({ tool: event.content_block?.type === "tool_use" });
|
package/src/claude-models.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { modelReasoningEfforts } from "./provider-metadata.mjs";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
+
import { modelDisplayName } from "./model-display.mjs";
|
|
3
4
|
|
|
4
5
|
const EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
5
6
|
|
|
@@ -25,7 +26,7 @@ export function claudeModelEntries(models, { desktopAliases = false } = {}) {
|
|
|
25
26
|
ids.add(name);
|
|
26
27
|
const advertised = model.capability?.values.reasoning === false ? [] : model.capability?.values.reasoning_efforts || modelReasoningEfforts(model);
|
|
27
28
|
const maxEffort = EFFORTS.filter(value => advertised?.includes(value)).at(-1);
|
|
28
|
-
return { name, ...(model.display_name ||
|
|
29
|
+
return { name, ...(model.display_name || name !== claudeClientModelId(model.id) ? { labelOverride: modelDisplayName(model) } : {}),
|
|
29
30
|
...(model.capability?.values.context_window >= 1000000 ? { supports1m: true } : {}), ...(maxEffort ? { maxEffort } : {}) };
|
|
30
31
|
});
|
|
31
32
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { deploymentModelId, resolveModelCapabilities } from "./model-capabilities.mjs";
|
|
2
2
|
import { claudeModelEntries } from "./claude-models.mjs";
|
|
3
3
|
import { claudeDeploymentId, claudeRouteAliases } from "./clients/claude-models.mjs";
|
|
4
|
+
import { modelDisplayName } from "./model-display.mjs";
|
|
4
5
|
|
|
5
6
|
const endpoints = { codex: ["/responses", "/v1/responses"], claude_app: ["/v1/messages"], claude_code: ["/v1/messages"] };
|
|
6
7
|
export function sourceModels(source, client) {
|
|
@@ -15,23 +16,25 @@ export function compileClientModels({ client, binding, source, enabled, names =
|
|
|
15
16
|
if (!binding.enabled) return { models: [], routes: new Map(), defaultModel: null, revision: "disabled" };
|
|
16
17
|
const explicit = Array.isArray(binding.deployments), selected = explicit ? binding.deployments : binding.source
|
|
17
18
|
? sourceModels(source(binding.source), client).map(model => ({ source: binding.source, model: model.id })) : [];
|
|
18
|
-
const models = [], routes = new Map(), raw = new Map(), catalogs = new Map(), available = [], counts = new Map();
|
|
19
|
+
const models = [], routes = new Map(), raw = new Map(), catalogs = new Map(), available = [], counts = new Map(), labels = new Map(), sourceLabels = new Map();
|
|
19
20
|
for (const item of selected) {
|
|
20
21
|
if (!binding.allowed.includes(item.source) || !enabled(item.source)) continue;
|
|
21
22
|
const provider = source(item.source);
|
|
22
23
|
if (!catalogs.has(provider)) catalogs.set(provider, new Map(sourceModels(provider, client).map(model => [model.id, model])));
|
|
23
24
|
const model = catalogs.get(provider).get(item.model);
|
|
24
25
|
if (!model || model.policy?.state && model.policy.state !== "enabled" || model.model_picker_enabled === false) continue;
|
|
25
|
-
|
|
26
|
+
const label = modelDisplayName(model), sourceName = names[item.source] || provider.name || ({ github: "GitHub Copilot", m365: "Microsoft 365" })[item.source] || item.source;
|
|
27
|
+
const key = JSON.stringify([label, sourceName]);
|
|
28
|
+
available.push({ item, provider, model, label, sourceName, key, route: deploymentModelId(item.source, model.id) });counts.set(model.id, (counts.get(model.id) || 0) + 1);
|
|
29
|
+
labels.set(label, (labels.get(label) || 0) + 1);sourceLabels.set(key, (sourceLabels.get(key) || 0) + 1);
|
|
26
30
|
}
|
|
27
31
|
const routeIds = new Set(available.map(entry => entry.route));
|
|
28
|
-
for (const { item, provider, model, route } of available) {
|
|
32
|
+
for (const { item, provider, model, route, label, sourceName, key } of available) {
|
|
29
33
|
const capability = model.capability || resolveModelCapabilities(model, { builtin: true });
|
|
30
|
-
const sourceName = names[item.source] || provider.name || ({ github: "GitHub Copilot", m365: "Microsoft 365" })[item.source] || item.source;
|
|
31
34
|
const ambiguous = counts.get(model.id) > 1;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const display = sourceLabels.get(key) > 1 ? `${label} · ${sourceName} (${model.id})` : labels.get(label) > 1 ? `${label} · ${sourceName}` : label;
|
|
36
|
+
const entry = { ...model, display_name: display, capability, source_id: item.source, source_name: sourceName, route_id: route,
|
|
37
|
+
...(explicit ? { client_id: client === "codex" && !ambiguous && !routeIds.has(model.id) ? model.id : route } : {}) };
|
|
35
38
|
if (client === "claude_app" && explicit) entry.client_id = claudeDeploymentId(entry, route, { desktopEffortAliases });
|
|
36
39
|
const publicId = explicit ? entry.client_id : client === "codex" ? model.id : claudeModelEntries([entry], { desktopAliases: client === "claude_app" && provider.id.startsWith("api_") })[0].name;
|
|
37
40
|
entry.public_id = publicId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { randomBytes, createHash } from "node:crypto";
|
|
3
3
|
import { accessSettingsPath, readAccessSettings, updateAccessSettings, checkedApi, checkedAccessSettings, accessError, CLIENT_IDS, CLIENT_NAMES } from "./access-settings.mjs";
|
|
4
4
|
import { createApiSecretStore, checkedApiKey } from "./api-secrets.mjs";
|
|
5
5
|
import { createApiCatalogRefresh } from "./api-catalog-refresh.mjs";
|
|
@@ -145,11 +145,25 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
145
145
|
], clients: CLIENT_IDS.map(id => ({ id, name: CLIENT_NAMES[id], ...config.clients[id], setup: setup[id] || null,
|
|
146
146
|
...(id === "codex" ? { memory_model: memoryModel.snapshot() } : {}),
|
|
147
147
|
observed_at: lastClients[id] || null, ...(compact ? {} : { model_plan: { default_model: plan(id).defaultModel, default_unavailable: plan(id).defaultUnavailable,
|
|
148
|
-
models: plan(id).models.map(model => ({ source: model.source_id, id: model.id, public_id: model.public_id, route_id: model.route_id, capability: model.capability })),
|
|
148
|
+
models: plan(id).models.map(model => ({ source: model.source_id, id: model.id, display_name: model.display_name, public_id: model.public_id, route_id: model.route_id, capability: model.capability })),
|
|
149
149
|
unavailable: (config.clients[id].deployments || []).filter(item => !plan(id).models.some(model => model.source_id === item.source && model.id === item.model))
|
|
150
150
|
.map(item => ({ source: item.source, id: item.model, route_id: deploymentModelId(item.source, item.model) })),
|
|
151
151
|
available: config.clients[id].allowed.filter(enabled).flatMap(source => sourceModels(getSource(source), id).map(model => ({ source, id: model.id,
|
|
152
|
-
route_id: deploymentModelId(source, model.id), capability: model.capability || resolveModelCapabilities(model, { builtin: true }) }))), sync: sharedSync, support: capabilitySupport } }) })),
|
|
152
|
+
display_name: model.display_name || model.name || model.id, route_id: deploymentModelId(source, model.id), capability: model.capability || resolveModelCapabilities(model, { builtin: true }) }))), sync: sharedSync, support: capabilitySupport } }) })),
|
|
153
|
+
...(!compact ? { source_impacts: Object.fromEntries(["github", "m365", ...config.apis.map(api => api.id)].map(id => [id, sourceImpact(id)])) } : {}), managed, m365_state: state.m365.state });
|
|
154
|
+
}
|
|
155
|
+
function sourceImpact(source) {
|
|
156
|
+
const clients = CLIENT_IDS.flatMap(id => {
|
|
157
|
+
const c = binding(id);if (!c.enabled) return [];
|
|
158
|
+
const explicit = Array.isArray(c.deployments), removed = explicit ? c.deployments.filter(item => item.source === source) : [];
|
|
159
|
+
if (explicit ? !removed.length : c.source !== source) return [];
|
|
160
|
+
const remaining = explicit ? c.deployments.length - removed.length : 0;
|
|
161
|
+
const defaultSource = plan(id).routes.get(c.default_model)?.source || removed.find(item => deploymentModelId(source, item.model) === c.default_model)?.source || c.source;
|
|
162
|
+
const default_affected = defaultSource === source;
|
|
163
|
+
return [{ id, removed: explicit ? removed.length : sourceModels(getSource(source), id).length, remaining, default_affected, needs_replacement: default_affected || remaining === 0 }];
|
|
164
|
+
});
|
|
165
|
+
const api = settings.apis.find(item => item.id === source), profile = api ? deploymentRevision(api, env) : getSource(source)?.profileId();
|
|
166
|
+
return { clients, revision: createHash("sha256").update(JSON.stringify([source, enabled(source), profile, CLIENT_IDS.map(id => binding(id))])).digest("hex") };
|
|
153
167
|
}
|
|
154
168
|
async function syncClients(ids = CLIENT_IDS) {
|
|
155
169
|
if (!ids.length) return;
|
|
@@ -228,18 +242,21 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
228
242
|
const next = editable(), current = next.apis.find(api => api.id === id);
|
|
229
243
|
if (!current?.enabled || deploymentRevision(current, env) !== revision) throw accessError("ccdx_connections_conflict", 409);
|
|
230
244
|
const byId = new Map(models.map(model => [model.id, model]));
|
|
231
|
-
|
|
245
|
+
let displayChanged = false;
|
|
246
|
+
try { displayChanged = modelDisplay.set(id, revision, models); } catch { log("warn", "Model display metadata could not be saved; routing is unchanged"); }
|
|
232
247
|
for (const model of current.models) if (byId.get(model.id)?.metadata) model.metadata = byId.get(model.id).metadata;
|
|
233
248
|
current.checked_at = checkedAt;
|
|
234
|
-
|
|
235
|
-
|
|
249
|
+
const changed = JSON.stringify(current) !== JSON.stringify(settings.apis.find(api => api.id === id));
|
|
250
|
+
if (changed) save(next);
|
|
251
|
+
if (changed || displayChanged) {
|
|
252
|
+
plans.clear();await syncClients(CLIENT_IDS.filter(client => binding(client).source === id || binding(client).deployments?.some(model => model.source === id)));
|
|
236
253
|
}
|
|
237
254
|
}
|
|
238
255
|
function enqueue(work) { operations++;const job = serial.then(work).finally(() => { operations--; });serial = job.catch(() => {});return job; }
|
|
239
256
|
const refreshApis = () => !closed && managed && !preserveClientConfiguration?.() ? catalogRefresh.refreshAll(settings.apis.filter(api => api.enabled).map(api => api.id)) : Promise.resolve();
|
|
240
257
|
async function change(input) {
|
|
241
258
|
if (closed) throw accessError("ccdx_connections_closed", 503);
|
|
242
|
-
if (!validObject(input, ["operation", "id", "config", "key", "allowed", "source", "enabled", "replacements", "model", "auto_review_model", "auto_review_effort", "deployments", "default_model", "auto_sync"])) throw accessError("ccdx_connections_action_invalid");
|
|
259
|
+
if (!validObject(input, ["operation", "id", "config", "key", "allowed", "source", "enabled", "replacements", "impact_revision", "model", "auto_review_model", "auto_review_effort", "deployments", "default_model", "auto_sync"])) throw accessError("ccdx_connections_action_invalid");
|
|
243
260
|
const next = editable();let freshRef, previousRef;
|
|
244
261
|
if (input.operation === "source_access") {
|
|
245
262
|
if (input.id !== "m365" || !Array.isArray(input.allowed) || new Set(input.allowed).size !== input.allowed.length || input.allowed.some(id => !CLIENT_IDS.includes(id))) throw accessError("ccdx_connections_action_invalid");
|
|
@@ -347,7 +364,9 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
347
364
|
if (input.id === "m365" && input.enabled && env.CCDX_M365 === "0") throw accessError("ccdx_provider_environment_disabled", 409);
|
|
348
365
|
if (input.id === "m365" && !input.enabled && legacy.snapshot().m365.claude.requests?.active > 0) throw accessError("ccdx_source_busy", 409);
|
|
349
366
|
if (!input.enabled) {
|
|
350
|
-
const
|
|
367
|
+
const impact = sourceImpact(input.id);
|
|
368
|
+
if (input.impact_revision !== undefined && input.impact_revision !== impact.revision) throw accessError("ccdx_connections_conflict", 409);
|
|
369
|
+
const affected = impact.clients.filter(client => client.needs_replacement).map(client => client.id);
|
|
351
370
|
if (affected.some(id => id !== "codex")) next.claude_private_keys = true;
|
|
352
371
|
if (affected.length && !validObject(input.replacements, affected)) throw accessError("ccdx_source_in_use", 409);
|
|
353
372
|
for (const id of affected) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
let data = null, editing = null, editingClient = null, disabling = null, models = [], selectedModels = new Set(), busy = false, generation = 0;
|
|
5
5
|
let claudeClient = "claude_app", bindingSelection = new Set(), bindingDefault = null, bindingDirty = false;
|
|
6
6
|
let memoryAction = null, memoryOrigin = null;
|
|
7
|
+
let disableRevision = null;
|
|
7
8
|
const drafts = new Map();let editorOrigin = null, discovery = null, desiredSource = null;
|
|
8
9
|
const apiForm = el("connection-api-form"), clientForm = el("connection-client-form");
|
|
9
10
|
const node = (tag, text, className) => { const item = document.createElement(tag);if (text !== undefined) item.textContent = text;if (className) item.className = className;return item; };
|
|
@@ -66,17 +67,17 @@
|
|
|
66
67
|
if (provider.discovery?.state === "stale") { const warning = node("p", undefined, "hint");words(warning, "cap_catalog_stale");warning.append(" ", provider.discovery.code);info.append(warning); }
|
|
67
68
|
if (!provider.builtin) actions.append(button("api_manage", () => editApi(provider)));
|
|
68
69
|
const toggle = node("input");toggle.type = "checkbox";toggle.checked = true;toggle.setAttribute("role", "switch");toggle.setAttribute("aria-label", format("api_disable_source") + " " + provider.name);
|
|
69
|
-
toggle.addEventListener("change", () => { toggle.checked = true;disableSource(provider); });
|
|
70
|
+
toggle.addEventListener("change", () => { toggle.checked = true;disableSource(provider); });const hit = node("label", undefined, "switch-hit");hit.append(toggle);actions.append(hit);
|
|
70
71
|
} else actions.append(button("api_restore", () => void change({ operation: "provider", id: provider.id, enabled: true })));
|
|
71
72
|
row.append(info, actions);if (!provider.enabled) disabledSources.append(row);else if (provider.id === selectedProvider) providerList.append(row);
|
|
72
73
|
}
|
|
73
74
|
const current = editingClient && client(editingClient);
|
|
74
75
|
if (current) {
|
|
75
|
-
const row = node("div", undefined, "connection-row"), title = node("
|
|
76
|
+
const row = node("div", undefined, "connection-row"), title = node("strong", current.name), toggle = node("input");
|
|
76
77
|
toggle.type = "checkbox";toggle.checked = current.enabled;toggle.setAttribute("role", "switch");toggle.setAttribute("aria-label", current.name);
|
|
77
78
|
toggle.addEventListener("change", () => void change({ operation: "client", id: current.id, enabled: toggle.checked,
|
|
78
79
|
source: toggle.checked ? current.source : null, allowed: current.allowed, ...(Array.isArray(current.deployments) ? { deployments: current.deployments, default_model: current.default_model, auto_sync: current.auto_sync } : {}) }));
|
|
79
|
-
row.append(title,
|
|
80
|
+
const hit = node("label", undefined, "switch-hit");hit.append(toggle);row.append(title, hit);clientList.append(row);
|
|
80
81
|
}
|
|
81
82
|
for (const c of data.clients.filter(c => !c.enabled)) {
|
|
82
83
|
const row = node("div", undefined, "connection-row");row.append(node("span", c.name), button("api_restore", () => void change({ operation: "client", id: c.id, enabled: true, source: null, allowed: c.allowed })));disabledClients.append(row);
|
|
@@ -109,16 +110,28 @@
|
|
|
109
110
|
panels();let key = input.operation === "save_api" ? "api_config_saved" : input.operation === "provider" ? input.enabled ? "api_provider_enabled" : "api_provider_disabled"
|
|
110
111
|
: !input.enabled ? "api_client_disabled" : !input.source ? "api_client_enabled" : "api_saved";
|
|
111
112
|
const setup = data.clients.find(c => c.id === input.id)?.setup;
|
|
112
|
-
if (input.operation === "client" &&
|
|
113
|
-
if (input.operation === "client" &&
|
|
114
|
-
if (input.operation === "client" &&
|
|
113
|
+
if (input.operation === "client" && ["preserved", "partially_preserved"].includes(setup)) key = "api_client_preserved";
|
|
114
|
+
if (input.operation === "client" && setup === "configuration_unavailable") key = "api_client_config_failed";
|
|
115
|
+
if (input.operation === "client" && setup === "not_installed") key = "api_client_not_installed";
|
|
116
|
+
if (input.operation === "client" && setup === "configured") key = "sync_config_written";
|
|
117
|
+
if (input.operation === "client" && setup === "manual_sync") key = "sync_manual";
|
|
115
118
|
if (input.operation === "client") words(el("connection-client-note"), key);else message(key);
|
|
119
|
+
if (input.operation === "save_api" && input.config.models.length) for (const c of data.clients.filter(c => c.enabled && input.allowed.includes(c.id))) {
|
|
120
|
+
const link = node("a", c.name, "section-link");link.href = c.id === "codex" ? "#codex" : "#claude";link.addEventListener("click", event => { event.preventDefault();editClient(c); });el("connection-note").append(" ", link);
|
|
121
|
+
}
|
|
116
122
|
}window.dispatchEvent(new CustomEvent("ccdx:connections"));void dashboardRefresh.refresh("auth", { force: true });void dashboardRefresh.refresh("status", { force: true }); }
|
|
117
|
-
catch (error) {
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (input.operation === "provider" && !input.enabled && error.message === "ccdx_connections_conflict") {
|
|
125
|
+
try { data = await api();list();disableSource(source(input.id));message("api_impact_changed"); } catch { message(error.message); }return;
|
|
126
|
+
}
|
|
127
|
+
if (input.operation === "source_access") accessError = error.message;else if (input.operation === "client") words(el("connection-client-note"), error.message);else message(error.message);return;
|
|
128
|
+
}
|
|
118
129
|
finally { busy = false;if (trigger?.tagName === "BUTTON") { trigger.removeAttribute("aria-busy");trigger.disabled = false;if (oldKey) words(trigger, oldKey);else trigger.textContent = oldText; }
|
|
119
130
|
if (["client", "preview_client"].includes(input.operation)) bindingRows();
|
|
120
131
|
if (input.operation === "source_access") renderAccess();
|
|
132
|
+
if (input.operation === "save_api") words(apiForm.querySelector('button[type="submit"]'), editing ? "api_save" : "api_save_read");
|
|
121
133
|
}
|
|
134
|
+
return true;
|
|
122
135
|
}
|
|
123
136
|
const resolved = (model, protocol = model.protocols.includes("messages") ? "messages" : model.protocols[0]) => {
|
|
124
137
|
const metadata = model.metadata?.deployment === source(editing)?.deployment_revision ? model.metadata : null;
|
|
@@ -230,11 +243,12 @@
|
|
|
230
243
|
apiForm.elements.key.required = !provider;globalThis.ccdxLanguage.set(apiForm.elements.key, provider ? "api_key_keep" : "api_key_enter", {}, "placeholder");
|
|
231
244
|
apiForm.elements.auth_header.value = provider?.auth_header || "x-api-key";
|
|
232
245
|
apiForm.elements.key_env.value = provider?.key_env || "";keyMode();
|
|
233
|
-
for (const input of apiForm.querySelectorAll('[name="protocol"]')) input.checked = provider ? provider.
|
|
246
|
+
for (const input of apiForm.querySelectorAll('[name="protocol"]')) input.checked = provider ? Boolean(provider.endpoints?.[input.value]) : input.value !== "chat";
|
|
234
247
|
setEndpoints(provider?.base_url || "", provider?.endpoints);
|
|
235
248
|
const allowed = el("connection-allowed-clients");allowed.replaceChildren(...data.clients.filter(c => c.enabled).map(c => check("allowed", c.id, c.allowed.includes(editing), c.name)));
|
|
236
249
|
el("connection-model-detail").hidden = true;
|
|
237
250
|
models = structuredClone(provider?.models || []);selectedModels = new Set(models.map(model => model.id));modelRows();el("connection-manual-model").open = false;el("connection-discover").disabled = !editing;el("connection-model-id").value = "";apiForm.elements.name.focus();
|
|
251
|
+
words(apiForm.querySelector('button[type="submit"]'), provider ? "api_save" : "api_save_read");
|
|
238
252
|
}
|
|
239
253
|
apiForm.elements.base.addEventListener("change", () => setEndpoints(apiForm.elements.base.value));
|
|
240
254
|
for (const input of apiForm.querySelectorAll('[name="protocol"]')) input.addEventListener("change", () => {
|
|
@@ -253,10 +267,15 @@
|
|
|
253
267
|
}
|
|
254
268
|
const endpoints = Object.fromEntries([...apiForm.querySelectorAll('[name="protocol"]:checked')].map(input => [input.value, apiForm.elements[input.value + "_url"].value.trim()]));
|
|
255
269
|
const key = apiForm.elements.key.value;apiForm.elements.key.value = "";
|
|
256
|
-
|
|
270
|
+
const first = !editing;
|
|
271
|
+
const input = { operation: "save_api", ...(editing ? { id: editing } : {}), key,
|
|
257
272
|
config: { name: apiForm.elements.name.value.trim(), base_url: apiForm.elements.base.value.trim().replace(/\/+$/, ""), endpoints, auth_header: apiForm.elements.auth_header.value, models: chosenModels,
|
|
258
273
|
...(apiForm.elements.key_env.value.trim() ? { key_env: apiForm.elements.key_env.value.trim() } : {}) },
|
|
259
|
-
allowed: [...apiForm.querySelectorAll('[name="allowed"]:checked')].map(input => input.value).concat(data.clients.filter(c => !c.enabled && c.allowed.includes(editing)).map(c => c.id)) }
|
|
274
|
+
allowed: [...apiForm.querySelectorAll('[name="allowed"]:checked')].map(input => input.value).concat(data.clients.filter(c => !c.enabled && c.allowed.includes(editing)).map(c => c.id)) };
|
|
275
|
+
void (async () => {
|
|
276
|
+
const saved = await change(input, first ? result => { const provider = result.providers.find(p => !p.builtin && p.name === input.config.name);if (provider) editApi(provider); } : undefined);
|
|
277
|
+
if (saved && first && editing) await discoverModels();
|
|
278
|
+
})();
|
|
260
279
|
});
|
|
261
280
|
el("connection-model-add").addEventListener("click", () => {
|
|
262
281
|
const id = el("connection-model-id").value.trim();if (!id || models.some(model => model.id === id) || models.length >= 500) return;
|
|
@@ -268,7 +287,7 @@
|
|
|
268
287
|
el("connection-discover").disabled = !editing;el("connection-discover").removeAttribute("aria-busy");words(el("connection-discover"), "api_read_models");el("connection-discover-cancel").hidden = true;return cancelled;
|
|
269
288
|
}
|
|
270
289
|
el("connection-discover-cancel").addEventListener("click", () => { stopDiscovery();message("api_read_cancelled");el("connection-discover").focus(); });
|
|
271
|
-
|
|
290
|
+
async function discoverModels() {
|
|
272
291
|
if (discovery || !editing) return;
|
|
273
292
|
const read = { id: editing, controller: new AbortController() };discovery = read;
|
|
274
293
|
const trigger = el("connection-discover");trigger.disabled = true;trigger.setAttribute("aria-busy", "true");words(trigger, "api_reading");el("connection-discover-cancel").hidden = false;
|
|
@@ -277,9 +296,10 @@
|
|
|
277
296
|
data = result;
|
|
278
297
|
const known = new Map(models.map(model => [model.id, model]));for (const model of result.discovered || []) { const previous = known.get(model.id);known.set(model.id, previous ? { ...previous, ...(model.display ? { display: model.display } : {}), ...(model.metadata ? { metadata: model.metadata } : {}) } : model); }
|
|
279
298
|
models = [...known.values()].slice(0, 500);modelRows();message("api_models_read");
|
|
280
|
-
} catch (error) { if (discovery === read) message(error.message); }
|
|
299
|
+
} catch (error) { if (discovery === read) message("api_read_failed", { code: error.message }); }
|
|
281
300
|
finally { if (discovery === read) { discovery = null;trigger.disabled = false;trigger.removeAttribute("aria-busy");words(trigger, "api_read_models");el("connection-discover-cancel").hidden = true; } }
|
|
282
|
-
}
|
|
301
|
+
}
|
|
302
|
+
el("connection-discover").addEventListener("click", () => void discoverModels());
|
|
283
303
|
function memoryMatches(item) {
|
|
284
304
|
const model = client("codex")?.memory_model?.model;
|
|
285
305
|
return Boolean(model && [item.id, item.model, item.route_id, item.public_id].includes(model));
|
|
@@ -343,7 +363,7 @@
|
|
|
343
363
|
const missing = [...bindingSelection].filter(key => !availableKeys.has(key)).map(key => { const [source, id] = key.split("\0");return { source, id, route_id: c.model_plan?.unavailable?.find(item => item.source === source && item.id === id)?.route_id, unavailable: true }; });
|
|
344
364
|
for (const item of [...available, ...missing]) {
|
|
345
365
|
const key = bindingKey(item.source, item.id), row = node("tr"), name = node("td"), capability = item.capability?.values || {};
|
|
346
|
-
const selection = check("binding-model", key, bindingSelection.has(key), item.id);
|
|
366
|
+
const selection = check("binding-model", key, bindingSelection.has(key), item.display_name || item.id);
|
|
347
367
|
selection.firstChild.addEventListener("change", event => {
|
|
348
368
|
const checked = event.target.checked;
|
|
349
369
|
const apply = () => {
|
|
@@ -368,6 +388,13 @@
|
|
|
368
388
|
const warning = el("connection-default-note");warning.hidden = !unavailableDefault;words(warning, "cap_default_unavailable");
|
|
369
389
|
clientForm.querySelector('button[type="submit"]').disabled = unavailableDefault || busy;
|
|
370
390
|
words(el("connection-draft-state"), bindingDirty ? "cap_unsaved" : "cap_saved");
|
|
391
|
+
const setup = c.setup || "not_configured", syncKey = setup === "configured" ? "sync_config_written" : setup === "manual_sync" ? "sync_manual"
|
|
392
|
+
: ["preserved", "partially_preserved"].includes(setup) ? "sync_preserved" : setup === "configuration_unavailable" ? "sync_failed"
|
|
393
|
+
: setup === "default_unavailable" ? "cap_default_unavailable" : "sync_not_configured";
|
|
394
|
+
globalThis.ccdxIcons.set(el("connection-setup-state"), syncKey, setup === "configured" ? "ok" : ["configuration_unavailable", "default_unavailable"].includes(setup) ? "warning" : "unavailable");
|
|
395
|
+
const capabilityNote = el("connection-capability-state");capabilityNote.hidden = !c.model_plan?.sync?.limitations?.some(item => item.code === "client_version_unknown");
|
|
396
|
+
if (!capabilityNote.hidden) words(capabilityNote, "sync_capability_unverified");
|
|
397
|
+
words(clientForm.querySelector('button[type="submit"]'), el("connection-auto-sync").checked ? "cap_save_sync" : "api_save");
|
|
371
398
|
if (focus) { const selector = focus.kind === "selection" ? 'input[name="binding-model"]' : 'button[data-binding]';[...body.querySelectorAll(selector)].find(input => (input.value || input.dataset.binding) === focus.key)?.focus(); }
|
|
372
399
|
if (!body.children.length) { const row = node("tr"), cell = node("td");cell.colSpan = 5;words(cell, "cap_no_models");const link = node("a");link.href = "#models";words(link, "model_services");cell.append(" ", link);row.append(cell);body.append(row); }
|
|
373
400
|
}
|
|
@@ -376,7 +403,7 @@
|
|
|
376
403
|
rememberDraft();claudeClient = segment.dataset.claudeClient;
|
|
377
404
|
for (const button of document.querySelectorAll("[data-claude-client]")) button.setAttribute("aria-pressed", String(button === segment));mountClient(true);
|
|
378
405
|
});
|
|
379
|
-
el("connection-auto-sync").addEventListener("change", () => { bindingDirty = true;rememberDraft();el("connection-client-cancel").disabled = false;words(el("connection-draft-state"), "cap_unsaved"); });
|
|
406
|
+
el("connection-auto-sync").addEventListener("change", () => { bindingDirty = true;rememberDraft();el("connection-client-cancel").disabled = false;words(el("connection-draft-state"), "cap_unsaved");words(clientForm.querySelector('button[type="submit"]'), el("connection-auto-sync").checked ? "cap_save_sync" : "api_save"); });
|
|
380
407
|
el("connection-client-cancel").addEventListener("click", () => { drafts.delete(editingClient);bindingDirty = false;mountClient(true); });
|
|
381
408
|
function bindingInput(operation) {
|
|
382
409
|
const c = client(editingClient);return { operation, id: c.id, enabled: true, allowed: c.allowed,
|
|
@@ -390,12 +417,21 @@
|
|
|
390
417
|
if (!confirmed && c?.enabled && c.memory_model?.enabled !== false && c.model_plan?.models.some(item => item.source === provider.id && memoryMatches(item))) {
|
|
391
418
|
confirmMemory(() => disableSource(provider, true));return;
|
|
392
419
|
}
|
|
393
|
-
const
|
|
394
|
-
if (!
|
|
420
|
+
const impact = data.source_impacts?.[provider.id];
|
|
421
|
+
if (!impact) { message("api_impact_unavailable");void load();return; }
|
|
422
|
+
const affected = impact.clients;disableRevision = impact.revision;
|
|
423
|
+
if (!affected.length) { void change({ operation: "provider", id: provider.id, enabled: false, impact_revision: disableRevision });return; }
|
|
395
424
|
disabling = provider.id;panels("disable");const area = el("connection-replacements");area.replaceChildren();
|
|
396
|
-
for (const
|
|
425
|
+
for (const item of affected) {
|
|
426
|
+
const c = client(item.id), section = node("div", undefined, "source-impact");section.append(node("strong", c.name));
|
|
427
|
+
const count = node("p");words(count, "api_impact_models", { before: item.removed + item.remaining, after: item.remaining, removed: item.removed });section.append(count);
|
|
428
|
+
const note = node("p", undefined, "hint");words(note, item.needs_replacement ? "api_choose_replacements" : "api_impact_default_kept");section.append(note);
|
|
429
|
+
if (item.needs_replacement) { const label = node("label"), select = choice(data.providers.filter(p => p.id !== provider.id && p.enabled && c.allowed.includes(p.id) && selectableSource(p, c.id)));select.name = c.id;select.setAttribute("aria-label", c.name);label.append(select);section.append(label); }
|
|
430
|
+
area.append(section);
|
|
431
|
+
}
|
|
397
432
|
}
|
|
398
433
|
el("connection-disable-form").addEventListener("submit", e => { e.preventDefault();void change({ operation: "provider", id: disabling, enabled: false,
|
|
434
|
+
impact_revision: disableRevision,
|
|
399
435
|
replacements: Object.fromEntries([...el("connection-replacements").querySelectorAll("select")].map(select => [select.name, select.value || null])) }); });
|
|
400
436
|
el("connection-add").addEventListener("click", () => { if (data) editApi(); });
|
|
401
437
|
for (const id of ["connection-cancel", "connection-disable-cancel"]) el(id).addEventListener("click", () => { panels();(editorOrigin?.isConnected ? editorOrigin : el("connection-source-list").querySelector("button") || el("connection-add")).focus(); });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
const known = new WeakSet(), active = new Map(), reduced = matchMedia("(prefers-reduced-motion: reduce)");
|
|
3
|
+
function settle(detail, operation) {
|
|
4
|
+
if (active.get(detail) !== operation) return;
|
|
5
|
+
active.delete(detail);operation.animations.forEach(animation => animation.cancel());
|
|
6
|
+
if (!operation.open) detail.open = false;delete detail.dataset.disclosureClosing;
|
|
7
|
+
}
|
|
8
|
+
function decorate(root) {
|
|
9
|
+
const details = [...(root.matches?.("details") ? [root] : []), ...(root.querySelectorAll?.("details") || [])];
|
|
10
|
+
for (const detail of details) {
|
|
11
|
+
if (known.has(detail)) continue;
|
|
12
|
+
const summary = detail.querySelector(":scope > summary");if (!summary) continue;
|
|
13
|
+
known.add(detail);
|
|
14
|
+
summary.addEventListener("click", event => {
|
|
15
|
+
if (event.defaultPrevented || event.target.closest("button,a,input,select,textarea") || typeof summary.animate !== "function" || reduced.matches || document.hidden) return;
|
|
16
|
+
event.preventDefault();
|
|
17
|
+
const previous = active.get(detail), open = !(previous?.open ?? detail.open);
|
|
18
|
+
if (previous) { active.delete(detail);previous.animations.forEach(animation => animation.cancel()); }
|
|
19
|
+
const operation = { open, animations: [] };active.set(detail, operation);
|
|
20
|
+
if (open) { delete detail.dataset.disclosureClosing;detail.open = true; }
|
|
21
|
+
else detail.dataset.disclosureClosing = "true";
|
|
22
|
+
for (const child of detail.children) if (child !== summary && !child.hidden && child.getClientRects().length) {
|
|
23
|
+
operation.animations.push(child.animate(open ? [{ opacity: 0, transform: "translateY(-3px)" }, { opacity: 1, transform: "translateY(0)" }]
|
|
24
|
+
: [{ opacity: 1, transform: "translateY(0)" }, { opacity: 0, transform: "translateY(-2px)" }],
|
|
25
|
+
{ duration: open ? 160 : 110, easing: "cubic-bezier(.25,1,.5,1)" }));
|
|
26
|
+
}
|
|
27
|
+
Promise.all(operation.animations.map(animation => animation.finished.catch(() => {}))).then(() => settle(detail, operation));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
decorate(document);
|
|
32
|
+
new MutationObserver(records => { for (const record of records) for (const node of record.addedNodes) if (node.nodeType === 1) decorate(node); }).observe(document.body, { childList: true, subtree: true });
|
|
33
|
+
const finish = () => { for (const [detail, operation] of active) settle(detail, operation); };
|
|
34
|
+
reduced.addEventListener?.("change", finish);
|
|
35
|
+
document.addEventListener("visibilitychange", () => { if (document.hidden) finish(); });
|
|
36
|
+
addEventListener("pagehide", finish);
|
|
37
|
+
})();
|
package/src/dashboard/index.html
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
<link rel="stylesheet" href="/ui.css">
|
|
11
11
|
<script src="/refresh.js" defer></script>
|
|
12
12
|
<script src="/icons.js" defer></script>
|
|
13
|
+
<script src="/disclosure.js" defer></script>
|
|
13
14
|
<script src="/time.js" defer></script>
|
|
14
15
|
<script src="/view-boundary.js" defer></script>
|
|
15
16
|
<script src="/status.js" defer></script>
|
|
@@ -79,6 +80,8 @@
|
|
|
79
80
|
<p id="connection-memory-warning" class="memory-model-notice" role="status" hidden></p>
|
|
80
81
|
</div>
|
|
81
82
|
<p id="connection-default-note" class="hint" role="status" hidden></p>
|
|
83
|
+
<p id="connection-setup-state" class="client-sync-state" role="status" aria-live="polite"></p>
|
|
84
|
+
<p id="connection-capability-state" class="hint" hidden></p>
|
|
82
85
|
<div class="table-wrap"><table class="binding-table"><thead><tr><th data-i18n="model">Model</th><th data-i18n="source">Source</th><th data-i18n="cap_context">Context</th><th data-i18n="cap_reasoning">Reasoning</th><th data-i18n="cap_default">Default</th></tr></thead><tbody id="connection-bindings"></tbody></table></div>
|
|
83
86
|
<div class="setting-row"><label for="connection-auto-sync" data-i18n="cap_auto_sync">Sync model settings</label><input id="connection-auto-sync" type="checkbox" role="switch" checked><span class="hint" data-i18n="cap_sync_scope">Preserves your manual settings.</span></div>
|
|
84
87
|
<div class="section-actions"><button type="submit" data-i18n="api_save">Save</button><button type="button" id="connection-client-cancel" data-i18n="cap_discard_changes">Discard changes</button><button type="button" id="connection-sync-preview" data-i18n="cap_sync_preview">Review sync</button></div>
|
|
@@ -170,7 +173,7 @@
|
|
|
170
173
|
</div>
|
|
171
174
|
<div data-view="models" hidden>
|
|
172
175
|
<section class="panel dashboard-section" id="connection-sources">
|
|
173
|
-
<div class="panel-heading"><h2 data-i18n="
|
|
176
|
+
<div class="panel-heading"><h2 data-i18n="source_accounts">Accounts & APIs</h2><button id="connection-add" type="button" data-i18n="api_add">Add API</button></div>
|
|
174
177
|
<div id="model-providers" class="provider-tabs" role="tablist" aria-label="Model providers" data-i18n-label="model_providers"></div>
|
|
175
178
|
<div id="connection-source-list"></div>
|
|
176
179
|
<details id="connection-disabled-sources" class="connection-disabled" hidden><summary data-i18n="api_disabled_sources">Disabled sources</summary><div id="connection-disabled-source-list"></div></details>
|
|
@@ -246,7 +249,7 @@
|
|
|
246
249
|
<p id="models-note" class="table-note" data-i18n="reading_provider_catalog">Loading model list…</p>
|
|
247
250
|
<details id="model-check-details" class="model-check-details" hidden><summary data-i18n="source_check_details">Check details</summary><dl id="model-check-fields" class="failure-detail"></dl></details>
|
|
248
251
|
<div class="table-wrap"><table><thead><tr><th scope="col" data-i18n="model">MODEL</th><th scope="col" data-i18n="client">APP</th><th scope="col" data-i18n="tools_details">Details</th></tr></thead><tbody id="live-models-body" role="tabpanel"><tr><td colspan="3" data-i18n="loading">Loading…</td></tr></tbody></table></div>
|
|
249
|
-
<details class="tool-details"><summary data-i18n="
|
|
252
|
+
<details class="tool-details"><summary data-i18n="catalog_scope">Catalog scope</summary><p class="hint" data-i18n="catalog_listing_does_not_guarantee_inference_access">Models listed; inference access not verified.</p></details>
|
|
250
253
|
</details>
|
|
251
254
|
<details class="panel dashboard-section" id="account-authorization">
|
|
252
255
|
<summary data-i18n="source_access_details">SOURCE ACCESS DETAILS</summary>
|
|
@@ -261,7 +264,7 @@
|
|
|
261
264
|
<p class="hint" data-i18n="tools_local_scope">Local checks do not contact external services.</p>
|
|
262
265
|
<div class="section-actions"><button id="check-local" type="button" data-i18n="tools_check_local">Check this computer</button></div>
|
|
263
266
|
<p id="checks-note" class="table-note" role="status" aria-live="polite" data-i18n="tools_checks_empty">Run a check to see the results.</p>
|
|
264
|
-
<div class="table-wrap"><table class="checks-table"><thead><tr><th data-i18n="tools_check_item">Check</th><th data-i18n="state">State</th><th data-i18n="tools_details">Details</th></tr></thead><tbody id="checks-body"></tbody></table></div>
|
|
267
|
+
<div class="table-wrap" id="checks-results" hidden><table class="checks-table"><thead><tr><th data-i18n="tools_check_item">Check</th><th data-i18n="state">State</th><th data-i18n="tools_details">Details</th></tr></thead><tbody id="checks-body"></tbody></table></div>
|
|
265
268
|
</section>
|
|
266
269
|
<section class="panel dashboard-section">
|
|
267
270
|
<h2 data-i18n="account_access">ACCOUNT AND ACCESS</h2>
|
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const translations = {
|
|
3
|
+
"model_id": ["Model ID", "模型 ID"],
|
|
4
|
+
"catalog_scope": ["Catalog scope", "目录说明"],
|
|
5
|
+
"issue_brief": ["{cause} · {model} · {time}", "{cause} · {model} · {time}"],
|
|
6
|
+
"issue_count_unavailable": ["Token counting unavailable", "令牌计数接口不可用"],
|
|
7
|
+
"issue_source_limit": ["Source usage limit reached", "模型来源用量受限"],
|
|
8
|
+
"issue_catalog_unavailable": ["Model catalog could not be read", "模型目录读取失败"],
|
|
9
|
+
"issue_model_not_selected": ["Model not selected for this app", "应用尚未选用此模型"],
|
|
10
|
+
"issue_access_denied": ["Access was denied", "请求被拒绝访问"],
|
|
11
|
+
"issue_request_failed": ["Request did not complete", "请求未完成"],
|
|
12
|
+
"api_save_read": ["Save & read models", "保存并读取模型"],
|
|
13
|
+
"api_read_failed": ["API saved. Model lookup failed; retry here. {code}", "来源已保存;模型读取失败,可在此重试。{code}"],
|
|
14
|
+
"sync_capability_unverified": ["Client capabilities are unverified; existing settings were kept.", "客户端能力未验证,现有设置已保留。"],
|
|
15
|
+
"source_accounts": ["Accounts & APIs", "账号与 API"],
|
|
16
|
+
"sync_config_written": ["Configuration written · reopen the app to load changes", "配置已写入 · 重开应用查看变更"],
|
|
17
|
+
"sync_manual": ["Selection saved · automatic sync is off", "选择已保存 · 自动同步已关闭"],
|
|
18
|
+
"sync_preserved": ["Manual settings retained · review sync details", "手工设置已保留 · 查看同步详情"],
|
|
19
|
+
"sync_failed": ["Configuration could not be written · review sync details", "配置写入失败 · 查看同步详情"],
|
|
20
|
+
"sync_not_configured": ["App configuration not applied", "尚未应用到客户端配置"],
|
|
21
|
+
"cap_save_sync": ["Save & sync", "保存并同步"],
|
|
22
|
+
"api_impact_models": ["Selected models: {before} → {after} · removes {removed}", "已选模型:{before} → {after} · 移除{removed}个"],
|
|
23
|
+
"api_impact_default_kept": ["The default model stays unchanged.", "默认模型保持不变。"],
|
|
24
|
+
"api_impact_unavailable": ["Refresh the page to review affected apps.", "请刷新页面,查看受影响的应用。"],
|
|
25
|
+
"api_impact_changed": ["Selections changed. Review the updated impact before confirming.", "模型选择已变化,请重新确认影响。"],
|
|
3
26
|
"tools_copy_code": ["Copy code", "复制验证码"],
|
|
4
27
|
"tools_copy_open_github": ["Copy & open GitHub", "复制并打开验证页"],
|
|
5
28
|
"tools_code_copied": ["Copied. Ready to paste.", "已复制,可直接粘贴。"],
|
|
@@ -157,7 +180,7 @@
|
|
|
157
180
|
"cap_unknown": ["Not provided", "未提供"],
|
|
158
181
|
"cap_supported": ["Supported", "支持"],
|
|
159
182
|
"cap_unsupported": ["Not supported", "不支持"],
|
|
160
|
-
"cap_auto_sync": ["Sync
|
|
183
|
+
"cap_auto_sync": ["Sync app configuration after saving", "保存后同步到本机应用"],
|
|
161
184
|
"cap_sync_scope": ["Preserves your manual settings.", "保留你手动修改的设置。"],
|
|
162
185
|
"cap_sync_preview": ["Review sync", "查看同步"],
|
|
163
186
|
"cap_no_models": ["No models yet. Add a source first.", "暂无可用模型,请先添加来源。"],
|
|
@@ -219,7 +242,7 @@
|
|
|
219
242
|
"api_messages_auth": ["Messages authentication", "Messages 认证"],
|
|
220
243
|
"api_allowed_clients": ["Allowed clients", "允许使用的客户端"],
|
|
221
244
|
"api_read_models": ["Read models", "读取模型"],
|
|
222
|
-
"api_discovery_save_first": ["
|
|
245
|
+
"api_discovery_save_first": ["Reads the model catalog; no inference request.", "只读取模型目录,不发起推理。"],
|
|
223
246
|
"api_add_model": ["Add model", "添加模型"],
|
|
224
247
|
"api_manual_model": ["Add a model manually", "手工添加模型"],
|
|
225
248
|
"api_model_protocol_hint": ["Select the models to use and their supported APIs.", "勾选要使用的模型,再选择其支持的接口。"],
|
|
@@ -624,7 +647,7 @@
|
|
|
624
647
|
"next_configuration_request_cached_suggestions_may_remain": ["Applies on the next settings request. Cached suggestions may still appear.", "下次读取建议设置时生效。\n已有建议可能仍会显示。"],
|
|
625
648
|
"reopen_the_client_to_finish": ["Reopen the app", "重开应用"],
|
|
626
649
|
"restart_ccdx_to_finish": ["Restart CCDX", "请重启 CCDX"],
|
|
627
|
-
"saved_saved_effective_effective_state": ["Saved
|
|
650
|
+
"saved_saved_effective_effective_state": ["Saved {saved}; active {effective} · {state}", "已保存:{saved};当前:{effective} · {state}"],
|
|
628
651
|
"on": ["On", "开启"],
|
|
629
652
|
"off": ["Off", "关闭"],
|
|
630
653
|
"controlled_by_environment": ["Set at startup", "启动限定"],
|
|
@@ -820,7 +843,7 @@
|
|
|
820
843
|
"reading_874bf": ["Reading…", "读取中"],
|
|
821
844
|
"reading_status": ["Reading status…", "读取中"],
|
|
822
845
|
"upstream_messages_may_contain_sensitive_text": ["Review private information before sharing error details.", "分享错误详情前,请检查其中的隐私信息。"],
|
|
823
|
-
"terminal_animation_9edf6": ["
|
|
846
|
+
"terminal_animation_9edf6": ["ANIMATION STYLE", "动效样式"],
|
|
824
847
|
"animation_theme": ["Animation style", "动效样式"],
|
|
825
848
|
"save_selection": ["Save animation", "保存动效"],
|
|
826
849
|
"applies_on_next_ccdx_start": ["Save, then restart ccdx to apply.", "保存后,下次启动生效。"],
|
package/src/dashboard/status.js
CHANGED
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
if (signature === failureSignature) return;
|
|
96
96
|
failureSignature = signature;
|
|
97
97
|
const list = element("failures");
|
|
98
|
-
const expanded = new Set([...list.querySelectorAll("details[open]")].map(
|
|
98
|
+
const expanded = new Set([...list.querySelectorAll("details[open]")].filter(item => item.dataset.disclosureClosing !== "true").map(item => item.dataset.key));
|
|
99
99
|
list.replaceChildren();
|
|
100
100
|
const requests = Array.isArray(recentRequests) ? recentRequests.slice(-20) : [];
|
|
101
101
|
const byRequest = new Map(requests.filter((request) => request.request_id).map((request) => [request.request_id, request]));
|
|
@@ -133,11 +133,16 @@
|
|
|
133
133
|
details.dataset.key = `${failure.at}/${failure.request_id || failure.response_id}/${failure.code}`;
|
|
134
134
|
details.open = expanded.has(details.dataset.key);
|
|
135
135
|
const title = document.createElement("summary");
|
|
136
|
+
const cause = failure.route === "messages_count_tokens" && [404, 405, 501].includes(failure.http_status) ? "issue_count_unavailable"
|
|
137
|
+
: ["rate_limit_error", "rate_limit_exceeded", "insufficient_quota", "http_429"].includes(failure.code) ? "issue_source_limit"
|
|
138
|
+
: /^m365_catalog_http_/.test(failure.code || "") ? "issue_catalog_unavailable"
|
|
139
|
+
: failure.reason === "ccdx_model_not_selected" ? "issue_model_not_selected"
|
|
140
|
+
: failure.http_status === 401 || failure.http_status === 403 ? "issue_access_denied" : "issue_request_failed";
|
|
136
141
|
const summary = {
|
|
137
|
-
detail: phrase("
|
|
142
|
+
detail: phrase("issue_brief", {
|
|
138
143
|
time: failure.at ? time(failure.at, { date: true }) : phrase("unknown_time"),
|
|
139
144
|
model: notModelRequest ? phrase("not_applicable") : failure.model ? String(failure.model).slice(0, 80) : phrase("unknown_model"),
|
|
140
|
-
|
|
145
|
+
cause: phrase(cause),
|
|
141
146
|
}),
|
|
142
147
|
retry: phrase(failure.upstream_attempts === 0 ? "no_upstream_call" : failure.retried ? "retry_attempted" : "no_retry"),
|
|
143
148
|
};
|
|
@@ -334,7 +339,7 @@
|
|
|
334
339
|
const signature = JSON.stringify(contextRequests);
|
|
335
340
|
if (signature === contextSignature) return;
|
|
336
341
|
contextSignature = signature;
|
|
337
|
-
const expanded = new Set([...(body.querySelectorAll?.("details[open]") || [])].map(details => details.getAttribute("data-request-key")));
|
|
342
|
+
const expanded = new Set([...(body.querySelectorAll?.("details[open]") || [])].filter(details => details.dataset.disclosureClosing !== "true").map(details => details.getAttribute("data-request-key")));
|
|
338
343
|
body.replaceChildren();
|
|
339
344
|
for (const request of contextRequests) {
|
|
340
345
|
const context = request.context || {};
|
package/src/dashboard/tools.js
CHANGED
|
@@ -140,6 +140,7 @@
|
|
|
140
140
|
const body = el("checks-body");body.replaceChildren();
|
|
141
141
|
const groups = new Map();
|
|
142
142
|
for (const check of data.checks || []) { if (!groups.has(check.id)) groups.set(check.id, []);groups.get(check.id).push(check); }
|
|
143
|
+
el("checks-results").hidden = !groups.size;
|
|
143
144
|
for (const [id, checks] of groups) {
|
|
144
145
|
const row = document.createElement("tr"), name = document.createElement("td"), result = document.createElement("td"), details = document.createElement("td");
|
|
145
146
|
const kind = checks.some(check => check.kind === "err" || check.kind === "warn") ? "warning" : checks.some(check => check.kind === "ok") ? "ok" : "unknown";
|
package/src/dashboard/ui.css
CHANGED
|
@@ -129,8 +129,19 @@ summary:focus-visible, select:focus-visible { outline: 2px solid var(--accent);
|
|
|
129
129
|
details > summary { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 8px; list-style: none; }
|
|
130
130
|
details > summary::-webkit-details-marker { display: none; }
|
|
131
131
|
details > summary::marker { content: ""; }
|
|
132
|
-
details > summary::before { content: "
|
|
133
|
-
details[open] > summary::before {
|
|
132
|
+
details > summary::before { content: ""; width: 14px; height: 14px; align-self: center; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; transition: transform 160ms cubic-bezier(.25,1,.5,1); }
|
|
133
|
+
details[open]:not([data-disclosure-closing]) > summary::before { transform: rotate(180deg); }
|
|
134
|
+
@media (prefers-reduced-motion: reduce) { details > summary::before { transition: none; } }
|
|
135
|
+
.client-sync-state { margin: 12px 0; font-size: 12px; color: var(--text); }
|
|
136
|
+
.source-impact { min-width: 0; }
|
|
137
|
+
.source-impact p { margin: 7px 0; }
|
|
138
|
+
.source-impact select { margin-top: 8px; max-width: 100%; }
|
|
139
|
+
.switch-hit { display: inline-flex; align-items: center; justify-content: center; }
|
|
140
|
+
@media (pointer: coarse) {
|
|
141
|
+
.switch-hit { min-width: 44px; min-height: 44px; }
|
|
142
|
+
.setting-row > label { display: flex; align-items: center; min-height: 44px; }
|
|
143
|
+
.topbar-actions .icon-button { min-width: 44px; min-height: 44px; }
|
|
144
|
+
}
|
|
134
145
|
.settings-panel > summary { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
|
|
135
146
|
.dashboard-section > summary.panel-heading, .lower > summary.panel-heading { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
|
|
136
147
|
.dashboard-section > summary.panel-heading span, .lower > summary.panel-heading span { white-space: normal; text-align: right; }
|
package/src/dashboard/ui.js
CHANGED
|
@@ -197,16 +197,16 @@ function applyModels(data, { changed }) {
|
|
|
197
197
|
if (data.provider && data.provider !== selectedProvider) return;
|
|
198
198
|
if (changed) {
|
|
199
199
|
const body = element("live-models-body");
|
|
200
|
-
const expanded = new Set([...body.querySelectorAll("details[open]")].map(node => node.dataset.model));
|
|
200
|
+
const expanded = new Set([...body.querySelectorAll("details[open]")].filter(node => node.dataset.disclosureClosing !== "true").map(node => node.dataset.model));
|
|
201
201
|
body.replaceChildren();
|
|
202
202
|
for (const model of data.models) {
|
|
203
203
|
const clients = (model.clients || []).map(id => ({ codex: "Codex App", claude_app: "Claude App", claude_code: "Claude Code" })[id] || id).join(" / ") || "—";
|
|
204
|
-
const row = tableRow([model.id, clients, ""]);row.children[0].className = "model-name";
|
|
204
|
+
const row = tableRow([model.display_name || model.id, clients, ""]);row.children[0].className = "model-name";
|
|
205
205
|
if (model.vendor && model.vendor !== "Unknown") { const maker = document.createElement("span");maker.className = "model-maker";maker.textContent = model.vendor;row.children[0].append(maker); }
|
|
206
206
|
const details = document.createElement("details"), summary = document.createElement("summary"), fields = document.createElement("dl");
|
|
207
207
|
details.dataset.model = model.id;details.open = expanded.has(model.id);fields.className = "failure-detail";
|
|
208
208
|
localize(summary, "model_details");details.append(summary, fields);
|
|
209
|
-
for (const [key, value, translated] of [["vendor", model.vendor && model.vendor !== "Unknown" ? model.vendor : phrase("cap_unknown")], ["model_owner", model.owned_by], ["api", model.endpoints.join(" / ") || "—"],
|
|
209
|
+
for (const [key, value, translated] of [["model_id", model.id], ["vendor", model.vendor && model.vendor !== "Unknown" ? model.vendor : phrase("cap_unknown")], ["model_owner", model.owned_by], ["api", model.endpoints.join(" / ") || "—"],
|
|
210
210
|
["reasoning", model.reasoning_efforts?.join(" / ") || "—"], ["state", model.preview ? "preview" : model.state || "listed", true],
|
|
211
211
|
["model_window", number(model.context_window)]]) {
|
|
212
212
|
if (value === undefined) continue;
|
package/src/dashboard.mjs
CHANGED
|
@@ -21,6 +21,7 @@ const ASSETS = new Map([
|
|
|
21
21
|
["/usage.js", ["./dashboard/usage.js", "text/javascript; charset=utf-8"]],
|
|
22
22
|
["/refresh.js", ["./dashboard/refresh.js", "text/javascript; charset=utf-8"]],
|
|
23
23
|
["/icons.js", ["./dashboard/icons.js", "text/javascript; charset=utf-8"]],
|
|
24
|
+
["/disclosure.js", ["./dashboard/disclosure.js", "text/javascript; charset=utf-8"]],
|
|
24
25
|
["/tools.js", ["./dashboard/tools.js", "text/javascript; charset=utf-8"]],
|
|
25
26
|
["/connections.js", ["./dashboard/connections.js", "text/javascript; charset=utf-8"]],
|
|
26
27
|
]);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Presentation never changes a model's upstream or client routing identity.
|
|
2
|
+
export function modelDisplayName(model) {
|
|
3
|
+
for (const key of ["display_name", "name", "id"]) {
|
|
4
|
+
const value = model?.[key];
|
|
5
|
+
if (typeof value === "string" && value.trim() && value.length <= (key === "display_name" ? 400 : 160)
|
|
6
|
+
&& !/[\u0000-\u001f\u007f\u202a-\u202e\u2066-\u2069]/.test(value)) return value.trim();
|
|
7
|
+
}
|
|
8
|
+
return model?.id || "";
|
|
9
|
+
}
|
package/src/optional-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/time.js", "/animation.js", "/status.js", "/view-boundary.js", "/activity.js", "/flow.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/preferences.js", "/icons.js", "/tools.js", "/connections.js"]);
|
|
1
|
+
export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/time.js", "/animation.js", "/status.js", "/view-boundary.js", "/activity.js", "/flow.js", "/usage.js", "/ui.js", "/console.js", "/updates.js", "/preferences.js", "/icons.js", "/disclosure.js", "/tools.js", "/connections.js"]);
|
|
2
2
|
export const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth", "/_ccdx/ui/providers", "/_ccdx/ui/settings", "/_ccdx/ui/m365/accounts", "/_ccdx/ui/updates", "/_ccdx/ui/account", "/_ccdx/ui/checks", "/_ccdx/ui/connections"]);
|
|
3
3
|
|
|
4
4
|
export function isOptionalRoute(method, pathname) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { autoReviewReasoningEfforts } from "./models.mjs";
|
|
2
|
+
import { modelDisplayName } from "./model-display.mjs";
|
|
2
3
|
// Public metadata only. Credentials and provider transport never enter this layer.
|
|
3
4
|
export const isProviderId = value => typeof value === "string" && /^[a-z][a-z0-9_-]{0,63}$/.test(value)
|
|
4
5
|
&& !["constructor", "prototype"].includes(value);
|
|
@@ -10,7 +11,7 @@ export function modelReasoningEfforts(model) {
|
|
|
10
11
|
|
|
11
12
|
export function publicModelCatalog(models, { clients = () => [], selectable = () => false, maker = model => model.publisher || model.vendor || model.owned_by || "Unknown" } = {}) {
|
|
12
13
|
return models.slice(0, 1000).filter(model => typeof model?.id === "string").map(model => ({
|
|
13
|
-
id: model.id, vendor: maker(model), ...(model.owned_by ? { owned_by: model.owned_by } : {}),
|
|
14
|
+
id: model.id, display_name: modelDisplayName(model), vendor: maker(model), ...(model.owned_by ? { owned_by: model.owned_by } : {}),
|
|
14
15
|
endpoints: [["responses", ["/responses", "/v1/responses"]], ["chat", ["/chat/completions", "/v1/chat/completions"]],
|
|
15
16
|
["messages", ["/v1/messages"]]].filter(([, paths]) => paths.some(path => model.supported_endpoints?.includes(path))).map(([label]) => label),
|
|
16
17
|
preview: model.preview === true, selectable: selectable(model), clients: clients(model),
|
package/src/providers/api.mjs
CHANGED
|
@@ -124,7 +124,7 @@ export function createApiProvider({ config, secrets, env = process.env, platform
|
|
|
124
124
|
return {
|
|
125
125
|
id: config.id, name: config.name, client, registry, configuredModels: true, defaultReviewEffort: null, profileId: (protocol = "responses") => profiles[protocol] || profile,
|
|
126
126
|
models: family => catalog.filter(model => model.supported_endpoints.includes(family === "claude" ? paths.messages : paths.responses))
|
|
127
|
-
.map(model => ({ ...model, capability: model.protocol_capabilities[family === "claude" ? "messages" : "responses"] })),
|
|
127
|
+
.map(model => ({ ...model, ...modelDisplay(model.id), capability: model.protocol_capabilities[family === "claude" ? "messages" : "responses"] })),
|
|
128
128
|
catalog: () => catalog,
|
|
129
129
|
publicCatalog(allowed = []) { return { source: "configured", checkedAt: config.checked_at || null, upstreamHost: new URL(config.base_url).hostname,
|
|
130
130
|
advertised: catalog.length, models: publicModelCatalog(catalog.map(model => ({ ...model, ...modelDisplay(model.id) })), { maker: model => model.publisher || model.vendor || null,
|
|
@@ -166,7 +166,7 @@ export function createHttpFailureDiagnostics({ maxEntries = 20, now } = {}) {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
export function buildHttpFailureDetails({ statusCode, route, requestId, model, code, origin, headers,
|
|
169
|
+
export function buildHttpFailureDetails({ statusCode, route, requestId, model, code, origin, headers, model_error,
|
|
170
170
|
error_body, error_type, parameter, diagnostic_message, method, target, request_options, upstream_attempts, attempt_timings, requested_model, provider,
|
|
171
171
|
application, reason, capability_cached, shared_upstream, transport }) {
|
|
172
172
|
if (!reason && code === "ccdx_client_source_disabled" && upstream_attempts === 0 && origin !== "upstream_http") {
|
|
@@ -188,7 +188,7 @@ export function buildHttpFailureDetails({ statusCode, route, requestId, model, c
|
|
|
188
188
|
: origin === "client_validation" ? "The request was rejected locally before an upstream call."
|
|
189
189
|
: error_body === "empty" ? "Upstream returned no error details." : "HTTP request failed; original response was preserved.");
|
|
190
190
|
const details = responseFailureDetails({ model, error: { code: typeof code === "string" && /^[a-z\d_.:-]{1,80}$/i.test(code) ? code : `http_${statusCode}`,
|
|
191
|
-
message } }, "http.error", { headers, provider });
|
|
191
|
+
message: model_error ? "The model source reported an error; the original HTTP response was preserved." : message } }, model_error ? "model.error" : "http.error", { headers, provider });
|
|
192
192
|
return { ...details, request_id: requestId, http_status: statusCode, route,
|
|
193
193
|
origin: origin || (route === "not_found" ? "route" : "unclassified"), local_message: true,
|
|
194
194
|
...(error_body ? { error_body } : {}), ...(error_type ? { error_type } : {}), ...(parameter ? { parameter } : {}),
|