codex-copilot-dx 1.2.19 → 1.2.20
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 +28 -0
- package/docs/REFERENCE.md +35 -2
- package/package.json +1 -1
- package/src/api-catalog-refresh.mjs +72 -0
- package/src/client-model-plan.mjs +7 -4
- package/src/connection-runtime.mjs +55 -54
- package/src/dashboard/connections.js +72 -31
- package/src/dashboard/console.js +2 -2
- package/src/dashboard/index.html +16 -16
- package/src/dashboard/language.js +9 -2
- package/src/dashboard/status.js +6 -4
- package/src/dashboard/tools.js +1 -1
- package/src/dashboard/ui.css +21 -1
- package/src/model-capabilities.mjs +8 -6
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ 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.20/install.sh) (macOS/Linux) or [install.ps1](https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.20/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. Dependencies still need your 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
|
|
|
@@ -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. 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.
|
|
58
58
|
|
|
59
|
-
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.
|
|
59
|
+
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.20 changes and verification](https://github.com/DaleXiao/codex-copilot-dx/blob/main/docs/RELEASE_1.2.20.md) cover default-model protection, nonblocking catalog reads and independent client drafts, retaining the native sign-in safeguards.
|
|
60
60
|
|
|
61
61
|
## Microsoft 365 access
|
|
62
62
|
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -648,3 +648,31 @@ Language controls have intrinsic width and no-wrap/no-shrink. Shared button-link
|
|
|
648
648
|
styling keeps the M365 navigation link semantically a link while matching the
|
|
649
649
|
existing GitHub shortcut; wording describes navigation rather than a silent check.
|
|
650
650
|
No new polling, framework, runtime dependency, setting or endpoint is introduced.
|
|
651
|
+
|
|
652
|
+
## Catalog transactions and default identity (1.2.20)
|
|
653
|
+
|
|
654
|
+
`api-catalog-refresh.mjs` owns bounded catalog I/O, same-source single-flight,
|
|
655
|
+
existing success/failure cooldowns, cancellation and deployment-version checks.
|
|
656
|
+
It receives source/config/commit callbacks; it does not write configuration or
|
|
657
|
+
client files. `connection-runtime.mjs` serializes only management changes and
|
|
658
|
+
result publication. A cancelled or obsolete read cannot publish; pinned source
|
|
659
|
+
instances drain through the existing reference tracking. The existing refresh
|
|
660
|
+
cycle remains the scheduler; no extra timer or background process is added.
|
|
661
|
+
|
|
662
|
+
Metadata commits merge only matching configured model IDs into the current
|
|
663
|
+
configuration and sync affected clients. Shared Claude capability projection
|
|
664
|
+
continues to consider both consumers and ownership journals. Metadata never
|
|
665
|
+
changes the selected model set, grants, default identity or native sign-in.
|
|
666
|
+
|
|
667
|
+
`client-model-plan.mjs` distinguishes an unspecified default from an unavailable
|
|
668
|
+
explicit default and indexes each source catalog once per compilation. Native
|
|
669
|
+
catalog projection does not depend on finding a default provider. Request
|
|
670
|
+
resolution still checks the selected source-qualified model before opening an
|
|
671
|
+
upstream call; no substitute model, cross-source fallback or auth recovery is
|
|
672
|
+
introduced. Builtin raw capability structures pass through normalization only;
|
|
673
|
+
validated manual fields belong to manual API configurations.
|
|
674
|
+
|
|
675
|
+
The existing dashboard connection controller owns one draft per client and
|
|
676
|
+
local operation feedback. Source browsing is one shared selection for management,
|
|
677
|
+
account and catalog. Presentation retains existing palettes, motion and native
|
|
678
|
+
controls; it adds no runtime UI dependency or protocol abstraction framework.
|
package/docs/REFERENCE.md
CHANGED
|
@@ -155,6 +155,22 @@ Claude observation covers all Messages sources; M365 counts keep their own scope
|
|
|
155
155
|
|
|
156
156
|
## Model capabilities and Claude synchronization
|
|
157
157
|
|
|
158
|
+
An explicitly selected default keeps its identity when its catalog entry becomes
|
|
159
|
+
unavailable. CCDX does not substitute the first model or rewrite that client's
|
|
160
|
+
existing configuration. Other authorized models remain in the catalog and can be
|
|
161
|
+
requested explicitly; an unavailable model produces a model error rather than a
|
|
162
|
+
sign-in challenge. The application page retains the unavailable selection and
|
|
163
|
+
asks for a valid default before saving. Catalog recovery restores the same route.
|
|
164
|
+
|
|
165
|
+
API saves complete independently of metadata reads. Catalog network work runs
|
|
166
|
+
outside the configuration transaction; only a version-checked result commit
|
|
167
|
+
holds that queue. Same-source, same-deployment reads join the active request.
|
|
168
|
+
Changing its endpoint/key, disabling the source, cancelling the read or stopping
|
|
169
|
+
the service prevents obsolete results from publishing. Failed reads retain saved
|
|
170
|
+
metadata and selections. Capability commits synchronize only affected clients;
|
|
171
|
+
shared Claude settings still respect both consumers and manual ownership.
|
|
172
|
+
|
|
173
|
+
|
|
158
174
|
Model sources owns source credentials, native interface declarations and model details.
|
|
159
175
|
Codex/Claude own the selected deployment set, default and automatic synchronization.
|
|
160
176
|
Claude App and Claude Code have separate segments and local keys. Settings retains
|
|
@@ -1264,7 +1280,7 @@ Unknown support prevents an explicitly requested exception from starting.
|
|
|
1264
1280
|
For an older updater that still requires Git, install the Release tarball directly:
|
|
1265
1281
|
|
|
1266
1282
|
```sh
|
|
1267
|
-
npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.
|
|
1283
|
+
npm install -g https://github.com/DaleXiao/codex-copilot-dx/releases/download/v1.2.20/codex-copilot-dx-1.2.20.tgz
|
|
1268
1284
|
# Windows PowerShell: use npm.cmd instead of npm.
|
|
1269
1285
|
```
|
|
1270
1286
|
|
|
@@ -1640,7 +1656,7 @@ unchanged.
|
|
|
1640
1656
|
|
|
1641
1657
|
New explicit-tool sign-ins use `~/.local/share/ccdx/github_token` and fingerprint-bound `.account.json` metadata, with private permissions and the existing atomic paired writer. When present, this owned store takes precedence over `~/.local/share/copilot-api/github_token`; existing startup/discovery compatibility remains supported. `auth logout` requires interactive confirmation or `--yes`, writes an empty owned credential, and does not delete or revoke other apps' legacy credentials. This intentionally blocks inference's legacy fallback. New login or normal startup can perform the existing explicit discovery/sign-in process again. CLI changes notify a compatible running local service; if notification is unavailable, the CLI asks for a service restart. In-flight model requests are not replayed or forcibly stopped. A token cache invalidation preserves its running account binding, so switching accounts still requires a restart.
|
|
1642
1658
|
|
|
1643
|
-
Model sources uses one source selector for the
|
|
1659
|
+
Model sources uses one source selector for the selected source controls, account and catalog. Disabled sources remain under its collapsed list; there is no second list of enabled source cards. Selecting a tab is browsing only. GitHub offers sign-in, independent connection checks and cancellation; sign-out is under More actions. The browser opens only the fixed GitHub device authorization URL after the user chooses Open GitHub. No token or password entry field is added. Microsoft 365 retains local account discovery/selection and source controls; its corporate SSO is not replaced with a GitHub-style login. Raw codes remain under details and last-good model lists retain their previous timestamp after failures.
|
|
1644
1660
|
|
|
1645
1661
|
`ccdx web` opens an existing compatible dashboard or starts a management-only local listener without sign-in, app configuration, app launch, prediction setup or automatic M365 startup. It does not claim normal startup integrations are active. Stop that management listener with Ctrl+C before running normal `ccdx` for application routing and optional integrations. Opening the dashboard does not initiate a GitHub Device Flow or model inference.
|
|
1646
1662
|
|
|
@@ -1878,3 +1894,20 @@ so toggling it does not shift nearby controls. The language control has a 40px
|
|
|
1878
1894
|
minimum width, cannot flex-shrink and keeps 中文 / EN on one line. Compact toolbars
|
|
1879
1895
|
wrap when required rather than compressing text; header position remains stable
|
|
1880
1896
|
between modules in the same language and viewport.
|
|
1897
|
+
|
|
1898
|
+
### Application editing and keyboard behavior (1.2.20)
|
|
1899
|
+
|
|
1900
|
+
Codex, Claude App and Claude Code keep separate page-local model/default/sync
|
|
1901
|
+
drafts. Switching clients, navigating within the dashboard or reading current
|
|
1902
|
+
settings preserves unsaved drafts. Save and Discard changes affect that client
|
|
1903
|
+
only; reloading the browser discards page-local drafts. Model selection restores
|
|
1904
|
+
focus to the corresponding checkbox/default button. Add API focuses its first
|
|
1905
|
+
field; Cancel restores the entry control. Narrow layouts stack source, context
|
|
1906
|
+
and reasoning below each model while retaining the same table semantics.
|
|
1907
|
+
|
|
1908
|
+
Reading a catalog marks only its Read models button busy and offers Cancel.
|
|
1909
|
+
Cancelling leaves the editor and its draft intact. No inference is sent. Source
|
|
1910
|
+
saves report persistence separately from subsequent metadata refresh. Background
|
|
1911
|
+
read failures retain existing messages; key read/save states use polite live
|
|
1912
|
+
announcements. Account labels and values stay paired, and request summaries use
|
|
1913
|
+
configured source names. Technical IDs remain available in request details.
|
package/package.json
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { accessError } from "./access-settings.mjs";
|
|
2
|
+
|
|
3
|
+
// Network work never holds the configuration transaction. Only publication
|
|
4
|
+
// enters the caller's short, version-checked commit boundary.
|
|
5
|
+
export function createApiCatalogRefresh({ config, source, track, revision, commit, onState, now = Date.now }) {
|
|
6
|
+
const reads = new Map(), flights = new Map(), pending = new Set();let closed = false, batch;
|
|
7
|
+
const current = (id, version) => !closed && config(id)?.enabled && revision(config(id)) === version;
|
|
8
|
+
function cancel(id) {
|
|
9
|
+
const flight = flights.get(id);if (!flight) return;
|
|
10
|
+
flights.delete(id);flight.controller.abort();
|
|
11
|
+
onState(id, { state: "cancelled", checked_at: new Date(now()).toISOString() });
|
|
12
|
+
}
|
|
13
|
+
function invalidate() {
|
|
14
|
+
for (const [id, flight] of flights) if (!current(id, flight.revision)) { cancel(id);onState(id, null); }
|
|
15
|
+
for (const [id, read] of reads) if (!current(id, read.revision)) { reads.delete(id);onState(id, null); }
|
|
16
|
+
}
|
|
17
|
+
async function refresh(id, force = false) {
|
|
18
|
+
const selected = config(id);
|
|
19
|
+
if (closed || !selected?.enabled) throw accessError("ccdx_client_source_disabled", 503);
|
|
20
|
+
const version = revision(selected), old = flights.get(id);
|
|
21
|
+
if (old?.revision === version && !old.controller.signal.aborted) return old.promise;
|
|
22
|
+
if (old) cancel(id);
|
|
23
|
+
const cached = reads.get(id), age = cached ? now() - cached.at : Infinity;
|
|
24
|
+
if (cached?.revision === version && age >= 0 && age < (force || cached.error ? 60000 : 30 * 60000)) {
|
|
25
|
+
if (cached.error) throw cached.error;
|
|
26
|
+
await commit(id, cached.models, version, new Date(cached.at).toISOString(), () => current(id, version));
|
|
27
|
+
onState(id, { state: "ready", checked_at: new Date(cached.at).toISOString() });return cached.models;
|
|
28
|
+
}
|
|
29
|
+
const savedAge = now() - Date.parse(selected.checked_at);
|
|
30
|
+
if (!force && !cached && savedAge >= 0 && savedAge < 30 * 60000 && selected.models.every(model => model.metadata?.state && model.metadata.deployment === version)) return selected.models;
|
|
31
|
+
const flight = { revision: version, controller: new AbortController() };
|
|
32
|
+
flights.set(id, flight);
|
|
33
|
+
const active = () => current(id, version) && flights.get(id) === flight && !flight.controller.signal.aborted;
|
|
34
|
+
onState(id, { state: "checking", checked_at: new Date(now()).toISOString() });
|
|
35
|
+
pending.add(flight);
|
|
36
|
+
flight.promise = (async () => {
|
|
37
|
+
let finish;
|
|
38
|
+
try {
|
|
39
|
+
const provider = source(id);finish = track(provider);
|
|
40
|
+
const models = await provider.discover({ signal: AbortSignal.any([flight.controller.signal, AbortSignal.timeout(20000)]) });
|
|
41
|
+
if (!active()) throw accessError("ccdx_connections_conflict", 409);
|
|
42
|
+
const at = now();await commit(id, models, version, new Date(at).toISOString(), active);
|
|
43
|
+
if (!active()) throw accessError("ccdx_connections_conflict", 409);
|
|
44
|
+
reads.set(id, { revision: version, at, models });
|
|
45
|
+
onState(id, { state: "ready", checked_at: new Date(at).toISOString() });return models;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (!active()) throw accessError("ccdx_connections_conflict", 409);
|
|
48
|
+
const code = /^ccdx_[a-z0-9_]+$/.test(error.code || "") ? error.code : "ccdx_api_catalog_unavailable";
|
|
49
|
+
const failure = accessError(code, [401, 403, 409].includes(error.statusCode) ? error.statusCode : 502);
|
|
50
|
+
if (active()) {
|
|
51
|
+
reads.set(id, { revision: version, at: now(), error: failure });
|
|
52
|
+
onState(id, { state: "stale", code, checked_at: new Date(now()).toISOString() });
|
|
53
|
+
}
|
|
54
|
+
throw failure;
|
|
55
|
+
} finally { finish?.();pending.delete(flight);if (flights.get(id) === flight) flights.delete(id); }
|
|
56
|
+
})();
|
|
57
|
+
return flight.promise;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
refresh, cancel, invalidate,
|
|
61
|
+
refreshAll(ids) {
|
|
62
|
+
if (closed) return Promise.resolve();
|
|
63
|
+
batch ||= (async () => { for (const id of ids) { if (closed) break;await refresh(id).catch(() => {}); } })().finally(() => { batch = null; });
|
|
64
|
+
return batch;
|
|
65
|
+
},
|
|
66
|
+
async close() {
|
|
67
|
+
closed = true;const jobs = [...pending].map(flight => flight.promise);
|
|
68
|
+
for (const flight of pending) flight.controller.abort();
|
|
69
|
+
await Promise.allSettled(jobs);await batch;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -15,10 +15,12 @@ export function compileClientModels({ client, binding, source, enabled, names =
|
|
|
15
15
|
if (!binding.enabled) return { models: [], routes: new Map(), defaultModel: null, revision: "disabled" };
|
|
16
16
|
const explicit = Array.isArray(binding.deployments), selected = explicit ? binding.deployments : binding.source
|
|
17
17
|
? sourceModels(source(binding.source), client).map(model => ({ source: binding.source, model: model.id })) : [];
|
|
18
|
-
const models = [], routes = new Map(), raw = new Map();
|
|
18
|
+
const models = [], routes = new Map(), raw = new Map(), catalogs = new Map();
|
|
19
19
|
for (const item of selected) {
|
|
20
20
|
if (!binding.allowed.includes(item.source) || !enabled(item.source)) continue;
|
|
21
|
-
const provider = source(item.source)
|
|
21
|
+
const provider = source(item.source);
|
|
22
|
+
if (!catalogs.has(provider)) catalogs.set(provider, new Map(sourceModels(provider, client).map(model => [model.id, model])));
|
|
23
|
+
const model = catalogs.get(provider).get(item.model);
|
|
22
24
|
if (!model || model.policy?.state && model.policy.state !== "enabled" || model.model_picker_enabled === false) continue;
|
|
23
25
|
const route = deploymentModelId(item.source, model.id), capability = model.capability || resolveModelCapabilities(model, { builtin: true });
|
|
24
26
|
const entry = { ...model, capability, source_id: item.source, route_id: route,
|
|
@@ -43,7 +45,8 @@ export function compileClientModels({ client, binding, source, enabled, names =
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
+
const requested = explicit ? binding.default_model : binding.model;
|
|
49
|
+
const chosen = routes.get(requested) || (!requested ? models[0] && routes.get(models[0].public_id) : null);
|
|
50
|
+
return { models, routes, defaultModel: chosen?.publicId || null, defaultUnavailable: Boolean(requested && !chosen),
|
|
48
51
|
revision: models.map(model => model.route_id + ":" + model.capability.revision).join(";") };
|
|
49
52
|
}
|
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import { randomBytes } 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
|
+
import { createApiCatalogRefresh } from "./api-catalog-refresh.mjs";
|
|
5
6
|
import { createApiProvider } from "./providers/api.mjs";
|
|
6
7
|
import { readClientGatewayKeys, gatewayClient } from "./client-gateway-keys.mjs";
|
|
7
8
|
import { createClaudeGatewayHandler } from "./claude-gateway.mjs";
|
|
@@ -25,9 +26,12 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
25
26
|
let settings = readAccessSettings(options), managed = fs.existsSync(accessSettingsPath(options)), serial = Promise.resolve(), keys, closed = false;
|
|
26
27
|
const instances = new Map(), active = new Map(), retired = new Set(), handlers = new Map(), summaries = new WeakMap(), sourceSecrets = new WeakMap(), setup = {}, lastClients = {};
|
|
27
28
|
const retiredSecrets = new Map(), cleanups = new Set(), plans = new Map(), discoveries = new Map();
|
|
28
|
-
const
|
|
29
|
+
const catalogRefresh = createApiCatalogRefresh({ config: id => settings.apis.find(api => api.id === id), source: getSource, track,
|
|
30
|
+
revision: api => deploymentRevision(api, env), now,
|
|
31
|
+
commit: (...args) => enqueue(() => applyCatalog(...args)),
|
|
32
|
+
onState: (id, state) => state ? discoveries.set(id, state) : discoveries.delete(id) });
|
|
29
33
|
const capabilitySupport = inspectClaudeCapabilitySupport(options);
|
|
30
|
-
let sharedSync = null, syncFlight = null, syncAgain = false;
|
|
34
|
+
let sharedSync = null, syncFlight = null, syncAgain = false;const syncTargets = new Set();
|
|
31
35
|
function cleanSecrets(id) {
|
|
32
36
|
const refs = retiredSecrets.get(id);if (!refs) return;
|
|
33
37
|
for (const ref of refs) {
|
|
@@ -94,7 +98,7 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
94
98
|
plans.clear();
|
|
95
99
|
settings = structuredClone(updateAccessSettings(current => {
|
|
96
100
|
if (JSON.stringify(current) !== JSON.stringify(settings)) throw accessError("ccdx_connections_conflict", 409);return next;
|
|
97
|
-
}, options));managed = true;
|
|
101
|
+
}, options));managed = true;catalogRefresh.invalidate();
|
|
98
102
|
for (const [id, item] of instances) {
|
|
99
103
|
const current = settings.apis.find(api => api.id === id);
|
|
100
104
|
if (!current?.enabled || JSON.stringify(current) + deploymentRevision(current, env) !== item.signature) { instances.delete(id);retire(item.source); }else item.config = current;
|
|
@@ -112,27 +116,34 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
112
116
|
...config.apis.map(api => { const { secret_ref, ...publicApi } = api;return { ...(compact ? { id: api.id, name: api.name, enabled: api.enabled } : publicApi),
|
|
113
117
|
...summary(api), ...(compact ? {} : { deployment_revision: deploymentRevision(api, env) }), discovery: discoveries.get(api.id) || null, builtin: false, key_saved: api.key_env ? Boolean(env[api.key_env]) : Boolean(secret_ref) }; }),
|
|
114
118
|
], clients: CLIENT_IDS.map(id => ({ id, name: CLIENT_NAMES[id], ...config.clients[id], setup: setup[id] || null,
|
|
115
|
-
observed_at: lastClients[id] || null, ...(compact ? {} : { model_plan: { default_model: plan(id).defaultModel,
|
|
119
|
+
observed_at: lastClients[id] || null, ...(compact ? {} : { model_plan: { default_model: plan(id).defaultModel, default_unavailable: plan(id).defaultUnavailable,
|
|
116
120
|
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 })),
|
|
121
|
+
unavailable: (config.clients[id].deployments || []).filter(item => !plan(id).models.some(model => model.source_id === item.source && model.id === item.model))
|
|
122
|
+
.map(item => ({ source: item.source, id: item.model, route_id: deploymentModelId(item.source, item.model) })),
|
|
117
123
|
available: config.clients[id].allowed.filter(enabled).flatMap(source => sourceModels(getSource(source), id).map(model => ({ source, id: model.id,
|
|
118
124
|
route_id: deploymentModelId(source, model.id), capability: model.capability || resolveModelCapabilities(model, { builtin: true }) }))), sync: sharedSync, support: capabilitySupport } }) })), managed, m365_state: state.m365.state });
|
|
119
125
|
}
|
|
120
|
-
async function syncClients() {
|
|
126
|
+
async function syncClients(ids = CLIENT_IDS) {
|
|
127
|
+
for (const id of ids) syncTargets.add(id);
|
|
121
128
|
syncAgain = true;if (syncFlight) return syncFlight;
|
|
122
|
-
syncFlight = (async () => { do { syncAgain = false;await performClientSync(); } while (syncAgain && !closed); })();
|
|
129
|
+
syncFlight = (async () => { do { syncAgain = false;const targets = new Set(syncTargets);syncTargets.clear();await performClientSync(targets); } while (syncAgain && !closed); })();
|
|
123
130
|
try { return await syncFlight; } finally { syncFlight = null; }
|
|
124
131
|
}
|
|
125
|
-
async function performClientSync() {
|
|
132
|
+
async function performClientSync(targets) {
|
|
126
133
|
if (!managed || closed) return;
|
|
127
134
|
const codex = binding("codex");
|
|
128
|
-
try { if (
|
|
135
|
+
try { if (!targets.has("codex")) { /* Unrelated source metadata does not write Codex settings. */ }
|
|
136
|
+
else if (codex.enabled && plan("codex").defaultUnavailable) setup.codex = "default_unavailable";
|
|
137
|
+
else if (codex.enabled && codex.auto_sync === false) setup.codex = "manual_sync";else setup.codex = configureCodex({ ...options, ...(codex.enabled && (Array.isArray(codex.deployments) || codex.source?.startsWith("api_"))
|
|
129
138
|
? { baseUrl: `http://127.0.0.1:${corePort}/v1`, apiKey: identities().codex, model: plan("codex").defaultModel || codex.model } : { restore: true }) }).state; }
|
|
130
139
|
catch { setup.codex = "configuration_unavailable"; }
|
|
131
|
-
if (!settings.claude_private_keys) return;
|
|
140
|
+
if (!settings.claude_private_keys || !["claude_app", "claude_code"].some(id => targets.has(id))) return;
|
|
132
141
|
let desktopManaged;
|
|
133
142
|
for (const id of ["claude_app", "claude_code"]) {
|
|
143
|
+
if (!targets.has(id)) continue;
|
|
134
144
|
const selected = binding(id), compiled = plan(id), source = selected.source && permitted(id, selected.source) ? getSource(selected.source) : null;
|
|
135
145
|
try {
|
|
146
|
+
if (selected.enabled && compiled.defaultUnavailable) { setup[id] = "default_unavailable";continue; }
|
|
136
147
|
if (!selected.enabled || !compiled.models.length) { const result = restoreClaude({ ...options, client: id });setup[id] = result.preserved ? "preserved" : "not_configured";continue; }
|
|
137
148
|
if (selected.auto_sync === false) { setup[id] = "manual_sync";continue; }
|
|
138
149
|
if (id === "claude_app") desktopManaged ??= await inspectDesktop(options);
|
|
@@ -143,6 +154,9 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
143
154
|
setup[id] = result[id === "claude_app" ? "app" : "code"] || "not_configured";
|
|
144
155
|
} catch { setup[id] = "configuration_unavailable"; }
|
|
145
156
|
}
|
|
157
|
+
if (["claude_app", "claude_code"].some(id => setup[id] === "default_unavailable")) {
|
|
158
|
+
sharedSync = { ...sharedSync, state: "partially_preserved", limitations: [{ code: "default_model_unavailable" }] };return;
|
|
159
|
+
}
|
|
146
160
|
const shared = claudeSharedCapabilityPlan({ app: setup.claude_app === "configured" ? plan("claude_app").models : [],
|
|
147
161
|
code: setup.claude_code === "configured" ? plan("claude_code").models : [], support: capabilitySupport });
|
|
148
162
|
if (["claude_app", "claude_code"].some(id => setup[id] === "manual_sync")) {
|
|
@@ -160,53 +174,23 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
160
174
|
if (!body || typeof body !== "object" || Array.isArray(body)) return;
|
|
161
175
|
if (managed && (binding(client).history_isolation || source?.id.startsWith("api_"))) guardConversation(client, source.profileId(client === "codex" ? "responses" : "messages"), body, headers, identities()[client]);
|
|
162
176
|
}
|
|
163
|
-
async function applyCatalog(id, models, revision, checkedAt) {
|
|
177
|
+
async function applyCatalog(id, models, revision, checkedAt, active) {
|
|
178
|
+
if (!active()) throw accessError("ccdx_connections_conflict", 409);
|
|
164
179
|
const next = editable(), current = next.apis.find(api => api.id === id);
|
|
165
180
|
if (!current?.enabled || deploymentRevision(current, env) !== revision) throw accessError("ccdx_connections_conflict", 409);
|
|
166
181
|
const byId = new Map(models.map(model => [model.id, model]));
|
|
167
182
|
for (const model of current.models) if (byId.get(model.id)?.metadata) model.metadata = byId.get(model.id).metadata;
|
|
168
183
|
current.checked_at = checkedAt;
|
|
169
|
-
if (JSON.stringify(current) !== JSON.stringify(settings.apis.find(api => api.id === id))) {
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
async function refreshApi(id, force = false) {
|
|
173
|
-
const config = settings.apis.find(api => api.id === id && api.enabled);
|
|
174
|
-
if (!config) throw accessError("ccdx_client_source_disabled", 503);
|
|
175
|
-
const revision = deploymentRevision(config, env), cached = catalogReads.get(id), age = cached ? now() - cached.at : Infinity;
|
|
176
|
-
if (cached?.revision === revision && age >= 0 && age < (force || cached.error ? 60000 : 30 * 60000)) {
|
|
177
|
-
if (cached.error) throw cached.error;await applyCatalog(id, cached.models, revision, new Date(cached.at).toISOString());return cached.models;
|
|
184
|
+
if (JSON.stringify(current) !== JSON.stringify(settings.apis.find(api => api.id === id))) {
|
|
185
|
+
save(next);await syncClients(CLIENT_IDS.filter(client => binding(client).source === id || binding(client).deployments?.some(model => model.source === id)));
|
|
178
186
|
}
|
|
179
|
-
const savedAge = now() - Date.parse(config.checked_at);
|
|
180
|
-
if (!force && !cached && savedAge >= 0 && savedAge < 30 * 60000 && config.models.every(model => model.metadata?.state && model.metadata.deployment === revision)) return config.models;
|
|
181
|
-
const source = getSource(id), finish = track(source);
|
|
182
|
-
try {
|
|
183
|
-
const models = await source.discover({ signal: AbortSignal.any([stopping.signal, AbortSignal.timeout(20000)]) });
|
|
184
|
-
if (closed) throw accessError("ccdx_connections_closed", 503);
|
|
185
|
-
await applyCatalog(id, models, revision, new Date(now()).toISOString());
|
|
186
|
-
catalogReads.set(id, { revision, at: now(), models });
|
|
187
|
-
return models;
|
|
188
|
-
} catch (error) {
|
|
189
|
-
const code = /^ccdx_[a-z0-9_]+$/.test(error.code || "") ? error.code : "ccdx_api_catalog_unavailable";
|
|
190
|
-
const failure = accessError(code, [401, 403].includes(error.statusCode) ? error.statusCode : 502);
|
|
191
|
-
catalogReads.set(id, { revision, at: now(), error: failure });
|
|
192
|
-
discoveries.set(id, { state: "stale", code, checked_at: new Date(now()).toISOString() });throw failure;
|
|
193
|
-
} finally { finish(); }
|
|
194
187
|
}
|
|
195
188
|
function enqueue(work) { const job = serial.then(work);serial = job.catch(() => {});return job; }
|
|
196
|
-
|
|
197
|
-
if (closed || !managed) return Promise.resolve();
|
|
198
|
-
refreshFlight ||= (async () => {
|
|
199
|
-
for (const api of settings.apis) {
|
|
200
|
-
if (closed) break;if (!api.enabled) continue;
|
|
201
|
-
await enqueue(() => closed ? undefined : refreshApi(api.id)).catch(() => {});
|
|
202
|
-
}
|
|
203
|
-
})().finally(() => { refreshFlight = null; });
|
|
204
|
-
return refreshFlight;
|
|
205
|
-
}
|
|
189
|
+
const refreshApis = () => !closed && managed ? catalogRefresh.refreshAll(settings.apis.filter(api => api.enabled).map(api => api.id)) : Promise.resolve();
|
|
206
190
|
async function change(input) {
|
|
207
191
|
if (closed) throw accessError("ccdx_connections_closed", 503);
|
|
208
192
|
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");
|
|
209
|
-
const next = editable();let freshRef, previousRef
|
|
193
|
+
const next = editable();let freshRef, previousRef;
|
|
210
194
|
if (input.operation === "save_api") {
|
|
211
195
|
const existing = next.apis.find(api => api.id === input.id);
|
|
212
196
|
if (!existing && next.apis.length >= 16) throw accessError("ccdx_api_limit");
|
|
@@ -227,7 +211,7 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
227
211
|
}
|
|
228
212
|
if (existing) { previousRef = existing.secret_ref;next.apis[next.apis.indexOf(existing)] = config; } else next.apis.push(config);
|
|
229
213
|
checkedAccessSettings(next);
|
|
230
|
-
try { if (freshRef) await secrets.set(freshRef, input.key);save(next);
|
|
214
|
+
try { if (freshRef) await secrets.set(freshRef, input.key);save(next); } catch (error) { if (freshRef) await secrets.remove(freshRef).catch(() => {});throw error; }
|
|
231
215
|
} else if (["client", "preview_client"].includes(input.operation)) {
|
|
232
216
|
if (!CLIENT_IDS.includes(input.id) || typeof input.enabled !== "boolean" || !Array.isArray(input.allowed)
|
|
233
217
|
|| input.source !== null && input.source !== undefined && !input.allowed.includes(input.source)) throw accessError("ccdx_connections_action_invalid");
|
|
@@ -315,13 +299,10 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
315
299
|
const source = await legacy.pauseM365();if (source) retire(source);
|
|
316
300
|
}
|
|
317
301
|
}
|
|
318
|
-
} else if (input.operation === "discover") {
|
|
319
|
-
const models = await refreshApi(input.id, true);return { ...snapshot(), discovered: models };
|
|
320
302
|
} else throw accessError("ccdx_connections_action_invalid");
|
|
321
303
|
await syncClients();
|
|
322
304
|
if (input.operation === "client" && input.id === "codex") await clientAccessChanged?.(binding("codex").enabled);
|
|
323
305
|
if (previousRef && (freshRef || input.config?.key_env)) { if (!retiredSecrets.has(input.id)) retiredSecrets.set(input.id, new Set());retiredSecrets.get(input.id).add(previousRef);cleanSecrets(input.id); }
|
|
324
|
-
if (savedApi && enabled(savedApi)) await refreshApi(savedApi).catch(() => {});
|
|
325
306
|
return snapshot();
|
|
326
307
|
}
|
|
327
308
|
return {
|
|
@@ -329,7 +310,19 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
329
310
|
source: getSource,
|
|
330
311
|
connections: snapshot,
|
|
331
312
|
syncClients,
|
|
332
|
-
manageConnections(input) {
|
|
313
|
+
async manageConnections(input) {
|
|
314
|
+
if (!input) return snapshot();
|
|
315
|
+
if (validObject(input, ["operation", "id"]) && input.operation === "discover") {
|
|
316
|
+
const models = await catalogRefresh.refresh(input.id, true);return { ...snapshot(), discovered: models };
|
|
317
|
+
}
|
|
318
|
+
if (validObject(input, ["operation", "id"]) && input.operation === "cancel_discovery") { catalogRefresh.cancel(input.id);return snapshot(); }
|
|
319
|
+
const result = await enqueue(() => change(input));
|
|
320
|
+
if (input.operation === "save_api") {
|
|
321
|
+
const id = input.id || result.providers.find(api => !api.builtin && api.name === input.config.name)?.id;
|
|
322
|
+
if (enabled(id)) void catalogRefresh.refresh(id).catch(() => {});
|
|
323
|
+
} else if (input.operation === "provider" && input.enabled && input.id?.startsWith("api_")) void catalogRefresh.refresh(input.id).catch(() => {});
|
|
324
|
+
return input.operation === "save_api" ? snapshot() : result;
|
|
325
|
+
},
|
|
333
326
|
async start() { const old = legacy.start();if (managed) await syncClients();const result = await old;if (managed) await syncClients();void refreshApis();return result; },
|
|
334
327
|
async refresh() { const result = await Promise.allSettled([!managed || settings.providers.m365 ? legacy.refresh() : Promise.resolve(), refreshApis()]);if (result[0].status === "rejected") throw result[0].reason; },
|
|
335
328
|
selection() { return { ...legacy.selection(), codex: binding("codex").enabled ? binding("codex").source : null }; },
|
|
@@ -356,13 +349,20 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
356
349
|
current(req) {
|
|
357
350
|
if (!managed) return legacy.current();
|
|
358
351
|
const c = binding("codex"), compiled = plan("codex");
|
|
359
|
-
const source = requireSource("codex", Array.isArray(c.deployments) ? compiled.routes.get(compiled.defaultModel)?.source : c.source);
|
|
360
352
|
if (Array.isArray(c.deployments) && req?.method === "GET") {
|
|
353
|
+
if (!c.enabled) throw accessError("ccdx_client_source_disabled", 503);
|
|
361
354
|
if (codexRequiresKey()) requireCodexKey(req);
|
|
362
|
-
return {
|
|
363
|
-
client: {
|
|
355
|
+
return { id: "connections", registry: { models: { data: compiled.models.map(model => ({ ...model, id: model.public_id })) } },
|
|
356
|
+
client: { listModels: async () => ({ status: 200, body: JSON.stringify({ data: compiled.models.map(model => ({ ...model, id: model.public_id })) }) }) },
|
|
364
357
|
codexCatalog: codexClientCatalog(compiled) };
|
|
365
358
|
}
|
|
359
|
+
if (Array.isArray(c.deployments) && compiled.defaultUnavailable) {
|
|
360
|
+
if (req && codexRequiresKey()) requireCodexKey(req);
|
|
361
|
+
// Admission uses the common handler; resolveCodex must resolve the
|
|
362
|
+
// explicitly requested model before any provider request is opened.
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
const source = requireSource("codex", Array.isArray(c.deployments) ? compiled.routes.get(compiled.defaultModel)?.source : c.source);
|
|
366
366
|
if (source?.id.startsWith("api_") && req) requireCodexKey(req);
|
|
367
367
|
return req?.method === "GET" && source?.configuredModels && source.id.startsWith("api_") ? { ...source, codexCatalog: codexSourceCatalog(source) } : source;
|
|
368
368
|
},
|
|
@@ -386,6 +386,7 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
386
386
|
track,
|
|
387
387
|
validateConversation,
|
|
388
388
|
historyContext(headers, target) {
|
|
389
|
+
if (target.id === "connections") return {};
|
|
389
390
|
if (!target.id.startsWith("api_")) return legacy.historyContext(headers, target);
|
|
390
391
|
// Opaque Responses state never transfers to another API/key/configuration.
|
|
391
392
|
return { historyNamespace: target.profileId() };
|
|
@@ -466,6 +467,6 @@ export function createConnectionRuntime({ legacy, home, env = process.env, platf
|
|
|
466
467
|
if (managed && input.action === "switch") { const next = editable();if (next.clients.codex.source !== input.provider) next.clients.codex.history_isolation = true;next.clients.codex.source = input.provider;next.clients.codex.deployments = null;next.clients.codex.default_model = null;for (const key of ["model", "auto_review_model", "auto_review_effort"]) delete next.clients.codex[key];if (input.provider === "m365") Object.assign(next.clients.codex, legacy.selection().m365);save(next);await syncClients(); }
|
|
467
468
|
return result;
|
|
468
469
|
},
|
|
469
|
-
async close() { closed = true;
|
|
470
|
+
async close() { closed = true;await catalogRefresh.close();await serial;await syncFlight;for (const { source } of instances.values()) source.close();for (const source of retired) source.close();active.clear();for (const id of retiredSecrets.keys()) cleanSecrets(id);await Promise.allSettled([...cleanups]);secrets.close();await legacy.close(); },
|
|
470
471
|
};
|
|
471
472
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const words = (node, key, args) => globalThis.ccdxLanguage.set(node, key, args), format = key => globalThis.ccdxLanguage.format(key);
|
|
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
|
+
const drafts = new Map();let editorOrigin = null, discovery = null, desiredSource = null;
|
|
6
7
|
const apiForm = el("connection-api-form"), clientForm = el("connection-client-form");
|
|
7
8
|
const node = (tag, text, className) => { const item = document.createElement(tag);if (text !== undefined) item.textContent = text;if (className) item.className = className;return item; };
|
|
8
9
|
const source = id => data.providers.find(item => item.id === id), client = id => data.clients.find(item => item.id === id);
|
|
@@ -12,13 +13,14 @@
|
|
|
12
13
|
const message = (key, values) => words(el("connection-note"), key, values);
|
|
13
14
|
function button(key, action) { const item = node("button");item.type = "button";words(item, key);item.addEventListener("click", action);return item; }
|
|
14
15
|
function check(name, value, checked, text) { const label = node("label"), input = node("input");input.type = "checkbox";input.name = name;input.value = value;input.checked = checked;label.append(input, node("span", text));return label; }
|
|
15
|
-
async function api(input) {
|
|
16
|
+
async function api(input, signal) {
|
|
16
17
|
const response = await fetch("/_ccdx/ui/connections", { method: input ? "POST" : "GET", headers: { "X-CCDX-Dashboard": "1", ...(input ? { "Content-Type": "application/json" } : {}) },
|
|
17
|
-
cache: "no-store", signal: AbortSignal.timeout(35000), ...(input ? { body: JSON.stringify(input) } : {}) });
|
|
18
|
+
cache: "no-store", signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(35000)]) : AbortSignal.timeout(35000), ...(input ? { body: JSON.stringify(input) } : {}) });
|
|
18
19
|
const result = await response.json();if (!response.ok) throw new Error(result.error || "ccdx_connections_action_failed");
|
|
19
20
|
if (result.source !== "connections" || !Array.isArray(result.providers) || !Array.isArray(result.clients)) throw new Error("ccdx_connections_unavailable");return result;
|
|
20
21
|
}
|
|
21
22
|
function panels(which = "list") {
|
|
23
|
+
if (which !== "api") stopDiscovery();
|
|
22
24
|
root.hidden = which !== "list";
|
|
23
25
|
el("source-account-panel").hidden = el("model-providers").hidden = which !== "list";
|
|
24
26
|
el("connection-editor").hidden = which !== "api";el("connection-disable-editor").hidden = which !== "disable";
|
|
@@ -39,11 +41,11 @@
|
|
|
39
41
|
const allowed = data.clients.filter(c => c.enabled && c.allowed.includes(provider.id)).map(c => c.name).join(" / ");
|
|
40
42
|
const line = node("p", undefined, "hint");words(line, "api_allowed_summary", { clients: allowed || format("api_none") });info.append(line);
|
|
41
43
|
if (provider.discovery?.state === "stale") { const warning = node("p", undefined, "hint");words(warning, "cap_catalog_stale");warning.append(" ", provider.discovery.code);info.append(warning); }
|
|
42
|
-
actions.append(button(
|
|
44
|
+
if (!provider.builtin) actions.append(button("api_manage", () => editApi(provider)));
|
|
43
45
|
const toggle = node("input");toggle.type = "checkbox";toggle.checked = true;toggle.setAttribute("role", "switch");toggle.setAttribute("aria-label", format("api_disable_source") + " " + provider.name);
|
|
44
46
|
toggle.addEventListener("change", () => { toggle.checked = true;disableSource(provider); });actions.append(toggle);
|
|
45
47
|
} else actions.append(button("api_restore", () => void change({ operation: "provider", id: provider.id, enabled: true })));
|
|
46
|
-
row.append(info, actions);(provider.enabled
|
|
48
|
+
row.append(info, actions);if (!provider.enabled) disabledSources.append(row);else if (provider.id === selectedProvider) providerList.append(row);
|
|
47
49
|
}
|
|
48
50
|
const current = editingClient && client(editingClient);
|
|
49
51
|
if (current) {
|
|
@@ -67,11 +69,19 @@
|
|
|
67
69
|
async function load() {
|
|
68
70
|
if (busy) return;const current = ++generation;
|
|
69
71
|
try { const result = await api();if (current !== generation) return;data = result;mountClient();list(); }
|
|
70
|
-
catch (error) { message(error.message); }
|
|
72
|
+
catch (error) { if (!data) message(error.message); }
|
|
71
73
|
}
|
|
72
74
|
async function change(input, done) {
|
|
73
|
-
if (busy) return;busy = true;generation++;
|
|
74
|
-
|
|
75
|
+
if (busy) return;busy = true;generation++;
|
|
76
|
+
const trigger = input.operation === "client" ? clientForm.querySelector('button[type="submit"]') : input.operation === "preview_client" ? el("connection-sync-preview")
|
|
77
|
+
: input.operation === "save_api" ? apiForm.querySelector('button[type="submit"]') : document.activeElement;
|
|
78
|
+
const oldKey = trigger?.dataset.i18n, oldText = trigger?.textContent;
|
|
79
|
+
if (trigger?.tagName === "BUTTON") { trigger.setAttribute("aria-busy", "true");trigger.disabled = true;words(trigger, input.operation === "preview_client" ? "api_reading" : "api_saving"); }
|
|
80
|
+
try { if (input.operation === "save_api") await stopDiscovery();data = await api(input);if (input.operation === "client") { drafts.delete(input.id);if (editingClient === input.id) bindingDirty = false; }mountClient();list();done?.(data);if (!done) {
|
|
81
|
+
if (input.operation === "save_api") {
|
|
82
|
+
desiredSource = input.id || data.providers.find(p => !p.builtin && p.name === input.config.name)?.id;
|
|
83
|
+
stopDiscovery();
|
|
84
|
+
} else if (input.operation === "provider" && input.enabled) desiredSource = input.id;
|
|
75
85
|
panels();let key = input.operation === "save_api" ? "api_config_saved" : input.operation === "provider" ? input.enabled ? "api_provider_enabled" : "api_provider_disabled"
|
|
76
86
|
: !input.enabled ? "api_client_disabled" : !input.source ? "api_client_enabled" : "api_saved";
|
|
77
87
|
const setup = data.clients.find(c => c.id === input.id)?.setup;
|
|
@@ -81,7 +91,9 @@
|
|
|
81
91
|
if (input.operation === "client") words(el("connection-client-note"), key);else message(key);
|
|
82
92
|
}window.dispatchEvent(new CustomEvent("ccdx:connections"));void dashboardRefresh.refresh("auth", { force: true });void dashboardRefresh.refresh("status", { force: true }); }
|
|
83
93
|
catch (error) { if (input.operation === "client") words(el("connection-client-note"), error.message);else message(error.message); }
|
|
84
|
-
finally { busy = false;
|
|
94
|
+
finally { busy = false;if (trigger?.tagName === "BUTTON") { trigger.removeAttribute("aria-busy");trigger.disabled = false;if (oldKey) words(trigger, oldKey);else trigger.textContent = oldText; }
|
|
95
|
+
if (["client", "preview_client"].includes(input.operation)) bindingRows();
|
|
96
|
+
}
|
|
85
97
|
}
|
|
86
98
|
const resolved = (model, protocol = model.protocols.includes("messages") ? "messages" : model.protocols[0]) => {
|
|
87
99
|
const metadata = model.metadata?.deployment === source(editing)?.deployment_revision ? model.metadata : null;
|
|
@@ -180,7 +192,7 @@
|
|
|
180
192
|
}
|
|
181
193
|
function setEndpoints(base, endpoints) { for (const [api, path] of [["messages", "messages"], ["responses", "responses"], ["chat", "chat/completions"]]) apiForm.elements[api + "_url"].value = endpoints?.[api] || base.replace(/\/+$/, "") + "/" + path; }
|
|
182
194
|
function editApi(provider) {
|
|
183
|
-
editing = provider?.id || null;panels("api");apiForm.reset();words(el("connection-editor-title"), provider ? "api_manage" : "api_add");
|
|
195
|
+
stopDiscovery();editorOrigin = document.activeElement;editing = provider?.id || null;panels("api");apiForm.reset();words(el("connection-editor-title"), provider ? "api_manage" : "api_add");
|
|
184
196
|
apiForm.elements.name.value = provider?.name || "";apiForm.elements.base.value = provider?.base_url || "";
|
|
185
197
|
apiForm.elements.key.required = !provider;globalThis.ccdxLanguage.set(apiForm.elements.key, provider ? "api_key_keep" : "api_key_enter", {}, "placeholder");
|
|
186
198
|
apiForm.elements.auth_header.value = provider?.auth_header || "x-api-key";
|
|
@@ -189,7 +201,7 @@
|
|
|
189
201
|
setEndpoints(provider?.base_url || "", provider?.endpoints);
|
|
190
202
|
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)));
|
|
191
203
|
el("connection-model-detail").hidden = true;
|
|
192
|
-
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 = "";
|
|
204
|
+
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();
|
|
193
205
|
}
|
|
194
206
|
apiForm.elements.base.addEventListener("change", () => setEndpoints(apiForm.elements.base.value));
|
|
195
207
|
for (const input of apiForm.querySelectorAll('[name="protocol"]')) input.addEventListener("change", () => {
|
|
@@ -217,56 +229,83 @@
|
|
|
217
229
|
const id = el("connection-model-id").value.trim();if (!id || models.some(model => model.id === id) || models.length >= 500) return;
|
|
218
230
|
models.push({ id, protocols: [] });selectedModels.add(id);el("connection-model-id").value = "";modelRows();
|
|
219
231
|
});
|
|
220
|
-
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
function stopDiscovery() {
|
|
233
|
+
const previous = discovery;if (!previous) return;discovery = null;previous.controller.abort();
|
|
234
|
+
const cancelled = api({ operation: "cancel_discovery", id: previous.id }).catch(() => {});
|
|
235
|
+
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;
|
|
236
|
+
}
|
|
237
|
+
el("connection-discover-cancel").addEventListener("click", () => { stopDiscovery();message("api_read_cancelled");el("connection-discover").focus(); });
|
|
238
|
+
el("connection-discover").addEventListener("click", async () => {
|
|
239
|
+
if (discovery || !editing) return;
|
|
240
|
+
const read = { id: editing, controller: new AbortController() };discovery = read;
|
|
241
|
+
const trigger = el("connection-discover");trigger.disabled = true;trigger.setAttribute("aria-busy", "true");words(trigger, "api_reading");el("connection-discover-cancel").hidden = false;
|
|
242
|
+
try {
|
|
243
|
+
const result = await api({ operation: "discover", id: read.id }, read.controller.signal);if (discovery !== read || editing !== read.id) return;
|
|
244
|
+
data = result;
|
|
245
|
+
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.metadata ? { metadata: model.metadata } : {}) } : model); }
|
|
246
|
+
models = [...known.values()].slice(0, 500);modelRows();message("api_models_read");
|
|
247
|
+
} catch (error) { if (discovery === read) message(error.message); }
|
|
248
|
+
finally { if (discovery === read) { discovery = null;trigger.disabled = false;trigger.removeAttribute("aria-busy");words(trigger, "api_read_models");el("connection-discover-cancel").hidden = true; } }
|
|
249
|
+
});
|
|
224
250
|
const bindingKey = (source, model) => source + "\0" + model;
|
|
225
251
|
const routeId = item => item.route_id || item.public_id;
|
|
252
|
+
function rememberDraft() {
|
|
253
|
+
if (editingClient && bindingDirty) drafts.set(editingClient, { selection: new Set(bindingSelection), defaultModel: bindingDefault, autoSync: el("connection-auto-sync").checked });
|
|
254
|
+
}
|
|
226
255
|
function mountClient(force = false) {
|
|
227
256
|
if (!data) return;
|
|
228
257
|
const route = location.hash.slice(1), id = route === "claude" ? claudeClient : "codex";
|
|
229
|
-
const mount = el(route === "claude" ? "claude-model-management" : "codex-model-management");
|
|
230
258
|
if (!["codex", "claude"].includes(route)) return;
|
|
259
|
+
rememberDraft();
|
|
260
|
+
const mount = el(route === "claude" ? "claude-model-management" : "codex-model-management");
|
|
231
261
|
mount.append(el("connection-clients"), el("connection-client-editor"));
|
|
232
262
|
const c = client(id);el("connection-client-editor").hidden = !c.enabled;
|
|
233
263
|
if (editingClient !== id || force || !bindingDirty) {
|
|
234
|
-
editingClient = id;bindingDirty =
|
|
264
|
+
editingClient = id;const draft = drafts.get(id);bindingDirty = Boolean(draft);
|
|
235
265
|
const selected = Array.isArray(c.deployments) ? c.deployments : (c.model_plan?.models || []).map(model => ({ source: model.source, model: model.id }));
|
|
236
|
-
bindingSelection = new Set(selected.map(item => bindingKey(item.source, item.model)));
|
|
237
|
-
bindingDefault = c.default_model || c.model_plan?.models.find(model => model.public_id === c.model_plan?.default_model)?.route_id || null;
|
|
238
|
-
el("connection-auto-sync").checked = c.auto_sync !== false;
|
|
266
|
+
bindingSelection = draft ? new Set(draft.selection) : new Set(selected.map(item => bindingKey(item.source, item.model)));
|
|
267
|
+
bindingDefault = draft ? draft.defaultModel : c.default_model || c.model_plan?.models.find(model => model.public_id === c.model_plan?.default_model)?.route_id || null;
|
|
268
|
+
el("connection-auto-sync").checked = draft ? draft.autoSync : c.auto_sync !== false;
|
|
239
269
|
el("connection-sync-result").hidden = true;el("connection-client-note").textContent = "";
|
|
240
270
|
}
|
|
241
|
-
words(el("connection-client-title"), "cap_visible_model");list();
|
|
271
|
+
bindingRows(document.activeElement?.name === "binding-model" ? { kind: "selection", key: document.activeElement.value } : document.activeElement?.dataset.binding ? { kind: "default", key: document.activeElement.dataset.binding } : null);words(el("connection-client-title"), "cap_visible_model");list();
|
|
242
272
|
}
|
|
243
|
-
function bindingRows() {
|
|
273
|
+
function bindingRows(focus) {
|
|
244
274
|
el("connection-client-cancel").disabled = !bindingDirty;
|
|
245
275
|
const body = el("connection-bindings"), c = client(editingClient);body.replaceChildren();
|
|
246
276
|
const available = c.model_plan?.available || [], availableKeys = new Set(available.map(item => bindingKey(item.source, item.id)));
|
|
247
|
-
const missing = [...bindingSelection].filter(key => !availableKeys.has(key)).map(key => { const [source, id] = key.split("\0");return { source, id, unavailable: true }; });
|
|
277
|
+
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 }; });
|
|
248
278
|
for (const item of [...available, ...missing]) {
|
|
249
279
|
const key = bindingKey(item.source, item.id), row = node("tr"), name = node("td"), capability = item.capability?.values || {};
|
|
250
280
|
const selection = check("binding-model", key, bindingSelection.has(key), item.id);
|
|
251
281
|
selection.firstChild.addEventListener("change", event => {
|
|
252
282
|
bindingDirty = true;if (event.target.checked) { bindingSelection.add(key);bindingDefault ||= routeId(item); }
|
|
253
|
-
else { bindingSelection.delete(key);if (bindingDefault === routeId(item) || !
|
|
254
|
-
bindingRows();
|
|
283
|
+
else { bindingSelection.delete(key);if (bindingDefault === routeId(item) || !bindingSelection.size) bindingDefault = null; }
|
|
284
|
+
rememberDraft();bindingRows({ kind: "selection", key });
|
|
255
285
|
});name.append(selection);
|
|
256
|
-
const action = button(bindingDefault === routeId(item) && bindingSelection.has(key) ? "cap_default" : "cap_set_default", () => { bindingDirty = true;bindingSelection.add(key);bindingDefault = routeId(item);bindingRows(); });
|
|
286
|
+
const action = button(bindingDefault === routeId(item) && bindingSelection.has(key) ? "cap_default" : "cap_set_default", () => { bindingDirty = true;bindingSelection.add(key);bindingDefault = routeId(item);rememberDraft();bindingRows({ kind: "default", key }); });
|
|
257
287
|
action.setAttribute("aria-pressed", String(bindingDefault === routeId(item) && bindingSelection.has(key)));
|
|
258
|
-
|
|
259
|
-
|
|
288
|
+
action.dataset.binding = key;action.disabled = Boolean(item.unavailable);action.setAttribute("aria-label", item.id + " · " + format(bindingDefault === routeId(item) ? "cap_default" : "cap_set_default"));
|
|
289
|
+
if (item.unavailable) { const warning = node("span", undefined, "hint binding-unavailable");words(warning, "cap_model_unavailable");name.append(warning); }
|
|
290
|
+
const cell = node("td");cell.append(action);
|
|
291
|
+
const details = [node("td", source(item.source)?.name || item.source), node("td", count(capability.context_window)), node("td", reasoningText(capability))];
|
|
292
|
+
details.forEach((cell, i) => cell.dataset.label = format(["source", "cap_context", "cap_reasoning"][i]));
|
|
293
|
+
row.append(name, ...details, cell);body.append(row);
|
|
260
294
|
}
|
|
295
|
+
const unavailableDefault = bindingSelection.size > 0 && !available.some(item => routeId(item) === bindingDefault && bindingSelection.has(bindingKey(item.source, item.id)));
|
|
296
|
+
const warning = el("connection-default-note");warning.hidden = !unavailableDefault;words(warning, "cap_default_unavailable");
|
|
297
|
+
clientForm.querySelector('button[type="submit"]').disabled = unavailableDefault || busy;
|
|
298
|
+
words(el("connection-draft-state"), bindingDirty ? "cap_unsaved" : "cap_saved");
|
|
299
|
+
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(); }
|
|
261
300
|
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); }
|
|
262
301
|
}
|
|
263
302
|
function editClient(c) { location.hash = c.id === "codex" ? "codex" : "claude";if (c.id !== "codex") claudeClient = c.id;mountClient(true); }
|
|
264
303
|
for (const segment of document.querySelectorAll("[data-claude-client]")) segment.addEventListener("click", () => {
|
|
265
|
-
claudeClient = segment.dataset.claudeClient;
|
|
304
|
+
rememberDraft();claudeClient = segment.dataset.claudeClient;
|
|
266
305
|
for (const button of document.querySelectorAll("[data-claude-client]")) button.setAttribute("aria-pressed", String(button === segment));mountClient(true);
|
|
267
306
|
});
|
|
268
|
-
el("connection-auto-sync").addEventListener("change", () => { bindingDirty = true;el("connection-client-cancel").disabled = false; });
|
|
269
|
-
el("connection-client-cancel").addEventListener("click", () => mountClient(true));
|
|
307
|
+
el("connection-auto-sync").addEventListener("change", () => { bindingDirty = true;rememberDraft();el("connection-client-cancel").disabled = false;words(el("connection-draft-state"), "cap_unsaved"); });
|
|
308
|
+
el("connection-client-cancel").addEventListener("click", () => { drafts.delete(editingClient);bindingDirty = false;mountClient(true); });
|
|
270
309
|
function bindingInput(operation) {
|
|
271
310
|
const c = client(editingClient);return { operation, id: c.id, enabled: true, allowed: c.allowed,
|
|
272
311
|
deployments: [...bindingSelection].map(key => { const [source, model] = key.split("\0");return { source, model }; }),
|
|
@@ -283,9 +322,11 @@
|
|
|
283
322
|
el("connection-disable-form").addEventListener("submit", e => { e.preventDefault();void change({ operation: "provider", id: disabling, enabled: false,
|
|
284
323
|
replacements: Object.fromEntries([...el("connection-replacements").querySelectorAll("select")].map(select => [select.name, select.value || null])) }); });
|
|
285
324
|
el("connection-add").addEventListener("click", () => { if (data) editApi(); });
|
|
286
|
-
for (const id of ["connection-cancel", "connection-disable-cancel"]) el(id).addEventListener("click", () => panels());
|
|
325
|
+
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(); });
|
|
287
326
|
window.addEventListener("hashchange", () => { apiForm.elements.key.value = "";mountClient();if (["#models", "#claude", "#codex"].includes(location.hash)) void load(); });
|
|
288
327
|
window.addEventListener("ccdx:choose-source", event => { if (typeof event.detail?.id === "string" && providerEntries.some(p => p.id === event.detail.id)) chooseProvider(event.detail.id); });
|
|
328
|
+
window.addEventListener("ccdx:source-view", () => { if (data) list(); });
|
|
329
|
+
window.addEventListener("ccdx:providers", () => { if (desiredSource && providerEntries.some(p => p.id === desiredSource)) { const id = desiredSource;desiredSource = null;chooseProvider(id); }if (data) list(); });
|
|
289
330
|
new MutationObserver(() => { if (data) list(); }).observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] });
|
|
290
331
|
globalThis.ccdxConnections = { load, editClient: id => { if (data && client(id)) { editClient(client(id)); } } };
|
|
291
332
|
for (const button of document.querySelectorAll("[data-client-access]")) button.addEventListener("click", () => globalThis.ccdxConnections.editClient(button.dataset.clientAccess));
|
package/src/dashboard/console.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const el = id => document.getElementById(id);
|
|
3
3
|
const label = (node, key, values = {}) => globalThis.ccdxLanguage.set(node, key, values);
|
|
4
4
|
const titles = { overview: "overview", codex: "Codex", claude: "Claude", models: "model_services", usage: "usage_and_diagnostics", requests: "request_records", checks: "tools_checks_title", system: "system_and_settings" };
|
|
5
|
-
const settingsViews = ["codex", "models", "system", "checks"];
|
|
5
|
+
const settingsViews = ["codex", "claude", "models", "system", "checks"];
|
|
6
6
|
let current = "overview", settings = null, settingsPending = false, stopped = false, timer = null, ticks = 0;
|
|
7
7
|
let sourceDirty = false, reviewDirty = false, sourceModels = [], modelsPreference = null, sourceGeneration = 0, modelsSource = null;
|
|
8
8
|
let settingsReadAt = null;
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
settingsPending = true;
|
|
167
167
|
el("terminal-color-theme").disabled = true;
|
|
168
168
|
syncAccountControls();
|
|
169
|
-
try { applySettings(await api());settingsReadAt = time(Date.now()); }
|
|
169
|
+
try { applySettings(await api());settingsReadAt = time(Date.now());void globalThis.ccdxConnections?.load(); }
|
|
170
170
|
catch (error) {
|
|
171
171
|
for (const id of ["settings-note", ...(settingsViews.includes(current) ? ["page-settings-note"] : [])]) {
|
|
172
172
|
label(el(id), settingsReadAt ? "showing_previous_data_updated_time" : "could_not_read_settings", { time: settingsReadAt });
|
package/src/dashboard/index.html
CHANGED
|
@@ -64,16 +64,17 @@
|
|
|
64
64
|
<section class="panel dashboard-section"><h2 data-i18n="this_run_usage">THIS RUN</h2><p id="runtime-usage" class="table-note"></p><p class="table-note"><span data-i18n="approx_cache_hit_rate">Approx. cache hit rate</span>: <strong id="runtime-cache-hit" data-i18n-title="runtime_cache_hit_basis" title="Reused input / input tokens. ~ Partial counts. — Unknown or invalid.">—</strong></p><p class="hint" data-i18n="updated_from_returned_usage_not_a_live_bill_pending_usage_is_not">Counts returned usage only. Pending usage is not included. This is not a live bill.</p></section>
|
|
65
65
|
</div>
|
|
66
66
|
<div data-view="codex" hidden>
|
|
67
|
-
<div id="codex-model-management"> <section class="
|
|
68
|
-
<
|
|
67
|
+
<div id="codex-model-management"> <section class="connection-access" id="connection-clients">
|
|
68
|
+
<div id="connection-client-list"></div>
|
|
69
69
|
<details id="connection-disabled-clients" class="connection-disabled" hidden><summary data-i18n="api_disabled_clients">Disabled clients</summary><div id="connection-disabled-client-list"></div></details>
|
|
70
70
|
</section>
|
|
71
71
|
<section class="panel dashboard-section" id="connection-client-editor" hidden aria-labelledby="connection-client-title">
|
|
72
|
-
<div class="panel-heading"><h2 id="connection-client-title"></h2><
|
|
72
|
+
<div class="panel-heading"><h2 id="connection-client-title"></h2><span id="connection-draft-state" class="hint"></span></div>
|
|
73
73
|
<form id="connection-client-form">
|
|
74
|
-
<
|
|
74
|
+
<p id="connection-default-note" class="hint" role="status" hidden></p>
|
|
75
|
+
<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>
|
|
75
76
|
<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>
|
|
76
|
-
<div class="section-actions"><button type="submit" data-i18n="api_save">Save</button><button type="button" id="connection-sync-preview" data-i18n="cap_sync_preview">Review sync</button></div>
|
|
77
|
+
<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>
|
|
77
78
|
<p id="connection-client-note" class="hint" role="status" aria-live="polite"></p>
|
|
78
79
|
<div id="connection-sync-result" hidden></div>
|
|
79
80
|
</form>
|
|
@@ -144,25 +145,26 @@
|
|
|
144
145
|
<div data-view="claude" hidden>
|
|
145
146
|
<div class="provider-tabs client-segments" role="group" aria-label="Claude app"><button type="button" data-claude-client="claude_app" aria-pressed="true">Claude App</button><button type="button" data-claude-client="claude_code" aria-pressed="false">Claude Code</button></div>
|
|
146
147
|
<div id="claude-model-management"></div>
|
|
147
|
-
<
|
|
148
|
-
<
|
|
148
|
+
<details class="panel dashboard-section" id="claude-connections">
|
|
149
|
+
<summary data-i18n="connection_details">Connection details</summary>
|
|
149
150
|
<div class="table-wrap"><table><thead><tr><th data-i18n="client">APP</th><th data-i18n="connection_setup" data-i18n-title="configured_not_successful">Setup</th><th data-i18n="local_bridge">Local service</th><th data-i18n="last_request">LAST REQUEST</th></tr></thead><tbody id="claude-clients"></tbody></table></div>
|
|
150
151
|
<p id="claude-client-state" class="hint"></p>
|
|
151
152
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
<
|
|
155
|
-
<
|
|
153
|
+
<p id="claude-route" class="table-note"></p><p>Anthropic Messages</p><a class="section-link" href="#models" data-i18n="model_services">Model sources</a>
|
|
154
|
+
</details>
|
|
155
|
+
<details class="panel dashboard-section" id="claude-performance">
|
|
156
|
+
<summary data-i18n="request_performance">REQUEST PERFORMANCE</summary>
|
|
156
157
|
<dl class="stats"><div><dt data-i18n="completed">Completed</dt><dd id="claude-completed">—</dd></div><div><dt data-i18n="incomplete">Incomplete</dt><dd id="claude-incomplete">—</dd></div><div><dt data-i18n="failed">Failed</dt><dd id="claude-failed">—</dd></div><div><dt data-i18n="cancelled">Cancelled</dt><dd id="claude-cancelled">—</dd></div><div><dt data-i18n="first_output">First output</dt><dd id="claude-ttft">—</dd></div><div><dt data-i18n="output_speed">Output speed</dt><dd id="claude-speed">—</dd></div></dl>
|
|
157
158
|
|
|
158
159
|
|
|
159
160
|
<dl class="stats timing-stats"><div><dt data-i18n="estimated_percentiles" data-i18n-title="percentile_basis">Approx. first-output P50 / P95</dt><dd id="claude-ttft-percentiles">—</dd></div></dl>
|
|
160
161
|
<a class="section-link" href="#requests" data-i18n="view_request_details">View request details</a>
|
|
161
|
-
</
|
|
162
|
+
</details>
|
|
162
163
|
</div>
|
|
163
164
|
<div data-view="models" hidden>
|
|
164
165
|
<section class="panel dashboard-section" id="connection-sources">
|
|
165
166
|
<div class="panel-heading"><h2 data-i18n="model_services">Model sources</h2><button id="connection-add" type="button" data-i18n="api_add">Add API</button></div>
|
|
167
|
+
<div id="model-providers" class="provider-tabs" role="tablist" aria-label="Model providers" data-i18n-label="model_providers"></div>
|
|
166
168
|
<div id="connection-source-list"></div>
|
|
167
169
|
<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>
|
|
168
170
|
</section>
|
|
@@ -181,7 +183,7 @@
|
|
|
181
183
|
<label><span data-i18n="api_key_env">Read key from environment</span><input name="key_env" type="text" autocomplete="off" spellcheck="false" placeholder="CCDX_COMPANY_API_KEY"><span class="hint" data-i18n="api_key_env_hint">Optional for servers without a credential service. Set before starting CCDX.</span></label>
|
|
182
184
|
</div></details>
|
|
183
185
|
<fieldset><legend data-i18n="api_allowed_clients">Allowed clients</legend><div class="connection-checks" id="connection-allowed-clients"></div></fieldset>
|
|
184
|
-
<fieldset><legend data-i18n="model_catalog">Model list</legend><div class="section-actions"><button type="button" id="connection-discover" data-i18n="api_read_models">Read models</button><span class="hint" data-i18n="api_discovery_save_first">Save the API first. No chat request is sent.</span></div>
|
|
186
|
+
<fieldset><legend data-i18n="model_catalog">Model list</legend><div class="section-actions"><button type="button" id="connection-discover" data-i18n="api_read_models">Read models</button><button type="button" id="connection-discover-cancel" data-i18n="cancel" hidden>Cancel</button><span class="hint" data-i18n="api_discovery_save_first">Save the API first. No chat request is sent.</span></div>
|
|
185
187
|
<details class="tool-details" id="connection-manual-model"><summary data-i18n="api_manual_model">Add a model manually</summary><div class="section-actions"><input type="text" id="connection-model-id" spellcheck="false" autocomplete="off" aria-label="Model ID" placeholder="Model ID"><button type="button" id="connection-model-add" data-i18n="api_add_model">Add model</button></div></details>
|
|
186
188
|
<p class="hint" data-i18n="api_model_protocol_hint">Choose the APIs each model supports.</p><div class="table-wrap"><table><thead><tr><th data-i18n="model">Model</th><th data-i18n="api_protocols">Available APIs</th><th data-i18n="cap_context">Context</th><th data-i18n="cap_reasoning">Reasoning</th><th data-i18n="cap_search">Search</th><th></th></tr></thead><tbody id="connection-models"></tbody></table></div>
|
|
187
189
|
</fieldset>
|
|
@@ -193,8 +195,6 @@
|
|
|
193
195
|
<p id="connection-note" class="hint" role="status" aria-live="polite"></p>
|
|
194
196
|
|
|
195
197
|
|
|
196
|
-
<div id="model-providers" class="provider-tabs" role="tablist" aria-label="Model providers" data-i18n-label="model_providers"></div>
|
|
197
|
-
|
|
198
198
|
<div id="source-account-panel" role="tabpanel">
|
|
199
199
|
<p id="source-status-note" class="hint" role="status"></p>
|
|
200
200
|
<section class="panel dashboard-section" id="github-account">
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
<p id="m365-account-note" class="hint" role="status" aria-live="polite"></p>
|
|
232
232
|
</section>
|
|
233
233
|
<details class="panel dashboard-section model-catalog" id="upstream-models" open>
|
|
234
|
-
<summary class="panel-heading"><h2 data-i18n="model_catalog">MODEL LIST</h2><span id="models-state" data-i18n="checking_live">CHECKING</span></summary>
|
|
234
|
+
<summary class="panel-heading"><h2 data-i18n="model_catalog">MODEL LIST</h2><span id="models-state" role="status" aria-live="polite" data-i18n="checking_live">CHECKING</span></summary>
|
|
235
235
|
<div class="section-actions"><button id="refresh-models" type="button" data-i18n="refresh">Refresh</button></div>
|
|
236
236
|
<p id="models-note" class="table-note" data-i18n="reading_provider_catalog">Loading model list…</p>
|
|
237
237
|
<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>
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const translations = {
|
|
3
|
+
"api_saving": ["Saving…", "保存中…"],
|
|
4
|
+
"api_reading": ["Reading…", "读取中…"],
|
|
5
|
+
"api_read_cancelled": ["Read cancelled. Saved metadata is kept.", "已取消读取,保留已存资料。"],
|
|
6
|
+
"cap_unsaved": ["Unsaved changes", "尚未保存"],
|
|
7
|
+
"cap_saved": ["Saved", "已保存"],
|
|
8
|
+
"cap_default_unavailable": ["Default model unavailable. Choose a default before saving.", "默认模型暂不可用,请选择默认后保存。"],
|
|
9
|
+
"cap_limit_default_model_unavailable": ["Default model unavailable. Existing app settings were kept.", "默认模型暂不可用,保留应用设置。"],
|
|
3
10
|
"cap_discard_changes": ["Discard changes", "放弃修改"],
|
|
4
11
|
"cap_current_budget": ["Current budget", "当前预算"],
|
|
5
12
|
"cap_proposed_budget": ["After sync", "同步后预算"],
|
|
@@ -14,7 +21,7 @@
|
|
|
14
21
|
"cap_set_default": ["Set default", "设为默认"],
|
|
15
22
|
"cap_details": ["Details", "能力详情"],
|
|
16
23
|
"cap_app_access": ["App access", "应用接入"],
|
|
17
|
-
"cap_unknown": ["Not
|
|
24
|
+
"cap_unknown": ["Not provided", "未提供"],
|
|
18
25
|
"cap_supported": ["Supported", "支持"],
|
|
19
26
|
"cap_unsupported": ["Not supported", "不支持"],
|
|
20
27
|
"cap_auto_sync": ["Sync model settings", "同步模型设置"],
|
|
@@ -102,7 +109,7 @@
|
|
|
102
109
|
"api_client_disabled": ["CCDX access is off; the app stays open.", "接入已关闭,应用保持运行。"],
|
|
103
110
|
"api_close_client": ["Disable client access", "关闭客户端接入"],
|
|
104
111
|
"api_saved": ["Saved. Reopen the app for first-time setup; existing requests stay unchanged.", "已保存。首次接入请重新打开应用。"],
|
|
105
|
-
"api_config_saved": ["API saved.
|
|
112
|
+
"api_config_saved": ["API saved. Metadata refresh runs separately.", "API 已保存,模型资料另行刷新。"],
|
|
106
113
|
"api_provider_disabled": ["Source disabled. Its configuration was kept.", "来源已关闭,配置已保留。"],
|
|
107
114
|
"api_provider_enabled": ["Source enabled. Client selections are unchanged.", "来源已开启,客户端来源未改变。"],
|
|
108
115
|
"api_client_enabled": ["Client enabled. Choose a source to connect.", "客户端已开启,请选择来源。"],
|
package/src/dashboard/status.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
let contextSignature;
|
|
7
7
|
const sourceNames = new Map([["github", "GitHub Copilot"], ["m365", "Microsoft 365"]]);
|
|
8
8
|
|
|
9
|
+
const sourceLabel = id => globalThis.ccdxConnectionNames?.[id] || sourceNames.get(id) || id;
|
|
9
10
|
function renderProviders(data) {
|
|
10
11
|
const providers = data.providers || [];
|
|
11
12
|
const states = { saved: "saved_locally", authorized: "authorized", disabled: "disabled", unavailable: "unavailable_ca184",
|
|
12
13
|
unknown: "unknown", unconfigured: "not_configured", ready: "ready", checking: "checking", unsupported: "unsupported",
|
|
13
|
-
configured: "configured", preserved: "existing_settings_kept", partially_preserved: "existing_settings_kept",
|
|
14
|
+
configured: "configured", default_unavailable: "cap_default_unavailable", preserved: "existing_settings_kept", partially_preserved: "existing_settings_kept",
|
|
14
15
|
restored: "settings_restored", not_installed: "not_installed", configuration_unavailable: "setup_unavailable", not_configured: "unknown", standby: "standby" };
|
|
15
16
|
const auth = element("provider-auth"), clients = element("provider-clients"), requests = element("provider-requests"), claudeClients = element("claude-clients");
|
|
16
17
|
auth.replaceChildren();clients.replaceChildren();requests.replaceChildren();claudeClients?.replaceChildren();
|
|
@@ -129,7 +130,7 @@
|
|
|
129
130
|
const timeline = failure.timeline;
|
|
130
131
|
const provider = failure.provider || timeline?.provider;
|
|
131
132
|
if (provider) {
|
|
132
|
-
const source =
|
|
133
|
+
const source = sourceLabel(provider);
|
|
133
134
|
const original = phrase("detail_retry", summary);
|
|
134
135
|
localize(title, "source_failure_summary", { source, detail: original });
|
|
135
136
|
}
|
|
@@ -182,6 +183,7 @@
|
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
function render(data) {
|
|
186
|
+
for (const source of data.providers?.connections?.providers || []) sourceNames.set(source.id, source.name);
|
|
185
187
|
globalThis.ccdxDashboardActivity?.update(data.model_activity);
|
|
186
188
|
globalThis.ccdxDashboardFlow?.update(data);
|
|
187
189
|
text("version", `v${data.version || "?"}`);
|
|
@@ -233,7 +235,7 @@
|
|
|
233
235
|
const routes = { ...data.stream_performance?.by_route, ...claudeMetrics?.by_route };
|
|
234
236
|
for (const [protocol, route] of Object.entries(routes)) for (const [source, stats] of Object.entries(route.by_provider || {})) {
|
|
235
237
|
const totals = stats.terminal_outcomes.totals;
|
|
236
|
-
sourceBody.append(tableRow([
|
|
238
|
+
sourceBody.append(tableRow([sourceLabel(source), protocol, number(stats.active), ...["completed", "incomplete", "failed", "cancelled", "unknown"].map(outcome => number(totals[outcome]))]));
|
|
237
239
|
}
|
|
238
240
|
if (!sourceBody.children.length) emptyTable("source-requests-body", 8, "no_requests_observed");
|
|
239
241
|
}
|
|
@@ -300,7 +302,7 @@
|
|
|
300
302
|
? `${(100 * Number(context.input_tokens) / Number(context.context_window_tokens)).toFixed(1)}%` : "—";
|
|
301
303
|
const at = Date.parse(request.at);
|
|
302
304
|
const row = tableRow([Number.isFinite(at) ? time(at) : "—",
|
|
303
|
-
String(
|
|
305
|
+
String(sourceLabel(request.provider) || "—").slice(0, 80),
|
|
304
306
|
String(request.model || "unknown").slice(0, 80), outcome, number(context.input_tokens), ""], { labels: [3] });
|
|
305
307
|
const wireFailure = Number.isInteger(request.http_status) && request.http_status >= 400;
|
|
306
308
|
if (globalThis.ccdxIcons) globalThis.ccdxIcons.set(row.children[3], wireFailure ? "request_http_failure" : outcome.toLowerCase(),
|
package/src/dashboard/tools.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
function field(list, key, value, kind) {
|
|
17
17
|
const term = document.createElement("dt"), detail = document.createElement("dd");label(term, key);
|
|
18
18
|
if (kind) globalThis.ccdxIcons.set(detail, value, kind);else detail.textContent = value;
|
|
19
|
-
list.append(term, detail);
|
|
19
|
+
if (list.classList.contains("account-summary")) { const pair = document.createElement("div");pair.append(term, detail);list.append(pair); }else list.append(term, detail);
|
|
20
20
|
}
|
|
21
21
|
function syncSource() {
|
|
22
22
|
const github = selectedProvider === "github";
|
package/src/dashboard/ui.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
:root { color-scheme: dark; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; --page: #0b110d; --surface: #111a13; --text: #e0e9df; --strong: #f0f6ec; --muted: #9aada0; --badge: #a9b9aa; --subtle: #78917d; --quiet: #
|
|
1
|
+
:root { color-scheme: dark; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; --page: #0b110d; --surface: #111a13; --text: #e0e9df; --strong: #f0f6ec; --muted: #9aada0; --badge: #a9b9aa; --subtle: #78917d; --quiet: #819987; --footer: #7f9785; --border: #2b3b2f; --top-border: #2a3a2e; --accent: #a6f5a8; --accent-soft: #84e99e; --heading: #83b98b; --bad: #ff947e; --failed: #ff9f91; --incomplete: #e3c77c; --button-border: #45634b; --button-bg: #152219; --button-fg: #b2f1bd; --button-hover: #203526; --selected-bg: #192a1d; --option-hover: #1a2a1e; --table-text: #d8e2d8; --preview: #657d69; --ansi-white: #f5fff5; --ansi-159: #9af5e9; --ansi-123: #75e4d9; --ansi-87: #5ad0d4; --ansi-51: #42b9d8; --ansi-45: #3ca2d0; --ansi-39: #4389c2; --ansi-33: #4775b2; }
|
|
2
2
|
:root[data-theme="light"] { color-scheme: light; --page: #f5f8f3; --surface: #ffffff; --text: #1b2b20; --strong: #122219; --muted: #475d4e; --badge: #475d4e; --subtle: #4b6652; --quiet: #55715c; --footer: #59735f; --border: #c4d2c5; --top-border: #b8c9ba; --accent: #176b3a; --accent-soft: #176b3a; --heading: #235f37; --bad: #a33625; --failed: #a33625; --incomplete: #835600; --button-border: #79a085; --button-bg: #ebf4ec; --button-fg: #185b32; --button-hover: #dbeedd; --selected-bg: #e4f3e7; --option-hover: #edf6ee; --table-text: #233b2b; --preview: #596f60; --ansi-white: #234231; --ansi-159: #116b64; --ansi-123: #0d7771; --ansi-87: #116b75; --ansi-51: #14697e; --ansi-45: #1a6183; --ansi-39: #265f8d; --ansi-33: #365a8d; }
|
|
3
3
|
* { box-sizing: border-box; }
|
|
4
4
|
[hidden] { display: none !important; }
|
|
@@ -492,3 +492,23 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
492
492
|
.binding-table td:last-child button { min-width: 102px; white-space: nowrap; }
|
|
493
493
|
#connection-sync-result { margin-top: 20px; }
|
|
494
494
|
#connection-sync-result tr:last-child td { border-bottom: 0; }
|
|
495
|
+
|
|
496
|
+
.connection-access { margin: 0 0 12px; }
|
|
497
|
+
.connection-access .connection-row { padding: 0; min-height: 44px; }
|
|
498
|
+
#connection-sources .provider-tabs { margin: 18px 0 0; }
|
|
499
|
+
.binding-unavailable { display: block; margin-left: 22px; }
|
|
500
|
+
#connection-default-note { color: var(--incomplete); }
|
|
501
|
+
@media (max-width: 650px) {
|
|
502
|
+
.binding-table, .binding-table tbody { display: block; width: 100%; }
|
|
503
|
+
.binding-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
|
504
|
+
.binding-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
|
|
505
|
+
.binding-table tr:last-child { border-bottom: 0; }
|
|
506
|
+
.binding-table td { border: 0; padding: 0; min-width: 0; }
|
|
507
|
+
.binding-table td:first-child { grid-column: 1; min-width: 0; }
|
|
508
|
+
.binding-table td:first-child label { overflow-wrap: anywhere; }
|
|
509
|
+
.binding-table td[data-label] { grid-column: 1 / -1; color: var(--muted); }
|
|
510
|
+
.binding-table td[data-label]::before { content: attr(data-label) " · "; color: var(--subtle); }
|
|
511
|
+
.binding-table td:last-child { grid-column: 2; grid-row: 1; align-self: center; }
|
|
512
|
+
.binding-table td:last-child button { min-width: 88px; padding: 9px; }
|
|
513
|
+
.binding-table td[colspan] { grid-column: 1 / -1; }
|
|
514
|
+
}
|
|
@@ -38,9 +38,9 @@ export function catalogCapabilities(model) {
|
|
|
38
38
|
max_output_tokens: first(model.max_output_tokens, window.max_output_tokens),
|
|
39
39
|
reasoning: first(typeof caps.reasoning === "boolean" ? caps.reasoning : undefined, supports.reasoning),
|
|
40
40
|
reasoning_efforts: first(model.reasoning_efforts, supports.reasoning_effort),
|
|
41
|
-
input_modalities: first(model.input_modalities, caps.input_modalities),
|
|
42
|
-
tools: supports.tools, parallel_tools: supports.parallel_tool_calls, streaming: supports.streaming,
|
|
43
|
-
structured_output: supports.structured_output, web_search: first(model.web_search, caps.web_search), thinking_modes: first(model.thinking_modes, caps.thinking_modes),
|
|
41
|
+
input_modalities: first(model.input_modalities, caps.input_modalities, supports.vision === true ? ["text", "image"] : undefined),
|
|
42
|
+
tools: first(supports.tools, supports.tool_calls), parallel_tools: supports.parallel_tool_calls, streaming: supports.streaming,
|
|
43
|
+
structured_output: first(supports.structured_output, supports.structured_outputs), web_search: first(model.web_search, caps.web_search), thinking_modes: first(model.thinking_modes, caps.thinking_modes),
|
|
44
44
|
...Object.fromEntries(["reasoning_required", "reasoning_adaptive", "reasoning_budget_min", "reasoning_budget_max", "reasoning_format"].map(key => [key, first(model[key], caps[key])])),
|
|
45
45
|
};
|
|
46
46
|
for (const [key, value] of Object.entries(candidate)) if (value !== undefined && validCapabilities({ [key]: value })) values[key] = value;
|
|
@@ -54,9 +54,11 @@ export function resolveModelCapabilities(model, { revision, checkedAt = null, bu
|
|
|
54
54
|
const fields = {}, declared = builtin ? catalogCapabilities(model) : { ...metadata?.values, ...metadata?.protocols?.[protocol] };
|
|
55
55
|
const put = (values, source, time) => { for (const [key, value] of Object.entries(values || {})) fields[key] = { value, source, checked_at: time }; };
|
|
56
56
|
put(declared, "catalog", builtin ? checkedAt : model.metadata?.checked_at || null);
|
|
57
|
-
|
|
58
|
-
...(model.
|
|
59
|
-
|
|
57
|
+
if (!builtin) {
|
|
58
|
+
put({ ...(model.context_window === undefined ? {} : { context_window: model.context_window }),
|
|
59
|
+
...(model.reasoning_efforts === undefined ? {} : { reasoning_efforts: model.reasoning_efforts }) }, "manual", null);
|
|
60
|
+
put(Object.fromEntries(Object.entries(model.capabilities || {}).filter(([key, value]) => validCapabilities({ [key]: value }))), "manual", null);
|
|
61
|
+
}
|
|
60
62
|
const values = Object.fromEntries(Object.entries(fields).map(([key, field]) => [key, field.value]));
|
|
61
63
|
if (protocol && values.reasoning_format && values.reasoning_format !== protocol) {
|
|
62
64
|
for (const key of ["reasoning", "reasoning_efforts", "reasoning_required", "reasoning_adaptive", "reasoning_budget_min", "reasoning_budget_max", "reasoning_format", "thinking_modes"]) delete values[key];
|