@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.
@@ -5,6 +5,409 @@ var __export = (target, all) => {
5
5
  __defProp(target, name, { get: all[name], enumerable: true });
6
6
  };
7
7
 
8
+ // ../../harness-discovery/dist/environment.js
9
+ import fs from "node:fs";
10
+ import path from "node:path";
11
+ function targetPath(platform) {
12
+ return platform === "win32" ? path.win32 : path.posix;
13
+ }
14
+ function environmentValue(environment, name) {
15
+ const lowered = name.toLowerCase();
16
+ for (const [key, value] of Object.entries(environment)) {
17
+ if (key.toLowerCase() === lowered)
18
+ return value;
19
+ }
20
+ return void 0;
21
+ }
22
+ function pathDelimiter(platform) {
23
+ return platform === "win32" ? ";" : ":";
24
+ }
25
+ function pathDirectories(environment, platform) {
26
+ return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
27
+ }
28
+ function executableExtensions(command, platform, environment) {
29
+ if (platform !== "win32")
30
+ return [""];
31
+ if (targetPath(platform).extname(command) !== "")
32
+ return [""];
33
+ return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
34
+ }
35
+ function isExecutableFile(filePath, platform) {
36
+ try {
37
+ fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
+ return fs.statSync(filePath).isFile();
39
+ } catch {
40
+ return false;
41
+ }
42
+ }
43
+ function subdirectoryNames(directory) {
44
+ try {
45
+ return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
46
+ } catch {
47
+ return [];
48
+ }
49
+ }
50
+ function newestFirst(names) {
51
+ return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
52
+ }
53
+
54
+ // ../../harness-discovery/dist/invocation.js
55
+ import path2 from "node:path";
56
+ function commandInvocation(command, arguments_, environment, platform = process.platform) {
57
+ const extension = path2.win32.extname(command).toLowerCase();
58
+ if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
59
+ return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
60
+ }
61
+ const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
62
+ const commandLine = [command, ...arguments_].map(quote).join(" ");
63
+ return {
64
+ command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
65
+ arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
66
+ windowsVerbatimArguments: true
67
+ };
68
+ }
69
+
70
+ // ../../harness-discovery/dist/node-runtime.js
71
+ import path3 from "node:path";
72
+ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
73
+ const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
74
+ const delimiter = platform === "win32" ? ";" : ":";
75
+ const runtimeDirectory = path3.dirname(runtimeExecutable);
76
+ const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
77
+ const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
78
+ if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
79
+ directories.push(runtimeDirectory);
80
+ }
81
+ return { ...environment, [pathKey]: directories.join(delimiter) };
82
+ }
83
+
84
+ // ../../harness-discovery/dist/resolve.js
85
+ import os from "node:os";
86
+
87
+ // ../../harness-discovery/dist/version-managers.js
88
+ function versionManagerBinaryDirectories(context) {
89
+ const { platform, environment, home } = context;
90
+ const list = context.subdirectories ?? subdirectoryNames;
91
+ const pathFlavor = targetPath(platform);
92
+ const value = (name) => environmentValue(environment, name);
93
+ const directories = [];
94
+ const versioned = (root, ...tail) => {
95
+ for (const version2 of newestFirst(list(root))) {
96
+ directories.push(pathFlavor.join(root, version2, ...tail));
97
+ }
98
+ };
99
+ if (platform === "win32") {
100
+ const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
101
+ const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
102
+ versioned(pathFlavor.join(appData, "nvm"));
103
+ versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
104
+ directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
105
+ directories.push(pathFlavor.join(home, ".bun", "bin"));
106
+ const pnpmHome2 = value("PNPM_HOME");
107
+ if (pnpmHome2)
108
+ directories.push(pnpmHome2);
109
+ directories.push(pathFlavor.join(localAppData, "pnpm"));
110
+ return directories;
111
+ }
112
+ versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
113
+ const fnmRoots = [
114
+ value("FNM_DIR"),
115
+ pathFlavor.join(home, ".local", "share", "fnm"),
116
+ pathFlavor.join(home, "Library", "Application Support", "fnm")
117
+ ].filter((root) => root !== void 0);
118
+ for (const root of fnmRoots) {
119
+ versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
120
+ }
121
+ const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
122
+ versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
123
+ directories.push(pathFlavor.join(voltaHome, "bin"));
124
+ const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
125
+ versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
126
+ directories.push(pathFlavor.join(asdfHome, "shims"));
127
+ const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
128
+ versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
129
+ directories.push(pathFlavor.join(nodenvHome, "shims"));
130
+ versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
131
+ directories.push(pathFlavor.join(home, ".bun", "bin"));
132
+ const pnpmHome = value("PNPM_HOME");
133
+ if (pnpmHome)
134
+ directories.push(pnpmHome);
135
+ directories.push(pathFlavor.join(home, "Library", "pnpm"));
136
+ directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
137
+ for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
138
+ for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
139
+ directories.push(pathFlavor.join(prefix, formula, "bin"));
140
+ }
141
+ }
142
+ return directories;
143
+ }
144
+
145
+ // ../../harness-discovery/dist/resolve.js
146
+ var VERSION_MANAGER_ROOTS = "<version-managers>";
147
+ function installRootExtensions(platform) {
148
+ return platform === "win32" ? [".exe", ".cmd"] : [""];
149
+ }
150
+ function resolveHomeDirectory(input) {
151
+ return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
152
+ }
153
+ function templateVariables(environment, platform, home) {
154
+ const pathFlavor = targetPath(platform);
155
+ return {
156
+ HOME: home,
157
+ USERPROFILE: home,
158
+ APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
159
+ LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
160
+ };
161
+ }
162
+ function joinTemplate(platform, value) {
163
+ const pathFlavor = targetPath(platform);
164
+ const segments = value.split("/");
165
+ const head = segments[0] ?? "";
166
+ const tail = segments.slice(1);
167
+ if (head === "")
168
+ return pathFlavor.join(pathFlavor.sep, ...tail);
169
+ return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
170
+ }
171
+ function expandInstallRoot(template, environment, platform, home) {
172
+ const variables = templateVariables(environment, platform, home);
173
+ let unresolved = false;
174
+ const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
175
+ const value = variables[name] ?? environmentValue(environment, name);
176
+ if (value === void 0 || value === "") {
177
+ unresolved = true;
178
+ return "";
179
+ }
180
+ return value;
181
+ });
182
+ return unresolved ? void 0 : joinTemplate(platform, substituted);
183
+ }
184
+ function installRootDirectories(spec, input, dependencies, platform, home) {
185
+ const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
186
+ const directories = [];
187
+ for (const template of templates) {
188
+ if (template === VERSION_MANAGER_ROOTS) {
189
+ directories.push(...versionManagerBinaryDirectories({
190
+ platform,
191
+ environment: input.environment,
192
+ home,
193
+ ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
194
+ }));
195
+ continue;
196
+ }
197
+ const directory = expandInstallRoot(template, input.environment, platform, home);
198
+ if (directory !== void 0)
199
+ directories.push(directory);
200
+ }
201
+ return directories;
202
+ }
203
+ function harnessCandidates(spec, input, dependencies = {}) {
204
+ const platform = input.platform ?? process.platform;
205
+ const pathFlavor = targetPath(platform);
206
+ const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
207
+ const command = configured ?? spec.command;
208
+ if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
209
+ return [{ candidate: command, source: "configured" }];
210
+ }
211
+ const candidates = [];
212
+ const extensions = executableExtensions(command, platform, input.environment);
213
+ for (const directory of pathDirectories(input.environment, platform)) {
214
+ for (const extension of extensions) {
215
+ candidates.push({
216
+ candidate: pathFlavor.join(directory, command + extension),
217
+ source: "path"
218
+ });
219
+ }
220
+ }
221
+ if (configured !== void 0)
222
+ return candidates;
223
+ const home = resolveHomeDirectory(input);
224
+ for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
225
+ for (const extension of installRootExtensions(platform)) {
226
+ candidates.push({
227
+ candidate: pathFlavor.join(directory, spec.command + extension),
228
+ source: "install-root"
229
+ });
230
+ }
231
+ }
232
+ return candidates;
233
+ }
234
+ function resolveHarnessExecutable(spec, input, dependencies = {}) {
235
+ const platform = input.platform ?? process.platform;
236
+ const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
237
+ const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
238
+ const context = { platform, isExecutable };
239
+ for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
240
+ const executable = runnable(candidate, context);
241
+ if (executable !== void 0 && isExecutable(executable))
242
+ return { executable, source };
243
+ }
244
+ return void 0;
245
+ }
246
+
247
+ // ../../harness-discovery/dist/installation.js
248
+ import { execFile } from "node:child_process";
249
+ import { homedir } from "node:os";
250
+ function runInstallationCommand(command, args, environment, timeout = 3e4) {
251
+ const env = withNodeRuntimeOnPath(environment);
252
+ const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
253
+ return new Promise((resolve, reject) => {
254
+ const child = execFile(invocation.command, invocation.arguments, {
255
+ env,
256
+ cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
257
+ encoding: "utf8",
258
+ timeout,
259
+ killSignal: "SIGKILL",
260
+ maxBuffer: 1024 * 1024,
261
+ windowsHide: true,
262
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
263
+ }, (error51, stdout, stderr) => {
264
+ if (error51)
265
+ reject(new Error(error51.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
266
+ else
267
+ resolve((stdout || stderr).trim());
268
+ });
269
+ child.stdin?.end();
270
+ });
271
+ }
272
+ function installationVersion(value) {
273
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
274
+ throw new Error("Harness returned an invalid version");
275
+ return value.trim().replace(/^v/, "");
276
+ }
277
+ function versionFromOutput(output) {
278
+ return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
279
+ }
280
+ function newerInstallationVersion(current, latest) {
281
+ const a = installationVersion(current).replace(/\+.*/, "");
282
+ const b = installationVersion(latest).replace(/\+.*/, "");
283
+ const coreA = a.replace(/-.*/, "").split(".").map(BigInt);
284
+ const coreB = b.replace(/-.*/, "").split(".").map(BigInt);
285
+ for (let i = 0; i < Math.max(coreA.length, coreB.length); i++) {
286
+ if ((coreA[i] ?? 0n) !== (coreB[i] ?? 0n))
287
+ return (coreB[i] ?? 0n) > (coreA[i] ?? 0n);
288
+ }
289
+ const preA = a.includes("-") ? a.slice(a.indexOf("-") + 1).split(".") : [];
290
+ const preB = b.includes("-") ? b.slice(b.indexOf("-") + 1).split(".") : [];
291
+ if (!preA.length || !preB.length)
292
+ return !!preA.length && !preB.length;
293
+ for (let i = 0; i < Math.max(preA.length, preB.length); i++) {
294
+ const x = preA[i];
295
+ const y = preB[i];
296
+ if (x === y)
297
+ continue;
298
+ if (x === void 0 || y === void 0)
299
+ return x === void 0;
300
+ const numericX = /^\d+$/.test(x);
301
+ const numericY = /^\d+$/.test(y);
302
+ if (numericX && numericY) {
303
+ if (BigInt(x) === BigInt(y))
304
+ continue;
305
+ return BigInt(y) > BigInt(x);
306
+ }
307
+ if (numericX !== numericY)
308
+ return numericX;
309
+ return y > x;
310
+ }
311
+ return false;
312
+ }
313
+ function createInstallationManager(options) {
314
+ let checking;
315
+ let updating;
316
+ const check2 = () => checking ??= options.check().finally(() => {
317
+ checking = void 0;
318
+ });
319
+ return (action) => {
320
+ if (updating)
321
+ return updating;
322
+ if (action === "check")
323
+ return check2();
324
+ updating = (async () => {
325
+ const before = await check2();
326
+ if (!before.updateAvailable)
327
+ return before;
328
+ if (!before.canUpdate)
329
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
330
+ await options.update(before);
331
+ const after = await check2();
332
+ if (after.currentVersion === before.currentVersion)
333
+ throw new Error("The Harness version did not change; check the native updater and retry");
334
+ return after;
335
+ })().finally(() => {
336
+ updating = void 0;
337
+ });
338
+ return updating;
339
+ };
340
+ }
341
+ async function fetchInstallationText(url2) {
342
+ const request = async () => {
343
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
344
+ if (!response.ok)
345
+ throw new Error("Could not check the latest Harness version");
346
+ return response.text();
347
+ };
348
+ try {
349
+ return await request();
350
+ } catch (error51) {
351
+ if (error51 instanceof DOMException && (error51.name === "AbortError" || error51.name === "TimeoutError"))
352
+ throw error51;
353
+ return request();
354
+ }
355
+ }
356
+
357
+ // ../../harness-discovery/dist/installer.js
358
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
359
+ import { tmpdir } from "node:os";
360
+ import { join } from "node:path";
361
+ function createHarnessInstaller(environment, source) {
362
+ return async () => {
363
+ if (!["darwin", "linux", "win32"].includes(process.platform))
364
+ throw new Error("Unsupported installation platform");
365
+ const env = withNodeRuntimeOnPath(environment);
366
+ if ("npm" in source) {
367
+ const npm = resolveHarnessExecutable({
368
+ id: "npm",
369
+ command: "npm",
370
+ installRoots: {
371
+ posix: [
372
+ "~/.npm-global/bin",
373
+ "~/.local/bin",
374
+ VERSION_MANAGER_ROOTS,
375
+ "/opt/homebrew/bin",
376
+ "/usr/local/bin",
377
+ "/usr/bin"
378
+ ],
379
+ windows: [
380
+ "${APPDATA}/npm",
381
+ VERSION_MANAGER_ROOTS,
382
+ "${ProgramFiles}/nodejs",
383
+ "${LOCALAPPDATA}/Programs/nodejs"
384
+ ]
385
+ }
386
+ }, { environment: env });
387
+ if (!npm)
388
+ throw new Error("Install Node.js and npm first");
389
+ await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
390
+ ...env,
391
+ ...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
392
+ }, 6e5);
393
+ return;
394
+ }
395
+ const windows = process.platform === "win32";
396
+ const url2 = windows ? source.windows : source.posix;
397
+ if (new URL(url2).protocol !== "https:")
398
+ throw new Error("Installer requires HTTPS");
399
+ const script = await fetchInstallationText(url2);
400
+ const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
401
+ try {
402
+ const file2 = join(directory, windows ? "install.ps1" : "install.sh");
403
+ await writeFile(file2, script, { mode: 384 });
404
+ await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
405
+ } finally {
406
+ await rm(directory, { recursive: true, force: true });
407
+ }
408
+ };
409
+ }
410
+
8
411
  // ../../../node_modules/diff/libesm/diff/base.js
