@liberseek/boft-cli-linux-x64 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +17950 -0
- package/app/console-web.js +27484 -0
- package/app/desktop-controller.mjs +221 -33
- package/app/host-runtime.mjs +3590 -1251
- package/app/plugins/antigravity/plugin.mjs +726 -357
- package/app/plugins/claude-code/plugin.mjs +3067 -2208
- package/app/plugins/codebuddy/plugin.mjs +798 -386
- package/app/plugins/cursor-cli/manifest.json +1 -1
- package/app/plugins/cursor-cli/plugin.mjs +1230 -555
- package/app/plugins/deepseek-harness/plugin.mjs +4761 -4967
- package/app/plugins/grok/plugin.mjs +670 -361
- package/app/plugins/hermes/plugin.mjs +764 -441
- package/app/plugins/kimi-code/plugin.mjs +1095 -428
- package/app/plugins/kiro-cli/plugin.mjs +603 -332
- package/app/plugins/muse/plugin.mjs +189 -58
- package/app/plugins/omp/plugin.mjs +689 -334
- package/app/plugins/opencode/plugin.mjs +946 -478
- package/app/plugins/pi/plugin.mjs +1325 -587
- package/app/plugins/qoder/plugin.mjs +756 -308
- package/app/plugins/qoder-cn/plugin.mjs +555 -99
- package/app/plugins/workbuddy/plugin.mjs +192 -58
- package/app/renderer-extension.js +3703 -1703
- package/bin/boft +0 -0
- package/libexec/boft-shim +0 -0
- package/libexec/boft-updater +0 -0
- package/package.json +2 -2
|
@@ -5,10 +5,492 @@ 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";
|
|
11
|
-
import
|
|
493
|
+
import path8 from "node:path";
|
|
12
494
|
|
|
13
495
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
14
496
|
var external_exports = {};
|
|
@@ -776,10 +1258,10 @@ function mergeDefs(...defs) {
|
|
|
776
1258
|
function cloneDef(schema) {
|
|
777
1259
|
return mergeDefs(schema._zod.def);
|
|
778
1260
|
}
|
|
779
|
-
function getElementAtPath(obj,
|
|
780
|
-
if (!
|
|
1261
|
+
function getElementAtPath(obj, path12) {
|
|
1262
|
+
if (!path12)
|
|
781
1263
|
return obj;
|
|
782
|
-
return
|
|
1264
|
+
return path12.reduce((acc, key) => acc?.[key], obj);
|
|
783
1265
|
}
|
|
784
1266
|
function promiseAllObject(promisesObj) {
|
|
785
1267
|
const keys = Object.keys(promisesObj);
|
|
@@ -1188,11 +1670,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
1188
1670
|
}
|
|
1189
1671
|
return false;
|
|
1190
1672
|
}
|
|
1191
|
-
function prefixIssues(
|
|
1673
|
+
function prefixIssues(path12, issues) {
|
|
1192
1674
|
return issues.map((iss) => {
|
|
1193
1675
|
var _a3;
|
|
1194
1676
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
1195
|
-
iss.path.unshift(
|
|
1677
|
+
iss.path.unshift(path12);
|
|
1196
1678
|
return iss;
|
|
1197
1679
|
});
|
|
1198
1680
|
}
|
|
@@ -1339,16 +1821,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1339
1821
|
}
|
|
1340
1822
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
1341
1823
|
const fieldErrors = { _errors: [] };
|
|
1342
|
-
const processError = (error52,
|
|
1824
|
+
const processError = (error52, path12 = []) => {
|
|
1343
1825
|
for (const issue2 of error52.issues) {
|
|
1344
1826
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1345
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1827
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
1346
1828
|
} else if (issue2.code === "invalid_key") {
|
|
1347
|
-
processError({ issues: issue2.issues }, [...
|
|
1829
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1348
1830
|
} else if (issue2.code === "invalid_element") {
|
|
1349
|
-
processError({ issues: issue2.issues }, [...
|
|
1831
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1350
1832
|
} else {
|
|
1351
|
-
const fullpath = [...
|
|
1833
|
+
const fullpath = [...path12, ...issue2.path];
|
|
1352
1834
|
if (fullpath.length === 0) {
|
|
1353
1835
|
fieldErrors._errors.push(mapper(issue2));
|
|
1354
1836
|
} else {
|
|
@@ -1375,17 +1857,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1375
1857
|
}
|
|
1376
1858
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
1377
1859
|
const result = { errors: [] };
|
|
1378
|
-
const processError = (error52,
|
|
1860
|
+
const processError = (error52, path12 = []) => {
|
|
1379
1861
|
var _a3, _b;
|
|
1380
1862
|
for (const issue2 of error52.issues) {
|
|
1381
1863
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1382
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1864
|
+
issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
|
|
1383
1865
|
} else if (issue2.code === "invalid_key") {
|
|
1384
|
-
processError({ issues: issue2.issues }, [...
|
|
1866
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1385
1867
|
} else if (issue2.code === "invalid_element") {
|
|
1386
|
-
processError({ issues: issue2.issues }, [...
|
|
1868
|
+
processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
|
|
1387
1869
|
} else {
|
|
1388
|
-
const fullpath = [...
|
|
1870
|
+
const fullpath = [...path12, ...issue2.path];
|
|
1389
1871
|
if (fullpath.length === 0) {
|
|
1390
1872
|
result.errors.push(mapper(issue2));
|
|
1391
1873
|
continue;
|
|
@@ -1417,8 +1899,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
1417
1899
|
}
|
|
1418
1900
|
function toDotPath(_path) {
|
|
1419
1901
|
const segs = [];
|
|
1420
|
-
const
|
|
1421
|
-
for (const seg of
|
|
1902
|
+
const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1903
|
+
for (const seg of path12) {
|
|
1422
1904
|
if (typeof seg === "number")
|
|
1423
1905
|
segs.push(`[${seg}]`);
|
|
1424
1906
|
else if (typeof seg === "symbol")
|
|
@@ -14110,13 +14592,13 @@ function resolveRef(ref, ctx) {
|
|
|
14110
14592
|
if (!ref.startsWith("#")) {
|
|
14111
14593
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
14112
14594
|
}
|
|
14113
|
-
const
|
|
14114
|
-
if (
|
|
14595
|
+
const path12 = ref.slice(1).split("/").filter(Boolean);
|
|
14596
|
+
if (path12.length === 0) {
|
|
14115
14597
|
return ctx.rootSchema;
|
|
14116
14598
|
}
|
|
14117
14599
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
14118
|
-
if (
|
|
14119
|
-
const key =
|
|
14600
|
+
if (path12[0] === defsKey) {
|
|
14601
|
+
const key = path12[1];
|
|
14120
14602
|
if (!key || !ctx.defs[key]) {
|
|
14121
14603
|
throw new Error(`Reference not found: ${ref}`);
|
|
14122
14604
|
}
|
|
@@ -14579,6 +15061,123 @@ var credentialImportsParamsSchema = external_exports.object({
|
|
|
14579
15061
|
request: credentialImportsRequestSchema
|
|
14580
15062
|
}).strict();
|
|
14581
15063
|
|
|
15064
|
+
// ../../shared-contracts/dist/harness-display-settings.js
|
|
15065
|
+
var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
|
|
15066
|
+
agent: external_exports.string().min(1).max(128),
|
|
15067
|
+
section: external_exports.enum(["main", "more", "auto"])
|
|
15068
|
+
})).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
|
|
15069
|
+
var harnessDisplaySettingsSchema = external_exports.strictObject({
|
|
15070
|
+
entries: harnessDisplayEntriesSchema.nullable()
|
|
15071
|
+
});
|
|
15072
|
+
var harnessDisplayGetSchema = external_exports.strictObject({});
|
|
15073
|
+
var harnessDisplaySetSchema = external_exports.strictObject({
|
|
15074
|
+
entries: harnessDisplayEntriesSchema,
|
|
15075
|
+
/** Import legacy Desktop preferences only if no shared settings exist yet. */
|
|
15076
|
+
initializeOnly: external_exports.boolean().optional()
|
|
15077
|
+
});
|
|
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
|
+
|
|
15144
|
+
// ../../shared-contracts/dist/console.js
|
|
15145
|
+
var consoleAnnouncementSchema = external_exports.strictObject({
|
|
15146
|
+
title: external_exports.string().trim().min(1).max(200),
|
|
15147
|
+
type: external_exports.enum(["info", "warning", "danger"]),
|
|
15148
|
+
body: external_exports.string().trim().min(1).max(16 * 1024)
|
|
15149
|
+
});
|
|
15150
|
+
var consoleOpenParamsSchema = external_exports.strictObject({});
|
|
15151
|
+
var consoleOpenResultSchema = external_exports.strictObject({
|
|
15152
|
+
/** The console address. */
|
|
15153
|
+
url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
|
|
15154
|
+
});
|
|
15155
|
+
var CONSOLE_HOST_METHODS = Object.freeze([
|
|
15156
|
+
"codexhost/harness/plugins/list",
|
|
15157
|
+
"codexhost/harness/display-settings/get",
|
|
15158
|
+
"codexhost/harness/display-settings/set",
|
|
15159
|
+
"codexhost/harness/inspect",
|
|
15160
|
+
"codexhost/harness/installation",
|
|
15161
|
+
"codexhost/harness/launch-settings/get",
|
|
15162
|
+
"codexhost/harness/launch-settings/set",
|
|
15163
|
+
HARNESS_LONG_CONTEXT_GET_METHOD,
|
|
15164
|
+
HARNESS_LONG_CONTEXT_SET_METHOD,
|
|
15165
|
+
"codexhost/harness/web-ui/open",
|
|
15166
|
+
"codexhost/harness/accounts/sources",
|
|
15167
|
+
"codexhost/harness/accounts/list",
|
|
15168
|
+
"codexhost/harness/accounts/inspect",
|
|
15169
|
+
"codexhost/harness/credential-imports",
|
|
15170
|
+
"codexhost/harness/session-import/sources",
|
|
15171
|
+
"codexhost/harness/session-import/list",
|
|
15172
|
+
"codexhost/harness/session-import/import",
|
|
15173
|
+
"codexhost/account/list",
|
|
15174
|
+
"codexhost/account/refresh",
|
|
15175
|
+
"codexhost/account/usage/inspect",
|
|
15176
|
+
"codexhost/update/check",
|
|
15177
|
+
"codexhost/update/start",
|
|
15178
|
+
"codexhost/update/status"
|
|
15179
|
+
]);
|
|
15180
|
+
|
|
14582
15181
|
// ../../shared-contracts/dist/version.js
|
|
14583
15182
|
var WORKSPACE_CONTRACT_VERSION = 1;
|
|
14584
15183
|
|
|
@@ -14622,15 +15221,11 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
|
|
|
14622
15221
|
inactiveMs: external_exports.number().nonnegative()
|
|
14623
15222
|
}));
|
|
14624
15223
|
|
|
14625
|
-
// ../../shared-contracts/dist/
|
|
14626
|
-
var
|
|
14627
|
-
|
|
15224
|
+
// ../../shared-contracts/dist/manual-compaction.js
|
|
15225
|
+
var threadManualCompactionStartedSchema = external_exports.strictObject({
|
|
15226
|
+
threadId: hostThreadIdSchema,
|
|
15227
|
+
turnId: hostTurnIdSchema
|
|
14628
15228
|
});
|
|
14629
|
-
var harnessIdSchema = opaqueIdSchema.brand();
|
|
14630
|
-
var hostThreadIdSchema = opaqueIdSchema.brand();
|
|
14631
|
-
var hostTurnIdSchema = opaqueIdSchema.brand();
|
|
14632
|
-
var hostItemIdSchema = opaqueIdSchema.brand();
|
|
14633
|
-
var hostInteractionIdSchema = opaqueIdSchema.brand();
|
|
14634
15229
|
|
|
14635
15230
|
// ../../shared-contracts/dist/thread-usage.js
|
|
14636
15231
|
var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
|
|
@@ -14692,6 +15287,10 @@ var threadUsageSnapshotSchema = external_exports.object({
|
|
|
14692
15287
|
var usagePercentSchema = external_exports.number().finite().min(0).max(100);
|
|
14693
15288
|
var accountCreditsProductUsageSchema = external_exports.object({
|
|
14694
15289
|
product: external_exports.string().min(1),
|
|
15290
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
15291
|
+
// Zero is a real empty cap, not an absent field.
|
|
15292
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
15293
|
+
unit: external_exports.string().min(1).max(32).optional(),
|
|
14695
15294
|
usagePercent: usagePercentSchema,
|
|
14696
15295
|
resetsAt: external_exports.string().min(1).optional()
|
|
14697
15296
|
}).strict();
|
|
@@ -14701,11 +15300,14 @@ var accountResetCreditsSchema = external_exports.object({
|
|
|
14701
15300
|
expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
|
|
14702
15301
|
}).strict();
|
|
14703
15302
|
var accountCreditsSnapshotSchema = external_exports.object({
|
|
15303
|
+
used: external_exports.number().finite().nonnegative().optional(),
|
|
15304
|
+
// Zero is a real empty cap, not an absent field.
|
|
15305
|
+
limit: external_exports.number().finite().nonnegative().optional(),
|
|
15306
|
+
unit: external_exports.string().trim().min(1).max(32).optional(),
|
|
14704
15307
|
/** Native label when the primary limit is scoped to a model or product group. */
|
|
14705
15308
|
label: external_exports.string().min(1).optional(),
|
|
14706
15309
|
usedPercent: usagePercentSchema.optional(),
|
|
14707
15310
|
remaining: external_exports.number().finite().optional(),
|
|
14708
|
-
unit: external_exports.string().trim().min(1).max(32).optional(),
|
|
14709
15311
|
resetsAt: external_exports.string().min(1).optional(),
|
|
14710
15312
|
periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
|
|
14711
15313
|
productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
|
|
@@ -14736,12 +15338,27 @@ var threadUsageInspectionSchema = external_exports.object({
|
|
|
14736
15338
|
}).strict();
|
|
14737
15339
|
|
|
14738
15340
|
// ../../shared-contracts/dist/harness-accounts.js
|
|
14739
|
-
var
|
|
15341
|
+
var accountBalanceSnapshotSchema = external_exports.object({
|
|
15342
|
+
amount: external_exports.number().finite().nonnegative(),
|
|
15343
|
+
/** ISO 4217 code as reported by the Provider, for example `CNY`. */
|
|
15344
|
+
currency: external_exports.string().trim().min(1).max(8),
|
|
15345
|
+
/** Native label when the Harness exposes several Billing Sources. */
|
|
15346
|
+
label: external_exports.string().trim().min(1).max(128).optional()
|
|
15347
|
+
}).strict();
|
|
15348
|
+
var harnessAccountSnapshotObject = external_exports.object({
|
|
14740
15349
|
email: external_exports.string().trim().min(1).max(320).optional(),
|
|
14741
15350
|
label: external_exports.string().trim().min(1).max(256).optional(),
|
|
14742
15351
|
plan: external_exports.string().trim().min(1).max(128).optional(),
|
|
14743
|
-
credits: accountCreditsSnapshotSchema
|
|
15352
|
+
credits: accountCreditsSnapshotSchema.optional(),
|
|
15353
|
+
balance: accountBalanceSnapshotSchema.optional()
|
|
14744
15354
|
}).strict();
|
|
15355
|
+
function requireReportedQuota(schema) {
|
|
15356
|
+
return schema.refine((value) => {
|
|
15357
|
+
const reported = value;
|
|
15358
|
+
return reported.credits !== void 0 || reported.balance !== void 0;
|
|
15359
|
+
}, { message: "Account must report either credits or a balance" });
|
|
15360
|
+
}
|
|
15361
|
+
var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
|
|
14745
15362
|
var harnessAccountIdentityShape = {
|
|
14746
15363
|
harnessId: harnessIdSchema,
|
|
14747
15364
|
harnessName: external_exports.string().trim().min(1).max(128)
|
|
@@ -14752,11 +15369,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
|
|
|
14752
15369
|
var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
|
|
14753
15370
|
var harnessAccountInspectResultSchema = external_exports.object({
|
|
14754
15371
|
...harnessAccountIdentityShape,
|
|
14755
|
-
account: harnessAccountSnapshotSchema.nullable()
|
|
15372
|
+
account: harnessAccountSnapshotSchema.nullable(),
|
|
15373
|
+
/** Every Billing Source from one Harness; `account` remains the first for older clients. */
|
|
15374
|
+
accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
|
|
14756
15375
|
}).strict();
|
|
14757
15376
|
var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
|
|
14758
15377
|
var harnessAccountListResultSchema = external_exports.object({
|
|
14759
|
-
accounts: external_exports.array(
|
|
15378
|
+
accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
|
|
14760
15379
|
}).strict();
|
|
14761
15380
|
|
|
14762
15381
|
// ../../shared-contracts/dist/json-value.js
|
|
@@ -14894,6 +15513,8 @@ var harnessModelSchema = external_exports.object({
|
|
|
14894
15513
|
ref: harnessModelRefSchema,
|
|
14895
15514
|
label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
|
|
14896
15515
|
resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
|
|
15516
|
+
/** Optional opaque selection for this same Model with priority processing enabled. */
|
|
15517
|
+
fastModel: harnessModelRefSchema.optional(),
|
|
14897
15518
|
supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
|
|
14898
15519
|
}).strict();
|
|
14899
15520
|
var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
|
|
@@ -14926,6 +15547,16 @@ var harnessModelCatalogSchema = external_exports.object({
|
|
|
14926
15547
|
});
|
|
14927
15548
|
}
|
|
14928
15549
|
refs.add(model.ref.id);
|
|
15550
|
+
if (model.fastModel) {
|
|
15551
|
+
if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
|
|
15552
|
+
context.addIssue({
|
|
15553
|
+
code: "custom",
|
|
15554
|
+
message: "Fast Model refs must be distinct and unique",
|
|
15555
|
+
path: ["models", index, "fastModel"]
|
|
15556
|
+
});
|
|
15557
|
+
}
|
|
15558
|
+
refs.add(model.fastModel.id);
|
|
15559
|
+
}
|
|
14929
15560
|
const supportedThinkingIds = /* @__PURE__ */ new Set();
|
|
14930
15561
|
for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
|
|
14931
15562
|
if (supportedThinkingIds.has(optionId)) {
|
|
@@ -15048,11 +15679,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
|
|
|
15048
15679
|
thinkingOptionId: harnessThinkingOptionIdSchema
|
|
15049
15680
|
}).strict();
|
|
15050
15681
|
var threadInspectionParamsSchema = external_exports.object({
|
|
15051
|
-
threadId: hostThreadIdSchema
|
|
15682
|
+
threadId: hostThreadIdSchema,
|
|
15683
|
+
includeReferenceCapability: external_exports.boolean().optional()
|
|
15052
15684
|
}).strict();
|
|
15053
15685
|
var codexThreadInspectionSchema = external_exports.object({
|
|
15054
15686
|
owner: external_exports.literal("codex"),
|
|
15055
|
-
locked: external_exports.literal(true)
|
|
15687
|
+
locked: external_exports.literal(true),
|
|
15688
|
+
supportsThreadReferences: external_exports.literal(true).optional()
|
|
15056
15689
|
}).strict();
|
|
15057
15690
|
var externalThreadInspectionSchema = external_exports.object({
|
|
15058
15691
|
owner: external_exports.literal("external"),
|
|
@@ -15090,73 +15723,31 @@ var threadOwnershipListParamsSchema = external_exports.object({
|
|
|
15090
15723
|
});
|
|
15091
15724
|
var codexThreadOwnershipSchema = external_exports.object({
|
|
15092
15725
|
threadId: hostThreadIdSchema,
|
|
15093
|
-
owner: external_exports.literal("codex")
|
|
15094
|
-
}).strict();
|
|
15095
|
-
var externalThreadOwnershipSchema = external_exports.object({
|
|
15096
|
-
threadId: hostThreadIdSchema,
|
|
15097
|
-
owner: external_exports.literal("external"),
|
|
15098
|
-
harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
|
|
15099
|
-
}).strict();
|
|
15100
|
-
var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
|
|
15101
|
-
codexThreadOwnershipSchema,
|
|
15102
|
-
externalThreadOwnershipSchema
|
|
15103
|
-
]);
|
|
15104
|
-
var threadOwnershipListResultSchema = external_exports.object({
|
|
15105
|
-
threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
|
|
15106
|
-
}).strict().superRefine(({ threads }, context) => {
|
|
15107
|
-
const seen = /* @__PURE__ */ new Set();
|
|
15108
|
-
for (const [index, thread] of threads.entries()) {
|
|
15109
|
-
if (seen.has(thread.threadId)) {
|
|
15110
|
-
context.addIssue({
|
|
15111
|
-
code: "custom",
|
|
15112
|
-
message: "Thread ownership-list results must be unique",
|
|
15113
|
-
path: ["threads", index, "threadId"]
|
|
15114
|
-
});
|
|
15115
|
-
}
|
|
15116
|
-
seen.add(thread.threadId);
|
|
15117
|
-
}
|
|
15118
|
-
});
|
|
15119
|
-
|
|
15120
|
-
// ../../shared-contracts/dist/harness-plugins.js
|
|
15121
|
-
var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
|
|
15122
|
-
var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
|
|
15123
|
-
var HARNESS_PLUGIN_LIMIT = 128;
|
|
15124
|
-
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);
|
|
15125
|
-
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");
|
|
15126
|
-
var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
|
|
15127
|
-
var pluginPresentationShape = {
|
|
15128
|
-
id: harnessPluginIdSchema,
|
|
15129
|
-
name: external_exports.string().trim().min(1).max(128),
|
|
15130
|
-
version: external_exports.string().min(1).max(128),
|
|
15131
|
-
/** The factory accepts a persisted local entrypoint through its construction context. */
|
|
15132
|
-
launchCommand: external_exports.literal(true).optional(),
|
|
15133
|
-
links: external_exports.object({
|
|
15134
|
-
documentation: documentationUrlSchema.optional(),
|
|
15135
|
-
installation: documentationUrlSchema.optional()
|
|
15136
|
-
}).strict().optional()
|
|
15137
|
-
};
|
|
15138
|
-
var harnessPluginManifestSchema = external_exports.object({
|
|
15139
|
-
manifestVersion: external_exports.literal(1),
|
|
15140
|
-
...pluginPresentationShape,
|
|
15141
|
-
adapterApiVersion: external_exports.number().int().positive(),
|
|
15142
|
-
entry: relativeResourceSchema,
|
|
15143
|
-
icon: relativeResourceSchema.optional()
|
|
15144
|
-
}).strict();
|
|
15145
|
-
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);
|
|
15146
|
-
var harnessPluginDescriptorSchema = external_exports.object({
|
|
15147
|
-
...pluginPresentationShape,
|
|
15148
|
-
icon: harnessPluginIconSchema.optional()
|
|
15149
|
-
}).strict();
|
|
15150
|
-
var harnessPluginListParamsSchema = external_exports.object({}).strict();
|
|
15151
|
-
var harnessPluginListResultSchema = external_exports.object({
|
|
15152
|
-
plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
|
|
15726
|
+
owner: external_exports.literal("codex")
|
|
15153
15727
|
}).strict();
|
|
15154
|
-
var
|
|
15155
|
-
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15728
|
+
var externalThreadOwnershipSchema = external_exports.object({
|
|
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
|
+
}
|
|
15160
15751
|
});
|
|
15161
15752
|
|
|
15162
15753
|
// ../../shared-contracts/dist/harness-route.js
|
|
@@ -15180,10 +15771,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
|
|
|
15180
15771
|
restartRequired: external_exports.boolean()
|
|
15181
15772
|
}).strict();
|
|
15182
15773
|
|
|
15774
|
+
// ../../shared-contracts/dist/harness-installation.js
|
|
15775
|
+
var harnessInstallationParamsSchema = external_exports.object({
|
|
15776
|
+
harnessId: harnessIdSchema,
|
|
15777
|
+
action: external_exports.enum(["check", "update", "install"])
|
|
15778
|
+
}).strict();
|
|
15779
|
+
var harnessInstallationStateSchema = external_exports.object({
|
|
15780
|
+
currentVersion: external_exports.string().min(1).max(128),
|
|
15781
|
+
latestVersion: external_exports.string().min(1).max(128),
|
|
15782
|
+
updateAvailable: external_exports.boolean(),
|
|
15783
|
+
canUpdate: external_exports.boolean(),
|
|
15784
|
+
message: external_exports.string().max(2048).optional()
|
|
15785
|
+
}).strict();
|
|
15786
|
+
|
|
15183
15787
|
// ../../shared-contracts/dist/codex-accounts.js
|
|
15184
15788
|
var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
|
|
15185
15789
|
var nonBlankTextSchema3 = external_exports.string().trim().min(1);
|
|
15186
15790
|
var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
|
|
15791
|
+
var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
|
|
15792
|
+
function isCodexAccountSiteUrl(value) {
|
|
15793
|
+
return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
|
|
15794
|
+
}
|
|
15795
|
+
var externalUrlOpenParamsSchema = external_exports.object({
|
|
15796
|
+
url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
|
|
15797
|
+
}).strict();
|
|
15798
|
+
var externalUrlOpenResultSchema = external_exports.object({}).strict();
|
|
15187
15799
|
var codexAccountPlanTypeSchema = external_exports.enum([
|
|
15188
15800
|
"free",
|
|
15189
15801
|
"go",
|
|
@@ -15209,7 +15821,8 @@ var codexAccountSchema = external_exports.object({
|
|
|
15209
15821
|
email: external_exports.string().email().max(320).optional(),
|
|
15210
15822
|
planType: codexAccountPlanTypeSchema.optional(),
|
|
15211
15823
|
authKind: codexAccountAuthKindSchema.optional(),
|
|
15212
|
-
authIdentity: nonBlankTextSchema3.max(256).optional()
|
|
15824
|
+
authIdentity: nonBlankTextSchema3.max(256).optional(),
|
|
15825
|
+
siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
|
|
15213
15826
|
}).strict();
|
|
15214
15827
|
var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
|
|
15215
15828
|
var codexAccountListResultSchema = external_exports.object({
|
|
@@ -16107,8 +16720,9 @@ var OpenCodeTransportError = class extends Error {
|
|
|
16107
16720
|
import { randomBytes } from "node:crypto";
|
|
16108
16721
|
import { spawn, spawnSync } from "node:child_process";
|
|
16109
16722
|
import fs2 from "node:fs";
|
|
16110
|
-
import {
|
|
16111
|
-
import
|
|
16723
|
+
import { createServer } from "node:net";
|
|
16724
|
+
import { homedir as homedir2, tmpdir as tmpdir2 } from "node:os";
|
|
16725
|
+
import path6 from "node:path";
|
|
16112
16726
|
|
|
16113
16727
|
// ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/serverSentEvents.gen.js
|
|
16114
16728
|
var createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url: url2, ...options }) => {
|
|
@@ -16334,7 +16948,7 @@ var serializeObjectParam = ({ allowReserved, explode, name, style, value, valueO
|
|
|
16334
16948
|
|
|
16335
16949
|
// ../../../node_modules/@opencode-ai/sdk/dist/v2/gen/core/utils.gen.js
|
|
16336
16950
|
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
16337
|
-
var defaultPathSerializer = ({ path:
|
|
16951
|
+
var defaultPathSerializer = ({ path: path12, url: _url2 }) => {
|
|
16338
16952
|
let url2 = _url2;
|
|
16339
16953
|
const matches = _url2.match(PATH_PARAM_RE);
|
|
16340
16954
|
if (matches) {
|
|
@@ -16353,7 +16967,7 @@ var defaultPathSerializer = ({ path: path9, url: _url2 }) => {
|
|
|
16353
16967
|
name = name.substring(1);
|
|
16354
16968
|
style = "matrix";
|
|
16355
16969
|
}
|
|
16356
|
-
const value =
|
|
16970
|
+
const value = path12[name];
|
|
16357
16971
|
if (value === void 0 || value === null) {
|
|
16358
16972
|
continue;
|
|
16359
16973
|
}
|
|
@@ -16384,11 +16998,11 @@ var defaultPathSerializer = ({ path: path9, url: _url2 }) => {
|
|
|
16384
16998
|
}
|
|
16385
16999
|
return url2;
|
|
16386
17000
|
};
|
|
16387
|
-
var getUrl = ({ baseUrl, path:
|
|
17001
|
+
var getUrl = ({ baseUrl, path: path12, query, querySerializer, url: _url2 }) => {
|
|
16388
17002
|
const pathUrl = _url2.startsWith("/") ? _url2 : `/${_url2}`;
|
|
16389
17003
|
let url2 = (baseUrl ?? "") + pathUrl;
|
|
16390
|
-
if (
|
|
16391
|
-
url2 = defaultPathSerializer({ path:
|
|
17004
|
+
if (path12) {
|
|
17005
|
+
url2 = defaultPathSerializer({ path: path12, url: url2 });
|
|
16392
17006
|
}
|
|
16393
17007
|
let search = query ? querySerializer(query) : "";
|
|
16394
17008
|
if (search.startsWith("?")) {
|
|
@@ -21385,360 +21999,133 @@ var OpencodeClient = class _OpencodeClient extends HeyApiClient {
|
|
|
21385
21999
|
get provider() {
|
|
21386
22000
|
return this._provider ??= new Provider({ client: this.client });
|
|
21387
22001
|
}
|
|
21388
|
-
_session;
|
|
21389
|
-
get session() {
|
|
21390
|
-
return this._session ??= new Session2({ client: this.client });
|
|
21391
|
-
}
|
|
21392
|
-
_part;
|
|
21393
|
-
get part() {
|
|
21394
|
-
return this._part ??= new Part({ client: this.client });
|
|
21395
|
-
}
|
|
21396
|
-
_sync;
|
|
21397
|
-
get sync() {
|
|
21398
|
-
return this._sync ??= new Sync({ client: this.client });
|
|
21399
|
-
}
|
|
21400
|
-
_tui;
|
|
21401
|
-
get tui() {
|
|
21402
|
-
return this._tui ??= new Tui({ client: this.client });
|
|
21403
|
-
}
|
|
21404
|
-
_v2;
|
|
21405
|
-
get v2() {
|
|
21406
|
-
return this._v2 ??= new V2({ client: this.client });
|
|
21407
|
-
}
|
|
21408
|
-
};
|
|
21409
|
-
|
|
21410
|
-
// ../../../node_modules/@opencode-ai/sdk/dist/error-interceptor.js
|
|
21411
|
-
function wrapClientError(error51, response, request, opts) {
|
|
21412
|
-
if (!opts?.throwOnError)
|
|
21413
|
-
return error51;
|
|
21414
|
-
if (error51 instanceof Error)
|
|
21415
|
-
return error51;
|
|
21416
|
-
if (typeof error51 === "object" && error51 !== null && Object.keys(error51).length > 0) {
|
|
21417
|
-
const obj = error51;
|
|
21418
|
-
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);
|
|
21419
|
-
return new Error(message, { cause: { body: error51, status: response?.status } });
|
|
21420
|
-
}
|
|
21421
|
-
if (typeof error51 === "string" && error51.length > 0) {
|
|
21422
|
-
return new Error(error51, { cause: { body: error51, status: response?.status } });
|
|
21423
|
-
}
|
|
21424
|
-
const reason = response ? "(empty response body)" : "network error (no response)";
|
|
21425
|
-
return new Error(`opencode server ${describe3(request, response)}: ${reason}`, {
|
|
21426
|
-
cause: { body: error51, status: response?.status }
|
|
21427
|
-
});
|
|
21428
|
-
}
|
|
21429
|
-
function describe3(request, response) {
|
|
21430
|
-
const method = request?.method ?? "?";
|
|
21431
|
-
const url2 = request?.url ?? "?";
|
|
21432
|
-
const status = response?.status;
|
|
21433
|
-
const statusText = response?.statusText;
|
|
21434
|
-
return `${method} ${url2}${status ? " → " + status : ""}${statusText ? " " + statusText : ""}`;
|
|
21435
|
-
}
|
|
21436
|
-
|
|
21437
|
-
// ../../../node_modules/@opencode-ai/sdk/dist/v2/client.js
|
|
21438
|
-
function pick2(value, fallback, encode3) {
|
|
21439
|
-
if (!value)
|
|
21440
|
-
return;
|
|
21441
|
-
if (!fallback)
|
|
21442
|
-
return value;
|
|
21443
|
-
if (value === fallback)
|
|
21444
|
-
return fallback;
|
|
21445
|
-
if (encode3 && value === encode3(fallback))
|
|
21446
|
-
return fallback;
|
|
21447
|
-
return value;
|
|
21448
|
-
}
|
|
21449
|
-
function rewrite(request, values) {
|
|
21450
|
-
if (request.method !== "GET" && request.method !== "HEAD")
|
|
21451
|
-
return request;
|
|
21452
|
-
const url2 = new URL(request.url);
|
|
21453
|
-
let changed = false;
|
|
21454
|
-
for (const [name, key] of [
|
|
21455
|
-
["x-opencode-directory", "directory"],
|
|
21456
|
-
["x-opencode-workspace", "workspace"]
|
|
21457
|
-
]) {
|
|
21458
|
-
const value = pick2(request.headers.get(name), key === "directory" ? values.directory : values.workspace, key === "directory" ? encodeURIComponent : void 0);
|
|
21459
|
-
if (!value)
|
|
21460
|
-
continue;
|
|
21461
|
-
for (const query of url2.pathname.startsWith("/api/") ? [key, `location[${key}]`] : [key]) {
|
|
21462
|
-
if (!url2.searchParams.has(query)) {
|
|
21463
|
-
url2.searchParams.set(query, value);
|
|
21464
|
-
}
|
|
21465
|
-
}
|
|
21466
|
-
changed = true;
|
|
21467
|
-
}
|
|
21468
|
-
if (!changed)
|
|
21469
|
-
return request;
|
|
21470
|
-
const next = new Request(url2, request);
|
|
21471
|
-
next.headers.delete("x-opencode-directory");
|
|
21472
|
-
next.headers.delete("x-opencode-workspace");
|
|
21473
|
-
return next;
|
|
21474
|
-
}
|
|
21475
|
-
function createOpencodeClient(config2) {
|
|
21476
|
-
if (!config2?.fetch) {
|
|
21477
|
-
const customFetch = (req) => {
|
|
21478
|
-
req.timeout = false;
|
|
21479
|
-
return fetch(req);
|
|
21480
|
-
};
|
|
21481
|
-
config2 = {
|
|
21482
|
-
...config2,
|
|
21483
|
-
fetch: customFetch
|
|
21484
|
-
};
|
|
21485
|
-
}
|
|
21486
|
-
if (config2?.directory) {
|
|
21487
|
-
config2.headers = {
|
|
21488
|
-
...config2.headers,
|
|
21489
|
-
"x-opencode-directory": encodeURIComponent(config2.directory)
|
|
21490
|
-
};
|
|
21491
|
-
}
|
|
21492
|
-
if (config2?.experimental_workspaceID) {
|
|
21493
|
-
config2.headers = {
|
|
21494
|
-
...config2.headers,
|
|
21495
|
-
"x-opencode-workspace": config2.experimental_workspaceID
|
|
21496
|
-
};
|
|
21497
|
-
}
|
|
21498
|
-
const client2 = createClient(config2);
|
|
21499
|
-
client2.interceptors.request.use((request) => rewrite(request, {
|
|
21500
|
-
directory: config2?.directory,
|
|
21501
|
-
workspace: config2?.experimental_workspaceID
|
|
21502
|
-
}));
|
|
21503
|
-
client2.interceptors.response.use((response) => {
|
|
21504
|
-
const contentType = response.headers.get("content-type");
|
|
21505
|
-
if (contentType === "text/html")
|
|
21506
|
-
throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");
|
|
21507
|
-
return response;
|
|
21508
|
-
});
|
|
21509
|
-
client2.interceptors.error.use(wrapClientError);
|
|
21510
|
-
return new OpencodeClient({ client: client2 });
|
|
21511
|
-
}
|
|
21512
|
-
|
|
21513
|
-
// dist/command.js
|
|
21514
|
-
import path3 from "node:path";
|
|
21515
|
-
|
|
21516
|
-
// ../../harness-discovery/dist/environment.js
|
|
21517
|
-
import fs from "node:fs";
|
|
21518
|
-
import path from "node:path";
|
|
21519
|
-
function targetPath(platform) {
|
|
21520
|
-
return platform === "win32" ? path.win32 : path.posix;
|
|
21521
|
-
}
|
|
21522
|
-
function environmentValue(environment, name) {
|
|
21523
|
-
const lowered = name.toLowerCase();
|
|
21524
|
-
for (const [key, value] of Object.entries(environment)) {
|
|
21525
|
-
if (key.toLowerCase() === lowered)
|
|
21526
|
-
return value;
|
|
21527
|
-
}
|
|
21528
|
-
return void 0;
|
|
21529
|
-
}
|
|
21530
|
-
function pathDelimiter(platform) {
|
|
21531
|
-
return platform === "win32" ? ";" : ":";
|
|
21532
|
-
}
|
|
21533
|
-
function pathDirectories(environment, platform) {
|
|
21534
|
-
return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
|
|
21535
|
-
}
|
|
21536
|
-
function executableExtensions(command, platform, environment) {
|
|
21537
|
-
if (platform !== "win32")
|
|
21538
|
-
return [""];
|
|
21539
|
-
if (targetPath(platform).extname(command) !== "")
|
|
21540
|
-
return [""];
|
|
21541
|
-
return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
|
|
21542
|
-
}
|
|
21543
|
-
function isExecutableFile(filePath, platform) {
|
|
21544
|
-
try {
|
|
21545
|
-
fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
|
|
21546
|
-
return fs.statSync(filePath).isFile();
|
|
21547
|
-
} catch {
|
|
21548
|
-
return false;
|
|
21549
|
-
}
|
|
21550
|
-
}
|
|
21551
|
-
function subdirectoryNames(directory) {
|
|
21552
|
-
try {
|
|
21553
|
-
return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
21554
|
-
} catch {
|
|
21555
|
-
return [];
|
|
21556
|
-
}
|
|
21557
|
-
}
|
|
21558
|
-
function newestFirst(names) {
|
|
21559
|
-
return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
|
|
21560
|
-
}
|
|
21561
|
-
|
|
21562
|
-
// ../../harness-discovery/dist/invocation.js
|
|
21563
|
-
import path2 from "node:path";
|
|
21564
|
-
function commandInvocation(command, arguments_, environment, platform = process.platform) {
|
|
21565
|
-
const extension = path2.win32.extname(command).toLowerCase();
|
|
21566
|
-
if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
|
|
21567
|
-
return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
|
|
21568
|
-
}
|
|
21569
|
-
const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
|
|
21570
|
-
const commandLine = [command, ...arguments_].map(quote).join(" ");
|
|
21571
|
-
return {
|
|
21572
|
-
command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
|
|
21573
|
-
arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
|
|
21574
|
-
windowsVerbatimArguments: true
|
|
21575
|
-
};
|
|
21576
|
-
}
|
|
21577
|
-
|
|
21578
|
-
// ../../harness-discovery/dist/resolve.js
|
|
21579
|
-
import os from "node:os";
|
|
21580
|
-
|
|
21581
|
-
// ../../harness-discovery/dist/version-managers.js
|
|
21582
|
-
function versionManagerBinaryDirectories(context) {
|
|
21583
|
-
const { platform, environment, home } = context;
|
|
21584
|
-
const list = context.subdirectories ?? subdirectoryNames;
|
|
21585
|
-
const pathFlavor = targetPath(platform);
|
|
21586
|
-
const value = (name) => environmentValue(environment, name);
|
|
21587
|
-
const directories = [];
|
|
21588
|
-
const versioned = (root, ...tail) => {
|
|
21589
|
-
for (const version2 of newestFirst(list(root))) {
|
|
21590
|
-
directories.push(pathFlavor.join(root, version2, ...tail));
|
|
21591
|
-
}
|
|
21592
|
-
};
|
|
21593
|
-
if (platform === "win32") {
|
|
21594
|
-
const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
|
|
21595
|
-
const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
|
|
21596
|
-
versioned(pathFlavor.join(appData, "nvm"));
|
|
21597
|
-
versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
|
|
21598
|
-
directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
|
|
21599
|
-
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
21600
|
-
const pnpmHome2 = value("PNPM_HOME");
|
|
21601
|
-
if (pnpmHome2)
|
|
21602
|
-
directories.push(pnpmHome2);
|
|
21603
|
-
directories.push(pathFlavor.join(localAppData, "pnpm"));
|
|
21604
|
-
return directories;
|
|
22002
|
+
_session;
|
|
22003
|
+
get session() {
|
|
22004
|
+
return this._session ??= new Session2({ client: this.client });
|
|
21605
22005
|
}
|
|
21606
|
-
|
|
21607
|
-
|
|
21608
|
-
|
|
21609
|
-
pathFlavor.join(home, ".local", "share", "fnm"),
|
|
21610
|
-
pathFlavor.join(home, "Library", "Application Support", "fnm")
|
|
21611
|
-
].filter((root) => root !== void 0);
|
|
21612
|
-
for (const root of fnmRoots) {
|
|
21613
|
-
versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
|
|
22006
|
+
_part;
|
|
22007
|
+
get part() {
|
|
22008
|
+
return this._part ??= new Part({ client: this.client });
|
|
21614
22009
|
}
|
|
21615
|
-
|
|
21616
|
-
|
|
21617
|
-
|
|
21618
|
-
const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
|
|
21619
|
-
versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
|
|
21620
|
-
directories.push(pathFlavor.join(asdfHome, "shims"));
|
|
21621
|
-
const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
|
|
21622
|
-
versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
|
|
21623
|
-
directories.push(pathFlavor.join(nodenvHome, "shims"));
|
|
21624
|
-
versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
|
|
21625
|
-
directories.push(pathFlavor.join(home, ".bun", "bin"));
|
|
21626
|
-
const pnpmHome = value("PNPM_HOME");
|
|
21627
|
-
if (pnpmHome)
|
|
21628
|
-
directories.push(pnpmHome);
|
|
21629
|
-
directories.push(pathFlavor.join(home, "Library", "pnpm"));
|
|
21630
|
-
directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
|
|
21631
|
-
for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
|
|
21632
|
-
for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
|
|
21633
|
-
directories.push(pathFlavor.join(prefix, formula, "bin"));
|
|
21634
|
-
}
|
|
22010
|
+
_sync;
|
|
22011
|
+
get sync() {
|
|
22012
|
+
return this._sync ??= new Sync({ client: this.client });
|
|
21635
22013
|
}
|
|
21636
|
-
|
|
21637
|
-
|
|
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
|
+
};
|
|
21638
22023
|
|
|
21639
|
-
//
|
|
21640
|
-
|
|
21641
|
-
|
|
21642
|
-
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
|
|
21646
|
-
|
|
21647
|
-
|
|
21648
|
-
|
|
21649
|
-
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
|
|
21653
|
-
|
|
21654
|
-
}
|
|
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 }
|
|
22041
|
+
});
|
|
21655
22042
|
}
|
|
21656
|
-
function
|
|
21657
|
-
const
|
|
21658
|
-
const
|
|
21659
|
-
const
|
|
21660
|
-
const
|
|
21661
|
-
|
|
21662
|
-
return pathFlavor.join(pathFlavor.sep, ...tail);
|
|
21663
|
-
return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
|
|
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 : ""}`;
|
|
21664
22049
|
}
|
|
21665
|
-
|
|
21666
|
-
|
|
21667
|
-
|
|
21668
|
-
|
|
21669
|
-
|
|
21670
|
-
|
|
21671
|
-
unresolved = true;
|
|
21672
|
-
return "";
|
|
21673
|
-
}
|
|
22050
|
+
|
|
22051
|
+
// ../../../node_modules/@opencode-ai/sdk/dist/v2/client.js
|
|
22052
|
+
function pick2(value, fallback, encode3) {
|
|
22053
|
+
if (!value)
|
|
22054
|
+
return;
|
|
22055
|
+
if (!fallback)
|
|
21674
22056
|
return value;
|
|
21675
|
-
|
|
21676
|
-
|
|
22057
|
+
if (value === fallback)
|
|
22058
|
+
return fallback;
|
|
22059
|
+
if (encode3 && value === encode3(fallback))
|
|
22060
|
+
return fallback;
|
|
22061
|
+
return value;
|
|
21677
22062
|
}
|
|
21678
|
-
function
|
|
21679
|
-
|
|
21680
|
-
|
|
21681
|
-
|
|
21682
|
-
|
|
21683
|
-
|
|
21684
|
-
|
|
21685
|
-
|
|
21686
|
-
|
|
21687
|
-
|
|
21688
|
-
|
|
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)
|
|
21689
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);
|
|
22078
|
+
}
|
|
21690
22079
|
}
|
|
21691
|
-
|
|
21692
|
-
if (directory !== void 0)
|
|
21693
|
-
directories.push(directory);
|
|
22080
|
+
changed = true;
|
|
21694
22081
|
}
|
|
21695
|
-
|
|
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;
|
|
21696
22088
|
}
|
|
21697
|
-
function
|
|
21698
|
-
|
|
21699
|
-
|
|
21700
|
-
|
|
21701
|
-
|
|
21702
|
-
|
|
21703
|
-
|
|
21704
|
-
|
|
21705
|
-
|
|
21706
|
-
|
|
21707
|
-
for (const directory of pathDirectories(input.environment, platform)) {
|
|
21708
|
-
for (const extension of extensions) {
|
|
21709
|
-
candidates.push({
|
|
21710
|
-
candidate: pathFlavor.join(directory, command + extension),
|
|
21711
|
-
source: "path"
|
|
21712
|
-
});
|
|
21713
|
-
}
|
|
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
|
+
};
|
|
21714
22099
|
}
|
|
21715
|
-
if (
|
|
21716
|
-
|
|
21717
|
-
|
|
21718
|
-
|
|
21719
|
-
|
|
21720
|
-
candidates.push({
|
|
21721
|
-
candidate: pathFlavor.join(directory, spec.command + extension),
|
|
21722
|
-
source: "install-root"
|
|
21723
|
-
});
|
|
21724
|
-
}
|
|
22100
|
+
if (config2?.directory) {
|
|
22101
|
+
config2.headers = {
|
|
22102
|
+
...config2.headers,
|
|
22103
|
+
"x-opencode-directory": encodeURIComponent(config2.directory)
|
|
22104
|
+
};
|
|
21725
22105
|
}
|
|
21726
|
-
|
|
21727
|
-
|
|
21728
|
-
|
|
21729
|
-
|
|
21730
|
-
|
|
21731
|
-
const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
|
|
21732
|
-
const context = { platform, isExecutable };
|
|
21733
|
-
for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
|
|
21734
|
-
const executable = runnable(candidate, context);
|
|
21735
|
-
if (executable !== void 0 && isExecutable(executable))
|
|
21736
|
-
return { executable, source };
|
|
22106
|
+
if (config2?.experimental_workspaceID) {
|
|
22107
|
+
config2.headers = {
|
|
22108
|
+
...config2.headers,
|
|
22109
|
+
"x-opencode-workspace": config2.experimental_workspaceID
|
|
22110
|
+
};
|
|
21737
22111
|
}
|
|
21738
|
-
|
|
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 });
|
|
21739
22125
|
}
|
|
21740
22126
|
|
|
21741
22127
|
// dist/command.js
|
|
22128
|
+
import path5 from "node:path";
|
|
21742
22129
|
var OpenCodeExecutableError = class extends Error {
|
|
21743
22130
|
code = "OPENCODE_NOT_FOUND";
|
|
21744
22131
|
constructor(message = "OpenCode CLI is not installed") {
|
|
@@ -21772,16 +22159,34 @@ function resolveOpenCodeExecutable(input = {}, dependencies = {}) {
|
|
|
21772
22159
|
}, dependencies);
|
|
21773
22160
|
if (!resolution)
|
|
21774
22161
|
throw new OpenCodeExecutableError();
|
|
21775
|
-
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable :
|
|
22162
|
+
return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
|
|
21776
22163
|
}
|
|
21777
|
-
function openCodeServerInvocation(executable, environment, platform = process.platform) {
|
|
21778
|
-
return commandInvocation(executable, ["serve", "--hostname=127.0.0.1",
|
|
22164
|
+
function openCodeServerInvocation(executable, environment, platform = process.platform, port = 0) {
|
|
22165
|
+
return commandInvocation(executable, ["serve", "--hostname=127.0.0.1", `--port=${port}`], environment, platform);
|
|
21779
22166
|
}
|
|
21780
22167
|
|
|
21781
22168
|
// dist/server-connection.js
|
|
21782
22169
|
var DEFAULT_STARTUP_TIMEOUT_MS = 2e4;
|
|
21783
22170
|
var DEFAULT_CLOSE_TIMEOUT_MS = 3e3;
|
|
22171
|
+
var STARTUP_ATTEMPTS = 3;
|
|
21784
22172
|
var SERVER_USERNAME = "codexhost";
|
|
22173
|
+
function freeLoopbackPort() {
|
|
22174
|
+
return new Promise((resolve, reject) => {
|
|
22175
|
+
const probe = createServer();
|
|
22176
|
+
probe.unref();
|
|
22177
|
+
probe.once("error", reject);
|
|
22178
|
+
probe.listen({ host: "127.0.0.1", port: 0 }, () => {
|
|
22179
|
+
const address = probe.address();
|
|
22180
|
+
const port = typeof address === "object" && address ? address.port : 0;
|
|
22181
|
+
probe.close(() => {
|
|
22182
|
+
if (port)
|
|
22183
|
+
resolve(port);
|
|
22184
|
+
else
|
|
22185
|
+
reject(new Error("Failed to assign an OpenCode Server loopback port"));
|
|
22186
|
+
});
|
|
22187
|
+
});
|
|
22188
|
+
});
|
|
22189
|
+
}
|
|
21785
22190
|
function isRecord2(value) {
|
|
21786
22191
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21787
22192
|
}
|
|
@@ -21849,9 +22254,9 @@ function signalProcessTree(child, signal) {
|
|
|
21849
22254
|
}
|
|
21850
22255
|
}
|
|
21851
22256
|
function safeOpenCodeServerCwd(environment) {
|
|
21852
|
-
const candidates = [environment.USERPROFILE, environment.HOME,
|
|
22257
|
+
const candidates = [environment.USERPROFILE, environment.HOME, homedir2(), tmpdir2()];
|
|
21853
22258
|
for (const candidate of candidates) {
|
|
21854
|
-
if (!candidate || !
|
|
22259
|
+
if (!candidate || !path6.isAbsolute(candidate))
|
|
21855
22260
|
continue;
|
|
21856
22261
|
try {
|
|
21857
22262
|
if (!fs2.statSync(candidate).isDirectory())
|
|
@@ -21903,7 +22308,8 @@ var OpenCodeServerConnection = class {
|
|
|
21903
22308
|
...spawnOptions,
|
|
21904
22309
|
windowsVerbatimArguments: spawnOptions.windowsVerbatimArguments
|
|
21905
22310
|
}),
|
|
21906
|
-
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds))
|
|
22311
|
+
sleep: (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)),
|
|
22312
|
+
assignPort: freeLoopbackPort
|
|
21907
22313
|
}) {
|
|
21908
22314
|
this.#options = options;
|
|
21909
22315
|
this.#environment = options.environment ?? process.env;
|
|
@@ -21959,11 +22365,26 @@ var OpenCodeServerConnection = class {
|
|
|
21959
22365
|
OPENCODE_SERVER_USERNAME: SERVER_USERNAME,
|
|
21960
22366
|
OPENCODE_SERVER_PASSWORD: password
|
|
21961
22367
|
};
|
|
21962
|
-
const invocation = openCodeServerInvocation(executable, environment);
|
|
21963
22368
|
const serverCwd = (this.#dependencies.resolveServerCwd ?? safeOpenCodeServerCwd)(environment);
|
|
21964
22369
|
if (!serverCwd) {
|
|
21965
22370
|
throw new OpenCodeTransportError("unavailable", "OpenCode Server requires a writable startup directory");
|
|
21966
22371
|
}
|
|
22372
|
+
let lastError;
|
|
22373
|
+
for (let attempt = 0; attempt < STARTUP_ATTEMPTS; attempt += 1) {
|
|
22374
|
+
try {
|
|
22375
|
+
return await this.#startAttempt(executable, environment, serverCwd, password);
|
|
22376
|
+
} catch (error51) {
|
|
22377
|
+
lastError = error51;
|
|
22378
|
+
if (!(error51 instanceof OpenCodeTransportError) || error51.code !== "processExited") {
|
|
22379
|
+
throw classifySdkError(error51, "Server startup");
|
|
22380
|
+
}
|
|
22381
|
+
}
|
|
22382
|
+
}
|
|
22383
|
+
throw classifySdkError(lastError, "Server startup");
|
|
22384
|
+
}
|
|
22385
|
+
async #startAttempt(executable, environment, serverCwd, password) {
|
|
22386
|
+
const port = await (this.#dependencies.assignPort ?? freeLoopbackPort)();
|
|
22387
|
+
const invocation = openCodeServerInvocation(executable, environment, process.platform, port);
|
|
21967
22388
|
let child;
|
|
21968
22389
|
try {
|
|
21969
22390
|
child = this.#dependencies.spawn(invocation.command, invocation.arguments, {
|
|
@@ -22024,7 +22445,7 @@ var OpenCodeServerConnection = class {
|
|
|
22024
22445
|
return { baseUrl, authorization };
|
|
22025
22446
|
} catch (error51) {
|
|
22026
22447
|
await this.#stopChild(child).catch(() => void 0);
|
|
22027
|
-
throw
|
|
22448
|
+
throw error51;
|
|
22028
22449
|
}
|
|
22029
22450
|
}
|
|
22030
22451
|
async #stopChild(child) {
|
|
@@ -22284,7 +22705,7 @@ var SdkOpenCodeTransport = class {
|
|
|
22284
22705
|
|
|
22285
22706
|
// dist/file-change-verification.js
|
|
22286
22707
|
import fs3 from "node:fs";
|
|
22287
|
-
import
|
|
22708
|
+
import path7 from "node:path";
|
|
22288
22709
|
function missingPath(error51) {
|
|
22289
22710
|
if (!error51 || typeof error51 !== "object")
|
|
22290
22711
|
return false;
|
|
@@ -22296,33 +22717,33 @@ function hasDotPathSegment(value) {
|
|
|
22296
22717
|
return segments.some((segment) => segment === "." || segment === "..");
|
|
22297
22718
|
}
|
|
22298
22719
|
function canonicalDirectoryPath(value) {
|
|
22299
|
-
let candidate =
|
|
22720
|
+
let candidate = path7.resolve(value);
|
|
22300
22721
|
const missingSegments = [];
|
|
22301
22722
|
for (; ; ) {
|
|
22302
22723
|
try {
|
|
22303
|
-
return
|
|
22724
|
+
return path7.join(fs3.realpathSync.native(candidate), ...missingSegments);
|
|
22304
22725
|
} catch (error51) {
|
|
22305
22726
|
if (!missingPath(error51))
|
|
22306
22727
|
return void 0;
|
|
22307
|
-
const parent =
|
|
22728
|
+
const parent = path7.dirname(candidate);
|
|
22308
22729
|
if (parent === candidate)
|
|
22309
22730
|
return void 0;
|
|
22310
|
-
missingSegments.unshift(
|
|
22731
|
+
missingSegments.unshift(path7.basename(candidate));
|
|
22311
22732
|
candidate = parent;
|
|
22312
22733
|
}
|
|
22313
22734
|
}
|
|
22314
22735
|
}
|
|
22315
22736
|
function canonicalFilePath(value) {
|
|
22316
|
-
const absolute =
|
|
22317
|
-
const parent = canonicalDirectoryPath(
|
|
22318
|
-
return parent ?
|
|
22737
|
+
const absolute = path7.resolve(value);
|
|
22738
|
+
const parent = canonicalDirectoryPath(path7.dirname(absolute));
|
|
22739
|
+
return parent ? path7.join(parent, path7.basename(absolute)) : void 0;
|
|
22319
22740
|
}
|
|
22320
22741
|
function pathIsWithin(root, candidate, allowRoot) {
|
|
22321
|
-
const relative =
|
|
22322
|
-
return allowRoot && relative === "" || relative !== "" && relative !== ".." && !relative.startsWith(`..${
|
|
22742
|
+
const relative = path7.relative(root, candidate);
|
|
22743
|
+
return allowRoot && relative === "" || relative !== "" && relative !== ".." && !relative.startsWith(`..${path7.sep}`) && !path7.isAbsolute(relative);
|
|
22323
22744
|
}
|
|
22324
22745
|
function verifiedOpenCodeWorktree(sessionDirectory, paths) {
|
|
22325
|
-
if (!paths || typeof paths !== "object" || typeof sessionDirectory !== "string" || typeof paths.directory !== "string" || typeof paths.worktree !== "string" || hasDotPathSegment(sessionDirectory) || hasDotPathSegment(paths.directory) || hasDotPathSegment(paths.worktree) || !
|
|
22746
|
+
if (!paths || typeof paths !== "object" || typeof sessionDirectory !== "string" || typeof paths.directory !== "string" || typeof paths.worktree !== "string" || hasDotPathSegment(sessionDirectory) || hasDotPathSegment(paths.directory) || hasDotPathSegment(paths.worktree) || !path7.isAbsolute(sessionDirectory) || !path7.isAbsolute(paths.directory) || !path7.isAbsolute(paths.worktree)) {
|
|
22326
22747
|
return void 0;
|
|
22327
22748
|
}
|
|
22328
22749
|
const session = canonicalDirectoryPath(sessionDirectory);
|
|
@@ -22334,10 +22755,10 @@ function verifiedOpenCodeWorktree(sessionDirectory, paths) {
|
|
|
22334
22755
|
return worktree;
|
|
22335
22756
|
}
|
|
22336
22757
|
function openCodeFileIdentity(file2, worktree) {
|
|
22337
|
-
if (typeof file2 !== "string" || typeof worktree !== "string" || hasDotPathSegment(file2) || hasDotPathSegment(worktree) || !
|
|
22758
|
+
if (typeof file2 !== "string" || typeof worktree !== "string" || hasDotPathSegment(file2) || hasDotPathSegment(worktree) || !path7.isAbsolute(worktree) || !file2 || file2.includes("\0") || file2.includes("\n") || file2.includes("\r")) {
|
|
22338
22759
|
return void 0;
|
|
22339
22760
|
}
|
|
22340
|
-
const candidate = canonicalFilePath(
|
|
22761
|
+
const candidate = canonicalFilePath(path7.isAbsolute(file2) ? file2 : path7.resolve(worktree, file2));
|
|
22341
22762
|
return candidate && pathIsWithin(worktree, candidate, false) ? candidate : void 0;
|
|
22342
22763
|
}
|
|
22343
22764
|
|
|
@@ -22631,7 +23052,7 @@ function sameCwd(left, right) {
|
|
|
22631
23052
|
try {
|
|
22632
23053
|
return fs4.realpathSync.native(value);
|
|
22633
23054
|
} catch {
|
|
22634
|
-
return
|
|
23055
|
+
return path8.resolve(value);
|
|
22635
23056
|
}
|
|
22636
23057
|
};
|
|
22637
23058
|
return canonical(left) === canonical(right);
|
|
@@ -23986,7 +24407,7 @@ var OpenCodeAdapter = class {
|
|
|
23986
24407
|
};
|
|
23987
24408
|
|
|
23988
24409
|
// dist/version.js
|
|
23989
|
-
import { execFile } from "node:child_process";
|
|
24410
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
23990
24411
|
import { promisify } from "node:util";
|
|
23991
24412
|
function openCodeMajor(version2) {
|
|
23992
24413
|
const match = /^(?:opencode\s+)?v?([12])\.\d+\.\d+(?:[-+][\w.-]+)?$/u.exec(version2.trim());
|
|
@@ -24001,7 +24422,7 @@ async function detectOpenCode(options) {
|
|
|
24001
24422
|
environment
|
|
24002
24423
|
});
|
|
24003
24424
|
const invocation = commandInvocation(executable, ["--version"], environment);
|
|
24004
|
-
const { stdout } = await promisify(
|
|
24425
|
+
const { stdout } = await promisify(execFile2)(invocation.command, invocation.arguments, {
|
|
24005
24426
|
env: environment,
|
|
24006
24427
|
timeout: options.startupTimeoutMs ?? 2e4,
|
|
24007
24428
|
maxBuffer: 16384,
|
|
@@ -24017,7 +24438,7 @@ import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
|
|
|
24017
24438
|
|
|
24018
24439
|
// dist/v2/state.js
|
|
24019
24440
|
import fs5 from "node:fs";
|
|
24020
|
-
import
|
|
24441
|
+
import path9 from "node:path";
|
|
24021
24442
|
var harnessId = harnessIdSchema.parse("opencode");
|
|
24022
24443
|
function failure(message, code = "nativeFailure") {
|
|
24023
24444
|
return {
|
|
@@ -24037,7 +24458,7 @@ function sameDirectory(left, right) {
|
|
|
24037
24458
|
try {
|
|
24038
24459
|
return fs5.realpathSync(value);
|
|
24039
24460
|
} catch {
|
|
24040
|
-
return
|
|
24461
|
+
return path9.resolve(value);
|
|
24041
24462
|
}
|
|
24042
24463
|
};
|
|
24043
24464
|
return canonical(left) === canonical(right);
|
|
@@ -25952,7 +26373,7 @@ var V2Connection = class {
|
|
|
25952
26373
|
};
|
|
25953
26374
|
|
|
25954
26375
|
// dist/v2/history.js
|
|
25955
|
-
import
|
|
26376
|
+
import path10 from "node:path";
|
|
25956
26377
|
async function readMessages(client2, sessionID) {
|
|
25957
26378
|
const messages = [];
|
|
25958
26379
|
let cursor;
|
|
@@ -26077,9 +26498,9 @@ function fileChanges(session, turn, diffs) {
|
|
|
26077
26498
|
if (!diffs.length)
|
|
26078
26499
|
return void 0;
|
|
26079
26500
|
const changes = diffs.map((diff) => {
|
|
26080
|
-
const absolute =
|
|
26081
|
-
const relative =
|
|
26082
|
-
if (relative.startsWith(`..${
|
|
26501
|
+
const absolute = path10.resolve(session.location.directory, diff.file);
|
|
26502
|
+
const relative = path10.relative(session.location.directory, absolute);
|
|
26503
|
+
if (relative.startsWith(`..${path10.sep}`) || relative === ".." || path10.isAbsolute(relative))
|
|
26083
26504
|
throw new Error("OpenCode v2 diff escaped the Session directory");
|
|
26084
26505
|
return {
|
|
26085
26506
|
path: absolute,
|
|
@@ -26986,13 +27407,60 @@ function normalize(error51) {
|
|
|
26986
27407
|
return failure(error51 instanceof Error ? error51.message : String(error51), error51 instanceof OpenCodeExecutableError ? "notInstalled" : "unavailable");
|
|
26987
27408
|
}
|
|
26988
27409
|
|
|
27410
|
+
// dist/installation.js
|
|
27411
|
+
import { realpath as realpath2 } from "node:fs/promises";
|
|
27412
|
+
import { homedir as homedir3 } from "node:os";
|
|
27413
|
+
import path11 from "node:path";
|
|
27414
|
+
function createOpenCodeInstallation(environment, command) {
|
|
27415
|
+
let update;
|
|
27416
|
+
return createInstallationManager({
|
|
27417
|
+
async check() {
|
|
27418
|
+
const executable = resolveOpenCodeExecutable({
|
|
27419
|
+
environment,
|
|
27420
|
+
...command ? { command } : {}
|
|
27421
|
+
});
|
|
27422
|
+
const currentVersion = versionFromOutput(await runInstallationCommand(executable, ["--version"], environment));
|
|
27423
|
+
const npm = await npmInstallation(executable, ["opencode-ai"], environment);
|
|
27424
|
+
let latestVersion;
|
|
27425
|
+
let canUpdate;
|
|
27426
|
+
if (npm) {
|
|
27427
|
+
latestVersion = await npm.latest();
|
|
27428
|
+
canUpdate = npm.canUpdate;
|
|
27429
|
+
update = npm.update;
|
|
27430
|
+
} else {
|
|
27431
|
+
const release = JSON.parse(await fetchInstallationText("https://api.github.com/repos/anomalyco/opencode/releases/latest"));
|
|
27432
|
+
latestVersion = installationVersion(release.tag_name);
|
|
27433
|
+
const home = environment.HOME ?? environment.USERPROFILE ?? homedir3();
|
|
27434
|
+
const standard = path11.join(home, ".opencode", "bin", process.platform === "win32" ? "opencode.exe" : "opencode");
|
|
27435
|
+
canUpdate = process.platform !== "win32" && path11.resolve(executable) === standard && await realpath2(executable) === standard;
|
|
27436
|
+
update = async (version2) => {
|
|
27437
|
+
await runInstallationCommand(executable, ["upgrade", version2, "--method", "curl"], environment, 3e5);
|
|
27438
|
+
};
|
|
27439
|
+
}
|
|
27440
|
+
return {
|
|
27441
|
+
currentVersion,
|
|
27442
|
+
latestVersion,
|
|
27443
|
+
updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
|
|
27444
|
+
canUpdate,
|
|
27445
|
+
...!canUpdate ? { message: "Use the original package manager to update this OpenCode installation." } : {}
|
|
27446
|
+
};
|
|
27447
|
+
},
|
|
27448
|
+
async update(state) {
|
|
27449
|
+
await update(state.latestVersion);
|
|
27450
|
+
}
|
|
27451
|
+
});
|
|
27452
|
+
}
|
|
27453
|
+
|
|
26989
27454
|
// dist/plugin.js
|
|
26990
27455
|
var OPENCODE_COMMAND_ENV = "CODEXHOST_OPENCODE_COMMAND";
|
|
26991
27456
|
function createHarnessAdapter(context) {
|
|
26992
27457
|
const environment = { ...context.environment };
|
|
26993
|
-
return new OpenCodeAdapter2({
|
|
27458
|
+
return Object.assign(new OpenCodeAdapter2({
|
|
26994
27459
|
...environment[OPENCODE_COMMAND_ENV] ? { command: environment[OPENCODE_COMMAND_ENV] } : {},
|
|
26995
27460
|
environment
|
|
27461
|
+
}), {
|
|
27462
|
+
installation: createOpenCodeInstallation(environment, environment[OPENCODE_COMMAND_ENV]),
|
|
27463
|
+
install: createHarnessInstaller(environment, { npm: "opencode-ai" })
|
|
26996
27464
|
});
|
|
26997
27465
|
}
|
|
26998
27466
|
export {
|