@liberseek/boft-cli-win32-arm64 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,488 @@ 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/npm-installation.js
358
+ import { readFile, realpath } from "node:fs/promises";
359
+ import path4 from "node:path";
360
+ function referencesNpmBin(shim, name, bin) {
361
+ if (bin.includes(".."))
362
+ return false;
363
+ const target = `node_modules/${name}/${bin.replace(/^\.\//, "")}`.toLowerCase();
364
+ const text = shim.replaceAll("\\", "/").toLowerCase();
365
+ return text.includes(`%dp0%/${target}"`) || text.includes(`%~dp0/${target}"`);
366
+ }
367
+ async function npmInstallation(command, packages, environment) {
368
+ let selected = await realpath(command);
369
+ if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
370
+ const shim = (await readFile(selected, "utf8")).replaceAll("\\", "/");
371
+ const root = path4.dirname(selected);
372
+ for (const name of packages) {
373
+ const directory2 = path4.join(root, "node_modules", ...name.split("/"));
374
+ const metadata = await readFile(path4.join(directory2, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
375
+ const bins = typeof metadata?.bin === "string" ? [metadata.bin] : Object.values(metadata?.bin ?? {});
376
+ const bin = bins.find((entry) => referencesNpmBin(shim, name, entry));
377
+ if (bin) {
378
+ selected = await realpath(path4.join(directory2, bin));
379
+ break;
380
+ }
381
+ }
382
+ }
383
+ let directory = path4.dirname(selected);
384
+ for (let depth = 0; depth < 8; depth++) {
385
+ const metadata = await readFile(path4.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
386
+ if (metadata?.name && packages.includes(metadata.name)) {
387
+ const name = metadata.name;
388
+ const currentVersion = installationVersion(metadata.version);
389
+ const segments = name.split("/");
390
+ let modules = directory;
391
+ for (let index = 0; index < segments.length; index++)
392
+ modules = path4.dirname(modules);
393
+ const prefix = process.platform === "win32" ? path4.dirname(modules) : path4.dirname(path4.dirname(modules));
394
+ const globalRoot = process.platform === "win32" ? path4.join(prefix, "node_modules") : path4.join(prefix, "lib", "node_modules");
395
+ const env = withNodeRuntimeOnPath(environment);
396
+ const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
397
+ let globalInstall = modules === globalRoot;
398
+ if (process.platform === "win32") {
399
+ const project = (await Promise.all(["package.json", "package-lock.json", "npm-shrinkwrap.json"].map((file2) => readFile(path4.join(prefix, file2), "utf8").then(() => true, (error51) => error51.code !== "ENOENT")))).some(Boolean);
400
+ const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
401
+ const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
402
+ if (path4.basename(bin) !== bin || entry.includes(".."))
403
+ return false;
404
+ const target = await realpath(path4.join(directory, entry)).catch(() => "");
405
+ if (target.toLowerCase() !== selected.toLowerCase())
406
+ return false;
407
+ const shim = await readFile(path4.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
408
+ return referencesNpmBin(shim, name, entry);
409
+ }));
410
+ globalInstall = globalInstall && !project && launchers.some(Boolean);
411
+ }
412
+ const canUpdate = globalInstall && !!npm;
413
+ return {
414
+ prefix,
415
+ currentVersion,
416
+ canUpdate,
417
+ latest: async () => {
418
+ const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(name)}/latest`));
419
+ return installationVersion(data.version);
420
+ },
421
+ update: async (version2) => {
422
+ if (!canUpdate || !npm)
423
+ throw new Error("Use the original package manager to update this installation");
424
+ await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${installationVersion(version2)}`], env, 3e5);
425
+ }
426
+ };
427
+ }
428
+ const parent = path4.dirname(directory);
429
+ if (parent === directory)
430
+ break;
431
+ directory = parent;
432
+ }
433
+ return null;
434
+ }
435
+
436
+ // ../../harness-discovery/dist/installer.js
437
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
438
+ import { tmpdir } from "node:os";
439
+ import { join } from "node:path";
440
+ function createHarnessInstaller(environment, source) {
441
+ return async () => {
442
+ if (!["darwin", "linux", "win32"].includes(process.platform))
443
+ throw new Error("Unsupported installation platform");
444
+ const env = withNodeRuntimeOnPath(environment);
445
+ if ("npm" in source) {
446
+ const npm = resolveHarnessExecutable({
447
+ id: "npm",
448
+ command: "npm",
449
+ installRoots: {
450
+ posix: [
451
+ "~/.npm-global/bin",
452
+ "~/.local/bin",
453
+ VERSION_MANAGER_ROOTS,
454
+ "/opt/homebrew/bin",
455
+ "/usr/local/bin",
456
+ "/usr/bin"
457
+ ],
458
+ windows: [
459
+ "${APPDATA}/npm",
460
+ VERSION_MANAGER_ROOTS,
461
+ "${ProgramFiles}/nodejs",
462
+ "${LOCALAPPDATA}/Programs/nodejs"
463
+ ]
464
+ }
465
+ }, { environment: env });
466
+ if (!npm)
467
+ throw new Error("Install Node.js and npm first");
468
+ await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
469
+ ...env,
470
+ ...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
471
+ }, 6e5);
472
+ return;
473
+ }
474
+ const windows = process.platform === "win32";
475
+ const url2 = windows ? source.windows : source.posix;
476
+ if (new URL(url2).protocol !== "https:")
477
+ throw new Error("Installer requires HTTPS");
478
+ const script = await fetchInstallationText(url2);
479
+ const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
480
+ try {
481
+ const file2 = join(directory, windows ? "install.ps1" : "install.sh");
482
+ await writeFile(file2, script, { mode: 384 });
483
+ await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
484
+ } finally {
485
+ await rm(directory, { recursive: true, force: true });
486
+ }
487
+ };
488
+ }
489
+
8
490
  // dist/opencode-adapter.js
9
491
  import { randomUUID } from "node:crypto";
10
492
  import fs4 from "node:fs";
@@ -14594,6 +15076,71 @@ var harnessDisplaySetSchema = external_exports.strictObject({
14594
15076
  initializeOnly: external_exports.boolean().optional()
14595
15077
  });
