@liberseek/boft-cli-linux-x64 0.7.5 → 0.7.7

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.
@@ -5,13 +5,416 @@ var __export = (target, all) => {
5
5
  __defProp(target, name, { get: all[name], enumerable: true });
6
6
  };
7
7
 
8
+ // ../../harness-discovery/dist/environment.js
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+ function targetPath(platform) {
12
+ return platform === "win32" ? path.win32 : path.posix;
13
+ }
14
+ function environmentValue(environment, name) {
15
+ const lowered = name.toLowerCase();
16
+ for (const [key, value] of Object.entries(environment)) {
17
+ if (key.toLowerCase() === lowered)
18
+ return value;
19
+ }
20
+ return void 0;
21
+ }
22
+ function pathDelimiter(platform) {
23
+ return platform === "win32" ? ";" : ":";
24
+ }
25
+ function pathDirectories(environment, platform) {
26
+ return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
27
+ }
28
+ function executableExtensions(command, platform, environment) {
29
+ if (platform !== "win32")
30
+ return [""];
31
+ if (targetPath(platform).extname(command) !== "")
32
+ return [""];
33
+ return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
34
+ }
35
+ function isExecutableFile(filePath, platform) {
36
+ try {
37
+ fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
+ return fs.statSync(filePath).isFile();
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+ function subdirectoryNames(directory) {
44
+ try {
45
+ return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
46
+ } catch {
47
+ return [];
48
+ }
49
+ }
50
+ function newestFirst(names) {
51
+ return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
52
+ }
53
+
54
+ // ../../harness-discovery/dist/invocation.js
55
+ import path2 from "node:path";
56
+ function commandInvocation(command, arguments_, environment, platform = process.platform) {
57
+ const extension = path2.win32.extname(command).toLowerCase();
58
+ if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
59
+ return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
60
+ }
61
+ const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
62
+ const commandLine = [command, ...arguments_].map(quote).join(" ");
63
+ return {
64
+ command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
65
+ arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
66
+ windowsVerbatimArguments: true
67
+ };
68
+ }
69
+
70
+ // ../../harness-discovery/dist/node-runtime.js
71
+ import path3 from "node:path";
72
+ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
73
+ const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
74
+ const delimiter = platform === "win32" ? ";" : ":";
75
+ const runtimeDirectory = path3.dirname(runtimeExecutable);
76
+ const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
77
+ const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
78
+ if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
79
+ directories.push(runtimeDirectory);
80
+ }
81
+ return { ...environment, [pathKey]: directories.join(delimiter) };
82
+ }
83
+
84
+ // ../../harness-discovery/dist/resolve.js
85
+ import os from "node:os";
86
+
87
+ // ../../harness-discovery/dist/version-managers.js
88
+ function versionManagerBinaryDirectories(context) {
89
+ const { platform, environment, home } = context;
90
+ const list = context.subdirectories ?? subdirectoryNames;
91
+ const pathFlavor = targetPath(platform);
92
+ const value = (name) => environmentValue(environment, name);
93
+ const directories = [];
94
+ const versioned = (root, ...tail) => {
95
+ for (const version2 of newestFirst(list(root))) {
96
+ directories.push(pathFlavor.join(root, version2, ...tail));
97
+ }
98
+ };
99
+ if (platform === "win32") {
100
+ const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
101
+ const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
102
+ versioned(pathFlavor.join(appData, "nvm"));
103
+ versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
104
+ directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
105
+ directories.push(pathFlavor.join(home, ".bun", "bin"));
106
+ const pnpmHome2 = value("PNPM_HOME");
107
+ if (pnpmHome2)
108
+ directories.push(pnpmHome2);
109
+ directories.push(pathFlavor.join(localAppData, "pnpm"));
110
+ return directories;
111
+ }
112
+ versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
113
+ const fnmRoots = [
114
+ value("FNM_DIR"),
115
+ pathFlavor.join(home, ".local", "share", "fnm"),
116
+ pathFlavor.join(home, "Library", "Application Support", "fnm")
117
+ ].filter((root) => root !== void 0);
118
+ for (const root of fnmRoots) {
119
+ versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
120
+ }
121
+ const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
122
+ versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
123
+ directories.push(pathFlavor.join(voltaHome, "bin"));
124
+ const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
125
+ versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
126
+ directories.push(pathFlavor.join(asdfHome, "shims"));
127
+ const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
128
+ versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
129
+ directories.push(pathFlavor.join(nodenvHome, "shims"));
130
+ versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
131
+ directories.push(pathFlavor.join(home, ".bun", "bin"));
132
+ const pnpmHome = value("PNPM_HOME");
133
+ if (pnpmHome)
134
+ directories.push(pnpmHome);
135
+ directories.push(pathFlavor.join(home, "Library", "pnpm"));
136
+ directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
137
+ for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
138
+ for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
139
+ directories.push(pathFlavor.join(prefix, formula, "bin"));
140
+ }
141
+ }
142
+ return directories;
143
+ }
144
+
145
+ // ../../harness-discovery/dist/resolve.js
146
+ var VERSION_MANAGER_ROOTS = "<version-managers>";
147
+ function installRootExtensions(platform) {
148
+ return platform === "win32" ? [".exe", ".cmd"] : [""];
149
+ }
150
+ function resolveHomeDirectory(input) {
151
+ return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
152
+ }
153
+ function templateVariables(environment, platform, home) {
154
+ const pathFlavor = targetPath(platform);
155
+ return {
156
+ HOME: home,
157
+ USERPROFILE: home,
158
+ APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
159
+ LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
160
+ };
161
+ }
162
+ function joinTemplate(platform, value) {
163
+ const pathFlavor = targetPath(platform);
164
+ const segments = value.split("/");
165
+ const head = segments[0] ?? "";
166
+ const tail = segments.slice(1);
167
+ if (head === "")
168
+ return pathFlavor.join(pathFlavor.sep, ...tail);
169
+ return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
170
+ }
171
+ function expandInstallRoot(template, environment, platform, home) {
172
+ const variables = templateVariables(environment, platform, home);
173
+ let unresolved = false;
174
+ const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
175
+ const value = variables[name] ?? environmentValue(environment, name);
176
+ if (value === void 0 || value === "") {
177
+ unresolved = true;
178
+ return "";
179
+ }
180
+ return value;
181
+ });
182
+ return unresolved ? void 0 : joinTemplate(platform, substituted);
183
+ }
184
+ function installRootDirectories(spec, input, dependencies, platform, home) {
185
+ const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
186
+ const directories = [];
187
+ for (const template of templates) {
188
+ if (template === VERSION_MANAGER_ROOTS) {
189
+ directories.push(...versionManagerBinaryDirectories({
190
+ platform,
191
+ environment: input.environment,
192
+ home,
193
+ ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
194
+ }));
195
+ continue;
196
+ }
197
+ const directory = expandInstallRoot(template, input.environment, platform, home);
198
+ if (directory !== void 0)
199
+ directories.push(directory);
200
+ }
201
+ return directories;
202
+ }
203
+ function harnessCandidates(spec, input, dependencies = {}) {
204
+ const platform = input.platform ?? process.platform;
205
+ const pathFlavor = targetPath(platform);
206
+ const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
207
+ const command = configured ?? spec.command;
208
+ if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
209
+ return [{ candidate: command, source: "configured" }];
210
+ }
211
+ const candidates = [];
212
+ const extensions = executableExtensions(command, platform, input.environment);
213
+ for (const directory of pathDirectories(input.environment, platform)) {
214
+ for (const extension of extensions) {
215
+ candidates.push({
216
+ candidate: pathFlavor.join(directory, command + extension),
217
+ source: "path"
218
+ });
219
+ }
220
+ }
221
+ if (configured !== void 0)
222
+ return candidates;
223
+ const home = resolveHomeDirectory(input);
224
+ for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
225
+ for (const extension of installRootExtensions(platform)) {
226
+ candidates.push({
227
+ candidate: pathFlavor.join(directory, spec.command + extension),
228
+ source: "install-root"
229
+ });
230
+ }
231
+ }
232
+ return candidates;
233
+ }
234
+ function resolveHarnessExecutable(spec, input, dependencies = {}) {
235
+ const platform = input.platform ?? process.platform;
236
+ const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
237
+ const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
238
+ const context = { platform, isExecutable };
239
+ for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
240
+ const executable = runnable(candidate, context);
241
+ if (executable !== void 0 && isExecutable(executable))
242
+ return { executable, source };
243
+ }
244
+ return void 0;
245
+ }
246
+
247
+ // ../../harness-discovery/dist/installation.js
248
+ import { execFile } from "node:child_process";
249
+ import { homedir } from "node:os";
250
+ function runInstallationCommand(command, args, environment, timeout = 3e4) {
251
+ const env = withNodeRuntimeOnPath(environment);
252
+ const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
253
+ return new Promise((resolve, reject) => {
254
+ const child = execFile(invocation.command, invocation.arguments, {
255
+ env,
256
+ cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
257
+ encoding: "utf8",
258
+ timeout,
259
+ killSignal: "SIGKILL",
260
+ maxBuffer: 1024 * 1024,
261
+ windowsHide: true,
262
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
263
+ }, (error51, stdout, stderr) => {
264
+ if (error51)
265
+ reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
266
+ else
267
+ resolve((stdout || stderr).trim());
268
+ });
269
+ child.stdin?.end();
270
+ });
271
+ }
272
+ function installationVersion(value) {
273
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
274
+ throw new Error("Harness returned an invalid version");
275
+ return value.trim().replace(/^v/, "");
276
+ }
277
+ function versionFromOutput(output) {
278
+ return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
279
+ }
280
+ function newerInstallationVersion(current, latest) {
281
+ const a = installationVersion(current).replace(/\+.*/, "");
282
+ const b = installationVersion(latest).replace(/\+.*/, "");
283
+ const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
284
+ const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
285
+ for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
286
+ if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
287
+ return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
288
+ }
289
+ const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
290
+ const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
291
+ if (!preA.length || !preB.length)
292
+ return !!preA.length && !preB.length;
293
+ for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
294
+ const x = preA[i];
295
+ const y = preB[i];
296
+ if (x === y)
297
+ continue;
298
+ if (x === void 0 || y === void 0)
299
+ return x === void 0;
300
+ const numericX = /^\d+$/.test(x);
301
+ const numericY = /^\d+$/.test(y);
302
+ if (numericX && numericY) {
303
+ if (BigInt(x) === BigInt(y))
304
+ continue;
305
+ return BigInt(y) > BigInt(x);
306
+ }
307
+ if (numericX !== numericY)
308
+ return numericX;
309
+ return y > x;
310
+ }
311
+ return false;
312
+ }
313
+ function createInstallationManager(options) {
314
+ let checking;
315
+ let updating;
316
+ const check2 = () => checking ??= options.check().finally(() => {
317
+ checking = void 0;
318
+ });
319
+ return (action) => {
320
+ if (updating)
321
+ return updating;
322
+ if (action === "check")
323
+ return check2();
324
+ updating = (async () => {
325
+ const before = await check2();
326
+ if (!before.updateAvailable)
327
+ return before;
328
+ if (!before.canUpdate)
329
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
330
+ await options.update(before);
331
+ const after = await check2();
332
+ if (after.currentVersion === before.currentVersion)
333
+ throw new Error("The Harness version did not change; check the native updater and retry");
334
+ return after;
335
+ })().finally(() => {
336
+ updating = void 0;
337
+ });
338
+ return updating;
339
+ };
340
+ }
341
+ async function fetchInstallationText(url2) {
342
+ const request = async () => {
343
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
344
+ if (!response.ok)
345
+ throw new Error("Could not check the latest Harness version");
346
+ return response.text();
347
+ };
348
+ try {
349
+ return await request();
350
+ } catch (error51) {
351
+ if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
352
+ throw error51;
353
+ return request();
354
+ }
355
+ }
356
+
357
+ // ../../harness-discovery/dist/installer.js
358
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
359
+ import { tmpdir } from "node:os";
360
+ import { join } from "node:path";
361
+ function createHarnessInstaller(environment, source) {
362
+ return async () => {
363
+ if (!["darwin", "linux", "win32"].includes(process.platform))
364
+ throw new Error("Unsupported installation platform");
365
+ const env = withNodeRuntimeOnPath(environment);
366
+ if ("npm" in source) {
367
+ const npm = resolveHarnessExecutable({
368
+ id: "npm",
369
+ command: "npm",
370
+ installRoots: {
371
+ posix: [
372
+ "~/.npm-global/bin",
373
+ "~/.local/bin",
374
+ VERSION_MANAGER_ROOTS,
375
+ "/opt/homebrew/bin",
376
+ "/usr/local/bin",
377
+ "/usr/bin"
378
+ ],
379
+ windows: [
380
+ "${APPDATA}/npm",
381
+ VERSION_MANAGER_ROOTS,
382
+ "${ProgramFiles}/nodejs",
383
+ "${LOCALAPPDATA}/Programs/nodejs"
384
+ ]
385
+ }
386
+ }, { environment: env });
387
+ if (!npm)
388
+ throw new Error("Install Node.js and npm first");
389
+ await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
390
+ ...env,
391
+ ...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
392
+ }, 6e5);
393
+ return;
394
+ }
395
+ const windows = process.platform === "win32";
396
+ const url2 = windows ? source.windows : source.posix;
397
+ if (new URL(url2).protocol !== "https:")
398
+ throw new Error("Installer requires HTTPS");
399
+ const script = await fetchInstallationText(url2);
400
+ const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
401
+ try {
402
+ const file2 = join(directory, windows ? "install.ps1" : "install.sh");
403
+ await writeFile(file2, script, { mode: 384 });
404
+ await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
405
+ } finally {
406
+ await rm(directory, { recursive: true, force: true });
407
+ }
408
+ };
409
+ }
410
+
8
411
  // dist/antigravity-adapter.js
