codex-copilot-dx 1.4.20 → 1.4.22

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 CHANGED
@@ -134,7 +134,9 @@ Each protocol observer retains at most 64 series of 64 request points and 16 com
134
134
 
135
135
  ## Observed tool calls
136
136
 
137
- **Requests → Tool and agent activity** offers Production line, Gear clock, Assembly line, Dual-lane sorter, Gantry transfer and Indexing table. Production line is the default for new browsers and replaces unsupported preferences. Saved styles with the same name use the new drawings. Choose Off to keep status text without drawing. The setting is per browser. The display follows observed request and tool activity. Motion stops on completion, failure, cancellation, stale evidence, hidden views or reduced-motion settings. The pictures show activity and do not measure progress. Expand Call details for the full list. Recent requests show total time next to the timestamp, with details below each request.
137
+ **Requests → Tool and agent activity** offers Production line, Gear clock, Assembly line, Dual-lane sorter, Gantry transfer, Indexing table and Articulated robot arm. Production line is the default for new browsers and replaces unsupported preferences. Saved styles with the same name use the new drawings. Choose Off to keep status text without drawing. The setting is per browser. The display follows observed request and tool activity. Motion stops on completion, failure, cancellation, stale evidence, hidden views or reduced-motion settings. The pictures show activity and do not measure progress. Expand Call details for the full list. Recent requests show total time next to the timestamp, with details below each request.
138
+
139
+ On the Antigravity page, the top **Refresh** reads local setup and activity. **Refresh models** fetches the upstream catalog. Returning to the page retains unsaved selections and the last focused model control while status refreshes.
138
140
 
139
141
  Calls are correlated using their IDs and the existing app/profile/session scope. A model emitting a tool call does not prove that the client executed it. Only a matching returned result ends the wait; ambiguous name-only Gemini results stay unconfirmed. Without a reliable session, completed requests show unconfirmed tool state. After 90 seconds without observable tool or response activity, the UI pauses and shows that fresh status is needed. Late results can update retained unconfirmed observations for another five minutes. These display deadlines never cancel tools or change source timeouts.
140
142
 
@@ -286,6 +288,8 @@ The initial internal ceiling is 128 concurrent requests per source/account. This
286
288
 
287
289
  Settings separates saved preferences from effective state. Auto-save applies changes by default; required restarts remain explicit. Restore-defaults creates a backup first and keeps accounts, keys, model plans and chats. CLI preference reset/restore uses its own service-only backup; it does not change browser appearance or replace the Web UI's backup.
288
290
 