14596
15078
 
15079
+ // ../../shared-contracts/dist/ids.js
15080
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15081
+ message: "Identifier must not be empty or whitespace"
15082
+ });
15083
+ var harnessIdSchema = opaqueIdSchema.brand();
15084
+ var hostThreadIdSchema = opaqueIdSchema.brand();
15085
+ var hostTurnIdSchema = opaqueIdSchema.brand();
15086
+ var hostItemIdSchema = opaqueIdSchema.brand();
15087
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
15088
+
15089
+ // ../../shared-contracts/dist/harness-plugins.js
15090
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15091
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15092
+ var HARNESS_PLUGIN_LIMIT = 128;
15093
+ 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);
15094
+ 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");
15095
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15096
+ var pluginPresentationShape = {
15097
+ id: harnessPluginIdSchema,
15098
+ name: external_exports.string().trim().min(1).max(128),
15099
+ version: external_exports.string().min(1).max(128),
15100
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15101
+ launchCommand: external_exports.literal(true).optional(),
15102
+ links: external_exports.object({
15103
+ documentation: documentationUrlSchema.optional(),
15104
+ installation: documentationUrlSchema.optional()
15105
+ }).strict().optional()
15106
+ };
15107
+ var harnessPluginManifestSchema = external_exports.object({
15108
+ manifestVersion: external_exports.literal(1),
15109
+ ...pluginPresentationShape,
15110
+ adapterApiVersion: external_exports.number().int().positive(),
15111
+ entry: relativeResourceSchema,
15112
+ icon: relativeResourceSchema.optional()
15113
+ }).strict();
15114
+ 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);
15115
+ var harnessPluginDescriptorSchema = external_exports.object({
15116
+ ...pluginPresentationShape,
15117
+ icon: harnessPluginIconSchema.optional()
15118
+ }).strict();
15119
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15120
+ var harnessPluginListResultSchema = external_exports.object({
15121
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15122
+ }).strict();
15123
+ var harnessPluginConfigurationSchema = external_exports.object({
15124
+ version: external_exports.literal(1),
15125
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15126
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15127
+ message: "Enabled plugin IDs must be unique",
15128
+ path: ["enabled"]
15129
+ });
15130
+
15131
+ // ../../shared-contracts/dist/harness-long-context.js
15132
+ var HARNESS_LONG_CONTEXT_GET_METHOD = "codexhost/harness/long-context/get";
15133
+ var HARNESS_LONG_CONTEXT_SET_METHOD = "codexhost/harness/long-context/set";
15134
+ var harnessLongContextGetSchema = external_exports.object({
15135
+ harnessId: harnessPluginIdSchema
15136
+ }).strict();
15137
+ var harnessLongContextSetSchema = harnessLongContextGetSchema.extend({
15138
+ enabled: external_exports.boolean()
15139
+ });
15140
+ var harnessLongContextSchema = external_exports.object({
15141
+ enabled: external_exports.boolean()
15142
+ }).strict();
15143
+
14597
15144
  // ../../shared-contracts/dist/console.js
14598
15145
  var consoleAnnouncementSchema = external_exports.strictObject({
14599
15146
  title: external_exports.string().trim().min(1).max(200),
@@ -14610,8 +15157,11 @@ var CONSOLE_HOST_METHODS = Object.freeze([
14610
15157
  "codexhost/harness/display-settings/get",
14611
15158
  "codexhost/harness/display-settings/set",
14612
15159
  "codexhost/harness/inspect",
15160
+ "codexhost/harness/installation",
14613
15161
  "codexhost/harness/launch-settings/get",
14614
15162
  "codexhost/harness/launch-settings/set",
15163
+ HARNESS_LONG_CONTEXT_GET_METHOD,
15164
+ HARNESS_LONG_CONTEXT_SET_METHOD,
14615
15165
  "codexhost/harness/web-ui/open",
14616
15166
  "codexhost/harness/accounts/sources",
14617
15167
  "codexhost/harness/accounts/list",
@@ -14671,16 +15221,6 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
14671
15221
  inactiveMs: external_exports.number().nonnegative()
14672
15222
  }));
14673
15223
 
14674
- // ../../shared-contracts/dist/ids.js
14675
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14676
- message: "Identifier must not be empty or whitespace"
14677
- });
14678
- var harnessIdSchema = opaqueIdSchema.brand();
14679
- var hostThreadIdSchema = opaqueIdSchema.brand();
14680
- var hostTurnIdSchema = opaqueIdSchema.brand();
14681
- var hostItemIdSchema = opaqueIdSchema.brand();
14682
- var hostInteractionIdSchema = opaqueIdSchema.brand();
14683
-
14684
15224
  // ../../shared-contracts/dist/manual-compaction.js