9
412
  import { spawn } from "node:child_process";
10
413
  import { randomUUID as randomUUID6 } from "node:crypto";
11
414
  import { readFile as readFile2, unlink } from "node:fs/promises";
12
415
  import https3 from "node:https";
13
416
  import os5 from "node:os";
14
- import path9 from "node:path";
417
+ import path10 from "node:path";
15
418
  import readline from "node:readline";
16
419
 
17
420
  // ../../../node_modules/zod/v4/classic/external.js
@@ -780,10 +1183,10 @@ function mergeDefs(...defs) {
780
1183
  function cloneDef(schema) {
781
1184
  return mergeDefs(schema._zod.def);
782
1185
  }
783
- function getElementAtPath(obj, path10) {
784
- if (!path10)
1186
+ function getElementAtPath(obj, path11) {
1187
+ if (!path11)
785
1188
  return obj;
786
- return path10.reduce((acc, key) => acc?.[key], obj);
1189
+ return path11.reduce((acc, key) => acc?.[key], obj);
787
1190
  }
788
1191
  function promiseAllObject(promisesObj) {
789
1192
  const keys = Object.keys(promisesObj);
@@ -1192,11 +1595,11 @@ function explicitlyAborted(x, startIndex = 0) {
1192
1595
  }
1193
1596
  return false;
1194
1597
  }
1195
- function prefixIssues(path10, issues) {
1598
+ function prefixIssues(path11, issues) {
1196
1599
  return issues.map((iss) => {
1197
1600
  var _a3;
1198
1601
  (_a3 = iss).path ?? (_a3.path = []);
1199
- iss.path.unshift(path10);
1602
+ iss.path.unshift(path11);
1200
1603
  return iss;
1201
1604
  });
1202
1605
  }
@@ -1343,16 +1746,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1343
1746
  }
1344
1747
  function formatError(error51, mapper = (issue2) => issue2.message) {
1345
1748
  const fieldErrors = { _errors: [] };
1346
- const processError = (error52, path10 = []) => {
1749
+ const processError = (error52, path11 = []) => {
1347
1750
  for (const issue2 of error52.issues) {
1348
1751
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1349
- issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
1752
+ issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
1350
1753
  } else if (issue2.code === "invalid_key") {
1351
- processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
1754
+ processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1352
1755
  } else if (issue2.code === "invalid_element") {
1353
- processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
1756
+ processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1354
1757
  } else {
1355
- const fullpath = [...path10, ...issue2.path];
1758
+ const fullpath = [...path11, ...issue2.path];
1356
1759
  if (fullpath.length === 0) {
1357
1760
  fieldErrors._errors.push(mapper(issue2));
1358
1761
  } else {
@@ -1379,17 +1782,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1379
1782
  }
1380
1783
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1381
1784
  const result = { errors: [] };
1382
- const processError = (error52, path10 = []) => {
1785
+ const processError = (error52, path11 = []) => {
1383
1786
  var _a3, _b;
1384
1787
  for (const issue2 of error52.issues) {
1385
1788
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1386
- issue2.errors.map((issues) => processError({ issues }, [...path10, ...issue2.path]));
1789
+ issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
1387
1790
  } else if (issue2.code === "invalid_key") {
1388
- processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
1791
+ processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1389
1792
  } else if (issue2.code === "invalid_element") {
1390
- processError({ issues: issue2.issues }, [...path10, ...issue2.path]);
1793
+ processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1391
1794
  } else {
1392
- const fullpath = [...path10, ...issue2.path];
1795
+ const fullpath = [...path11, ...issue2.path];
1393
1796
  if (fullpath.length === 0) {
1394
1797
  result.errors.push(mapper(issue2));
1395
1798
  continue;
@@ -1421,8 +1824,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1421
1824
  }
1422
1825
  function toDotPath(_path) {
1423
1826
  const segs = [];
1424
- const path10 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1425
- for (const seg of path10) {
1827
+ const path11 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1828
+ for (const seg of path11) {
1426
1829
  if (typeof seg === "number")
1427
1830
  segs.push(`[${seg}]`);
1428
1831
  else if (typeof seg === "symbol")
@@ -14114,13 +14517,13 @@ function resolveRef(ref, ctx) {
14114
14517
  if (!ref.startsWith("#")) {
14115
14518
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14116
14519
  }
14117
- const path10 = ref.slice(1).split("/").filter(Boolean);
14118
- if (path10.length === 0) {
14520
+ const path11 = ref.slice(1).split("/").filter(Boolean);
14521
+ if (path11.length === 0) {
14119
14522
  return ctx.rootSchema;
14120
14523
  }
14121
14524
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14122
- if (path10[0] === defsKey) {
14123
- const key = path10[1];
14525
+ if (path11[0] === defsKey) {
14526
+ const key = path11[1];
14124
14527
  if (!key || !ctx.defs[key]) {
14125
14528
  throw new Error(`Reference not found: ${ref}`);
14126
14529
  }
@@ -14583,6 +14986,123 @@ var credentialImportsParamsSchema = external_exports.object({
14583
14986
  request: credentialImportsRequestSchema
14584
14987
  }).strict();
14585
14988
 
14989
+ // ../../shared-contracts/dist/harness-display-settings.js
14990
+ var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
14991
+ agent: external_exports.string().min(1).max(128),
14992
+ section: external_exports.enum(["main", "more", "auto"])
14993
+ })).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
14994
+ var harnessDisplaySettingsSchema = external_exports.strictObject({
14995
+ entries: harnessDisplayEntriesSchema.nullable()
14996
+ });
14997
+ var harnessDisplayGetSchema = external_exports.strictObject({});
14998
+ var harnessDisplaySetSchema = external_exports.strictObject({
14999
+ entries: harnessDisplayEntriesSchema,
15000
+ /** Import legacy Desktop preferences only if no shared settings exist yet. */
15001
+ initializeOnly: external_exports.boolean().optional()
15002
+ });
15003
+
15004
+ // ../../shared-contracts/dist/ids.js
15005
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15006
+ message: "Identifier must not be empty or whitespace"
15007
+ });
15008
+ var harnessIdSchema = opaqueIdSchema.brand();
15009
+ var hostThreadIdSchema = opaqueIdSchema.brand();
15010
+ var hostTurnIdSchema = opaqueIdSchema.brand();
15011
+ var hostItemIdSchema = opaqueIdSchema.brand();
15012
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
15013
+
15014
+ // ../../shared-contracts/dist/harness-plugins.js
15015
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15016
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15017
+ var HARNESS_PLUGIN_LIMIT = 128;
15018
+ var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
15019
+ var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
15020
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15021
+ var pluginPresentationShape = {
15022
+ id: harnessPluginIdSchema,
15023
+ name: external_exports.string().trim().min(1).max(128),
15024
+ version: external_exports.string().min(1).max(128),
15025
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15026
+ launchCommand: external_exports.literal(true).optional(),
15027
+ links: external_exports.object({
15028
+ documentation: documentationUrlSchema.optional(),
15029
+ installation: documentationUrlSchema.optional()
15030
+ }).strict().optional()
15031
+ };
15032
+ var harnessPluginManifestSchema = external_exports.object({
15033
+ manifestVersion: external_exports.literal(1),
15034
+ ...pluginPresentationShape,
15035
+ adapterApiVersion: external_exports.number().int().positive(),
15036
+ entry: relativeResourceSchema,
15037
+ icon: relativeResourceSchema.optional()
15038
+ }).strict();
15039
+ var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
15040
+ var harnessPluginDescriptorSchema = external_exports.object({
15041
+ ...pluginPresentationShape,
15042
+ icon: harnessPluginIconSchema.optional()
15043
+ }).strict();
15044
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15045
+ var harnessPluginListResultSchema = external_exports.object({
15046
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15047
+ }).strict();
15048
+ var harnessPluginConfigurationSchema = external_exports.object({
15049
+ version: external_exports.literal(1),
15050
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15051
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15052
+ message: "Enabled plugin IDs must be unique",
15053
+ path: ["enabled"]
15054
+ });
15055
+
15056
+ // ../../shared-contracts/dist/harness-long-context.js
15057
+ var HARNESS_LONG_CONTEXT_GET_METHOD = "codexhost/harness/long-context/get";
15058
+ var HARNESS_LONG_CONTEXT_SET_METHOD = "codexhost/harness/long-context/set";
15059
+ var harnessLongContextGetSchema = external_exports.object({
15060
+ harnessId: harnessPluginIdSchema
15061
+ }).strict();
15062
+ var harnessLongContextSetSchema = harnessLongContextGetSchema.extend({
15063
+ enabled: external_exports.boolean()
15064
+ });
15065
+ var harnessLongContextSchema = external_exports.object({
15066
+ enabled: external_exports.boolean()
15067
+ }).strict();
15068
+
15069
+ // ../../shared-contracts/dist/console.js
15070
+ var consoleAnnouncementSchema = external_exports.strictObject({
15071
+ title: external_exports.string().trim().min(1).max(200),
15072
+ type: external_exports.enum(["info", "warning", "danger"]),
15073
+ body: external_exports.string().trim().min(1).max(16 * 1024)
15074
+ });
15075
+ var consoleOpenParamsSchema = external_exports.strictObject({});
15076
+ var consoleOpenResultSchema = external_exports.strictObject({
15077
+ /** The console address. */
15078
+ url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15079
+ });
15080
+ var CONSOLE_HOST_METHODS = Object.freeze([
15081
+ "codexhost/harness/plugins/list",
15082
+ "codexhost/harness/display-settings/get",
15083
+ "codexhost/harness/display-settings/set",
15084
+ "codexhost/harness/inspect",
15085
+ "codexhost/harness/installation",
15086
+ "codexhost/harness/launch-settings/get",
15087
+ "codexhost/harness/launch-settings/set",
15088
+ HARNESS_LONG_CONTEXT_GET_METHOD,
15089
+ HARNESS_LONG_CONTEXT_SET_METHOD,
15090
+ "codexhost/harness/web-ui/open",
15091
+ "codexhost/harness/accounts/sources",
15092
+ "codexhost/harness/accounts/list",
15093
+ "codexhost/harness/accounts/inspect",
15094
+ "codexhost/harness/credential-imports",
15095
+ "codexhost/harness/session-import/sources",
15096
+ "codexhost/harness/session-import/list",
15097
+ "codexhost/harness/session-import/import",
15098
+ "codexhost/account/list",
15099
+ "codexhost/account/refresh",
15100
+ "codexhost/account/usage/inspect",
15101
+ "codexhost/update/check",
15102
+ "codexhost/update/start",
15103
+ "codexhost/update/status"
15104
+ ]);
15105
+
14586
15106
  // ../../shared-contracts/dist/version.js
14587
15107
  var WORKSPACE_CONTRACT_VERSION = 1;
14588
15108
 
@@ -14626,15 +15146,11 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
14626
15146
  inactiveMs: external_exports.number().nonnegative()
14627
15147
  }));
14628
15148
 
14629
- // ../../shared-contracts/dist/ids.js
14630
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14631
- message: "Identifier must not be empty or whitespace"
15149
+ // ../../shared-contracts/dist/manual-compaction.js
15150
+ var threadManualCompactionStartedSchema = external_exports.strictObject({
15151
+ threadId: hostThreadIdSchema,
15152
+ turnId: hostTurnIdSchema
14632
15153
  });
14633
- var harnessIdSchema = opaqueIdSchema.brand();
14634
- var hostThreadIdSchema = opaqueIdSchema.brand();
14635
- var hostTurnIdSchema = opaqueIdSchema.brand();
14636
- var hostItemIdSchema = opaqueIdSchema.brand();
14637
- var hostInteractionIdSchema = opaqueIdSchema.brand();
14638
15154
 
14639
15155
  // ../../shared-contracts/dist/thread-usage.js
14640
15156
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
@@ -14696,6 +15212,10 @@ var threadUsageSnapshotSchema = external_exports.object({
14696
15212
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
14697
15213
  var accountCreditsProductUsageSchema = external_exports.object({
14698
15214
  product: external_exports.string().min(1),
15215
+ used: external_exports.number().finite().nonnegative().optional(),
15216
+ // Zero is a real empty cap, not an absent field.
15217
+ limit: external_exports.number().finite().nonnegative().optional(),
15218
+ unit: external_exports.string().min(1).max(32).optional(),
14699
15219
  usagePercent: usagePercentSchema,
14700
15220
  resetsAt: external_exports.string().min(1).optional()
14701
15221
  }).strict();
@@ -14705,11 +15225,14 @@ var accountResetCreditsSchema = external_exports.object({
14705
15225
  expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
14706
15226
  }).strict();
14707
15227
  var accountCreditsSnapshotSchema = external_exports.object({
15228
+ used: external_exports.number().finite().nonnegative().optional(),
15229
+ // Zero is a real empty cap, not an absent field.
15230
+ limit: external_exports.number().finite().nonnegative().optional(),
15231
+ unit: external_exports.string().trim().min(1).max(32).optional(),
14708
15232
  /** Native label when the primary limit is scoped to a model or product group. */
14709
15233
  label: external_exports.string().min(1).optional(),
14710
15234
  usedPercent: usagePercentSchema.optional(),
14711
15235
  remaining: external_exports.number().finite().optional(),
14712
- unit: external_exports.string().trim().min(1).max(32).optional(),
14713
15236
  resetsAt: external_exports.string().min(1).optional(),
14714
15237
  periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
14715
15238
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
@@ -14740,12 +15263,27 @@ var threadUsageInspectionSchema = external_exports.object({
14740
15263
  }).strict();
14741
15264
 
14742
15265
  // ../../shared-contracts/dist/harness-accounts.js
14743
- var harnessAccountSnapshotSchema = external_exports.object({
15266
+ var accountBalanceSnapshotSchema = external_exports.object({
15267
+ amount: external_exports.number().finite().nonnegative(),
15268
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
15269
+ currency: external_exports.string().trim().min(1).max(8),
15270
+ /** Native label when the Harness exposes several Billing Sources. */
15271
+ label: external_exports.string().trim().min(1).max(128).optional()
15272
+ }).strict();
15273
+ var harnessAccountSnapshotObject = external_exports.object({
14744
15274
  email: external_exports.string().trim().min(1).max(320).optional(),
14745
15275
  label: external_exports.string().trim().min(1).max(256).optional(),
14746
15276
  plan: external_exports.string().trim().min(1).max(128).optional(),
14747
- credits: accountCreditsSnapshotSchema
15277
+ credits: accountCreditsSnapshotSchema.optional(),
15278
+ balance: accountBalanceSnapshotSchema.optional()
14748
15279
  }).strict();
15280
+ function requireReportedQuota(schema) {
15281
+ return schema.refine((value) => {
15282
+ const reported = value;
15283
+ return reported.credits !== void 0 || reported.balance !== void 0;
15284
+ }, { message: "Account must report either credits or a balance" });
15285
+ }
15286
+ var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
14749
15287
  var harnessAccountIdentityShape = {
14750
15288
  harnessId: harnessIdSchema,
14751
15289
  harnessName: external_exports.string().trim().min(1).max(128)
@@ -14756,11 +15294,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
14756
15294
  var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
14757
15295
  var harnessAccountInspectResultSchema = external_exports.object({
14758
15296
  ...harnessAccountIdentityShape,
14759
- account: harnessAccountSnapshotSchema.nullable()
15297
+ account: harnessAccountSnapshotSchema.nullable(),
15298
+ /** Every Billing Source from one Harness; `account` remains the first for older clients. */
15299
+ accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
14760
15300
  }).strict();
14761
15301
  var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
14762
15302
  var harnessAccountListResultSchema = external_exports.object({
14763
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend(harnessAccountIdentityShape)).max(128)
15303
+ accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
14764
15304
  }).strict();
14765
15305
 
14766
15306
  // ../../shared-contracts/dist/json-value.js
@@ -14898,6 +15438,8 @@ var harnessModelSchema = external_exports.object({
14898
15438
  ref: harnessModelRefSchema,
14899
15439
  label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
14900
15440
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15441
+ /** Optional opaque selection for this same Model with priority processing enabled. */
15442
+ fastModel: harnessModelRefSchema.optional(),
14901
15443
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
14902
15444
  }).strict();
14903
15445
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
@@ -14930,6 +15472,16 @@ var harnessModelCatalogSchema = external_exports.object({
14930
15472
  });
14931
15473
  }
14932
15474
  refs.add(model.ref.id);
15475
+ if (model.fastModel) {
15476
+ if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
15477
+ context.addIssue({
15478
+ code: "custom",
15479
+ message: "Fast Model refs must be distinct and unique",
15480
+ path: ["models", index, "fastModel"]
15481
+ });
15482
+ }
15483
+ refs.add(model.fastModel.id);
15484
+ }
14933
15485
  const supportedThinkingIds = /* @__PURE__ */ new Set();
14934
15486
  for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
14935
15487
  if (supportedThinkingIds.has(optionId)) {
@@ -15052,11 +15604,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
15052
15604
  thinkingOptionId: harnessThinkingOptionIdSchema
15053
15605
  }).strict();
15054
15606
  var threadInspectionParamsSchema = external_exports.object({
15055
- threadId: hostThreadIdSchema
15607
+ threadId: hostThreadIdSchema,
15608
+ includeReferenceCapability: external_exports.boolean().optional()
15056
15609
  }).strict();
15057
15610
  var codexThreadInspectionSchema = external_exports.object({
15058
15611
  owner: external_exports.literal("codex"),
15059
- locked: external_exports.literal(true)
15612
+ locked: external_exports.literal(true),
15613
+ supportsThreadReferences: external_exports.literal(true).optional()
15060
15614
  }).strict();
15061
15615
  var externalThreadInspectionSchema = external_exports.object({
15062
15616
  owner: external_exports.literal("external"),
@@ -15121,48 +15675,6 @@ var threadOwnershipListResultSchema = external_exports.object({
15121
15675
  }
15122
15676
  });
15123
15677
 
15124
- // ../../shared-contracts/dist/harness-plugins.js
15125
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15126
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15127
- var HARNESS_PLUGIN_LIMIT = 128;
15128
- var harnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).refine((id) => id !== "codex", "The official Codex identity is reserved").pipe(harnessIdSchema);
15129
- var relativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
15130
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15131
- var pluginPresentationShape = {
15132
- id: harnessPluginIdSchema,
15133
- name: external_exports.string().trim().min(1).max(128),
15134
- version: external_exports.string().min(1).max(128),
15135
- /** The factory accepts a persisted local entrypoint through its construction context. */
15136
- launchCommand: external_exports.literal(true).optional(),
15137
- links: external_exports.object({
15138
- documentation: documentationUrlSchema.optional(),
15139
- installation: documentationUrlSchema.optional()
15140
- }).strict().optional()
15141
- };
15142
- var harnessPluginManifestSchema = external_exports.object({
15143
- manifestVersion: external_exports.literal(1),
15144
- ...pluginPresentationShape,
15145
- adapterApiVersion: external_exports.number().int().positive(),
15146
- entry: relativeResourceSchema,
15147
- icon: relativeResourceSchema.optional()
15148
- }).strict();
15149
- var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
15150
- var harnessPluginDescriptorSchema = external_exports.object({
15151
- ...pluginPresentationShape,
15152
- icon: harnessPluginIconSchema.optional()
15153
- }).strict();
15154
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
15155
- var harnessPluginListResultSchema = external_exports.object({
15156
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15157
- }).strict();
15158
- var harnessPluginConfigurationSchema = external_exports.object({
15159
- version: external_exports.literal(1),
15160
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15161
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15162
- message: "Enabled plugin IDs must be unique",
15163
- path: ["enabled"]
15164
- });
15165
-
15166
15678
  // ../../shared-contracts/dist/harness-route.js
15167
15679
  var harnessPluginRouteSchema = external_exports.object({
15168
15680
  harnessId: harnessPluginIdSchema,
@@ -15184,10 +15696,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
15184
15696
  restartRequired: external_exports.boolean()
15185
15697
  }).strict();
15186
15698
 
15699
+ // ../../shared-contracts/dist/harness-installation.js
15700
+ var harnessInstallationParamsSchema = external_exports.object({
15701
+ harnessId: harnessIdSchema,
15702
+ action: external_exports.enum(["check", "update", "install"])
15703
+ }).strict();
15704
+ var harnessInstallationStateSchema = external_exports.object({
15705
+ currentVersion: external_exports.string().min(1).max(128),
15706
+ latestVersion: external_exports.string().min(1).max(128),
15707
+ updateAvailable: external_exports.boolean(),
15708
+ canUpdate: external_exports.boolean(),
15709
+ message: external_exports.string().max(2048).optional()
15710
+ }).strict();
15711
+
15187
15712
  // ../../shared-contracts/dist/codex-accounts.js
15188
15713
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
15189
15714
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
15190
15715
  var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
15716
+ var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
15717
+ function isCodexAccountSiteUrl(value) {
15718
+ return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
15719
+ }
15720
+ var externalUrlOpenParamsSchema = external_exports.object({
15721
+ url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
15722
+ }).strict();
15723
+ var externalUrlOpenResultSchema = external_exports.object({}).strict();
15191
15724
  var codexAccountPlanTypeSchema = external_exports.enum([
15192
15725
  "free",
15193
15726
  "go",
@@ -15213,7 +15746,8 @@ var codexAccountSchema = external_exports.object({
15213
15746
  email: external_exports.string().email().max(320).optional(),
15214
15747
  planType: codexAccountPlanTypeSchema.optional(),
15215
15748
  authKind: codexAccountAuthKindSchema.optional(),
15216
- authIdentity: nonBlankTextSchema3.max(256).optional()
15749
+ authIdentity: nonBlankTextSchema3.max(256).optional(),
15750
+ siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
15217
15751
  }).strict();
15218
15752
  var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
15219
15753
  var codexAccountListResultSchema = external_exports.object({
@@ -15613,233 +16147,8 @@ var usageFields = /* @__PURE__ */ new Set([
15613
16147
  "contextUsagePercent"
15614
16148
  ]);
15615
16149
 
15616
- // ../../harness-discovery/dist/environment.js
15617
- import fs from "node:fs";
15618
- import path from "node:path";
15619
- function targetPath(platform) {
15620
- return platform === "win32" ? path.win32 : path.posix;
15621
- }
15622
- function environmentValue(environment, name) {
15623
- const lowered = name.toLowerCase();
15624
- for (const [key, value] of Object.entries(environment)) {
15625
- if (key.toLowerCase() === lowered)
15626
- return value;
15627
- }
15628
- return void 0;
15629
- }
15630
- function pathDelimiter(platform) {
15631
- return platform === "win32" ? ";" : ":";
15632
- }
15633
- function pathDirectories(environment, platform) {
15634
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
15635
- }
15636
- function executableExtensions(command, platform, environment) {
15637
- if (platform !== "win32")
15638
- return [""];
15639
- if (targetPath(platform).extname(command) !== "")
15640
- return [""];
15641
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
15642
- }
15643
- function isExecutableFile(filePath, platform) {
15644
- try {
15645
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
15646
- return fs.statSync(filePath).isFile();
15647
- } catch {
15648
- return false;
15649
- }
15650
- }
15651
- function subdirectoryNames(directory) {
15652
- try {
15653
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
15654
- } catch {
15655
- return [];
15656
- }
15657
- }
15658
- function newestFirst(names) {
15659
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
15660
- }
15661
-
15662
- // ../../harness-discovery/dist/invocation.js
15663
- import path2 from "node:path";
15664
- function commandInvocation(command, arguments_, environment, platform = process.platform) {
15665
- const extension = path2.win32.extname(command).toLowerCase();
15666
- if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
15667
- return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
15668
- }
15669
- const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
15670
- const commandLine = [command, ...arguments_].map(quote).join(" ");
15671
- return {
15672
- command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
15673
- arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
15674
- windowsVerbatimArguments: true
15675
- };
15676
- }
15677
-
15678
- // ../../harness-discovery/dist/resolve.js
15679
- import os from "node:os";
15680
-
15681
- // ../../harness-discovery/dist/version-managers.js
15682
- function versionManagerBinaryDirectories(context) {
15683
- const { platform, environment, home } = context;
15684
- const list = context.subdirectories ?? subdirectoryNames;
15685
- const pathFlavor = targetPath(platform);
15686
- const value = (name) => environmentValue(environment, name);
15687
- const directories = [];
15688
- const versioned = (root, ...tail) => {
15689
- for (const version2 of newestFirst(list(root))) {
15690
- directories.push(pathFlavor.join(root, version2, ...tail));
15691
- }
15692
- };
15693
- if (platform === "win32") {
15694
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
15695
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
15696
- versioned(pathFlavor.join(appData, "nvm"));
15697
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
15698
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
15699
- directories.push(pathFlavor.join(home, ".bun", "bin"));
15700
- const pnpmHome2 = value("PNPM_HOME");
15701
- if (pnpmHome2)
15702
- directories.push(pnpmHome2);
15703
- directories.push(pathFlavor.join(localAppData, "pnpm"));
15704
- return directories;
15705
- }
15706
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
15707
- const fnmRoots = [
15708
- value("FNM_DIR"),
15709
- pathFlavor.join(home, ".local", "share", "fnm"),
15710
- pathFlavor.join(home, "Library", "Application Support", "fnm")
15711
- ].filter((root) => root !== void 0);
15712
- for (const root of fnmRoots) {
15713
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
15714
- }
15715
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
15716
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
15717
- directories.push(pathFlavor.join(voltaHome, "bin"));
15718
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
15719
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
15720
- directories.push(pathFlavor.join(asdfHome, "shims"));
15721
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
15722
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
15723
- directories.push(pathFlavor.join(nodenvHome, "shims"));
15724
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
15725
- directories.push(pathFlavor.join(home, ".bun", "bin"));
15726
- const pnpmHome = value("PNPM_HOME");
15727
- if (pnpmHome)
15728
- directories.push(pnpmHome);
15729
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
15730
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
15731
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
15732
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
15733
- directories.push(pathFlavor.join(prefix, formula, "bin"));
15734
- }
15735
- }
15736
- return directories;
15737
- }
15738
-
15739
- // ../../harness-discovery/dist/resolve.js
15740
- var VERSION_MANAGER_ROOTS = "<version-managers>";
15741
- function installRootExtensions(platform) {
15742
- return platform === "win32" ? [".exe", ".cmd"] : [""];
15743
- }
15744
- function resolveHomeDirectory(input) {
15745
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
15746
- }
15747
- function templateVariables(environment, platform, home) {
15748
- const pathFlavor = targetPath(platform);
15749
- return {
15750
- HOME: home,
15751
- USERPROFILE: home,
15752
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
15753
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
15754
- };
15755
- }
15756
- function joinTemplate(platform, value) {
15757
- const pathFlavor = targetPath(platform);
15758
- const segments = value.split("/");
15759
- const head = segments[0] ?? "";
15760
- const tail = segments.slice(1);
15761
- if (head === "")
15762
- return pathFlavor.join(pathFlavor.sep, ...tail);
15763
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
15764
- }
15765
- function expandInstallRoot(template, environment, platform, home) {
15766
- const variables = templateVariables(environment, platform, home);
15767
- let unresolved = false;
15768
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
15769
- const value = variables[name] ?? environmentValue(environment, name);
15770
- if (value === void 0 || value === "") {
15771
- unresolved = true;
15772
- return "";
15773
- }
15774
- return value;
15775
- });
15776
- return unresolved ? void 0 : joinTemplate(platform, substituted);
15777
- }
15778
- function installRootDirectories(spec, input, dependencies, platform, home) {
15779
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
15780
- const directories = [];
15781
- for (const template of templates) {
15782
- if (template === VERSION_MANAGER_ROOTS) {
15783
- directories.push(...versionManagerBinaryDirectories({
15784
- platform,
15785
- environment: input.environment,
15786
- home,
15787
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
15788
- }));
15789
- continue;
15790
- }
15791
- const directory = expandInstallRoot(template, input.environment, platform, home);
15792
- if (directory !== void 0)
15793
- directories.push(directory);
15794
- }
15795
- return directories;
15796
- }
15797
- function harnessCandidates(spec, input, dependencies = {}) {
15798
- const platform = input.platform ?? process.platform;
15799
- const pathFlavor = targetPath(platform);
15800
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
15801
- const command = configured ?? spec.command;
15802
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
15803
- return [{ candidate: command, source: "configured" }];
15804
- }
15805
- const candidates = [];
15806
- const extensions = executableExtensions(command, platform, input.environment);
15807
- for (const directory of pathDirectories(input.environment, platform)) {
15808
- for (const extension of extensions) {
15809
- candidates.push({
15810
- candidate: pathFlavor.join(directory, command + extension),
15811
- source: "path"
15812
- });
15813
- }
15814
- }
15815
- if (configured !== void 0)
15816
- return candidates;
15817
- const home = resolveHomeDirectory(input);
15818
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
15819
- for (const extension of installRootExtensions(platform)) {
15820
- candidates.push({
15821
- candidate: pathFlavor.join(directory, spec.command + extension),
15822
- source: "install-root"
15823
- });
15824
- }
15825
- }
15826
- return candidates;
15827
- }
15828
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
15829
- const platform = input.platform ?? process.platform;
15830
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
15831
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
15832
- const context = { platform, isExecutable };
15833
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
15834
- const executable = runnable(candidate, context);
15835
- if (executable !== void 0 && isExecutable(executable))
15836
- return { executable, source };
15837
- }
15838
- return void 0;
15839
- }
15840
-
15841
16150
  // dist/command.js
15842
- import path3 from "node:path";
16151
+ import path4 from "node:path";
15843
16152
  var antigravityDiscoverySpec = {
15844
16153
  id: "antigravity",
15845
16154
  command: "agy",
@@ -15859,20 +16168,20 @@ function resolveAntigravityExecutable(input = {}) {
15859
16168
  });
15860
16169
  if (!resolution)
15861
16170
  return void 0;
15862
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path3.resolve(resolution.executable);
16171
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path4.resolve(resolution.executable);
15863
16172
  }
15864
16173
 
15865
16174
  // dist/fork.js
15866
16175
  import { randomUUID as randomUUID2 } from "node:crypto";
15867
16176
  import { copyFile, cp, mkdir as mkdir2 } from "node:fs/promises";
15868
16177
  import os3 from "node:os";
15869
- import path5 from "node:path";
16178
+ import path6 from "node:path";
15870
16179
 
15871
16180
  // dist/history.js
15872
16181
  import { randomUUID } from "node:crypto";
15873
- import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
16182
+ import { mkdir, readFile, readdir, rename, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
15874
16183
  import os2 from "node:os";
15875
- import path4 from "node:path";
16184
+ import path5 from "node:path";
15876
16185
  var HISTORY_VERSION = 1;
15877
16186
  var THREAD_ID_ENV = "CODEXHOST_THREAD_ID";
15878
16187
  var harnessErrorSchema = external_exports.strictObject({
@@ -15969,7 +16278,7 @@ var historySchema = external_exports.strictObject({
15969
16278
  });
15970
16279
  function historyRoot(environment) {
15971
16280
  const dataDirectory = environment.CODEXHOST_DATA_DIR;
15972
- return path4.join(dataDirectory ? path4.resolve(dataDirectory) : path4.join(os2.homedir(), ".codexhost"), "antigravity-history");
16281
+ return path5.join(dataDirectory ? path5.resolve(dataDirectory) : path5.join(os2.homedir(), ".codexhost"), "antigravity-history");
15973
16282
  }
15974
16283
  function safeThreadId(environment) {
15975
16284
  const threadId = (environment[THREAD_ID_ENV] ?? environment.CODEXHOST_DELEGATION_THREAD_ID)?.trim();
@@ -15977,7 +16286,7 @@ function safeThreadId(environment) {
15977
16286
  }
15978
16287
  function historyPath(environment) {
15979
16288
  const threadId = safeThreadId(environment);
15980
- return threadId ? path4.join(historyRoot(environment), `${threadId}.json`) : null;
16289
+ return threadId ? path5.join(historyRoot(environment), `${threadId}.json`) : null;
15981
16290
  }
15982
16291
  function jsonTurn(turn) {
15983
16292
  return JSON.parse(JSON.stringify(turn));
@@ -16056,7 +16365,7 @@ var AntigravityHistory = class _AntigravityHistory {
16056
16365
  for (const entry of entries) {
16057
16366
  if (!entry.endsWith(".json"))
16058
16367
  continue;
16059
- const file2 = path4.join(root, entry);
16368
+ const file2 = path5.join(root, entry);
16060
16369
  try {
16061
16370
  const parsed = historySchema.safeParse(JSON.parse(await readFile(file2, "utf8")));
16062
16371
  if (parsed.success && parsed.data.nativeSessionId === nativeSessionId) {
@@ -16143,11 +16452,11 @@ var AntigravityHistory = class _AntigravityHistory {
16143
16452
  const model = this.#model;
16144
16453
  const thinkingOptionId = this.#thinkingOptionId;
16145
16454
  this.#write = this.#write.catch(() => void 0).then(async () => {
16146
- const directory = path4.dirname(file2);
16455
+ const directory = path5.dirname(file2);
16147
16456
  await mkdir(directory, { recursive: true, mode: 448 });
16148
- const temporary = path4.join(directory, `.${path4.basename(file2)}.${randomUUID()}.tmp`);
16457
+ const temporary = path5.join(directory, `.${path5.basename(file2)}.${randomUUID()}.tmp`);
16149
16458
  try {
16150
- await writeFile(temporary, `${JSON.stringify({
16459
+ await writeFile2(temporary, `${JSON.stringify({
16151
16460
  formatVersion: HISTORY_VERSION,
16152
16461
  nativeSessionId,
16153
16462
  turns,
@@ -16157,31 +16466,31 @@ var AntigravityHistory = class _AntigravityHistory {
16157
16466
  `, { mode: 384 });
16158
16467
  await rename(temporary, file2);
16159
16468
  } finally {
16160
- await rm(temporary, { force: true }).catch(() => void 0);
16469
+ await rm2(temporary, { force: true }).catch(() => void 0);
16161
16470
  }
16162
16471
  });
16163
16472
  }
16164
16473
  };
16165
16474
 
16166
16475
  // dist/fork.js
16167
- function nativeConversationDbPath(nativeSessionId, homedir = os3.homedir()) {
16168
- return path5.join(homedir, ".gemini", "antigravity-cli", "conversations", `${nativeSessionId}.db`);
16476
+ function nativeConversationDbPath(nativeSessionId, homedir2 = os3.homedir()) {
16477
+ return path6.join(homedir2, ".gemini", "antigravity-cli", "conversations", `${nativeSessionId}.db`);
16169
16478
  }
16170
- function nativeBrainDirPath(nativeSessionId, homedir = os3.homedir()) {
16171
- return path5.join(homedir, ".gemini", "antigravity-cli", "brain", nativeSessionId);
16479
+ function nativeBrainDirPath(nativeSessionId, homedir2 = os3.homedir()) {
16480
+ return path6.join(homedir2, ".gemini", "antigravity-cli", "brain", nativeSessionId);
16172
16481
  }
16173
16482
  async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, retainedTurnsCountOrHomedir, homedirOption = os3.homedir()) {
16174
16483
  let retainedTurnsCount;
16175
- let homedir = homedirOption;
16484
+ let homedir2 = homedirOption;
16176
16485
  if (typeof retainedTurnsCountOrHomedir === "string") {
16177
- homedir = retainedTurnsCountOrHomedir;
16486
+ homedir2 = retainedTurnsCountOrHomedir;
16178
16487
  } else if (typeof retainedTurnsCountOrHomedir === "number") {
16179
16488
  retainedTurnsCount = retainedTurnsCountOrHomedir;
16180
16489
  }
16181
- const sourceDb = nativeConversationDbPath(sourceSessionId, homedir);
16182
- const targetDb = nativeConversationDbPath(derivedSessionId, homedir);
16490
+ const sourceDb = nativeConversationDbPath(sourceSessionId, homedir2);
16491
+ const targetDb = nativeConversationDbPath(derivedSessionId, homedir2);
16183
16492
  try {
16184
- await mkdir2(path5.dirname(targetDb), { recursive: true });
16493
+ await mkdir2(path6.dirname(targetDb), { recursive: true });
16185
16494
  await copyFile(sourceDb, targetDb);
16186
16495
  } catch {
16187
16496
  return false;
@@ -16232,7 +16541,7 @@ async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, reta
16232
16541
  } catch {
16233
16542
  }
16234
16543
  try {
16235
- const summariesDbPath = path5.join(homedir, ".gemini", "antigravity-cli", "conversation_summaries.db");
16544
+ const summariesDbPath = path6.join(homedir2, ".gemini", "antigravity-cli", "conversation_summaries.db");
16236
16545
  const sumDb = new DatabaseSync(summariesDbPath);
16237
16546
  try {
16238
16547
  const cur = sumDb.prepare("SELECT * FROM conversation_summaries WHERE conversation_id = ?");
@@ -16269,13 +16578,13 @@ async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, reta
16269
16578
  return true;
16270
16579
  }
16271
16580
  var copyNativeConversationDbIfExists = cloneNativeConversationDb;
16272
- async function copyNativeBrainDirIfExists(sourceSessionId, derivedSessionId, homedir = os3.homedir()) {
16273
- const sourceBrain = nativeBrainDirPath(sourceSessionId, homedir);
16274
- const targetBrain = nativeBrainDirPath(derivedSessionId, homedir);
16581
+ async function copyNativeBrainDirIfExists(sourceSessionId, derivedSessionId, homedir2 = os3.homedir()) {
16582
+ const sourceBrain = nativeBrainDirPath(sourceSessionId, homedir2);
16583
+ const targetBrain = nativeBrainDirPath(derivedSessionId, homedir2);
16275
16584
  try {
16276
16585
  await cp(sourceBrain, targetBrain, {
16277
16586
  recursive: true,
16278
- filter: (source) => path5.basename(source) !== ".system_generated"
16587
+ filter: (source) => path6.basename(source) !== ".system_generated"
16279
16588
  });
16280
16589
  return true;
16281
16590
  } catch {
@@ -16726,7 +17035,7 @@ function parseAndFormatAntigravityCommand(command) {
16726
17035
  import https from "node:https";
16727
17036
 
16728
17037
  // dist/tool-projection.js
16729
- import path6 from "node:path";
17038
+ import path7 from "node:path";
16730
17039
  function isRecord(value) {
16731
17040
  return typeof value === "object" && value !== null && !Array.isArray(value);
16732
17041
  }
@@ -16747,10 +17056,10 @@ function displayPath(nativePath, cwd) {
16747
17056
  if (typeof nativePath !== "string" || nativePath.trim().length === 0 || nativePath.includes("\0") || nativePath.includes("\n") || nativePath.includes("\r")) {
16748
17057
  return null;
16749
17058
  }
16750
- const resolvedCwd = path6.resolve(cwd);
16751
- const resolvedPath = path6.isAbsolute(nativePath) ? path6.resolve(nativePath) : path6.resolve(cwd, nativePath);
16752
- const relative = path6.relative(resolvedCwd, resolvedPath);
16753
- const inside = !path6.isAbsolute(relative) && relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path6.sep}`);
17059
+ const resolvedCwd = path7.resolve(cwd);
17060
+ const resolvedPath = path7.isAbsolute(nativePath) ? path7.resolve(nativePath) : path7.resolve(cwd, nativePath);
17061
+ const relative = path7.relative(resolvedCwd, resolvedPath);
17062
+ const inside = !path7.isAbsolute(relative) && relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path7.sep}`);
16754
17063
  const selected = inside ? relative : resolvedPath;
16755
17064
  const normalized = selected.replaceAll("\\", "/");
16756
17065
  if (normalized.length === 0 || normalized === ".")
@@ -16881,7 +17190,7 @@ function synthesizeAntigravityCommand(toolName, params, cwd) {
16881
17190
  ]);
16882
17191
  let resolvedCwd;
16883
17192
  if (workingDir && workingDir.trim().length > 0) {
16884
- resolvedCwd = cwd && !path6.isAbsolute(workingDir) ? path6.resolve(cwd, workingDir) : workingDir;
17193
+ resolvedCwd = cwd && !path7.isAbsolute(workingDir) ? path7.resolve(cwd, workingDir) : workingDir;
16885
17194
  } else if (cwd) {
16886
17195
  resolvedCwd = cwd;
16887
17196
  }
@@ -17282,10 +17591,10 @@ async function fetchAntigravityQuota(run, now = /* @__PURE__ */ new Date()) {
17282
17591
 
17283
17592
  // dist/question-bridge.js
17284
17593
  import { randomBytes, randomUUID as randomUUID4, timingSafeEqual } from "node:crypto";
17285
- import { mkdir as mkdir3, mkdtemp, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
17594
+ import { mkdir as mkdir3, mkdtemp as mkdtemp2, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
17286
17595
  import { createServer } from "node:http";
17287
17596
  import os4 from "node:os";
17288
- import path7 from "node:path";
17597
+ import path8 from "node:path";
17289
17598
 
17290
17599
  // dist/question-hook-client.js
17291
17600
  var ANTIGRAVITY_QUESTION_HOOK_CLIENT = String.raw`
@@ -17410,7 +17719,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17410
17719
  this.#server.on("request", (request, response) => this.#receive(request, response));
17411
17720
  }
17412
17721
  static async create(options) {
17413
- const directory = await mkdtemp(path7.join(os4.tmpdir(), "codexhost-agy-question-"));
17722
+ const directory = await mkdtemp2(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
17414
17723
  const bridge = new _AntigravityQuestionBridge(directory, options);
17415
17724
  try {
17416
17725
  await new Promise((resolve, reject) => {
@@ -17425,14 +17734,14 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17425
17734
  if (!address || typeof address === "string")
17426
17735
  throw new Error("Question bridge did not bind");
17427
17736
  bridge.environment.CODEXHOST_AGY_QUESTION_URL = `http://127.0.0.1:${address.port}/question`;
17428
- const client = path7.join(directory, "question-hook.cjs");
17429
- await mkdir3(path7.join(directory, ".agents"));
17430
- await writeFile2(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
17737
+ const client = path8.join(directory, "question-hook.cjs");
17738
+ await mkdir3(path8.join(directory, ".agents"));
17739
+ await writeFile3(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
17431
17740
  const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
17432
17741
  bridge.environment.CODEXHOST_AGY_QUESTION_NODE = `"${process.execPath.replaceAll("\\", "/")}"`;
17433
17742
  bridge.environment.CODEXHOST_AGY_QUESTION_CLIENT = `"${client.replaceAll("\\", "/")}"`;
17434
17743
  const command = process.platform === "win32" ? "%CODEXHOST_AGY_QUESTION_NODE% %CODEXHOST_AGY_QUESTION_CLIENT%" : `${quote(process.execPath)} ${quote(client)}`;
17435
- await writeFile2(path7.join(directory, ".agents", "hooks.json"), JSON.stringify({
17744
+ await writeFile3(path8.join(directory, ".agents", "hooks.json"), JSON.stringify({
17436
17745
  "codexhost-question-bridge": {
17437
17746
  PreToolUse: [
17438
17747
  {
@@ -17655,7 +17964,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17655
17964
  this.#server.close(() => resolve());
17656
17965
  this.#server.closeAllConnections();
17657
17966
  });
17658
- await rm2(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
17967
+ await rm3(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
17659
17968
  })();
17660
17969
  return this.#disposal;
17661
17970
  }
@@ -17667,7 +17976,7 @@ import { randomUUID as randomUUID5 } from "node:crypto";
17667
17976
  // dist/subagent-transcript.js
17668
17977
  import { open, realpath } from "node:fs/promises";
17669
17978
  import https2 from "node:https";
17670
- import path8 from "node:path";
17979
+ import path9 from "node:path";
17671
17980
  var nativeSubagentIdSchema = external_exports.uuid();
17672
17981
  var MAX_TRANSCRIPT_BYTES = 8 * 1024 * 1024;
17673
17982
  var transcriptStepSchema = external_exports.object({
@@ -17835,10 +18144,10 @@ async function readSubagentTranscript(input) {
17835
18144
  };
17836
18145
  }
17837
18146
  try {
17838
- const file2 = path8.join(nativeBrainDirPath(input.childId, input.home), ".system_generated", "logs", "transcript.jsonl");
17839
- const brainRoot = await realpath(path8.dirname(nativeBrainDirPath(input.childId, input.home)));
18147
+ const file2 = path9.join(nativeBrainDirPath(input.childId, input.home), ".system_generated", "logs", "transcript.jsonl");
18148
+ const brainRoot = await realpath(path9.dirname(nativeBrainDirPath(input.childId, input.home)));
17840
18149
  const resolved = await realpath(file2);
17841
- const expected = path8.join(brainRoot, input.childId, ".system_generated", "logs", "transcript.jsonl");
18150
+ const expected = path9.join(brainRoot, input.childId, ".system_generated", "logs", "transcript.jsonl");
17842
18151
  const normalize = (value) => process.platform === "win32" ? value.toLowerCase() : value;
17843
18152
  if (normalize(resolved) !== normalize(expected))
17844
18153
  throw new Error("Subagent log redirects outside its native location");
@@ -18183,8 +18492,8 @@ function mergePendingStep(pending, step) {
18183
18492
  };
18184
18493
  }
18185
18494
  function sameFile(left, right) {
18186
- const a = path9.resolve(left);
18187
- const b = path9.resolve(right);
18495
+ const a = path10.resolve(left);
18496
+ const b = path10.resolve(right);
18188
18497
  return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
18189
18498
  }
18190
18499
  function resolveAntigravityContextWindow(modelId, reportedWindow) {
@@ -18351,7 +18660,9 @@ function normalizedProcessError(detail, fallback, exposeDetail = false) {
18351
18660
  return {
18352
18661
  code: "nativeFailure",
18353
18662
  message: exposeDetail && nativeDetail ? `${fallback}: ${nativeDetail}` : fallback,
18354
- retryable: true,
18663
+ // These native rejections need a changed precondition or a quota reset;
18664
+ // immediately replaying a Turn (and its tools) cannot resolve them.
18665
+ retryable: !/User location is not supported for the API use|Individual quota reached/iu.test(nativeDetail),
18355
18666
  ...diagnostic ? { stderrTail: diagnostic.slice(-4e3) } : {}
18356
18667
  };
18357
18668
  }
@@ -18543,7 +18854,7 @@ var AntigravitySession = class {
18543
18854
  return { ok: false, error: invalidState("Antigravity Session is closed") };
18544
18855
  }
18545
18856
  const environment = { ...this.#environment, ...questions.environment };
18546
- const logPath = path9.join(os5.tmpdir(), `codexhost-antigravity-${randomUUID6()}.log`);
18857
+ const logPath = path10.join(os5.tmpdir(), `codexhost-antigravity-${randomUUID6()}.log`);
18547
18858
  const arguments_ = [
18548
18859
  "--input-format",
18549
18860
  "stream-json",
@@ -18762,6 +19073,18 @@ ${line}`).slice(-8e3);
18762
19073
  async #handleResult(active, event) {
18763
19074
  if (this.#active !== active)
18764
19075
  return;
19076
+ const resultConversationId = event.result.conversation_id.trim();
19077
+ if (resultConversationId && this.#nativeRef && resultConversationId !== this.#nativeRef.nativeSessionId) {
19078
+ this.#completeTurn(active, {
19079
+ status: "failed",
19080
+ error: {
19081
+ code: "protocolError",
19082
+ message: "Antigravity returned a result for a different Conversation",
19083
+ retryable: false
19084
+ }
19085
+ });
19086
+ return;
19087
+ }
18765
19088
  const usage = hostUsage(event.result.usage, active.model?.id);
18766
19089
  if (usage)
18767
19090
  this.#publishUsage(active, usage);
@@ -18774,7 +19097,7 @@ ${line}`).slice(-8e3);
18774
19097
  await active.subagents.refresh();
18775
19098
  if (this.#active !== active)
18776
19099
  return;
18777
- const convId = event.result.conversation_id && event.result.conversation_id.trim().length > 0 ? event.result.conversation_id.trim() : this.#nativeRef?.nativeSessionId ?? "";
19100
+ const convId = resultConversationId || this.#nativeRef?.nativeSessionId || "";
18778
19101
  if (!this.#nativeRef && convId) {
18779
19102
  this.#nativeRef = nativeSessionRefSchema.parse({
18780
19103
  harnessId: this.harnessId,
@@ -19222,7 +19545,7 @@ var AntigravityAdapter = class {
19222
19545
  if (this.#closed) {
19223
19546
  return { status: "unavailable", error: invalidState("Antigravity Adapter is closed") };
19224
19547
  }
19225
- const cwd = path9.resolve(input.cwd ?? process.cwd());
19548
+ const cwd = path10.resolve(input.cwd ?? process.cwd());
19226
19549
  const inFlight = this.#inspectionInFlight.get(cwd);
19227
19550
  if (inFlight)
19228
19551
  return inFlight;
@@ -19364,7 +19687,7 @@ var AntigravityAdapter = class {
19364
19687
  }
19365
19688
  };
19366
19689
  }
19367
- const cwd = path9.resolve(input.cwd);
19690
+ const cwd = path10.resolve(input.cwd);
19368
19691
  let catalog = this.#inspectionCache.get(cwd)?.catalog;
19369
19692
  if (!catalog) {
19370
19693
  const inspection = await this.inspect({ cwd: input.cwd });
@@ -19510,13 +19833,59 @@ var AntigravityAdapter = class {
19510
19833
  }
19511
19834
  };
19512
19835
 
19836
+ // dist/installation.js
19837
+ var ANTIGRAVITY_UPDATE_MANIFEST_ROOT = "https://antigravity-cli-auto-updater-974169037036.us-central1.run.app";
19838
+ function antigravityUpdateManifestUrl(platform = process.platform, arch = process.arch) {
19839
+ const system = platform === "darwin" ? "darwin" : platform === "linux" ? "linux" : platform === "win32" ? "windows" : void 0;
19840
+ const cpu = arch === "arm64" ? "arm64" : arch === "x64" ? "amd64" : void 0;
19841
+ if (!system || !cpu)
19842
+ throw new Error("Antigravity updates are unavailable for this platform");
19843
+ return `${ANTIGRAVITY_UPDATE_MANIFEST_ROOT}/manifests/${system}_${cpu}.json`;
19844
+ }
19845
+ function createAntigravityInstallation(environment, command, dependencies = {}) {
19846
+ const run = dependencies.run ?? ((args, timeout) => runInstallationCommand(resolveAntigravityExecutable({ environment, ...command ? { command } : {} }) ?? "agy", args, environment, timeout));
19847
+ const fetchText = dependencies.fetchText ?? fetchInstallationText;
19848
+ const platform = dependencies.platform ?? process.platform;
19849
+ const arch = dependencies.arch ?? process.arch;
19850
+ return createInstallationManager({
19851
+ async check() {
19852
+ const manifestUrl = antigravityUpdateManifestUrl(platform, arch);
19853
+ const currentVersion = versionFromOutput(await run(["--version"]));
19854
+ let payload;
19855
+ try {
19856
+ payload = JSON.parse(await fetchText(manifestUrl));
19857
+ } catch (error51) {
19858
+ if (error51 instanceof SyntaxError)
19859
+ throw new Error("Could not check the latest Antigravity version");
19860
+ throw error51;
19861
+ }
19862
+ const latestVersion = installationVersion(payload.version);
19863
+ return {
19864
+ currentVersion,
19865
+ latestVersion,
19866
+ updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
19867
+ canUpdate: true
19868
+ };
19869
+ },
19870
+ async update() {
19871
+ await run(["update"], 3e5);
19872
+ }
19873
+ });
19874
+ }
19875
+
19513
19876
  // dist/plugin.js
19514
19877
  var ANTIGRAVITY_COMMAND_ENV = "CODEXHOST_ANTIGRAVITY_COMMAND";
19515
19878
  function createHarnessAdapter(context) {
19516
19879
  const environment = { ...context.environment };
19517
- return new AntigravityAdapter({
19880
+ return Object.assign(new AntigravityAdapter({
19518
19881
  ...environment[ANTIGRAVITY_COMMAND_ENV] ? { command: environment[ANTIGRAVITY_COMMAND_ENV] } : {},
19519
19882
  environment
19883
+ }), {
19884
+ install: createHarnessInstaller(environment, {
19885
+ posix: "https://antigravity.google/cli/install.sh",
19886
+ windows: "https://antigravity.google/cli/install.ps1"
19887
+ }),
19888
+ installation: createAntigravityInstallation(environment, environment[ANTIGRAVITY_COMMAND_ENV])
19520
19889
  });
19521
19890
  }
19522
19891
  async function warmup(adapter) {