291
+ Use the button beside the CCDX wordmark to collapse the sidebar to icons. The browser remembers the layout for this dashboard address. The current page stays selected when the sidebar changes width.
292
+
289
293
  **Settings → Bark notifications** is collapsed by default. Enable it and paste the URL containing the device key from Bark. The minimum duration defaults to 30 minutes. Zero includes every eligible completed turn. Leave the title and description blank to use the name of the app that finished. The phone retrieves the matching public PNG from [Lobe Icons](https://github.com/lobehub/lobe-icons).
290
294
 
291
295
  New Bark URLs require HTTPS. Existing HTTP addresses remain usable with a settings warning. If a custom reverse-proxy prefix makes a copied URL ambiguous, use `https://host/prefix/push?device_key=KEY`. CCDX removes the query before sending and passes the key in the push body.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "1.4.20",
3
+ "version": "1.4.22",
4
4
  "description": "Local gateway for Codex, Claude and Gemini Antigravity with Copilot, Microsoft 365 and custom APIs",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
@@ -204,6 +204,19 @@ function createGuardedMessagesObserver(onEvent, maxBytes, clientModel, guard, re
204
204
  return { write: chunk => run("write", chunk), finish: () => run("finish") };
205
205
  }
206
206
 
207
+ function malformedTextBlock(body) {
208
+ const invalidIndex = content => Array.isArray(content)
209
+ ? content.findIndex(block => block?.type === "text" && typeof block.text !== "string") : -1;
210
+ const system = invalidIndex(body.system);
211
+ if (system >= 0) return `system[${system}].text`;
212
+ for (const [index, message] of body.messages.entries()) {
213
+ if (message?.role !== "user" && message?.role !== "system") continue;
214
+ const block = invalidIndex(message.content);
215
+ if (block >= 0) return `messages[${index}].content[${block}].text`;
216
+ }
217
+ return null;
218
+ }
219
+
207
220
  export function createClaudeGatewayHandler({ provider, apiKey, desktopAliases = false, appContract, messagesSystemMode = "passthrough", log = () => {}, onRequest = () => {}, env = process.env, performance: sharedPerformance, validateConversation,
208
221
  resolveRequest, privacy, compaction, privacyClient = "claude", record = recordUsage, acquireRequest = createRequestAdmission({ maxBytes: 16 * 1024 * 1024, maxQueued: 8 }) } = {}) {
209
222
  if (!provider || !isProviderId(provider.id) || typeof apiKey !== "string" || apiKey.length < 32) throw new Error("Claude gateway requires a provider and private local key");
@@ -260,6 +273,13 @@ export function createClaudeGatewayHandler({ provider, apiKey, desktopAliases =
260
273
  if (!body || typeof body.model !== "string" || !Array.isArray(body.messages)) {
261
274
  send(res, 400, apiError("ccdx_messages_invalid", "Expected a model and messages array"));return;
262
275
  }
276
+ const invalidText = malformedTextBlock(body);
277
+ if (invalidText) {
278
+ failureStatus = 400;
279
+ send(res, failureStatus, { type: "error", error: { type: "invalid_request_error",
280
+ code: "ccdx_messages_text_invalid", param: invalidText, message: `${invalidText} must be a string.` } });
281
+ return;
282
+ }
263
283
  const apiVersion = req.headers["anthropic-version"];
264
284
  if (typeof apiVersion === "string" && apiVersion.trim() === "2026-10-21") {
265
285
  const parameter = ["temperature", "top_p", "top_k"].find(name => Object.hasOwn(body, name));
@@ -1,5 +1,5 @@
1
1
  (() => {
2
- function create({ element: el, change, localize, isBusy = () => false }) {
2
+ function create({ element: el, change, localize, isBusy = () => false, isMutating = isBusy }) {
3
3
  let data, pending = false, sequence = 0, confirmation = null, claudeApp = true, note = null, autoError = false, antigravityCatalogPending = false;
4
4
  const route = () => ({ codex: "codex", claude: claudeApp ? "claude_app" : null, gemini: "antigravity" })[location.hash.slice(1)] || null;
5
5
  const label = (id, key) => localize(el(id), key);
@@ -23,7 +23,7 @@
23
23
  el("codex-auto-launch").disabled = isBusy() || data?.effective?.codex_auto_launch?.locked === true || !data;
24
24
  label("codex-auto-launch-note", autoError ? "application_preference_failed" : data?.effective?.codex_auto_launch?.locked ? "controlled_by_environment" : "next_ccdx_start");
25
25
  }
26
- window.dispatchEvent(new CustomEvent("ccdx:application-state", { detail: { id, application: state, pending: pending || isBusy() } }));
26
+ window.dispatchEvent(new CustomEvent("ccdx:application-state", { detail: { id, application: state, pending: pending || isMutating() } }));
27
27
  }
28
28
  function sync(next) {
29
29
  const applications = { ...next.applications };
@@ -89,7 +89,8 @@
89
89
  globalThis.ccdxSettingsPreferences = preferences;
90
90
  const bark = globalThis.ccdxBarkSettings?.create({ element: el, api });
91
91
  const features = globalThis.ccdxDashboardFeatures?.create({ element: el, api, apply: applySettings, change, localize: label });
92
- const applications = globalThis.ccdxApplications?.create({ element: el, change, localize: label, isBusy: () => settingsPending });
92
+ const applications = globalThis.ccdxApplications?.create({ element: el, change, localize: label,
93
+ isBusy: () => settingsPending, isMutating: () => settingsPending && !settingsReadPending });
93
94
  globalThis.ccdxApplicationControls = applications;
94
95
  const states = { needs_github_access: "image_needs_github", image_model_unavailable: "image_no_models", immediate: "effective_now", terminal_unavailable: "terminal_animation_unavailable_in_this_output_mode", next_start: "next_ccdx_start", next_call: "applies_to_new_calls", needs_setup: "setup_required",
95
96
  next_config_request: "next_configuration_request_cached_suggestions_may_remain", needs_app_relaunch: "reopen_the_client_to_finish", needs_service_restart: "restart_ccdx_to_finish" };
@@ -201,11 +202,12 @@
201
202
  async function loadSettings() {
202
203
  if (settingsPending) return settingsReadPending;
203
204
  settingsPending = true;
205
+ settingsReadPending = api();
204
206
  applications?.render();
205
207
  el("terminal-color-theme").disabled = true;
206
208
  syncAccountControls();
207
209
  const readVersion = preferences?.version;
208
- try { settingsReadPending = api();applySettings(await settingsReadPending, { readVersion });settingsReadAt = time(Date.now());void globalThis.ccdxConnections?.load(); }
210
+ try { applySettings(await settingsReadPending, { readVersion });settingsReadAt = time(Date.now());void globalThis.ccdxConnections?.load(); }
209
211
  catch (error) {
210
212
  for (const id of ["settings-note", ...(settingsViews.includes(current) ? ["page-settings-note"] : [])]) {
211
213
  label(el(id), settingsReadAt ? "showing_previous_data_updated_time" : "could_not_read_settings", { time: settingsReadAt });
@@ -2,6 +2,7 @@
2
2
  const el=id=>document.getElementById(id),language=globalThis.ccdxLanguage;
3
3
  let busy=false,state=null,draft=null,defaultDraft,timeoutDraft,nativeDraft,notice=null,pendingAction=null;
4
4
  let sharedApplication=null,sharedPending=false,savedTimer,showSaved=false,savedModels=false;
5
+ let reading, renderedSources, renderedCatalog, modelRows=[], lastFieldFocus;
5
6
  const words=(id,key)=>language.set(el(id),key);
6
7
  const clear=id=>{el(id).removeAttribute('data-i18n');el(id).removeAttribute('data-i18n-args');el(id).textContent='';el(id).title=''};
7
8
  const controls=['gemini-enabled','gemini-open','gemini-refresh','gemini-save','gemini-cancel','gemini-use-app-default'];
@@ -48,7 +49,11 @@
48
49
  native.disabled=busy||sharedPending;
49
50
  const options=[{id:'',name:language.format('gemini_native_source_none')},...sources];
50
51
  if(state.native_source&&!sources.some(source=>source.id===state.native_source))options.push({id:state.native_source,name:language.format('unknown'),disabled:true});
51
- native.replaceChildren(...options.map(source=>{const option=document.createElement('option');option.value=source.id;option.textContent=source.name;option.disabled=source.disabled===true;return option}));
52
+ const sourcesKey=JSON.stringify(options);
53
+ if(sourcesKey!==renderedSources){
54
+ native.replaceChildren(...options.map(source=>{const option=document.createElement('option');option.value=source.id;option.textContent=source.name;option.disabled=source.disabled===true;return option}));
55
+ renderedSources=sourcesKey;
56
+ }
52
57
  native.value=nativeDraft===undefined?state.native_source??'':nativeDraft??'';
53
58
  syncSaveControls();
54
59
  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');
@@ -66,44 +71,74 @@
66
71
  el('gemini-reopen').hidden=!hint;if(hint)words('gemini-reopen',state.enabled?'gemini_reopen':'gemini_pause_reopen');
67
72
  el('gemini-open').hidden=!fallback;
68
73
  el('gemini-open').disabled=busy||sharedPending||state.app.status!=='stopped';
74
+ renderModels();
75
+ for(const id of ['active','failed','copilot','total'])el('gemini-'+id).textContent=state.activity?.[id]??'—';
76
+ if(notice)words('gemini-note',notice);
77
+ }
78
+ function renderModels(){
69
79
  const list=el('gemini-models'),focused=list.contains(document.activeElement)?document.activeElement:null;
70
- const focus={value:focused?.value,kind:focused?.tagName};list.replaceChildren();
71
- for(const model of groupedModels()){
72
- const chosen=new Set(draft||selected()),ids=model.efforts.map(item=>item.id);
73
- const row=document.createElement('tr'),name=document.createElement('td'),label=document.createElement('label'),input=document.createElement('input');
74
- 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);
75
- 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()};
76
- input.addEventListener('change',()=>{const saved=ids.filter(id=>selected().includes(id));update(input.checked&&saved.length?saved:ids,input.checked)});
77
- label.append(input,document.createTextNode(model.name));name.append(label);row.append(name);
78
- 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)}
79
- const efforts=document.createElement('td');efforts.dataset.label=language.format('cap_reasoning');
80
- efforts.textContent=model.efforts.map(item=>item.effort||'—').join(' / ');
81
- const preferred=document.createElement('td'),button=document.createElement('button');preferred.dataset.label=language.format('gemini_new_chat_default');
80
+ const groups=groupedModels(), catalogKey=JSON.stringify([document.documentElement.lang,groups.map(model=>
81
+ [model.id,model.name,model.context_window,model.efforts.map(item=>[item.id,item.effort])])]);
82
+ if(catalogKey!==renderedCatalog){
83
+ const oldFocus=focused||(lastFieldFocus&&list.contains(lastFieldFocus)?lastFieldFocus:null);
84
+ modelRows=groups.map(model=>{
85
+ const ids=model.efforts.map(item=>item.id);
86
+ const row=document.createElement('tr'),name=document.createElement('td'),label=document.createElement('label'),input=document.createElement('input');
87
+ input.type='checkbox';input.value=model.id;input.setAttribute('aria-label',model.name);
88
+ input.addEventListener('change',()=>{
89
+ const saved=ids.filter(id=>selected().includes(id)),checked=input.checked;
90
+ const values=checked&&saved.length?saved:ids,next=new Set(draft||selected());
91
+ for(const id of values)if(checked)next.add(id);else next.delete(id);
92
+ draft=[...next];if(!checked&&values.includes(currentDefault()))defaultDraft=null;
93
+ notice=null;clear('gemini-note');render();
94
+ });
95
+ label.append(input,document.createTextNode(model.name));name.append(label);row.append(name);
96
+ for(const [key,value]of [['source','GitHub Copilot'],['cap_context',count(model.context_window)]]){
97
+ const cell=document.createElement('td');cell.textContent=value;cell.dataset.label=language.format(key);row.append(cell);
98
+ }
99
+ const efforts=document.createElement('td');efforts.dataset.label=language.format('cap_reasoning');
100
+ efforts.textContent=model.efforts.map(item=>item.effort||'—').join(' / ');
101
+ const preferred=document.createElement('td'),button=document.createElement('button');preferred.dataset.label=language.format('gemini_new_chat_default');
102
+ button.type='button';button.value=model.id;
103
+ button.addEventListener('click',()=>{
104
+ if(button.getAttribute('aria-pressed')==='true')return;
105
+ const chosen=new Set(draft||selected()),saved=ids.filter(id=>selected().includes(id));
106
+ const visible=model.efforts.filter(item=>chosen.has(item.id));
107
+ const available=visible.length?visible:saved.length?model.efforts.filter(item=>saved.includes(item.id)):model.efforts;
108
+ if(!visible.length){for(const item of available)chosen.add(item.id);draft=[...chosen];}
109
+ defaultDraft=(available.find(item=>item.effort==='medium')||available[0])?.id??null;
110
+ notice=null;clear('gemini-note');render();
111
+ });
112
+ preferred.append(button);row.append(efforts,preferred);return {row,model,ids,input,button};
113
+ });
114
+ list.replaceChildren(...modelRows.map(({row})=>row));
115
+ if(!modelRows.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);}
116
+ if(oldFocus){
117
+ lastFieldFocus=[...list.querySelectorAll(oldFocus.tagName.toLowerCase())].find(control=>control.value===oldFocus.value);
118
+ }
119
+ renderedCatalog=catalogKey;
120
+ }
121
+ const chosen=new Set(draft||selected()),disabled=busy||sharedPending;
122
+ for(const {model,ids,input,button} of modelRows){
82
123
  const isDefault=ids.includes(currentDefault())&&chosen.has(currentDefault());
83
- button.type='button';button.value=model.id;button.disabled=busy||sharedPending;
124
+ input.checked=ids.some(id=>chosen.has(id));input.disabled=button.disabled=disabled;
84
125
  const title=isDefault?'cap_default':'cap_set_default';language.set(button,title);
85
126
  button.setAttribute('aria-pressed',String(isDefault));button.setAttribute('aria-label',language.format('model_action_label',{name:model.name,action:language.format(title)}));
86
- button.addEventListener('click',()=>{
87
- if(isDefault)return;
88
- const saved=ids.filter(id=>selected().includes(id)),visible=model.efforts.filter(item=>chosen.has(item.id));
89
- const available=visible.length?visible:saved.length?model.efforts.filter(item=>saved.includes(item.id)):model.efforts;
90
- if(!visible.length){for(const item of available)chosen.add(item.id);draft=[...chosen];}
91
- defaultDraft=(available.find(item=>item.effort==='medium')||available[0])?.id??null;
92
- notice=null;clear('gemini-note');render();
93
- });
94
- preferred.append(button);row.append(efforts,preferred);list.append(row);
95
127
  }
96
- 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)}
97
- if(focus.kind)[...list.querySelectorAll(focus.kind.toLowerCase())].find(control=>control.value===focus.value)?.focus();
98
- for(const id of ['active','failed','copilot','total'])el('gemini-'+id).textContent=state.activity?.[id]??'—';
99
- if(notice)words('gemini-note',notice);
128
+ if(focused&&!focused.isConnected)lastFieldFocus?.focus({preventScroll:true});
100
129
  }
101
130
  async function load(action,extra={},report=true){
102
- if(busy){if(!report)throw Error('Antigravity settings are busy');return}
103
- busy=true;pendingAction=action;render();
131
+ if(busy&&!reading){if(!report)throw Error('Antigravity settings are busy');return}
132
+ const write=Boolean(action&&action!=='summary');
133
+ if(!write&&reading&&(reading.action===action||action==='summary'))return;
134
+ reading?.controller.abort();
135
+ const controller=new AbortController();
136
+ reading=write?null:{action,controller};
137
+ if(write||!state){busy=true;pendingAction=action;render();}
104
138
  try{
105
- 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})}:{})});
139
+ const 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.any([controller.signal,AbortSignal.timeout(20000)]),...(write?{body:JSON.stringify({action,...(action==='enable'?{accept_background_copilot:true}:{}),...extra})}:{})});
106
140
  const value=await response.json();if(!response.ok)throw Error(value.error||'Antigravity setup failed');
