@liberseek/boft-cli-linux-x64 0.7.6 → 0.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,14 +15699,17 @@ 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),
15287
15706
  latestVersion: external_exports.string().min(1).max(128),
15288
15707
  updateAvailable: external_exports.boolean(),
15289
15708
  canUpdate: external_exports.boolean(),
15290
- message: external_exports.string().max(2048).optional()
15709
+ // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15710
+ message: external_exports.string().max(2048).optional(),
15711
+ messageCode: external_exports.string().min(1).max(128).optional(),
15712
+ latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15291
15713
  }).strict();
15292
15714
 
15293
15715
  // ../../shared-contracts/dist/codex-accounts.js
@@ -15401,682 +15823,333 @@ var deepSeekModernSessionListResultSchema = external_exports.object({
15401
15823
  }).strict();
15402
15824
  var deepSeekModernSessionImportParamsSchema = external_exports.object({
15403
15825
  nativeSessionId: deepSeekModernSessionIdSchema
15404
- }).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
- });
15826
+ }).strict();
15827
+ var deepSeekModernSessionImportResultSchema = external_exports.object({
15828
+ threadId: nonBlankTextSchema5.max(DEEPSEEK_MODERN_HOST_THREAD_ID_MAX_LENGTH).pipe(hostThreadIdSchema)
15829
+ }).strict();
15603
15830
 
