@liberseek/boft-cli-win32-arm64 0.7.6 → 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,6 +5,409 @@ 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";
@@ -14598,6 +15001,71 @@ var harnessDisplaySetSchema = external_exports.strictObject({
14598
15001
  initializeOnly: external_exports.boolean().optional()
14599
15002
  });
14600
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
+
14601
15069
  // ../../shared-contracts/dist/console.js
14602
15070
  var consoleAnnouncementSchema = external_exports.strictObject({
14603
15071
  title: external_exports.string().trim().min(1).max(200),
@@ -14614,8 +15082,11 @@ var CONSOLE_HOST_METHODS = Object.freeze([
14614
15082
  "codexhost/harness/display-settings/get",
14615
15083
  "codexhost/harness/display-settings/set",
14616
15084
  "codexhost/harness/inspect",
15085
+ "codexhost/harness/installation",
14617
15086
  "codexhost/harness/launch-settings/get",
14618
15087
  "codexhost/harness/launch-settings/set",
15088
+ HARNESS_LONG_CONTEXT_GET_METHOD,
15089
+ HARNESS_LONG_CONTEXT_SET_METHOD,
14619
15090
  "codexhost/harness/web-ui/open",
14620
15091
  "codexhost/harness/accounts/sources",
14621
15092
  "codexhost/harness/accounts/list",
@@ -14675,16 +15146,6 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
14675
15146
  inactiveMs: external_exports.number().nonnegative()
14676
15147
  }));
14677
15148
 
14678
- // ../../shared-contracts/dist/ids.js
14679
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14680
- message: "Identifier must not be empty or whitespace"
14681
- });
14682
- var harnessIdSchema = opaqueIdSchema.brand();
14683
- var hostThreadIdSchema = opaqueIdSchema.brand();
14684
- var hostTurnIdSchema = opaqueIdSchema.brand();
14685
- var hostItemIdSchema = opaqueIdSchema.brand();
14686
- var hostInteractionIdSchema = opaqueIdSchema.brand();
14687
-
14688
15149
  // ../../shared-contracts/dist/manual-compaction.js
14689
15150
  var threadManualCompactionStartedSchema = external_exports.strictObject({
14690
15151
  threadId: hostThreadIdSchema,
@@ -15214,48 +15675,6 @@ var threadOwnershipListResultSchema = external_exports.object({
15214
15675
  }
15215
15676
  });
15216
15677
 
15217
- // ../../shared-contracts/dist/harness-plugins.js
15218
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15219
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15220
- var HARNESS_PLUGIN_LIMIT = 128;
15221
- 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);
15222
- 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");
15223
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15224
- var pluginPresentationShape = {
15225
- id: harnessPluginIdSchema,
15226
- name: external_exports.string().trim().min(1).max(128),
15227
- version: external_exports.string().min(1).max(128),
15228
- /** The factory accepts a persisted local entrypoint through its construction context. */
15229
- launchCommand: external_exports.literal(true).optional(),
15230
- links: external_exports.object({
15231
- documentation: documentationUrlSchema.optional(),
15232
- installation: documentationUrlSchema.optional()
15233
- }).strict().optional()
15234
- };
15235
- var harnessPluginManifestSchema = external_exports.object({
15236
- manifestVersion: external_exports.literal(1),
15237
- ...pluginPresentationShape,
15238
- adapterApiVersion: external_exports.number().int().positive(),
15239
- entry: relativeResourceSchema,
15240
- icon: relativeResourceSchema.optional()
15241
- }).strict();
15242
- 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);
15243
- var harnessPluginDescriptorSchema = external_exports.object({
15244
- ...pluginPresentationShape,
15245
- icon: harnessPluginIconSchema.optional()
15246
- }).strict();
15247
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
15248
- var harnessPluginListResultSchema = external_exports.object({
15249
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15250
- }).strict();
15251
- var harnessPluginConfigurationSchema = external_exports.object({
15252
- version: external_exports.literal(1),
15253
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15254
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15255
- message: "Enabled plugin IDs must be unique",
15256
- path: ["enabled"]
15257
- });
15258
-
15259
15678
  // ../../shared-contracts/dist/harness-route.js