141
+ if(controller.signal.aborted)return;
107
142
  state=value;if(action==='models'){
108
143
  draft=null;defaultDraft=undefined;timeoutDraft=undefined;nativeDraft=undefined;showSaved=true;savedModels=extra.models!==undefined||extra.native_source!==undefined;clearTimeout(savedTimer);savedTimer=setTimeout(()=>{showSaved=false;render()},2200);
109
144
  }
@@ -113,8 +148,14 @@
113
148
  clear('gemini-note');
114
149
  }
115
150
  return state;
116
- }catch(error){if(!report)throw error;notice='gemini_operation_failed';words('gemini-note',notice);el('gemini-note').title=error.message}
117
- finally{busy=false;pendingAction=null;render();window.dispatchEvent(new CustomEvent('ccdx-gemini-state',{detail:{application:state?.application,needsCatalogReload:(state?.enabled===true&&state.source_enabled!==false||Boolean(state?.native_source))&&state.models_reload_required===true&&state.default_model_unavailable!==true}}))}
151
+ }catch(error){if(!controller.signal.aborted){if(!report)throw error;notice='gemini_operation_failed';words('gemini-note',notice);el('gemini-note').title=error.message;}}
152
+ finally{
153
+ if(!controller.signal.aborted){
154
+ if(reading?.controller===controller)reading=null;
155
+ busy=false;pendingAction=null;render();
156
+ window.dispatchEvent(new CustomEvent('ccdx-gemini-state',{detail:{application:state?.application,needsCatalogReload:(state?.enabled===true&&state.source_enabled!==false||Boolean(state?.native_source))&&state.models_reload_required===true&&state.default_model_unavailable!==true}}));
157
+ }
158
+ }
118
159
  }
119
160
  globalThis.ccdxAntigravity={get state(){return state},get pending(){return busy},refreshStatus:()=>load('summary'),setEnabled:enabled=>load(enabled?'enable':'disable',{},false)};
120
161
  el('gemini-enabled').addEventListener('change',event=>void load(event.target.checked?'enable':'disable'));
@@ -131,8 +172,14 @@
131
172
  el('gemini-open').addEventListener('click',()=>{if(globalThis.ccdxApplicationControls)globalThis.ccdxApplicationControls.open('antigravity');else void load('open')});
132
173
  window.addEventListener('ccdx:application-state',event=>{if(event.detail?.id==='antigravity'){sharedApplication=event.detail.application;sharedPending=event.detail.pending;render()}});
133
174
  el('gemini-refresh').addEventListener('click',()=>void load('refresh'));
134
- el('refresh').addEventListener('click',()=>{if(['#gemini','#models'].includes(location.hash))void load(location.hash==='#models'?'summary':'refresh')});
135
- window.addEventListener('hashchange',()=>{if(['#gemini','#models'].includes(location.hash))void load(location.hash==='#models'?'summary':undefined)});
175
+ el('refresh').addEventListener('click',()=>{if(['#gemini','#models'].includes(location.hash))void load(location.hash==='#models'?'summary':undefined)});
176
+ el('gemini-model-form').addEventListener('focusin',event=>{lastFieldFocus=event.target});
177
+ window.addEventListener('hashchange',()=>{
178
+ if(location.hash==='#gemini'){
179
+ if(document.activeElement===el('main-content')&&lastFieldFocus?.isConnected)lastFieldFocus.focus({preventScroll:true});
180
+ void load();
181
+ }else if(location.hash==='#models')void load('summary');
182
+ });
136
183
  new MutationObserver(render).observe(document.documentElement,{attributes:true,attributeFilter:['lang']});
137
184
  void load(location.hash==='#gemini'?undefined:'summary');
138
185
  })();
@@ -14,8 +14,13 @@
14
14
  <body>
15
15
  <div class="shell">
16
16
  <aside class="sidebar">
17
+ <div class="sidebar-header">
17
18
  <a class="sidebar-brand" href="#overview"><svg id="status-icon" class="status-icon" viewBox="0 0 64 64" aria-hidden="true" focusable="false"><g fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round"><ellipse cx="32" cy="32" rx="26" ry="10"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(60 32 32)"/><ellipse cx="32" cy="32" rx="26" ry="10" transform="rotate(120 32 32)"/></g><circle cx="32" cy="32" r="4.5" fill="currentColor"/></svg><span class="brand-name">CCDX</span></a>
18
- <nav aria-label="Navigation" data-i18n-label="main_navigation">
19
+ <button class="icon-button sidebar-toggle" id="sidebar-toggle" type="button" aria-controls="sidebar-navigation" aria-expanded="true" aria-label="Collapse sidebar" title="Collapse sidebar">
20
+ <svg class="nav-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 4v16"/><path class="sidebar-chevron" d="m16 9-3 3 3 3"/></svg>
21
+ </button>
22
+ </div>
23
+ <nav id="sidebar-navigation" aria-label="Navigation" data-i18n-label="main_navigation">
19
24
  <a href="#overview" data-route="overview" aria-current="page"><svg class="nav-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg><span data-i18n="overview">Overview</span></a>
20
25
  <span class="nav-group" data-i18n="clients">Apps</span>
21
26
  <a class="nav-child" href="#codex" data-route="codex"><svg class="nav-icon" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="m7 8 4 4-4 4m7 0h3"/></svg><span>Codex</span></a>
@@ -406,7 +411,7 @@
406
411
  <div class="flow-caption"><span id="flow-caption" data-i18n="flow_status_unknown">Status unavailable</span><button id="flow-clear" type="button" data-i18n="flow_show_all" hidden>Show all</button><button id="flow-more" type="button" hidden>More models</button></div>
407
412
  </section>
408
413
  <section id="tool-activity" class="panel dashboard-section" aria-labelledby="tool-title" data-paused="true">
409
- <div class="panel-heading"><h2 id="tool-title" data-i18n="tool_heading">TOOL AND AGENT ACTIVITY</h2><label class="tool-style" for="tool-style"><span data-i18n="tool_style">Style</span><select id="tool-style"><option value="production" data-i18n="tool_style_production">Production line</option><option value="clock" data-i18n="tool_style_clock">Gear clock</option><option value="assembly" data-i18n="tool_style_assembly">Assembly line</option><option value="sorter" data-i18n="tool_style_sorter">Dual-lane sorter</option><option value="gantry" data-i18n="tool_style_gantry">Gantry transfer</option><option value="rotary" data-i18n="tool_style_rotary">Indexing table</option><option value="off" data-i18n="tool_style_off">Off</option></select></label></div>
414
+ <div class="panel-heading"><h2 id="tool-title" data-i18n="tool_heading">TOOL AND AGENT ACTIVITY</h2><label class="tool-style" for="tool-style"><span data-i18n="tool_style">Style</span><select id="tool-style"><option value="production" data-i18n="tool_style_production">Production line</option><option value="clock" data-i18n="tool_style_clock">Gear clock</option><option value="assembly" data-i18n="tool_style_assembly">Assembly line</option><option value="sorter" data-i18n="tool_style_sorter">Dual-lane sorter</option><option value="gantry" data-i18n="tool_style_gantry">Gantry transfer</option><option value="rotary" data-i18n="tool_style_rotary">Indexing table</option><option value="arm" data-i18n="tool_style_arm">Articulated robot arm</option><option value="off" data-i18n="tool_style_off">Off</option></select></label></div>
410
415
  <div id="tool-stage" class="tool-stage" data-style="production">
411
416
  <div class="tool-visual"><div class="tool-orbit"><canvas id="tool-canvas" role="img" data-i18n-label="tool_heading" aria-label="Tool and agent activity"></canvas></div><p class="tool-narration"><span id="tool-state" role="status" aria-live="polite" data-i18n="flow_status_unknown">Waiting for a fresh status</span><span id="tool-cursor" aria-hidden="true" hidden> …</span></p></div>
412
417
  <div class="tool-content"><p id="tool-context" class="tool-context" hidden></p><div id="tool-list"></div><p id="tool-more" class="hint" hidden></p></div>
@@ -29,6 +29,7 @@
29
29
  "tool_style_sorter": ["Dual-lane sorter","双轨分拣"],
