codex-copilot-dx 1.4.22 → 1.4.24

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.
@@ -0,0 +1,39 @@
1
+ export const DASHBOARD_ASSETS = new Map([
2
+ ["/", ["./dashboard/index.html", "text/html; charset=utf-8"]],
3
+ ["/ui.css", ["./dashboard/ui.css", "text/css; charset=utf-8"]],
4
+ ["/language.js", ["./dashboard/language.js", "text/javascript; charset=utf-8"]],
5
+ ["/theme.js", ["./dashboard/theme.js", "text/javascript; charset=utf-8"]],
6
+ ["/refresh.js", ["./dashboard/refresh.js", "text/javascript; charset=utf-8"]],
7
+ ["/live.js", ["./dashboard/live.js", "text/javascript; charset=utf-8"]],
8
+ ["/icons.js", ["./dashboard/icons.js", "text/javascript; charset=utf-8"]],
9
+ ["/disclosure.js", ["./dashboard/disclosure.js", "text/javascript; charset=utf-8"]],
10
+ ["/time.js", ["./dashboard/time.js", "text/javascript; charset=utf-8"]],
11
+ ["/view-boundary.js", ["./dashboard/view-boundary.js", "text/javascript; charset=utf-8"]],
12
+ ["/status.js", ["./dashboard/status.js", "text/javascript; charset=utf-8"]],
13
+ ["/activity.js", ["./dashboard/activity.js", "text/javascript; charset=utf-8"]],
14
+ ["/flow.js", ["./dashboard/flow.js", "text/javascript; charset=utf-8"]],
15
+ ["/tool-activity-machines.js", ["./dashboard/tool-activity-machines.js", "text/javascript; charset=utf-8"]],
16
+ ["/tool-activity-arm.js", ["./dashboard/tool-activity-arm.js", "text/javascript; charset=utf-8"]],
17
+ ["/tool-activity-warehouse.js", ["./dashboard/tool-activity-warehouse.js", "text/javascript; charset=utf-8"]],
18
+ ["/tool-activity.js", ["./dashboard/tool-activity.js", "text/javascript; charset=utf-8"]],
19
+ ["/usage.js", ["./dashboard/usage.js", "text/javascript; charset=utf-8"]],
20
+ ["/context.js", ["./dashboard/context.js", "text/javascript; charset=utf-8"]],
21
+ ["/updates.js", ["./dashboard/updates.js", "text/javascript; charset=utf-8"]],
22
+ ["/animation.js", ["./dashboard/animation.js", "text/javascript; charset=utf-8"]],
23
+ ["/ui.js", ["./dashboard/ui.js", "text/javascript; charset=utf-8"]],
24
+ ["/preferences.js", ["./dashboard/preferences.js", "text/javascript; charset=utf-8"]],
25
+ ["/bark.js", ["./dashboard/bark.js", "text/javascript; charset=utf-8"]],
26
+ ["/features.js", ["./dashboard/features.js", "text/javascript; charset=utf-8"]],
27
+ ["/applications.js", ["./dashboard/applications.js", "text/javascript; charset=utf-8"]],
28
+ ["/console.js", ["./dashboard/console.js", "text/javascript; charset=utf-8"]],
29
+ ["/tools.js", ["./dashboard/tools.js", "text/javascript; charset=utf-8"]],
30
+ ["/connections-loader.js", ["./dashboard/connections-loader.js", "text/javascript; charset=utf-8"]],
31
+ ["/connections.js", ["./dashboard/connections.js", "text/javascript; charset=utf-8"]],
32
+ ["/privacy.js", ["./dashboard/privacy.js", "text/javascript; charset=utf-8"]],
33
+ ["/gemini.js", ["./dashboard/gemini.js", "text/javascript; charset=utf-8"]],
34
+ ]);
35
+ const STANDALONE = new Set(["/language.js", "/theme.js", "/connections.js",
36
+ "/tool-activity-machines.js", "/tool-activity-arm.js", "/tool-activity-warehouse.js"]);
37
+ export const DASHBOARD_BUNDLE_ASSETS = [...DASHBOARD_ASSETS].filter(([name, [, type]]) =>
38
+ type.startsWith("text/javascript") && !STANDALONE.has(name)).map(([name]) => name);
39
+ export const DASHBOARD_PATHS = new Set([...DASHBOARD_ASSETS.keys(), "/dashboard.js"]);
package/src/dashboard.mjs CHANGED
@@ -2,55 +2,36 @@ import { readFile } from "node:fs/promises";
2
2
  import { isLoopbackAddress, isLoopbackHostHeader } from "./security.mjs";
3
3
  import { createHash } from "node:crypto";
4
4
  import { ADAPTER_VERSION } from "./running-adapter.mjs";