14685
15225
  var threadManualCompactionStartedSchema = external_exports.strictObject({
14686
15226
  threadId: hostThreadIdSchema,
@@ -15186,70 +15726,28 @@ var codexThreadOwnershipSchema = external_exports.object({
15186
15726
  owner: external_exports.literal("codex")
15187
15727
  }).strict();
15188
15728
  var externalThreadOwnershipSchema = external_exports.object({
15189
- threadId: hostThreadIdSchema,
15190
- owner: external_exports.literal("external"),
15191
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15192
- }).strict();
15193
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15194
- codexThreadOwnershipSchema,
15195
- externalThreadOwnershipSchema
15196
- ]);
15197
- var threadOwnershipListResultSchema = external_exports.object({
15198
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15199
- }).strict().superRefine(({ threads }, context) => {
15200
- const seen = /* @__PURE__ */ new Set();
15201
- for (const [index, thread] of threads.entries()) {
15202
- if (seen.has(thread.threadId)) {
15203
- context.addIssue({
15204
- code: "custom",
15205
- message: "Thread ownership-list results must be unique",
15206
- path: ["threads", index, "threadId"]
15207
- });
15208
- }
15209
- seen.add(thread.threadId);
15210
- }
15211
- });
15212
-
15213
- // ../../shared-contracts/dist/harness-plugins.js
15214
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15215
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15216
- var HARNESS_PLUGIN_LIMIT = 128;
15217
- 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);
15218
- 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");
15219
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15220
- var pluginPresentationShape = {
15221
- id: harnessPluginIdSchema,
15222
- name: external_exports.string().trim().min(1).max(128),
15223
- version: external_exports.string().min(1).max(128),
15224
- /** The factory accepts a persisted local entrypoint through its construction context. */
15225
- launchCommand: external_exports.literal(true).optional(),
15226
- links: external_exports.object({
15227
- documentation: documentationUrlSchema.optional(),
15228
- installation: documentationUrlSchema.optional()
15229
- }).strict().optional()
15230
- };
15231
- var harnessPluginManifestSchema = external_exports.object({
15232
- manifestVersion: external_exports.literal(1),
15233
- ...pluginPresentationShape,
15234
- adapterApiVersion: external_exports.number().int().positive(),
15235
- entry: relativeResourceSchema,
15236
- icon: relativeResourceSchema.optional()
15237
- }).strict();
15238
- 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);
15239
- var harnessPluginDescriptorSchema = external_exports.object({
15240
- ...pluginPresentationShape,
15241
- icon: harnessPluginIconSchema.optional()
15242
- }).strict();
15243
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
15244
- var harnessPluginListResultSchema = external_exports.object({
15245
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15246
- }).strict();
15247
- var harnessPluginConfigurationSchema = external_exports.object({
15248
- version: external_exports.literal(1),
15249
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15250
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15251
- message: "Enabled plugin IDs must be unique",
15252
- path: ["enabled"]
15729
+ threadId: hostThreadIdSchema,
15730
+ owner: external_exports.literal("external"),
15731
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15732
+ }).strict();
15733
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15734
+ codexThreadOwnershipSchema,
15735
+ externalThreadOwnershipSchema
15736
+ ]);
15737
+ var threadOwnershipListResultSchema = external_exports.object({
15738
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15739
+ }).strict().superRefine(({ threads }, context) => {
15740
+ const seen = /* @__PURE__ */ new Set();
15741
+ for (const [index, thread] of threads.entries()) {
15742
+ if (seen.has(thread.threadId)) {
15743
+ context.addIssue({
15744
+ code: "custom",
15745
+ message: "Thread ownership-list results must be unique",
15746
+ path: ["threads", index, "threadId"]
15747
+ });
15748
+ }
15749
+ seen.add(thread.threadId);
15750
+ }
15253
15751
  });
15254
15752
 
15255
15753
  // ../../shared-contracts/dist/harness-route.js
