@liberseek/boft-cli-linux-x64 0.7.6 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +69 -53
- package/app/console-web.js +563 -96
- package/app/desktop-controller.mjs +68 -20
- package/app/host-runtime.mjs +523 -124
- package/app/plugins/antigravity/plugin.mjs +804 -716
- package/app/plugins/claude-code/plugin.mjs +275 -115
- package/app/plugins/codebuddy/plugin.mjs +733 -662
- package/app/plugins/cursor-cli/plugin.mjs +446 -357
- package/app/plugins/deepseek-harness/plugin.mjs +25471 -26253
- package/app/plugins/grok/plugin.mjs +1398 -1309
- package/app/plugins/hermes/plugin.mjs +524 -435
- package/app/plugins/kimi-code/plugin.mjs +745 -671
- package/app/plugins/kiro-cli/plugin.mjs +15822 -15731
- package/app/plugins/muse/plugin.mjs +69 -53
- package/app/plugins/omp/plugin.mjs +1639 -1547
- package/app/plugins/opencode/plugin.mjs +736 -665
- package/app/plugins/pi/plugin.mjs +15771 -15663
- package/app/plugins/qoder/plugin.mjs +479 -390
- package/app/plugins/qoder-cn/plugin.mjs +145 -54
- package/app/plugins/workbuddy/plugin.mjs +69 -53
- package/app/renderer-extension.js +695 -212
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/package.json +2 -2
|
@@ -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,
|
|
@@ -15187,69 +15727,27 @@ var codexThreadOwnershipSchema = external_exports.object({
|
|
|
15187
15727
|
}).strict();
|
|
15188
15728
|
var externalThreadOwnershipSchema = external_exports.object({
|
|
15189
15729
|
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"]
|
|
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,7 +15774,7 @@ 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),
|
|
@@ -16223,7 +16721,7 @@ import { randomBytes } from "node:crypto";
|
|
|
16223
16721
|
import { spawn, spawnSync } from "node:child_process";
|
|
16224
16722
|
import fs2 from "node:fs";
|
|
16225
16723
|
import { createServer } from "node:net";
|
|
16226
|
-
import { homedir as homedir2, tmpdir } from "node:os";
|
|
16724
|
+
import { homedir as homedir2, tmpdir as tmpdir2 } from "node:os";
|
|
16227
16725
|
import path6 from "node:path";
|
|
16228
16726
|
|
|
16229
16727
|
// ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
|
|
@@ -21446,618 +21944,188 @@ var OpencodeClient = class _OpencodeClient extends HeyApiClient {
|
|
|
21446
21944
|
return this._worktree ??= new Worktree({ client: this.client });
|
|
21447
21945
|
}
|
|
21448
21946
|
_find;
|
|
21449
|
-
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 };
|
|
21947
|
+
get find() {
|
|
21948
|
+
return this._find ??= new Find({ client: this.client });
|
|
21684
21949
|
}
|
|
21685
|
-
|
|
21686
|
-
|
|
21687
|
-
|
|
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);
|
|
21950
|
+
_file;
|
|
21951
|
+
get file() {
|
|
21952
|
+
return this._file ??= new File2({ client: this.client });
|
|
21704
21953
|
}
|
|
21705
|
-
|
|
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;
|
|
21954
|
+
_instance;
|
|
21955
|
+
get instance() {
|
|
21956
|
+
return this._instance ??= new Instance({ client: this.client });
|
|
21735
21957
|
}
|
|
21736
|
-
|
|
21737
|
-
|
|
21738
|
-
|
|
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");
|
|
21958
|
+
_path;
|
|
21959
|
+
get path() {
|
|
21960
|
+
return this._path ??= new Path({ client: this.client });
|
|
21744
21961
|
}
|
|
21745
|
-
|
|
21746
|
-
|
|
21747
|
-
|
|
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
|
-
}
|
|
21962
|
+
_vcs;
|
|
21963
|
+
get vcs() {
|
|
21964
|
+
return this._vcs ??= new Vcs({ client: this.client });
|
|
21765
21965
|
}
|
|
21766
|
-
|
|
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);
|
|
21966
|
+
_command;
|
|
21967
|
+
get command() {
|
|
21968
|
+
return this._command ??= new Command({ client: this.client });
|
|
21824
21969
|
}
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
|
|
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" }];
|
|
21970
|
+
_lsp;
|
|
21971
|
+
get lsp() {
|
|
21972
|
+
return this._lsp ??= new Lsp({ client: this.client });
|
|
21834
21973
|
}
|
|
21835
|
-
|
|
21836
|
-
|
|
21837
|
-
|
|
21838
|
-
for (const extension of extensions) {
|
|
21839
|
-
candidates.push({
|
|
21840
|
-
candidate: pathFlavor.join(directory, command + extension),
|
|
21841
|
-
source: "path"
|
|
21842
|
-
});
|
|
21843
|
-
}
|
|
21974
|
+
_formatter;
|
|
21975
|
+
get formatter() {
|
|
21976
|
+
return this._formatter ??= new Formatter({ client: this.client });
|
|
21844
21977
|
}
|
|
21845
|
-
|
|
21846
|
-
|
|
21847
|
-
|
|
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
|
-
}
|
|
21978
|
+
_mcp;
|
|
21979
|
+
get mcp() {
|
|
21980
|
+
return this._mcp ??= new Mcp({ client: this.client });
|
|
21855
21981
|
}
|
|
21856
|
-
|
|
21857
|
-
|
|
21858
|
-
|
|
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 };
|
|
21982
|
+
_project;
|
|
21983
|
+
get project() {
|
|
21984
|
+
return this._project ??= new Project({ client: this.client });
|
|
21867
21985
|
}
|
|
21868
|
-
|
|
21869
|
-
|
|
21870
|
-
|
|
21871
|
-
|
|
21872
|
-
|
|
21873
|
-
|
|
21874
|
-
|
|
21875
|
-
|
|
21876
|
-
|
|
21877
|
-
|
|
21878
|
-
|
|
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);
|
|
21986
|
+
_pty;
|
|
21987
|
+
get pty() {
|
|
21988
|
+
return this._pty ??= new Pty({ client: this.client });
|
|
21989
|
+
}
|
|
21990
|
+
_question;
|
|
21991
|
+
get question() {
|
|
21992
|
+
return this._question ??= new Question({ client: this.client });
|
|
21993
|
+
}
|
|
21994
|
+
_permission;
|
|
21995
|
+
get permission() {
|
|
21996
|
+
return this._permission ??= new Permission({ client: this.client });
|
|
21912
21997
|
}
|
|
21913
|
-
|
|
21914
|
-
|
|
21915
|
-
|
|
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;
|
|
21998
|
+
_provider;
|
|
21999
|
+
get provider() {
|
|
22000
|
+
return this._provider ??= new Provider({ client: this.client });
|
|
21934
22001
|
}
|
|
21935
|
-
|
|
21936
|
-
|
|
21937
|
-
|
|
21938
|
-
|
|
21939
|
-
|
|
21940
|
-
|
|
21941
|
-
|
|
22002
|
+
_session;
|
|
22003
|
+
get session() {
|
|
22004
|
+
return this._session ??= new Session2({ client: this.client });
|
|
22005
|
+
}
|
|
22006
|
+
_part;
|
|
22007
|
+
get part() {
|
|
22008
|
+
return this._part ??= new Part({ client: this.client });
|
|
22009
|
+
}
|
|
22010
|
+
_sync;
|
|
22011
|
+
get sync() {
|
|
22012
|
+
return this._sync ??= new Sync({ client: this.client });
|
|
22013
|
+
}
|
|
22014
|
+
_tui;
|
|
22015
|
+
get tui() {
|
|
22016
|
+
return this._tui ??= new Tui({ client: this.client });
|
|
22017
|
+
}
|
|
22018
|
+
_v2;
|
|
22019
|
+
get v2() {
|
|
22020
|
+
return this._v2 ??= new V2({ client: this.client });
|
|
22021
|
+
}
|
|
22022
|
+
};
|
|
22023
|
+
|
|
22024
|
+
// ../../../node_modules/@opencode-ai/sdk/dist/error-interceptor.js
|
|
22025
|
+
function wrapClientError(error51, response, request, opts) {
|
|
22026
|
+
if (!opts?.throwOnError)
|
|
22027
|
+
return error51;
|
|
22028
|
+
if (error51 instanceof Error)
|
|
22029
|
+
return error51;
|
|
22030
|
+
if (typeof error51 === "object" && error51 !== null && Object.keys(error51).length > 0) {
|
|
22031
|
+
const obj = error51;
|
|
22032
|
+
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);
|
|
22033
|
+
return new Error(message, { cause: { body: error51, status: response?.status } });
|
|
22034
|
+
}
|
|
22035
|
+
if (typeof error51 === "string" && error51.length > 0) {
|
|
22036
|
+
return new Error(error51, { cause: { body: error51, status: response?.status } });
|
|
22037
|
+
}
|
|
22038
|
+
const reason = response ? "(empty response body)" : "network error (no response)";
|
|
22039
|
+
return new Error(`opencode server ${describe3(request, response)}: ${reason}`, {
|
|
22040
|
+
cause: { body: error51, status: response?.status }
|
|
21942
22041
|
});
|
|
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
22042
|
}
|
|
21965
|
-
|
|
21966
|
-
const
|
|
21967
|
-
|
|
21968
|
-
|
|
21969
|
-
|
|
21970
|
-
|
|
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
|
-
}
|
|
22043
|
+
function describe3(request, response) {
|
|
22044
|
+
const method = request?.method ?? "?";
|
|
22045
|
+
const url2 = request?.url ?? "?";
|
|
22046
|
+
const status = response?.status;
|
|
22047
|
+
const statusText = response?.statusText;
|
|
22048
|
+
return `${method} ${url2}${status ? " → " + status : ""}${statusText ? " " + statusText : ""}`;
|
|
21979
22049
|
}
|
|
21980
22050
|
|
|
21981
|
-
//
|
|
21982
|
-
|
|
21983
|
-
|
|
21984
|
-
|
|
21985
|
-
if (
|
|
21986
|
-
return
|
|
21987
|
-
|
|
21988
|
-
|
|
21989
|
-
|
|
22051
|
+
// ../../../node_modules/@opencode-ai/sdk/dist/v2/client.js
|
|
22052
|
+
function pick2(value, fallback, encode3) {
|
|
22053
|
+
if (!value)
|
|
22054
|
+
return;
|
|
22055
|
+
if (!fallback)
|
|
22056
|
+
return value;
|
|
22057
|
+
if (value === fallback)
|
|
22058
|
+
return fallback;
|
|
22059
|
+
if (encode3 && value === encode3(fallback))
|
|
22060
|
+
return fallback;
|
|
22061
|
+
return value;
|
|
21990
22062
|
}
|
|
21991
|
-
|
|
21992
|
-
|
|
21993
|
-
|
|
21994
|
-
|
|
21995
|
-
|
|
21996
|
-
|
|
21997
|
-
|
|
21998
|
-
|
|
21999
|
-
|
|
22000
|
-
|
|
22001
|
-
|
|
22002
|
-
|
|
22003
|
-
|
|
22063
|
+
function rewrite(request, values) {
|
|
22064
|
+
if (request.method !== "GET" && request.method !== "HEAD")
|
|
22065
|
+
return request;
|
|
22066
|
+
const url2 = new URL(request.url);
|
|
22067
|
+
let changed = false;
|
|
22068
|
+
for (const [name, key] of [
|
|
22069
|
+
["x-opencode-directory", "directory"],
|
|
22070
|
+
["x-opencode-workspace", "workspace"]
|
|
22071
|
+
]) {
|
|
22072
|
+
const value = pick2(request.headers.get(name), key === "directory" ? values.directory : values.workspace, key === "directory" ? encodeURIComponent : void 0);
|
|
22073
|
+
if (!value)
|
|
22074
|
+
continue;
|
|
22075
|
+
for (const query of url2.pathname.startsWith("/api/") ? [key, `location[${key}]`] : [key]) {
|
|
22076
|
+
if (!url2.searchParams.has(query)) {
|
|
22077
|
+
url2.searchParams.set(query, value);
|
|
22004
22078
|
}
|
|
22005
22079
|
}
|
|
22080
|
+
changed = true;
|
|
22006
22081
|
}
|
|
22007
|
-
|
|
22008
|
-
|
|
22009
|
-
|
|
22010
|
-
|
|
22011
|
-
|
|
22012
|
-
|
|
22013
|
-
|
|
22014
|
-
|
|
22015
|
-
|
|
22016
|
-
|
|
22017
|
-
|
|
22018
|
-
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
|
|
22022
|
-
|
|
22023
|
-
|
|
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;
|
|
22082
|
+
if (!changed)
|
|
22083
|
+
return request;
|
|
22084
|
+
const next = new Request(url2, request);
|
|
22085
|
+
next.headers.delete("x-opencode-directory");
|
|
22086
|
+
next.headers.delete("x-opencode-workspace");
|
|
22087
|
+
return next;
|
|
22088
|
+
}
|
|
22089
|
+
function createOpencodeClient(config2) {
|
|
22090
|
+
if (!config2?.fetch) {
|
|
22091
|
+
const customFetch = (req) => {
|
|
22092
|
+
req.timeout = false;
|
|
22093
|
+
return fetch(req);
|
|
22094
|
+
};
|
|
22095
|
+
config2 = {
|
|
22096
|
+
...config2,
|
|
22097
|
+
fetch: customFetch
|
|
22098
|
+
};
|
|
22056
22099
|
}
|
|
22057
|
-
|
|
22100
|
+
if (config2?.directory) {
|
|
22101
|
+
config2.headers = {
|
|
22102
|
+
...config2.headers,
|
|
22103
|
+
"x-opencode-directory": encodeURIComponent(config2.directory)
|
|
22104
|
+
};
|
|
22105
|
+
}
|
|
22106
|
+
if (config2?.experimental_workspaceID) {
|
|
22107
|
+
config2.headers = {
|
|
22108
|
+
...config2.headers,
|
|
22109
|
+
"x-opencode-workspace": config2.experimental_workspaceID
|
|
22110
|
+
};
|
|
22111
|
+
}
|
|
22112
|
+
const client2 = createClient(config2);
|
|
22113
|
+
client2.interceptors.request.use((request) => rewrite(request, {
|
|
22114
|
+
directory: config2?.directory,
|
|
22115
|
+
workspace: config2?.experimental_workspaceID
|
|
22116
|
+
}));
|
|
22117
|
+
client2.interceptors.response.use((response) => {
|
|
22118
|
+
const contentType = response.headers.get("content-type");
|
|
22119
|
+
if (contentType === "text/html")
|
|
22120
|
+
throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");
|
|
22121
|
+
return response;
|
|
22122
|
+
});
|
|
22123
|
+
client2.interceptors.error.use(wrapClientError);
|
|
22124
|
+
return new OpencodeClient({ client: client2 });
|
|
22058
22125
|
}
|
|
22059
22126
|
|
|
22060
22127
|
// dist/command.js
|
|
22128
|
+
import path5 from "node:path";
|
|
22061
22129
|
var OpenCodeExecutableError = class extends Error {
|
|
22062
22130
|
code = "OPENCODE_NOT_FOUND";
|
|
22063
22131
|
constructor(message = "OpenCode CLI is not installed") {
|
|
@@ -22186,7 +22254,7 @@ function signalProcessTree(child, signal) {
|
|
|
22186
22254
|
}
|
|
22187
22255
|
}
|
|
22188
22256
|
function safeOpenCodeServerCwd(environment) {
|
|
22189
|
-
const candidates = [environment.USERPROFILE, environment.HOME, homedir2(),
|
|
22257
|
+
const candidates = [environment.USERPROFILE, environment.HOME, homedir2(), tmpdir2()];
|
|
22190
22258
|
for (const candidate of candidates) {
|
|
22191
22259
|
if (!candidate || !path6.isAbsolute(candidate))
|
|
22192
22260
|
continue;
|
|
@@ -27390,7 +27458,10 @@ function createHarnessAdapter(context) {
|
|
|
27390
27458
|
return Object.assign(new OpenCodeAdapter2({
|
|
27391
27459
|
...environment[OPENCODE_COMMAND_ENV] ? { command: environment[OPENCODE_COMMAND_ENV] } : {},
|
|
27392
27460
|
environment
|
|
27393
|
-
}), {
|
|
27461
|
+
}), {
|
|
27462
|
+
installation: createOpenCodeInstallation(environment, environment[OPENCODE_COMMAND_ENV]),
|
|
27463
|
+
install: createHarnessInstaller(environment, { npm: "opencode-ai" })
|
|
27464
|
+
});
|
|
27394
27465
|
}
|
|
27395
27466
|
export {
|
|
27396
27467
|
OPENCODE_COMMAND_ENV,
|