15604
- // ../../shared-contracts/dist/index.js
15605
- var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
15831
+ // ../../shared-contracts/dist/external-thread-fork.js
15832
+ var externalThreadForkParamsSchema = external_exports.object({
15833
+ threadId: hostThreadIdSchema,
15834
+ lastTurnId: hostTurnIdSchema
15835
+ }).strict();
15836
+ var externalThreadForkResultSchema = external_exports.object({
15837
+ threadId: hostThreadIdSchema
15838
+ }).strict();
15606
15839
 
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");
15840
+ // ../../shared-contracts/dist/harness-commands.js
15841
+ var commandIdSchema = external_exports.string().trim().min(1).max(128).regex(/^[A-Za-z0-9._:-]+$/u).brand();
15842
+ var commandInvocationSchema = external_exports.string().min(1).max(128);
15843
+ var commandLabelSchema = external_exports.string().trim().min(1).max(128);
15844
+ var commandDescriptionSchema = external_exports.string().trim().min(1).max(512);
15845
+ var harnessCommandDescriptorSchema = external_exports.object({
15846
+ id: commandIdSchema,
15847
+ invocation: commandInvocationSchema,
15848
+ label: commandLabelSchema,
15849
+ description: commandDescriptionSchema.optional(),
15850
+ argumentMode: external_exports.enum(["none", "text"]),
15851
+ /**
15852
+ * Native distinction reported by the Harness. Omitted when the Harness does
15853
+ * not tell skills and commands apart; consumers treat that as "command".
15854
+ */
15855
+ kind: external_exports.enum(["command", "skill"]).optional()
15856
+ }).strict();
15857
+ var harnessCommandCatalogSchema = external_exports.object({
15858
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15859
+ /**
15860
+ * `live` when the catalog includes what a native Session reports for its
15861
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15862
+ * Omitted by Adapters; set by the Host on inspection results.
15863
+ */
15864
+ source: external_exports.enum(["live", "static"]).optional()
15865
+ }).strict().superRefine((catalog, context) => {
15866
+ const ids = /* @__PURE__ */ new Set();
15867
+ for (const [index, command] of catalog.commands.entries()) {
15868
+ if (ids.has(command.id)) {
15869
+ context.addIssue({
15870
+ code: "custom",
15871
+ message: "Harness command IDs must be unique",
15872
+ path: ["commands", index, "id"]
15873
+ });
15638
15874
  }
15875
+ ids.add(command.id);
15639
15876
  }
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
- ]);
15877
+ });
15878
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15879
+ harnessId: harnessIdSchema,
15880
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15881
+ cwd: external_exports.string().min(1).optional()
15882
+ }).strict();
15883
+ var threadCommandsInspectParamsSchema = external_exports.object({
15884
+ threadId: hostThreadIdSchema
15885
+ }).strict();
15886
+ var threadCommandExecuteParamsSchema = external_exports.object({
15887
+ threadId: hostThreadIdSchema,
15888
+ commandId: commandIdSchema,
15889
+ turnId: hostTurnIdSchema.optional(),
15890
+ arguments: jsonObjectSchema.optional()
15891
+ }).strict();
15892
+ var threadCommandExecuteResultSchema = external_exports.object({
15893
+ accepted: external_exports.literal(true),
15894
+ turnId: hostTurnIdSchema
15895
+ }).strict();
15730
15896
 
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
- }
15897
+ // ../../shared-contracts/dist/json-rpc.js
15898
+ var jsonRpcVersionSchema = external_exports.literal("2.0").optional();
15899
+ var absentSchema = external_exports.never().optional();
15900
+ var methodSchema = external_exports.string().min(1);
15901
+ var jsonRpcIdSchema = external_exports.union([external_exports.string(), external_exports.number().int()]);
15902
+ var jsonRpcErrorSchema = external_exports.object({
15903
+ code: external_exports.number().int(),
15904
+ message: external_exports.string(),
15905
+ data: jsonValueSchema.optional()
15906
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["data"]));
15907
+ var jsonRpcRequestSchema = external_exports.object({
15908
+ jsonrpc: jsonRpcVersionSchema,
15909
+ id: jsonRpcIdSchema,
15910
+ method: methodSchema,
15911
+ params: jsonValueSchema.optional(),
15912
+ result: absentSchema,
15913
+ error: absentSchema
15914
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "params", "result", "error"]));
15915
+ var jsonRpcNotificationSchema = external_exports.object({
15916
+ jsonrpc: jsonRpcVersionSchema,
15917
+ id: absentSchema,
15918
+ method: methodSchema,
15919
+ params: jsonValueSchema.optional(),
15920
+ result: absentSchema,
15921
+ error: absentSchema
15922
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "id", "params", "result", "error"]));
15923
+ var jsonRpcSuccessResponseSchema = external_exports.object({
15924
+ jsonrpc: jsonRpcVersionSchema,
15925
+ id: jsonRpcIdSchema,
15926
+ method: absentSchema,
15927
+ params: absentSchema,
15928
+ result: jsonValueSchema,
15929
+ error: absentSchema
15930
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "error"]));
15931
+ var jsonRpcErrorResponseSchema = external_exports.object({
15932
+ jsonrpc: jsonRpcVersionSchema,
15933
+ id: jsonRpcIdSchema,
15934
+ method: absentSchema,
15935
+ params: absentSchema,
15936
+ result: absentSchema,
15937
+ error: jsonRpcErrorSchema
15938
+ }).catchall(jsonValueSchema).superRefine(rejectExplicitUndefined(["jsonrpc", "method", "params", "result"]));
15939
+ var jsonRpcEnvelopeSchema = external_exports.union([
15940
+ jsonRpcRequestSchema,
15941
+ jsonRpcNotificationSchema,
15942
+ jsonRpcSuccessResponseSchema,
15943
+ jsonRpcErrorResponseSchema
15944
+ ]);
15776
15945
 
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
- }
15946
+ // ../../shared-contracts/dist/native-refs.js
15947
+ var nativeIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15948
+ message: "Native identifier must not be empty or whitespace"
15949
+ });
15950
+ var nativeSessionRefV1RuntimeSchema = external_exports.strictObject({
15951
+ harnessId: harnessIdSchema,
15952
+ nativeSessionId: nativeIdSchema,
15953
+ locator: jsonValueSchema.optional(),
15954
+ formatVersion: external_exports.literal(1)
15955
+ }).superRefine(rejectExplicitUndefined(["locator"]));
15956
+ var nativeSessionRefV1Schema = nativeSessionRefV1RuntimeSchema;
15957
+ var nativeSessionRefSchema = nativeSessionRefV1Schema;
15958
+ var nativeTurnRefV1Schema = external_exports.strictObject({
15959
+ harnessId: harnessIdSchema,
15960
+ nativeSessionId: nativeIdSchema,
15961
+ nativeTurnKey: nativeIdSchema,
15962
+ formatVersion: external_exports.literal(1)
15963
+ });
15964
+ var nativeTurnRefSchema = nativeTurnRefV1Schema;
15965
+ var nativeCheckpointRefV1RuntimeSchema = external_exports.strictObject({
15966
+ harnessId: harnessIdSchema,
15967
+ nativeSessionId: nativeIdSchema,
15968
+ checkpointId: nativeIdSchema,
15969
+ locator: jsonValueSchema.optional(),
15970
+ formatVersion: external_exports.literal(1)
15971
+ }).superRefine(rejectExplicitUndefined(["locator"]));
15972
+ var nativeCheckpointRefV1Schema = nativeCheckpointRefV1RuntimeSchema;
15973
+ var nativeCheckpointRefSchema = nativeCheckpointRefV1Schema;
15792
15974
 
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);
15975
+ // ../../shared-contracts/dist/updates.js
15976
+ var UPDATE_ERROR_MAX_LENGTH = 500;
15977
+ var UPDATE_SEMVER_PATTERN = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
15978
+ var updateSemanticVersionSchema = external_exports.string().regex(UPDATE_SEMVER_PATTERN);
15979
+ var updateInstallationSchema = external_exports.enum(["npm", "windows-installer", "macos-dmg"]);
15980
+ var updatePhaseSchema = external_exports.enum([
15981
+ "prepared",
15982
+ "downloading",
15983
+ "waiting-for-exit",
15984
+ "installing",
15985
+ "restarting",
15986
+ "succeeded",
15987
+ "failed"
15988
+ ]);
15989
+ var updateStatusSchema = external_exports.strictObject({
15990
+ version: updateSemanticVersionSchema,
15991
+ installation: updateInstallationSchema,
15992
+ phase: updatePhaseSchema,
15993
+ updatedAt: external_exports.number().int().nonnegative(),
15994
+ downloadedBytes: external_exports.number().int().nonnegative().optional(),
15995
+ totalBytes: external_exports.number().int().positive().optional(),
15996
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
15997
+ }).superRefine((status, context) => {
15998
+ if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
15999
+ context.addIssue({
16000
+ code: "custom",
16001
+ path: ["downloadedBytes"],
16002
+ message: "downloadedBytes must not exceed totalBytes"
16003
+ });
15803
16004
  }
15804
- return { ...environment, [pathKey]: directories.join(delimiter) };
15805
- }
15806
-
15807
- // ../../harness-discovery/dist/resolve.js
15808
- import os from "node:os";
16005
+ });
16006
+ var updateEmptyParamsSchema = external_exports.strictObject({});
16007
+ var githubReleaseNotesUrlSchema = external_exports.string().max(300).regex(/^https:\/\/github\.com\/(LiberSeek|LIBERSEEK)\/BOFT-CLI\/releases\/tag\/v[0-9A-Za-z.+-]+$/u, "release notes URL must identify a codexhost GitHub Release");
16008
+ var updateCheckResultSchema = external_exports.strictObject({
16009
+ currentVersion: updateSemanticVersionSchema,
16010
+ installation: updateInstallationSchema.nullable(),
16011
+ latestVersion: updateSemanticVersionSchema.nullable(),
16012
+ updateAvailable: external_exports.boolean(),
16013
+ installationAvailable: external_exports.boolean(),
16014
+ releaseNotes: external_exports.string().min(1).max(2e4).nullable(),
16015
+ releaseNotesUrl: githubReleaseNotesUrlSchema.nullable(),
16016
+ status: updateStatusSchema.nullable(),
16017
+ error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
16018
+ });
16019
+ var updateStartResultSchema = external_exports.strictObject({
16020
+ status: updateStatusSchema
16021
+ });
16022
+ var updateStatusResultSchema = external_exports.strictObject({
16023
+ status: updateStatusSchema.nullable()
16024
+ });
15809
16025
 
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
- }
16026
+ // ../../shared-contracts/dist/index.js
16027
+ var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
15867
16028
 
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" }];
16029
+ // ../../harness-adapter/dist/question.js
16030
+ function invalidRequest(message) {
16031
+ return { code: "invalidRequest", message, retryable: false };
16032
+ }
16033
+ function validateHostQuestionResponse(interaction, response) {
16034
+ const questionIds = new Set(interaction.questions.map(({ id }) => id));
16035
+ if (response.cancelled) {
16036
+ return Object.keys(response.answers).length === 0 ? null : invalidRequest("Cancelled Question Response must not contain answers");
15933
16037
  }
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
- });
16038
+ for (const answerId of Object.keys(response.answers)) {
16039
+ if (!questionIds.has(answerId)) {
16040
+ return invalidRequest("Question Response contains an unknown Question ID");
15942
16041
  }
15943
16042
  }
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
- });
16043
+ for (const question of interaction.questions) {
16044
+ const answers = response.answers[question.id] ?? [];
16045
+ if (!question.optional && answers.length === 0) {
16046
+ return invalidRequest("Question Response omits a required answer");
16047
+ }
16048
+ if (question.type === "text") {
16049
+ if (answers.length > 1) {
16050
+ return invalidRequest("Text Question accepts at most one answer");
16051
+ }
16052
+ continue;
16053
+ }
16054
+ if (!question.multiple && answers.length > 1) {
16055
+ return invalidRequest("Single-choice Question accepts at most one answer");
16056
+ }
16057
+ const declared = new Set(question.options.map(({ value }) => value));
16058
+ if (!question.allowOther && answers.some((answer) => !declared.has(answer))) {
16059
+ return invalidRequest("Question Response contains an undeclared choice");
15953
16060
  }
15954
16061
  }
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;
16062
+ return null;
15968
16063
  }