5
+ import { DASHBOARD_ASSETS, DASHBOARD_BUNDLE_ASSETS } from "./dashboard-assets.mjs";
5
6
 
6
- const ASSETS = new Map([
7
- ["/", ["./dashboard/index.html", "text/html; charset=utf-8"]],
8
- ["/ui.css", ["./dashboard/ui.css", "text/css; charset=utf-8"]],
9
- ["/language.js", ["./dashboard/language.js", "text/javascript; charset=utf-8"]],
10
- ["/theme.js", ["./dashboard/theme.js", "text/javascript; charset=utf-8"]],
11
- ["/refresh.js", ["./dashboard/refresh.js", "text/javascript; charset=utf-8"]],
12
- ["/live.js", ["./dashboard/live.js", "text/javascript; charset=utf-8"]],
13
- ["/icons.js", ["./dashboard/icons.js", "text/javascript; charset=utf-8"]],
14
- ["/disclosure.js", ["./dashboard/disclosure.js", "text/javascript; charset=utf-8"]],
15
- ["/time.js", ["./dashboard/time.js", "text/javascript; charset=utf-8"]],
16
- ["/view-boundary.js", ["./dashboard/view-boundary.js", "text/javascript; charset=utf-8"]],
17
- ["/status.js", ["./dashboard/status.js", "text/javascript; charset=utf-8"]],
18
- ["/activity.js", ["./dashboard/activity.js", "text/javascript; charset=utf-8"]],
19
- ["/flow.js", ["./dashboard/flow.js", "text/javascript; charset=utf-8"]],
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"]],
22
- ["/tool-activity.js", ["./dashboard/tool-activity.js", "text/javascript; charset=utf-8"]],
23
- ["/usage.js", ["./dashboard/usage.js", "text/javascript; charset=utf-8"]],
24
- ["/context.js", ["./dashboard/context.js", "text/javascript; charset=utf-8"]],
25
- ["/updates.js", ["./dashboard/updates.js", "text/javascript; charset=utf-8"]],
26
- ["/animation.js", ["./dashboard/animation.js", "text/javascript; charset=utf-8"]],
27
- ["/ui.js", ["./dashboard/ui.js", "text/javascript; charset=utf-8"]],
28
- ["/preferences.js", ["./dashboard/preferences.js", "text/javascript; charset=utf-8"]],
29
- ["/bark.js", ["./dashboard/bark.js", "text/javascript; charset=utf-8"]],
30
- ["/features.js", ["./dashboard/features.js", "text/javascript; charset=utf-8"]],
31
- ["/applications.js", ["./dashboard/applications.js", "text/javascript; charset=utf-8"]],
32
- ["/console.js", ["./dashboard/console.js", "text/javascript; charset=utf-8"]],
33
- ["/tools.js", ["./dashboard/tools.js", "text/javascript; charset=utf-8"]],
34
- ["/connections.js", ["./dashboard/connections.js", "text/javascript; charset=utf-8"]],
35
- ["/privacy.js", ["./dashboard/privacy.js", "text/javascript; charset=utf-8"]],
36
- ["/gemini.js", ["./dashboard/gemini.js", "text/javascript; charset=utf-8"]],
37
- ]);
38
- let bundle;
39
- function assets() {
40
- bundle ||= Promise.all([...ASSETS].map(async ([name, [file, type]]) => {
41
- let body = await readFile(new URL(file, import.meta.url));
42
- if (name === "/") body = Buffer.from(body.toString().replace(/(src|href)="(\/[a-z-]+\.(?:js|css))"/g, `$1="$2?v=${ADAPTER_VERSION}"`));
43
- return [name, { body, type, etag: `"${createHash("sha256").update(body).digest("hex")}"` }];
44
- })).then(async entries => {
45
- const installed = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
46
- if (installed.version !== ADAPTER_VERSION) throw new Error("Dashboard files changed; restart CCDX before loading the new dashboard");
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));
50
- const body = Buffer.concat(scripts.flatMap(([name, asset]) => [Buffer.from("// " + name + "\n"), asset.body, Buffer.from("\n;\n")]));
51
- return new Map([...entries, ["/dashboard.js", { body, type: "text/javascript; charset=utf-8", etag: `"${createHash("sha256").update(body).digest("hex")}"` }]]);
52
- }).catch(error => { bundle = null;throw error; });
53
- return bundle;
7
+ const loaded = new Map();
8
+ let versionCheck;
9
+ function checkVersion() {
10
+ versionCheck ||= readFile(new URL("../package.json", import.meta.url), "utf8").then(text => {
11
+ if (JSON.parse(text).version !== ADAPTER_VERSION) throw new Error("Dashboard files changed; restart CCDX before loading the new dashboard");
12
+ }).finally(() => { versionCheck = null; });
13
+ return versionCheck;
14
+ }
15
+
16
+ function asset(name) {
17
+ if (!loaded.has(name)) loaded.set(name, (async () => {
18
+ await checkVersion();
19
+ let body, type;
20
+ if (name === "/dashboard.js") {
21
+ const files = await Promise.all(DASHBOARD_BUNDLE_ASSETS.map(asset));
22
+ body = Buffer.concat(files.flatMap(({ body }, i) => [Buffer.from("// " + DASHBOARD_BUNDLE_ASSETS[i] + "\n"), body, Buffer.from("\n;\n")]));
23
+ type = "text/javascript; charset=utf-8";
24
+ } else {
25
+ const [file, contentType] = DASHBOARD_ASSETS.get(name);
26
+ body = await readFile(new URL(file, import.meta.url));
27
+ type = contentType;
28
+ if (name === "/") body = Buffer.from(body.toString().replace(/(src|href)="(\/[a-z-]+\.(?:js|css))"/g, `$1="$2?v=${ADAPTER_VERSION}"`));
29
+ }
30
+ // A cold asset may be requested after the on-disk package was replaced.
31
+ await checkVersion();
32
+ return { body, type, etag: `"${createHash("sha256").update(body).digest("hex")}"` };
33
+ })().catch(error => { loaded.delete(name); throw error; }));
34
+ return loaded.get(name);
54
35
  }
