codex-copilot-dx 1.4.3 → 1.4.5
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 +4 -1
- package/bin/cli.mjs +5 -4
- package/docs/ARCHITECTURE.md +20 -0
- package/docs/REFERENCE.md +42 -8
- package/package.json +1 -1
- package/src/access-settings.mjs +5 -2
- package/src/adapter.mjs +9 -1
- package/src/antigravity-chat-bridge.mjs +4 -2
- package/src/antigravity-handler.mjs +51 -24
- package/src/antigravity-images.mjs +3 -2
- package/src/antigravity-runtime.mjs +13 -3
- package/src/application-configuration.mjs +43 -0
- package/src/application-control.mjs +114 -0
- package/src/application-evidence.mjs +42 -0
- package/src/application-process.mjs +114 -0
- package/src/claude-gateway.mjs +30 -17
- package/src/cli-command-spec.mjs +7 -4
- package/src/cli-management.mjs +37 -4
- package/src/client-effort.mjs +28 -0
- package/src/client-model-plan.mjs +2 -1
- package/src/codex-image-host-launch.mjs +1 -2
- package/src/codex-launch-control.mjs +7 -7
- package/src/connection-management.mjs +18 -3
- package/src/connection-policy.mjs +9 -1
- package/src/connection-routing.mjs +8 -2
- package/src/connection-runtime.mjs +21 -5
- package/src/connection-view.mjs +12 -3
- package/src/context-compaction-wire.mjs +7 -6
- package/src/context-compaction.mjs +6 -4
- package/src/copilot-client.mjs +17 -13
- package/src/copilot-responses-compat.mjs +1 -0
- package/src/copilot-web.mjs +6 -2
- package/src/dashboard/applications.js +83 -0
- package/src/dashboard/connections.js +71 -18
- package/src/dashboard/console.js +19 -9
- package/src/dashboard/gemini.js +8 -5
- package/src/dashboard/index.html +17 -0
- package/src/dashboard/language.js +45 -0
- package/src/dashboard/ui.css +9 -0
- package/src/dashboard-api.mjs +6 -1
- package/src/dashboard.mjs +1 -0
- package/src/gemini-app.mjs +3 -2
- package/src/http-transport.mjs +6 -3
- package/src/launcher.mjs +6 -5
- package/src/native-images.mjs +1 -1
- package/src/provider-runtime.mjs +14 -9
- package/src/providers/api.mjs +18 -12
- package/src/providers/m365.mjs +9 -5
- package/src/request-admission.mjs +6 -0
- package/src/responses-bridge.mjs +5 -2
- package/src/responses-handler.mjs +2 -0
- package/src/responses-proxy.mjs +9 -4
- package/src/safe-upstream-error.mjs +9 -11
- package/src/service-control.mjs +29 -5
- package/src/settings-preferences.mjs +3 -3
- package/src/source-admission-state.mjs +29 -0
- package/src/source-admission.mjs +310 -0
- package/src/source-discovery-probe.mjs +35 -0
- package/src/source-discovery.mjs +112 -0
- package/src/source-response.mjs +134 -0
- package/src/source-transport.mjs +19 -0
- package/src/stream-contract.mjs +3 -1
- package/src/stream-performance.mjs +3 -1
- package/src/stream.mjs +6 -4
- package/src/upstream-body.mjs +9 -8
- package/src/user-settings.mjs +2 -2
package/src/copilot-client.mjs
CHANGED
|
@@ -6,9 +6,11 @@ import { debugLog } from "./log.mjs";
|
|
|
6
6
|
import { enforceResponsesPayloadByteBudget } from "./responses-byte-budget.mjs";
|
|
7
7
|
import { status } from "./status.mjs";
|
|
8
8
|
import { withChatStreamUsage } from "./stream-contract.mjs";
|
|
9
|
-
import { markRequestObservation,
|
|
9
|
+
import { markRequestObservation, markUpstreamHeaders } from "./stream-performance.mjs";
|
|
10
10
|
import { currentRequestContext } from "./request-context.mjs";
|
|
11
11
|
import { requestOptionsEvidence } from "./response-failures.mjs";
|
|
12
|
+
import { sourceTransport } from "./source-transport.mjs";
|
|
13
|
+
import { SOURCE_HTTP_CLIENT } from "./source-response.mjs";
|
|
12
14
|
|
|
13
15
|
function abortError(signal) {
|
|
14
16
|
if (signal?.reason instanceof Error) return signal.reason;
|
|
@@ -90,6 +92,7 @@ export function createCopilotClientRuntime({
|
|
|
90
92
|
retryOptions,
|
|
91
93
|
bodyText,
|
|
92
94
|
onUpstreamStart,
|
|
95
|
+
...sourceOptions
|
|
93
96
|
} = {}) {
|
|
94
97
|
const token = await tokenSession.getToken({ signal });
|
|
95
98
|
const upstreamReq = chatReq.stream === true ? withChatStreamUsage(chatReq) : chatReq;
|
|
@@ -104,14 +107,13 @@ export function createCopilotClientRuntime({
|
|
|
104
107
|
vision: computeVision(messages),
|
|
105
108
|
});
|
|
106
109
|
headers["Content-Length"] = String(Buffer.byteLength(serializedBody));
|
|
107
|
-
onUpstreamStart
|
|
108
|
-
|
|
109
|
-
return fetchCopilotUpstream(`${tokenSession.getApiBase()}/chat/completions`, {
|
|
110
|
+
return sourceTransport({ ...sourceOptions, signal, onUpstreamStart }, { send: fetchCopilotUpstream, model: upstreamReq.model, bodyText: serializedBody, stream: upstreamReq.stream === true, observe: true,
|
|
111
|
+
args: [`${tokenSession.getApiBase()}/chat/completions`, {
|
|
110
112
|
method: "POST",
|
|
111
113
|
headers,
|
|
112
114
|
body: serializedBody,
|
|
113
115
|
signal,
|
|
114
|
-
}, { fetchImpl, ...retryOptions });
|
|
116
|
+
}, { fetchImpl, ...retryOptions }] });
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
async function fetchModels({ signal, fetchImpl, retryOptions }) {
|
|
@@ -169,6 +171,7 @@ export function createCopilotClientRuntime({
|
|
|
169
171
|
onUpstreamStart,
|
|
170
172
|
payloadPrepared = false,
|
|
171
173
|
payloadOptions = {},
|
|
174
|
+
...sourceOptions
|
|
172
175
|
} = {}) {
|
|
173
176
|
const token = await tokenSession.getToken({ signal });
|
|
174
177
|
const preparedPayload = await prepareResponsesPayload(reqBody, {
|
|
@@ -194,15 +197,15 @@ export function createCopilotClientRuntime({
|
|
|
194
197
|
try {
|
|
195
198
|
const context = currentRequestContext();
|
|
196
199
|
if (context) context.requestOptions = requestOptionsEvidence(reqBody);
|
|
197
|
-
onUpstreamStart
|
|
198
|
-
|
|
199
|
-
return await fetchCopilotUpstream(`${tokenSession.getApiBase()}${responsesEndpointPath()}`, {
|
|
200
|
+
return await sourceTransport({ ...sourceOptions, signal, onUpstreamStart }, { send: fetchCopilotUpstream, model: reqBody.model, bodyText, stream: reqBody.stream === true, observe: true,
|
|
201
|
+
args: [`${tokenSession.getApiBase()}${responsesEndpointPath()}`, {
|
|
200
202
|
method: "POST",
|
|
201
203
|
headers,
|
|
202
204
|
body: bodyText,
|
|
203
205
|
signal,
|
|
204
|
-
}, { fetchImpl, ...retryOptions });
|
|
206
|
+
}, { fetchImpl, ...retryOptions }] });
|
|
205
207
|
} catch (error) {
|
|
208
|
+
if (error.sourceQueue || error.origin === "source_admission") throw error;
|
|
206
209
|
if (signal?.aborted) throw abortError(signal);
|
|
207
210
|
const cause = error?.cause;
|
|
208
211
|
const causeText = cause ? ` (${[cause.code, cause.message].filter(Boolean).join(": ")})` : "";
|
|
@@ -210,16 +213,16 @@ export function createCopilotClientRuntime({
|
|
|
210
213
|
}
|
|
211
214
|
}
|
|
212
215
|
|
|
213
|
-
async function images(operation, body, { signal, fetchImpl } = {}) {
|
|
216
|
+
async function images(operation, body, { signal, fetchImpl, ...sourceOptions } = {}) {
|
|
214
217
|
if (!["generations", "edits"].includes(operation)) throw new Error("Unsupported image operation");
|
|
215
218
|
const token = await tokenSession.getToken({ signal });
|
|
216
219
|
const headers = buildHeaders({ token, version: getVSCodeVersion(), initiator: "user", vision: operation === "edits" });
|
|
217
220
|
const bodyText = JSON.stringify(body);
|
|
218
221
|
markRequestObservation({ payload_bytes: Buffer.byteLength(bodyText), images: body.images?.length || 0 });
|
|
219
|
-
|
|
220
|
-
|
|
222
|
+
const response = await sourceTransport({ ...sourceOptions, signal }, { send: fetchCopilotUpstream, model: body.model, bodyText, stream: false, observe: true,
|
|
223
|
+
args: [`${tokenSession.getApiBase()}/v1/images/${operation}`, {
|
|
221
224
|
method: "POST", headers, body: bodyText, signal, redirect: "error",
|
|
222
|
-
}, { fetchImpl, retries: 0 });
|
|
225
|
+
}, { fetchImpl, retries: 0 }] });
|
|
223
226
|
markUpstreamHeaders(response.status);
|
|
224
227
|
return response;
|
|
225
228
|
}
|
|
@@ -243,6 +246,7 @@ export function createCopilotClientRuntime({
|
|
|
243
246
|
}
|
|
244
247
|
|
|
245
248
|
return Object.freeze({
|
|
249
|
+
[SOURCE_HTTP_CLIENT]: true,
|
|
246
250
|
profile,
|
|
247
251
|
cacheModelEndpoints,
|
|
248
252
|
getCachedModelEndpoints,
|
|
@@ -104,6 +104,7 @@ export async function openCopilotResponse(reqContext, upstream = copilotResponse
|
|
|
104
104
|
try {
|
|
105
105
|
options.assertPrepareActive?.();
|
|
106
106
|
resp = await upstream(reqContext.body, {
|
|
107
|
+
sourceBodyManaged: true,
|
|
107
108
|
assertActive: options.assertPrepareActive,
|
|
108
109
|
signal: options.signal,
|
|
109
110
|
currentInputStart: reqContext.currentInputStart,
|
package/src/copilot-web.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import { readSavedGithubToken } from "./auth-credentials.mjs";
|
|
|
2
2
|
import { githubTokenFingerprint } from "./github-identity.mjs";
|
|
3
3
|
import { httpError, readBoundedResponseText } from "./http-transport.mjs";
|
|
4
4
|
import { localPackageVersion } from "./version.mjs";
|
|
5
|
+
import { SOURCE_ADMISSION } from "./source-admission.mjs";
|
|
6
|
+
import { cancelSourceResponse } from "./source-response.mjs";
|
|
5
7
|
|
|
6
8
|
const trustedHosts = new Set(["api.githubcopilot.com", "api.enterprise.githubcopilot.com"]);
|
|
7
9
|
const unsupported = ["image_query", "literature_search_query", "screenshot", "finance", "weather", "sports", "time"];
|
|
@@ -28,7 +30,7 @@ async function rpc(endpoint, headers, method, id, params, signal, session, fetch
|
|
|
28
30
|
body: JSON.stringify({ jsonrpc: "2.0", ...(id ? { id } : {}), method, params }) });
|
|
29
31
|
const sessionId = response.headers.get("mcp-session-id");
|
|
30
32
|
if (!response.ok) {
|
|
31
|
-
await response
|
|
33
|
+
await cancelSourceResponse(response);
|
|
32
34
|
const error = failure("GitHub Copilot search was refused (HTTP " + response.status + ")", "ccdx_copilot_search_http", response.status);
|
|
33
35
|
const retryAfter = response.headers.get("retry-after");
|
|
34
36
|
if (retryAfter && /^(?:\d{1,8}|[A-Za-z0-9,: ]{10,40})$/.test(retryAfter)) error.retryAfter = retryAfter;
|
|
@@ -98,6 +100,8 @@ function pageLinks(text, base) {
|
|
|
98
100
|
export function createCopilotWeb({ client, query = copilotQuery, readToken = readSavedGithubToken, fetchImpl = fetch,
|
|
99
101
|
pageReader = async options => (await import("./copilot-web-fetch.mjs")).createCopilotPageReader(options) } = {}) {
|
|
100
102
|
const store = referenceStore();
|
|
103
|
+
const source = client?.[SOURCE_ADMISSION], network = source ? (url, init) => source.scheduler.run(source.descriptor(), () => fetchImpl(url, init),
|
|
104
|
+
{ signal: init.signal, sourceBodyManaged: true, model: "web_search", client: "search", bytes: () => Buffer.byteLength(init.body || "") }) : fetchImpl;
|
|
101
105
|
async function search(body, { signal, providerProfile } = {}) {
|
|
102
106
|
if (typeof body.id !== "string" || !body.id || body.id.length > 160 || !body.commands || typeof body.commands !== "object"
|
|
103
107
|
|| Array.isArray(body.commands)) throw failure("Invalid Copilot search request", "ccdx_copilot_search_invalid", 400);
|
|
@@ -137,7 +141,7 @@ export function createCopilotWeb({ client, query = copilotQuery, readToken = rea
|
|
|
137
141
|
const domains = (item.domains || []).map(value => value.toLowerCase().replace(/^\.+|\.+$/g, ""));
|
|
138
142
|
const constraints = [domains.length ? "Limit results to these domains: " + domains.join(", ") + "." : "",
|
|
139
143
|
item.recency ? "Prefer sources from the past " + item.recency + " days." : ""].filter(Boolean).join(" ");
|
|
140
|
-
const data = await query(item.q + (constraints ? "\n" + constraints : ""), { endpoint, credential, signal, fetchImpl });
|
|
144
|
+
const data = await query(item.q + (constraints ? "\n" + constraints : ""), { endpoint, credential, signal, fetchImpl: network });
|
|
141
145
|
output.push("GitHub Copilot search: " + item.q);
|
|
142
146
|
let count = 0;
|
|
143
147
|
for (const group of data.search_result_groups || []) {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
function create({ element: el, change, localize, isBusy = () => false }) {
|
|
3
|
+
let data, pending = false, sequence = 0, confirmation = null, claudeApp = true, note = null, autoError = false;
|
|
4
|
+
const route = () => ({ codex: "codex", claude: claudeApp ? "claude_app" : null, gemini: "antigravity" })[location.hash.slice(1)] || null;
|
|
5
|
+
const label = (id, key) => localize(el(id), key);
|
|
6
|
+
const buttonKey = state => state?.status === "running" ? state.needs_reload ? "application_reopen" : "application_focus"
|
|
7
|
+
: state?.status === "starting" ? "application_opening" : state?.status === "stopped" ? "application_open" : "application_check";
|
|
8
|
+
function render() {
|
|
9
|
+
const id = route(), state = data?.applications?.[id];
|
|
10
|
+
el("application-launch").hidden = !id;
|
|
11
|
+
el("page-title").closest(".intro").classList.toggle("has-application-launch", Boolean(id));
|
|
12
|
+
el("application-reopen-confirm").hidden = !confirmation || confirmation.id !== id;
|
|
13
|
+
el("application-reopen-apply").disabled = pending || isBusy();
|
|
14
|
+
if (!id) return;
|
|
15
|
+
label("application-open-label", buttonKey(state));
|
|
16
|
+
el("application-open").disabled = pending || isBusy() || ["starting", "unsupported", "not_installed", "multiple"].includes(state?.status);
|
|
17
|
+
el("application-open").setAttribute("aria-busy", String(pending || isBusy() || state?.status === "starting"));
|
|
18
|
+
label("application-state", note || (state?.status === "running" ? state.needs_reload ? "application_reload_pending" : state.connection === "observed" ? "application_connected" : "application_pending"
|
|
19
|
+
: state?.status === "stopped" ? "application_stopped" : state?.status === "starting" ? "application_opening" : "application_" + (state?.status || "unknown")));
|
|
20
|
+
if (!pending) {
|
|
21
|
+
el("codex-auto-launch").checked = data?.effective?.codex_auto_launch?.value === true;
|
|
22
|
+
el("codex-auto-launch").disabled = isBusy() || data?.effective?.codex_auto_launch?.locked === true || !data;
|
|
23
|
+
label("codex-auto-launch-note", autoError ? "application_preference_failed" : data?.effective?.codex_auto_launch?.locked ? "controlled_by_environment" : "next_ccdx_start");
|
|
24
|
+
}
|
|
25
|
+
window.dispatchEvent(new CustomEvent("ccdx:application-state", { detail: { id, application: state, pending: pending || isBusy() } }));
|
|
26
|
+
}
|
|
27
|
+
function sync(next) {
|
|
28
|
+
const applications = { ...next.applications };
|
|
29
|
+
for (const [id, state] of Object.entries(data?.applications || {})) if ((state.inspection || 0) > (applications[id]?.inspection || 0)) applications[id] = state;
|
|
30
|
+
data = { ...next, applications };render();
|
|
31
|
+
}
|
|
32
|
+
async function check(fresh = false) {
|
|
33
|
+
const id = route();if (!id || pending) return;
|
|
34
|
+
const version = ++sequence;
|
|
35
|
+
try {
|
|
36
|
+
const response = await fetch(`/_ccdx/ui/settings?application=${id}${fresh ? "&fresh=1" : ""}`, { cache: "no-store", headers: { "X-CCDX-Dashboard": "1" }, signal: AbortSignal.timeout(15000) });
|
|
37
|
+
const next = await response.json();if (!response.ok) throw Error("check failed");
|
|
38
|
+
if (version !== sequence || route() !== id) return;
|
|
39
|
+
note = null;sync({ ...data, applications: next.applications });
|
|
40
|
+
} catch { if (version === sequence) { note = "application_unknown";render(); } }
|
|
41
|
+
}
|
|
42
|
+
async function act(operation, expected) {
|
|
43
|
+
const id = route();if (!id || pending) return;
|
|
44
|
+
pending = true;confirmation = null;note = null;sequence++;render();
|
|
45
|
+
try {
|
|
46
|
+
const next = await change({ action: "application", id, operation,
|
|
47
|
+
...(operation === "restart" ? { confirmed: true, expected_pid: expected.pid, expected_started: expected.started } : {}) }, el("application-open"), { quiet: true });
|
|
48
|
+
if (!next) { note = "application_action_failed";return; }
|
|
49
|
+
data = next;const result = next.last_operation?.feature === "application" ? next.last_operation.result : null;
|
|
50
|
+
if (["opened", "opening"].includes(result?.status)) for (const delay of [1000, 10500]) setTimeout(() => { if (route() === id && document.visibilityState === "visible") void check(true); }, delay);
|
|
51
|
+
if (result && !["opened", "opening", "focused", "checked"].includes(result.status)) {
|
|
52
|
+
const direct = { unknown: "application_unknown", app_check_failed: "application_unknown", not_installed: "application_not_installed", multiple: "application_multiple", multiple_apps: "application_multiple", unsupported: "application_unsupported", app_not_running: "application_stopped", app_route_conflict: "application_action_route_conflict" };
|
|
53
|
+
note = direct[result.status] || (["open_failed", "focus_unavailable", "quit_refused", "quit_timeout", "app_changed", "needs_app_relaunch", "route_conflict"].includes(result.status) ? "application_action_" + result.status : "application_action_failed");
|
|
54
|
+
}
|
|
55
|
+
} finally { pending = false;render(); }
|
|
56
|
+
}
|
|
57
|
+
function openCurrent() {
|
|
58
|
+
const id = route(), state = data?.applications?.[id];
|
|
59
|
+
if (state?.status === "running" && state.needs_reload) { confirmation = { id, pid: state.pid, started: state.started };render(); }
|
|
60
|
+
else if (state?.status === "running") void act("focus");
|
|
61
|
+
else if (state?.status === "stopped") void act("open");
|
|
62
|
+
else void check(true);
|
|
63
|
+
}
|
|
64
|
+
el("application-open").addEventListener("click", openCurrent);
|
|
65
|
+
el("application-reopen-cancel").addEventListener("click", () => { confirmation = null;render();el("application-open").focus(); });
|
|
66
|
+
el("application-reopen-apply").addEventListener("click", () => { if (confirmation?.id === route()) void act("restart", confirmation); });
|
|
67
|
+
el("codex-auto-launch").addEventListener("change", async event => {
|
|
68
|
+
const value = event.target.checked;if (pending) return;
|
|
69
|
+
pending = true;sequence++;event.target.disabled = true;
|
|
70
|
+
try { const next = await change({ action: "preference", key: "codex_auto_launch", value }, event.target, { quiet: true });autoError = !next;if (next) data = next; }
|
|
71
|
+
finally { pending = false;render(); }
|
|
72
|
+
});
|
|
73
|
+
for (const button of document.querySelectorAll("[data-claude-client]")) button.addEventListener("click", () => {
|
|
74
|
+
claudeApp = button.dataset.claudeClient === "claude_app";confirmation = null;note = null;render();if (claudeApp) void check();
|
|
75
|
+
});
|
|
76
|
+
window.addEventListener("focus", () => { if (document.visibilityState === "visible") void check(); });
|
|
77
|
+
window.addEventListener("ccdx-gemini-state", event => {
|
|
78
|
+
const state = event.detail?.application;if (state) sync({ ...data, applications: { ...data?.applications, antigravity: state } });
|
|
79
|
+
});
|
|
80
|
+
return { sync, render, open(id) { if (route() === id && !pending && !isBusy()) openCurrent(); }, routeChanged() { confirmation = null;note = null;sequence++;render();void check(); }, refresh: () => check(true) };
|
|
81
|
+
}
|
|
82
|
+
globalThis.ccdxApplications = { create };
|
|
83
|
+
})();
|
|
@@ -3,14 +3,28 @@
|
|
|
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, bindingImageModel = null, bindingImageDirty = false, bindingDirty = false;
|
|
6
|
+
let bindingEfforts = new Map();
|
|
6
7
|
let memoryAction = null, memoryOrigin = null;
|
|
7
8
|
let disableRevision = null;
|
|
8
9
|
const drafts = new Map();let editorOrigin = null, discovery = null, desiredSource = null;
|
|
10
|
+
let importSequence = 0;
|
|
9
11
|
const apiForm = el("connection-api-form"), clientForm = el("connection-client-form");
|
|
10
12
|
const node = (tag, text, className) => { const item = document.createElement(tag);if (text !== undefined) item.textContent = text;if (className) item.className = className;return item; };
|
|
11
13
|
const source = id => data.providers.find(item => item.id === id), client = id => data.clients.find(item => item.id === id);
|
|
12
14
|
const accessDrafts = new Map(), accessResults = new Map();
|
|
15
|
+
const sourceLimitDrafts = new Map();
|
|
13
16
|
const accessForm = el("source-access-form");
|
|
17
|
+
el("source-limit-maximum").addEventListener("input", event => {
|
|
18
|
+
sourceLimitDrafts.set(selectedProvider, event.target.value);
|
|
19
|
+
el("source-limit-save").disabled = busy || (event.target.value === "" ? null : Number(event.target.value)) === (source(selectedProvider)?.concurrency?.maximum ?? null);
|
|
20
|
+
});
|
|
21
|
+
el("source-limit-form").addEventListener("submit", event => {
|
|
22
|
+
event.preventDefault();const id = selectedProvider, field = el("source-limit-maximum");
|
|
23
|
+
if (!field.reportValidity()) return;
|
|
24
|
+
void change({ operation: "source_limits", id, maximum: field.value === "" ? null : Number(field.value), impact_revision: data.source_impacts?.[id]?.revision }, () => {
|
|
25
|
+
sourceLimitDrafts.delete(id);renderAccess();words(el("source-limit-note"), "api_saved");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
14
28
|
const sameAccess = (a,b) => JSON.stringify([...a].sort()) === JSON.stringify([...b].sort());
|
|
15
29
|
function accessChoices(id) {
|
|
16
30
|
const provider=source(id);if(!provider)return [];
|
|
@@ -21,6 +35,10 @@
|
|
|
21
35
|
}
|
|
22
36
|
function renderAccess() {
|
|
23
37
|
const id=selectedProvider,provider=source(id),root=el("source-app-access");root.hidden=!provider;if(!provider)return;
|
|
38
|
+
const limit = el("source-limit-maximum"), maximum = provider.concurrency?.maximum ?? null;
|
|
39
|
+
if (document.activeElement !== limit || limit.dataset.source !== id) limit.value = sourceLimitDrafts.has(id) ? sourceLimitDrafts.get(id) : maximum ?? "";
|
|
40
|
+
limit.dataset.source = id;limit.placeholder = format("source_concurrency_auto");
|
|
41
|
+
limit.disabled = busy;el("source-limit-save").disabled = busy || (limit.value === "" ? null : Number(limit.value)) === maximum;
|
|
24
42
|
const waiting=id==="github"&&!globalThis.ccdxAntigravity?.state,pending=busy||id==="github"&&Boolean(globalThis.ccdxAntigravity?.pending);
|
|
25
43
|
const saved=savedAccess(id),selected=accessDrafts.get(id)||saved,dirty=!sameAccess(saved,selected),area=el("source-allowed-apps");
|
|
26
44
|
const focus=area.contains(document.activeElement)?document.activeElement.value:null;
|
|
@@ -129,9 +147,10 @@
|
|
|
129
147
|
if (busy) return;busy = true;generation++;
|
|
130
148
|
const previousImage = imageViewRevision(data);
|
|
131
149
|
const trigger = ["client", "image_model"].includes(input.operation) ? clientForm.querySelector('button[type="submit"]') : input.operation === "preview_client" ? el("connection-sync-preview")
|
|
132
|
-
: input.operation === "save_api" ? apiForm.querySelector('button[type="submit"]') : document.activeElement;
|
|
150
|
+
: input.operation === "save_api" ? apiForm.querySelector('button[type="submit"]') : input.operation === "source_limits" ? el("source-limit-save") : document.activeElement;
|
|
133
151
|
const oldKey = trigger?.dataset.i18n, oldText = trigger?.textContent;
|
|
134
152
|
if (trigger?.tagName === "BUTTON") { trigger.setAttribute("aria-busy", "true");trigger.disabled = true;words(trigger, input.operation === "preview_client" ? "api_reading" : "api_saving"); }
|
|
153
|
+
if (input.operation === "source_limits") renderAccess();
|
|
135
154
|
try { if (input.operation === "save_api") await stopDiscovery();data = await api(input);if (["client", "image_model"].includes(input.operation)) { drafts.delete(input.id);if (editingClient === input.id) bindingDirty = false; }mountClient();list();done?.(data);if (!done) {
|
|
136
155
|
if (input.operation === "save_api") {
|
|
137
156
|
desiredSource = input.id || data.providers.find(p => !p.builtin && p.name === input.config.name)?.id;
|
|
@@ -158,7 +177,7 @@
|
|
|
158
177
|
}
|
|
159
178
|
finally { busy = false;if (trigger?.tagName === "BUTTON") { trigger.removeAttribute("aria-busy");trigger.disabled = false;if (oldKey) words(trigger, oldKey);else trigger.textContent = oldText; }
|
|
160
179
|
if (["client", "preview_client", "image_model"].includes(input.operation)) bindingRows();
|
|
161
|
-
if (input.operation
|
|
180
|
+
if (["source_access", "source_limits"].includes(input.operation)) renderAccess();
|
|
162
181
|
if (input.operation === "save_api") words(apiForm.querySelector('button[type="submit"]'), editing ? "api_save" : "api_save_read");
|
|
163
182
|
}
|
|
164
183
|
return true;
|
|
@@ -389,7 +408,7 @@
|
|
|
389
408
|
const bindingKey = (source, model) => source + "\0" + model;
|
|
390
409
|
const routeId = item => item.route_id || item.public_id;
|
|
391
410
|
function rememberDraft() {
|
|
392
|
-
if (editingClient && bindingDirty) drafts.set(editingClient, { selection: new Set(bindingSelection), defaultModel: bindingDefault, imageModel: bindingImageModel, imageDirty: bindingImageDirty, autoSync: el("connection-auto-sync").checked });
|
|
411
|
+
if (editingClient && bindingDirty) drafts.set(editingClient, { selection: new Set(bindingSelection), efforts: new Map(bindingEfforts), defaultModel: bindingDefault, imageModel: bindingImageModel, imageDirty: bindingImageDirty, autoSync: el("connection-auto-sync").checked });
|
|
393
412
|
}
|
|
394
413
|
function mountClient(force = false) {
|
|
395
414
|
if (!data) return;
|
|
@@ -403,6 +422,7 @@
|
|
|
403
422
|
editingClient = id;const draft = drafts.get(id);bindingDirty = Boolean(draft);
|
|
404
423
|
const selected = Array.isArray(c.deployments) ? c.deployments : (c.model_plan?.models || []).map(model => ({ source: model.source, model: model.id }));
|
|
405
424
|
bindingSelection = draft ? new Set(draft.selection) : new Set(selected.map(item => bindingKey(item.source, item.model)));
|
|
425
|
+
bindingEfforts = draft ? new Map(draft.efforts || []) : new Map(selected.filter(item => item.reasoning_effort !== undefined).map(item => [bindingKey(item.source, item.model), item.reasoning_effort]));
|
|
406
426
|
bindingDefault = draft ? draft.defaultModel : c.default_model || c.model_plan?.models.find(model => model.public_id === c.model_plan?.default_model)?.route_id || null;
|
|
407
427
|
bindingImageModel = draft?.imageDirty ? draft.imageModel : c.image_model || c.model_plan?.image?.selected_model || null;
|
|
408
428
|
bindingImageDirty = draft?.imageDirty === true;
|
|
@@ -410,12 +430,13 @@
|
|
|
410
430
|
el("connection-sync-result").hidden = true;el("connection-client-note").textContent = "";
|
|
411
431
|
}
|
|
412
432
|
if (id === "codex" && !bindingImageDirty) bindingImageModel = c.image_model || c.model_plan?.image?.selected_model || null;
|
|
413
|
-
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();
|
|
433
|
+
bindingRows(document.activeElement?.name === "binding-model" ? { kind: "selection", key: document.activeElement.value } : document.activeElement?.dataset.effortBinding ? { kind: "effort", key: document.activeElement.dataset.effortBinding } : document.activeElement?.dataset.binding ? { kind: "default", key: document.activeElement.dataset.binding } : null);words(el("connection-client-title"), "cap_visible_model");list();
|
|
414
434
|
}
|
|
415
435
|
function bindingRows(focus) {
|
|
416
436
|
memoryRender();
|
|
417
437
|
el("connection-client-cancel").disabled = !bindingDirty;
|
|
418
438
|
const body = el("connection-bindings"), c = client(editingClient);body.replaceChildren();
|
|
439
|
+
let effortControls = 0;
|
|
419
440
|
const available = c.model_plan?.available || [], availableKeys = new Set(available.map(item => bindingKey(item.source, item.id)));
|
|
420
441
|
const missing = [...bindingSelection].filter(key => !availableKeys.has(key)).map(key => { const [source, id] = key.split("\0"), saved = c.model_plan?.unavailable?.find(item => item.source === source && item.id === id);return { source, id, route_id: saved?.route_id, reason: saved?.reason, unavailable: true }; });
|
|
421
442
|
for (const item of [...available, ...missing]) {
|
|
@@ -438,6 +459,17 @@
|
|
|
438
459
|
if (item.unavailable) { const warning = node("span", undefined, "hint binding-unavailable");words(warning, item.reason ? "visibility_" + item.reason : "cap_model_unavailable");name.append(warning); }
|
|
439
460
|
const cell = node("td");cell.append(action);
|
|
440
461
|
const details = [node("td", source(item.source)?.name || item.source), node("td", count(capability.context_window)), node("td", reasoningText(capability))];
|
|
462
|
+
const levels = capability.reasoning === false ? [] : capability.reasoning_efforts || [];
|
|
463
|
+
if (editingClient === "claude_app" && (item.effort_control === "gateway" && levels.length || bindingEfforts.has(key))) {
|
|
464
|
+
const select = node("select"), follow = node("option");follow.value = "";words(follow, "cap_effort_follow");select.append(follow);
|
|
465
|
+
const saved = bindingEfforts.get(key);
|
|
466
|
+
if (saved && !levels.includes(saved)) { const option = node("option");option.value = saved;option.disabled = true;words(option, "cap_effort_unavailable", { effort: saved });select.append(option); }
|
|
467
|
+
for (const effort of levels) { const option = node("option", effort);option.value = effort;select.append(option); }
|
|
468
|
+
select.value = saved || "";select.dataset.effortBinding = key;select.setAttribute("aria-label", (item.display_name || item.id) + " · " + format("cap_reasoning"));
|
|
469
|
+
select.disabled = busy || Boolean(item.unavailable) || !bindingSelection.has(key);
|
|
470
|
+
select.addEventListener("change", () => { if (select.value) bindingEfforts.set(key, select.value);else bindingEfforts.delete(key);bindingDirty = true;rememberDraft();bindingRows({ kind: "effort", key }); });
|
|
471
|
+
details[2].replaceChildren(select);effortControls++;
|
|
472
|
+
}
|
|
441
473
|
details.forEach((cell, i) => cell.dataset.label = format(["source", "cap_context", "cap_reasoning"][i]));
|
|
442
474
|
row.append(name, ...details, cell);body.append(row);
|
|
443
475
|
}
|
|
@@ -463,9 +495,10 @@
|
|
|
463
495
|
: setup === "default_unavailable" ? "cap_default_unavailable" : "sync_not_configured";
|
|
464
496
|
globalThis.ccdxIcons.set(el("connection-setup-state"), syncKey, setup === "configured" ? "ok" : ["configuration_unavailable", "default_unavailable"].includes(setup) ? "warning" : "unavailable");
|
|
465
497
|
const capabilityNote = el("connection-capability-state");capabilityNote.hidden = !c.model_plan?.sync?.limitations?.some(item => item.code === "client_version_unknown");
|
|
498
|
+
el("connection-effort-note").hidden = !effortControls;
|
|
466
499
|
if (!capabilityNote.hidden) words(capabilityNote, "sync_capability_unverified");
|
|
467
500
|
words(clientForm.querySelector('button[type="submit"]'), el("connection-auto-sync").checked ? "cap_save_sync" : "api_save");
|
|
468
|
-
if (focus) { const selector = focus.kind === "selection" ? 'input[name="binding-model"]' : focus.kind === "image" ? 'input[name="binding-image-model"]' : 'button[data-binding]';[...body.querySelectorAll(selector)].find(input => (input.value || input.dataset.binding) === focus.key)?.focus(); }
|
|
501
|
+
if (focus) { const selector = focus.kind === "selection" ? 'input[name="binding-model"]' : focus.kind === "image" ? 'input[name="binding-image-model"]' : focus.kind === "effort" ? 'select[data-effort-binding]' : 'button[data-binding]';[...body.querySelectorAll(selector)].find(input => (input.dataset.effortBinding || input.value || input.dataset.binding) === focus.key)?.focus(); }
|
|
469
502
|
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); }
|
|
470
503
|
}
|
|
471
504
|
function editClient(c) { location.hash = c.id === "codex" ? "codex" : "claude";if (c.id !== "codex") claudeClient = c.id;mountClient(true); }
|
|
@@ -485,7 +518,7 @@
|
|
|
485
518
|
return { operation: "image_model", id: "codex", model: bindingImageModel, client_revision: c.revision };
|
|
486
519
|
}
|
|
487
520
|
return { operation, id: c.id, enabled: true, allowed: c.allowed,
|
|
488
|
-
deployments: [...bindingSelection].map(key => { const [source, model] = key.split("\0");return { source, model }; }),
|
|
521
|
+
deployments: [...bindingSelection].map(key => { const [source, model] = key.split("\0");return { source, model, ...(editingClient === "claude_app" && bindingEfforts.has(key) ? { reasoning_effort: bindingEfforts.get(key) } : {}) }; }),
|
|
489
522
|
...(editingClient === "codex" && bindingImageModel ? { image_model: bindingImageModel } : {}),
|
|
490
523
|
default_model: bindingDefault, auto_sync: el("connection-auto-sync").checked };
|
|
491
524
|
}
|
|
@@ -514,29 +547,49 @@
|
|
|
514
547
|
impact_revision: disableRevision,
|
|
515
548
|
replacements: Object.fromEntries([...el("connection-replacements").querySelectorAll("select")].map(select => [select.name, select.value || null])) }); });
|
|
516
549
|
el("connection-add").addEventListener("click", () => { if (data) editApi(); });
|
|
517
|
-
el("connection-import").
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
const preview = el("connection-import-preview");preview.hidden = true;preview.replaceChildren();
|
|
521
|
-
if (file.size > 256 * 1024) { message("ccdx_import_size_invalid");return; }
|
|
522
|
-
try {
|
|
523
|
-
const result = await api({ operation: "preview_import", content: JSON.parse(await file.text()) });
|
|
550
|
+
function closeImport() { importSequence++;el("connection-import-preview").hidden = true;el("connection-import").focus(); }
|
|
551
|
+
function importPreview(result) {
|
|
552
|
+
const preview = el("connection-import-preview");preview.replaceChildren();
|
|
524
553
|
const heading = node("h3");words(heading, "import_preview");preview.append(heading);
|
|
525
|
-
const note = node("p", undefined, "hint");words(note, "import_scope");preview.append(note);
|
|
554
|
+
if (result.drafts.length) { const note = node("p", undefined, "hint");words(note, "import_scope");preview.append(note); }
|
|
555
|
+
if (result.discovery && !result.drafts.length) { const state = node("p");words(state, "import_discovery_" + result.discovery.state);preview.append(state); }
|
|
556
|
+
if (result.discovery?.skipped) { const skipped = node("p", undefined, "hint");words(skipped, "import_discovery_skipped");preview.append(skipped); }
|
|
557
|
+
if (result.discovery?.truncated) { const limit = node("p", undefined, "hint");words(limit, "import_discovery_truncated");preview.append(limit); }
|
|
526
558
|
for (const draft of result.drafts) {
|
|
527
559
|
const row = node("div", undefined, "connection-row"), info = node("div"), actions = node("div", undefined, "connection-actions");
|
|
528
560
|
info.append(node("h3", draft.config.name), node("p", draft.config.base_url, "hint"));
|
|
529
561
|
for (const warning of draft.warnings) { const text = node("p", undefined, "hint");words(text, "import_" + warning);info.append(text); }
|
|
530
562
|
actions.append(button("import_review", () => {
|
|
531
|
-
editApi();const config = draft.config;
|
|
563
|
+
editApi();editorOrigin = el("connection-import");const config = draft.config;
|
|
532
564
|
apiForm.elements.name.value = config.name;apiForm.elements.base.value = config.base_url;apiForm.elements.auth_header.value = config.auth_header;
|
|
533
565
|
apiForm.elements.key_env.value = config.key_env || "";keyMode();
|
|
534
566
|
for (const input of apiForm.querySelectorAll('[name="protocol"]')) input.checked = Boolean(config.endpoints[input.value]);
|
|
535
|
-
setEndpoints(config.base_url, config.endpoints);models = structuredClone(config.models);selectedModels = new Set(models.map(model => model.id));modelRows();preview.hidden = true;
|
|
567
|
+
setEndpoints(config.base_url, config.endpoints);models = structuredClone(config.models);selectedModels = new Set(models.map(model => model.id));modelRows();importSequence++;preview.hidden = true;
|
|
536
568
|
}));row.append(info, actions);preview.append(row);
|
|
537
569
|
}
|
|
538
|
-
preview.hidden = false;
|
|
539
|
-
|
|
570
|
+
preview.append(button("cancel", closeImport));preview.hidden = false;
|
|
571
|
+
}
|
|
572
|
+
async function importTool(tool) {
|
|
573
|
+
const sequence = ++importSequence, preview = el("connection-import-preview"), reading = node("p");words(reading, "reading");
|
|
574
|
+
preview.replaceChildren(reading, button("cancel", closeImport));preview.hidden = false;
|
|
575
|
+
try { const result = await api({ operation: "preview_import", tool });if (sequence === importSequence) importPreview(result); }
|
|
576
|
+
catch (error) { if (sequence === importSequence) { preview.hidden = true;message(/^ccdx_import_/.test(error.message) ? error.message : "ccdx_import_discovery_invalid"); } }
|
|
577
|
+
}
|
|
578
|
+
el("connection-import").addEventListener("click", () => {
|
|
579
|
+
if (!data || busy) return;importSequence++;
|
|
580
|
+
const preview = el("connection-import-preview"), heading = node("h3"), actions = node("div", undefined, "section-actions");words(heading, "import_source");
|
|
581
|
+
const file = button("import_file", () => el("connection-import-file").click());
|
|
582
|
+
const cc = node("button", "CC Switch"), magpie = node("button", "Magpie");cc.type = magpie.type = "button";
|
|
583
|
+
cc.dataset.importTool = "cc-switch";magpie.dataset.importTool = "magpie";
|
|
584
|
+
cc.addEventListener("click", () => void importTool("cc-switch"));magpie.addEventListener("click", () => void importTool("magpie"));
|
|
585
|
+
actions.append(file, cc, magpie, button("cancel", closeImport));preview.replaceChildren(heading, actions);preview.hidden = false;file.focus();
|
|
586
|
+
});
|
|
587
|
+
el("connection-import-file").addEventListener("change", async event => {
|
|
588
|
+
const file = event.target.files?.[0];event.target.value = "";if (!file) return;
|
|
589
|
+
const sequence = ++importSequence, preview = el("connection-import-preview");preview.hidden = true;preview.replaceChildren();
|
|
590
|
+
if (file.size > 256 * 1024) { message("ccdx_import_size_invalid");return; }
|
|
591
|
+
try { const result = await api({ operation: "preview_import", content: JSON.parse(await file.text()) });if (sequence === importSequence) importPreview(result); }
|
|
592
|
+
catch (error) { if (sequence === importSequence) message(/^ccdx_import_/.test(error.message) ? error.message : "ccdx_import_format_invalid"); }
|
|
540
593
|
});
|
|
541
594
|
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(); });
|
|
542
595
|
el("refresh").addEventListener("click", () => { if (["#models", "#codex", "#claude"].includes(location.hash)) void load(); });
|
package/src/dashboard/console.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
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", gemini: "Antigravity", models: "model_services", usage: "usage_and_diagnostics", requests: "request_records", checks: "tools_checks_title", system: "system_and_settings" };
|
|
5
|
-
const settingsViews = ["codex", "claude", "models", "system", "checks"];
|
|
6
|
-
let current = "overview", settings = null, settingsPending = false, stopped = false, timer = null, ticks = 0;
|
|
5
|
+
const settingsViews = ["codex", "claude", "gemini", "models", "system", "checks"];
|
|
6
|
+
let current = "overview", settings = null, settingsPending = false, settingsReadPending = null, 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;
|
|
9
9
|
let accountsPending = false;
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
if (item.dataset.route === next) item.setAttribute("aria-current", "page");else item.removeAttribute("aria-current");
|
|
65
65
|
}
|
|
66
66
|
label(el("page-title"), titles[next]);
|
|
67
|
+
applications?.routeChanged();
|
|
67
68
|
el("page-settings-note").textContent = "";
|
|
68
69
|
window.scrollTo(0, 0);
|
|
69
70
|
el("main-content").focus({ preventScroll: true });
|
|
@@ -79,7 +80,7 @@
|
|
|
79
80
|
async function api(body) {
|
|
80
81
|
const response = await fetch("/_ccdx/ui/settings", { method: body ? "POST" : "GET", cache: "no-store",
|
|
81
82
|
headers: { "X-CCDX-Dashboard": "1", ...(body ? { "Content-Type": "application/json" } : {}) },
|
|
82
|
-
...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout((body?.action === "prediction" || ["image", "codex_app"].includes(body?.action) && ["open", "restart"].includes(body?.operation)) ? 210000 : ["image", "codex_app"].includes(body?.action) || body?.operation === "account" ? 65000 : 15000) });
|
|
83
|
+
...(body ? { body: JSON.stringify(body) } : {}), signal: AbortSignal.timeout((body?.action === "prediction" || ["image", "codex_app"].includes(body?.action) && ["open", "restart"].includes(body?.operation)) ? 210000 : ["image", "codex_app", "application"].includes(body?.action) || body?.operation === "account" ? 65000 : 15000) });
|
|
83
84
|
const data = await response.json();if (!response.ok) throw Object.assign(new Error(data.error || `HTTP ${response.status}`), { code: data.code });return data;
|
|
84
85
|
}
|
|
85
86
|
const preferences = globalThis.ccdxDashboardPreferences?.create({ element: el, api, applied: applySettings, time,
|
|
@@ -87,6 +88,8 @@
|
|
|
87
88
|
refreshAnimation() { dashboardRefresh.invalidate("animation");if (current === "system") void dashboardRefresh.refresh("animation", { force: true }); } });
|
|
88
89
|
globalThis.ccdxSettingsPreferences = preferences;
|
|
89
90
|
const features = globalThis.ccdxDashboardFeatures?.create({ element: el, api, apply: applySettings, change, localize: label });
|
|
91
|
+
const applications = globalThis.ccdxApplications?.create({ element: el, change, localize: label, isBusy: () => settingsPending });
|
|
92
|
+
globalThis.ccdxApplicationControls = applications;
|
|
90
93
|
const states = { needs_github_access: "image_needs_github", image_model_unavailable: "image_no_models", immediate: "effective_now", terminal_unavailable: "terminal_animation_unavailable_in_this_output_mode", next_start: "next_ccdx_start", next_call: "applies_to_new_calls", needs_setup: "setup_required",
|
|
91
94
|
next_config_request: "next_configuration_request_cached_suggestions_may_remain", needs_app_relaunch: "reopen_the_client_to_finish", needs_service_restart: "restart_ccdx_to_finish" };
|
|
92
95
|
const selectedSource = () => providerEntries.find(source => source.id === el("source-provider").value);
|
|
@@ -189,30 +192,34 @@
|
|
|
189
192
|
}
|
|
190
193
|
el("process-notice").textContent = data.terminal?.last_notice || "";
|
|
191
194
|
preferences?.sync(data, meta);
|
|
195
|
+
applications?.sync(data);
|
|
192
196
|
}
|
|
193
197
|
window.addEventListener("ccdx:connections", event => { if (current === "codex" && event.detail?.imageChanged) void loadSettings(); });
|
|
194
198
|
async function loadSettings() {
|
|
195
|
-
if (settingsPending) return;
|
|
199
|
+
if (settingsPending) return settingsReadPending;
|
|
196
200
|
settingsPending = true;
|
|
201
|
+
applications?.render();
|
|
197
202
|
el("terminal-color-theme").disabled = true;
|
|
198
203
|
syncAccountControls();
|
|
199
204
|
const readVersion = preferences?.version;
|
|
200
|
-
try { applySettings(await
|
|
205
|
+
try { settingsReadPending = api();applySettings(await settingsReadPending, { readVersion });settingsReadAt = time(Date.now());void globalThis.ccdxConnections?.load(); }
|
|
201
206
|
catch (error) {
|
|
202
207
|
for (const id of ["settings-note", ...(settingsViews.includes(current) ? ["page-settings-note"] : [])]) {
|
|
203
208
|
label(el(id), settingsReadAt ? "showing_previous_data_updated_time" : "could_not_read_settings", { time: settingsReadAt });
|
|
204
209
|
el(id).title = error.message;
|
|
205
210
|
}
|
|
206
211
|
}
|
|
207
|
-
finally { settingsPending = false;el("m365-enabled").disabled = !settings;el("terminal-color-theme").disabled = !settings;el("apply-source").disabled = !sourceReady();syncReviewButton();syncAccountControls(); }
|
|
212
|
+
finally { settingsReadPending = null;settingsPending = false;applications?.render();el("m365-enabled").disabled = !settings;el("terminal-color-theme").disabled = !settings;el("apply-source").disabled = !sourceReady();syncReviewButton();syncAccountControls(); }
|
|
208
213
|
}
|
|
209
214
|
async function change(body, button, { quiet = false } = {}) {
|
|
215
|
+
if (settingsReadPending) await settingsReadPending.catch(() => {});
|
|
210
216
|
if (settingsPending) return;
|
|
211
217
|
settingsPending = true;
|
|
218
|
+
applications?.render();
|
|
212
219
|
syncAccountControls();
|
|
213
220
|
const controls = [...document.querySelectorAll("[role=switch], #save-history, #clean-history, #fix-prediction, #apply-source, #save-review, #source-provider, #source-model, #source-review, #source-review-effort, #terminal-color-theme, #m365-enabled, #prediction-continue, #prediction-open, #prediction-setup, #prediction-remove, #image-models input, #image-check, #image-repair, #image-open, #decoded-limit, #decoded-limit-save, #decoded-limit-default, #install-update")];
|
|
214
221
|
controls.forEach(input => { input.disabled = true; });
|
|
215
|
-
const note = el(body.action === "codex_app" ? body.intent === "prediction" ? "prediction-open-note" : "image-action-note" : body.action === "prediction" ? body.operation === "open" ? "prediction-open-note" : "prediction-action-note" : body.action === "image" ? "effect-image_enabled" : body.action === "update" ? "manual-update-note" : body.action === "decoded_limit" ? "decoded-limit-note" : body.action === "nightly_update" ? "nightly-state" : body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
|
|
222
|
+
const note = el(body.action === "application" ? "application-state" : body.key === "codex_auto_launch" ? "codex-auto-launch-note" : body.action === "codex_app" ? body.intent === "prediction" ? "prediction-open-note" : "image-action-note" : body.action === "prediction" ? body.operation === "open" ? "prediction-open-note" : "prediction-action-note" : body.action === "image" ? "effect-image_enabled" : body.action === "update" ? "manual-update-note" : body.action === "decoded_limit" ? "decoded-limit-note" : body.action === "nightly_update" ? "nightly-state" : body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
|
|
216
223
|
: body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
|
|
217
224
|
: body.operation === "switch" ? "source-control-note" : body.operation === "auto-review" ? "review-control-note"
|
|
218
225
|
: body.operation === "account" ? "m365-account-note" : "m365-control-note");
|
|
@@ -248,10 +255,12 @@
|
|
|
248
255
|
} finally {
|
|
249
256
|
settingsPending = false;controls.forEach(input => { input.disabled = false; });
|
|
250
257
|
syncAccountControls();
|
|
251
|
-
if (settings) for (const [key, value] of Object.entries(settings.effective)) if (value.locked)
|
|
258
|
+
if (settings) for (const [key, value] of Object.entries(settings.effective)) if (value.locked) {
|
|
259
|
+
const node = el(key === "codex_auto_launch" ? "codex-auto-launch" : `setting-${key}`);if (node) node.disabled = true;
|
|
260
|
+
}
|
|
252
261
|
if (settings?.history.source === "environment") el("save-history").disabled = true;
|
|
253
262
|
el("apply-source").disabled = !sourceReady();el("source-model").disabled = !selectedSource()?.selection.models_required;syncReviewButton();
|
|
254
|
-
features?.render(settings, { notes: false });
|
|
263
|
+
features?.render(settings, { notes: false });applications?.render();
|
|
255
264
|
button?.removeAttribute("aria-busy");
|
|
256
265
|
}
|
|
257
266
|
}
|
|
@@ -343,6 +352,7 @@
|
|
|
343
352
|
});
|
|
344
353
|
el("auto-refresh").addEventListener("click", schedule);
|
|
345
354
|
el("refresh").addEventListener("click", () => { if (settingsViews.includes(current)) void loadSettings(); });
|
|
355
|
+
el("refresh").addEventListener("click", () => applications?.refresh());
|
|
346
356
|
document.addEventListener("ccdx:privacy-preferences", event => { if (event.detail?.preferences) preferences?.sync(event.detail);else if (settingsViews.includes(current)) void loadSettings(); });
|
|
347
357
|
window.addEventListener("pagehide", () => { stopped = true;clearTimeout(timer); });
|
|
348
358
|
window.addEventListener("pageshow", () => { stopped = false;schedule(); });
|
package/src/dashboard/gemini.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const el=id=>document.getElementById(id),language=globalThis.ccdxLanguage;
|
|
3
3
|
let busy=false,state=null,draft=null,notice=null,pendingAction=null;
|
|
4
|
+
let sharedApplication=null,sharedPending=false;
|
|
4
5
|
const words=(id,key)=>language.set(el(id),key);
|
|
5
6
|
const clear=id=>{el(id).removeAttribute('data-i18n');el(id).removeAttribute('data-i18n-args');el(id).textContent='';el(id).title=''};
|
|
6
7
|
const controls=['gemini-enabled','gemini-open','gemini-refresh','gemini-save','gemini-cancel'];
|
|
@@ -18,10 +19,11 @@
|
|
|
18
19
|
return [...groups.values()];
|
|
19
20
|
};
|
|
20
21
|
function render(){
|
|
21
|
-
for(const id of controls)el(id).disabled=busy||!state;
|
|
22
|
+
for(const id of controls)el(id).disabled=busy||sharedPending||!state;
|
|
22
23
|
if(!state)return;
|
|
24
|
+
if(sharedApplication&&(sharedApplication.inspection||0)>=(state.application?.inspection||0))state.app={...state.app,status:sharedApplication.status,version:sharedApplication.version||state.app.version};
|
|
23
25
|
if(!busy)el('gemini-enabled').checked=state.enabled;
|
|
24
|
-
el('gemini-save').disabled=busy||!dirty();el('gemini-cancel').disabled=busy||!dirty();
|
|
26
|
+
el('gemini-save').disabled=busy||sharedPending||!dirty();el('gemini-cancel').disabled=busy||sharedPending||!dirty();
|
|
25
27
|
words('gemini-save',busy&&pendingAction==='models'?'api_saving':'api_save');if(busy&&pendingAction==='models')el('gemini-save').setAttribute('aria-busy','true');else el('gemini-save').removeAttribute('aria-busy');
|
|
26
28
|
words('gemini-draft-state',dirty()?'cap_unsaved':'cap_saved');
|
|
27
29
|
words('gemini-route-state',!state.enabled?'gemini_disabled':state.source_enabled===false?'gemini_source_disabled':state.app.status==='starting'?'gemini_route_waiting':state.models_reload_required===null?'gemini_catalog_unknown':state.models_reload_required?'gemini_models_pending':state.route_observed?'gemini_route_observed':'gemini_route_waiting');
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
const needsReload=state.enabled&&state.source_enabled!==false&&(state.models_reload_required===true||state.models_reload_required===null);
|
|
31
33
|
const hint=!state.enabled&&state.app.status==='running'?'gemini_pause_reopen':needsReload?(state.app.status==='running'?(state.models_reload_required===null?'gemini_maybe_reopen':'gemini_reopen'):state.app.status==='stopped'?'gemini_open_to_load':null):null;
|
|
32
34
|
el('gemini-reopen').hidden=!hint;if(hint)words('gemini-reopen',hint);
|
|
33
|
-
el('gemini-open').disabled=busy||state.app.status!=='stopped';
|
|
35
|
+
el('gemini-open').disabled=busy||sharedPending||state.app.status!=='stopped';
|
|
34
36
|
const list=el('gemini-models'),focus=list.contains(document.activeElement)?document.activeElement.value:null;list.replaceChildren();
|
|
35
37
|
for(const model of groupedModels()){
|
|
36
38
|
const chosen=new Set(draft||selected()),ids=model.efforts.map(item=>item.id);
|
|
@@ -63,13 +65,14 @@
|
|
|
63
65
|
}
|
|
64
66
|
return state;
|
|
65
67
|
}catch(error){if(!report)throw error;notice='gemini_operation_failed';words('gemini-note',notice);el('gemini-note').title=error.message}
|
|
66
|
-
finally{busy=false;pendingAction=null;render();window.dispatchEvent(new
|
|
68
|
+
finally{busy=false;pendingAction=null;render();window.dispatchEvent(new CustomEvent('ccdx-gemini-state',{detail:{application:state?.application}}))}
|
|
67
69
|
}
|
|
68
70
|
globalThis.ccdxAntigravity={get state(){return state},get pending(){return busy},setEnabled:enabled=>load(enabled?'enable':'disable',{},false)};
|
|
69
71
|
el('gemini-enabled').addEventListener('change',event=>void load(event.target.checked?'enable':'disable'));
|
|
70
72
|
el('gemini-model-form').addEventListener('submit',event=>{event.preventDefault();if(dirty())void load('models',{models:draft})});
|
|
71
73
|
el('gemini-cancel').addEventListener('click',()=>{draft=null;notice=null;clear('gemini-note');render()});
|
|
72
|
-
el('gemini-open').addEventListener('click',()=>void load('open'));
|
|
74
|
+
el('gemini-open').addEventListener('click',()=>{if(globalThis.ccdxApplicationControls)globalThis.ccdxApplicationControls.open('antigravity');else void load('open')});
|
|
75
|
+
window.addEventListener('ccdx:application-state',event=>{if(event.detail?.id==='antigravity'){sharedApplication=event.detail.application;sharedPending=event.detail.pending;render()}});
|
|
73
76
|
el('gemini-refresh').addEventListener('click',()=>void load('refresh'));
|
|
74
77
|
el('refresh').addEventListener('click',()=>{if(['#gemini','#models'].includes(location.hash))void load(location.hash==='#models'?'summary':'refresh')});
|
|
75
78
|
window.addEventListener('hashchange',()=>{if(['#gemini','#models'].includes(location.hash))void load(location.hash==='#models'?'summary':undefined)});
|