15969
16064
 
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);
16065
+ // ../../harness-adapter/dist/output-channel.js
16066
+ var HarnessOutputChannel = class {
16067
+ outputs;
16068
+ #consumerCreated = false;
16069
+ #ended = false;
16070
+ #pending = [];
16071
+ #values = [];
16072
+ constructor() {
16073
+ this.outputs = {
16074
+ [Symbol.asyncIterator]: () => {
16075
+ if (this.#consumerCreated) {
16076
+ throw new Error("Harness outputs allow only one consumer");
16077
+ }
16078
+ this.#consumerCreated = true;
16079
+ return {
16080
+ next: () => this.#next()
16081
+ };
16082
+ }
16083
+ };
16011
16084
  }
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;
16085
+ emit(value) {
16086
+ if (this.#ended)
16087
+ return false;
16088
+ const resolve = this.#pending.shift();
16089
+ if (resolve)
16090
+ resolve({ done: false, value });
16091
+ else
16092
+ this.#values.push(value);
16093
+ return true;
16033
16094
  }
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();
16095
+ end() {
16096
+ if (this.#ended)
16097
+ return;
16098
+ this.#ended = true;
16099
+ if (this.#values.length !== 0)
16100
+ return;
16101
+ for (const resolve of this.#pending.splice(0))
16102
+ resolve({ done: true, value: void 0 });
16103
+ }
16104
+ #next() {
16105
+ const value = this.#values.shift();
16106
+ if (value !== void 0)
16107
+ return Promise.resolve({ done: false, value });
16108
+ if (this.#ended)
16109
+ return Promise.resolve({ done: true, value: void 0 });
16110
+ return new Promise((resolve) => this.#pending.push(resolve));
16077
16111
  }
16112
+ };
16113
+
16114
+ // ../../harness-adapter/dist/diagnostics.js
16115
+ var DIAGNOSTIC_TAIL_MAX_LENGTH = 8e3;
16116
+ var SENSITIVE_VALUE_PATTERN = /(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/giu;
16117
+ var BEARER_PATTERN = /\bBearer\s+[A-Za-z0-9._~+/=-]+/giu;
16118
+ function sanitizeDiagnosticTail(value) {
16119
+ const redacted = value.replace(BEARER_PATTERN, "Bearer [redacted]").replace(SENSITIVE_VALUE_PATTERN, "$1$2[redacted]");
16120
+ return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
16078
16121
  }
16079
16122
 
16123
+ // ../../harness-adapter/dist/usage.js
16124
+ var tokenFields = [
16125
+ "inputTokens",
16126
+ "cachedInputTokens",
16127
+ "cacheWriteInputTokens",
16128
+ "outputTokens",
16129
+ "outputTokensPerSecond",
16130
+ "reasoningOutputTokens",
16131
+ "totalTokens",
16132
+ "contextWindowTokens",
16133
+ "contextUsedTokens"
16134
+ ];
16135
+ var safeIntegerFields = [
16136
+ "planFiveHourResetsAtUnix",
16137
+ "planSevenDayResetsAtUnix"
16138
+ ];
16139
+ var percentFields = [
16140
+ "cacheHitRatePercent",
16141
+ "planFiveHourUsedPercent",
16142
+ "planSevenDayUsedPercent"
16143
+ ];
16144
+ var usageFields = /* @__PURE__ */ new Set([
16145
+ ...tokenFields,
16146
+ ...safeIntegerFields,
16147
+ ...percentFields,
16148
+ "totalCostUsd",
16149
+ "totalCredits",
16150
+ "contextUsagePercent"
16151
+ ]);
16152
+
16080
16153
  // dist/command.js
16081
16154
  import path4 from "node:path";
16082
16155
  var antigravityDiscoverySpec = {
@@ -16109,7 +16182,7 @@ import path6 from "node:path";
16109
16182
 
16110
16183
  // dist/history.js
16111
16184
  import { randomUUID } from "node:crypto";
16112
- import { mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
16185
+ import { mkdir, readFile, readdir, rename, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
16113
16186
  import os2 from "node:os";
16114
16187
  import path5 from "node:path";
16115
16188
  var HISTORY_VERSION = 1;
@@ -16386,7 +16459,7 @@ var AntigravityHistory = class _AntigravityHistory {
16386
16459
  await mkdir(directory, { recursive: true, mode: 448 });
16387
16460
  const temporary = path5.join(directory, `.${path5.basename(file2)}.${randomUUID()}.tmp`);
16388
16461
  try {
16389
- await writeFile(temporary, `${JSON.stringify({
16462
+ await writeFile2(temporary, `${JSON.stringify({
16390
16463
  formatVersion: HISTORY_VERSION,
16391
16464
  nativeSessionId,
16392
16465
  turns,
@@ -16396,7 +16469,7 @@ var AntigravityHistory = class _AntigravityHistory {
16396
16469
  `, { mode: 384 });
16397
16470
  await rename(temporary, file2);
16398
16471
  } finally {
16399
- await rm(temporary, { force: true }).catch(() => void 0);
16472
+ await rm2(temporary, { force: true }).catch(() => void 0);
16400
16473
  }
16401
16474
  });
16402
16475
  }
@@ -17521,7 +17594,7 @@ async function fetchAntigravityQuota(run, now = /* @__PURE__ */ new Date()) {
17521
17594
 
17522
17595
  // dist/question-bridge.js
17523
17596
  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";
17597
+ import { mkdir as mkdir3, mkdtemp as mkdtemp2, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
17525
17598
  import { createServer } from "node:http";
17526
17599
  import os4 from "node:os";
17527
17600
  import path8 from "node:path";
@@ -17649,7 +17722,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17649
17722
  this.#server.on("request", (request, response) => this.#receive(request, response));
17650
17723
  }
17651
17724
  static async create(options) {
17652
- const directory = await mkdtemp(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
17725
+ const directory = await mkdtemp2(path8.join(os4.tmpdir(), "codexhost-agy-question-"));
17653
17726
  const bridge = new _AntigravityQuestionBridge(directory, options);
17654
17727
  try {
17655
17728
  await new Promise((resolve, reject) => {
@@ -17666,12 +17739,12 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17666
17739
  bridge.environment.CODEXHOST_AGY_QUESTION_URL = `http://127.0.0.1:${address.port}/question`;
17667
17740
  const client = path8.join(directory, "question-hook.cjs");
17668
17741
  await mkdir3(path8.join(directory, ".agents"));
17669
- await writeFile2(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
17742
+ await writeFile3(client, ANTIGRAVITY_QUESTION_HOOK_CLIENT, "utf8");
17670
17743
  const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
17671
17744
  bridge.environment.CODEXHOST_AGY_QUESTION_NODE = `"${process.execPath.replaceAll("\\", "/")}"`;
17672
17745
  bridge.environment.CODEXHOST_AGY_QUESTION_CLIENT = `"${client.replaceAll("\\", "/")}"`;
17673
17746
  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({
17747
+ await writeFile3(path8.join(directory, ".agents", "hooks.json"), JSON.stringify({
17675
17748
  "codexhost-question-bridge": {
17676
17749
  PreToolUse: [
17677
17750
  {
@@ -17894,7 +17967,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
17894
17967
  this.#server.close(() => resolve());
17895
17968
  this.#server.closeAllConnections();
17896
17969
  });
17897
- await rm2(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
17970
+ await rm3(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
17898
17971
  })();
17899
17972
  return this.#disposal;
17900
17973
  }
@@ -18590,7 +18663,9 @@ function normalizedProcessError(detail, fallback, exposeDetail = false) {
18590
18663
  return {
18591
18664
  code: "nativeFailure",
18592
18665
  message: exposeDetail && nativeDetail ? `${fallback}: ${nativeDetail}` : fallback,
18593
- retryable: true,
18666
+ // These native rejections need a changed precondition or a quota reset;
18667
+ // immediately replaying a Turn (and its tools) cannot resolve them.
18668
+ retryable: !/User location is not supported for the API use|Individual quota reached/iu.test(nativeDetail),
18594
18669
  ...diagnostic ? { stderrTail: diagnostic.slice(-4e3) } : {}
18595
18670
  };
18596
18671
  }
@@ -19001,6 +19076,18 @@ ${line}`).slice(-8e3);
19001
19076
  async #handleResult(active, event) {
19002
19077
  if (this.#active !== active)
19003
19078
  return;
19079
+ const resultConversationId = event.result.conversation_id.trim();
19080
+ if (resultConversationId && this.#nativeRef && resultConversationId !== this.#nativeRef.nativeSessionId) {
19081
+ this.#completeTurn(active, {
19082
+ status: "failed",
19083
+ error: {
19084
+ code: "protocolError",
19085
+ message: "Antigravity returned a result for a different Conversation",
19086
+ retryable: false
19087
+ }
19088
+ });
19089
+ return;
19090
+ }
19004
19091
  const usage = hostUsage(event.result.usage, active.model?.id);
19005
19092
  if (usage)
19006
19093
  this.#publishUsage(active, usage);
@@ -19013,7 +19100,7 @@ ${line}`).slice(-8e3);
19013
19100
  await active.subagents.refresh();
19014
19101
  if (this.#active !== active)
19015
19102
  return;
19016
- const convId = event.result.conversation_id && event.result.conversation_id.trim().length > 0 ? event.result.conversation_id.trim() : this.#nativeRef?.nativeSessionId ?? "";
19103
+ const convId = resultConversationId || this.#nativeRef?.nativeSessionId || "";
19017
19104
  if (!this.#nativeRef && convId) {
19018
19105
  this.#nativeRef = nativeSessionRefSchema.parse({
19019
19106
  harnessId: this.harnessId,
@@ -19797,6 +19884,10 @@ function createHarnessAdapter(context) {
19797
19884
  ...environment[ANTIGRAVITY_COMMAND_ENV] ? { command: environment[ANTIGRAVITY_COMMAND_ENV] } : {},
19798
19885
  environment
19799
19886
  }), {
19887
+ install: createHarnessInstaller(environment, {
19888
+ posix: "https://antigravity.google/cli/install.sh",
19889
+ windows: "https://antigravity.google/cli/install.ps1"
19890
+ }),
19800
19891
  installation: createAntigravityInstallation(environment, environment[ANTIGRAVITY_COMMAND_ENV])
19801
19892
  });
19802
19893
  }