55
36
 
56
37
  export async function serveDashboard(req, res, pathname) {
@@ -66,7 +47,7 @@ export async function serveDashboard(req, res, pathname) {
66
47
  if (version && version !== ADAPTER_VERSION) {
67
48
  res.writeHead(409, { "Content-Type": "text/plain; charset=utf-8", "Cache-Control": "no-store" });res.end("Dashboard version changed. Reload this page.");return;
68
49
  }
69
- const { body, type: contentType, etag } = (await assets()).get(pathname);
50
+ const { body, type: contentType, etag } = await asset(pathname);
70
51
  const unchanged = pathname !== "/" && String(req.headers?.["if-none-match"] || "").split(/\s*,\s*/).includes(etag);
71
52
  res.writeHead(unchanged ? 304 : 200, {
72
53
  "Content-Type": contentType,
@@ -3,20 +3,31 @@ import path from "node:path";
3
3
  import os from "node:os";
4
4
  import {execFile} from "node:child_process";
5
5
  import {promisify} from "node:util";
6
+ import { inspectWindowsAntigravity, windowsAntigravityEnvironment, windowsAntigravityPath } from "./windows-antigravity-app.mjs";
7
+ import { googleMacTeam, macAntigravityBundles, macAntigravityBundlePaths } from "./macos-antigravity-app.mjs";
6
8
 
7
9
  const execute=promisify(execFile);
8
10
 
9
- export async function inspectGeminiApp({platform=process.platform,app="/Applications/Gemini.app",exec=execute,exists=fs.existsSync}={}) {
11
+ export async function inspectGeminiApp({platform=process.platform,app,home=os.homedir(),env=process.env,exec=execute,exists=fs.existsSync}={}) {
12
+ if(platform==="win32"){
13
+ const state=await inspectWindowsAntigravity({env,exec,app});
14
+ return !app&&state.app?inspectWindowsAntigravity({env,exec,app:state.app}):state;
15
+ }
10
16
  if(platform!=="darwin")return {status:"unsupported"};
17
+ app??=macAntigravityBundlePaths(home).find(candidate=>exists(path.join(candidate,"Contents/Info.plist")));
18
+ if(!app)return {status:"not_installed"};
19
+ const bundle=macAntigravityBundles[path.basename(app)];
20
+ if(!bundle)throw new Error("Unrecognized Antigravity App identity");
11
21
  const metadata=path.join(app,"Contents/Info.plist");
12
22
  if(!exists(metadata))return {status:"not_installed"};
13
23
  const result=await exec("/usr/bin/plutil",["-convert","json","-o","-",metadata],{encoding:"utf8",timeout:3000,maxBuffer:65536});
14
24
  const info=JSON.parse(String(result.stdout??result));
15
- if(info.CFBundleIdentifier!=="com.google.GeminiMacOS"||info.CFBundleExecutable!=="Gemini")throw new Error("Unrecognized Gemini App identity");
16
- const helper=path.join(app,"Contents/Helpers/agy");
25
+ if(info.CFBundleIdentifier!==bundle.identifier||info.CFBundleExecutable!==bundle.executable)throw new Error("Unrecognized Antigravity App identity");
26
+ const helper=path.join(app,bundle.helper);
17
27
  if(!exists(helper))return {status:"antigravity_unavailable"};
18
- await exec("/usr/bin/codesign",["--verify","--deep","--strict","-R",'=identifier "com.google.GeminiMacOS" and anchor apple generic',app],{encoding:"utf8",timeout:15000,maxBuffer:65536});
19
- const executable=path.join(app,"Contents/MacOS/Gemini");
28
+ await exec("/usr/bin/codesign",["--verify","--deep","--strict","-R",
29
+ `=identifier "${bundle.identifier}" and anchor apple generic and certificate leaf[subject.OU] = "${googleMacTeam}"`,app],{encoding:"utf8",timeout:15000,maxBuffer:65536});
30
+ const executable=path.join(app,"Contents/MacOS",bundle.executable);
20
31
  const processes=await exec("/bin/ps",["-axo","pid=,comm="],{encoding:"utf8",timeout:3000,maxBuffer:4*1024*1024});
21
32
  const pids=String(processes.stdout??processes).split("\n").flatMap(line=>{const match=/^\s*(\d+)\s+(.+?)\s*$/.exec(line);return match?.[2]===executable?[Number(match[1])]:[]});
22
33
  return {status:pids.length>1?"multiple":pids.length?"running":"stopped",app,executable,helper,version:info.CFBundleShortVersionString,pids};
@@ -24,12 +35,17 @@ export async function inspectGeminiApp({platform=process.platform,app="/Applicat
24
35
 
25
36
  // A launch plan is reviewable without changing files, credentials, or running apps.
26
37
  // A prepared environment is not evidence that the App has adopted the route.
27
- export function planGeminiAppLaunch(state,{cloudCodeUrl,env=process.env,home=os.homedir(),managedGateway=false}={}) {
38
+ export function planGeminiAppLaunch(state,{cloudCodeUrl,env=process.env,home=os.homedir(),platform=process.platform,managedGateway=false}={}) {
28
39
  if(!["running","stopped","multiple"].includes(state?.status))return {status:state?.status||"unknown"};
29
- if(state.status==="stopped"&&!["/Applications/Gemini.app",path.join(home,"Applications/Gemini.app")].includes(state.app))throw new Error("Unrecognized Gemini App location");
30
- const url=new URL(cloudCodeUrl);
31
- if(url.protocol!=="http:"||url.hostname!=="127.0.0.1"||!url.port||Number(url.port)<1||url.username||url.password||url.search||url.hash)throw new Error("Gemini route must use a local CCDX endpoint");
32
- if(managedGateway||Object.entries(env).some(([key,value])=>key.startsWith("AGY_LLM_GATEWAY_")&&value)||env.CLOUD_CODE_URL&&env.CLOUD_CODE_URL!==url.href)return {status:"route_conflict"};
40
+ if(state.status==="stopped"&&!(platform==="win32"?windowsAntigravityPath(state.app):
41
+ macAntigravityBundlePaths(home).includes(state.app)))throw new Error("Unrecognized Gemini App location");
42
+ const url=cloudCodeUrl===undefined?null:new URL(cloudCodeUrl);
43
+ if(url&&(url.protocol!=="http:"||url.hostname!=="127.0.0.1"||!url.port||Number(url.port)<1||url.username||url.password||url.search||url.hash))throw new Error("Gemini route must use a local CCDX endpoint");
44
+ if(url&&(managedGateway||platform==="win32"&&state.wsl||Object.entries(env).some(([name,value])=>{
45
+ const key=name.toUpperCase();
46
+ return Boolean(value)&&(key.startsWith("AGY_LLM_GATEWAY_")||key==="CLOUD_CODE_URL"&&value!==url.href||platform==="win32"&&key==="ANTIGRAVITY_WSL_DISTRO");
47
+ })))return {status:"route_conflict"};
33
48
  if(state.status!=="stopped")return {status:state.status==="multiple"?"multiple":"needs_app_relaunch",pids:[...state.pids]};
34
- return {status:"prepared",command:"/usr/bin/open",args:["-a",state.app,"--env","CLOUD_CODE_URL="+url.href]};
49
+ if(platform==="win32")return {status:"prepared",command:state.app,args:[],environment:windowsAntigravityEnvironment(env,url?.href)};
50
+ return {status:"prepared",command:"/usr/bin/open",args:["-a",state.app,...(url?["--env","CLOUD_CODE_URL="+url.href]:[])]};
35
51
  }
@@ -0,0 +1,13 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+
4
+ export const macAntigravityBundles = {
5
+ "Gemini.app": { identifier: "com.google.GeminiMacOS", executable: "Gemini", helper: "Contents/Helpers/agy" },
6
+ "Antigravity.app": { identifier: "com.google.antigravity", executable: "Antigravity", helper: "Contents/Resources/bin/language_server" },
7
+ };
8
+ export const googleMacTeam = "EQHXZ8M8AV";
9
+
10
+ export function macAntigravityBundlePaths(home = os.homedir()) {
11
+ const names=Object.keys(macAntigravityBundles);
12
+ return [...names.map(name=>"/Applications/"+name),...names.map(name=>path.join(home,"Applications",name))];
13
+ }
@@ -1,8 +1,8 @@
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"]);
1
+ import { DASHBOARD_PATHS } from "./dashboard-assets.mjs";
2
+
3
+ export { DASHBOARD_PATHS };
2
4
  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
5
 
4
- DASHBOARD_PATHS.add("/gemini.js");
5
- DASHBOARD_PATHS.add("/dashboard.js");
6
6
  DASHBOARD_API_PATHS.add("/_ccdx/ui/gemini");
7
7
 
8
8
  export function isOptionalRoute(method, pathname) {
@@ -118,10 +118,14 @@ export function createApiProvider({ config, secrets, env = process.env, platform
118
118
  const recovery = cooldown?.enter();let observed = false;
119
119
  try {
120
120
  const transport = !closed && network && (network.healthy?.() ?? true) ? network : await getNetwork(options.signal);
121
+ const generation = api === "gemini" ? body?.generationConfig : undefined;
122
+ const thinkingLevel = generation?.thinkingConfig?.thinkingLevel;
121
123
  const result = await sourceTransport(options, { send: transport.fetch, receiver: transport, args: [url, { method: body ? "POST" : "GET", headers, body: serialized, signal: options.signal }],
122
124
  model: requestModel, bodyText: serialized, stream, observe: Boolean(body && options.observeUpstream !== false),
123
- evidence: body && !options.countTokens ? { max_output_tokens_sent: api === "messages" ? body.max_tokens : api === "chat" ? body.max_completion_tokens : body.max_output_tokens,
124
- reasoning_effort_sent: api === "messages" ? body.output_config?.effort : api === "chat" ? body.reasoning_effort : body.reasoning?.effort } : undefined });
125
+ evidence: body && !options.countTokens ? { max_output_tokens_sent: api === "messages" ? body.max_tokens : api === "chat" ? body.max_completion_tokens :
126
+ api === "gemini" ? generation?.maxOutputTokens : body.max_output_tokens,
127
+ reasoning_effort_sent: api === "messages" ? body.output_config?.effort : api === "chat" ? body.reasoning_effort :
128
+ api === "gemini" ? typeof thinkingLevel === "string" ? thinkingLevel.toLowerCase() : undefined : body.reasoning?.effort } : undefined });
125
129
  const temporary = result.status === 502 || result.status === 503 || result.status === 504;
126
130
  let retryAfterMs = 0;
127
131
  if (temporary) { const retry = result.headers.get("retry-after");retryAfterMs = /^\d{1,8}$/.test(retry || "") ? Number(retry) * 1000 : Math.max(0, Date.parse(retry) - now()); }
@@ -4,6 +4,7 @@ import { chatCompletions } from "./copilot.mjs";
4
4
  import { webStreamLines } from "./stream.mjs";
5
5
  import { cancelSourceResponse, sourceResponseAccepted, sourceResponseFailed } from "./source-response.mjs";
6
6
  import { normalizeCallLessToolOutputs } from "./responses-tool-output.mjs";
7
+ import { chatOutputParts } from "./chat-output-parts.mjs";
7
8
  import {
8
9
  abortErrorStatusCode,
9
10
  isAbortLikeError,
@@ -322,7 +323,10 @@ export function chatToResponses(chatResp, model, { toolChoice, toolAdapter } = {
322
323
  const name = call?.function?.name || "";
323
324
  return terminal.status === "completed" ? !allowed.has(name) : name && ![...allowed].some(candidate => candidate.startsWith(name));
324
325
  }) || terminal.status === "completed" && toolChoice.allowed_tools.mode === "required" && !msg?.tool_calls?.length)) throw disallowedUpstreamTool();
325
- if (msg?.content) output.push({ type: "message", id: `msg_${uid()}`, role: "assistant", status: terminal.status, content: [{ type: "output_text", text: msg.content }] });
326
+ for (const { text, thought } of chatOutputParts(msg?.content)) {
327
+ output.push(thought ? { type: "reasoning", id: `rs_${uid()}`, summary: [{ type: "summary_text", text }] }
328
+ : { type: "message", id: `msg_${uid()}`, role: "assistant", status: terminal.status, content: [{ type: "output_text", text }] });
329
+ }
326
330
  if (msg?.tool_calls) for (const tc of msg.tool_calls) output.push(toolAdapter
327
331
  ? toolAdapter.outputItem({ id: tc.id, callId: tc.id, name: tc.function?.name, arguments: tc.function?.arguments }, terminal.status)
328
332
  : { type: "function_call", id: tc.id, call_id: tc.id, name: tc.function.name, arguments: tc.function.arguments, status: terminal.status });
@@ -400,6 +404,7 @@ export async function forwardToChat(chatReq, emitEvent, onDone, onError, options
400
404
  let finishReason = null;
401
405
  let fullText = "";
402
406
  let messageItem = null;
407
+ let reasoningItem = null;
403
408
  let nextOutputIndex = 0;
404
409
  let usage = { input_tokens: 0, output_tokens: 0, total_tokens: 0 };
405
410
  const toolCalls = new Map();
@@ -462,11 +467,32 @@ export async function forwardToChat(chatReq, emitEvent, onDone, onError, options
462
467
  return { tool, created: true };
463
468
  };
464
469
 
470
+ async function appendReasoning(text) {
471
+ if (!reasoningItem) {
472
+ reasoningItem = { id: `rs_${uid()}`, outputIndex: nextOutputIndex++, text: "" };
473
+ const { id, outputIndex } = reasoningItem;
474
+ await emitEvent("response.output_item.added", { output_index: outputIndex, item: { type:"reasoning", id, summary:[] } });
475
+ await emitEvent("response.reasoning_summary_part.added", { item_id:id, output_index:outputIndex, summary_index:0, part:{ type:"summary_text", text:"" } });
476
+ }
477
+ reasoningItem.text += text;
478
+ await emitEvent("response.reasoning_summary_text.delta", { item_id:reasoningItem.id, output_index:reasoningItem.outputIndex, summary_index:0, delta:text });
479
+ }
480
+
465
481
  const emitTerminal = async () => {
466
482
  const terminal = chatTerminal(finishReason);
467
483
  if (allowed && terminal.status === "completed" && ([...toolCalls.values()].some(tool => !allowed.has(tool.name)) || allowedRequired && !toolCalls.size)) throw disallowedUpstreamTool();
468
- if (!messageItem && toolCalls.size === 0) await ensureMessageItem();
484
+ if (!messageItem && !reasoningItem && toolCalls.size === 0) await ensureMessageItem();
469
485
  const output = [];
486
+ if (reasoningItem) {
487
+ const { id, text, outputIndex } = reasoningItem;
488
+ const part = { type:"summary_text", text };
489
+ const item = { type:"reasoning", id, summary:[part] };
490
+ const details = { item_id:id, output_index:outputIndex, summary_index:0 };
491
+ await emitEvent("response.reasoning_summary_text.done", { ...details, text });
492
+ await emitEvent("response.reasoning_summary_part.done", { ...details, part });
493
+ await emitEvent("response.output_item.done", { output_index:outputIndex, item });
494
+ output[outputIndex] = item;
495
+ }
470
496
  if (messageItem) {
471
497
  const item = {
472
498
  type: "message",
@@ -556,11 +582,15 @@ export async function forwardToChat(chatReq, emitEvent, onDone, onError, options
556
582
  if (choice?.finish_reason) finishReason = choice.finish_reason;
557
583
  const delta = choice?.delta;
558
584
  if (!delta) continue;
559
- if (isChatOutputDelta(delta)) markPerformanceOutput();
560
- if (delta.content) {
561
- const message = await ensureMessageItem();
562
- fullText += delta.content;
563
- await emitEvent("response.output_text.delta", { output_index: message.outputIndex, content_index: 0, delta: delta.content });
585
+ const parts = chatOutputParts(delta.content);
586
+ if (parts.length || isChatOutputDelta(delta)) markPerformanceOutput();
587
+ for (const { text, thought } of parts) {
588
+ if (thought) await appendReasoning(text);
589
+ else {
590
+ const message = await ensureMessageItem();
591
+ fullText += text;
592
+ await emitEvent("response.output_text.delta", { output_index: message.outputIndex, content_index: 0, delta: text });
593
+ }
564
594
  }
565
595
  if (delta.tool_calls) {
566
596
  for (const tc of delta.tool_calls) {
package/src/shutdown.mjs CHANGED
@@ -1,6 +1,9 @@
1
1
  export async function closeHttpServer(server, { timeoutMs = 5000 } = {}) {
2
2
  server?.ccdxCloseActivity?.();
3
- if (!server?.listening) return { forced: false };
3
+ if (!server?.listening) {
4
+ await server?.ccdxDrainBackground?.();
5
+ return { forced: false };
6
+ }
4
7
 
5
8
  return new Promise((resolve, reject) => {
6
9
  let settled = false;
@@ -26,5 +29,5 @@ export async function closeHttpServer(server, { timeoutMs = 5000 } = {}) {
26
29
  if (e?.code === "ERR_SERVER_NOT_RUNNING") finish(null);
27
30
  else finish(e);
28
31
  }
29
- });
32
+ }).finally(() => server.ccdxDrainBackground?.());
30
33
  }
@@ -0,0 +1,111 @@
1
+ import path from "node:path";
2
+ import { execFile, spawn } from "node:child_process";
3
+ import { promisify } from "node:util";
4
+ import { windowsPowerShellEnvironment } from "./windows-process.mjs";
5
+
6
+ const execute = promisify(execFile);
7
+ // Extracted from Google's Authenticode-bearing Antigravity App installers, not the IDE.
8
+ // Windows App payload identity is verified against all three routing components.
9
+ // https://antigravity.google/download
10
+ const officialBundles = new Map([
11
+ ["fdf8a0a6af474d54301740bdf0144d95a30be3105d96a2cb39bb8086278513ac", [
12
+ "9f0aad7274795d7fbde04931d96b348dcfc5f3d81d7373e6b70aeb09307442df",
13
+ "73ce9a2405b455a93d1f13db2ae555da50406110217a349b6dd85c377fbdb9d1",
14
+ ]],
15
+ ["ec43b6ade67822195c8529c99468bddc10baa5de1aaeccaa8e55f9d79fd03ff7", [
16
+ "9f0aad7274795d7fbde04931d96b348dcfc5f3d81d7373e6b70aeb09307442df",
17
+ "3ab260e0e1bed6e2c86eab13f385200f62e26c33f27174f485ddae21933c4f74",
18
+ ]],
19
+ ]);
20
+
21
+ const inventory = String.raw`
22
+ [Console]::OutputEncoding=[Text.UTF8Encoding]::new($false)
23
+ $ErrorActionPreference='Stop'
24
+ $paths=@()
25
+ if($env:CCDX_AGY_INSPECT_APP){$paths=@($env:CCDX_AGY_INSPECT_APP)}
26
+ else{
27
+ if($env:LOCALAPPDATA){$paths+=Join-Path $env:LOCALAPPDATA 'Programs\Antigravity\Antigravity.exe'}
28
+ if($env:ProgramFiles){$paths+=Join-Path $env:ProgramFiles 'Antigravity\Antigravity.exe'}
29
+ $keys=@('HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
30
+ 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*',
31
+ 'HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*')
32
+ foreach($entry in (Get-ItemProperty -Path $keys -ErrorAction SilentlyContinue)){
33
+ if($entry.DisplayName -ne 'Antigravity' -or $entry.Publisher -notin @('Google','Google LLC')){continue}
34
+ if($entry.InstallLocation){$paths+=Join-Path $entry.InstallLocation 'Antigravity.exe'}
35
+ if($entry.DisplayIcon -match '^\s*"?([a-z]:\\[^"]*\\Antigravity\.exe)"?(?:,\d+)?\s*$'){$paths+=$Matches[1]}
36
+ }
37
+ }
38
+ $rows=@(foreach($p in ($paths|Sort-Object -Unique)){
39
+ if($p -notmatch '^[a-z]:\\' -or [IO.Path]::GetFileName($p) -ne 'Antigravity.exe'){continue}
40
+ $item=Get-Item -LiteralPath $p -ErrorAction SilentlyContinue
41
+ if(!$item -or $item.PSIsContainer){continue}
42
+ $v=$item.VersionInfo
43
+ if($v.ProductName -ne 'Antigravity' -or $v.CompanyName -notin @('Google','Google LLC')){continue}
44
+ $helper=Join-Path $item.DirectoryName 'resources\bin\language_server.exe'
45
+ $asar=Join-Path $item.DirectoryName 'resources\app.asar'
46
+ if(!(Test-Path -LiteralPath $helper -PathType Leaf) -or !(Test-Path -LiteralPath $asar -PathType Leaf)){continue}
47
+ $row=@{app=$item.FullName;helper=$helper;version=$v.ProductVersion}
48
+ if($env:CCDX_AGY_INSPECT_APP){
49
+ $before=@($item, (Get-Item -LiteralPath $asar), (Get-Item -LiteralPath $helper))
50
+ $row.hashes=@(foreach($f in $before){(Get-FileHash -LiteralPath $f.FullName -Algorithm SHA256).Hash})
51
+ foreach($f in $before){
52
+ $after=Get-Item -LiteralPath $f.FullName
53
+ if($after.Length -ne $f.Length -or $after.LastWriteTimeUtc -ne $f.LastWriteTimeUtc){throw 'Antigravity files changed during verification'}
54
+ }
55
+ $row.pids=@(Get-CimInstance Win32_Process -Filter "Name = 'Antigravity.exe'" |
56
+ Where-Object { $_.ExecutablePath -eq $item.FullName } | ForEach-Object { [int]$_.ProcessId })
57
+ if($env:APPDATA){
58
+ $state=Get-Item -LiteralPath (Join-Path $env:APPDATA 'Antigravity\wsl_state.json') -ErrorAction SilentlyContinue
59
+ if($state -and $state.Length -le 16384){
60
+ try {$row.wsl=[bool]((Get-Content -Raw -LiteralPath $state.FullName | ConvertFrom-Json).distro)}catch{}
61
+ }
62
+ }
63
+ }
64
+ $row
65
+ })
66
+ ConvertTo-Json -InputObject @($rows) -Depth 4 -Compress
67
+ `;
68
+
69
+ export const windowsAntigravityPath = value => typeof value === "string" && /^[a-z]:\\/i.test(value)
70
+ && path.win32.normalize(value) === value && path.win32.basename(value).toLowerCase() === "antigravity.exe";
71
+
72
+ export async function inspectWindowsAntigravity({ env = process.env, exec = execute, app } = {}) {
73
+ if (app !== undefined && !windowsAntigravityPath(app)) throw new Error("Unrecognized Antigravity App location");
74
+ const command = path.win32.join(env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
75
+ const childEnv = windowsPowerShellEnvironment({ ...env, CCDX_AGY_INSPECT_APP: app || "" });
76
+ const { stdout } = await exec(command, ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", inventory],
77
+ { env: childEnv, encoding: "utf8", timeout: app ? 15000 : 3000, maxBuffer: 64 * 1024, windowsHide: true });
78
+ const value = JSON.parse(stdout);
79
+ const rows = Array.isArray(value) ? value.filter(row => windowsAntigravityPath(row?.app)
80
+ && (!app || row.app.toLowerCase() === app.toLowerCase())
81
+ && typeof row.version === "string" && /^[0-9][0-9A-Za-z.+_-]{0,63}$/.test(row.version)) : [];
82
+ const distinct = [...new Map(rows.map(row => [row.app.toLowerCase(), row])).values()];
83
+ if (distinct.length !== 1) return { status: distinct.length ? "multiple" : "not_installed" };
84
+ const row = distinct[0], executable = row.app,
85
+ helper = path.win32.join(path.win32.dirname(executable), "resources", "bin", "language_server.exe");
86
+ const result = { app: executable, target: executable, executable, helper, version: row.version };
87
+ if (!app) return result;
88
+ const hashes = Array.isArray(row.hashes) && row.hashes.length === 3 ? row.hashes.map(value => String(value).toLowerCase()) : [];
89
+ const expected = officialBundles.get(hashes[0]);
90
+ if (!expected || expected.some((value, i) => hashes[i+1] !== value)) return { ...result, status: "unknown" };
91
+ const pids = Array.isArray(row.pids) ? row.pids.filter(pid => Number.isSafeInteger(pid) && pid > 0) : [];
92
+ return { ...result, status: pids.length ? "running" : "stopped", pids, wsl: row.wsl === true };
93
+ }
94
+
95
+ export function windowsAntigravityEnvironment(env, url) {
96
+ const launch = Object.fromEntries(Object.entries(env).filter(([name]) =>
97
+ /^(PATH|SYSTEMROOT|SYSTEMDRIVE|WINDIR|COMSPEC|PATHEXT|LOCALAPPDATA|APPDATA|TEMP|TMP|USERPROFILE|HOMEDRIVE|HOMEPATH|USERNAME|USERDOMAIN|PROGRAMDATA|PROGRAMFILES(?:\(X86\))?|PROGRAMW6432|PROCESSOR_ARCHITECTURE|NUMBER_OF_PROCESSORS|OS|LANG|LC_ALL|TZ|(?:HTTP|HTTPS|ALL|NO)_PROXY|ANTIGRAVITY_WSL_DISTRO)$/i.test(name)));
98
+ if (url) launch.CLOUD_CODE_URL = url;
99
+ return launch;
100
+ }
101
+
102
+ export async function launchWindowsAntigravity(plan, { spawnImpl = spawn } = {}) {
103
+ return new Promise((resolve, reject) => {
104
+ const child = spawnImpl(plan.command, plan.args, {
105
+ cwd: path.win32.dirname(plan.command), env: plan.environment,
106
+ detached: true, stdio: "ignore", shell: false,
107
+ });
108
+ child.once("error", reject);
109
+ child.once("spawn", () => { child.unref();resolve(); });
110
+ });
111
+ }