codex-copilot-dx 1.4.7 → 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 +2 -3
- package/package.json +1 -1
- package/src/antigravity-handler.mjs +7 -5
- package/src/antigravity-models.mjs +10 -2
- package/src/antigravity-runtime.mjs +23 -12
- package/src/cli-command-spec.mjs +1 -1
- package/src/cli-management.mjs +20 -7
- package/src/dashboard/gemini.js +32 -12
- package/src/dashboard/index.html +9 -8
- package/src/dashboard/language.js +2 -0
- package/src/dashboard/ui.css +2 -1
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
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -123,7 +123,9 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
123
123
|
if(method==="fetchAvailableModels"&&upstream.ok){
|
|
124
124
|
const value=JSON.parse(await readBoundedResponseText(upstream,{maxBytes:8*1024*1024,signal:abort.signal,label:"Google model catalog"}));
|
|
125
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)}
|
|
126
|
-
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;
|
|
127
129
|
catalogModels=Object.keys(merged.models).filter(id=>id.startsWith(ANTIGRAVITY_MODEL_PREFIX));
|
|
128
130
|
res.writeHead(200,{"Content-Type":"application/json","Cache-Control":"no-store"});res.end(JSON.stringify(merged));return;
|
|
129
131
|
}
|
|
@@ -259,6 +261,6 @@ export function createAntigravityHandler({client,models=()=>[],selectedModels=()
|
|
|
259
261
|
}
|
|
260
262
|
}
|
|
261
263
|
};
|
|
262
|
-
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});
|
|
263
265
|
return handler;
|
|
264
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/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-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/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>
|
|
@@ -406,6 +406,8 @@
|
|
|
406
406
|
"ccdx_client_effort_unavailable": ["The saved reasoning level is unavailable. Choose a declared level or follow the app.", "已保存的推理档位不可用,请选择支持的档位或跟随应用。"],
|
|
407
407
|
"cap_search": ["Search", "联网搜索"],
|
|
408
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.", "当前目录无法使用已保存的默认模型。"],
|
|
409
411
|
"cap_set_default": ["Set default", "设为默认"],
|
|
410
412
|
"cap_details": ["Details", "能力详情"],
|
|
411
413
|
"cap_app_access": ["App access", "应用接入"],
|
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%; }
|