15260
15679
  var harnessPluginRouteSchema = external_exports.object({
15261
15680
  harnessId: harnessPluginIdSchema,
@@ -15280,7 +15699,7 @@ var harnessLaunchSettingsSchema = external_exports.object({
15280
15699
  // ../../shared-contracts/dist/harness-installation.js
15281
15700
  var harnessInstallationParamsSchema = external_exports.object({
15282
15701
  harnessId: harnessIdSchema,
15283
- action: external_exports.enum(["check", "update"])
15702
+ action: external_exports.enum(["check", "update", "install"])
15284
15703
  }).strict();
15285
15704
  var harnessInstallationStateSchema = external_exports.object({
15286
15705
  currentVersion: external_exports.string().min(1).max(128),
@@ -15402,681 +15821,332 @@ var deepSeekModernSessionListResultSchema = external_exports.object({
15402
15821
  var deepSeekModernSessionImportParamsSchema = external_exports.object({
15403
15822
  nativeSessionId: deepSeekModernSessionIdSchema
15404
15823
  }).strict();
15405
- var deepSeekModernSessionImportResultSchema = external_exports.object({
15406
- threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
15407
- }).strict();
15408
-
15409
- // ../../shared-contracts/dist/external-thread-fork.js
15410
- var externalThreadForkParamsSchema = external_exports.object({
15411
- threadId: hostThreadIdSchema,
15412
- lastTurnId: hostTurnIdSchema
15413
- }).strict();
15414
- var externalThreadForkResultSchema = external_exports.object({
15415
- threadId: hostThreadIdSchema
15416
- }).strict();
15417
-
15418
- // ../../shared-contracts/dist/harness-commands.js
15419
- var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
15420
- var commandInvocationSchema = external_exports.string().min(1).max(128);
15421
- var commandLabelSchema = external_exports.string().trim().min(1).max(128);
15422
- var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
15423
- var harnessCommandDescriptorSchema = external_exports.object({
15424
- id: commandIdSchema,
15425
- invocation: commandInvocationSchema,
15426
- label: commandLabelSchema,
15427
- description: commandDescriptionSchema.optional(),
15428
- argumentMode: external_exports.enum(["none", "text"]),
15429
- /**
15430
- * Native distinction reported by the Harness. Omitted when the Harness does
15431
- * not tell skills and commands apart; consumers treat that as "command".
15432
- */
15433
- kind: external_exports.enum(["command", "skill"]).optional()
15434
- }).strict();
15435
- var harnessCommandCatalogSchema = external_exports.object({
15436
- commands: external_exports.array(harnessCommandDescriptorSchema),
15437
- /**
15438
- * `live` when the catalog includes what a native Session reports for its
15439
- * workspace (custom commands, skills); `static` for Adapter built-ins only.
15440
- * Omitted by Adapters; set by the Host on inspection results.
15441
- */
15442
- source: external_exports.enum(["live", "static"]).optional()
15443
- }).strict().superRefine((catalog, context) => {
15444
- const ids = /* @__PURE__ */ new Set();
15445
- for (const [index, command] of catalog.commands.entries()) {
15446
- if (ids.has(command.id)) {
15447
- context.addIssue({
15448
- code: "custom",
15449
- message: "Harness command IDs must be unique",
15450
- path: ["commands", index, "id"]
15451
- });
15452
- }
15453
- ids.add(command.id);
15454
- }
15455
- });
15456
- var harnessCommandsInspectParamsSchema = external_exports.object({
15457
- harnessId: harnessIdSchema,
15458
- /** Workspace of a draft without a Thread, for its live catalog when known. */
15459
- cwd: external_exports.string().min(1).optional()
15460
- }).strict();
15461
- var threadCommandsInspectParamsSchema = external_exports.object({
15462
- threadId: hostThreadIdSchema
15463
- }).strict();
15464
- var threadCommandExecuteParamsSchema = external_exports.object({
15465
- threadId: hostThreadIdSchema,
15466
- commandId: commandIdSchema,
15467
- turnId: hostTurnIdSchema.optional(),
15468
- arguments: jsonObjectSchema.optional()
15469
- }).strict();
15470
- var threadCommandExecuteResultSchema = external_exports.object({
15471
- accepted: external_exports.literal(true),
15472
- turnId: hostTurnIdSchema
15473
- }).strict();
15474
-
15475
- // ../../shared-contracts/dist/json-rpc.js
15476
- var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
15477
- var absentSchema = external_exports.never().optional();
15478
- var methodSchema = external_exports.string().min(1);
15479
- var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
15480
- var jsonRpcErrorSchema = external_exports.object({
15481
- code: external_exports.number().int(),
15482
- message: external_exports.string(),
15483
- data: jsonValueSchema.optional()
15484
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
15485
- var jsonRpcRequestSchema = external_exports.object({
15486
- jsonrpc: jsonRpcVersionSchema,
15487
- id: jsonRpcIdSchema,
15488
- method: methodSchema,
15489
- params: jsonValueSchema.optional(),
15490
- result: absentSchema,
15491
- error: absentSchema
15492
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
15493
- var jsonRpcNotificationSchema = external_exports.object({
15494
- jsonrpc: jsonRpcVersionSchema,
15495
- id: absentSchema,
15496
- method: methodSchema,
15497
- params: jsonValueSchema.optional(),
15498
- result: absentSchema,
15499
- error: absentSchema
15500
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
15501
- var jsonRpcSuccessResponseSchema = external_exports.object({
15502
- jsonrpc: jsonRpcVersionSchema,
15503
- id: jsonRpcIdSchema,
15504
- method: absentSchema,
15505
- params: absentSchema,
15506
- result: jsonValueSchema,
15507
- error: absentSchema
15508
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
15509
- var jsonRpcErrorResponseSchema = external_exports.object({
15510
- jsonrpc: jsonRpcVersionSchema,
15511
- id: jsonRpcIdSchema,
15512
- method: absentSchema,
15513
- params: absentSchema,
15514
- result: absentSchema,
15515
- error: jsonRpcErrorSchema
15516
- }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
15517
- var jsonRpcEnvelopeSchema = external_exports.union([
15518
- jsonRpcRequestSchema,
15519
- jsonRpcNotificationSchema,
15520
- jsonRpcSuccessResponseSchema,
15521
- jsonRpcErrorResponseSchema
15522
- ]);
15523
-
15524
- // ../../shared-contracts/dist/native-refs.js
15525
- var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15526
- message: "Native identifier must not be empty or whitespace"
15527
- });
15528
- var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
15529
- harnessId: harnessIdSchema,
15530
- nativeSessionId: nativeIdSchema,
15531
- locator: jsonValueSchema.optional(),
15532
- formatVersion: external_exports.literal(1)
15533
- }).superRefine(rejectExplicitUndefined(["locator"]));
15534
- var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
15535
- var nativeSessionRefSchema = nativeSessionRefV1Schema;
15536
- var nativeTurnRefV1Schema = external_exports.strictObject({
15537
- harnessId: harnessIdSchema,
15538
- nativeSessionId: nativeIdSchema,
15539
- nativeTurnKey: nativeIdSchema,
15540
- formatVersion: external_exports.literal(1)
15541
- });
15542
- var nativeTurnRefSchema = nativeTurnRefV1Schema;
15543
- var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
15544
- harnessId: harnessIdSchema,
15545
- nativeSessionId: nativeIdSchema,
15546
- checkpointId: nativeIdSchema,
15547
- locator: jsonValueSchema.optional(),
15548
- formatVersion: external_exports.literal(1)
15549
- }).superRefine(rejectExplicitUndefined(["locator"]));
15550
- var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
15551
- var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
15552
-
15553
- // ../../shared-contracts/dist/updates.js
15554
- var UPDATE_ERROR_MAX_LENGTH = 500;
15555
- var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
15556
- var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
15557
- var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
15558
- var updatePhaseSchema = external_exports.enum([
15559
- "prepared",
15560
- "downloading",
15561
- "waiting-for-exit",
15562
- "installing",
15563
- "restarting",
15564
- "succeeded",
15565
- "failed"
15566
- ]);
15567
- var updateStatusSchema = external_exports.strictObject({
15568
- version: updateSemanticVersionSchema,
15569
- installation: updateInstallationSchema,
15570
- phase: updatePhaseSchema,
15571
- updatedAt: external_exports.number().int().nonnegative(),
15572
- downloadedBytes: external_exports.number().int().nonnegative().optional(),
15573
- totalBytes: external_exports.number().int().positive().optional(),
15574
- error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15575
- }).superRefine((status, context) => {
15576
- if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
15577
- context.addIssue({
15578
- code: "custom",
15579
- path: ["downloadedBytes"],
15580
- message: "downloadedBytes must not exceed totalBytes"
15581
- });
15582
- }
15583
- });
15584
- var updateEmptyParamsSchema = external_exports.strictObject({});
15585
- var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/LiberSeek\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
15586
- var updateCheckResultSchema = external_exports.strictObject({
15587
- currentVersion: updateSemanticVersionSchema,
15588
- installation: updateInstallationSchema.nullable(),
15589
- latestVersion: updateSemanticVersionSchema.nullable(),
15590
- updateAvailable: external_exports.boolean(),
15591
- installationAvailable: external_exports.boolean(),
15592
- releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
15593
- releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
15594
- status: updateStatusSchema.nullable(),
15595
- error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15596
- });
15597
- var updateStartResultSchema = external_exports.strictObject({
15598
- status: updateStatusSchema
15599
- });
15600
- var updateStatusResultSchema = external_exports.strictObject({
15601
- status: updateStatusSchema.nullable()
15602
- });
15824
+ var deepSeekModernSessionImportResultSchema = external_exports.object({
15825
+ threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
15826
+ }).strict();
15603
15827
 
15604
- // ../../shared-contracts/dist/index.js
15605
- var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
15828
+ // ../../shared-contracts/dist/external-thread-fork.js
15829
+ var externalThreadForkParamsSchema = external_exports.object({
15830
+ threadId: hostThreadIdSchema,
15831
+ lastTurnId: hostTurnIdSchema
15832
+ }).strict();
15833
+ var externalThreadForkResultSchema = external_exports.object({
15834
+ threadId: hostThreadIdSchema
15835
+ }).strict();
15606
15836
 
15607
- // ../../harness-adapter/dist/question.js
15608
- function invalidRequest(message) {
15609
- return { code: "invalidRequest", message, retryable: false };
15610
- }
15611
- function validateHostQuestionResponse(interaction, response) {
15612
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
15613
- if (response.cancelled) {
15614
- return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
15615
- }
15616
- for (const answerId of Object.keys(response.answers)) {
15617
- if (!questionIds.has(answerId)) {
15618
- return invalidRequest("Question Response contains an unknown Question ID");
15619
- }
15620
- }
15621
- for (const question of interaction.questions) {
15622
- const answers = response.answers[question.id] ?? [];
15623
- if (!question.optional && answers.length === 0) {
15624
- return invalidRequest("Question Response omits a required answer");
15625
- }
15626
- if (question.type === "text") {
15627
- if (answers.length > 1) {
15628
- return invalidRequest("Text Question accepts at most one answer");
15629
- }
15630
- continue;
15631
- }
15632
- if (!question.multiple && answers.length > 1) {
15633
- return invalidRequest("Single-choice Question accepts at most one answer");
15634
- }
15635
- const declared = new Set(question.options.map(({ value }) => value));
15636
- if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
15637
- return invalidRequest("Question Response contains an undeclared choice");
15837
+ // ../../shared-contracts/dist/harness-commands.js
15838
+ var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
15839
+ var commandInvocationSchema = external_exports.string().min(1).max(128);
15840
+ var commandLabelSchema = external_exports.string().trim().min(1).max(128);
15841
+ var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
15842
+ var harnessCommandDescriptorSchema = external_exports.object({
15843
+ id: commandIdSchema,
15844
+ invocation: commandInvocationSchema,
15845
+ label: commandLabelSchema,
15846
+ description: commandDescriptionSchema.optional(),
15847
+ argumentMode: external_exports.enum(["none", "text"]),
15848
+ /**
15849
+ * Native distinction reported by the Harness. Omitted when the Harness does
15850
+ * not tell skills and commands apart; consumers treat that as "command".
15851
+ */
15852
+ kind: external_exports.enum(["command", "skill"]).optional()
15853
+ }).strict();
15854
+ var harnessCommandCatalogSchema = external_exports.object({
15855
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15856
+ /**
15857
+ * `live` when the catalog includes what a native Session reports for its
15858
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15859
+ * Omitted by Adapters; set by the Host on inspection results.
15860
+ */
15861
+ source: external_exports.enum(["live", "static"]).optional()
15862
+ }).strict().superRefine((catalog, context) => {
15863
+ const ids = /* @__PURE__ */ new Set();
15864
+ for (const [index, command] of catalog.commands.entries()) {
15865
+ if (ids.has(command.id)) {
15866
+ context.addIssue({
15867
+ code: "custom",
15868
+ message: "Harness command IDs must be unique",
15869
+ path: ["commands", index, "id"]
15870
+ });
15638
15871
  }
15872
+ ids.add(command.id);
15639
15873
  }
15640
- return null;
15641
- }
15642
-
15643
- // ../../harness-adapter/dist/output-channel.js
15644
- var HarnessOutputChannel = class {
15645
- outputs;
15646
- #consumerCreated = false;
15647
- #ended = false;
15648
- #pending = [];
15649
- #values = [];
15650
- constructor() {
15651
- this.outputs = {
15652
- [Symbol.asyncIterator]: () => {
15653
- if (this.#consumerCreated) {
15654
- throw new Error("Harness outputs allow only one consumer");
15655
- }
15656
- this.#consumerCreated = true;
15657
- return {
15658
- next: () => this.#next()
15659
- };
15660
- }
15661
- };
15662
- }
15663
- emit(value) {
15664
- if (this.#ended)
15665
- return false;
15666
- const resolve = this.#pending.shift();
15667
- if (resolve)
15668
- resolve({ done: false, value });
15669
- else
15670
- this.#values.push(value);
15671
- return true;
15672
- }
15673
- end() {
15674
- if (this.#ended)
15675
- return;
15676
- this.#ended = true;
15677
- if (this.#values.length !== 0)
15678
- return;
15679
- for (const resolve of this.#pending.splice(0))
15680
- resolve({ done: true, value: void 0 });
15681
- }
15682
- #next() {
15683
- const value = this.#values.shift();
15684
- if (value !== void 0)
15685
- return Promise.resolve({ done: false, value });
15686
- if (this.#ended)
15687
- return Promise.resolve({ done: true, value: void 0 });
15688
- return new Promise((resolve) => this.#pending.push(resolve));
15689
- }
15690
- };
15691
-
15692
- // ../../harness-adapter/dist/diagnostics.js
15693
- var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
15694
- var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
15695
- var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
15696
- function sanitizeDiagnosticTail(value) {
15697
- const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
15698
- return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
15699
- }
15700
-
15701
- // ../../harness-adapter/dist/usage.js
15702
- var tokenFields = [
15703
- "inputTokens",
15704
- "cachedInputTokens",
15705
- "cacheWriteInputTokens",
15706
- "outputTokens",
15707
- "outputTokensPerSecond",
15708
- "reasoningOutputTokens",
15709
- "totalTokens",
15710
- "contextWindowTokens",
15711
- "contextUsedTokens"
15712
- ];
15713
- var safeIntegerFields = [
15714
- "planFiveHourResetsAtUnix",
15715
- "planSevenDayResetsAtUnix"
15716
- ];
15717
- var percentFields = [
15718
- "cacheHitRatePercent",
15719
- "planFiveHourUsedPercent",
15720
- "planSevenDayUsedPercent"
15721
- ];
15722
- var usageFields = /* @__PURE__ */ new Set([
15723
- ...tokenFields,
15724
- ...safeIntegerFields,
15725
- ...percentFields,
15726
- "totalCostUsd",
15727
- "totalCredits",
15728
- "contextUsagePercent"
15729
- ]);
15874
+ });
15875
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15876
+ harnessId: harnessIdSchema,
15877
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15878
+ cwd: external_exports.string().min(1).optional()
15879
+ }).strict();
15880
+ var threadCommandsInspectParamsSchema = external_exports.object({
15881
+ threadId: hostThreadIdSchema
15882
+ }).strict();
15883
+ var threadCommandExecuteParamsSchema = external_exports.object({
15884
+ threadId: hostThreadIdSchema,
15885
+ commandId: commandIdSchema,
15886
+ turnId: hostTurnIdSchema.optional(),
15887
+ arguments: jsonObjectSchema.optional()
15888
+ }).strict();
15889
+ var threadCommandExecuteResultSchema = external_exports.object({
15890
+ accepted: external_exports.literal(true),
15891
+ turnId: hostTurnIdSchema
15892
+ }).strict();
15730
15893
 
15731
- // ../../harness-discovery/dist/environment.js
15732
- import fs from "node:fs";
15733
- import path from "node:path";
15734
- function targetPath(platform) {
15735
- return platform === "win32" ? path.win32 : path.posix;
15736
- }
15737
- function environmentValue(environment, name) {
15738
- const lowered = name.toLowerCase();
15739
- for (const [key, value] of Object.entries(environment)) {
15740
- if (key.toLowerCase() === lowered)
15741
- return value;
15742
- }
15743
- return void 0;
15744
- }
15745
- function pathDelimiter(platform) {
15746
- return platform === "win32" ? ";" : ":";
15747
- }
15748
- function pathDirectories(environment, platform) {
15749
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
15750
- }
15751
- function executableExtensions(command, platform, environment) {
15752
- if (platform !== "win32")
15753
- return [""];
15754
- if (targetPath(platform).extname(command) !== "")
15755
- return [""];
15756
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
15757
- }
15758
- function isExecutableFile(filePath, platform) {
15759
- try {
15760
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
15761
- return fs.statSync(filePath).isFile();
15762
- } catch {
15763
- return false;
15764
- }
15765
- }
15766
- function subdirectoryNames(directory) {
15767
- try {
15768
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
15769
- } catch {
15770
- return [];
15771
- }
15772
- }
15773
- function newestFirst(names) {
15774
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
15775
- }
15894
+ // ../../shared-contracts/dist/json-rpc.js
15895
+ var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
15896
+ var absentSchema = external_exports.never().optional();
15897
+ var methodSchema = external_exports.string().min(1);
15898
+ var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
15899
+ var jsonRpcErrorSchema = external_exports.object({
15900
+ code: external_exports.number().int(),
15901
+ message: external_exports.string(),
15902
+ data: jsonValueSchema.optional()
15903
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
15904
+ var jsonRpcRequestSchema = external_exports.object({
15905
+ jsonrpc: jsonRpcVersionSchema,
15906
+ id: jsonRpcIdSchema,
15907
+ method: methodSchema,
15908
+ params: jsonValueSchema.optional(),
15909
+ result: absentSchema,
15910
+ error: absentSchema
15911
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
15912
+ var jsonRpcNotificationSchema = external_exports.object({
15913
+ jsonrpc: jsonRpcVersionSchema,
15914
+ id: absentSchema,
15915
+ method: methodSchema,
15916
+ params: jsonValueSchema.optional(),
15917
+ result: absentSchema,
15918
+ error: absentSchema
15919
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
15920
+ var jsonRpcSuccessResponseSchema = external_exports.object({
15921
+ jsonrpc: jsonRpcVersionSchema,
15922
+ id: jsonRpcIdSchema,
15923
+ method: absentSchema,
15924
+ params: absentSchema,
15925
+ result: jsonValueSchema,
15926
+ error: absentSchema
15927
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
15928
+ var jsonRpcErrorResponseSchema = external_exports.object({
15929
+ jsonrpc: jsonRpcVersionSchema,
15930
+ id: jsonRpcIdSchema,
15931
+ method: absentSchema,
15932
+ params: absentSchema,
15933
+ result: absentSchema,
15934
+ error: jsonRpcErrorSchema
15935
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
15936
+ var jsonRpcEnvelopeSchema = external_exports.union([
15937
+ jsonRpcRequestSchema,
15938
+ jsonRpcNotificationSchema,
15939
+ jsonRpcSuccessResponseSchema,
15940
+ jsonRpcErrorResponseSchema
15941
+ ]);
15776
15942
 
15777
- // ../../harness-discovery/dist/invocation.js
15778
- import path2 from "node:path";
15779
- function commandInvocation(command, arguments_, environment, platform = process.platform) {
15780
- const extension = path2.win32.extname(command).toLowerCase();
15781
- if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
15782
- return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
15783
- }
15784
- const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
15785
- const commandLine = [command, ...arguments_].map(quote).join(" ");
15786
- return {
15787
- command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
15788
- arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
15789
- windowsVerbatimArguments: true
15790
- };
15791
- }
15943
+ // ../../shared-contracts/dist/native-refs.js
15944
+ var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15945
+ message: "Native identifier must not be empty or whitespace"
15946
+ });
15947
+ var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
15948
+ harnessId: harnessIdSchema,
15949
+ nativeSessionId: nativeIdSchema,
15950
+ locator: jsonValueSchema.optional(),
15951
+ formatVersion: external_exports.literal(1)
15952
+ }).superRefine(rejectExplicitUndefined(["locator"]));
15953
+ var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
15954
+ var nativeSessionRefSchema = nativeSessionRefV1Schema;
15955
+ var nativeTurnRefV1Schema = external_exports.strictObject({
15956
+ harnessId: harnessIdSchema,
15957
+ nativeSessionId: nativeIdSchema,
15958
+ nativeTurnKey: nativeIdSchema,
15959
+ formatVersion: external_exports.literal(1)
15960
+ });
15961
+ var nativeTurnRefSchema = nativeTurnRefV1Schema;
15962
+ var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
15963
+ harnessId: harnessIdSchema,
15964
+ nativeSessionId: nativeIdSchema,
15965
+ checkpointId: nativeIdSchema,
15966
+ locator: jsonValueSchema.optional(),
15967
+ formatVersion: external_exports.literal(1)
15968
+ }).superRefine(rejectExplicitUndefined(["locator"]));
15969
+ var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
15970
+ var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
15792
15971
 
15793
- // ../../harness-discovery/dist/node-runtime.js
15794
- import path3 from "node:path";
15795
- function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
15796
- const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
15797
- const delimiter = platform === "win32" ? ";" : ":";
15798
- const runtimeDirectory = path3.dirname(runtimeExecutable);
15799
- const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
15800
- const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
15801
- if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
15802
- directories.push(runtimeDirectory);
15972
+ // ../../shared-contracts/dist/updates.js
15973
+ var UPDATE_ERROR_MAX_LENGTH = 500;
15974
+ var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
15975
+ var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
15976
+ var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
15977
+ var updatePhaseSchema = external_exports.enum([
15978
+ "prepared",
15979
+ "downloading",
15980
+ "waiting-for-exit",
15981
+ "installing",
15982
+ "restarting",
15983
+ "succeeded",
15984
+ "failed"
15985
+ ]);
15986
+ var updateStatusSchema = external_exports.strictObject({
15987
+ version: updateSemanticVersionSchema,
15988
+ installation: updateInstallationSchema,
15989
+ phase: updatePhaseSchema,
15990
+ updatedAt: external_exports.number().int().nonnegative(),
15991
+ downloadedBytes: external_exports.number().int().nonnegative().optional(),
15992
+ totalBytes: external_exports.number().int().positive().optional(),
15993
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15994
+ }).superRefine((status, context) => {
15995
+ if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
15996
+ context.addIssue({
15997
+ code: "custom",
15998
+ path: ["downloadedBytes"],
15999
+ message: "downloadedBytes must not exceed totalBytes"
16000
+ });
15803
16001
  }
15804
- return { ...environment, [pathKey]: directories.join(delimiter) };
15805
- }
15806
-
15807
- // ../../harness-discovery/dist/resolve.js
15808
- import os from "node:os";
16002
+ });
16003
+ var updateEmptyParamsSchema = external_exports.strictObject({});
16004
+ var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/LiberSeek\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
16005
+ var updateCheckResultSchema = external_exports.strictObject({
16006
+ currentVersion: updateSemanticVersionSchema,
16007
+ installation: updateInstallationSchema.nullable(),
16008
+ latestVersion: updateSemanticVersionSchema.nullable(),
16009
+ updateAvailable: external_exports.boolean(),
16010
+ installationAvailable: external_exports.boolean(),
16011
+ releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
16012
+ releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
16013
+ status: updateStatusSchema.nullable(),
16014
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
16015
+ });
16016
+ var updateStartResultSchema = external_exports.strictObject({
16017
+ status: updateStatusSchema
16018
+ });
16019
+ var updateStatusResultSchema = external_exports.strictObject({
16020
+ status: updateStatusSchema.nullable()
16021
+ });
15809
16022
 
15810
- // ../../harness-discovery/dist/version-managers.js
15811
- function versionManagerBinaryDirectories(context) {
15812
- const { platform, environment, home } = context;
15813
- const list = context.subdirectories ?? subdirectoryNames;
15814
- const pathFlavor = targetPath(platform);
15815
- const value = (name) => environmentValue(environment, name);
15816
- const directories = [];
15817
- const versioned = (root, ...tail) => {
15818
- for (const version2 of newestFirst(list(root))) {
15819
- directories.push(pathFlavor.join(root, version2, ...tail));
15820
- }
15821
- };
15822
- if (platform === "win32") {
15823
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
15824
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
15825
- versioned(pathFlavor.join(appData, "nvm"));
15826
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
15827
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
15828
- directories.push(pathFlavor.join(home, ".bun", "bin"));
15829
- const pnpmHome2 = value("PNPM_HOME");
15830
- if (pnpmHome2)
15831
- directories.push(pnpmHome2);
15832
- directories.push(pathFlavor.join(localAppData, "pnpm"));
15833
- return directories;
15834
- }
15835
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
15836
- const fnmRoots = [
15837
- value("FNM_DIR"),
15838
- pathFlavor.join(home, ".local", "share", "fnm"),
15839
- pathFlavor.join(home, "Library", "Application Support", "fnm")
15840
- ].filter((root) => root !== void 0);
15841
- for (const root of fnmRoots) {
15842
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
15843
- }
15844
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
15845
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
15846
- directories.push(pathFlavor.join(voltaHome, "bin"));
15847
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
15848
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
15849
- directories.push(pathFlavor.join(asdfHome, "shims"));
15850
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
15851
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
15852
- directories.push(pathFlavor.join(nodenvHome, "shims"));
15853
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
15854
- directories.push(pathFlavor.join(home, ".bun", "bin"));
15855
- const pnpmHome = value("PNPM_HOME");
15856
- if (pnpmHome)
15857
- directories.push(pnpmHome);
15858
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
15859
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
15860
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
15861
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
15862
- directories.push(pathFlavor.join(prefix, formula, "bin"));
15863
- }
15864
- }
15865
- return directories;
15866
- }
16023
+ // ../../shared-contracts/dist/index.js
16024
+ var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
15867
16025
 
15868
- // ../../harness-discovery/dist/resolve.js
15869
- var VERSION_MANAGER_ROOTS = "<version-managers>";
15870
- function installRootExtensions(platform) {
15871
- return platform === "win32" ? [".exe", ".cmd"] : [""];
15872
- }
15873
- function resolveHomeDirectory(input) {
15874
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
15875
- }
15876
- function templateVariables(environment, platform, home) {
15877
- const pathFlavor = targetPath(platform);
15878
- return {
15879
- HOME: home,
15880
- USERPROFILE: home,
15881
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
15882
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
15883
- };
15884
- }
15885
- function joinTemplate(platform, value) {
15886
- const pathFlavor = targetPath(platform);
15887
- const segments = value.split("/");
15888
- const head = segments[0] ?? "";
15889
- const tail = segments.slice(1);
15890
- if (head === "")
15891
- return pathFlavor.join(pathFlavor.sep, ...tail);
15892
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
15893
- }
15894
- function expandInstallRoot(template, environment, platform, home) {
15895
- const variables = templateVariables(environment, platform, home);
15896
- let unresolved = false;
15897
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
15898
- const value = variables[name] ?? environmentValue(environment, name);
15899
- if (value === void 0 || value === "") {
15900
- unresolved = true;
15901
- return "";
15902
- }
15903
- return value;
15904
- });
15905
- return unresolved ? void 0 : joinTemplate(platform, substituted);
15906
- }
15907
- function installRootDirectories(spec, input, dependencies, platform, home) {
15908
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
15909
- const directories = [];
15910
- for (const template of templates) {
15911
- if (template === VERSION_MANAGER_ROOTS) {
15912
- directories.push(...versionManagerBinaryDirectories({
15913
- platform,
15914
- environment: input.environment,
15915
- home,
15916
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
15917
- }));
15918
- continue;
15919
- }
15920
- const directory = expandInstallRoot(template, input.environment, platform, home);
15921
- if (directory !== void 0)
15922
- directories.push(directory);
15923
- }
15924
- return directories;
15925
- }
15926
- function harnessCandidates(spec, input, dependencies = {}) {
15927
- const platform = input.platform ?? process.platform;
15928
- const pathFlavor = targetPath(platform);
15929
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
15930
- const command = configured ?? spec.command;
15931
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
15932
- return [{ candidate: command, source: "configured" }];
16026
+ // ../../harness-adapter/dist/question.js
16027
+ function invalidRequest(message) {
16028
+ return { code: "invalidRequest", message, retryable: false };
16029
+ }
16030
+ function validateHostQuestionResponse(interaction, response) {
16031
+ const questionIds = new Set(interaction.questions.map(({ id }) => id));
16032
+ if (response.cancelled) {
16033
+ return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
15933
16034
  }
15934
- const candidates = [];
15935
- const extensions = executableExtensions(command, platform, input.environment);
15936
- for (const directory of pathDirectories(input.environment, platform)) {
15937
- for (const extension of extensions) {
15938
- candidates.push({
15939
- candidate: pathFlavor.join(directory, command + extension),
15940
- source: "path"
15941
- });
16035
+ for (const answerId of Object.keys(response.answers)) {
16036
+ if (!questionIds.has(answerId)) {
16037
+ return invalidRequest("Question Response contains an unknown Question ID");
15942
16038
  }
15943
16039
  }
15944
- if (configured !== void 0)
15945
- return candidates;
15946
- const home = resolveHomeDirectory(input);
15947
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
15948
- for (const extension of installRootExtensions(platform)) {
15949
- candidates.push({
15950
- candidate: pathFlavor.join(directory, spec.command + extension),
15951
- source: "install-root"
15952
- });
16040
+ for (const question of interaction.questions) {
16041
+ const answers = response.answers[question.id] ?? [];
16042
+ if (!question.optional && answers.length === 0) {
16043
+ return invalidRequest("Question Response omits a required answer");
16044
+ }
16045
+ if (question.type === "text") {
16046
+ if (answers.length > 1) {
16047
+ return invalidRequest("Text Question accepts at most one answer");
16048
+ }
16049
+ continue;
16050
+ }
16051
+ if (!question.multiple && answers.length > 1) {
16052
+ return invalidRequest("Single-choice Question accepts at most one answer");
16053
+ }
16054
+ const declared = new Set(question.options.map(({ value }) => value));
16055
+ if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
16056
+ return invalidRequest("Question Response contains an undeclared choice");
15953
16057
  }
15954
16058
  }
15955
- return candidates;
15956
- }
15957
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
15958
- const platform = input.platform ?? process.platform;
15959
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
15960
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
15961
- const context = { platform, isExecutable };
15962
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
15963
- const executable = runnable(candidate, context);
15964
- if (executable !== void 0 && isExecutable(executable))
15965
- return { executable, source };
15966
- }
15967
- return void 0;
16059
+ return null;
15968
16060
  }
15969
16061
 
15970
- // ../../harness-discovery/dist/installation.js
15971
- import { execFile } from "node:child_process";
15972
- import { homedir } from "node:os";
15973
- function runInstallationCommand(command, args, environment, timeout = 3e4) {
15974
- const env = withNodeRuntimeOnPath(environment);
15975
- const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
15976
- return new Promise((resolve, reject) => {
15977
- const child = execFile(invocation.command, invocation.arguments, {
15978
- env,
15979
- cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
15980
- encoding: "utf8",
15981
- timeout,
15982
- killSignal: "SIGKILL",
15983
- maxBuffer: 1024 * 1024,
15984
- windowsHide: true,
15985
- windowsVerbatimArguments: invocation.windowsVerbatimArguments
15986
- }, (error51, stdout, stderr) => {
15987
- if (error51)
15988
- reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
15989
- else
15990
- resolve((stdout || stderr).trim());
15991
- });
15992
- child.stdin?.end();
15993
- });
15994
- }
15995
- function installationVersion(value) {
15996
- if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
15997
- throw new Error("Harness returned an invalid version");
15998
- return value.trim().replace(/^v/, "");
15999
- }
16000
- function versionFromOutput(output) {
16001
- return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
16002
- }
16003
- function newerInstallationVersion(current, latest) {
16004
- const a = installationVersion(current).replace(/\+.*/, "");
16005
- const b = installationVersion(latest).replace(/\+.*/, "");
16006
- const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
16007
- const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
16008
- for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
16009
- if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
16010
- return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
16062
+ // ../../harness-adapter/dist/output-channel.js
16063
+ var HarnessOutputChannel = class {
16064
+ outputs;
16065
+ #consumerCreated = false;
16066
+ #ended = false;
16067
+ #pending = [];
16068
+ #values = [];
16069
+ constructor() {
16070
+ this.outputs = {
16071
+ [Symbol.asyncIterator]: () => {
16072
+ if (this.#consumerCreated) {
16073
+ throw new Error("Harness outputs allow only one consumer");
16074
+ }
16075
+ this.#consumerCreated = true;
16076
+ return {
16077
+ next: () => this.#next()
16078
+ };
16079
+ }
16080
+ };
16011
16081
  }
16012
- const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
16013
- const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
16014
- if (!preA.length || !preB.length)
16015
- return !!preA.length && !preB.length;
16016
- for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
16017
- const x = preA[i];
16018
- const y = preB[i];
16019
- if (x === y)
16020
- continue;
16021
- if (x === void 0 || y === void 0)
16022
- return x === void 0;
16023
- const numericX = /^\d+$/.test(x);
16024
- const numericY = /^\d+$/.test(y);
16025
- if (numericX && numericY) {
16026
- if (BigInt(x) === BigInt(y))
16027
- continue;
16028
- return BigInt(y) > BigInt(x);
16029
- }
16030
- if (numericX !== numericY)
16031
- return numericX;
16032
- return y > x;
16082
+ emit(value) {
16083
+ if (this.#ended)
16084
+ return false;
16085
+ const resolve = this.#pending.shift();
16086
+ if (resolve)
16087
+ resolve({ done: false, value });
16088
+ else
16089
+ this.#values.push(value);
16090
+ return true;
16033
16091
  }
16034
- return false;
16035
- }
16036
- function createInstallationManager(options) {
16037
- let checking;
16038
- let updating;
16039
- const check2 = () => checking ??= options.check().finally(() => {
16040
- checking = void 0;
16041
- });
16042
- return (action) => {
16043
- if (updating)
16044
- return updating;
16045
- if (action === "check")
16046
- return check2();
16047
- updating = (async () => {
16048
- const before = await check2();
16049
- if (!before.updateAvailable)
16050
- return before;
16051
- if (!before.canUpdate)
16052
- throw new Error(before.message ?? "This installation cannot be updated automatically");
16053
- await options.update(before);
16054
- const after = await check2();
16055
- if (after.currentVersion === before.currentVersion)
16056
- throw new Error("The Harness version did not change; check the native updater and retry");
16057
- return after;
16058
- })().finally(() => {
16059
- updating = void 0;
16060
- });
16061
- return updating;
16062
- };
16063
- }
16064
- async function fetchInstallationText(url2) {
16065
- const request = async () => {
16066
- const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
16067
- if (!response.ok)
16068
- throw new Error("Could not check the latest Harness version");
16069
- return response.text();
16070
- };
16071
- try {
16072
- return await request();
16073
- } catch (error51) {
16074
- if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
16075
- throw error51;
16076
- return request();
16092
+ end() {
16093
+ if (this.#ended)
16094
+ return;
16095
+ this.#ended = true;
16096
+ if (this.#values.length !== 0)
16097
+ return;
16098
+ for (const resolve of this.#pending.splice(0))
16099
+ resolve({ done: true, value: void 0 });
16100
+ }
16101
+ #next() {
16102
+ const value = this.#values.shift();
16103
+ if (value !== void 0)
16104
+ return Promise.resolve({ done: false, value });
16105
+ if (this.#ended)
16106
+ return Promise.resolve({ done: true, value: void 0 });
16107
+ return new Promise((resolve) => this.#pending.push(resolve));
16077
16108
  }
16109
+ };
16110
+
16111
+ // ../../harness-adapter/dist/diagnostics.js
16112
+ var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
16113
+ var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
16114
+ var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
16115
+ function sanitizeDiagnosticTail(value) {
16116
+ const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
16117
+ return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
16078
16118
  }
16079
16119
 
16120
+ // ../../harness-adapter/dist/usage.js
16121
+ var tokenFields = [
16122
+ "inputTokens",
16123
+ "cachedInputTokens",
16124
+ "cacheWriteInputTokens",
16125
+ "outputTokens",
16126
+ "outputTokensPerSecond",
16127
+ "reasoningOutputTokens",
16128
+ "totalTokens",
16129
+ "contextWindowTokens",
16130
+ "contextUsedTokens"
16131
+ ];
16132
+ var safeIntegerFields = [
16133
+ "planFiveHourResetsAtUnix",
16134
+ "planSevenDayResetsAtUnix"
16135
+ ];
16136
+ var percentFields = [
16137
+ "cacheHitRatePercent",
16138
+ "planFiveHourUsedPercent",
16139
+ "planSevenDayUsedPercent"
16140
+ ];
16141
+ var usageFields = /* @__PURE__ */ new Set([
16142
+ ...tokenFields,
16143
+ ...safeIntegerFields,
16144
+ ...percentFields,
16145
+ "totalCostUsd",
16146
+ "totalCredits",
16147
+ "contextUsagePercent"
16148
+ ]);
16149
+
16080
16150
  // dist/command.js
16081
16151
  import path4 from "node:path";
16082
16152
  var antigravityDiscoverySpec = {
@@ -16109,7 +16179,7 @@ import path6 from "node:path";
16109
16179
 
16110
16180
  // dist/history.js
16111
16181
  import { randomUUID } from "node:crypto";
16112
- 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";
16113
16183
  import os2 from "node:os";
16114
16184
  import path5 from "node:path";
16115
16185
  var HISTORY_VERSION = 1;
@@ -16386,7 +16456,7 @@ var AntigravityHistory = class _AntigravityHistory {
16386
16456
  await mkdir(directory, { recursive: true, mode: 448 });
16387
16457
  const temporary = path5.join(directory, `.${path5.basename(file2)}.${randomUUID()}.tmp`);
16388
16458
  try {
16389
- await writeFile(temporary, `${JSON.stringify({
16459
+ await writeFile2(temporary, `${JSON.stringify({
16390
16460
  formatVersion: HISTORY_VERSION,
16391
16461
  nativeSessionId,
16392
16462
  turns,
@@ -16396,7 +16466,7 @@ var AntigravityHistory = class _AntigravityHistory {
16396
16466
  `, { mode: 384 });
16397
16467
  await rename(temporary, file2);
16398
16468
  } finally {
16399
- await rm(temporary, { force: true }).catch(() => void 0);
16469
+ await rm2(temporary, { force: true }).catch(() => void 0);
16400
16470
  }
16401
16471
  });
16402
16472
  }
@@ -17521,7 +17591,7 @@ async function fetchAntigravityQuota(run, now = /* @__PURE__ */ new Date()) {
17521
17591
 
17522
17592
  // dist/question-bridge.js
17523
17593
  import { randomBytes, randomUUID as randomUUID4, timingSafeEqual } from "node:crypto";
17524
- 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";
17525
17595
  import { createServer } from "node:http";
17526
17596
  import os4 from "node:os";
17527
17597
  import path8 from "node:path";
@@ -17649,7 +17719,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17649
17719
  this.#server.on("request", (request, response) => this.#receive(request, response));
17650
17720
  }
17651
17721
  static async create(options) {
17652
- const directory = await mkdtemp(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
17722
+ const directory = await mkdtemp2(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
17653
17723
  const bridge = new _AntigravityQuestionBridge(directory, options);
17654
17724
  try {
17655
17725
  await new Promise((resolve, reject) => {
@@ -17666,12 +17736,12 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17666
17736
  bridge.environment.CODEXHOST_AGY_QUESTION_URL = `http://127.0.0.1:${address.port}/question`;
17667
17737
  const client = path8.join(directory, "question-hook.cjs");
17668
17738
  await mkdir3(path8.join(directory, ".agents"));
17669
- await writeFile2(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
17739
+ await writeFile3(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
17670
17740
  const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
17671
17741
  bridge.environment.CODEXHOST_AGY_QUESTION_NODE = `"${process.execPath.replaceAll("\\", "/")}"`;
17672
17742
  bridge.environment.CODEXHOST_AGY_QUESTION_CLIENT = `"${client.replaceAll("\\", "/")}"`;
17673
17743
  const command = process.platform === "win32" ? "%CODEXHOST_AGY_QUESTION_NODE% %CODEXHOST_AGY_QUESTION_CLIENT%" : `${quote(process.execPath)} ${quote(client)}`;
17674
- await writeFile2(path8.join(directory, ".agents", "hooks.json"), JSON.stringify({
17744
+ await writeFile3(path8.join(directory, ".agents", "hooks.json"), JSON.stringify({
17675
17745
  "codexhost-question-bridge": {
17676
17746
  PreToolUse: [
17677
17747
  {
@@ -17894,7 +17964,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17894
17964
  this.#server.close(() => resolve());
17895
17965
  this.#server.closeAllConnections();
17896
17966
  });
17897
- 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 });
17898
17968
  })();
17899
17969
  return this.#disposal;
17900
17970
  }
@@ -18590,7 +18660,9 @@ function normalizedProcessError(detail, fallback, exposeDetail = false) {
18590
18660
  return {
18591
18661
  code: "nativeFailure",
18592
18662
  message: exposeDetail && nativeDetail ? `${fallback}: ${nativeDetail}` : fallback,
18593
- 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),
18594
18666
  ...diagnostic ? { stderrTail: diagnostic.slice(-4e3) } : {}
18595
18667
  };
18596
18668
  }
@@ -19001,6 +19073,18 @@ ${line}`).slice(-8e3);
19001
19073
  async #handleResult(active, event) {
19002
19074
  if (this.#active !== active)
19003
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
+ }
19004
19088
  const usage = hostUsage(event.result.usage, active.model?.id);
19005
19089
  if (usage)
19006
19090
  this.#publishUsage(active, usage);
@@ -19013,7 +19097,7 @@ ${line}`).slice(-8e3);
19013
19097
  await active.subagents.refresh();
19014
19098
  if (this.#active !== active)
19015
19099
  return;
19016
- 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 || "";
19017
19101
  if (!this.#nativeRef && convId) {
19018
19102
  this.#nativeRef = nativeSessionRefSchema.parse({
19019
19103
  harnessId: this.harnessId,
@@ -19797,6 +19881,10 @@ function createHarnessAdapter(context) {
19797
19881
  ...environment[ANTIGRAVITY_COMMAND_ENV] ? { command: environment[ANTIGRAVITY_COMMAND_ENV] } : {},
19798
19882
  environment
19799
19883
  }), {
19884
+ install: createHarnessInstaller(environment, {
19885
+ posix: "https://antigravity.google/cli/install.sh",
19886
+ windows: "https://antigravity.google/cli/install.ps1"
19887
+ }),
19800
19888
  installation: createAntigravityInstallation(environment, environment[ANTIGRAVITY_COMMAND_ENV])
19801
19889
  });
19802
19890
  }