30
30
  "tool_style_gantry": ["Gantry transfer","龙门移载"],
31
31
  "tool_style_rotary": ["Indexing table","分度转盘"],
32
+ "tool_style_arm": ["Articulated robot arm","多节机械臂"],
32
33
  "tool_style_production": ["Production line", "工业生产线"],
33
34
  "tool_style_clock": ["Gear clock", "齿轮钟表"],
34
35
  "tool_style_assembly": ["Assembly line","装配线"],
@@ -963,6 +964,8 @@
963
964
  "usage_and_diagnostics": ["Usage", "用量统计"],
964
965
  "system_and_settings": ["Settings", "设置"],
965
966
  "main_navigation": ["Navigation", "页面导航"],
967
+ "sidebar_collapse": ["Collapse sidebar", "收起侧栏"],
968
+ "sidebar_expand": ["Expand sidebar", "展开侧栏"],
966
969
  "local_control": ["LOCAL CONTROL", "本机控制"],
967
970
  "terminal_appearance": ["Terminal appearance", "终端外观"],
968
971
  "configuration_observation": ["SETUP AND ACTIVITY", "接入状态"],
@@ -0,0 +1,450 @@
1
+ (() => {
2
+ "use strict";
3
+ // One fixed camera and one set of 3D joint coordinates for the entire assembly.
4
+ const tau = 2 * Math.PI, diagonal = Math.SQRT1_2;
5
+ const camera = [.5,.5,diagonal];
6
+ const X = [1,0,0], Y = [0,1,0], Z = [0,0,1];
7
+ const add = (a,b) => [a[0]+b[0],a[1]+b[1],a[2]+b[2]];
8
+ const sub = (a,b) => [a[0]-b[0],a[1]-b[1],a[2]-b[2]];
9
+ const scale = (a,k) => [a[0]*k,a[1]*k,a[2]*k];
10
+ const dot = (a,b) => a[0]*b[0]+a[1]*b[1]+a[2]*b[2];
11
+ const cross = (a,b) => [a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]];
12
+ const len = a => Math.hypot(...a);
13
+ const unit = a => scale(a,1/len(a));
14
+ const mix = (a,b,s) => add(a,scale(sub(b,a),s));
15
+ const clamp = (x,lo,hi) => Math.min(hi,Math.max(lo,x));
16
+ const project = ([x,y,z]) => [(x-y)*diagonal,(x+y)/2-z*diagonal];
17
+ const radial = (u,v,angle) => add(scale(u,Math.cos(angle)),scale(v,Math.sin(angle)));
18
+ const withZ = ([x,y],z) => [x,y,z];
19
+
20
+ const fixtureA = [89,-42], fixtureB = [86,40], park = [64,-4,79];
21
+ const floor = 6, gripZ = 35, travelZ = 76;
22
+ const upperLength = 62, foreLength = 53, closedGap = 7.4, openGap = 10.8;
23
+ const transferStart = 3.85, transferEnd = 5.55, duration = 9.25;
24
+ const queue = [];
25
+
26
+ function progress(t) {
27
+ // Integrate a piecewise linear speed profile. The outer quarters have constant acceleration.
28
+ const r = .25, speed = 1/(1-r);
29
+ if (t <= r) return speed*t*t/(2*r);
30
+ if (t >= 1-r) return 1-speed*(1-t)*(1-t)/(2*r);
31
+ return speed*(t-r/2);
32
+ }
33
+
34
+ function makeStages(a, b, yOffset) {
35
+ const approach = [a[0]-5,a[1]+yOffset,61];
36
+ return [
37
+ [0,park,openGap], [.40,park,openGap], [1.50,approach,openGap], [2.00,withZ(a,61),openGap],
38
+ [2.80,withZ(a,gripZ),openGap], [3.15,withZ(a,gripZ),closedGap], [3.35,withZ(a,gripZ),closedGap],
39
+ [transferStart,withZ(a,travelZ),closedGap], [transferEnd,withZ(b,travelZ),closedGap],
40
+ [6.45,withZ(b,gripZ),closedGap], [6.72,withZ(b,gripZ),closedGap], [7.09,withZ(b,gripZ),openGap],
41
+ [7.82,withZ(b,61),openGap], [duration,park,openGap],
42
+ ];
43
+ }
44
+ const stagesForward = makeStages(fixtureA, fixtureB, 4);
45
+ const stagesReverse = makeStages(fixtureB, fixtureA, -4);
46
+ function trajectory(t, reverse) {
47
+ const stages = reverse ? stagesReverse : stagesForward;
48
+ const i = stages.findIndex((stage, j) => j+1 === stages.length-1 || t < stages[j+1][0]);
49
+ const [from, p, g] = stages[i], [to, q, h] = stages[i+1];
50
+ const s = progress(clamp((t-from)/(to-from),0,1));
51
+ return { position:mix(p,q,s), jaw:g+(h-g)*s,
52
+ a:reverse?fixtureB:fixtureA, b:reverse?fixtureA:fixtureB };
53
+ }
54
+
55
+ function solve([x,y,z]) {
56
+ const yaw = Math.atan2(y,x);
57
+ const radialAxis = [Math.cos(yaw),Math.sin(yaw),0];
58
+ const side = [-Math.sin(yaw),Math.cos(yaw),0];
59
+ const reach = Math.hypot(x,y), shoulder = [0,0,50], lift = z-shoulder[2];
60
+ const bend = -Math.acos(clamp((reach*reach+lift*lift-upperLength**2-foreLength**2)/(2*upperLength*foreLength),-1,1));
61
+ const pitch = Math.atan2(lift,reach)-Math.atan2(foreLength*Math.sin(bend),upperLength+foreLength*Math.cos(bend));
62
+ const planeVector = angle => add(scale(radialAxis,Math.cos(angle)),scale(Z,Math.sin(angle)));
63
+ const upper = planeVector(pitch), fore = planeVector(pitch+bend);
64
+ const elbow = add(shoulder,scale(upper,upperLength));
65
+ return {yaw,bend,radialAxis,side,shoulder,elbow,wrist:add(elbow,scale(fore,foreLength)),upper,fore};
66
+ }
67
+
68
+ function face(points,fill,stroke=null,width=.43,bias=0) {
69
+ const depth = points.reduce((sum,p)=>sum+dot(p,camera),0)/points.length;
70
+ queue.push({points,fill,stroke,width,depth:depth+bias,bias});
71
+ }
72
+ function line(a,b,stroke="fine",width=.46,bias=.15) {face([a,b],null,stroke,width,bias);}
73
+ function ring(at,u,v,r,n=24,phase=0) {
74
+ return Array.from({length:n},(_,i)=>add(at,scale(radial(u,v,phase+tau*i/n),r)));
75
+ }
76
+ function disk(at,u,v,r,fill="metal",stroke="edge",bias=.2) {face(ring(at,u,v,r),fill,stroke,.55,bias);}
77
+ function visible(normal) {return dot(normal,camera) > .005;}
78
+ function turnedPart(origin,axis,guide,profile,options={}) {
79
+ const u=unit(cross(guide,axis)),v=cross(axis,u);
80
+ const facing=Math.atan2(dot(v,camera),dot(u,camera));
81
+ const n=Math.max(8,(options.sectors??24)/2|0);
82
+ // The two silhouette tangents move continuously; the rim does not switch facets.
83
+ const normals=Array.from({length:n+1},(_,i)=>radial(u,v,facing-Math.PI/2+Math.PI*i/n));
84
+ const sample=([offset,radius])=>{
85
+ const center=add(origin,scale(axis,offset));
86
+ return normals.map(normal=>add(center,scale(normal,radius)));
87
+ };
88
+ let previous=sample(profile[0]);
89
+ face(previous,null,"edge",.46,.12);
90
+ for(let i=1;i<profile.length;i++) {
91
+ const next=sample(profile[i]);
92
+ const [begin,r1]=profile[i-1], [end,r2,palette]=profile[i];
93
+ const sections=Math.max(1,Math.ceil((end-begin)/9));
94
+ for(let j=0;j<n;j++) {
95
+ const normal=unit(add(normals[j],normals[j+1]));
96
+ const shade=clamp(Math.round((dot(normal,[-.42,-.49,.76])+1)*3),0,6);
97
+ const paint=palette??options.color??"shade"+shade;
98
+ for(let k=0;k<sections;k++) {
99
+ const t=k/sections,s=(k+1)/sections;
100
+ face([mix(previous[j],next[j],t),mix(previous[j+1],next[j+1],t),
101
+ mix(previous[j+1],next[j+1],s),mix(previous[j],next[j],s)],paint);
102
+ }
103
+ }
104
+ line(previous[0],next[0],"edge",.53,.12);
105
+ line(previous[n],next[n],"edge",.53,.12);
106
+ if(r1!==r2||i===profile.length-1)face(next,null,"edge",.43,.12);
107
+ previous=next;
108
+ }
109
+ const [offset,radius]=dot(axis,camera)>0?profile.at(-1):profile[0];
110
+ disk(add(origin,scale(axis,offset)),u,v,radius,options.cap??"metal");
111
+ return sample;
112
+ }
113
+ function body(a,b,r,options={}) {
114
+ const offset=sub(b,a),axis=unit(offset);
115
+ const guide=options.guide??(Math.abs(dot(axis,Z))>.95?X:Z);
116
+ return turnedPart(a,axis,guide,[[0,r],[len(offset),r]],options);
117
+ }
118
+ function slab(corners,z0,z1,offset=[0,0,0],top="metal") {
119
+ const layer=z=>corners.map(([x,y])=>add([x,y,z],offset));
120
+ const lower=layer(z0),upper=layer(z1);
121
+ for(let i=0;i<corners.length;i++) {
122
+ const j=(i+1)%corners.length;
123
+ if(visible(cross(sub(lower[j],lower[i]),Z)))face([lower[i],lower[j],upper[j],upper[i]],"dark-metal","edge",.58);
124
+ }
125
+ face(upper,top,"edge",.68);
126
+ }
127
+ const rect=(x0,y0,x1,y1)=>[[x0,y0],[x1,y0],[x1,y1],[x0,y1]];
128
+ function bolt(at,u,v,r=1.35) {
129
+ face(ring(at,u,v,r,6,Math.PI/6),"dark-metal","edge",.39,.4);
130
+ line(add(at,scale(u,-r*.55)),add(at,scale(u,r*.55)),"recess",.36,.55);
131
+ }
132
+ function gear(at,u,v,r,n,angle) {
133
+ const points=Array.from({length:n*4},(_,i)=>{
134
+ const distance=i%4===0||i%4===3?r-.9:r+.55;
135
+ return add(at,scale(radial(u,v,angle+tau*i/(n*4)),distance));
136
+ });
137
+ face(points,"dark-metal","edge",.50,.36);
138
+ disk(add(at,scale(unit(cross(u,v)),.12)),u,v,r-2.5,"metal","edge",.56);
139
+ disk(at,u,v,r*.24,"recess","edge",.8);
140
+ for(let i=0;i<3;i++) {
141
+ const spoke=radial(u,v,angle+i*tau/3);
142
+ line(add(at,scale(spoke,r*.33)),add(at,scale(spoke,r*.72)),"edge",.58,.85);
143
+ }
144
+ const notch=radial(u,v,angle);
145
+ line(add(at,scale(notch,r*.70)),add(at,scale(notch,r*.93)),"recess",.85,.94);
146
+ }
147
+
148
+ const platePath = [[-46,-63],[104,-63],[115,-52],[115,53],[104,64],[-46,64],[-56,54],[-56,-53]];
149
+ function fixtureMark(at) {
150
+ slab(rect(-12,-10,12,10),4.8,6,withZ(at,0),"paper");
151
+ const center=withZ(at,6.12);
152
+ for(const s of [-1,1]) {
153
+ for(const q of [-1,1])bolt(add(center,[s*9,q*7,0]),X,Y,1.05);
154
+ line(add(center,[s*7,-5,0]),add(center,[s*7,5,0]),"fine",.43,.2);
155
+ }
156
+ line(add(center,[0,-4,0]),add(center,[0,4,0]),"fine",.4,.2);
157
+ line(add(center,[-4,0,0]),add(center,[4,0,0]),"fine",.4,.2);
158
+ }
159
+ function staticPlate() {
160
+ slab(platePath,0,2,[0,0,0],"dark-metal");
161
+ slab(platePath.map(([x,y])=>[x*.99,y*.983]),2,5);
162
+ for(const [x,y] of [[-43,-51],[102,-51],[102,52],[-43,52]]) {
163
+ disk([x,y,5.08],X,Y,3.8,"paper","fine");
164
+ bolt([x,y,5.19],X,Y,2);
165
+ }
166
+ for(const at of [fixtureA,fixtureB])fixtureMark(at);
167
+ const motor=[-27,19,5];
168
+ slab(rect(-11,-9,11,9),0,4,motor,"dark-metal");
169
+ for(let i=-3;i<=3;i++)line(add(motor,[i*2.6,-6,4.1]),add(motor,[i*2.6,6,4.1]),"edge",.55,.2);
170
+ for(const shift of [0,3]) {
171
+ line([-15,21+shift,5.4],[-8,21+shift,5.4],"edge",.75);
172
+ line([-8,21+shift,5.4],[-5,16+shift,5.4],"edge",.75);
173
+ }
174
+ }
175
+ function part(at) {
176
+ const oct=[[-6,-4],[6,-4],[6,4],[4,6],[-4,6],[-6,4]];
177
+ slab(oct,0,5,at,"paper");
178
+ disk(add(at,[0,0,5.15]),X,Y,2.4,"recess","edge",.45);
179
+ for(const x of [-4,4])bolt(add(at,[x,0,5.25]),X,Y,.95);
180
+ }
181
+ function scanner(at, locked) {
182
+ const base=withZ(at,6.4);
183
+ const stroke=locked?"sensor":"fine";
184
+ for(const s of [-1,1])for(const q of [-1,1]){
185
+ line(add(base,[s*11,q*5,0]),add(base,[s*11,q*9,0]),stroke,.85,.25);
186
+ line(add(base,[s*11,q*9,0]),add(base,[s*7,q*9,0]),stroke,.85,.25);
187
+ }
188
+ }
189
+ function piston(anchor,pin,side) {
190
+ const d=sub(pin,anchor), axis=unit(d);
191
+ turnedPart(anchor,axis,side,[
192
+ [1,2.20],[2.8,2.20],[2.8,2.03],[13.1,2.03],[13.1,2.5],
193
+ [15.8,2.5,"metal"],[15.8,1.11],[len(d),1.11,"paper"],
194
+ ],{sectors:16,cap:"metal"});
195
+ for(const joint of [anchor,pin])body(add(joint,scale(side,-1.8)),add(joint,scale(side,1.8)),2.05,{sectors:12});
196
+ }
197
+ function ringBolts(at,u,v,r,count=6) {
198
+ for(const p of ring(at,u,v,r,count,Math.PI/6))bolt(p,u,v,1.08);
199
+ }
200
+
201
+ function actuatorTube(a,b,side,r) {
202
+ const extent=len(sub(b,a)),axis=unit(sub(b,a));
203
+ const collar=r+1.05;
204
+ const surface=turnedPart(a,axis,side,[
205
+ [0,r],[1.3,r],[1.3,collar],[3.2,collar,"metal"],[3.2,r],
206
+ [extent-3.2,r],[extent-3.2,collar],[extent-1.3,collar,"metal"],[extent-1.3,r],[extent,r],
207
+ ]);
208
+ for(const offset of [5,6.6,extent*.48-1.8,extent*.48,extent*.48+1.8,extent-6.6,extent-5])
209
+ face(surface([offset,r+.085]),null,"edge",.46,.22);
210
+ }
211
+ function joint(at,side,d,r,u,v) {
212
+ body(add(at,scale(side,-d)),add(at,scale(side,d)),r,{guide:u,cap:"paper"});
213
+ const near=add(at,scale(side,visible(side)?d+.15:-d-.15));
214
+ disk(near,u,v,r*.85,"metal","edge",.35);
215
+ ringBolts(near,u,v,r*.69);
216
+ disk(near,u,v,r*.36,"recess","edge",.62);
217
+ disk(near,u,v,r*.21,"paper","edge",.8);
218
+ }
219
+ function gripper(wrist,jaw,yaw) {
220
+ const at=(x,y,z)=>add(wrist,[x,y,z]);
221
+ body(wrist,at(0,0,-13),4.65,{cap:"paper"});
222
+ body(at(0,0,-6),at(0,0,-11),6.2,{cap:"dark-metal"});
223
+ const index=radial(X,Y,-yaw);
224
+ line(add(at(0,0,-6),scale(index,4.8)),add(at(0,0,-6),scale(index,6.1)),"ink",.85,.55);
225
+ slab(rect(-13,-3.8,13,3.8),-17,-13,wrist,"metal");
226
+ for(const y of [-3,3])body(at(-12,y,-19),at(12,y,-19),.94,{sectors:10,color:"paper"});
227
+ body(at(-12,4.1,-19),at(12,4.1,-19),1.0,{sectors:12,color:"dark-metal"});
228
+ const screwAngle=tau*(openGap-jaw)/2.4;
229
+ for(const sign of [-1,1]) {
230
+ let prev=null;
231
+ for(let j=0;j<=32;j++) {
232
+ const k=j/4,a=screwAngle+tau*k/2.4;
233
+ const n=[0,Math.cos(a),Math.sin(a)];
234
+ const p=at(sign*k,4.1+1.15*n[1],-19+1.15*n[2]);
235
+ if(prev&&visible(n))line(prev,p,"ink",.38,.21);
236
+ prev=p;
237
+ }
238
+ const x=sign*jaw;
239
+ slab(rect(x-1.6,-3.15,x+1.6,3.15),-22,-18,wrist,"dark-metal");
240
+ slab(rect(x-1.3,-2.8,x+1.3,2.8),-28,-21,wrist,"metal");
241
+ const pad=x-sign*1.35;
242
+ slab(rect(pad-.1,-2.25,pad+.1,2.25),-27.4,-23.25,wrist,"recess");
243
+ for(let i=0;i<3;i++)line(at(x-.8,2.9,-24-i),at(x+.8,2.9,-24-i),"fine",.4,.29);
244
+ }
245
+ }
246
+
247
+ function drawArm(t, reverse) {
248
+ const state=trajectory(t,reverse), pose=solve(state.position);
249
+ const {wrist,shoulder,elbow,upper,fore,side,radialAxis,yaw,bend}=pose;
250
+ const beforePickup=t<3.15, afterPlacement=t>=6.45;
251
+ const cargo=beforePickup?withZ(state.a,floor):afterPlacement?withZ(state.b,floor):add(wrist,[0,0,floor-gripZ]);
252
+ part(cargo);
253
+ if(t>0&&t<3.35)scanner(state.a,t>=2);
254
+ if(t>=5.55&&t<7.82)scanner(state.b,t>=6.45);
255
+
256
+ body([0,0,5],[0,0,11],25,{color:"dark-metal",cap:"metal"});
257
+ for(const p of ring([0,0,11.12],X,Y,21,8))bolt(p,X,Y,1.5);
258
+ body([0,0,11],[0,0,18],19,{cap:"paper"});
259
+ gear([0,0,18.16],X,Y,17.4,32,yaw);
260
+ body([0,0,18],[0,0,23],14,{cap:"paper"});
261
+ body([0,0,23],[0,0,43],10.6,{cap:"metal"});
262
+ body([0,0,24],[0,0,27],11.2,{color:"dark-metal"});
263
+ body([0,0,40],[0,0,44],11.75,{cap:"paper"});
264
+ const baseNotch=add([0,0,44.2],scale(radialAxis,8));
265
+ line(baseNotch,add(baseNotch,scale(radialAxis,3)),"ink",1.1,.38);
266
+ for(const sign of [-1,1]) {
267
+ const y=scale(side,sign*8.6);
268
+ body(add([0,0,36],y),add(shoulder,y),3.7,{cap:"dark-metal",sectors:14});
269
+ }
270
+
271
+ actuatorTube(add(shoulder,scale(upper,7)),add(elbow,scale(upper,-6)),side,7);
272
+ actuatorTube(add(elbow,scale(fore,6)),add(wrist,scale(fore,-5)),side,5.5);
273
+ const outward=side;
274
+ const lateral=scale(outward,13);
275
+ const anchor=add(add(shoulder,scale(radialAxis,-1)),add(scale(Z,-14),lateral));
276
+ const pin=add(add(shoulder,scale(upper,24)),lateral);
277
+ piston(anchor,pin,side);
278
+ const elbowAnchor=add(add(elbow,scale(upper,-21)),scale(outward,12));
279
+ const elbowPin=add(add(elbow,scale(fore,11)),scale(outward,12));
280
+ piston(elbowAnchor,elbowPin,side);
281
+
282
+ const planeV=unit(cross(outward,upper));
283
+ joint(shoulder,side,10,9,radialAxis,Z);
284
+ joint(elbow,side,9.5,8,upper,planeV);
285
+ joint(wrist,side,6,4.8,radialAxis,Z);
286
+
287
+ // The pair is mounted on the upper-arm bracket. Both pitch circles meet on its centerline.
288
+ const ringCenter=add(elbow,scale(outward,11.6));
289
+ const pinionCenter=add(ringCenter,scale(upper,-16.2));
290
+ const bracket=scale(outward,-2.4);
291
+ body(add(pinionCenter,bracket),add(ringCenter,bracket),3.7,{guide:outward,color:"dark-metal",sectors:12});
292
+ body(add(pinionCenter,scale(outward,-4)),pinionCenter,4.65,{guide:upper,color:"dark-metal"});
293
+ const drivenAngle=-bend;
294
+ gear(ringCenter,upper,planeV,10.8,24,drivenAngle);
295
+ gear(pinionCenter,upper,planeV,5.4,12,Math.PI/12-2*drivenAngle);
296
+ gripper(wrist,state.jaw,yaw);
297
+ }
298
+
299
+ function palette(ink, paper) {
300
+ const pixel = document.createElement("canvas");
301
+ pixel.width=pixel.height=1;
302
+ const sampler = pixel.getContext("2d", { willReadFrequently:true });
303
+ const rgb = value => {
304
+ sampler.fillStyle=value;
305
+ sampler.fillRect(0,0,1,1);
306
+ return Array.from(sampler.getImageData(0,0,1,1).data).slice(0,3);
307
+ };
308
+ const a=rgb(ink), b=rgb(paper);
309
+ const tone = amount => "rgb("+b.map((c,i)=>Math.round(c+(a[i]-c)*amount)).join(",")+")";
310
+ const colors={paper,ink,edge:tone(.82),fine:tone(.59),metal:tone(.11),
311
+ "dark-metal":tone(.25),recess:tone(.44),sensor:ink};
312
+ for(let i=0;i<7;i++) colors["shade"+i]=tone(.36-i*.048);
313
+ return colors;
314
+ }
315
+
316
+ function paint(context,colors) {
317
+ context.lineJoin="round";context.lineCap="round";
318
+ queue.sort((a,b)=>a.depth-b.depth);
319
+ for(const {points,fill,stroke,width} of queue) {
320
+ context.beginPath();context.moveTo(...project(points[0]));
321
+ for(let i=1;i<points.length;i++)context.lineTo(...project(points[i]));
322
+ if(fill){context.closePath();context.fillStyle=colors[fill];context.fill();}
323
+ if(stroke){context.strokeStyle=colors[stroke];context.lineWidth=width;context.stroke();}
324
+ }
325
+ queue.length=0;
326
+ }
327
+
328
+ function createDepthRenderer(context) {
329
+ const layer=document.createElement("canvas");
330
+ const gl=layer.getContext("webgl",{alpha:true,antialias:true,depth:true,premultipliedAlpha:false,preserveDrawingBuffer:true});
331
+ if(!gl)return null;
332
+ function shader(type,source) {
333
+ const compiled=gl.createShader(type);
334
+ gl.shaderSource(compiled,source);gl.compileShader(compiled);
335
+ return gl.getShaderParameter(compiled,gl.COMPILE_STATUS)?compiled:null;
336
+ }
337
+ const vertex=shader(gl.VERTEX_SHADER,
338
+ "attribute vec3 position; attribute vec3 color; varying vec3 ink; void main(){gl_Position=vec4(position,1.0);ink=color;}");
339
+ const fragment=shader(gl.FRAGMENT_SHADER,
340
+ "precision mediump float; varying vec3 ink; void main(){gl_FragColor=vec4(ink,1.0);}");
341
+ if(!vertex||!fragment)return null;
342
+ const program=gl.createProgram();
343
+ gl.attachShader(program,vertex);gl.attachShader(program,fragment);gl.linkProgram(program);
344
+ if(!gl.getProgramParameter(program,gl.LINK_STATUS))return null;
345
+ gl.useProgram(program);
346
+ gl.enable(gl.DEPTH_TEST);gl.depthFunc(gl.LEQUAL);
347
+ gl.bindBuffer(gl.ARRAY_BUFFER,gl.createBuffer());
348
+ for(const [name,offset] of [["position",0],["color",12]]){
349
+ const index=gl.getAttribLocation(program,name);
350
+ gl.enableVertexAttribArray(index);gl.vertexAttribPointer(index,3,gl.FLOAT,false,24,offset);
351
+ }
352
+ const pixel=document.createElement("canvas");pixel.width=pixel.height=1;
353
+ const sampler=pixel.getContext("2d",{willReadFrequently:true});
354
+ const rgb=new Map();
355
+ const colorFor=(key,colors)=>{
356
+ if(!rgb.has(key)){
357
+ sampler.fillStyle=colors[key]??key;sampler.fillRect(0,0,1,1);
358
+ const rgba=sampler.getImageData(0,0,1,1).data;
359
+ rgb.set(key,[rgba[0]/255,rgba[1]/255,rgba[2]/255]);
360
+ }
361
+ return rgb.get(key);
362
+ };
363
+ let stream=new Float32Array(65536),cursor=0;
364
+ function vertexAt(p,ink) {
365
+ if(cursor+6>stream.length){const next=new Float32Array(stream.length*2);next.set(stream);stream=next;}
366
+ stream[cursor++]=p[0];stream[cursor++]=p[1];stream[cursor++]=p[2];
367
+ stream[cursor++]=ink[0];stream[cursor++]=ink[1];stream[cursor++]=ink[2];
368
+ }
369
+ function triangle(a,b,c,ink) {vertexAt(a,ink);vertexAt(b,ink);vertexAt(c,ink);}
370
+ function frame(geometry,zoom,posX,posY,dpr,colors) {
371
+ if(gl.isContextLost())return false;
372
+ const {width:w,height:h}=context.canvas;
373
+ if(layer.width!==w||layer.height!==h){layer.width=w;layer.height=h;}
374
+ gl.viewport(0,0,w,h);
375
+ gl.clearColor(0,0,0,0);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);
376
+ cursor=0;
377
+ for(const {points,fill,stroke,width,bias} of geometry){
378
+ const vertices=points.map(p=>{
379
+ const [x,y]=project(p);
380
+ return [2*(x*zoom+posX)/w-1,1-2*(y*zoom+posY)/h,-(dot(p,camera)+bias*.05)/384];
381
+ });
382
+ if(fill){
383
+ const ink=colorFor(fill,colors);
384
+ if(vertices.length===4) {
385
+ triangle(vertices[0],vertices[1],vertices[2],ink);
386
+ triangle(vertices[0],vertices[2],vertices[3],ink);
387
+ } else {
388
+ const center=scale(vertices.reduce(add,[0,0,0]),1/vertices.length);
389
+ for(let i=0;i<vertices.length;i++)triangle(center,vertices[i],vertices[(i+1)%vertices.length],ink);
390
+ }
391
+ }
392
+ if(stroke){
393
+ const ink=colorFor(stroke,colors),count=fill?vertices.length:vertices.length-1;
394
+ for(let i=0;i<count;i++){
395
+ const a=vertices[i], b=vertices[(i+1)%vertices.length];
396
+ const dx=(b[0]-a[0])*w,dy=(b[1]-a[1])*h;
397
+ const distance=Math.hypot(dx,dy);
398
+ if(distance<.001)continue;
399
+ const thick=Math.max(.74*dpr,width*zoom),x=-dy/distance*thick/w,y=dx/distance*thick/h;
400
+ const forward=.00023;
401
+ const p=[a[0]-x,a[1]-y,a[2]-forward],q=[a[0]+x,a[1]+y,a[2]-forward];
402
+ const r=[b[0]-x,b[1]-y,b[2]-forward],s=[b[0]+x,b[1]+y,b[2]-forward];
403
+ triangle(p,q,r,ink);triangle(q,s,r,ink);
404
+ }
405
+ }
406
+ }
407
+ gl.bufferData(gl.ARRAY_BUFFER,stream.subarray(0,cursor),gl.DYNAMIC_DRAW);
408
+ gl.drawArrays(gl.TRIANGLES,0,cursor/6);
409
+ context.drawImage(layer,0,0);
410
+ return true;
411
+ }
412
+ return {frame,setColors:()=>rgb.clear()};
413
+ }
414
+ globalThis.ccdxToolArm = context => {
415
+ let key, platform, colors, zoom, left, top;
416
+ let depthView;
417
+ try { depthView=createDepthRenderer(context); } catch { /* Continuous 2D geometry is available without WebGL. */ }
418
+ staticPlate();
419
+ const plate=queue.splice(0);
420
+ return (_style,{time,width,height,dpr,ink,surface}) => {
421
+ const next=[width,height,dpr,ink,surface].join("|");
422
+ if(key!==next){
423
+ const {width:w,height:h}=context.canvas;
424
+ const size=Math.min((width-12)/254,(height-12)/180)*dpr;
425
+ if(!(size>0))return;
426
+ zoom=size;left=w/2-21*zoom;top=h/2-5*zoom;
427
+ colors=palette(ink,surface);
428
+ platform=null;depthView?.setColors();
429
+ key=next;
430
+ }
431
+ context.setTransform(1,0,0,1,0,0);
432
+ const elapsed=Math.max(0,time),cycle=Math.floor(elapsed/duration);
433
+ drawArm(elapsed-cycle*duration,cycle%2===1);
434
+ if(depthView?.frame([...plate,...queue],zoom,left,top,dpr,colors)){
435
+ queue.length=0;
436
+ return;
437
+ }
438
+ if(!platform){
439
+ const moving=queue.splice(0);
440
+ platform=document.createElement("canvas");
441
+ platform.width=context.canvas.width;platform.height=context.canvas.height;
442
+ const base=platform.getContext("2d");
443
+ base.setTransform(zoom,0,0,zoom,left,top);
444
+ queue.push(...plate);paint(base,colors);queue.push(...moving);
445
+ }
446
+ context.drawImage(platform,0,0);
447
+ context.setTransform(zoom,0,0,zoom,left,top);paint(context,colors);
448
+ };
449
+ };
450
+ })();
@@ -1,12 +1,14 @@
1
1
  (() => {
2
2
  const root = document.getElementById("tool-activity");if (!root) return;
3
3
  const el = id => document.getElementById(id), canvas = el("tool-canvas"), ctx = canvas.getContext?.("2d");
4
- const styles = new Set(["production", "clock", "assembly", "sorter", "gantry", "rotary", "off"]), storageKey = "ccdx.dashboard.toolMotionStyle";
4
+ const styles = new Set(["production", "clock", "assembly", "sorter", "gantry", "rotary", "arm", "off"]), storageKey = "ccdx.dashboard.toolMotionStyle";
5
5
  const pending = state => ["preparing", "waiting"].includes(state);
6
6
  const phrase = (key, values = {}) => globalThis.ccdxLanguage.format(key, values);
7
7
  const text = (id, key, values) => globalThis.ccdxLanguage.set(el(id), key, values);
8
8
  const state = { scene: "idle", style: "production" };
9
- const drawMachine = ctx && globalThis.ccdxToolMachines(ctx);
9
+ const dashboardScript = document.currentScript.src;
10
+ const renderers = new Map();
11
+ const rendererName = () => state.style === "arm" ? "arm" : "machines";
10
12
  try { const saved = localStorage.getItem(storageKey);if (styles.has(saved)) state.style = saved; } catch {}
11
13
  const motion = globalThis.matchMedia?.("(prefers-reduced-motion: reduce)") || { matches: false, addEventListener() {} };
12
14
  let records = [], fresh = false, supported = false, visible = true, raf = 0, last = 0, start = performance.now(), expiry = null;
@@ -22,6 +24,7 @@
22
24
  refreshAnimation();
23
25
  }
24
26
  function draw(now = performance.now()) {
27
+ const drawMachine = renderers.get(rendererName());
25
28
  if (!drawMachine || !box.width || !box.height) return;
26
29
  const dpr = Math.min(devicePixelRatio || 1, 1.5), width = box.width, height = box.height;
27
30
  const w = Math.round(width * dpr), h = Math.round(height * dpr);
@@ -39,9 +42,33 @@
39
42
  }
40
43
  function refreshAnimation() {
41
44
  cancelAnimationFrame(raf);raf = 0;
42
- root.dataset.paused = String(!shown() || motion.matches || !animating() || state.style === "off");
43
- if (!shown() || state.style === "off") return;
44
- draw();if (!motion.matches && animating()) raf = requestAnimationFrame(animate);
45
+ const ready = shown() && state.style !== "off" && renderers.get(rendererName());
46
+ const moving = Boolean(ready && !motion.matches && animating());
47
+ root.dataset.paused = String(!moving);
48
+ if (!ready) {
49
+ if (shown() && state.style !== "off" && ctx) {
50
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
51
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
52
+ }
53
+ return;
54
+ }
55
+ draw();if (moving) raf = requestAnimationFrame(animate);
56
+ }
57
+ function loadMachine() {
58
+ const name = rendererName();
59
+ if (!ctx || state.style === "off" || renderers.has(name)) return;
60
+ renderers.set(name, null);
61
+ const asset = new URL(dashboardScript);
62
+ asset.pathname = "/tool-activity-" + name + ".js";
63
+ const script = document.createElement("script");
64
+ script.src = asset.href;
65
+ script.addEventListener("load", () => {
66
+ const create = name === "arm" ? globalThis.ccdxToolArm : globalThis.ccdxToolMachines;
67
+ if (typeof create !== "function") return;
68
+ renderers.set(name, create(ctx));
69
+ if (rendererName() === name) refreshAnimation();
70
+ }, { once: true });
71
+ document.head.append(script);
45
72
  }
46
73
  function category(name) {
47
74
  const value = String(name || "").toLowerCase().split(/__|\./).at(-1);
@@ -56,6 +83,7 @@
56
83
  const sourceName = id => id === "github" ? "GitHub Copilot" : id === "m365" ? "Microsoft 365" : id === "google" ? "Google" : globalThis.ccdxConnectionNames?.[id] || phrase("flow_source_unknown");
57
84
  function render(force = false) {
58
85
  if (root.closest("[hidden]")) { signature = "";refreshAnimation();return; }
86
+ loadMachine();
59
87
  const time = performance.now();
60
88
  if (requestDeadline && time >= requestDeadline) { requests = [];requestDeadline = 0;fresh = false; }
61
89
  for (const row of records) if (row.until <= time && pending(row.state)) { row.state = "unknown";row.until = time + 300000; }
@@ -238,8 +238,12 @@ footer { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color:
238
238
  [hidden] { display: none !important; }
239
239
  .shell { max-width: 1520px; min-height: 100vh; display: grid; grid-template-columns: 204px minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr) auto; column-gap: 34px; padding: 0 28px; }
240
240
  .sidebar { grid-row: 1 / 4; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 28px 22px 24px 0; border-right: 1px solid var(--border); }
241
+ .sidebar-header { display: flex; align-items: center; gap: 12px; min-height: 44px; }
241
242
  .sidebar-brand { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; column-gap: 12px; color: var(--accent); text-decoration: none; font-size: 23px; font-weight: 750; letter-spacing: .04em; }
242
243
  .sidebar-brand > .status-icon, .sidebar-brand > .brand-name { grid-row: 1; }
244
+ .sidebar-toggle { color: var(--accent); }
245
+ .sidebar-toggle:hover { background: var(--option-hover); }
246
+ .sidebar-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
243
247
 
244
248
  .sidebar nav { display: flex; flex-direction: column; gap: 5px; margin-top: 28px; }
245
249
  .sidebar nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; font-size: 13px; border-left: 2px solid transparent; }
@@ -321,6 +325,26 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
321
325
  .section-actions > label { flex: 1 1 180px; }
322
326
  .section-actions select { max-width: 100%; }
323
327
  }
328
+ @media (min-width: 641px) and (max-width: 900px) {
329
+ .sidebar-header { gap: 8px; }
330
+ .sidebar-brand { column-gap: 8px; font-size: 21px; }
331
+ }
332
+ [data-sidebar-collapsed] .shell { grid-template-columns: 64px minmax(0, 1fr); column-gap: 20px; }
333
+ [data-sidebar-collapsed] .sidebar { padding-inline-end: 8px; }
334
+ [data-sidebar-collapsed] .sidebar-header { justify-content: center; }
335
+ [data-sidebar-collapsed] :is(.sidebar-brand, .nav-group) { display: none; }
336
+ [data-sidebar-collapsed] .sidebar-chevron { transform: scaleX(-1); transform-origin: 14.5px 12px; }
337
+ [data-sidebar-collapsed] .sidebar nav a { position: relative; justify-content: center; gap: 0; padding-inline: 0; min-height: 36px; border-inline-end: 2px solid transparent; }
338
+ [data-sidebar-collapsed] .sidebar nav a > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
339
+ @media (max-width: 640px) {
340
+ [data-sidebar-collapsed] .sidebar { padding-inline-end: 0; }
341
+ [data-sidebar-collapsed] .sidebar-header { justify-content: flex-start; }
342
+ [data-sidebar-collapsed] .sidebar nav a { width: 36px; }
343
+ }
344
+ @media (pointer: coarse) {
345
+ .sidebar-toggle { min-width: 44px; min-height: 44px; }
346
+ [data-sidebar-collapsed] .sidebar nav a { min-width: 44px; min-height: 44px; }
347
+ }
324
348
 
325
349
  /* Independent color palettes; green remains the unchanged default. */
326
350
  :root[data-palette="klein"][data-theme="light"] {
@@ -58,6 +58,33 @@ element("refresh").addEventListener("click", () => {
58
58
  });
59
59
  document.querySelector(".sidebar-brand").addEventListener("click", animateLogo);
60
60
 
61
+ const sidebarPreference = "ccdx.dashboard.sidebar";
62
+ const sidebarToggle = element("sidebar-toggle");
63
+ const sidebarLinks = element("sidebar-navigation").querySelectorAll("a");
64
+ function setSidebarCollapsed(collapsed) {
65
+ if (collapsed) document.documentElement.dataset.sidebarCollapsed = "true";
66
+ else delete document.documentElement.dataset.sidebarCollapsed;
67
+ sidebarToggle.setAttribute("aria-expanded", String(!collapsed));
68
+ const label = collapsed ? "sidebar_expand" : "sidebar_collapse";
69
+ localize(sidebarToggle, label, {}, "aria-label");
70
+ localize(sidebarToggle, label, {}, "title");
71
+ for (const link of sidebarLinks) {
72
+ const name = link.querySelector("span");
73
+ localize(link, collapsed ? name.dataset.i18n || name.textContent : "", {}, "title");
74
+ }
75
+ }
76
+ try { setSidebarCollapsed(localStorage.getItem(sidebarPreference) === "collapsed"); }
77
+ catch { setSidebarCollapsed(false); }
78
+ sidebarToggle.addEventListener("click", () => {
79
+ const collapsed = sidebarToggle.getAttribute("aria-expanded") === "true";
80
+ setSidebarCollapsed(collapsed);
81
+ try { localStorage.setItem(sidebarPreference, collapsed ? "collapsed" : "expanded"); }
82
+ catch { /* The tab still keeps its own choice. */ }
83
+ });
84
+ globalThis.addEventListener?.("storage", event => {
85
+ if (event.key === sidebarPreference) setSidebarCollapsed(event.newValue === "collapsed");
86
+ });
87
+
61
88
  const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
62
89
  const animationView = globalThis.ccdxViewBoundary.create("animation-settings", () => globalThis.ccdxDashboardAnimation.create({ element, phrase, localize, text, reducedMotion,
63
90
  getRefresh: () => dashboardRefresh, document }), ["apply", "load", "save", "sync", "stop", "select"]);
package/src/dashboard.mjs CHANGED
@@ -18,6 +18,7 @@ const ASSETS = new Map([
18
18
  ["/activity.js", ["./dashboard/activity.js", "text/javascript; charset=utf-8"]],
19
19
  ["/flow.js", ["./dashboard/flow.js", "text/javascript; charset=utf-8"]],
20
20
  ["/tool-activity-machines.js", ["./dashboard/tool-activity-machines.js", "text/javascript; charset=utf-8"]],
21
+ ["/tool-activity-arm.js", ["./dashboard/tool-activity-arm.js", "text/javascript; charset=utf-8"]],
21
22
  ["/tool-activity.js", ["./dashboard/tool-activity.js", "text/javascript; charset=utf-8"]],
22
23
  ["/usage.js", ["./dashboard/usage.js", "text/javascript; charset=utf-8"]],
23
24
  ["/context.js", ["./dashboard/context.js", "text/javascript; charset=utf-8"]],
@@ -43,8 +44,9 @@ function assets() {
43
44
  })).then(async entries => {
44
45
  const installed = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
45
46
  if (installed.version !== ADAPTER_VERSION) throw new Error("Dashboard files changed; restart CCDX before loading the new dashboard");
46
- // Shared globals and their consumers execute together, without partial script loading.
47
- const scripts = entries.filter(([name, asset]) => asset.type.startsWith("text/javascript") && !["/language.js", "/theme.js"].includes(name));
47
+ // The Requests view loads its drawing code separately. Shared view code remains bundled.
48
+ const scripts = entries.filter(([name, asset]) => asset.type.startsWith("text/javascript") &&
49
+ !["/language.js", "/theme.js", "/tool-activity-machines.js", "/tool-activity-arm.js"].includes(name));
48
50
  const body = Buffer.concat(scripts.flatMap(([name, asset]) => [Buffer.from("// " + name + "\n"), asset.body, Buffer.from("\n;\n")]));
49
51
  return new Map([...entries, ["/dashboard.js", { body, type: "text/javascript; charset=utf-8", etag: `"${createHash("sha256").update(body).digest("hex")}"` }]]);
50
52
  }).catch(error => { bundle = null;throw error; });
@@ -1,4 +1,4 @@
1
- export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/live.js", "/time.js", "/animation.js", "/status.js", "/view-boundary.js", "/activity.js", "/flow.js", "/usage.js", "/context.js", "/ui.js", "/console.js", "/updates.js", "/preferences.js", "/features.js", "/icons.js", "/disclosure.js", "/tools.js", "/connections.js", "/privacy.js"]);
1
+ export const DASHBOARD_PATHS = new Set(["/", "/ui.css", "/theme.js", "/language.js", "/refresh.js", "/live.js", "/time.js", "/animation.js", "/status.js", "/view-boundary.js", "/activity.js", "/flow.js", "/tool-activity-machines.js", "/tool-activity-arm.js", "/usage.js", "/context.js", "/ui.js", "/console.js", "/updates.js", "/preferences.js", "/features.js", "/icons.js", "/disclosure.js", "/tools.js", "/connections.js", "/privacy.js"]);
2
2
  export const DASHBOARD_API_PATHS = new Set(["/_ccdx/ui/animation", "/_ccdx/ui/models/live", "/_ccdx/ui/usage", "/_ccdx/ui/auth", "/_ccdx/ui/providers", "/_ccdx/ui/settings", "/_ccdx/ui/m365/accounts", "/_ccdx/ui/updates", "/_ccdx/ui/account", "/_ccdx/ui/checks", "/_ccdx/ui/connections", "/_ccdx/ui/context", "/_ccdx/ui/privacy"]);
3
3
 
4
4
  DASHBOARD_PATHS.add("/gemini.js");