9
412
  var Diff = class {
10
413
  diff(oldStr, newStr, options = {}) {
@@ -105,16 +508,16 @@ var Diff = class {
105
508
  }
106
509
  }
107
510
  }
108
- addToPath(path5, added, removed, oldPosInc, options) {
109
- const last = path5.lastComponent;
511
+ addToPath(path7, added, removed, oldPosInc, options) {
512
+ const last = path7.lastComponent;
110
513
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
111
514
  return {
112
- oldPos: path5.oldPos + oldPosInc,
515
+ oldPos: path7.oldPos + oldPosInc,
113
516
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
114
517
  };
115
518
  } else {
116
519
  return {
117
- oldPos: path5.oldPos + oldPosInc,
520
+ oldPos: path7.oldPos + oldPosInc,
118
521
  lastComponent: { count: 1, added, removed, previousComponent: last }
119
522
  };
120
523
  }
@@ -528,7 +931,7 @@ function splitLines(text) {
528
931
  // dist/omp-adapter.js
529
932
  import { randomUUID as randomUUID2 } from "node:crypto";
530
933
  import { realpath as realpath2, stat } from "node:fs/promises";
531
- import path4 from "node:path";
934
+ import path5 from "node:path";
532
935
 
533
936
  // ../../../node_modules/zod/v4/classic/external.js
534
937
  var external_exports = {};
@@ -1296,10 +1699,10 @@ function mergeDefs(...defs) {
1296
1699
  function cloneDef(schema) {
1297
1700
  return mergeDefs(schema._zod.def);
1298
1701
  }
1299
- function getElementAtPath(obj, path5) {
1300
- if (!path5)
1702
+ function getElementAtPath(obj, path7) {
1703
+ if (!path7)
1301
1704
  return obj;
1302
- return path5.reduce((acc, key) => acc?.[key], obj);
1705
+ return path7.reduce((acc, key) => acc?.[key], obj);
1303
1706
  }
1304
1707
  function promiseAllObject(promisesObj) {
1305
1708
  const keys = Object.keys(promisesObj);
@@ -1708,11 +2111,11 @@ function explicitlyAborted(x, startIndex = 0) {
1708
2111
  }
1709
2112
  return false;
1710
2113
  }
1711
- function prefixIssues(path5, issues) {
2114
+ function prefixIssues(path7, issues) {
1712
2115
  return issues.map((iss) => {
1713
2116
  var _a3;
1714
2117
  (_a3 = iss).path ?? (_a3.path = []);
1715
- iss.path.unshift(path5);
2118
+ iss.path.unshift(path7);
1716
2119
  return iss;
1717
2120
  });
1718
2121
  }
@@ -1859,16 +2262,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1859
2262
  }
1860
2263
  function formatError(error51, mapper = (issue2) => issue2.message) {
1861
2264
  const fieldErrors = { _errors: [] };
1862
- const processError = (error52, path5 = []) => {
2265
+ const processError = (error52, path7 = []) => {
1863
2266
  for (const issue2 of error52.issues) {
1864
2267
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1865
- issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
2268
+ issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
1866
2269
  } else if (issue2.code === "invalid_key") {
1867
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
2270
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
1868
2271
  } else if (issue2.code === "invalid_element") {
1869
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
2272
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
1870
2273
  } else {
1871
- const fullpath = [...path5, ...issue2.path];
2274
+ const fullpath = [...path7, ...issue2.path];
1872
2275
  if (fullpath.length === 0) {
1873
2276
  fieldErrors._errors.push(mapper(issue2));
1874
2277
  } else {
@@ -1895,17 +2298,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1895
2298
  }
1896
2299
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1897
2300
  const result = { errors: [] };
1898
- const processError = (error52, path5 = []) => {
2301
+ const processError = (error52, path7 = []) => {
1899
2302
  var _a3, _b;
1900
2303
  for (const issue2 of error52.issues) {
1901
2304
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1902
- issue2.errors.map((issues) => processError({ issues }, [...path5, ...issue2.path]));
2305
+ issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
1903
2306
  } else if (issue2.code === "invalid_key") {
1904
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
2307
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
1905
2308
  } else if (issue2.code === "invalid_element") {
1906
- processError({ issues: issue2.issues }, [...path5, ...issue2.path]);
2309
+ processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
1907
2310
  } else {
1908
- const fullpath = [...path5, ...issue2.path];
2311
+ const fullpath = [...path7, ...issue2.path];
1909
2312
  if (fullpath.length === 0) {
1910
2313
  result.errors.push(mapper(issue2));
1911
2314
  continue;
@@ -1937,8 +2340,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1937
2340
  }
1938
2341
  function toDotPath(_path) {
1939
2342
  const segs = [];
1940
- const path5 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1941
- for (const seg of path5) {
2343
+ const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2344
+ for (const seg of path7) {
1942
2345
  if (typeof seg === "number")
1943
2346
  segs.push(`[${seg}]`);
1944
2347
  else if (typeof seg === "symbol")
@@ -14630,13 +15033,13 @@ function resolveRef(ref, ctx) {
14630
15033
  if (!ref.startsWith("#")) {
14631
15034
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14632
15035
  }
14633
- const path5 = ref.slice(1).split("/").filter(Boolean);
14634
- if (path5.length === 0) {
15036
+ const path7 = ref.slice(1).split("/").filter(Boolean);
15037
+ if (path7.length === 0) {
14635
15038
  return ctx.rootSchema;
14636
15039
  }
14637
15040
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14638
- if (path5[0] === defsKey) {
14639
- const key = path5[1];
15041
+ if (path7[0] === defsKey) {
15042
+ const key = path7[1];
14640
15043
  if (!key || !ctx.defs[key]) {
14641
15044
  throw new Error(`Reference not found: ${ref}`);
14642
15045
  }
@@ -15099,6 +15502,123 @@ var credentialImportsParamsSchema = external_exports.object({
15099
15502
  request: credentialImportsRequestSchema
15100
15503
  }).strict();
15101
15504
 
15505
+ // ../../shared-contracts/dist/harness-display-settings.js
15506
+ var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
15507
+ agent: external_exports.string().min(1).max(128),
15508
+ section: external_exports.enum(["main", "more", "auto"])
15509
+ })).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
15510
+ var harnessDisplaySettingsSchema = external_exports.strictObject({
15511
+ entries: harnessDisplayEntriesSchema.nullable()
15512
+ });
15513
+ var harnessDisplayGetSchema = external_exports.strictObject({});
15514
+ var harnessDisplaySetSchema = external_exports.strictObject({
15515
+ entries: harnessDisplayEntriesSchema,
15516
+ /** Import legacy Desktop preferences only if no shared settings exist yet. */
15517
+ initializeOnly: external_exports.boolean().optional()
15518
+ });
15519
+
15520
+ // ../../shared-contracts/dist/ids.js
15521
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15522
+ message: "Identifier must not be empty or whitespace"
15523
+ });
15524
+ var harnessIdSchema = opaqueIdSchema.brand();
15525
+ var hostThreadIdSchema = opaqueIdSchema.brand();
15526
+ var hostTurnIdSchema = opaqueIdSchema.brand();
15527
+ var hostItemIdSchema = opaqueIdSchema.brand();
15528
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
15529
+
15530
+ // ../../shared-contracts/dist/harness-plugins.js
15531
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15532
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15533
+ var HARNESS_PLUGIN_LIMIT = 128;
15534
+ 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);
15535
+ 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");
15536
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15537
+ var pluginPresentationShape = {
15538
+ id: harnessPluginIdSchema,
15539
+ name: external_exports.string().trim().min(1).max(128),
15540
+ version: external_exports.string().min(1).max(128),
15541
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15542
+ launchCommand: external_exports.literal(true).optional(),
15543
+ links: external_exports.object({
15544
+ documentation: documentationUrlSchema.optional(),
15545
+ installation: documentationUrlSchema.optional()
15546
+ }).strict().optional()
15547
+ };
15548
+ var harnessPluginManifestSchema = external_exports.object({
15549
+ manifestVersion: external_exports.literal(1),
15550
+ ...pluginPresentationShape,
15551
+ adapterApiVersion: external_exports.number().int().positive(),
15552
+ entry: relativeResourceSchema,
15553
+ icon: relativeResourceSchema.optional()
15554
+ }).strict();
15555
+ 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);
15556
+ var harnessPluginDescriptorSchema = external_exports.object({
15557
+ ...pluginPresentationShape,
15558
+ icon: harnessPluginIconSchema.optional()
15559
+ }).strict();
15560
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15561
+ var harnessPluginListResultSchema = external_exports.object({
15562
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15563
+ }).strict();
15564
+ var harnessPluginConfigurationSchema = external_exports.object({
15565
+ version: external_exports.literal(1),
15566
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15567
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15568
+ message: "Enabled plugin IDs must be unique",
15569
+ path: ["enabled"]
15570
+ });
15571
+
15572
+ // ../../shared-contracts/dist/harness-long-context.js
15573
+ var HARNESS_LONG_CONTEXT_GET_METHOD = "codexhost/harness/long-context/get";
15574
+ var HARNESS_LONG_CONTEXT_SET_METHOD = "codexhost/harness/long-context/set";
15575
+ var harnessLongContextGetSchema = external_exports.object({
15576
+ harnessId: harnessPluginIdSchema
15577
+ }).strict();
15578
+ var harnessLongContextSetSchema = harnessLongContextGetSchema.extend({
15579
+ enabled: external_exports.boolean()
15580
+ });
15581
+ var harnessLongContextSchema = external_exports.object({
15582
+ enabled: external_exports.boolean()
15583
+ }).strict();
15584
+
15585
+ // ../../shared-contracts/dist/console.js
15586
+ var consoleAnnouncementSchema = external_exports.strictObject({
15587
+ title: external_exports.string().trim().min(1).max(200),
15588
+ type: external_exports.enum(["info", "warning", "danger"]),
15589
+ body: external_exports.string().trim().min(1).max(16 * 1024)
15590
+ });
15591
+ var consoleOpenParamsSchema = external_exports.strictObject({});
15592
+ var consoleOpenResultSchema = external_exports.strictObject({
15593
+ /** The console address. */
15594
+ url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15595
+ });
15596
+ var CONSOLE_HOST_METHODS = Object.freeze([
15597
+ "codexhost/harness/plugins/list",
15598
+ "codexhost/harness/display-settings/get",
15599
+ "codexhost/harness/display-settings/set",
15600
+ "codexhost/harness/inspect",
15601
+ "codexhost/harness/installation",
15602
+ "codexhost/harness/launch-settings/get",
15603
+ "codexhost/harness/launch-settings/set",
15604
+ HARNESS_LONG_CONTEXT_GET_METHOD,
15605
+ HARNESS_LONG_CONTEXT_SET_METHOD,
15606
+ "codexhost/harness/web-ui/open",
15607
+ "codexhost/harness/accounts/sources",
15608
+ "codexhost/harness/accounts/list",
15609
+ "codexhost/harness/accounts/inspect",
15610
+ "codexhost/harness/credential-imports",
15611
+ "codexhost/harness/session-import/sources",
15612
+ "codexhost/harness/session-import/list",
15613
+ "codexhost/harness/session-import/import",
15614
+ "codexhost/account/list",
15615
+ "codexhost/account/refresh",
15616
+ "codexhost/account/usage/inspect",
15617
+ "codexhost/update/check",
15618
+ "codexhost/update/start",
15619
+ "codexhost/update/status"
15620
+ ]);
15621
+
15102
15622
  // ../../shared-contracts/dist/version.js
15103
15623
  var WORKSPACE_CONTRACT_VERSION = 1;
15104
15624
 
@@ -15142,15 +15662,11 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
15142
15662
  inactiveMs: external_exports.number().nonnegative()
15143
15663
  }));
15144
15664
 
15145
- // ../../shared-contracts/dist/ids.js
15146
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15147
- message: "Identifier must not be empty or whitespace"
15665
+ // ../../shared-contracts/dist/manual-compaction.js
15666
+ var threadManualCompactionStartedSchema = external_exports.strictObject({
15667
+ threadId: hostThreadIdSchema,
15668
+ turnId: hostTurnIdSchema
15148
15669
  });
15149
- var harnessIdSchema = opaqueIdSchema.brand();
15150
- var hostThreadIdSchema = opaqueIdSchema.brand();
15151
- var hostTurnIdSchema = opaqueIdSchema.brand();
15152
- var hostItemIdSchema = opaqueIdSchema.brand();
15153
- var hostInteractionIdSchema = opaqueIdSchema.brand();
15154
15670
 
15155
15671
  // ../../shared-contracts/dist/thread-usage.js
15156
15672
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
@@ -15212,6 +15728,10 @@ var threadUsageSnapshotSchema = external_exports.object({
15212
15728
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
15213
15729
  var accountCreditsProductUsageSchema = external_exports.object({
15214
15730
  product: external_exports.string().min(1),
15731
+ used: external_exports.number().finite().nonnegative().optional(),
15732
+ // Zero is a real empty cap, not an absent field.
15733
+ limit: external_exports.number().finite().nonnegative().optional(),
15734
+ unit: external_exports.string().min(1).max(32).optional(),
15215
15735
  usagePercent: usagePercentSchema,
15216
15736
  resetsAt: external_exports.string().min(1).optional()
15217
15737
  }).strict();
@@ -15221,11 +15741,14 @@ var accountResetCreditsSchema = external_exports.object({
15221
15741
  expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
15222
15742
  }).strict();
15223
15743
  var accountCreditsSnapshotSchema = external_exports.object({
15744
+ used: external_exports.number().finite().nonnegative().optional(),
15745
+ // Zero is a real empty cap, not an absent field.
15746
+ limit: external_exports.number().finite().nonnegative().optional(),
15747
+ unit: external_exports.string().trim().min(1).max(32).optional(),
15224
15748
  /** Native label when the primary limit is scoped to a model or product group. */
15225
15749
  label: external_exports.string().min(1).optional(),
15226
15750
  usedPercent: usagePercentSchema.optional(),
15227
15751
  remaining: external_exports.number().finite().optional(),
15228
- unit: external_exports.string().trim().min(1).max(32).optional(),
15229
15752
  resetsAt: external_exports.string().min(1).optional(),
15230
15753
  periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
15231
15754
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
@@ -15256,12 +15779,27 @@ var threadUsageInspectionSchema = external_exports.object({
15256
15779
  }).strict();
15257
15780
 
15258
15781
  // ../../shared-contracts/dist/harness-accounts.js
15259
- var harnessAccountSnapshotSchema = external_exports.object({
15782
+ var accountBalanceSnapshotSchema = external_exports.object({
15783
+ amount: external_exports.number().finite().nonnegative(),
15784
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
15785
+ currency: external_exports.string().trim().min(1).max(8),
15786
+ /** Native label when the Harness exposes several Billing Sources. */
15787
+ label: external_exports.string().trim().min(1).max(128).optional()
15788
+ }).strict();
15789
+ var harnessAccountSnapshotObject = external_exports.object({
15260
15790
  email: external_exports.string().trim().min(1).max(320).optional(),
15261
15791
  label: external_exports.string().trim().min(1).max(256).optional(),
15262
15792
  plan: external_exports.string().trim().min(1).max(128).optional(),
15263
- credits: accountCreditsSnapshotSchema
15793
+ credits: accountCreditsSnapshotSchema.optional(),
15794
+ balance: accountBalanceSnapshotSchema.optional()
15264
15795
  }).strict();
15796
+ function requireReportedQuota(schema) {
15797
+ return schema.refine((value) => {
15798
+ const reported = value;
15799
+ return reported.credits !== void 0 || reported.balance !== void 0;
15800
+ }, { message: "Account must report either credits or a balance" });
15801
+ }
15802
+ var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
15265
15803
  var harnessAccountIdentityShape = {
15266
15804
  harnessId: harnessIdSchema,
15267
15805
  harnessName: external_exports.string().trim().min(1).max(128)
@@ -15272,11 +15810,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
15272
15810
  var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
15273
15811
  var harnessAccountInspectResultSchema = external_exports.object({
15274
15812
  ...harnessAccountIdentityShape,
15275
- account: harnessAccountSnapshotSchema.nullable()
15813
+ account: harnessAccountSnapshotSchema.nullable(),
15814
+ /** Every Billing Source from one Harness; `account` remains the first for older clients. */
15815
+ accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
15276
15816
  }).strict();
15277
15817
  var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
15278
15818
  var harnessAccountListResultSchema = external_exports.object({
15279
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend(harnessAccountIdentityShape)).max(128)
15819
+ accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
15280
15820
  }).strict();
15281
15821
 
15282
15822
  // ../../shared-contracts/dist/json-value.js
@@ -15414,6 +15954,8 @@ var harnessModelSchema = external_exports.object({
15414
15954
  ref: harnessModelRefSchema,
15415
15955
  label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
15416
15956
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15957
+ /** Optional opaque selection for this same Model with priority processing enabled. */
15958
+ fastModel: harnessModelRefSchema.optional(),
15417
15959
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
15418
15960
  }).strict();
15419
15961
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
@@ -15446,6 +15988,16 @@ var harnessModelCatalogSchema = external_exports.object({
15446
15988
  });
15447
15989
  }
15448
15990
  refs.add(model.ref.id);
15991
+ if (model.fastModel) {
15992
+ if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
15993
+ context.addIssue({
15994
+ code: "custom",
15995
+ message: "Fast Model refs must be distinct and unique",
15996
+ path: ["models", index, "fastModel"]
15997
+ });
15998
+ }
15999
+ refs.add(model.fastModel.id);
16000
+ }
15449
16001
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15450
16002
  for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
15451
16003
  if (supportedThinkingIds.has(optionId)) {
@@ -15568,11 +16120,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
15568
16120
  thinkingOptionId: harnessThinkingOptionIdSchema
15569
16121
  }).strict();
15570
16122
  var threadInspectionParamsSchema = external_exports.object({
15571
- threadId: hostThreadIdSchema
16123
+ threadId: hostThreadIdSchema,
16124
+ includeReferenceCapability: external_exports.boolean().optional()
15572
16125
  }).strict();
15573
16126
  var codexThreadInspectionSchema = external_exports.object({
15574
16127
  owner: external_exports.literal("codex"),
15575
- locked: external_exports.literal(true)
16128
+ locked: external_exports.literal(true),
16129
+ supportsThreadReferences: external_exports.literal(true).optional()
15576
16130
  }).strict();
15577
16131
  var externalThreadInspectionSchema = external_exports.object({
15578
16132
  owner: external_exports.literal("external"),
@@ -15618,65 +16172,23 @@ var externalThreadOwnershipSchema = external_exports.object({
15618
16172
  harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15619
16173
  }).strict();
15620
16174
  var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15621
- codexThreadOwnershipSchema,
15622
- externalThreadOwnershipSchema
15623
- ]);
15624
- var threadOwnershipListResultSchema = external_exports.object({
15625
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15626
- }).strict().superRefine(({ threads }, context) => {
15627
- const seen = /* @__PURE__ */ new Set();
15628
- for (const [index, thread] of threads.entries()) {
15629
- if (seen.has(thread.threadId)) {
15630
- context.addIssue({
15631
- code: "custom",
15632
- message: "Thread ownership-list results must be unique",
15633
- path: ["threads", index, "threadId"]
15634
- });
15635
- }
15636
- seen.add(thread.threadId);
15637
- }
15638
- });
15639
-
15640
- // ../../shared-contracts/dist/harness-plugins.js
15641
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15642
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15643
- var HARNESS_PLUGIN_LIMIT = 128;
15644
- 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);
15645
- 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");
15646
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15647
- var pluginPresentationShape = {
15648
- id: harnessPluginIdSchema,
15649
- name: external_exports.string().trim().min(1).max(128),
15650
- version: external_exports.string().min(1).max(128),
15651
- /** The factory accepts a persisted local entrypoint through its construction context. */
15652
- launchCommand: external_exports.literal(true).optional(),
15653
- links: external_exports.object({
15654
- documentation: documentationUrlSchema.optional(),
15655
- installation: documentationUrlSchema.optional()
15656
- }).strict().optional()
15657
- };
15658
- var harnessPluginManifestSchema = external_exports.object({
15659
- manifestVersion: external_exports.literal(1),
15660
- ...pluginPresentationShape,
15661
- adapterApiVersion: external_exports.number().int().positive(),
15662
- entry: relativeResourceSchema,
15663
- icon: relativeResourceSchema.optional()
15664
- }).strict();
15665
- 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);
15666
- var harnessPluginDescriptorSchema = external_exports.object({
15667
- ...pluginPresentationShape,
15668
- icon: harnessPluginIconSchema.optional()
15669
- }).strict();
15670
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
15671
- var harnessPluginListResultSchema = external_exports.object({
15672
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
15673
- }).strict();
15674
- var harnessPluginConfigurationSchema = external_exports.object({
15675
- version: external_exports.literal(1),
15676
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15677
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15678
- message: "Enabled plugin IDs must be unique",
15679
- path: ["enabled"]
16175
+ codexThreadOwnershipSchema,
16176
+ externalThreadOwnershipSchema
16177
+ ]);
16178
+ var threadOwnershipListResultSchema = external_exports.object({
16179
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
16180
+ }).strict().superRefine(({ threads }, context) => {
16181
+ const seen = /* @__PURE__ */ new Set();
16182
+ for (const [index, thread] of threads.entries()) {
16183
+ if (seen.has(thread.threadId)) {
16184
+ context.addIssue({
16185
+ code: "custom",
16186
+ message: "Thread ownership-list results must be unique",
16187
+ path: ["threads", index, "threadId"]
16188
+ });
16189
+ }
16190
+ seen.add(thread.threadId);
16191
+ }
15680
16192
  });
15681
16193
 
15682
16194
  // ../../shared-contracts/dist/harness-route.js
@@ -15700,10 +16212,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
15700
16212
  restartRequired: external_exports.boolean()
15701
16213
  }).strict();
15702
16214
 
16215
+ // ../../shared-contracts/dist/harness-installation.js
16216
+ var harnessInstallationParamsSchema = external_exports.object({
16217
+ harnessId: harnessIdSchema,
16218
+ action: external_exports.enum(["check", "update", "install"])
16219
+ }).strict();
16220
+ var harnessInstallationStateSchema = external_exports.object({
16221
+ currentVersion: external_exports.string().min(1).max(128),
16222
+ latestVersion: external_exports.string().min(1).max(128),
16223
+ updateAvailable: external_exports.boolean(),
16224
+ canUpdate: external_exports.boolean(),
16225
+ message: external_exports.string().max(2048).optional()
16226
+ }).strict();
16227
+
15703
16228
  // ../../shared-contracts/dist/codex-accounts.js
15704
16229
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
15705
16230
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
15706
16231
  var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
16232
+ var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
16233
+ function isCodexAccountSiteUrl(value) {
16234
+ return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
16235
+ }
16236
+ var externalUrlOpenParamsSchema = external_exports.object({
16237
+ url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
16238
+ }).strict();
16239
+ var externalUrlOpenResultSchema = external_exports.object({}).strict();
15707
16240
  var codexAccountPlanTypeSchema = external_exports.enum([
15708
16241
  "free",
15709
16242
  "go",
@@ -15729,7 +16262,8 @@ var codexAccountSchema = external_exports.object({
15729
16262
  email: external_exports.string().email().max(320).optional(),
15730
16263
  planType: codexAccountPlanTypeSchema.optional(),
15731
16264
  authKind: codexAccountAuthKindSchema.optional(),
15732
- authIdentity: nonBlankTextSchema3.max(256).optional()
16265
+ authIdentity: nonBlankTextSchema3.max(256).optional(),
16266
+ siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
15733
16267
  }).strict();
15734
16268
  var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
15735
16269
  var codexAccountListResultSchema = external_exports.object({
@@ -16886,230 +17420,7 @@ async function rollbackOmpLastTurn(transport, sourceSessionId, cwd) {
16886
17420
  // dist/omp-rpc-session.js
16887
17421
  import { spawn, spawnSync } from "node:child_process";
16888
17422
  import { randomUUID } from "node:crypto";
16889
- import path3 from "node:path";
16890
-
16891
- // ../../harness-discovery/dist/environment.js
16892
- import fs from "node:fs";
16893
- import path from "node:path";
16894
- function targetPath(platform) {
16895
- return platform === "win32" ? path.win32 : path.posix;
16896
- }
16897
- function environmentValue(environment, name) {
16898
- const lowered = name.toLowerCase();
16899
- for (const [key, value] of Object.entries(environment)) {
16900
- if (key.toLowerCase() === lowered)
16901
- return value;
16902
- }
16903
- return void 0;
16904
- }
16905
- function pathDelimiter(platform) {
16906
- return platform === "win32" ? ";" : ":";
16907
- }
16908
- function pathDirectories(environment, platform) {
16909
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
16910
- }
16911
- function executableExtensions(command, platform, environment) {
16912
- if (platform !== "win32")
16913
- return [""];
16914
- if (targetPath(platform).extname(command) !== "")
16915
- return [""];
16916
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
16917
- }
16918
- function isExecutableFile(filePath, platform) {
16919
- try {
16920
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
16921
- return fs.statSync(filePath).isFile();
16922
- } catch {
16923
- return false;
16924
- }
16925
- }
16926
- function subdirectoryNames(directory) {
16927
- try {
16928
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
16929
- } catch {
16930
- return [];
16931
- }
16932
- }
16933
- function newestFirst(names) {
16934
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
16935
- }
16936
-
16937
- // ../../harness-discovery/dist/node-runtime.js
16938
- import path2 from "node:path";
16939
- function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
16940
- const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
16941
- const delimiter = platform === "win32" ? ";" : ":";
16942
- const runtimeDirectory = path2.dirname(runtimeExecutable);
16943
- const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
16944
- const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
16945
- if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
16946
- directories.push(runtimeDirectory);
16947
- }
16948
- return { ...environment, [pathKey]: directories.join(delimiter) };
16949
- }
16950
-
16951
- // ../../harness-discovery/dist/resolve.js
16952
- import os from "node:os";
16953
-
16954
- // ../../harness-discovery/dist/version-managers.js
16955
- function versionManagerBinaryDirectories(context) {
16956
- const { platform, environment, home } = context;
16957
- const list = context.subdirectories ?? subdirectoryNames;
16958
- const pathFlavor = targetPath(platform);
16959
- const value = (name) => environmentValue(environment, name);
16960
- const directories = [];
16961
- const versioned = (root, ...tail) => {
16962
- for (const version2 of newestFirst(list(root))) {
16963
- directories.push(pathFlavor.join(root, version2, ...tail));
16964
- }
16965
- };
16966
- if (platform === "win32") {
16967
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
16968
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
16969
- versioned(pathFlavor.join(appData, "nvm"));
16970
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
16971
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
16972
- directories.push(pathFlavor.join(home, ".bun", "bin"));
16973
- const pnpmHome2 = value("PNPM_HOME");
16974
- if (pnpmHome2)
16975
- directories.push(pnpmHome2);
16976
- directories.push(pathFlavor.join(localAppData, "pnpm"));
16977
- return directories;
16978
- }
16979
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
16980
- const fnmRoots = [
16981
- value("FNM_DIR"),
16982
- pathFlavor.join(home, ".local", "share", "fnm"),
16983
- pathFlavor.join(home, "Library", "Application Support", "fnm")
16984
- ].filter((root) => root !== void 0);
16985
- for (const root of fnmRoots) {
16986
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
16987
- }
16988
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
16989
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
16990
- directories.push(pathFlavor.join(voltaHome, "bin"));
16991
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
16992
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
16993
- directories.push(pathFlavor.join(asdfHome, "shims"));
16994
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
16995
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
16996
- directories.push(pathFlavor.join(nodenvHome, "shims"));
16997
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
16998
- directories.push(pathFlavor.join(home, ".bun", "bin"));
16999
- const pnpmHome = value("PNPM_HOME");
17000
- if (pnpmHome)
17001
- directories.push(pnpmHome);
17002
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
17003
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
17004
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
17005
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
17006
- directories.push(pathFlavor.join(prefix, formula, "bin"));
17007
- }
17008
- }
17009
- return directories;
17010
- }
17011
-
17012
- // ../../harness-discovery/dist/resolve.js
17013
- var VERSION_MANAGER_ROOTS = "<version-managers>";
17014
- function installRootExtensions(platform) {
17015
- return platform === "win32" ? [".exe", ".cmd"] : [""];
17016
- }
17017
- function resolveHomeDirectory(input) {
17018
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
17019
- }
17020
- function templateVariables(environment, platform, home) {
17021
- const pathFlavor = targetPath(platform);
17022
- return {
17023
- HOME: home,
17024
- USERPROFILE: home,
17025
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
17026
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
17027
- };
17028
- }
17029
- function joinTemplate(platform, value) {
17030
- const pathFlavor = targetPath(platform);
17031
- const segments = value.split("/");
17032
- const head = segments[0] ?? "";
17033
- const tail = segments.slice(1);
17034
- if (head === "")
17035
- return pathFlavor.join(pathFlavor.sep, ...tail);
17036
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
17037
- }
17038
- function expandInstallRoot(template, environment, platform, home) {
17039
- const variables = templateVariables(environment, platform, home);
17040
- let unresolved = false;
17041
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
17042
- const value = variables[name] ?? environmentValue(environment, name);
17043
- if (value === void 0 || value === "") {
17044
- unresolved = true;
17045
- return "";
17046
- }
17047
- return value;
17048
- });
17049
- return unresolved ? void 0 : joinTemplate(platform, substituted);
17050
- }
17051
- function installRootDirectories(spec, input, dependencies, platform, home) {
17052
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
17053
- const directories = [];
17054
- for (const template of templates) {
17055
- if (template === VERSION_MANAGER_ROOTS) {
17056
- directories.push(...versionManagerBinaryDirectories({
17057
- platform,
17058
- environment: input.environment,
17059
- home,
17060
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
17061
- }));
17062
- continue;
17063
- }
17064
- const directory = expandInstallRoot(template, input.environment, platform, home);
17065
- if (directory !== void 0)
17066
- directories.push(directory);
17067
- }
17068
- return directories;
17069
- }
17070
- function harnessCandidates(spec, input, dependencies = {}) {
17071
- const platform = input.platform ?? process.platform;
17072
- const pathFlavor = targetPath(platform);
17073
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
17074
- const command = configured ?? spec.command;
17075
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
17076
- return [{ candidate: command, source: "configured" }];
17077
- }
17078
- const candidates = [];
17079
- const extensions = executableExtensions(command, platform, input.environment);
17080
- for (const directory of pathDirectories(input.environment, platform)) {
17081
- for (const extension of extensions) {
17082
- candidates.push({
17083
- candidate: pathFlavor.join(directory, command + extension),
17084
- source: "path"
17085
- });
17086
- }
17087
- }
17088
- if (configured !== void 0)
17089
- return candidates;
17090
- const home = resolveHomeDirectory(input);
17091
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
17092
- for (const extension of installRootExtensions(platform)) {
17093
- candidates.push({
17094
- candidate: pathFlavor.join(directory, spec.command + extension),
17095
- source: "install-root"
17096
- });
17097
- }
17098
- }
17099
- return candidates;
17100
- }
17101
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
17102
- const platform = input.platform ?? process.platform;
17103
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
17104
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
17105
- const context = { platform, isExecutable };
17106
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
17107
- const executable = runnable(candidate, context);
17108
- if (executable !== void 0 && isExecutable(executable))
17109
- return { executable, source };
17110
- }
17111
- return void 0;
17112
- }
17423
+ import path4 from "node:path";
17113
17424
 
17114
17425
  // dist/command.js
17115
17426
  var ompDiscoverySpec = {
@@ -17483,7 +17794,7 @@ function ompRpcProcessCommand(options, dependencies = {}) {
17483
17794
  ...modelArguments,
17484
17795
  ...sessionArguments
17485
17796
  ];
17486
- const extension = path3.win32.extname(command).toLowerCase();
17797
+ const extension = path4.win32.extname(command).toLowerCase();
17487
17798
  if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
17488
17799
  return { command, arguments: arguments_, windowsVerbatimArguments: false };
17489
17800
  }
@@ -18755,7 +19066,7 @@ function subagentTranscriptPath(parentSessionFile, nativeSubagentId) {
18755
19066
  if (nativeSubagentId.includes("/") || nativeSubagentId.includes("\\") || nativeSubagentId.includes("\0") || nativeSubagentId === "." || nativeSubagentId === "..") {
18756
19067
  throw new Error("Omp Subagent ID is not a plain transcript file name");
18757
19068
  }
18758
- if (!parentSessionFile.endsWith(".jsonl") || !path4.isAbsolute(parentSessionFile)) {
19069
+ if (!parentSessionFile.endsWith(".jsonl") || !path5.isAbsolute(parentSessionFile)) {
18759
19070
  return null;
18760
19071
  }
18761
19072
  return `${parentSessionFile.slice(0, -".jsonl".length)}/${nativeSubagentId}.jsonl`;
@@ -18764,7 +19075,7 @@ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
18764
19075
  const transcriptFile = subagentTranscriptPath(parentSessionFile, nativeSubagentId);
18765
19076
  if (transcriptFile === null)
18766
19077
  return { status: "missing" };
18767
- const parentDirectory = path4.dirname(transcriptFile);
19078
+ const parentDirectory = path5.dirname(transcriptFile);
18768
19079
  let metadata;
18769
19080
  try {
18770
19081
  metadata = await stat(transcriptFile);
@@ -18782,7 +19093,7 @@ async function readSubagentTranscriptFile(parentSessionFile, nativeSubagentId) {
18782
19093
  realpath2(transcriptFile),
18783
19094
  realpath2(parentDirectory)
18784
19095
  ]);
18785
- if (path4.dirname(resolvedTranscript) !== resolvedParentDirectory) {
19096
+ if (path5.dirname(resolvedTranscript) !== resolvedParentDirectory) {
18786
19097
  throw new Error("Omp Subagent transcript resolves outside its parent Session directory");
18787
19098
  }
18788
19099
  return {
@@ -18847,10 +19158,10 @@ function stripDiffPrefix(pathString) {
18847
19158
  return pathString.startsWith("a/") || pathString.startsWith("b/") ? pathString.slice(2) : pathString;
18848
19159
  }
18849
19160
  function displayPath(nativePath, cwd) {
18850
- const resolvedCwd = path4.resolve(cwd);
18851
- const resolvedPath = path4.isAbsolute(nativePath) ? path4.resolve(nativePath) : path4.resolve(cwd, nativePath);
18852
- const relative = path4.relative(resolvedCwd, resolvedPath);
18853
- const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path4.sep}`);
19161
+ const resolvedCwd = path5.resolve(cwd);
19162
+ const resolvedPath = path5.isAbsolute(nativePath) ? path5.resolve(nativePath) : path5.resolve(cwd, nativePath);
19163
+ const relative = path5.relative(resolvedCwd, resolvedPath);
19164
+ const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path5.sep}`);
18854
19165
  const selected = inside ? relative : resolvedPath;
18855
19166
  const normalized = selected.replaceAll("\\", "/");
18856
19167
  if (normalized.length === 0 || normalized === ".")
@@ -20710,13 +21021,57 @@ var OmpAdapter = class {
20710
21021
  }
20711
21022
  };
20712
21023
 
21024
+ // dist/installation.js
21025
+ import { realpath as realpath3 } from "node:fs/promises";
21026
+ import path6 from "node:path";
21027
+ function createOmpInstallation(environment, command) {
21028
+ let executable;
21029
+ let env;
21030
+ return createInstallationManager({
21031
+ async check() {
21032
+ executable = resolveOmpExecutable({ environment, ...command ? { command } : {} });
21033
+ const selected = await realpath3(executable);
21034
+ const pathKey = Object.keys(environment).find((key) => key.toLowerCase() === "path") ?? "PATH";
21035
+ env = {
21036
+ ...environment,
21037
+ [pathKey]: `${path6.dirname(executable)}${path6.delimiter}${environment[pathKey] ?? ""}`
21038
+ };
21039
+ const target = resolveHarnessExecutable({ id: "omp", command: "omp", installRoots: { posix: [], windows: [] } }, { environment: env });
21040
+ const canUpdate = !selected.includes("/nix/store/") && !!target && await realpath3(target.executable) === selected;
21041
+ const output = await runInstallationCommand(executable, ["update", "--check"], env);
21042
+ const currentVersion = versionFromOutput(output);
21043
+ const available = output.match(/New version available:\s*(\S+)/i);
21044
+ if (!available && !/already up to date/i.test(output))
21045
+ throw new Error("OMP update check returned an unknown response");
21046
+ const latestVersion = available ? installationVersion(available[1]) : currentVersion;
21047
+ return {
21048
+ currentVersion,
21049
+ latestVersion,
21050
+ updateAvailable: newerInstallationVersion(currentVersion, latestVersion),
21051
+ canUpdate,
21052
+ ...!canUpdate ? { message: "Update this installation with its original package manager or launcher." } : {}
21053
+ };
21054
+ },
21055
+ async update() {
21056
+ await runInstallationCommand(executable, ["update"], env, 3e5);
21057
+ }
21058
+ });
21059
+ }
21060
+
20713
21061
  // dist/plugin.js
20714
21062
  var OMP_COMMAND_ENV = "CODEXHOST_OMP_COMMAND";
20715
21063
  function createHarnessAdapter(context) {
20716
21064
  const environment = { ...context.environment };
20717
- return new OmpAdapter({
21065
+ return Object.assign(new OmpAdapter({
20718
21066
  ...environment[OMP_COMMAND_ENV] ? { command: environment[OMP_COMMAND_ENV] } : {},
20719
21067
  environment
21068
+ }), {
21069
+ installation: createOmpInstallation(environment, environment[OMP_COMMAND_ENV]),
21070
+ install: createHarnessInstaller(environment, {
21071
+ posix: "https://omp.sh/install",
21072
+ windows: "https://omp.sh/install.ps1",
21073
+ shell: "sh"
21074
+ })
20720
21075
  });
20721
21076
  }
20722
21077
  export {