@@ -15276,14 +15774,17 @@ var harnessLaunchSettingsSchema = external_exports.object({
15276
15774
  // ../../shared-contracts/dist/harness-installation.js
15277
15775
  var harnessInstallationParamsSchema = external_exports.object({
15278
15776
  harnessId: harnessIdSchema,
15279
- action: external_exports.enum(["check", "update"])
15777
+ action: external_exports.enum(["check", "update", "install"])
15280
15778
  }).strict();
15281
15779
  var harnessInstallationStateSchema = external_exports.object({
15282
15780
  currentVersion: external_exports.string().min(1).max(128),
15283
15781
  latestVersion: external_exports.string().min(1).max(128),
15284
15782
  updateAvailable: external_exports.boolean(),
15285
15783
  canUpdate: external_exports.boolean(),
15286
- message: external_exports.string().max(2048).optional()
15784
+ // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
15785
+ message: external_exports.string().max(2048).optional(),
15786
+ messageCode: external_exports.string().min(1).max(128).optional(),
15787
+ latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
15287
15788
  }).strict();
15288
15789
 
15289
15790
  // ../../shared-contracts/dist/codex-accounts.js
@@ -15578,7 +16079,7 @@ var updateStatusSchema = external_exports.strictObject({
15578
16079
  }
15579
16080
  });
15580
16081
  var updateEmptyParamsSchema = external_exports.strictObject({});
15581
- 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");
16082
+ 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");
15582
16083
  var updateCheckResultSchema = external_exports.strictObject({
15583
16084
  currentVersion: updateSemanticVersionSchema,
15584
16085
  installation: updateInstallationSchema.nullable(),
@@ -16223,7 +16724,7 @@ import { randomBytes } from "node:crypto";
16223
16724
  import { spawn, spawnSync } from "node:child_process";
16224
16725
  import fs2 from "node:fs";
16225
16726
  import { createServer } from "node:net";
16226
- import { homedir as homedir2, tmpdir } from "node:os";
16727
+ import { homedir as homedir2, tmpdir as tmpdir2 } from "node:os";
16227
16728
  import path6 from "node:path";
16228
16729
 
16229
16730
  // ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
@@ -21447,617 +21948,187 @@ var OpencodeClient = class _OpencodeClient extends HeyApiClient {
21447
21948
  }
21448
21949
  _find;
21449
21950
  get find() {
21450
- return this._find ??= new Find({ client: this.client });
21451
- }
21452
- _file;
21453
- get file() {
21454
- return this._file ??= new File2({ client: this.client });
21455
- }
21456
- _instance;
21457
- get instance() {
21458
- return this._instance ??= new Instance({ client: this.client });
21459
- }
21460
- _path;
21461
- get path() {
21462
- return this._path ??= new Path({ client: this.client });
21463
- }
21464
- _vcs;
21465
- get vcs() {
21466
- return this._vcs ??= new Vcs({ client: this.client });
21467
- }
21468
- _command;
21469
- get command() {
21470
- return this._command ??= new Command({ client: this.client });
21471
- }
21472
- _lsp;
21473
- get lsp() {
21474
- return this._lsp ??= new Lsp({ client: this.client });
21475
- }
21476
- _formatter;
21477
- get formatter() {
21478
- return this._formatter ??= new Formatter({ client: this.client });
21479
- }
21480
- _mcp;
21481
- get mcp() {
21482
- return this._mcp ??= new Mcp({ client: this.client });
21483
- }
21484
- _project;
21485
- get project() {
21486
- return this._project ??= new Project({ client: this.client });
21487
- }
21488
- _pty;
21489
- get pty() {
21490
- return this._pty ??= new Pty({ client: this.client });
21491
- }
21492
- _question;
21493
- get question() {
21494
- return this._question ??= new Question({ client: this.client });
21495
- }
21496
- _permission;
21497
- get permission() {
21498
- return this._permission ??= new Permission({ client: this.client });
21499
- }
21500
- _provider;
21501
- get provider() {
21502
- return this._provider ??= new Provider({ client: this.client });
21503
- }
21504
- _session;
21505
- get session() {
21506
- return this._session ??= new Session2({ client: this.client });
21507
- }
21508
- _part;
21509
- get part() {
21510
- return this._part ??= new Part({ client: this.client });
21511
- }
21512
- _sync;
21513
- get sync() {
21514
- return this._sync ??= new Sync({ client: this.client });
21515
- }
21516
- _tui;
21517
- get tui() {
21518
- return this._tui ??= new Tui({ client: this.client });
21519
- }
21520
- _v2;
21521
- get v2() {
21522
- return this._v2 ??= new V2({ client: this.client });
21523
- }
21524
- };
21525
-
21526
- // ../../../node_modules/@opencode-ai/sdk/dist/error-interceptor.js
21527
- function wrapClientError(error51, response, request, opts) {
21528
- if (!opts?.throwOnError)
21529
- return error51;
21530
- if (error51 instanceof Error)
21531
- return error51;
21532
- if (typeof error51 === "object" && error51 !== null && Object.keys(error51).length > 0) {
21533
- const obj = error51;
21534
- const message = typeof obj.data?.message === "string" && obj.data.message || typeof obj.message === "string" && obj.message || typeof obj.name === "string" && obj.name || describe3(request, response);
21535
- return new Error(message, { cause: { body: error51, status: response?.status } });
21536
- }
21537
- if (typeof error51 === "string" && error51.length > 0) {
21538
- return new Error(error51, { cause: { body: error51, status: response?.status } });
21539
- }
21540
- const reason = response ? "(empty response body)" : "network error (no response)";
21541
- return new Error(`opencode server ${describe3(request, response)}: ${reason}`, {
21542
- cause: { body: error51, status: response?.status }
21543
- });
21544
- }
21545
- function describe3(request, response) {
21546
- const method = request?.method ?? "?";
21547
- const url2 = request?.url ?? "?";
21548
- const status = response?.status;
21549
- const statusText = response?.statusText;
21550
- return `${method} ${url2}${status ? " → " + status : ""}${statusText ? " " + statusText : ""}`;
21551
- }
21552
-
21553
- // ../../../node_modules/@opencode-ai/sdk/dist/v2/client.js
21554
- function pick2(value, fallback, encode3) {
21555
- if (!value)
21556
- return;
21557
- if (!fallback)
21558
- return value;
21559
- if (value === fallback)
21560
- return fallback;
21561
- if (encode3 && value === encode3(fallback))
21562
- return fallback;
21563
- return value;
21564
- }
21565
- function rewrite(request, values) {
21566
- if (request.method !== "GET" && request.method !== "HEAD")
21567
- return request;
21568
- const url2 = new URL(request.url);
21569
- let changed = false;
21570
- for (const [name, key] of [
21571
- ["x-opencode-directory", "directory"],
21572
- ["x-opencode-workspace", "workspace"]
21573
- ]) {
21574
- const value = pick2(request.headers.get(name), key === "directory" ? values.directory : values.workspace, key === "directory" ? encodeURIComponent : void 0);
21575
- if (!value)
21576
- continue;
21577
- for (const query of url2.pathname.startsWith("/api/") ? [key, `location[${key}]`] : [key]) {
21578
- if (!url2.searchParams.has(query)) {
21579
- url2.searchParams.set(query, value);
21580
- }
21581
- }
21582
- changed = true;
21583
- }
21584
- if (!changed)
21585
- return request;
21586
- const next = new Request(url2, request);
21587
- next.headers.delete("x-opencode-directory");
21588
- next.headers.delete("x-opencode-workspace");
21589
- return next;
21590
- }
21591
- function createOpencodeClient(config2) {
21592
- if (!config2?.fetch) {
21593
- const customFetch = (req) => {
21594
- req.timeout = false;
21595
- return fetch(req);
21596
- };
21597
- config2 = {
21598
- ...config2,
21599
- fetch: customFetch
21600
- };
21601
- }
21602
- if (config2?.directory) {
21603
- config2.headers = {
21604
- ...config2.headers,
21605
- "x-opencode-directory": encodeURIComponent(config2.directory)
21606
- };
21607
- }
21608
- if (config2?.experimental_workspaceID) {
21609
- config2.headers = {
21610
- ...config2.headers,
21611
- "x-opencode-workspace": config2.experimental_workspaceID
21612
- };
21613
- }
21614
- const client2 = createClient(config2);
21615
- client2.interceptors.request.use((request) => rewrite(request, {
21616
- directory: config2?.directory,
21617
- workspace: config2?.experimental_workspaceID
21618
- }));
21619
- client2.interceptors.response.use((response) => {
21620
- const contentType = response.headers.get("content-type");
21621
- if (contentType === "text/html")
21622
- throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");
21623
- return response;
21624
- });
21625
- client2.interceptors.error.use(wrapClientError);
21626
- return new OpencodeClient({ client: client2 });
21627
- }
21628
-
21629
- // dist/command.js
21630
- import path5 from "node:path";
21631
-
21632
- // ../../harness-discovery/dist/environment.js
21633
- import fs from "node:fs";
21634
- import path from "node:path";
21635
- function targetPath(platform) {
21636
- return platform === "win32" ? path.win32 : path.posix;
21637
- }
21638
- function environmentValue(environment, name) {
21639
- const lowered = name.toLowerCase();
21640
- for (const [key, value] of Object.entries(environment)) {
21641
- if (key.toLowerCase() === lowered)
21642
- return value;
21643
- }
21644
- return void 0;
21645
- }
21646
- function pathDelimiter(platform) {
21647
- return platform === "win32" ? ";" : ":";
21648
- }
21649
- function pathDirectories(environment, platform) {
21650
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
21651
- }
21652
- function executableExtensions(command, platform, environment) {
21653
- if (platform !== "win32")
21654
- return [""];
21655
- if (targetPath(platform).extname(command) !== "")
21656
- return [""];
21657
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
21658
- }
21659
- function isExecutableFile(filePath, platform) {
21660
- try {
21661
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
21662
- return fs.statSync(filePath).isFile();
21663
- } catch {
21664
- return false;
21665
- }
21666
- }
21667
- function subdirectoryNames(directory) {
21668
- try {
21669
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
21670
- } catch {
21671
- return [];
21672
- }
21673
- }
21674
- function newestFirst(names) {
21675
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
21676
- }
21677
-
21678
- // ../../harness-discovery/dist/invocation.js
21679
- import path2 from "node:path";
21680
- function commandInvocation(command, arguments_, environment, platform = process.platform) {
21681
- const extension = path2.win32.extname(command).toLowerCase();
21682
- if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
21683
- return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
21951
+ return this._find ??= new Find({ client: this.client });
21684
21952
  }
21685
- const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
21686
- const commandLine = [command, ...arguments_].map(quote).join(" ");
21687
- return {
21688
- command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
21689
- arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
21690
- windowsVerbatimArguments: true
21691
- };
21692
- }
21693
-
21694
- // ../../harness-discovery/dist/node-runtime.js
21695
- import path3 from "node:path";
21696
- function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
21697
- const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
21698
- const delimiter = platform === "win32" ? ";" : ":";
21699
- const runtimeDirectory = path3.dirname(runtimeExecutable);
21700
- const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
21701
- const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
21702
- if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
21703
- directories.push(runtimeDirectory);
21953
+ _file;
21954
+ get file() {
21955
+ return this._file ??= new File2({ client: this.client });
21704
21956
  }
21705
- return { ...environment, [pathKey]: directories.join(delimiter) };
21706
- }
21707
-
21708
- // ../../harness-discovery/dist/resolve.js
21709
- import os from "node:os";
21710
-
21711
- // ../../harness-discovery/dist/version-managers.js
21712
- function versionManagerBinaryDirectories(context) {
21713
- const { platform, environment, home } = context;
21714
- const list = context.subdirectories ?? subdirectoryNames;
21715
- const pathFlavor = targetPath(platform);
21716
- const value = (name) => environmentValue(environment, name);
21717
- const directories = [];
21718
- const versioned = (root, ...tail) => {
21719
- for (const version2 of newestFirst(list(root))) {
21720
- directories.push(pathFlavor.join(root, version2, ...tail));
21721
- }
21722
- };
21723
- if (platform === "win32") {
21724
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
21725
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
21726
- versioned(pathFlavor.join(appData, "nvm"));
21727
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
21728
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
21729
- directories.push(pathFlavor.join(home, ".bun", "bin"));
21730
- const pnpmHome2 = value("PNPM_HOME");
21731
- if (pnpmHome2)
21732
- directories.push(pnpmHome2);
21733
- directories.push(pathFlavor.join(localAppData, "pnpm"));
21734
- return directories;
21957
+ _instance;
21958
+ get instance() {
21959
+ return this._instance ??= new Instance({ client: this.client });
21735
21960
  }
21736
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
21737
- const fnmRoots = [
21738
- value("FNM_DIR"),
21739
- pathFlavor.join(home, ".local", "share", "fnm"),
21740
- pathFlavor.join(home, "Library", "Application Support", "fnm")
21741
- ].filter((root) => root !== void 0);
21742
- for (const root of fnmRoots) {
21743
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
21961
+ _path;
21962
+ get path() {
21963
+ return this._path ??= new Path({ client: this.client });
21744
21964
  }
21745
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
21746
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
21747
- directories.push(pathFlavor.join(voltaHome, "bin"));
21748
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
21749
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
21750
- directories.push(pathFlavor.join(asdfHome, "shims"));
21751
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
21752
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
21753
- directories.push(pathFlavor.join(nodenvHome, "shims"));
21754
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
21755
- directories.push(pathFlavor.join(home, ".bun", "bin"));
21756
- const pnpmHome = value("PNPM_HOME");
21757
- if (pnpmHome)
21758
- directories.push(pnpmHome);
21759
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
21760
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
21761
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
21762
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
21763
- directories.push(pathFlavor.join(prefix, formula, "bin"));
21764
- }
21965
+ _vcs;
21966
+ get vcs() {
21967
+ return this._vcs ??= new Vcs({ client: this.client });
21765
21968
  }
21766
- return directories;
21767
- }
21768
-
21769
- // ../../harness-discovery/dist/resolve.js
21770
- var VERSION_MANAGER_ROOTS = "<version-managers>";
21771
- function installRootExtensions(platform) {
21772
- return platform === "win32" ? [".exe", ".cmd"] : [""];
21773
- }
21774
- function resolveHomeDirectory(input) {
21775
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
21776
- }
21777
- function templateVariables(environment, platform, home) {
21778
- const pathFlavor = targetPath(platform);
21779
- return {
21780
- HOME: home,
21781
- USERPROFILE: home,
21782
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
21783
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
21784
- };
21785
- }
21786
- function joinTemplate(platform, value) {
21787
- const pathFlavor = targetPath(platform);
21788
- const segments = value.split("/");
21789
- const head = segments[0] ?? "";
21790
- const tail = segments.slice(1);
21791
- if (head === "")
21792
- return pathFlavor.join(pathFlavor.sep, ...tail);
21793
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
21794
- }
21795
- function expandInstallRoot(template, environment, platform, home) {
21796
- const variables = templateVariables(environment, platform, home);
21797
- let unresolved = false;
21798
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
21799
- const value = variables[name] ?? environmentValue(environment, name);
21800
- if (value === void 0 || value === "") {
21801
- unresolved = true;
21802
- return "";
21803
- }
21804
- return value;
21805
- });
21806
- return unresolved ? void 0 : joinTemplate(platform, substituted);
21807
- }
21808
- function installRootDirectories(spec, input, dependencies, platform, home) {
21809
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
21810
- const directories = [];
21811
- for (const template of templates) {
21812
- if (template === VERSION_MANAGER_ROOTS) {
21813
- directories.push(...versionManagerBinaryDirectories({
21814
- platform,
21815
- environment: input.environment,
21816
- home,
21817
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
21818
- }));
21819
- continue;
21820
- }
21821
- const directory = expandInstallRoot(template, input.environment, platform, home);
21822
- if (directory !== void 0)
21823
- directories.push(directory);
21969
+ _command;
21970
+ get command() {
21971
+ return this._command ??= new Command({ client: this.client });
21824
21972
  }
21825
- return directories;
21826
- }
21827
- function harnessCandidates(spec, input, dependencies = {}) {
21828
- const platform = input.platform ?? process.platform;
21829
- const pathFlavor = targetPath(platform);
21830
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
21831
- const command = configured ?? spec.command;
21832
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
21833
- return [{ candidate: command, source: "configured" }];
21973
+ _lsp;
21974
+ get lsp() {
21975
+ return this._lsp ??= new Lsp({ client: this.client });
21834
21976
  }
21835
- const candidates = [];
21836
- const extensions = executableExtensions(command, platform, input.environment);
21837
- for (const directory of pathDirectories(input.environment, platform)) {
21838
- for (const extension of extensions) {
21839
- candidates.push({
21840
- candidate: pathFlavor.join(directory, command + extension),
21841
- source: "path"
21842
- });
21843
- }
21977
+ _formatter;
21978
+ get formatter() {
21979
+ return this._formatter ??= new Formatter({ client: this.client });
21844
21980
  }
21845
- if (configured !== void 0)
21846
- return candidates;
21847
- const home = resolveHomeDirectory(input);
21848
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
21849
- for (const extension of installRootExtensions(platform)) {
21850
- candidates.push({
21851
- candidate: pathFlavor.join(directory, spec.command + extension),
21852
- source: "install-root"
21853
- });
21854
- }
21981
+ _mcp;
21982
+ get mcp() {
21983
+ return this._mcp ??= new Mcp({ client: this.client });
21855
21984
  }
21856
- return candidates;
21857
- }
21858
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
21859
- const platform = input.platform ?? process.platform;
21860
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
21861
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
21862
- const context = { platform, isExecutable };
21863
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
21864
- const executable = runnable(candidate, context);
21865
- if (executable !== void 0 && isExecutable(executable))
21866
- return { executable, source };
21985
+ _project;
21986
+ get project() {
21987
+ return this._project ??= new Project({ client: this.client });
21867
21988
  }
21868
- return void 0;
21869
- }
21870
-
21871
- // ../../harness-discovery/dist/installation.js
21872
- import { execFile } from "node:child_process";
21873
- import { homedir } from "node:os";
21874
- function runInstallationCommand(command, args, environment, timeout = 3e4) {
21875
- const env = withNodeRuntimeOnPath(environment);
21876
- const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
21877
- return new Promise((resolve, reject) => {
21878
- const child = execFile(invocation.command, invocation.arguments, {
21879
- env,
21880
- cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
21881
- encoding: "utf8",
21882
- timeout,
21883
- killSignal: "SIGKILL",
21884
- maxBuffer: 1024 * 1024,
21885
- windowsHide: true,
21886
- windowsVerbatimArguments: invocation.windowsVerbatimArguments
21887
- }, (error51, stdout, stderr) => {
21888
- if (error51)
21889
- reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
21890
- else
21891
- resolve((stdout || stderr).trim());
21892
- });
21893
- child.stdin?.end();
21894
- });
21895
- }
21896
- function installationVersion(value) {
21897
- if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
21898
- throw new Error("Harness returned an invalid version");
21899
- return value.trim().replace(/^v/, "");
21900
- }
21901
- function versionFromOutput(output) {
21902
- return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
21903
- }
21904
- function newerInstallationVersion(current, latest) {
21905
- const a = installationVersion(current).replace(/\+.*/, "");
21906
- const b = installationVersion(latest).replace(/\+.*/, "");
21907
- const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
21908
- const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
21909
- for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
21910
- if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
21911
- return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
21989
+ _pty;
21990
+ get pty() {
21991
+ return this._pty ??= new Pty({ client: this.client });
21992
+ }
21993
+ _question;
21994
+ get question() {
21995
+ return this._question ??= new Question({ client: this.client });
21996
+ }
21997
+ _permission;
21998
+ get permission() {
21999
+ return this._permission ??= new Permission({ client: this.client });
21912
22000
  }
21913
- const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
21914
- const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
21915
- if (!preA.length || !preB.length)
21916
- return !!preA.length && !preB.length;
21917
- for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
21918
- const x = preA[i];
21919
- const y = preB[i];
21920
- if (x === y)
21921
- continue;
21922
- if (x === void 0 || y === void 0)
21923
- return x === void 0;
21924
- const numericX = /^\d+$/.test(x);
21925
- const numericY = /^\d+$/.test(y);
21926
- if (numericX && numericY) {
21927
- if (BigInt(x) === BigInt(y))
21928
- continue;
21929
- return BigInt(y) > BigInt(x);
21930
- }
21931
- if (numericX !== numericY)
21932
- return numericX;
21933
- return y > x;
22001
+ _provider;
22002
+ get provider() {
22003
+ return this._provider ??= new Provider({ client: this.client });
21934
22004
  }
21935
- return false;
21936
- }
21937
- function createInstallationManager(options) {
21938
- let checking;
21939
- let updating;
21940
- const check2 = () => checking ??= options.check().finally(() => {
21941
- checking = void 0;
22005
+ _session;
22006
+ get session() {
22007
+ return this._session ??= new Session2({ client: this.client });
22008
+ }
22009
+ _part;
22010
+ get part() {
22011
+ return this._part ??= new Part({ client: this.client });
22012
+ }
22013
+ _sync;
22014
+ get sync() {
22015
+ return this._sync ??= new Sync({ client: this.client });
22016
+ }
22017
+ _tui;
22018
+ get tui() {
22019
+ return this._tui ??= new Tui({ client: this.client });
22020
+ }
22021
+ _v2;
22022
+ get v2() {
22023
+ return this._v2 ??= new V2({ client: this.client });
22024
+ }
22025
+ };
22026
+
22027
+ // ../../../node_modules/@opencode-ai/sdk/dist/error-interceptor.js
22028
+ function wrapClientError(error51, response, request, opts) {
22029
+ if (!opts?.throwOnError)
22030
+ return error51;
22031
+ if (error51 instanceof Error)
22032
+ return error51;
22033
+ if (typeof error51 === "object" && error51 !== null && Object.keys(error51).length > 0) {
22034
+ const obj = error51;
22035
+ const message = typeof obj.data?.message === "string" && obj.data.message || typeof obj.message === "string" && obj.message || typeof obj.name === "string" && obj.name || describe3(request, response);
22036
+ return new Error(message, { cause: { body: error51, status: response?.status } });
22037
+ }
22038
+ if (typeof error51 === "string" && error51.length > 0) {
22039
+ return new Error(error51, { cause: { body: error51, status: response?.status } });
22040
+ }
22041
+ const reason = response ? "(empty response body)" : "network error (no response)";
22042
+ return new Error(`opencode server ${describe3(request, response)}: ${reason}`, {
22043
+ cause: { body: error51, status: response?.status }
21942
22044
  });
21943
- return (action) => {
21944
- if (updating)
21945
- return updating;
21946
- if (action === "check")
21947
- return check2();
21948
- updating = (async () => {
21949
- const before = await check2();
21950
- if (!before.updateAvailable)
21951
- return before;
21952
- if (!before.canUpdate)
21953
- throw new Error(before.message ?? "This installation cannot be updated automatically");
21954
- await options.update(before);
21955
- const after = await check2();
21956
- if (after.currentVersion === before.currentVersion)
21957
- throw new Error("The Harness version did not change; check the native updater and retry");
21958
- return after;
21959
- })().finally(() => {
21960
- updating = void 0;
21961
- });
21962
- return updating;
21963
- };
21964
22045
  }
21965
- async function fetchInstallationText(url2) {
21966
- const request = async () => {
21967
- const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
21968
- if (!response.ok)
21969
- throw new Error("Could not check the latest Harness version");
21970
- return response.text();
21971
- };
21972
- try {
21973
- return await request();
21974
- } catch (error51) {
21975
- if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
21976
- throw error51;
21977
- return request();
21978
- }
22046
+ function describe3(request, response) {
22047
+ const method = request?.method ?? "?";
22048
+ const url2 = request?.url ?? "?";
22049
+ const status = response?.status;
22050
+ const statusText = response?.statusText;
22051
+ return `${method} ${url2}${status ? " → " + status : ""}${statusText ? " " + statusText : ""}`;
21979
22052
  }
21980
22053
 
21981
- // ../../harness-discovery/dist/npm-installation.js
21982
- import { readFile, realpath } from "node:fs/promises";
21983
- import path4 from "node:path";
21984
- function referencesNpmBin(shim, name, bin) {
21985
- if (bin.includes(".."))
21986
- return false;
21987
- const target = `node_modules/${name}/${bin.replace(/^\.\//, "")}`.toLowerCase();
21988
- const text = shim.replaceAll("\\", "/").toLowerCase();
21989
- return text.includes(`%dp0%/${target}"`) || text.includes(`%~dp0/${target}"`);
22054
+ // ../../../node_modules/@opencode-ai/sdk/dist/v2/client.js
22055
+ function pick2(value, fallback, encode3) {
22056
+ if (!value)
22057
+ return;
22058
+ if (!fallback)
22059
+ return value;
22060
+ if (value === fallback)
22061
+ return fallback;
22062
+ if (encode3 && value === encode3(fallback))
22063
+ return fallback;
22064
+ return value;
21990
22065
  }
21991
- async function npmInstallation(command, packages, environment) {
21992
- let selected = await realpath(command);
21993
- if (process.platform === "win32" && /\.(cmd|bat)$/i.test(selected)) {
21994
- const shim = (await readFile(selected, "utf8")).replaceAll("\\", "/");
21995
- const root = path4.dirname(selected);
21996
- for (const name of packages) {
21997
- const directory2 = path4.join(root, "node_modules", ...name.split("/"));
21998
- const metadata = await readFile(path4.join(directory2, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
21999
- const bins = typeof metadata?.bin === "string" ? [metadata.bin] : Object.values(metadata?.bin ?? {});
22000
- const bin = bins.find((entry) => referencesNpmBin(shim, name, entry));
22001
- if (bin) {
22002
- selected = await realpath(path4.join(directory2, bin));
22003
- break;
22066
+ function rewrite(request, values) {
22067
+ if (request.method !== "GET" && request.method !== "HEAD")
22068
+ return request;
22069
+ const url2 = new URL(request.url);
22070
+ let changed = false;
22071
+ for (const [name, key] of [
22072
+ ["x-opencode-directory", "directory"],
22073
+ ["x-opencode-workspace", "workspace"]
22074
+ ]) {
22075
+ const value = pick2(request.headers.get(name), key === "directory" ? values.directory : values.workspace, key === "directory" ? encodeURIComponent : void 0);
22076
+ if (!value)
22077
+ continue;
22078
+ for (const query of url2.pathname.startsWith("/api/") ? [key, `location[${key}]`] : [key]) {
22079
+ if (!url2.searchParams.has(query)) {
22080
+ url2.searchParams.set(query, value);
22004
22081
  }
22005
22082
  }
22083
+ changed = true;
22006
22084
  }
22007
- let directory = path4.dirname(selected);
22008
- for (let depth = 0; depth < 8; depth++) {
22009
- const metadata = await readFile(path4.join(directory, "package.json"), "utf8").then((text) => JSON.parse(text)).catch(() => null);
22010
- if (metadata?.name && packages.includes(metadata.name)) {
22011
- const name = metadata.name;
22012
- const currentVersion = installationVersion(metadata.version);
22013
- const segments = name.split("/");
22014
- let modules = directory;
22015
- for (let index = 0; index < segments.length; index++)
22016
- modules = path4.dirname(modules);
22017
- const prefix = process.platform === "win32" ? path4.dirname(modules) : path4.dirname(path4.dirname(modules));
22018
- const globalRoot = process.platform === "win32" ? path4.join(prefix, "node_modules") : path4.join(prefix, "lib", "node_modules");
22019
- const env = withNodeRuntimeOnPath(environment);
22020
- const npm = resolveHarnessExecutable({ id: "npm", command: "npm", installRoots: { posix: [], windows: [] } }, { environment: env });
22021
- let globalInstall = modules === globalRoot;
22022
- if (process.platform === "win32") {
22023
- const project = (await Promise.all(["package.json", "package-lock.json", "npm-shrinkwrap.json"].map((file2) => readFile(path4.join(prefix, file2), "utf8").then(() => true, (error51) => error51.code !== "ENOENT")))).some(Boolean);
22024
- const bins = typeof metadata.bin === "string" ? { [name.split("/").at(-1) ?? name]: metadata.bin } : metadata.bin ?? {};
22025
- const launchers = await Promise.all(Object.entries(bins).map(async ([bin, entry]) => {
22026
- if (path4.basename(bin) !== bin || entry.includes(".."))
22027
- return false;
22028
- const target = await realpath(path4.join(directory, entry)).catch(() => "");
22029
- if (target.toLowerCase() !== selected.toLowerCase())
22030
- return false;
22031
- const shim = await readFile(path4.join(prefix, `${bin}.cmd`), "utf8").catch(() => "");
22032
- return referencesNpmBin(shim, name, entry);
22033
- }));
22034
- globalInstall = globalInstall && !project && launchers.some(Boolean);
22035
- }
22036
- const canUpdate = globalInstall && !!npm;
22037
- return {
22038
- prefix,
22039
- currentVersion,
22040
- canUpdate,
22041
- latest: async () => {
22042
- const data = JSON.parse(await fetchInstallationText(`https://registry.npmjs.org/${encodeURIComponent(name)}/latest`));
22043
- return installationVersion(data.version);
22044
- },
22045
- update: async (version2) => {
22046
- if (!canUpdate || !npm)
22047
- throw new Error("Use the original package manager to update this installation");
22048
- await runInstallationCommand(npm.executable, ["install", "--global", "--prefix", prefix, `${name}@${installationVersion(version2)}`], env, 3e5);
22049
- }
22050
- };
22051
- }
22052
- const parent = path4.dirname(directory);
22053
- if (parent === directory)
22054
- break;
22055
- directory = parent;
22085
+ if (!changed)
22086
+ return request;
22087
+ const next = new Request(url2, request);
22088
+ next.headers.delete("x-opencode-directory");
22089
+ next.headers.delete("x-opencode-workspace");
22090
+ return next;
22091
+ }
22092
+ function createOpencodeClient(config2) {
22093
+ if (!config2?.fetch) {
22094
+ const customFetch = (req) => {
22095
+ req.timeout = false;
22096
+ return fetch(req);
22097
+ };
22098
+ config2 = {
22099
+ ...config2,
22100
+ fetch: customFetch
22101
+ };
22056
22102
  }
22057
- return null;
22103
+ if (config2?.directory) {
22104
+ config2.headers = {
22105
+ ...config2.headers,
22106
+ "x-opencode-directory": encodeURIComponent(config2.directory)
22107
+ };
22108
+ }
22109
+ if (config2?.experimental_workspaceID) {
22110
+ config2.headers = {
22111
+ ...config2.headers,
22112
+ "x-opencode-workspace": config2.experimental_workspaceID
22113
+ };
22114
+ }
22115
+ const client2 = createClient(config2);
22116
+ client2.interceptors.request.use((request) => rewrite(request, {
22117
+ directory: config2?.directory,
22118
+ workspace: config2?.experimental_workspaceID
22119
+ }));
22120
+ client2.interceptors.response.use((response) => {
22121
+ const contentType = response.headers.get("content-type");
22122
+ if (contentType === "text/html")
22123
+ throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");
22124
+ return response;
22125
+ });
22126
+ client2.interceptors.error.use(wrapClientError);
22127
+ return new OpencodeClient({ client: client2 });
22058
22128
  }
22059
22129
 
22060
22130
  // dist/command.js
22131
+ import path5 from "node:path";
22061
22132
  var OpenCodeExecutableError = class extends Error {
22062
22133
  code = "OPENCODE_NOT_FOUND";
22063
22134
  constructor(message = "OpenCode CLI is not installed") {
@@ -22186,7 +22257,7 @@ function signalProcessTree(child, signal) {
22186
22257
  }
22187
22258
  }
22188
22259
  function safeOpenCodeServerCwd(environment) {
22189
- const candidates = [environment.USERPROFILE, environment.HOME, homedir2(), tmpdir()];
22260
+ const candidates = [environment.USERPROFILE, environment.HOME, homedir2(), tmpdir2()];
22190
22261
  for (const candidate of candidates) {
22191
22262
  if (!candidate || !path6.isAbsolute(candidate))
22192
22263
  continue;
@@ -27374,7 +27445,10 @@ function createOpenCodeInstallation(environment, command) {
27374
27445
  latestVersion,
27375
27446
  updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
27376
27447
  canUpdate,
27377
- ...!canUpdate ? { message: "Use the original package manager to update this OpenCode installation." } : {}
27448
+ ...!canUpdate ? {
27449
+ messageCode: "original-installer",
27450
+ message: "Use the original package manager to update this OpenCode installation."
27451
+ } : {}
27378
27452
  };
27379
27453
  },
27380
27454
  async update(state) {
@@ -27390,7 +27464,10 @@ function createHarnessAdapter(context) {
27390
27464
  return Object.assign(new OpenCodeAdapter2({
27391
27465
  ...environment[OPENCODE_COMMAND_ENV] ? { command: environment[OPENCODE_COMMAND_ENV] } : {},
27392
27466
  environment
27393
- }), { installation: createOpenCodeInstallation(environment, environment[OPENCODE_COMMAND_ENV]) });
27467
+ }), {
27468
+ installation: createOpenCodeInstallation(environment, environment[OPENCODE_COMMAND_ENV]),
27469
+ install: createHarnessInstaller(environment, { npm: "opencode-ai" })
27470
+ });
27394
27471
  }
27395
27472
  export {
27396
27473
  OPENCODE_COMMAND_ENV,