codex-copilot-dx 1.4.6 → 1.4.8
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/docs/REFERENCE.md +6 -5
- package/package.json +1 -1
- package/src/adapter.mjs +5 -2
- package/src/antigravity-handler.mjs +14 -6
- package/src/antigravity-models.mjs +10 -2
- package/src/antigravity-runtime.mjs +23 -12
- package/src/carbon-search.mjs +1 -1
- package/src/claude-gateway.mjs +1 -1
- package/src/cli-command-spec.mjs +1 -1
- package/src/cli-limits.mjs +6 -1
- package/src/cli-management.mjs +20 -7
- package/src/dashboard/console.js +2 -2
- package/src/dashboard/features.js +21 -1
- package/src/dashboard/gemini.js +32 -12
- package/src/dashboard/index.html +10 -9
- package/src/dashboard/language.js +16 -4
- package/src/dashboard/status.js +9 -3
- package/src/dashboard/ui.css +2 -1
- package/src/http-transport.mjs +21 -8
- package/src/native-images.mjs +1 -1
- package/src/request-admission.mjs +53 -19
- package/src/responses-handler.mjs +2 -2
- package/src/service-control.mjs +9 -3
- package/src/user-settings.mjs +34 -0
package/docs/REFERENCE.md
CHANGED
|
@@ -85,7 +85,7 @@ Choose its exposed models on the Antigravity page or with
|
|
|
85
85
|
`app antigravity models --edit`. Each WebUI row represents one model. Compatible Gemini chat models come from the current GitHub catalog, rather than a fixed Carbon/Argon list. The Reasoning column lists advertised levels, including Hydrogen's `xhigh` when available. The model checkbox controls visibility. Save/Discard, refresh, navigation, pausing and an off/on toggle preserve an existing saved route subset. CLI model editing and model files remain available for fine-grained effort selection. Refresh on this page or run `app antigravity models --refresh` to read the upstream catalog through the existing GitHub refresh runtime. Refresh does not change saved choices, save drafts, restart clients or invoke inference; failed reads retain the last usable list.
|
|
86
86
|
|
|
87
87
|
The native Gemini catalog still uses distinct routing aliases for each level so its original selector can choose the intended effort. JSON model output retains those aliases for compatibility, with a `model` field identifying the actual model; the management status also includes `model_groups`. A model file accepts `{"models":["gemini-4-hydrogen"]}` to expose all of its advertised levels, or individual `ccdx-copilot-...-<effort>` aliases to choose a subset. Existing Carbon/Argon aliases remain valid. Models without declared reasoning levels use one plain alias.
|
|
88
|
-
|
|
88
|
+
Choose **Set default** on a Copilot model row, or **Use app default** to clear the preference. The row action uses `medium` if selected, otherwise the first selected level. `app antigravity models --edit` can choose an exact level; a model file can add `"default_model"` with a selected base ID or route alias, or `null` to clear. The gateway changes only the agent-default field in a compatible catalog; it leaves requests, existing conversation bindings, ordinary Gemini chat and background tasks unchanged. An unavailable saved default does not silently pick another Copilot model. The page reports when the catalog still needs to be loaded. Reopen Gemini through CCDX if needed; a fetched catalog does not prove that the app changed its current picker selection.
|
|
89
89
|
|
|
90
90
|
The WebUI uses one authorization form for GitHub Copilot, Microsoft 365 and custom APIs. Source switches apply immediately. App-authorization and model checkboxes are drafts until **Save**; **Discard changes** restores the saved selection. Drafts survive refresh and navigation. Source authorization does not choose app models.
|
|
91
91
|
|
|
@@ -93,8 +93,7 @@ Pausing Antigravity Copilot access retains its saved model selection. Native Goo
|
|
|
93
93
|
|
|
94
94
|
The page distinguishes enabled access from an observed client connection.
|
|
95
95
|
|
|
96
|
-
Compatible Gemini models and their declared reasoning levels appear when the Copilot account advertises them. Image-only models, incompatible interfaces and explicitly unavailable models are excluded. Google models
|
|
97
|
-
are retained. Conversations keep their initial Google/Copilot source; start a
|
|
96
|
+
Compatible Gemini models and their declared reasoning levels appear when the Copilot account advertises them. Image-only models, incompatible interfaces and explicitly unavailable models are excluded. Google models and account controls are retained. The app default is retained unless an available preferred Copilot model can be published in a compatible agent catalog. Conversations keep their initial Google/Copilot source; start a
|
|
98
97
|
new conversation to change source. Unsupported PDF, audio and video inputs are refused
|
|
99
98
|
before Copilot dispatch. Text, inline images and native function tools are
|
|
100
99
|
converted to the advertised Copilot Chat interface; truncated streams report an
|
|
@@ -258,9 +257,11 @@ For an identified conversation, hovering a point in the input-history chart show
|
|
|
258
257
|
|
|
259
258
|
## Shared source concurrency
|
|
260
259
|
|
|
260
|
+
In **Settings → Advanced: request limits**, **Shared request-body limit** sets the shared gateway reservation to 32–128 MiB (default 32 MiB). It applies at the next CCDX start. `ccdx config limits` shows the saved and running values. `CCDX_MAX_INFLIGHT_BODY_BYTES` still overrides the saved value. This control does not change per-request size limits, the decompressed-body or response-history pools, Claude's separate Messages queue, or provider concurrency. Increasing this limit does not fix a provider timeout. Antigravity control GETs without a framed body do not enter the upload queue.
|
|
261
|
+
|
|
261
262
|
`ccdx status` shows the longest admitted wait in the gateway's local request-body queue. `status --json` retains the longest sample and up to 16 recent waits, including cancellations and timeouts. Samples record a route, request ID, wait reason and byte counts in memory; no request body or credential is retained. The existing request details distinguish local waiting from waiting for the selected source. Local waiting ends before the body is read, and source waiting ends before sending upstream.
|
|
262
263
|
|
|
263
|
-
All three Apps share admission for the same configured source and account. A slot spans the real upstream response body through completion, cancellation or error. Request-body memory is tracked separately; unknown
|
|
264
|
+
All three Apps share admission for the same configured source and account. A slot spans the real upstream response body through completion, cancellation or error. Request-body memory is tracked separately; uploads of unknown length start with a minimal reservation and grow it by bytes read, before retaining the data for parsing. If there is not enough room, reading pauses until existing requests release memory. Only one such reader per pool may grow at a time; a reader waiting for more memory takes priority over new admissions. Once upload is complete, another reader can start while the earlier request retains its actual body reservation. Requests larger than the pool still run exclusively at the pool ceiling, subject to the existing per-request limits. Growth waits share the existing upload deadline and can appear in the body-read time; the entry queue is recorded separately. Recovery and internal summaries acquire fresh slots after the rejected response releases its slot.
|
|
264
265
|
|
|
265
266
|
Automatic control distinguishes explicit concurrency rejection, request-rate feedback and quota exhaustion. Clear concurrency feedback lowers capacity without interrupting active streams; stable successful traffic with real waiting demand slowly increases it. Explicit account-wide rate/quota evidence pauses that account; model-scoped feedback leaves sibling models available after a short spacing interval. Unknown 429s use bounded backoff. Parameters, permissions and long thinking time do not train concurrency. There are no quota probes or automatic source/account/model switches. A first upstream limit rejection can still occur before its capacity is known.
|
|
266
267
|
|
|
@@ -810,7 +811,7 @@ The old external image provider, Qwen-specific generation/editing, `/mcp/image`,
|
|
|
810
811
|
| `CCDX_ALLOW_LAN` | unset | Set to `1` to permit a non-loopback host such as `0.0.0.0`; this exposes the Copilot-backed adapter beyond this machine |
|
|
811
812
|
| `CCDX_MAX_BODY_BYTES` | `67108864` | Maximum compressed or raw request-body size |
|
|
812
813
|
| `CCDX_MAX_DECODED_BODY_BYTES` | `134217728` | Maximum decoded request-body size after decompression |
|
|
813
|
-
| `CCDX_MAX_INFLIGHT_BODY_BYTES` | `33554432` | Per-pool byte budget for raw bodies, decoded bodies, and materialized response history;
|
|
814
|
+
| `CCDX_MAX_INFLIGHT_BODY_BYTES` | `33554432` | Per-pool byte budget for raw bodies, decoded bodies, and materialized response history; overrides the saved shared request-body setting. A larger item runs exclusively in its pool |
|
|
814
815
|
| `CCDX_MAX_UPSTREAM_CHAT_RESPONSE_BYTES` | `67108864` | Maximum buffered successful Chat Completions response used by the internal Responses compatibility path |
|
|
815
816
|
| `CCDX_MAX_UPSTREAM_RESPONSES_RESPONSE_BYTES` | `268435456` | Maximum buffered successful native Responses or compact response; streaming Responses use bounded backpressure |
|
|
816
817
|
| `CCDX_MAX_QUEUED_REQUESTS` | `16` | Maximum body requests waiting for shared byte admission |
|
package/package.json
CHANGED
package/src/adapter.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { imageModelCatalog } from "./image-models.mjs";
|
|
2
2
|
import http from "node:http";
|
|
3
|
-
import { readUserSettings } from "./user-settings.mjs";
|
|
3
|
+
import { inflightBodyLimitPreference, readUserSettings } from "./user-settings.mjs";
|
|
4
4
|
import { createNativeImagesHandler } from "./native-images.mjs";
|
|
5
5
|
import { defaultCopilotClient } from "./copilot.mjs";
|
|
6
6
|
import { buildCodexModelResponse } from "./codex-model-catalog.mjs";
|
|
@@ -177,7 +177,10 @@ export function createAdapterHandler(options = {}) {
|
|
|
177
177
|
const streamHandshakeTimeoutMs = parsePositiveInteger(options.streamHandshakeTimeoutMs, ADAPTER_RUNTIME_CONFIG.streamHandshakeTimeoutMs);
|
|
178
178
|
const streamIdleTimeoutMs = parsePositiveInteger(options.streamIdleTimeoutMs, ADAPTER_RUNTIME_CONFIG.streamIdleTimeoutMs);
|
|
179
179
|
const requestBodyTimeoutMs = parsePositiveInteger(options.requestBodyTimeoutMs, ADAPTER_RUNTIME_CONFIG.requestBodyTimeoutMs);
|
|
180
|
-
const acquireRequest = options.acquireRequest || createRequestAdmission(
|
|
180
|
+
const acquireRequest = options.acquireRequest || createRequestAdmission({
|
|
181
|
+
maxBytes: inflightBodyLimitPreference({ env: options.env, home: options.dashboardOptions?.home }).bytes,
|
|
182
|
+
maxSupplementalBytes: options.env ? loadRuntimeConfig(options.env).maxInflightBodyBytes : ADAPTER_RUNTIME_CONFIG.maxInflightBodyBytes,
|
|
183
|
+
});
|
|
181
184
|
const requestMetrics = options.requestMetrics || createRequestMetrics();
|
|
182
185
|
const streamPerformanceMetrics = options.streamPerformanceMetrics || createStreamPerformanceMetrics({ routeNames: ["responses", "responses_compact", "antigravity"] });
|
|
183
186
|
const imagePressure = options.imagePressure || createResponsesImagePressureController();
|
|
@@ -4,7 +4,7 @@ import {createRequestAbort,abortErrorStatusCode,readJsonBody,readBoundedResponse
|
|
|
4
4
|
import {safeUpstreamResponseHeaders} from "./upstream-headers.mjs";
|
|
5
5
|
import {isLoopbackAddress,isLoopbackHostHeader} from "./security.mjs";
|
|
6
6
|
import {antigravityToChat,chatToAntigravity,chatStreamToAntigravity,parseAntigravityJSON} from "./antigravity-chat-bridge.mjs";
|
|
7
|
-
import {ANTIGRAVITY_MODEL_PREFIX,antigravityCopilotModels,mergeAntigravityModels} from "./antigravity-models.mjs";
|
|
7
|
+
import {ANTIGRAVITY_MODEL_PREFIX,antigravityCopilotModels,hasAntigravityAgentDefault,mergeAntigravityModels} from "./antigravity-models.mjs";
|
|
8
8
|
import {createPrivacyTextFragments} from "./privacy-stream.mjs";
|
|
9
9
|
import {createGoogleResponseObserver,googleUsageEvent} from "./antigravity-usage.mjs";
|
|
10
10
|
import {currentRequestContext,observeRequestedModel} from "./request-context.mjs";
|
|
@@ -37,10 +37,10 @@ function groundedSearch(result,query){
|
|
|
37
37
|
groundingMetadata:{webSearchQueries:[query],groundingChunks:sources.map(item=>({web:{uri:item.url,title:item.title||item.url}}))}}]};
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export function createAntigravityHandler({client,models=()=>[],selectedModels=()=>null,enabled=()=>false,privacy,searchFn,imageFn,guardSource,acquireRequest=async()=>()=>{},sourceAdmission,applicationEvidence,
|
|
40
|
+
export function createAntigravityHandler({client,models=()=>[],selectedModels=()=>null,defaultModel=()=>null,enabled=()=>false,privacy,searchFn,imageFn,guardSource,acquireRequest=async()=>()=>{},sourceAdmission,applicationEvidence,
|
|
41
41
|
compaction,compactionProfile=()=>"github",rememberConversationSource=()=>{},resolveCompactionSource=()=>null,recordUsageFn=recordUsage,fetchGoogle=fetch,googleOrigin=GOOGLE_ORIGIN,requestBodyTimeoutMs=120000,upstreamTimeoutMs=180000,streamIdleTimeoutMs=60000}={}) {
|
|
42
42
|
if(![GOOGLE_ORIGIN,"https://cloudcode-pa.googleapis.com"].includes(googleOrigin))throw new Error("Unrecognized Google control origin");
|
|
43
|
-
let active=0,observed=false,catalogModels=null;const nativeWindows=new Map();
|
|
43
|
+
let active=0,observed=false,catalogModels=null,catalogDefaultSupported=null,catalogDefaultModel=null;const nativeWindows=new Map();
|
|
44
44
|
const counts={total:0,google:0,copilot:0,search:0,images:0,failed:0};
|
|
45
45
|
const handler=async(req,res)=>{
|
|
46
46
|
const abort=createRequestAbort(req,res);let release=()=>{},session,body,request,converted,phase="validation",usageEvent=null,usageModel=null,outcome=null,usageMode,usageProvider;
|
|
@@ -73,7 +73,13 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
73
73
|
const method=match[1];
|
|
74
74
|
if(controlMethods.has(method))applicationEvidence?.notice(req,res,"antigravity","control");
|
|
75
75
|
if(req.method==="POST"&&!/^application\/json(?:;|$)/i.test(req.headers["content-type"]||""))throw httpError("Antigravity requires JSON",415);
|
|
76
|
-
|
|
76
|
+
const length=req.headers["content-length"];
|
|
77
|
+
const bodylessControl=req.method==="GET"&&controlMethods.has(method)&&req.headers["transfer-encoding"]===undefined
|
|
78
|
+
&&(length===undefined||typeof length==="string"&&/^0+$/.test(length));
|
|
79
|
+
phase="admission";
|
|
80
|
+
// A framed request still needs the existing reservation. A known control
|
|
81
|
+
// GET with no body does not occupy space in the upload queue.
|
|
82
|
+
if(!bodylessControl)release=await measureRequestStageAsync("admission",()=>acquireRequest(req,{signal:abort.signal,streamingBody:req.method==="POST"}));
|
|
77
83
|
phase="body";abort.setTimeout(requestBodyTimeoutMs,"request_body_timeout");
|
|
78
84
|
body=req.method==="POST"?await measureRequestStageAsync("body",()=>readJsonBody(req,{admission:release,signal:abort.signal,parse:parseBody})):null;
|
|
79
85
|
phase="preparation";
|
|
@@ -117,7 +123,9 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
117
123
|
if(method==="fetchAvailableModels"&&upstream.ok){
|
|
118
124
|
const value=JSON.parse(await readBoundedResponseText(upstream,{maxBytes:8*1024*1024,signal:abort.signal,label:"Google model catalog"}));
|
|
119
125
|
nativeWindows.clear();for(const[id,entry]of Object.entries(value.models||{}).slice(0,256))if(Number.isSafeInteger(entry?.maxTokens)&&entry.maxTokens>0){nativeWindows.set(id,entry.maxTokens);if(typeof entry.model==="string")nativeWindows.set(entry.model,entry.maxTokens)}
|
|
120
|
-
const merged=mergeAntigravityModels(value,models(),selectedModels());
|
|
126
|
+
const merged=mergeAntigravityModels(value,models(),selectedModels(),defaultModel());
|
|
127
|
+
catalogDefaultSupported=hasAntigravityAgentDefault(value);
|
|
128
|
+
catalogDefaultModel=catalogDefaultSupported&&merged.defaultAgentModelId.startsWith(ANTIGRAVITY_MODEL_PREFIX)?merged.defaultAgentModelId:null;
|
|
121
129
|
catalogModels=Object.keys(merged.models).filter(id=>id.startsWith(ANTIGRAVITY_MODEL_PREFIX));
|
|
122
130
|
res.writeHead(200,{"Content-Type":"application/json","Cache-Control":"no-store"});res.end(JSON.stringify(merged));return;
|
|
123
131
|
}
|
|
@@ -253,6 +261,6 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
253
261
|
}
|
|
254
262
|
}
|
|
255
263
|
};
|
|
256
|
-
handler.snapshot=()=>({enabled:enabled(),observed,catalog_models:catalogModels,active,...counts});
|
|
264
|
+
handler.snapshot=()=>({enabled:enabled(),observed,catalog_models:catalogModels,catalog_default_supported:catalogDefaultSupported,catalog_default_model:catalogDefaultModel,active,...counts});
|
|
257
265
|
return handler;
|
|
258
266
|
}
|
|
@@ -22,7 +22,14 @@ export function antigravityCopilotModels(catalog) {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// Use the upstream's existing agent-default field only when it names a model
|
|
26
|
+
// in the same catalog. Do not invent a default contract for an unknown catalog.
|
|
27
|
+
export function hasAntigravityAgentDefault(catalog) {
|
|
28
|
+
const id=catalog?.defaultAgentModelId;
|
|
29
|
+
return typeof id==="string"&&!!catalog.models&&Object.hasOwn(catalog.models,id);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function mergeAntigravityModels(googleCatalog,copilotCatalog,selection=null,defaultModel=null) {
|
|
26
33
|
if(!googleCatalog?.models||typeof googleCatalog.models!=="object"||Array.isArray(googleCatalog.models))throw new Error("Unrecognized Google model catalog");
|
|
27
34
|
const entries=antigravityCopilotModels(copilotCatalog).filter(model=>selection===null||selection.includes(model.id)),models={...googleCatalog.models};
|
|
28
35
|
if(!entries.length)return googleCatalog;
|
|
@@ -39,5 +46,6 @@ export function mergeAntigravityModels(googleCatalog,copilotCatalog,selection=nu
|
|
|
39
46
|
const sort=sorts.find(item=>item.displayName?.toLowerCase()==="recommended")||sorts[0];
|
|
40
47
|
sort.groups??=[];sort.groups[0]??={modelIds:[]};
|
|
41
48
|
sort.groups[0].modelIds=[...(sort.groups[0].modelIds||[]),...entries.map(entry=>entry.id)];
|
|
42
|
-
return {...googleCatalog,models,agentModelSorts:sorts
|
|
49
|
+
return {...googleCatalog,models,agentModelSorts:sorts,
|
|
50
|
+
...(hasAntigravityAgentDefault(googleCatalog)&&entries.some(entry=>entry.id===defaultModel)?{defaultAgentModelId:defaultModel}:{})};
|
|
43
51
|
}
|
|
@@ -19,7 +19,8 @@ import {withFileLockSync} from "./lock.mjs";
|
|
|
19
19
|
import {httpError} from "./http-errors.mjs";
|
|
20
20
|
import {antigravityCopilotModels} from "./antigravity-models.mjs";
|
|
21
21
|
|
|
22
|
-
const execute=promisify(execFile),key="gemini_antigravity_enabled",modelKey="gemini_antigravity_models";
|
|
22
|
+
const execute=promisify(execFile),key="gemini_antigravity_enabled",modelKey="gemini_antigravity_models",defaultKey="gemini_antigravity_default_model";
|
|
23
|
+
const validAlias=id=>typeof id==="string"&&/^ccdx-copilot-[a-z0-9._-]{1,140}$/.test(id);
|
|
23
24
|
|
|
24
25
|
export function createAntigravityRuntime({client,models=()=>[],refreshModels,privacy,home=os.homedir(),env=process.env,inspect=inspectGeminiApp,
|
|
25
26
|
exec=execute,searchFn,imageFn,guardSource,googleFetch,acquireRequest,applicationControl,readToken=()=>readSavedGithubToken(home),...timeouts}={}) {
|
|
@@ -35,8 +36,9 @@ export function createAntigravityRuntime({client,models=()=>[],refreshModels,pri
|
|
|
35
36
|
const settings=()=>{
|
|
36
37
|
const saved=readUserSettings({...options,strict:true});
|
|
37
38
|
if(saved[key]!==undefined&&typeof saved[key]!=="boolean")throw httpError("Invalid Gemini integration setting",409);
|
|
38
|
-
if(saved[modelKey]!==undefined&&(!Array.isArray(saved[modelKey])||saved[modelKey].length>100||new Set(saved[modelKey]).size!==saved[modelKey].length||saved[modelKey].some(id
|
|
39
|
-
|
|
39
|
+
if(saved[modelKey]!==undefined&&(!Array.isArray(saved[modelKey])||saved[modelKey].length>100||new Set(saved[modelKey]).size!==saved[modelKey].length||saved[modelKey].some(id=>!validAlias(id))))throw httpError("Invalid Antigravity model selection",409);
|
|
40
|
+
if(saved[defaultKey]!==undefined&&!validAlias(saved[defaultKey]))throw httpError("Invalid Antigravity default model",409);
|
|
41
|
+
return {configured:Object.hasOwn(saved,key),enabled:saved[key]===true,selected_models:saved[modelKey]??null,default_model:saved[defaultKey]??null};
|
|
40
42
|
};
|
|
41
43
|
const available=()=>settings().enabled&&readAccessSettings(options).providers.github?models():[];
|
|
42
44
|
const sourceGuard=guardSource||((body,source,signal)=>{
|
|
@@ -45,7 +47,7 @@ export function createAntigravityRuntime({client,models=()=>[],refreshModels,pri
|
|
|
45
47
|
const profile=source==="github"?"codex:"+githubTokenFingerprint(readToken()||""):"google:gemini-native";
|
|
46
48
|
return guard("gemini",profile,{messages:[]},{session_id:id},readClientGatewayKeys({...options,create:false}).codex,undefined,signal);
|
|
47
49
|
});
|
|
48
|
-
const handler=createAntigravityHandler({client,models:available,selectedModels:()=>settings().selected_models,enabled:()=>settings().configured,privacy,searchFn:searchFn||web.search,
|
|
50
|
+
const handler=createAntigravityHandler({client,models:available,selectedModels:()=>settings().selected_models,defaultModel:()=>settings().default_model,enabled:()=>settings().configured,privacy,searchFn:searchFn||web.search,
|
|
49
51
|
imageFn:imageFn||createAntigravityImages({client,models:available,privacy}),guardSource:sourceGuard,compactionProfile:()=>githubTokenFingerprint(readToken()||""),
|
|
50
52
|
rememberConversationSource(body,source){const key=conversationKey(body);if(!key||typeof body.model!=="string"||!/^[\w][\w./:@+-]{0,159}$/.test(body.model))return;conversationSources.delete(key);conversationSources.set(key,{source,model:body.model});while(conversationSources.size>256)conversationSources.delete(conversationSources.keys().next().value)},
|
|
51
53
|
async resolveCompactionSource(body){
|
|
@@ -61,26 +63,29 @@ export function createAntigravityRuntime({client,models=()=>[],refreshModels,pri
|
|
|
61
63
|
},fetchGoogle:googleFetch,acquireRequest,...timeouts});
|
|
62
64
|
function snapshot(){
|
|
63
65
|
const config=settings(),sourceEnabled=readAccessSettings(options).providers.github,activity=handler.snapshot();
|
|
64
|
-
const listed=antigravityCopilotModels(models()).map(({id,model,displayName,effort,maxTokens})=>({id,model,name:displayName,effort,context_window:maxTokens,selected:config.selected_models===null||config.selected_models.includes(id)}));
|
|
66
|
+
const listed=antigravityCopilotModels(models()).map(({id,model,displayName,effort,maxTokens})=>({id,model,name:displayName,effort,context_window:maxTokens,default:id===config.default_model,selected:config.selected_models===null||config.selected_models.includes(id)}));
|
|
65
67
|
const groups=new Map();
|
|
66
68
|
for(const variant of listed){
|
|
67
|
-
if(!groups.has(variant.model))groups.set(variant.model,{id:variant.model,name:variant.name.split(" · Copilot")[0],source:"github",context_window:variant.context_window,efforts:[]});
|
|
68
|
-
groups.get(variant.model).efforts.push({id:variant.id,effort:variant.effort,selected:variant.selected});
|
|
69
|
+
if(!groups.has(variant.model))groups.set(variant.model,{id:variant.model,name:variant.name.split(" · Copilot")[0],source:"github",context_window:variant.context_window,default:false,efforts:[]});
|
|
70
|
+
const group=groups.get(variant.model);group.default||=variant.default;group.efforts.push({id:variant.id,effort:variant.effort,selected:variant.selected});
|
|
69
71
|
}
|
|
70
72
|
const expected=listed.filter(model=>model.selected).map(model=>model.id).sort();
|
|
71
|
-
const
|
|
73
|
+
const desiredDefault=expected.includes(config.default_model)?config.default_model:null;
|
|
74
|
+
const reload=config.enabled&&sourceEnabled?(activity.catalog_models===null?null:JSON.stringify([...activity.catalog_models].sort())!==JSON.stringify(expected)
|
|
75
|
+
||activity.catalog_default_supported===true&&activity.catalog_default_model!==desiredDefault):false;
|
|
76
|
+
const defaultUnavailable=config.default_model!==null&&(!desiredDefault||activity.catalog_default_supported===false);
|
|
72
77
|
const current=applicationControl?.snapshot().antigravity;
|
|
73
78
|
const visibleApp=current?{status:current.status,version:current.version||null,pids:current.pid?[current.pid]:[]}:app;
|
|
74
|
-
return {source:"gemini_antigravity",...config,source_enabled:sourceEnabled,models_reload_required:reload,app:visibleApp,application:current||null,route_observed:handler.snapshot().observed,
|
|
79
|
+
return {source:"gemini_antigravity",...config,source_enabled:sourceEnabled,default_model_unavailable:defaultUnavailable,models_reload_required:reload,app:visibleApp,application:current||null,route_observed:handler.snapshot().observed,
|
|
75
80
|
model_source:"Google + GitHub Copilot",background_source:"GitHub Copilot",ordinary_chat_source:"Google (unchanged)",
|
|
76
81
|
compaction_source:"Observed conversation source; existing background policy when unassigned",
|
|
77
82
|
models:listed,model_groups:[...groups.values()],activity,last_operation:lastOperation};
|
|
78
83
|
}
|
|
79
84
|
async function action(input={},baseUrl){
|
|
80
|
-
if(input&&Object.keys(input).some(name=>!["action","accept_background_copilot","models"].includes(name)))throw httpError("Invalid Gemini operation",400);
|
|
85
|
+
if(input&&Object.keys(input).some(name=>!["action","accept_background_copilot","models","default_model"].includes(name)))throw httpError("Invalid Gemini operation",400);
|
|
81
86
|
const operation=input.action||"status";
|
|
82
87
|
if(!["status","summary","refresh","models","enable","disable","open","preview"].includes(operation))throw httpError("Unknown Gemini operation",400);
|
|
83
|
-
if(input.models!==undefined&&operation!=="models")throw httpError("Models require the models operation",400);
|
|
88
|
+
if((input.models!==undefined||input.default_model!==undefined)&&operation!=="models")throw httpError("Models require the models operation",400);
|
|
84
89
|
if(operation==="refresh"){
|
|
85
90
|
if(!refreshModels)throw httpError("Antigravity model refresh is unavailable in this service",503);
|
|
86
91
|
await refreshModels();lastOperation={action:operation,status:"models_refreshed"};
|
|
@@ -89,7 +94,13 @@ export function createAntigravityRuntime({client,models=()=>[],refreshModels,pri
|
|
|
89
94
|
const ids=input.models,known=new Set(antigravityCopilotModels(models()).map(model=>model.id));
|
|
90
95
|
if(!Array.isArray(ids)||ids.length>100||new Set(ids).size!==ids.length||ids.some(id=>!known.has(id)))throw httpError("Choose available Antigravity models",400);
|
|
91
96
|
const file=userSettingsPath(options);fs.mkdirSync(path.dirname(file),{recursive:true,mode:0o700});
|
|
92
|
-
|
|
97
|
+
if(input.default_model!==undefined&&input.default_model!==null&&(!validAlias(input.default_model)||!ids.includes(input.default_model)))throw httpError("Choose a selected Antigravity model as the default",400);
|
|
98
|
+
withFileLockSync(file+".lock",()=>{
|
|
99
|
+
const saved=readUserSettings({...options,strict:true});saved[modelKey]=ids;
|
|
100
|
+
if(input.default_model!==undefined&&input.default_model!==null)saved[defaultKey]=input.default_model;
|
|
101
|
+
if(input.default_model===null||saved[defaultKey]!==undefined&&!ids.includes(saved[defaultKey]))delete saved[defaultKey];
|
|
102
|
+
atomicWriteFileIfChangedSync(file,JSON.stringify(saved,null,2)+"\n",{mode:0o600});
|
|
103
|
+
});
|
|
93
104
|
lastOperation={action:operation,status:"models_saved"};
|
|
94
105
|
}
|
|
95
106
|
if(operation==="summary")return snapshot();
|
package/src/carbon-search.mjs
CHANGED
|
@@ -8,7 +8,7 @@ export function createCarbonSearchHandler({ acquireRequest, privacy, resolveProv
|
|
|
8
8
|
const abort = createRequestAbort(req, res);
|
|
9
9
|
let release = () => {};
|
|
10
10
|
try {
|
|
11
|
-
release = await acquireRequest(req, { signal: abort.signal });
|
|
11
|
+
release = await acquireRequest(req, { signal: abort.signal, streamingBody: true });
|
|
12
12
|
abort.setTimeout(requestBodyTimeoutMs, "request_body_timeout");
|
|
13
13
|
let upstream;
|
|
14
14
|
{
|
package/src/claude-gateway.mjs
CHANGED
|
@@ -247,7 +247,7 @@ export function createClaudeGatewayHandler({ provider, apiKey, desktopAliases =
|
|
|
247
247
|
context.streamPerformance = tracker;context.route = countTokens ? "messages_count_tokens" : "messages";
|
|
248
248
|
await runWithRequestContext(context, async () => {
|
|
249
249
|
try {
|
|
250
|
-
release = await acquireRequest(req, { signal: abort.signal });
|
|
250
|
+
release = await acquireRequest(req, { signal: abort.signal, streamingBody: true });
|
|
251
251
|
abort.setTimeout(config.requestBodyTimeoutMs, "request_body_timeout");
|
|
252
252
|
let body = await readJsonBody(req, { admission: release, signal: abort.signal, maxBodyBytes: config.maxBodyBytes, maxDecodedBodyBytes: decodedLimit });
|
|
253
253
|
abort.setTimeout(config.upstreamTimeoutMs, "messages_prepare_timeout");
|
package/src/cli-command-spec.mjs
CHANGED
|
@@ -291,7 +291,7 @@ export function parseManagedCommand(args) {
|
|
|
291
291
|
const extras = {
|
|
292
292
|
source:
|
|
293
293
|
"Status reads local/cached evidence. check/--refresh may contact the source; no inference.\nsource import --file FILE previews supplied metadata; --from cc-switch|magpie reads known local configuration on demand.\n--select N --apply saves one source using private key input; no client access is granted.\nSource access grants do not select client models. Disable previews affected clients.\nGitHub login and company-account selection are source-specific.\nChoose visible models and defaults with app <app> models --edit.",
|
|
294
|
-
app: "Configured is not App adoption or process liveness. Unknown stays unknown.\nmodels shows the selected plan; Antigravity lists compatible Copilot models and
|
|
294
|
+
app: "Configured is not App adoption or process liveness. Unknown stays unknown.\nmodels shows the selected plan; Antigravity lists compatible Copilot models, selected levels and the saved default. Its --edit also sets or clears the default.\napp antigravity models --refresh reads the GitHub catalog without inference or changing saved choices.\nsource <id> models shows the upstream catalog.\nsetup/remove changes integration setup; pause/resume retains credentials.\nsync --preview shows the model/configuration plan, not a byte-level file diff.\nopen focuses an already-running app; check is read-only and sends no inference.\nrestart asks before a graceful reopen. No client program is force-restarted.",
|
|
295
295
|
config:
|
|
296
296
|
"Only service and terminal preferences are in scope. Browser appearance stays in WebUI.\nReset keeps accounts, keys, model plans and chats and stores a pre-reset backup.\nSaved and effective values can differ; restart requirements remain explicit.",
|
|
297
297
|
requests:
|
package/src/cli-limits.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import os from "node:os";
|
|
|
2
2
|
import { MIB } from "./cache-limits.mjs";
|
|
3
3
|
import { readAdapterStatus } from "./cli-status.mjs";
|
|
4
4
|
import { loadRuntimeConfig } from "./runtime-config.mjs";
|
|
5
|
-
import { decodedBodyLimitPreference, writeDecodedBodyLimitMib } from "./user-settings.mjs";
|
|
5
|
+
import { decodedBodyLimitPreference, writeDecodedBodyLimitMib, inflightBodyLimitPreference } from "./user-settings.mjs";
|
|
6
6
|
|
|
7
7
|
function mib(bytes) {
|
|
8
8
|
const value = Number(bytes);
|
|
@@ -37,6 +37,8 @@ export async function runLimitsCommand({
|
|
|
37
37
|
} catch {
|
|
38
38
|
runtime = null;
|
|
39
39
|
}
|
|
40
|
+
const inflight = inflightBodyLimitPreference({ env, home });
|
|
41
|
+
const activeInflight = runtime?.data?.admission?.maxBytes;
|
|
40
42
|
const activeDecoded = Number(runtime?.data?.limits?.max_decoded_body_bytes);
|
|
41
43
|
const activeRaw = Number(runtime?.data?.limits?.max_body_bytes);
|
|
42
44
|
const lines = [
|
|
@@ -45,10 +47,13 @@ export async function runLimitsCommand({
|
|
|
45
47
|
runtime && Number.isFinite(activeDecoded) && activeDecoded > 0
|
|
46
48
|
? `Running decoded request body: ${mib(activeDecoded)}`
|
|
47
49
|
: "Running decoded request body: unavailable",
|
|
50
|
+
`Configured shared request-body budget: ${mib(inflight.bytes)} (${inflight.source})`,
|
|
51
|
+
Number.isFinite(activeInflight) && activeInflight > 0 ? `Running shared request-body budget: ${mib(activeInflight)}` : "Running shared request-body budget: unavailable",
|
|
48
52
|
`Raw request body: ${mib(runtime && Number.isFinite(activeRaw) && activeRaw > 0 ? activeRaw : loadRuntimeConfig(env).maxBodyBytes)}${runtime ? " (running)" : " (configured)"}`,
|
|
49
53
|
];
|
|
50
54
|
if (!runtime) lines.push("Running adapter status unavailable; restart ccdx to apply and verify this limit.");
|
|
51
55
|
else if (activeDecoded !== preference.bytes) lines.push("Restart ccdx to apply the configured decoded-body limit.");
|
|
56
|
+
if (Number.isFinite(activeInflight) && activeInflight !== inflight.bytes) lines.push("Restart ccdx to apply the configured shared request-body budget.");
|
|
52
57
|
if (action === "set") lines.push("Existing conversations and caches were not modified.");
|
|
53
58
|
output.write(`${lines.join("\n")}\n`);
|
|
54
59
|
return { preference, runtime };
|
package/src/cli-management.mjs
CHANGED
|
@@ -237,9 +237,9 @@ export async function runManagementCommand(command, options = {}) {
|
|
|
237
237
|
}
|
|
238
238
|
if(action==="models"&&flags.edit){
|
|
239
239
|
const state=await request({path:"gemini",...(flags.refresh?{body:{action:"refresh"},timeoutMs:20000}:{})});
|
|
240
|
-
let ids;
|
|
240
|
+
let ids, preferred;
|
|
241
241
|
if(flags.file){
|
|
242
|
-
const
|
|
242
|
+
const file=readFile(),listed=file.models;preferred=file.default_model;if(!Array.isArray(listed))throw new Error("Model files require a models array.");
|
|
243
243
|
ids=listed.flatMap(id=>state.model_groups?.find(model=>model.id===id)?.efforts.map(item=>item.id)||[id]);
|
|
244
244
|
}
|
|
245
245
|
else if(Array.isArray(state.model_groups)){
|
|
@@ -252,13 +252,26 @@ export async function runManagementCommand(command, options = {}) {
|
|
|
252
252
|
}
|
|
253
253
|
}else ids=(await choose(state.models.map(model=>model.name),state.models.flatMap((model,index)=>model.selected!==false?[index]:[]))).map(index=>state.models[index].id);
|
|
254
254
|
if(!Array.isArray(ids)||new Set(ids).size!==ids.length||ids.some(id=>!state.models.some(model=>model.id===id)))throw new Error("Choose listed Antigravity model IDs.");
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
const available=state.models.filter(model=>ids.includes(model.id));
|
|
256
|
+
if(!flags.file&&available.length&&Object.hasOwn(state,"default_model")){
|
|
257
|
+
available.forEach((model,index)=>output.write(`${index+1}. ${terminalCell(model.name)}${model.id===state.default_model?" (default)":""}\n`));
|
|
258
|
+
const answer=(await ask("Default model number (Enter keeps it; none uses the app default): ")).trim();
|
|
259
|
+
if(answer==="none")preferred=null;
|
|
260
|
+
else if(answer){if(!/^\d+$/.test(answer)||!available[Number(answer)-1])throw new Error("Choose a listed default model number.");preferred=available[Number(answer)-1].id;}
|
|
261
|
+
}
|
|
262
|
+
if(preferred!==undefined&&preferred!==null&&!ids.includes(preferred)){
|
|
263
|
+
const choices=available.filter(item=>item.model===preferred);
|
|
264
|
+
preferred=(choices.find(item=>item.effort==="medium")||choices[0])?.id;
|
|
265
|
+
if(!preferred)throw new Error("Choose a selected Antigravity model as the default.");
|
|
266
|
+
}
|
|
267
|
+
const body={models:ids,...(preferred!==undefined?{default_model:preferred}:{})};
|
|
268
|
+
if(flags.preview)return print({...body,saved:false});
|
|
269
|
+
await confirm("Save Antigravity model settings? Reopen Gemini afterward to reload them.");
|
|
270
|
+
return print(await request({path:"gemini",body:{action:"models",...body}}));
|
|
258
271
|
}
|
|
259
272
|
const state = await request({ path: "gemini", ...(action==="models"&&flags.refresh?{body:{action:"refresh"},timeoutMs:20000}:["status", "models"].includes(action) ? {} : { body: { action: flags.preview ? "preview" : action, ...(action === "enable" ? { accept_background_copilot: true } : {}) }, timeoutMs: 20000 }) });
|
|
260
|
-
if(action==="models"&&flags.format!=="json"&&state.model_groups)return print(state.model_groups.map(model=>({model:model.name,id:model.id,source:"GitHub Copilot",context:model.context_window,
|
|
261
|
-
efforts:model.efforts.map(item=>(item.effort||"default")+(item.selected?" ✓":"")).join(" / ")})),[["model","Model"],["id","ID"],["source","Source"],["context","Context"],["efforts","Reasoning (selected ✓)"]]);
|
|
273
|
+
if(action==="models"&&flags.format!=="json"&&state.model_groups)return print(state.model_groups.map(model=>({model:model.name,id:model.id,source:"GitHub Copilot",context:model.context_window,default:model.default===true,
|
|
274
|
+
efforts:model.efforts.map(item=>(item.effort||"default")+(item.selected?" ✓":"")).join(" / ")})),[["model","Model"],["id","ID"],["source","Source"],["context","Context"],["efforts","Reasoning (selected ✓)"],["default","Default"]]);
|
|
262
275
|
return print(action === "models" ? state.models : state);
|
|
263
276
|
}
|
|
264
277
|
const graph = await connection(), snapshot = (await readStatus()).data, view = projectTerminalState(snapshot);
|
package/src/dashboard/console.js
CHANGED
|
@@ -217,9 +217,9 @@
|
|
|
217
217
|
settingsPending = true;
|
|
218
218
|
applications?.render();
|
|
219
219
|
syncAccountControls();
|
|
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")];
|
|
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, #inflight-body-limit, #inflight-body-limit-save, #inflight-body-limit-default, #install-update")];
|
|
221
221
|
controls.forEach(input => { input.disabled = true; });
|
|
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"
|
|
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 === "inflight_body_limit" ? "inflight-body-limit-note" : body.action === "nightly_update" ? "nightly-state" : body.key ? `effect-${body.key}` : body.action === "color_theme" ? "terminal-color-note"
|
|
223
223
|
: body.action.startsWith("history_") ? "effect-history" : body.action === "prediction_fix" ? "prediction-note"
|
|
224
224
|
: body.operation === "switch" ? "source-control-note" : body.operation === "auto-review" ? "review-control-note"
|
|
225
225
|
: body.operation === "account" ? "m365-account-note" : "m365-control-note");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
function create({ element: el, change, localize }) {
|
|
3
|
-
let saved = null, limitDirty = false, imageSignature = "", imageApp = { status: "unknown" }, appInspectionStarted = false;
|
|
3
|
+
let saved = null, limitDirty = false, inflightDirty = false, imageSignature = "", imageApp = { status: "unknown" }, appInspectionStarted = false;
|
|
4
4
|
function renderImageApp() {
|
|
5
5
|
const connected = imageApp.status === "running" && imageApp.host === "connected";
|
|
6
6
|
const restart = imageApp.status === "running" && (imageApp.needs_restart === true || saved?.features?.prediction?.display_pending === true);
|
|
@@ -67,6 +67,22 @@
|
|
|
67
67
|
};
|
|
68
68
|
el("decoded-limit-save").addEventListener("click", () => void saveLimit(Number(el("decoded-limit").value)));
|
|
69
69
|
el("decoded-limit-default").addEventListener("click", () => void saveLimit(null));
|
|
70
|
+
const inflightField = el("inflight-body-limit");
|
|
71
|
+
inflightField.addEventListener("input", () => { inflightDirty = true; });
|
|
72
|
+
const saveInflight = async useDefault => {
|
|
73
|
+
if (inflightField.disabled) return;
|
|
74
|
+
if (!useDefault && !inflightField.checkValidity()) {
|
|
75
|
+
localize(el("inflight-body-limit-note"), "ccdx_inflight_limit_invalid");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const data = await change({ action: "inflight_body_limit", mib: useDefault ? null : inflightField.valueAsNumber }, el(useDefault ? "inflight-body-limit-default" : "inflight-body-limit-save"));
|
|
79
|
+
if (data?.inflight_body) { inflightDirty = false;inflightField.value = data.inflight_body.bytes / 1048576;render(data); }
|
|
80
|
+
};
|
|
81
|
+
el("inflight-body-limit-save").addEventListener("click", () => void saveInflight(false));
|
|
82
|
+
el("inflight-body-limit-default").addEventListener("click", () => void saveInflight(true));
|
|
83
|
+
inflightField.addEventListener("keydown", event => {
|
|
84
|
+
if (event.key === "Enter") { event.preventDefault();void saveInflight(false); }
|
|
85
|
+
});
|
|
70
86
|
el("install-update").addEventListener("click", () => {
|
|
71
87
|
if (window.confirm(globalThis.ccdxLanguage.format("update_install_confirm"))) void change({ action: "update", confirmed: true }, el("install-update"));
|
|
72
88
|
});
|
|
@@ -111,6 +127,10 @@
|
|
|
111
127
|
if (!limitDirty && document.activeElement !== el("decoded-limit")) el("decoded-limit").value = limit?.bytes / 1048576 || 128;
|
|
112
128
|
el("decoded-limit").disabled = el("decoded-limit-save").disabled = el("decoded-limit-default").disabled = !limit || limit.source === "environment";
|
|
113
129
|
localize(el("decoded-limit-note"), limit?.source === "environment" ? "controlled_by_environment" : "next_ccdx_start");
|
|
130
|
+
const inflight = data.inflight_body;
|
|
131
|
+
if (inflight && (!inflightDirty && document.activeElement !== inflightField || inflight.source === "environment")) inflightField.value = inflight.bytes / 1048576;
|
|
132
|
+
inflightField.disabled = el("inflight-body-limit-save").disabled = el("inflight-body-limit-default").disabled = !inflight || inflight.source === "environment";
|
|
133
|
+
localize(el("inflight-body-limit-note"), !inflight ? "feature_unavailable" : inflight.source === "environment" ? "controlled_by_environment" : "inflight_body_limit_next_start");
|
|
114
134
|
el("install-update").disabled = !data.manual_update?.available;
|
|
115
135
|
const update = data.nightly_update;
|
|
116
136
|
if (notes) localize(el("manual-update-note"), !data.manual_update?.available ? "update_external_launch" : update?.manual ? `manual_update_${update.phase}` : "update_idle_switch");
|
package/src/dashboard/gemini.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
const el=id=>document.getElementById(id),language=globalThis.ccdxLanguage;
|
|
3
|
-
let busy=false,state=null,draft=null,notice=null,pendingAction=null;
|
|
3
|
+
let busy=false,state=null,draft=null,defaultDraft,notice=null,pendingAction=null;
|
|
4
4
|
let sharedApplication=null,sharedPending=false;
|
|
5
5
|
const words=(id,key)=>language.set(el(id),key);
|
|
6
6
|
const clear=id=>{el(id).removeAttribute('data-i18n');el(id).removeAttribute('data-i18n-args');el(id).textContent='';el(id).title=''};
|
|
7
|
-
const controls=['gemini-enabled','gemini-open','gemini-refresh','gemini-save','gemini-cancel'];
|
|
7
|
+
const controls=['gemini-enabled','gemini-open','gemini-refresh','gemini-save','gemini-cancel','gemini-use-app-default'];
|
|
8
8
|
const selected=()=>state?.models.filter(model=>model.selected!==false).map(model=>model.id)||[];
|
|
9
|
-
const
|
|
9
|
+
const savedDefault=()=>state?.default_model??null;
|
|
10
|
+
const currentDefault=()=>defaultDraft===undefined?savedDefault():defaultDraft;
|
|
11
|
+
const dirty=()=>currentDefault()!==savedDefault()||draft!==null&&JSON.stringify([...draft].sort())!==JSON.stringify(selected().sort());
|
|
10
12
|
const count=value=>!value?'—':value>=1000000?`${Number((value/1000000).toFixed(2))}M`:value>=1000?`${Number((value/1000).toFixed(1))}K`:String(value);
|
|
11
13
|
const groupedModels=()=>{
|
|
12
14
|
if(Array.isArray(state.model_groups))return state.model_groups;
|
|
@@ -26,6 +28,9 @@
|
|
|
26
28
|
el('gemini-save').disabled=busy||sharedPending||!dirty();el('gemini-cancel').disabled=busy||sharedPending||!dirty();
|
|
27
29
|
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');
|
|
28
30
|
words('gemini-draft-state',dirty()?'cap_unsaved':'cap_saved');
|
|
31
|
+
el('gemini-use-app-default').hidden=currentDefault()===null;
|
|
32
|
+
el('gemini-default-note').hidden=!state.default_model_unavailable||currentDefault()!==savedDefault();
|
|
33
|
+
if(!el('gemini-default-note').hidden)words('gemini-default-note','gemini_default_unavailable');
|
|
29
34
|
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
35
|
el('gemini-version').textContent=state.app.version||'—';
|
|
31
36
|
words('gemini-app-state',state.app.status==='running'?'gemini_running':state.app.status==='stopped'?'gemini_stopped':state.app.status==='starting'?'gemini_starting':'gemini_unavailable');
|
|
@@ -33,21 +38,35 @@
|
|
|
33
38
|
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;
|
|
34
39
|
el('gemini-reopen').hidden=!hint;if(hint)words('gemini-reopen',hint);
|
|
35
40
|
el('gemini-open').disabled=busy||sharedPending||state.app.status!=='stopped';
|
|
36
|
-
const list=el('gemini-models'),
|
|
41
|
+
const list=el('gemini-models'),focused=list.contains(document.activeElement)?document.activeElement:null;
|
|
42
|
+
const focus={value:focused?.value,kind:focused?.tagName};list.replaceChildren();
|
|
37
43
|
for(const model of groupedModels()){
|
|
38
44
|
const chosen=new Set(draft||selected()),ids=model.efforts.map(item=>item.id);
|
|
39
45
|
const row=document.createElement('tr'),name=document.createElement('td'),label=document.createElement('label'),input=document.createElement('input');
|
|
40
|
-
input.type='checkbox';input.value=model.id;input.checked=ids.some(id=>chosen.has(id));input.disabled=busy;input.setAttribute('aria-label',model.name);
|
|
41
|
-
const update=(values,checked)=>{const next=new Set(draft||selected());for(const id of values)if(checked)next.add(id);else next.delete(id);draft=[...next];notice=null;clear('gemini-note');render()};
|
|
46
|
+
input.type='checkbox';input.value=model.id;input.checked=ids.some(id=>chosen.has(id));input.disabled=busy||sharedPending;input.setAttribute('aria-label',model.name);
|
|
47
|
+
const update=(values,checked)=>{const next=new Set(draft||selected());for(const id of values)if(checked)next.add(id);else next.delete(id);draft=[...next];if(!checked&&values.includes(currentDefault()))defaultDraft=null;notice=null;clear('gemini-note');render()};
|
|
42
48
|
input.addEventListener('change',()=>{const saved=ids.filter(id=>selected().includes(id));update(input.checked&&saved.length?saved:ids,input.checked)});
|
|
43
49
|
label.append(input,document.createTextNode(model.name));name.append(label);row.append(name);
|
|
44
50
|
for(const [key,value]of [['source','GitHub Copilot'],['cap_context',count(model.context_window)]]){const cell=document.createElement('td');cell.textContent=value;cell.dataset.label=language.format(key);row.append(cell)}
|
|
45
51
|
const efforts=document.createElement('td');efforts.dataset.label=language.format('cap_reasoning');
|
|
46
52
|
efforts.textContent=model.efforts.map(item=>item.effort||'—').join(' / ');
|
|
47
|
-
|
|
53
|
+
const preferred=document.createElement('td'),button=document.createElement('button');preferred.dataset.label=language.format('cap_default');
|
|
54
|
+
const isDefault=ids.includes(currentDefault())&&chosen.has(currentDefault());
|
|
55
|
+
button.type='button';button.value=model.id;button.disabled=busy||sharedPending;
|
|
56
|
+
const title=isDefault?'cap_default':'cap_set_default';language.set(button,title);
|
|
57
|
+
button.setAttribute('aria-pressed',String(isDefault));button.setAttribute('aria-label',model.name+' · '+language.format(title));
|
|
58
|
+
button.addEventListener('click',()=>{
|
|
59
|
+
if(isDefault)return;
|
|
60
|
+
const saved=ids.filter(id=>selected().includes(id)),visible=model.efforts.filter(item=>chosen.has(item.id));
|
|
61
|
+
const available=visible.length?visible:saved.length?model.efforts.filter(item=>saved.includes(item.id)):model.efforts;
|
|
62
|
+
if(!visible.length){for(const item of available)chosen.add(item.id);draft=[...chosen];}
|
|
63
|
+
defaultDraft=(available.find(item=>item.effort==='medium')||available[0])?.id??null;
|
|
64
|
+
notice=null;clear('gemini-note');render();
|
|
65
|
+
});
|
|
66
|
+
preferred.append(button);row.append(efforts,preferred);list.append(row);
|
|
48
67
|
}
|
|
49
|
-
if(!state.models.length){const row=document.createElement('tr'),cell=document.createElement('td');cell.colSpan=
|
|
50
|
-
if(focus)[...list.querySelectorAll(
|
|
68
|
+
if(!state.models.length){const row=document.createElement('tr'),cell=document.createElement('td');cell.colSpan=5;language.set(cell,'gemini_no_models');row.append(cell);list.append(row)}
|
|
69
|
+
if(focus.kind)[...list.querySelectorAll(focus.kind.toLowerCase())].find(control=>control.value===focus.value)?.focus();
|
|
51
70
|
for(const id of ['active','failed','copilot','total'])el('gemini-'+id).textContent=state.activity?.[id]??'—';
|
|
52
71
|
if(notice)words('gemini-note',notice);
|
|
53
72
|
}
|
|
@@ -57,7 +76,7 @@
|
|
|
57
76
|
try{
|
|
58
77
|
const write=action&&action!=='summary',response=await fetch('/_ccdx/ui/gemini'+(action==='summary'?'?scope=summary':''),{method:write?'POST':'GET',headers:{'X-CCDX-Dashboard':'1',...(write?{'Content-Type':'application/json'}:{})},cache:'no-store',signal:AbortSignal.timeout(20000),...(write?{body:JSON.stringify({action,...(action==='enable'?{accept_background_copilot:true}:{}),...extra})}:{})});
|
|
59
78
|
const value=await response.json();if(!response.ok)throw Error(value.error||'Antigravity setup failed');
|
|
60
|
-
state=value;if(action==='models')draft=null;
|
|
79
|
+
state=value;if(action==='models'){draft=null;defaultDraft=undefined;}
|
|
61
80
|
globalThis.ccdxGeminiStatus=state;
|
|
62
81
|
if(action&&action!=='summary'){
|
|
63
82
|
const status=state.last_operation?.status;notice=action==='models'?null:status==='needs_app_relaunch'?'gemini_reopen':status==='opened'?'gemini_opened':status==='route_conflict'?'gemini_conflict':null;
|
|
@@ -69,8 +88,9 @@
|
|
|
69
88
|
}
|
|
70
89
|
globalThis.ccdxAntigravity={get state(){return state},get pending(){return busy},setEnabled:enabled=>load(enabled?'enable':'disable',{},false)};
|
|
71
90
|
el('gemini-enabled').addEventListener('change',event=>void load(event.target.checked?'enable':'disable'));
|
|
72
|
-
el('gemini-model-form').addEventListener('submit',event=>{event.preventDefault();if(dirty())void load('models',{models:draft})});
|
|
73
|
-
el('gemini-cancel').addEventListener('click',()=>{draft=null;notice=null;clear('gemini-note');render()});
|
|
91
|
+
el('gemini-model-form').addEventListener('submit',event=>{event.preventDefault();if(dirty())void load('models',{models:draft||selected(),...(defaultDraft!==undefined?{default_model:defaultDraft}:{})})});
|
|
92
|
+
el('gemini-cancel').addEventListener('click',()=>{draft=null;defaultDraft=undefined;notice=null;clear('gemini-note');render()});
|
|
93
|
+
el('gemini-use-app-default').addEventListener('click',()=>{defaultDraft=null;render();el('gemini-save').focus();});
|
|
74
94
|
el('gemini-open').addEventListener('click',()=>{if(globalThis.ccdxApplicationControls)globalThis.ccdxApplicationControls.open('antigravity');else void load('open')});
|
|
75
95
|
window.addEventListener('ccdx:application-state',event=>{if(event.detail?.id==='antigravity'){sharedApplication=event.detail.application;sharedPending=event.detail.pending;render()}});
|
|
76
96
|
el('gemini-refresh').addEventListener('click',()=>void load('refresh'));
|
package/src/dashboard/index.html
CHANGED
|
@@ -178,9 +178,10 @@
|
|
|
178
178
|
<section class="panel dashboard-section">
|
|
179
179
|
<div class="panel-heading"><h2 data-i18n="cap_visible_model">Available models</h2><span id="gemini-draft-state" role="status">—</span></div>
|
|
180
180
|
<form id="gemini-model-form">
|
|
181
|
-
<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></tr></thead><tbody id="gemini-models"></tbody></table></div>
|
|
182
|
-
<div class="section-actions"><button id="gemini-save" type="submit" data-i18n="api_save" disabled>Save</button><button id="gemini-cancel" type="button" data-i18n="cap_discard_changes" disabled>Discard changes</button></div>
|
|
181
|
+
<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="gemini-models"></tbody></table></div>
|
|
182
|
+
<div class="section-actions"><button id="gemini-save" type="submit" data-i18n="api_save" disabled>Save</button><button id="gemini-cancel" type="button" data-i18n="cap_discard_changes" disabled>Discard changes</button><button id="gemini-use-app-default" type="button" data-i18n="gemini_use_app_default" hidden>Use app default</button></div>
|
|
183
183
|
</form>
|
|
184
|
+
<p id="gemini-default-note" class="hint" role="status" hidden></p>
|
|
184
185
|
<p id="gemini-note" class="hint" role="status" aria-live="polite"></p>
|
|
185
186
|
</section>
|
|
186
187
|
<details class="panel dashboard-section" open>
|
|
@@ -414,18 +415,18 @@
|
|
|
414
415
|
</div>
|
|
415
416
|
<div data-view="system" hidden>
|
|
416
417
|
<section class="panel dashboard-section" aria-labelledby="web-appearance-title">
|
|
417
|
-
<h2 id="web-appearance-title" data-i18n="appearance_web_appearance"
|
|
418
|
+
<h2 id="web-appearance-title" data-i18n="appearance_web_appearance">Web appearance</h2>
|
|
418
419
|
<div class="appearance-row">
|
|
419
|
-
<div class="appearance-label"><label for="web-color-theme" data-i18n="appearance_color_theme"
|
|
420
|
-
<select id="web-color-theme" class="appearance-select"><option value="green" data-i18n="appearance_classic_green"
|
|
420
|
+
<div class="appearance-label"><label for="web-color-theme" data-i18n="appearance_color_theme">Color theme</label><p id="web-color-note" role="status" data-i18n="theme_saved_browser">This browser only. Applies now.</p></div>
|
|
421
|
+
<select id="web-color-theme" class="appearance-select"><option value="green" data-i18n="appearance_classic_green">Classic green (default)</option><option value="klein" data-i18n="appearance_klein_blue">Klein blue</option><option value="pink" data-i18n="appearance_soft_pink">Soft pink</option><option value="mono" data-i18n="appearance_pure_white">Pure white</option></select>
|
|
421
422
|
</div>
|
|
422
423
|
</section>
|
|
423
424
|
|
|
424
425
|
<section class="panel dashboard-section" id="terminal-appearance" aria-labelledby="terminal-appearance-title">
|
|
425
|
-
<h2 id="terminal-appearance-title" data-i18n="terminal_appearance"
|
|
426
|
+
<h2 id="terminal-appearance-title" data-i18n="terminal_appearance">Terminal appearance</h2>
|
|
426
427
|
<div class="appearance-row">
|
|
427
|
-
<div class="appearance-label"><label for="terminal-color-theme" data-i18n="appearance_color_theme"
|
|
428
|
-
<select id="terminal-color-theme" disabled class="appearance-select"><option value="green" data-i18n="appearance_classic_green"
|
|
428
|
+
<div class="appearance-label"><label for="terminal-color-theme" data-i18n="appearance_color_theme">Color theme</label><p id="terminal-color-note" role="status" data-i18n="appearance_terminal_effect">Table updates now; startup logo next launch.</p></div>
|
|
429
|
+
<select id="terminal-color-theme" disabled class="appearance-select"><option value="green" data-i18n="appearance_classic_green">Classic green (default)</option><option value="klein" data-i18n="appearance_klein_blue">Klein blue</option><option value="pink" data-i18n="appearance_soft_pink">Soft pink</option><option value="mono" data-i18n="appearance_black_white">Black & white</option><option value="orange" data-i18n="appearance_orange">Orange</option></select>
|
|
429
430
|
</div>
|
|
430
431
|
|
|
431
432
|
<div class="setting-row terminal-animation-toggle"><label for="setting-terminal_animation_enabled" data-i18n="terminal_animation">Terminal animation</label><input id="setting-terminal_animation_enabled" type="checkbox" role="switch" disabled><span id="effect-terminal_animation_enabled" class="hint" role="status"></span></div>
|
|
@@ -506,7 +507,7 @@
|
|
|
506
507
|
<div class="section-actions"><button id="privacy-cancel" type="button" hidden data-i18n="cancel">Cancel</button><button id="privacy-retry" type="button" hidden data-i18n="view_retry">Retry</button><button id="privacy-remove" type="button" hidden data-i18n="privacy_remove">Delete model</button><p id="privacy-error" class="hint" role="alert"></p></div>
|
|
507
508
|
</section>
|
|
508
509
|
<dialog id="privacy-dialog" class="preferences-dialog" aria-labelledby="privacy-dialog-title"><h2 id="privacy-dialog-title" data-i18n="privacy_enable">Local masking</h2><p data-i18n="privacy_download">Downloads about 39 MB plus the local component. Checks may add delay or mistake ordinary text.</p><p data-i18n="privacy_fail_closed">If a check cannot finish, the request is not sent.</p><div class="section-actions"><button id="privacy-dialog-cancel" type="button" data-i18n="cancel">Cancel</button><button id="privacy-dialog-confirm" type="button" data-i18n="privacy_confirm">Download & enable</button></div></dialog>
|
|
509
|
-
<details class="panel dashboard-section" id="request-limits"><summary data-i18n="advanced_limits">Advanced: request limits</summary><div class="section-actions"><label><span data-i18n="decoded_limit">Decoded request limit (MiB)</span><input id="decoded-limit" type="number" min="128" max="512" step="1"></label><button id="decoded-limit-save" type="button" data-i18n="api_save">Save</button><button id="decoded-limit-default" type="button" data-i18n="limit_default">Use default</button></div><p id="decoded-limit-note" class="hint" role="status"></p></details>
|
|
510
|
+
<details class="panel dashboard-section" id="request-limits"><summary data-i18n="advanced_limits">Advanced: request limits</summary><div class="section-actions"><label><span data-i18n="decoded_limit">Decoded request limit (MiB)</span><input id="decoded-limit" type="number" min="128" max="512" step="1"></label><button id="decoded-limit-save" type="button" data-i18n="api_save">Save</button><button id="decoded-limit-default" type="button" data-i18n="limit_default">Use default</button></div><p id="decoded-limit-note" class="hint" role="status"></p><div class="section-actions"><label><span data-i18n="inflight_body_limit">Shared request-body limit (MiB)</span> <input id="inflight-body-limit" type="number" min="32" max="128" step="1" required aria-describedby="inflight-body-limit-note" disabled></label><button id="inflight-body-limit-save" type="button" data-i18n="api_save" disabled>Save</button><button id="inflight-body-limit-default" type="button" data-i18n="limit_default" disabled>Use default</button></div><p id="inflight-body-limit-note" class="hint" role="status"></p></details>
|
|
510
511
|
<section class="panel dashboard-section" id="settings-preferences" aria-labelledby="preferences-heading">
|
|
511
512
|
<h2 id="preferences-heading" data-i18n="preferences_heading">SAVE & RESTORE</h2>
|
|
512
513
|
<div class="preferences-row"><div><label for="preferences-auto" data-i18n="preferences_auto">Save changes automatically</label><p class="hint" data-i18n="preferences_auto_hint">Valid changes on this page save automatically.</p></div><input id="preferences-auto" type="checkbox" role="switch" disabled checked></div>
|
|
@@ -120,6 +120,9 @@
|
|
|
120
120
|
compatibility_scope: ["Tests Codex Responses, streaming and compaction. Uses quota.", "测试 Codex Responses、流式响应与压缩,会消耗用量。"],
|
|
121
121
|
advanced_limits: ["Advanced: request limits", "高级:请求限制"],
|
|
122
122
|
decoded_limit: ["Decoded request limit (MiB)", "解码后请求上限(MiB)"],
|
|
123
|
+
inflight_body_limit: ["Shared request-body limit (MiB)", "共享请求体内存额度(MiB)"],
|
|
124
|
+
inflight_body_limit_next_start: ["Multiple requests share this budget. Changes apply next time CCDX starts.", "多条请求的正文共用此额度。下次启动 CCDX 时生效。"],
|
|
125
|
+
ccdx_inflight_limit_invalid: ["Enter a whole number from 32 to 128 MiB.", "请输入 32 至 128 MiB 之间的整数。"],
|
|
123
126
|
prediction_remove_confirm: ["Remove the CCDX prediction trust and route? Quit Codex to finish cleanup.", "移除 CCDX 预测信任与路由?退出 Codex 后才能完成清理。"],
|
|
124
127
|
update_install_confirm: ["Install the latest stable release and switch CCDX when idle? Active work postpones the switch.", "安装最新稳定版并在空闲时切换 CCDX?有执行中的工作时会推迟切换。"],
|
|
125
128
|
feature_unavailable: ["Restart the updated CCDX to use these controls.", "重启更新后的 CCDX 以使用这些控制。"],
|
|
@@ -403,6 +406,8 @@
|
|
|
403
406
|
"ccdx_client_effort_unavailable": ["The saved reasoning level is unavailable. Choose a declared level or follow the app.", "已保存的推理档位不可用,请选择支持的档位或跟随应用。"],
|
|
404
407
|
"cap_search": ["Search", "联网搜索"],
|
|
405
408
|
"cap_default": ["Default", "默认"],
|
|
409
|
+
"gemini_use_app_default": ["Use app default", "恢复应用默认"],
|
|
410
|
+
"gemini_default_unavailable": ["Saved default cannot be used with the current catalog.", "当前目录无法使用已保存的默认模型。"],
|
|
406
411
|
"cap_set_default": ["Set default", "设为默认"],
|
|
407
412
|
"cap_details": ["Details", "能力详情"],
|
|
408
413
|
"cap_app_access": ["App access", "应用接入"],
|
|
@@ -1014,11 +1019,18 @@
|
|
|
1014
1019
|
"requested_model": ["Requested model", "指定模型"],
|
|
1015
1020
|
"request_kind": ["Request purpose", "请求用途"],
|
|
1016
1021
|
"attempt_timings": ["Send attempts", "发送次数"],
|
|
1017
|
-
"body_queue_wait": ["Local queue", "
|
|
1022
|
+
"body_queue_wait": ["Local queue history", "本机排队记录"],
|
|
1018
1023
|
"source_queue_wait": ["Source queue", "来源排队"],
|
|
1019
|
-
"body_queue_detail": ["{ms} ms · {
|
|
1020
|
-
"
|
|
1021
|
-
"
|
|
1024
|
+
"body_queue_detail": ["Waited {ms} ms · {result}. At entry: {reason}. Reservation {reserved}; in use {occupied}/{limit}.", "等待 {ms} ms · {result}。入队原因:{reason}。预留 {reserved};入队时占用 {occupied}/{limit}。"],
|
|
1025
|
+
"body_queue_admitted": ["Admitted", "已放行"],
|
|
1026
|
+
"body_queue_timed_out": ["Queue timed out", "排队超时"],
|
|
1027
|
+
"body_queue_aborted": ["Wait cancelled", "等待已取消"],
|
|
1028
|
+
"body_queue_result_unknown": ["Result not recorded", "未记录排队结果"],
|
|
1029
|
+
"body_queue_exclusive": ["An earlier request needed exclusive access", "前方请求需独占额度"],
|
|
1030
|
+
"body_queue_upload_in_progress": ["Another unknown-length upload was still being read", "前一条未知长度的上传还没读完"],
|
|
1031
|
+
"body_queue_upload_growth": ["An upload already in progress was waiting for more memory", "正在读入的上传需要更多内存额度"],
|
|
1032
|
+
"body_queue_unknown_length": ["Unknown body length required a full reservation", "请求长度未知,需预留全部额度"],
|
|
1033
|
+
"body_queue_budget": ["Remaining budget could not cover the reservation", "剩余额度不足以预留本请求"],
|
|
1022
1034
|
"gateway_timing_output_speed_is_estimated": ["Estimated by CCDX. Not internal model time or total throughput.", "由 CCDX 估算。\n不代表模型内部耗时或总吞吐。"],
|
|
1023
1035
|
"value_samples_samples": ["{value} / {samples} samples", "{value} / {samples}次样本"],
|
|
1024
1036
|
"ccdx_local_dashboard": ["CCDX · Dashboard", "CCDX · 运行面板"],
|
package/src/dashboard/status.js
CHANGED
|
@@ -400,11 +400,17 @@
|
|
|
400
400
|
details.className = "request-details";fields.className = "failure-detail";
|
|
401
401
|
if (Number.isSafeInteger(context.privacy_count)) globalThis.ccdxLanguage.set(summary, "privacy_result", { count: context.privacy_count, ms: context.privacy_ms || 0 });
|
|
402
402
|
else localize(summary, "request_metadata");details.append(summary, fields);
|
|
403
|
+
const queue = context.body_queue;
|
|
404
|
+
const queueResult = queue?.outcome === "admitted" ? "body_queue_admitted" : queue?.outcome === "timed_out" ? "body_queue_timed_out"
|
|
405
|
+
: queue?.outcome === "aborted" ? "body_queue_aborted" : "body_queue_result_unknown";
|
|
406
|
+
const queueReason = queue?.reason === "upload_in_progress" ? "body_queue_upload_in_progress" : queue?.reason === "upload_growth" ? "body_queue_upload_growth"
|
|
407
|
+
: queue?.reason === "exclusive_waiter" ? "body_queue_exclusive"
|
|
408
|
+
: queue?.length_known === false && queue.requested_bytes === queue.limit_bytes ? "body_queue_unknown_length" : "body_queue_budget";
|
|
403
409
|
for (const [key, value] of [["request_id", request.request_id || "—"], ["http_status", number(request.http_status)], ["attempts", number(request.upstream_attempts)], ["model_outcome", globalThis.ccdxLanguage?.format(outcome.toLowerCase()) || outcome],
|
|
404
410
|
["time", Number.isFinite(at) ? time(at, { date: true }) : "—"],
|
|
405
|
-
...(Number.isSafeInteger(
|
|
406
|
-
ms: number(
|
|
407
|
-
reserved: mib(
|
|
411
|
+
...(Number.isSafeInteger(queue?.wait_ms) ? [["body_queue_wait", phrase("body_queue_detail", {
|
|
412
|
+
ms: number(queue.wait_ms), result: phrase(queueResult), reason: phrase(queueReason),
|
|
413
|
+
reserved: mib(queue.requested_bytes), occupied: mib(queue.active_bytes), limit: mib(queue.limit_bytes),
|
|
408
414
|
})]] : []),
|
|
409
415
|
...(Number.isSafeInteger(context.source_queue_ms) ? [["source_queue_wait", `${number(context.source_queue_ms)} ms`]] : []),
|
|
410
416
|
["wire_mib", finite(context.payload_bytes) ? `${(Number(context.payload_bytes) / 1048576).toFixed(2)} MiB` : "—"],
|
package/src/dashboard/ui.css
CHANGED
|
@@ -38,7 +38,7 @@ button[aria-busy="true"] { cursor: progress; }
|
|
|
38
38
|
h1 { margin: 0; font-size: clamp(20px, 3vw, 27px); font-weight: 650; letter-spacing: -.035em; }
|
|
39
39
|
.status-icon { display: block; grid-row: 1 / 3; width: 44px; height: 44px; color: var(--accent); }
|
|
40
40
|
.intro p { margin: 0; color: var(--subtle); font-size: 11px; }
|
|
41
|
-
.intro.has-application-launch { align-items:center; flex-wrap:wrap; }
|
|
41
|
+
.intro.has-application-launch { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; }
|
|
42
42
|
.intro.has-application-launch #page-settings-note { order:3; flex-basis:100%; }
|
|
43
43
|
.intro.has-application-launch #page-settings-note:empty { display:none; }
|
|
44
44
|
#application-launch { display:flex; flex-direction:column; align-items:flex-end; gap:5px; margin-left:auto; }
|
|
@@ -305,6 +305,7 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
|
|
|
305
305
|
.analytics-controls select { box-sizing: border-box; height:var(--control-height); min-height:var(--control-height); line-height:normal; }
|
|
306
306
|
.section-actions button, .section-actions .button-link { padding-top: 0; padding-bottom: 0; }
|
|
307
307
|
@media (max-width: 640px) {
|
|
308
|
+
.sidebar nav .nav-child { padding-left: 10px; }
|
|
308
309
|
.topbar { height:auto; min-height:96px; padding:8px 0; }
|
|
309
310
|
.topbar-actions { display:flex; flex-wrap:wrap; justify-content:flex-start; gap:8px; }
|
|
310
311
|
.topbar-actions #connection { flex-basis:100%; }
|
package/src/http-transport.mjs
CHANGED
|
@@ -37,7 +37,7 @@ function payloadTooLarge(kind, maxBytes) {
|
|
|
37
37
|
|
|
38
38
|
function consumeRequestChunks(req, { signal, onChunk }) {
|
|
39
39
|
return new Promise((resolve, reject) => {
|
|
40
|
-
let settled = false;
|
|
40
|
+
let settled = false, waiting = false, ended = false;
|
|
41
41
|
const cleanup = () => {
|
|
42
42
|
req.off("data", handleData);
|
|
43
43
|
req.off("end", handleEnd);
|
|
@@ -58,12 +58,21 @@ function consumeRequestChunks(req, { signal, onChunk }) {
|
|
|
58
58
|
};
|
|
59
59
|
const handleData = (chunk) => {
|
|
60
60
|
try {
|
|
61
|
-
onChunk(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
61
|
+
const pending = onChunk(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
62
|
+
if (pending) {
|
|
63
|
+
waiting = true;
|
|
64
|
+
req.pause();
|
|
65
|
+
pending.then(() => {
|
|
66
|
+
waiting = false;
|
|
67
|
+
if (settled) return;
|
|
68
|
+
if (ended) finish();else req.resume();
|
|
69
|
+
}, stopReading);
|
|
70
|
+
}
|
|
62
71
|
} catch (error) {
|
|
63
72
|
stopReading(error);
|
|
64
73
|
}
|
|
65
74
|
};
|
|
66
|
-
const handleEnd = () => finish();
|
|
75
|
+
const handleEnd = () => { ended = true;if (!waiting) finish(); };
|
|
67
76
|
const handleError = (error) => finish(error);
|
|
68
77
|
const handleAborted = () => finish(admissionAbortError(signal));
|
|
69
78
|
const handleSignalAbort = () => stopReading(admissionAbortError(signal));
|
|
@@ -80,7 +89,7 @@ function consumeRequestChunks(req, { signal, onChunk }) {
|
|
|
80
89
|
});
|
|
81
90
|
}
|
|
82
91
|
|
|
83
|
-
async function readRequestBuffer(req, maxBytes, signal) {
|
|
92
|
+
async function readRequestBuffer(req, maxBytes, signal, growUpload) {
|
|
84
93
|
const contentLength = requestContentLength(req);
|
|
85
94
|
if (Number.isFinite(contentLength) && contentLength > maxBytes) {
|
|
86
95
|
throw payloadTooLarge("Raw", maxBytes);
|
|
@@ -93,13 +102,15 @@ async function readRequestBuffer(req, maxBytes, signal) {
|
|
|
93
102
|
onChunk(buffer) {
|
|
94
103
|
total += buffer.length;
|
|
95
104
|
if (total > maxBytes) throw payloadTooLarge("Raw", maxBytes);
|
|
105
|
+
const pending = growUpload?.(total, signal);
|
|
106
|
+
if (pending) return pending.then(() => { if (!signal?.aborted) chunks.push(buffer); });
|
|
96
107
|
chunks.push(buffer);
|
|
97
108
|
},
|
|
98
109
|
});
|
|
99
110
|
return Buffer.concat(chunks);
|
|
100
111
|
}
|
|
101
112
|
|
|
102
|
-
async function readIdentityText(req, maxBodyBytes, maxDecodedBodyBytes, signal,
|
|
113
|
+
async function readIdentityText(req, maxBodyBytes, maxDecodedBodyBytes, signal, admission) {
|
|
103
114
|
const contentLength = requestContentLength(req);
|
|
104
115
|
if (Number.isFinite(contentLength) && contentLength > maxBodyBytes) {
|
|
105
116
|
throw payloadTooLarge("Raw", maxBodyBytes);
|
|
@@ -125,6 +136,8 @@ async function readIdentityText(req, maxBodyBytes, maxDecodedBodyBytes, signal,
|
|
|
125
136
|
total += buffer.length;
|
|
126
137
|
if (total > maxBodyBytes) throw payloadTooLarge("Raw", maxBodyBytes);
|
|
127
138
|
if (total > maxDecodedBodyBytes) throw payloadTooLarge("Decoded", maxDecodedBodyBytes);
|
|
139
|
+
const pending = admission?.growUpload?.(total, signal);
|
|
140
|
+
if (pending) return pending.then(() => { if (!signal?.aborted) text += decoder.decode(buffer, { stream: true }); });
|
|
128
141
|
if (preallocatedLength) {
|
|
129
142
|
allocated ||= Buffer.allocUnsafe(preallocatedLength);
|
|
130
143
|
if (!overflow && total <= allocated.length) {
|
|
@@ -138,7 +151,7 @@ async function readIdentityText(req, maxBodyBytes, maxDecodedBodyBytes, signal,
|
|
|
138
151
|
}
|
|
139
152
|
},
|
|
140
153
|
});
|
|
141
|
-
|
|
154
|
+
admission?.resize?.(total);
|
|
142
155
|
if (preallocatedLength) {
|
|
143
156
|
if (!allocated) return "";
|
|
144
157
|
return new TextDecoder().decode(overflow ? Buffer.concat(overflow, total) : allocated.subarray(0, total));
|
|
@@ -199,9 +212,9 @@ export async function readJsonBody(req, {
|
|
|
199
212
|
if (signal?.aborted) throw admissionAbortError(signal);
|
|
200
213
|
const encoding = req.headers?.["content-encoding"];
|
|
201
214
|
if (!encoding || encoding === "identity" || contentEncodings(encoding).every(value => value === "identity")) {
|
|
202
|
-
return parse(await readIdentityText(req, maxBodyBytes, maxDecodedBodyBytes, signal,
|
|
215
|
+
return parse(await readIdentityText(req, maxBodyBytes, maxDecodedBodyBytes, signal, admission));
|
|
203
216
|
}
|
|
204
|
-
const buffer = await readRequestBuffer(req, maxBodyBytes, signal);
|
|
217
|
+
const buffer = await readRequestBuffer(req, maxBodyBytes, signal, admission?.growUpload);
|
|
205
218
|
admission?.resize?.(buffer.length);
|
|
206
219
|
let releaseDecompression = () => {};
|
|
207
220
|
let decodedReservation;
|
package/src/native-images.mjs
CHANGED
|
@@ -74,7 +74,7 @@ export function createNativeImagesHandler({ client, acquireRequest, privacy, env
|
|
|
74
74
|
if (processing >= 2) { metrics.busy++;throw httpError("Two image requests are already active", 503); }
|
|
75
75
|
active++;processing++;admitted = true;processingSlot = true;
|
|
76
76
|
abort.setTimeout(requestBodyTimeoutMs, "request_body_timeout");
|
|
77
|
-
release = await acquireRequest(req, { signal: abort.signal });
|
|
77
|
+
release = await acquireRequest(req, { signal: abort.signal, streamingBody: true });
|
|
78
78
|
const parsed = await readJsonBody(req, { admission: release, signal: abort.signal, maxBodyBytes: BODY_MAX_BYTES, maxDecodedBodyBytes: BODY_MAX_BYTES });
|
|
79
79
|
const available = models();
|
|
80
80
|
const image = parsed?.model === "gpt-image-2" ? imageModelSelection(available, selection()).selected_model : parsed?.model;
|
|
@@ -21,8 +21,7 @@ export function requestContentLength(req) {
|
|
|
21
21
|
return Number.parseInt(req.headers?.["content-length"] || "", 10);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function requestAdmissionWeight(req, maxBytes) {
|
|
25
|
-
const contentLength = requestContentLength(req);
|
|
24
|
+
function requestAdmissionWeight(req, maxBytes, contentLength) {
|
|
26
25
|
if (!Number.isFinite(contentLength) || contentLength < 0) return maxBytes;
|
|
27
26
|
const encoding = req.headers?.["content-encoding"];
|
|
28
27
|
const compressed = encoding && encoding !== "identity" && contentEncodings(encoding).some(value => value !== "identity");
|
|
@@ -154,10 +153,12 @@ function createSupplementalAdmission({ maxWeight, maxQueued, waitTimeoutMs, labe
|
|
|
154
153
|
|
|
155
154
|
export function createRequestAdmission({
|
|
156
155
|
maxBytes = MAX_INFLIGHT_BODY_BYTES,
|
|
156
|
+
maxSupplementalBytes = maxBytes,
|
|
157
157
|
maxQueued = MAX_QUEUED_REQUESTS,
|
|
158
158
|
waitTimeoutMs = REQUEST_QUEUE_TIMEOUT_MS,
|
|
159
159
|
} = {}) {
|
|
160
160
|
const byteLimit = parsePositiveInteger(maxBytes, MAX_INFLIGHT_BODY_BYTES);
|
|
161
|
+
const supplementalByteLimit = parsePositiveInteger(maxSupplementalBytes, byteLimit);
|
|
161
162
|
const queueLimit = parsePositiveInteger(maxQueued, MAX_QUEUED_REQUESTS);
|
|
162
163
|
const timeoutMs = parsePositiveInteger(waitTimeoutMs, REQUEST_QUEUE_TIMEOUT_MS);
|
|
163
164
|
const acquireDecompression = createSupplementalAdmission({
|
|
@@ -167,14 +168,14 @@ export function createRequestAdmission({
|
|
|
167
168
|
label: "Request decompression",
|
|
168
169
|
});
|
|
169
170
|
const acquireDecodedBody = createSupplementalAdmission({
|
|
170
|
-
maxWeight:
|
|
171
|
+
maxWeight: supplementalByteLimit,
|
|
171
172
|
maxQueued: queueLimit,
|
|
172
173
|
waitTimeoutMs: timeoutMs,
|
|
173
174
|
label: "Decoded request body",
|
|
174
175
|
blockBehindExclusive: true,
|
|
175
176
|
});
|
|
176
177
|
const acquireResponseHistory = createSupplementalAdmission({
|
|
177
|
-
maxWeight:
|
|
178
|
+
maxWeight: supplementalByteLimit,
|
|
178
179
|
maxQueued: queueLimit,
|
|
179
180
|
waitTimeoutMs: timeoutMs,
|
|
180
181
|
label: "Response history",
|
|
@@ -182,6 +183,10 @@ export function createRequestAdmission({
|
|
|
182
183
|
const queue = [];
|
|
183
184
|
let activeBytes = 0;
|
|
184
185
|
let activeRequests = 0;
|
|
186
|
+
// Only one upload per pool can retain partial data and later ask for more.
|
|
187
|
+
// A blocked growth request goes before new admissions so it can make progress.
|
|
188
|
+
let progressiveReader = false;
|
|
189
|
+
let growth = null;
|
|
185
190
|
const recentWaits = [];
|
|
186
191
|
let longestWait = null;
|
|
187
192
|
function recordWait(entry, outcome, waitMs) {
|
|
@@ -207,8 +212,10 @@ export function createRequestAdmission({
|
|
|
207
212
|
if (index >= 0) queue.splice(index, 1);
|
|
208
213
|
};
|
|
209
214
|
|
|
210
|
-
const activate = (weight) => {
|
|
215
|
+
const activate = (weight, progressive) => {
|
|
211
216
|
activeBytes += weight;
|
|
217
|
+
if (progressive) progressiveReader = true;
|
|
218
|
+
let reading = progressive;
|
|
212
219
|
activeRequests += 1;
|
|
213
220
|
counters.activated += 1;
|
|
214
221
|
let released = false;
|
|
@@ -216,6 +223,10 @@ export function createRequestAdmission({
|
|
|
216
223
|
const release = () => {
|
|
217
224
|
if (released) return;
|
|
218
225
|
released = true;
|
|
226
|
+
if (reading) {
|
|
227
|
+
growth?.cancel();
|
|
228
|
+
reading = progressiveReader = false;
|
|
229
|
+
}
|
|
219
230
|
if (supplementalReleases) {
|
|
220
231
|
for (const releaseSupplemental of supplementalReleases) releaseSupplemental();
|
|
221
232
|
supplementalReleases.clear();
|
|
@@ -227,9 +238,25 @@ export function createRequestAdmission({
|
|
|
227
238
|
release.resize = bytes => {
|
|
228
239
|
if (released || !Number.isSafeInteger(bytes) || bytes < 0) return;
|
|
229
240
|
const next = Math.max(1, Math.min(weight, bytes));
|
|
230
|
-
if (next === weight) return;
|
|
241
|
+
if (!reading && next === weight) return;
|
|
242
|
+
if (reading) reading = progressiveReader = false;
|
|
231
243
|
activeBytes -= weight - next;weight = next;drain();
|
|
232
244
|
};
|
|
245
|
+
if (progressive) release.growUpload = (bytes, signal) => {
|
|
246
|
+
if (!reading || signal?.aborted) throw admissionAbortError(signal);
|
|
247
|
+
// Preserve the existing exclusive handling for bodies larger than the pool.
|
|
248
|
+
// The independent per-request raw and decoded limits still apply.
|
|
249
|
+
const next = Math.min(byteLimit, bytes), extra = next - weight;
|
|
250
|
+
if (extra <= 0) return;
|
|
251
|
+
if (activeBytes + extra <= byteLimit) { weight = next;activeBytes += extra;return; }
|
|
252
|
+
return new Promise((resolve, reject) => {
|
|
253
|
+
const clear = () => { growth = null;signal?.removeEventListener("abort", cancel); };
|
|
254
|
+
const cancel = () => { clear();reject(admissionAbortError(signal)); };
|
|
255
|
+
growth = { extra, cancel, grant() { clear();weight = next;activeBytes += extra;resolve(); } };
|
|
256
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
257
|
+
if (signal?.aborted) cancel();
|
|
258
|
+
});
|
|
259
|
+
};
|
|
233
260
|
const reserve = async (gate, weight, options) => {
|
|
234
261
|
const releaseSupplemental = await gate(weight, options);
|
|
235
262
|
if (released) {
|
|
@@ -265,16 +292,19 @@ export function createRequestAdmission({
|
|
|
265
292
|
};
|
|
266
293
|
|
|
267
294
|
const drain = () => {
|
|
295
|
+
if (growth) {
|
|
296
|
+
if (activeBytes + growth.extra > byteLimit) return;
|
|
297
|
+
growth.grant();
|
|
298
|
+
}
|
|
268
299
|
for (let index = 0; index < queue.length;) {
|
|
269
300
|
const entry = queue[index];
|
|
270
301
|
if (entry.cancelled) {
|
|
271
302
|
queue.splice(index, 1);
|
|
272
303
|
continue;
|
|
273
304
|
}
|
|
274
|
-
if (activeBytes + entry.weight > byteLimit) {
|
|
275
|
-
//
|
|
276
|
-
|
|
277
|
-
if (entry.weight === byteLimit) break;
|
|
305
|
+
if (activeBytes + entry.weight > byteLimit || entry.progressive && progressiveReader) {
|
|
306
|
+
// Preserve queue ordering for requests that need exclusive access.
|
|
307
|
+
if (!entry.progressive && entry.weight === byteLimit) break;
|
|
278
308
|
index += 1;
|
|
279
309
|
continue;
|
|
280
310
|
}
|
|
@@ -284,20 +314,23 @@ export function createRequestAdmission({
|
|
|
284
314
|
counters.waitMsTotal += waitMs;
|
|
285
315
|
counters.waitMsMax = Math.max(counters.waitMsMax, waitMs);
|
|
286
316
|
recordWait(entry, "admitted", waitMs);
|
|
287
|
-
entry.resolve(activate(entry.weight));
|
|
317
|
+
entry.resolve(activate(entry.weight, entry.progressive));
|
|
288
318
|
}
|
|
289
319
|
};
|
|
290
320
|
|
|
291
|
-
const acquire = (req, { signal } = {}) => {
|
|
321
|
+
const acquire = (req, { signal, streamingBody = false } = {}) => {
|
|
292
322
|
counters.total += 1;
|
|
293
323
|
if (signal?.aborted) {
|
|
294
324
|
counters.aborted += 1;
|
|
295
325
|
return Promise.reject(admissionAbortError(signal));
|
|
296
326
|
}
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
|
|
327
|
+
const length = requestContentLength(req), lengthKnown = Number.isFinite(length) && length >= 0;
|
|
328
|
+
const progressive = streamingBody && !lengthKnown;
|
|
329
|
+
const weight = progressive ? 1 : requestAdmissionWeight(req, byteLimit, length);
|
|
330
|
+
const available = !growth && activeBytes + weight <= byteLimit && (!progressive || !progressiveReader);
|
|
331
|
+
if (queue.length === 0 && available) return Promise.resolve(activate(weight, progressive));
|
|
332
|
+
const blockedByExclusive = queue.some(entry => !entry.cancelled && !entry.progressive && entry.weight === byteLimit);
|
|
333
|
+
if (!blockedByExclusive && available) return Promise.resolve(activate(weight, progressive));
|
|
301
334
|
if (queue.length >= queueLimit) {
|
|
302
335
|
counters.rejected += 1;
|
|
303
336
|
return Promise.reject(httpError(`Request queue is full (${queueLimit} waiting)`, 503));
|
|
@@ -305,14 +338,13 @@ export function createRequestAdmission({
|
|
|
305
338
|
counters.queued += 1;
|
|
306
339
|
const start = Date.now(), context = currentRequestContext();
|
|
307
340
|
const id = context?.requestId;
|
|
308
|
-
const length = requestContentLength(req);
|
|
309
341
|
const evidence = {
|
|
310
342
|
...(typeof id === "string" && /^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(id) ? { request_id: id } : {}),
|
|
311
343
|
route: ADMISSION_ROUTES.has(context?.route) ? context.route : "other",
|
|
312
344
|
queued_at: new Date(start).toISOString(),
|
|
313
|
-
reason: blockedByExclusive ? "exclusive_waiter" : "body_budget",
|
|
345
|
+
reason: growth ? "upload_growth" : blockedByExclusive ? "exclusive_waiter" : progressive && progressiveReader ? "upload_in_progress" : "body_budget",
|
|
314
346
|
requested_bytes: weight, active_bytes: activeBytes, limit_bytes: byteLimit,
|
|
315
|
-
length_known:
|
|
347
|
+
length_known: lengthKnown,
|
|
316
348
|
};
|
|
317
349
|
return new Promise((resolve, reject) => {
|
|
318
350
|
let timer;
|
|
@@ -322,6 +354,7 @@ export function createRequestAdmission({
|
|
|
322
354
|
evidence,
|
|
323
355
|
tracker: context?.streamPerformance,
|
|
324
356
|
weight,
|
|
357
|
+
progressive,
|
|
325
358
|
resolve,
|
|
326
359
|
cleanup: () => {
|
|
327
360
|
if (timer) clearTimeout(timer);
|
|
@@ -369,6 +402,7 @@ export function createRequestAdmission({
|
|
|
369
402
|
? Number((counters.waitMsTotal / counters.activated).toFixed(1))
|
|
370
403
|
: 0,
|
|
371
404
|
waitMsMax: counters.waitMsMax,
|
|
405
|
+
uploadWaitingForMemory: Boolean(growth),
|
|
372
406
|
longestWait: longestWait ? { ...longestWait } : null,
|
|
373
407
|
recentWaits: recentWaits.map(row => ({ ...row })),
|
|
374
408
|
decompressionsActive: acquireDecompression.stats().activeRequests,
|
|
@@ -259,7 +259,7 @@ export function createResponsesHandler(options) {
|
|
|
259
259
|
releaseRequest();
|
|
260
260
|
};
|
|
261
261
|
try {
|
|
262
|
-
releaseRequest = await measureRequestStageAsync("admission", () => acquireRequest(req, { signal: abort.signal }));
|
|
262
|
+
releaseRequest = await measureRequestStageAsync("admission", () => acquireRequest(req, { signal: abort.signal, streamingBody: true }));
|
|
263
263
|
abort.setTimeout(requestBodyTimeoutMs, "request_body_timeout");
|
|
264
264
|
parsed = await measureRequestStageAsync("body", () => readJsonBody(req, { admission: releaseRequest, signal: abort.signal }));
|
|
265
265
|
observeRequestedModel(parsed);
|
|
@@ -597,7 +597,7 @@ export function createResponsesCompactHandler(options) {
|
|
|
597
597
|
releaseRequest();
|
|
598
598
|
};
|
|
599
599
|
try {
|
|
600
|
-
releaseRequest = await measureRequestStageAsync("admission", () => acquireRequest(req, { signal: abort.signal }));
|
|
600
|
+
releaseRequest = await measureRequestStageAsync("admission", () => acquireRequest(req, { signal: abort.signal, streamingBody: true }));
|
|
601
601
|
abort.setTimeout(requestBodyTimeoutMs, "request_body_timeout");
|
|
602
602
|
const parsed = await measureRequestStageAsync("body", () => readJsonBody(req, { admission: releaseRequest, signal: abort.signal }));
|
|
603
603
|
const context = currentRequestContext();if (context) { context.purpose = requestPurpose(req.headers["x-ccdx-purpose"], "compaction");context.streamPerformance?.setPurpose(context.purpose); }
|
package/src/service-control.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { controlImage } from "./image-control.mjs";
|
|
|
3
3
|
import { controlCodexLaunch } from "./codex-launch-control.mjs";
|
|
4
4
|
import { serviceSettingsSnapshot, servicePreferences, writeServicePreference,
|
|
5
5
|
writeTerminalAnimationTheme, writeTerminalColorTheme, responseHistoryLimitPreference, writeResponseHistoryLimitMib,
|
|
6
|
-
nightlyUpdatePreference, writeNightlyUpdatePreference, decodedBodyLimitPreference, writeDecodedBodyLimitMib } from "./user-settings.mjs";
|
|
6
|
+
nightlyUpdatePreference, writeNightlyUpdatePreference, decodedBodyLimitPreference, writeDecodedBodyLimitMib, inflightBodyLimitPreference, writeInflightBodyLimitMib, INFLIGHT_BODY_LIMIT_MIN_MIB, INFLIGHT_BODY_LIMIT_MAX_MIB } from "./user-settings.mjs";
|
|
7
7
|
import { readPredictionSettings } from "./native-prediction-profile.mjs";
|
|
8
8
|
import { cacheRuntimeSnapshot, cleanRuntimeCaches, setHistoryCacheLimit } from "./cache-control.mjs";
|
|
9
9
|
import { isTerminalAnimationTheme } from "./terminal-animation.mjs";
|
|
@@ -46,7 +46,7 @@ export function createServiceControl({ env = process.env, home, platform = proce
|
|
|
46
46
|
return { source: "service_settings", saved, theme, color_theme, preferences: settingsPreferencesSnapshot(options), local_privacy: localPrivacy,
|
|
47
47
|
applications: applicationControl.snapshot(),
|
|
48
48
|
features: { prediction: { ...featureSnapshot(predictionControlSnapshot), bridge: prediction?.bridge || "stopped", active: prediction?.active === true }, image: { ...image, runtime: imageHostState.snapshot() } },
|
|
49
|
-
decoded_body: decodedBodyLimitPreference(options), manual_update: { available: typeof manualUpdate === "function" }, last_operation: lastOperation,
|
|
49
|
+
decoded_body: decodedBodyLimitPreference(options), inflight_body: inflightBodyLimitPreference(options), manual_update: { available: typeof manualUpdate === "function" }, last_operation: lastOperation,
|
|
50
50
|
...(providerRuntime?.errorCaptureSnapshot ? { error_capture: providerRuntime.errorCaptureSnapshot() } : {}),
|
|
51
51
|
...(providerRuntime?.compaction ? { compaction: providerRuntime.compaction.snapshot() } : {}),
|
|
52
52
|
nightly_update: { enabled, ...nightly, effect: enabled && !nightly ? "next_start" : "immediate" },
|
|
@@ -70,7 +70,7 @@ export function createServiceControl({ env = process.env, home, platform = proce
|
|
|
70
70
|
prediction: ["action", "operation"], image: ["action", "operation", "model", "evidence", "confirmed"],
|
|
71
71
|
codex_app: ["action", "operation", "intent", "confirmed"],
|
|
72
72
|
application: ["action", "id", "operation", "confirmed", "fresh", "expected_pid", "expected_started"],
|
|
73
|
-
update: ["action", "confirmed"], decoded_limit: ["action", "mib"],
|
|
73
|
+
update: ["action", "confirmed"], decoded_limit: ["action", "mib"], inflight_body_limit: ["action", "mib"],
|
|
74
74
|
error_capture: ["action", "operation", "source", "model"],
|
|
75
75
|
preferences: ["action", "values", "revision"], reset_preferences: ["action", "revision", "backup_id", "scope"], restore_preferences: ["action", "revision", "backup_id", "scope"],
|
|
76
76
|
provider: ["action", "operation", "provider", "model", "auto_review_model", "auto_review_effort", "account_id"] }[input.action];
|
|
@@ -99,6 +99,12 @@ export function createServiceControl({ env = process.env, home, platform = proce
|
|
|
99
99
|
} else if (input.action === "decoded_limit") {
|
|
100
100
|
if (decodedBodyLimitPreference(options).source === "environment") throw new Error("Request limit is controlled by the launch environment");
|
|
101
101
|
writeDecodedBodyLimitMib(input.mib, options);
|
|
102
|
+
} else if (input.action === "inflight_body_limit") {
|
|
103
|
+
if (inflightBodyLimitPreference(options).source === "environment") throw Object.assign(new Error("Request limit is controlled by the launch environment"), { code: "ccdx_inflight_limit_environment", statusCode: 409 });
|
|
104
|
+
if (input.mib !== null && (!Number.isSafeInteger(input.mib) || input.mib < INFLIGHT_BODY_LIMIT_MIN_MIB || input.mib > INFLIGHT_BODY_LIMIT_MAX_MIB)) {
|
|
105
|
+
throw Object.assign(new Error(`Shared request-body limit must be an integer from ${INFLIGHT_BODY_LIMIT_MIN_MIB} to ${INFLIGHT_BODY_LIMIT_MAX_MIB} MiB`), { code: "ccdx_inflight_limit_invalid", statusCode: 400 });
|
|
106
|
+
}
|
|
107
|
+
writeInflightBodyLimitMib(input.mib, options);
|
|
102
108
|
} else if (["preferences", "reset_preferences", "restore_preferences"].includes(input.action)) {
|
|
103
109
|
if (input.action === "preferences" && Object.hasOwn(input.values || {}, "privacy_enabled")
|
|
104
110
|
&& input.values.privacy_enabled !== settingsPreferencesSnapshot(options).values.privacy_enabled) {
|
package/src/user-settings.mjs
CHANGED
|
@@ -23,6 +23,9 @@ const AUTO_REVIEW_REASONING_KEY = "auto_review_reasoning";
|
|
|
23
23
|
const TERMINAL_ANIMATION_KEY = "terminal_animation";
|
|
24
24
|
const RESPONSE_HISTORY_MAX_MIB_KEY = "response_history_max_mib";
|
|
25
25
|
const DECODED_BODY_LIMIT_MIB_KEY = "decoded_body_limit_mib";
|
|
26
|
+
const INFLIGHT_BODY_LIMIT_MIB_KEY = "inflight_body_limit_mib";
|
|
27
|
+
export const INFLIGHT_BODY_LIMIT_MIN_MIB = RUNTIME_DEFAULTS.maxInflightBodyBytes / MIB;
|
|
28
|
+
export const INFLIGHT_BODY_LIMIT_MAX_MIB = 128;
|
|
26
29
|
const SERVICE_FLAGS = ["terminal_animation_enabled", "open_webui", "image_enabled", "prediction_enabled", "context_compaction_enabled", "codex_auto_launch"];
|
|
27
30
|
export const DECODED_BODY_LIMIT_MIN_MIB = RUNTIME_DEFAULTS.maxDecodedBodyBytes / MIB;
|
|
28
31
|
export const DECODED_BODY_LIMIT_MAX_MIB = 512;
|
|
@@ -107,6 +110,10 @@ export function readUserSettings({ env = process.env, home = os.homedir(), stric
|
|
|
107
110
|
delete parsed[DECODED_BODY_LIMIT_MIB_KEY];
|
|
108
111
|
}
|
|
109
112
|
}
|
|
113
|
+
if (Object.hasOwn(parsed, INFLIGHT_BODY_LIMIT_MIB_KEY) && !validInflightBodyLimit(parsed[INFLIGHT_BODY_LIMIT_MIB_KEY])) {
|
|
114
|
+
if (strict) throw invalidSettings(filePath, `${INFLIGHT_BODY_LIMIT_MIB_KEY} must be an integer from ${INFLIGHT_BODY_LIMIT_MIN_MIB} to ${INFLIGHT_BODY_LIMIT_MAX_MIB}`);
|
|
115
|
+
delete parsed[INFLIGHT_BODY_LIMIT_MIB_KEY];
|
|
116
|
+
}
|
|
110
117
|
return parsed;
|
|
111
118
|
} catch (error) {
|
|
112
119
|
if (error?.code === "ENOENT") return {};
|
|
@@ -215,6 +222,33 @@ function historyLimitPreference(settings, env) {
|
|
|
215
222
|
return { bytes: RESPONSE_HISTORY_DEFAULT_MIB * MIB, mib: RESPONSE_HISTORY_DEFAULT_MIB, source: "default" };
|
|
216
223
|
}
|
|
217
224
|
|
|
225
|
+
const validInflightBodyLimit = mib => Number.isSafeInteger(mib)
|
|
226
|
+
&& mib >= INFLIGHT_BODY_LIMIT_MIN_MIB && mib <= INFLIGHT_BODY_LIMIT_MAX_MIB;
|
|
227
|
+
|
|
228
|
+
export function inflightBodyLimitPreference({ env = process.env, home = os.homedir() } = {}) {
|
|
229
|
+
if (String(env.CCDX_MAX_INFLIGHT_BODY_BYTES || "").trim()) {
|
|
230
|
+
return { bytes: loadRuntimeConfig(env).maxInflightBodyBytes, source: "environment" };
|
|
231
|
+
}
|
|
232
|
+
const mib = readUserSettings({ env, home })[INFLIGHT_BODY_LIMIT_MIB_KEY];
|
|
233
|
+
if (mib !== undefined) return { bytes: mib * MIB, mib, source: "settings" };
|
|
234
|
+
return { bytes: RUNTIME_DEFAULTS.maxInflightBodyBytes, mib: INFLIGHT_BODY_LIMIT_MIN_MIB, source: "default" };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function writeInflightBodyLimitMib(mib, options = {}) {
|
|
238
|
+
if (mib !== null && !validInflightBodyLimit(mib)) {
|
|
239
|
+
throw new Error(`Shared request-body limit must be an integer from ${INFLIGHT_BODY_LIMIT_MIN_MIB} to ${INFLIGHT_BODY_LIMIT_MAX_MIB} MiB`);
|
|
240
|
+
}
|
|
241
|
+
const filePath = userSettingsPath(options);
|
|
242
|
+
return withFileLockSync(`${filePath}.lock`, () => {
|
|
243
|
+
const next = readUserSettings({ ...options, strict: true });
|
|
244
|
+
if (mib === null) {
|
|
245
|
+
if (!Object.hasOwn(next, INFLIGHT_BODY_LIMIT_MIB_KEY)) return false;
|
|
246
|
+
delete next[INFLIGHT_BODY_LIMIT_MIB_KEY];
|
|
247
|
+
} else next[INFLIGHT_BODY_LIMIT_MIB_KEY] = mib;
|
|
248
|
+
return atomicWriteFileIfChangedSync(filePath, `${JSON.stringify(next, null, 2)}\n`, { mode: 0o600 });
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
|
|
218
252
|
export function decodedBodyLimitPreference({ env = process.env, home = os.homedir() } = {}) {
|
|
219
253
|
const environment = String(env.CCDX_MAX_DECODED_BODY_BYTES || "").trim();
|
|
220
254
|
if (environment) {
|