@liberseek/boft-cli-win32-arm64 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,20 +5,387 @@ 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
+ }, (error53, stdout, stderr) => {
264
+ if (error53)
265
+ reject(new Error(error53.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 createInstallationManager(options) {
278
+ let checking;
279
+ let updating;
280
+ const check2 = () => checking ??= options.check().finally(() => {
281
+ checking = void 0;
282
+ });
283
+ return (action) => {
284
+ if (updating)
285
+ return updating;
286
+ if (action === "check")
287
+ return check2();
288
+ updating = (async () => {
289
+ const before = await check2();
290
+ if (!before.updateAvailable)
291
+ return before;
292
+ if (!before.canUpdate)
293
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
294
+ await options.update(before);
295
+ const after = await check2();
296
+ if (after.currentVersion === before.currentVersion)
297
+ throw new Error("The Harness version did not change; check the native updater and retry");
298
+ return after;
299
+ })().finally(() => {
300
+ updating = void 0;
301
+ });
302
+ return updating;
303
+ };
304
+ }
305
+ async function fetchInstallationText(url2) {
306
+ const request = async () => {
307
+ const response = await fetch(url2, { signal: AbortSignal.timeout(15e3) });
308
+ if (!response.ok)
309
+ throw new Error("Could not check the latest Harness version");
310
+ return response.text();
311
+ };
312
+ try {
313
+ return await request();
314
+ } catch (error53) {
315
+ if (error53 instanceof DOMException && (error53.name === "AbortError" || error53.name === "TimeoutError"))
316
+ throw error53;
317
+ return request();
318
+ }
319
+ }
320
+
321
+ // ../../harness-discovery/dist/installer.js
322
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
323
+ import { tmpdir } from "node:os";
324
+ import { join } from "node:path";
325
+ function createHarnessInstaller(environment, source) {
326
+ return async () => {
327
+ if (!["darwin", "linux", "win32"].includes(process.platform))
328
+ throw new Error("Unsupported installation platform");
329
+ const env = withNodeRuntimeOnPath(environment);
330
+ if ("npm" in source) {
331
+ const npm = resolveHarnessExecutable({
332
+ id: "npm",
333
+ command: "npm",
334
+ installRoots: {
335
+ posix: [
336
+ "~/.npm-global/bin",
337
+ "~/.local/bin",
338
+ VERSION_MANAGER_ROOTS,
339
+ "/opt/homebrew/bin",
340
+ "/usr/local/bin",
341
+ "/usr/bin"
342
+ ],
343
+ windows: [
344
+ "${APPDATA}/npm",
345
+ VERSION_MANAGER_ROOTS,
346
+ "${ProgramFiles}/nodejs",
347
+ "${LOCALAPPDATA}/Programs/nodejs"
348
+ ]
349
+ }
350
+ }, { environment: env });
351
+ if (!npm)
352
+ throw new Error("Install Node.js and npm first");
353
+ await runInstallationCommand(npm.executable, ["install", "--global", source.npm], {
354
+ ...env,
355
+ ...source.allowScripts ? { npm_config_allow_scripts: source.allowScripts } : {}
356
+ }, 6e5);
357
+ return;
358
+ }
359
+ const windows = process.platform === "win32";
360
+ const url2 = windows ? source.windows : source.posix;
361
+ if (new URL(url2).protocol !== "https:")
362
+ throw new Error("Installer requires HTTPS");
363
+ const script = await fetchInstallationText(url2);
364
+ const directory = await mkdtemp(join(tmpdir(), "codexhost-installer-"));
365
+ try {
366
+ const file2 = join(directory, windows ? "install.ps1" : "install.sh");
367
+ await writeFile(file2, script, { mode: 384 });
368
+ await runInstallationCommand(windows ? "powershell.exe" : source.shell ?? "bash", windows ? ["-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", file2] : [file2], env, 6e5);
369
+ } finally {
370
+ await rm(directory, { recursive: true, force: true });
371
+ }
372
+ };
373
+ }
374
+
8
375
  // dist/grok-adapter.js
9
376
  import { randomUUID } from "node:crypto";
10
377
 
11
378
  // dist/grok-credential-export.js
12
379
  import { createHash } from "node:crypto";
13
380
  import { readFile } from "node:fs/promises";
14
- import os from "node:os";
15
- import path from "node:path";
381
+ import os2 from "node:os";
382
+ import path4 from "node:path";
16
383
  async function readGrokCredentials(environment) {
17
384
  if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((v) => v?.trim()))
18
385
  return [];
19
386
  try {
20
- const home = environment.GROK_HOME ?? path.join(environment.HOME ?? os.homedir(), ".grok");
21
- const auth = JSON.parse(await readFile(path.join(home, "auth.json"), "utf8"));
387
+ const home = environment.GROK_HOME ?? path4.join(environment.HOME ?? os2.homedir(), ".grok");
388
+ const auth = JSON.parse(await readFile(path4.join(home, "auth.json"), "utf8"));
22
389
  const client2 = "b1a00492-073a-47ea-816f-4c329264a828";
23
390
  const entry = auth[`https://auth.x.ai::${client2}`] ?? auth["https://auth.x.ai"];
24
391
  if (!entry || entry.oidc_issuer !== "https://auth.x.ai" || entry.oidc_client_id !== client2)
@@ -45,7 +412,7 @@ async function readGrokCredentials(environment) {
45
412
  }
46
413
 
47
414
  // dist/grok-adapter.js
48
- import path11 from "node:path";
415
+ import path12 from "node:path";
49
416
 
50
417
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
51
418
  var AGENT_METHODS = {
@@ -865,10 +1232,10 @@ function mergeDefs(...defs) {
865
1232
  function cloneDef(schema) {
866
1233
  return mergeDefs(schema._zod.def);
867
1234
  }
868
- function getElementAtPath(obj, path12) {
869
- if (!path12)
1235
+ function getElementAtPath(obj, path13) {
1236
+ if (!path13)
870
1237
  return obj;
871
- return path12.reduce((acc, key) => acc?.[key], obj);
1238
+ return path13.reduce((acc, key) => acc?.[key], obj);
872
1239
  }
873
1240
  function promiseAllObject(promisesObj) {
874
1241
  const keys = Object.keys(promisesObj);
@@ -1277,11 +1644,11 @@ function explicitlyAborted(x, startIndex = 0) {
1277
1644
  }
1278
1645
  return false;
1279
1646
  }
1280
- function prefixIssues(path12, issues) {
1647
+ function prefixIssues(path13, issues) {
1281
1648
  return issues.map((iss) => {
1282
1649
  var _a3;
1283
1650
  (_a3 = iss).path ?? (_a3.path = []);
1284
- iss.path.unshift(path12);
1651
+ iss.path.unshift(path13);
1285
1652
  return iss;
1286
1653
  });
1287
1654
  }
@@ -1428,16 +1795,16 @@ function flattenError(error53, mapper = (issue2) => issue2.message) {
1428
1795
  }
1429
1796
  function formatError(error53, mapper = (issue2) => issue2.message) {
1430
1797
  const fieldErrors = { _errors: [] };
1431
- const processError = (error54, path12 = []) => {
1798
+ const processError = (error54, path13 = []) => {
1432
1799
  for (const issue2 of error54.issues) {
1433
1800
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1434
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1801
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1435
1802
  } else if (issue2.code === "invalid_key") {
1436
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1803
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1437
1804
  } else if (issue2.code === "invalid_element") {
1438
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1805
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1439
1806
  } else {
1440
- const fullpath = [...path12, ...issue2.path];
1807
+ const fullpath = [...path13, ...issue2.path];
1441
1808
  if (fullpath.length === 0) {
1442
1809
  fieldErrors._errors.push(mapper(issue2));
1443
1810
  } else {
@@ -1464,17 +1831,17 @@ function formatError(error53, mapper = (issue2) => issue2.message) {
1464
1831
  }
1465
1832
  function treeifyError(error53, mapper = (issue2) => issue2.message) {
1466
1833
  const result = { errors: [] };
1467
- const processError = (error54, path12 = []) => {
1834
+ const processError = (error54, path13 = []) => {
1468
1835
  var _a3, _b;
1469
1836
  for (const issue2 of error54.issues) {
1470
1837
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1471
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1838
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1472
1839
  } else if (issue2.code === "invalid_key") {
1473
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1840
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1474
1841
  } else if (issue2.code === "invalid_element") {
1475
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1842
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1476
1843
  } else {
1477
- const fullpath = [...path12, ...issue2.path];
1844
+ const fullpath = [...path13, ...issue2.path];
1478
1845
  if (fullpath.length === 0) {
1479
1846
  result.errors.push(mapper(issue2));
1480
1847
  continue;
@@ -1506,8 +1873,8 @@ function treeifyError(error53, mapper = (issue2) => issue2.message) {
1506
1873
  }
1507
1874
  function toDotPath(_path) {
1508
1875
  const segs = [];
1509
- const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1510
- for (const seg of path12) {
1876
+ const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1877
+ for (const seg of path13) {
1511
1878
  if (typeof seg === "number")
1512
1879
  segs.push(`[${seg}]`);
1513
1880
  else if (typeof seg === "symbol")
@@ -14199,13 +14566,13 @@ function resolveRef(ref, ctx) {
14199
14566
  if (!ref.startsWith("#")) {
14200
14567
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14201
14568
  }
14202
- const path12 = ref.slice(1).split("/").filter(Boolean);
14203
- if (path12.length === 0) {
14569
+ const path13 = ref.slice(1).split("/").filter(Boolean);
14570
+ if (path13.length === 0) {
14204
14571
  return ctx.rootSchema;
14205
14572
  }
14206
14573
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14207
- if (path12[0] === defsKey) {
14208
- const key = path12[1];
14574
+ if (path13[0] === defsKey) {
14575
+ const key = path13[1];
14209
14576
  if (!key || !ctx.defs[key]) {
14210
14577
  throw new Error(`Reference not found: ${ref}`);
14211
14578
  }
@@ -18777,6 +19144,123 @@ var credentialImportsParamsSchema = external_exports.object({
18777
19144
  request: credentialImportsRequestSchema
18778
19145
  }).strict();
18779
19146
 
19147
+ // ../../shared-contracts/dist/harness-display-settings.js
19148
+ var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
19149
+ agent: external_exports.string().min(1).max(128),
19150
+ section: external_exports.enum(["main", "more", "auto"])
19151
+ })).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
19152
+ var harnessDisplaySettingsSchema = external_exports.strictObject({
19153
+ entries: harnessDisplayEntriesSchema.nullable()
19154
+ });
19155
+ var harnessDisplayGetSchema = external_exports.strictObject({});
19156
+ var harnessDisplaySetSchema = external_exports.strictObject({
19157
+ entries: harnessDisplayEntriesSchema,
19158
+ /** Import legacy Desktop preferences only if no shared settings exist yet. */
19159
+ initializeOnly: external_exports.boolean().optional()
19160
+ });
19161
+
19162
+ // ../../shared-contracts/dist/ids.js
19163
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
19164
+ message: "Identifier must not be empty or whitespace"
19165
+ });
19166
+ var harnessIdSchema = opaqueIdSchema.brand();
19167
+ var hostThreadIdSchema = opaqueIdSchema.brand();
19168
+ var hostTurnIdSchema = opaqueIdSchema.brand();
19169
+ var hostItemIdSchema = opaqueIdSchema.brand();
19170
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
19171
+
19172
+ // ../../shared-contracts/dist/harness-plugins.js
19173
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19174
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
19175
+ var HARNESS_PLUGIN_LIMIT = 128;
19176
+ 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);
19177
+ 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");
19178
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
19179
+ var pluginPresentationShape = {
19180
+ id: harnessPluginIdSchema,
19181
+ name: external_exports.string().trim().min(1).max(128),
19182
+ version: external_exports.string().min(1).max(128),
19183
+ /** The factory accepts a persisted local entrypoint through its construction context. */
19184
+ launchCommand: external_exports.literal(true).optional(),
19185
+ links: external_exports.object({
19186
+ documentation: documentationUrlSchema.optional(),
19187
+ installation: documentationUrlSchema.optional()
19188
+ }).strict().optional()
19189
+ };
19190
+ var harnessPluginManifestSchema = external_exports.object({
19191
+ manifestVersion: external_exports.literal(1),
19192
+ ...pluginPresentationShape,
19193
+ adapterApiVersion: external_exports.number().int().positive(),
19194
+ entry: relativeResourceSchema,
19195
+ icon: relativeResourceSchema.optional()
19196
+ }).strict();
19197
+ 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);
19198
+ var harnessPluginDescriptorSchema = external_exports.object({
19199
+ ...pluginPresentationShape,
19200
+ icon: harnessPluginIconSchema.optional()
19201
+ }).strict();
19202
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
19203
+ var harnessPluginListResultSchema = external_exports.object({
19204
+ plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
19205
+ }).strict();
19206
+ var harnessPluginConfigurationSchema = external_exports.object({
19207
+ version: external_exports.literal(1),
19208
+ enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
19209
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
19210
+ message: "Enabled plugin IDs must be unique",
19211
+ path: ["enabled"]
19212
+ });
19213
+
19214
+ // ../../shared-contracts/dist/harness-long-context.js
19215
+ var HARNESS_LONG_CONTEXT_GET_METHOD = "codexhost/harness/long-context/get";
19216
+ var HARNESS_LONG_CONTEXT_SET_METHOD = "codexhost/harness/long-context/set";
19217
+ var harnessLongContextGetSchema = external_exports.object({
19218
+ harnessId: harnessPluginIdSchema
19219
+ }).strict();
19220
+ var harnessLongContextSetSchema = harnessLongContextGetSchema.extend({
19221
+ enabled: external_exports.boolean()
19222
+ });
19223
+ var harnessLongContextSchema = external_exports.object({
19224
+ enabled: external_exports.boolean()
19225
+ }).strict();
19226
+
19227
+ // ../../shared-contracts/dist/console.js
19228
+ var consoleAnnouncementSchema = external_exports.strictObject({
19229
+ title: external_exports.string().trim().min(1).max(200),
19230
+ type: external_exports.enum(["info", "warning", "danger"]),
19231
+ body: external_exports.string().trim().min(1).max(16 * 1024)
19232
+ });
19233
+ var consoleOpenParamsSchema = external_exports.strictObject({});
19234
+ var consoleOpenResultSchema = external_exports.strictObject({
19235
+ /** The console address. */
19236
+ url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
19237
+ });
19238
+ var CONSOLE_HOST_METHODS = Object.freeze([
19239
+ "codexhost/harness/plugins/list",
19240
+ "codexhost/harness/display-settings/get",
19241
+ "codexhost/harness/display-settings/set",
19242
+ "codexhost/harness/inspect",
19243
+ "codexhost/harness/installation",
19244
+ "codexhost/harness/launch-settings/get",
19245
+ "codexhost/harness/launch-settings/set",
19246
+ HARNESS_LONG_CONTEXT_GET_METHOD,
19247
+ HARNESS_LONG_CONTEXT_SET_METHOD,
19248
+ "codexhost/harness/web-ui/open",
19249
+ "codexhost/harness/accounts/sources",
19250
+ "codexhost/harness/accounts/list",
19251
+ "codexhost/harness/accounts/inspect",
19252
+ "codexhost/harness/credential-imports",
19253
+ "codexhost/harness/session-import/sources",
19254
+ "codexhost/harness/session-import/list",
19255
+ "codexhost/harness/session-import/import",
19256
+ "codexhost/account/list",
19257
+ "codexhost/account/refresh",
19258
+ "codexhost/account/usage/inspect",
19259
+ "codexhost/update/check",
19260
+ "codexhost/update/start",
19261
+ "codexhost/update/status"
19262
+ ]);
19263
+
18780
19264
  // ../../shared-contracts/dist/version.js
18781
19265
  var WORKSPACE_CONTRACT_VERSION = 1;
18782
19266
 
@@ -18820,15 +19304,11 @@ var loadedSessionsSchema = external_exports.array(external_exports.strictObject(
18820
19304
  inactiveMs: external_exports.number().nonnegative()
18821
19305
  }));
18822
19306
 
18823
- // ../../shared-contracts/dist/ids.js
18824
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18825
- message: "Identifier must not be empty or whitespace"
19307
+ // ../../shared-contracts/dist/manual-compaction.js
19308
+ var threadManualCompactionStartedSchema = external_exports.strictObject({
19309
+ threadId: hostThreadIdSchema,
19310
+ turnId: hostTurnIdSchema
18826
19311
  });
18827
- var harnessIdSchema = opaqueIdSchema.brand();
18828
- var hostThreadIdSchema = opaqueIdSchema.brand();
18829
- var hostTurnIdSchema = opaqueIdSchema.brand();
18830
- var hostItemIdSchema = opaqueIdSchema.brand();
18831
- var hostInteractionIdSchema = opaqueIdSchema.brand();
18832
19312
 
18833
19313
  // ../../shared-contracts/dist/thread-usage.js
18834
19314
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
@@ -18890,6 +19370,10 @@ var threadUsageSnapshotSchema = external_exports.object({
18890
19370
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
18891
19371
  var accountCreditsProductUsageSchema = external_exports.object({
18892
19372
  product: external_exports.string().min(1),
19373
+ used: external_exports.number().finite().nonnegative().optional(),
19374
+ // Zero is a real empty cap, not an absent field.
19375
+ limit: external_exports.number().finite().nonnegative().optional(),
19376
+ unit: external_exports.string().min(1).max(32).optional(),
18893
19377
  usagePercent: usagePercentSchema,
18894
19378
  resetsAt: external_exports.string().min(1).optional()
18895
19379
  }).strict();
@@ -18899,11 +19383,14 @@ var accountResetCreditsSchema = external_exports.object({
18899
19383
  expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
18900
19384
  }).strict();
18901
19385
  var accountCreditsSnapshotSchema = external_exports.object({
19386
+ used: external_exports.number().finite().nonnegative().optional(),
19387
+ // Zero is a real empty cap, not an absent field.
19388
+ limit: external_exports.number().finite().nonnegative().optional(),
19389
+ unit: external_exports.string().trim().min(1).max(32).optional(),
18902
19390
  /** Native label when the primary limit is scoped to a model or product group. */
18903
19391
  label: external_exports.string().min(1).optional(),
18904
19392
  usedPercent: usagePercentSchema.optional(),
18905
19393
  remaining: external_exports.number().finite().optional(),
18906
- unit: external_exports.string().trim().min(1).max(32).optional(),
18907
19394
  resetsAt: external_exports.string().min(1).optional(),
18908
19395
  periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
18909
19396
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
@@ -18934,12 +19421,27 @@ var threadUsageInspectionSchema = external_exports.object({
18934
19421
  }).strict();
18935
19422
 
18936
19423
  // ../../shared-contracts/dist/harness-accounts.js
18937
- var harnessAccountSnapshotSchema = external_exports.object({
19424
+ var accountBalanceSnapshotSchema = external_exports.object({
19425
+ amount: external_exports.number().finite().nonnegative(),
19426
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
19427
+ currency: external_exports.string().trim().min(1).max(8),
19428
+ /** Native label when the Harness exposes several Billing Sources. */
19429
+ label: external_exports.string().trim().min(1).max(128).optional()
19430
+ }).strict();
19431
+ var harnessAccountSnapshotObject = external_exports.object({
18938
19432
  email: external_exports.string().trim().min(1).max(320).optional(),
18939
19433
  label: external_exports.string().trim().min(1).max(256).optional(),
18940
19434
  plan: external_exports.string().trim().min(1).max(128).optional(),
18941
- credits: accountCreditsSnapshotSchema
19435
+ credits: accountCreditsSnapshotSchema.optional(),
19436
+ balance: accountBalanceSnapshotSchema.optional()
18942
19437
  }).strict();
19438
+ function requireReportedQuota(schema) {
19439
+ return schema.refine((value) => {
19440
+ const reported = value;
19441
+ return reported.credits !== void 0 || reported.balance !== void 0;
19442
+ }, { message: "Account must report either credits or a balance" });
19443
+ }
19444
+ var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
18943
19445
  var harnessAccountIdentityShape = {
18944
19446
  harnessId: harnessIdSchema,
18945
19447
  harnessName: external_exports.string().trim().min(1).max(128)
@@ -18950,11 +19452,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
18950
19452
  var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
18951
19453
  var harnessAccountInspectResultSchema = external_exports.object({
18952
19454
  ...harnessAccountIdentityShape,
18953
- account: harnessAccountSnapshotSchema.nullable()
19455
+ account: harnessAccountSnapshotSchema.nullable(),
19456
+ /** Every Billing Source from one Harness; `account` remains the first for older clients. */
19457
+ accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
18954
19458
  }).strict();
18955
19459
  var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
18956
19460
  var harnessAccountListResultSchema = external_exports.object({
18957
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend(harnessAccountIdentityShape)).max(128)
19461
+ accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
18958
19462
  }).strict();
18959
19463
 
18960
19464
  // ../../shared-contracts/dist/json-value.js
@@ -19092,6 +19596,8 @@ var harnessModelSchema = external_exports.object({
19092
19596
  ref: harnessModelRefSchema,
19093
19597
  label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
19094
19598
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19599
+ /** Optional opaque selection for this same Model with priority processing enabled. */
19600
+ fastModel: harnessModelRefSchema.optional(),
19095
19601
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
19096
19602
  }).strict();
19097
19603
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
@@ -19124,6 +19630,16 @@ var harnessModelCatalogSchema = external_exports.object({
19124
19630
  });
19125
19631
  }
19126
19632
  refs.add(model.ref.id);
19633
+ if (model.fastModel) {
19634
+ if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
19635
+ context.addIssue({
19636
+ code: "custom",
19637
+ message: "Fast Model refs must be distinct and unique",
19638
+ path: ["models", index, "fastModel"]
19639
+ });
19640
+ }
19641
+ refs.add(model.fastModel.id);
19642
+ }
19127
19643
  const supportedThinkingIds = /* @__PURE__ */ new Set();
19128
19644
  for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
19129
19645
  if (supportedThinkingIds.has(optionId)) {
@@ -19246,11 +19762,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
19246
19762
  thinkingOptionId: harnessThinkingOptionIdSchema
19247
19763
  }).strict();
19248
19764
  var threadInspectionParamsSchema = external_exports.object({
19249
- threadId: hostThreadIdSchema
19765
+ threadId: hostThreadIdSchema,
19766
+ includeReferenceCapability: external_exports.boolean().optional()
19250
19767
  }).strict();
19251
19768
  var codexThreadInspectionSchema = external_exports.object({
19252
19769
  owner: external_exports.literal("codex"),
19253
- locked: external_exports.literal(true)
19770
+ locked: external_exports.literal(true),
19771
+ supportsThreadReferences: external_exports.literal(true).optional()
19254
19772
  }).strict();
19255
19773
  var externalThreadInspectionSchema = external_exports.object({
19256
19774
  owner: external_exports.literal("external"),
@@ -19315,48 +19833,6 @@ var threadOwnershipListResultSchema = external_exports.object({
19315
19833
  }
19316
19834
  });
19317
19835
 
19318
- // ../../shared-contracts/dist/harness-plugins.js
19319
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19320
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
19321
- var HARNESS_PLUGIN_LIMIT = 128;
19322
- 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);
19323
- 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");
19324
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
19325
- var pluginPresentationShape = {
19326
- id: harnessPluginIdSchema,
19327
- name: external_exports.string().trim().min(1).max(128),
19328
- version: external_exports.string().min(1).max(128),
19329
- /** The factory accepts a persisted local entrypoint through its construction context. */
19330
- launchCommand: external_exports.literal(true).optional(),
19331
- links: external_exports.object({
19332
- documentation: documentationUrlSchema.optional(),
19333
- installation: documentationUrlSchema.optional()
19334
- }).strict().optional()
19335
- };
19336
- var harnessPluginManifestSchema = external_exports.object({
19337
- manifestVersion: external_exports.literal(1),
19338
- ...pluginPresentationShape,
19339
- adapterApiVersion: external_exports.number().int().positive(),
19340
- entry: relativeResourceSchema,
19341
- icon: relativeResourceSchema.optional()
19342
- }).strict();
19343
- 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);
19344
- var harnessPluginDescriptorSchema = external_exports.object({
19345
- ...pluginPresentationShape,
19346
- icon: harnessPluginIconSchema.optional()
19347
- }).strict();
19348
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
19349
- var harnessPluginListResultSchema = external_exports.object({
19350
- plugins: external_exports.array(harnessPluginDescriptorSchema).max(HARNESS_PLUGIN_LIMIT)
19351
- }).strict();
19352
- var harnessPluginConfigurationSchema = external_exports.object({
19353
- version: external_exports.literal(1),
19354
- enabled: external_exports.array(harnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
19355
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
19356
- message: "Enabled plugin IDs must be unique",
19357
- path: ["enabled"]
19358
- });
19359
-
19360
19836
  // ../../shared-contracts/dist/harness-route.js
19361
19837
  var harnessPluginRouteSchema = external_exports.object({
19362
19838
  harnessId: harnessPluginIdSchema,
@@ -19378,10 +19854,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
19378
19854
  restartRequired: external_exports.boolean()
19379
19855
  }).strict();
19380
19856
 
19857
+ // ../../shared-contracts/dist/harness-installation.js
19858
+ var harnessInstallationParamsSchema = external_exports.object({
19859
+ harnessId: harnessIdSchema,
19860
+ action: external_exports.enum(["check", "update", "install"])
19861
+ }).strict();
19862
+ var harnessInstallationStateSchema = external_exports.object({
19863
+ currentVersion: external_exports.string().min(1).max(128),
19864
+ latestVersion: external_exports.string().min(1).max(128),
19865
+ updateAvailable: external_exports.boolean(),
19866
+ canUpdate: external_exports.boolean(),
19867
+ message: external_exports.string().max(2048).optional()
19868
+ }).strict();
19869
+
19381
19870
  // ../../shared-contracts/dist/codex-accounts.js
19382
19871
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
19383
19872
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
19384
19873
  var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
19874
+ var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
19875
+ function isCodexAccountSiteUrl(value) {
19876
+ return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
19877
+ }
19878
+ var externalUrlOpenParamsSchema = external_exports.object({
19879
+ url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
19880
+ }).strict();
19881
+ var externalUrlOpenResultSchema = external_exports.object({}).strict();
19385
19882
  var codexAccountPlanTypeSchema = external_exports.enum([
19386
19883
  "free",
19387
19884
  "go",
@@ -19407,7 +19904,8 @@ var codexAccountSchema = external_exports.object({
19407
19904
  email: external_exports.string().email().max(320).optional(),
19408
19905
  planType: codexAccountPlanTypeSchema.optional(),
19409
19906
  authKind: codexAccountAuthKindSchema.optional(),
19410
- authIdentity: nonBlankTextSchema3.max(256).optional()
19907
+ authIdentity: nonBlankTextSchema3.max(256).optional(),
19908
+ siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
19411
19909
  }).strict();
19412
19910
  var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
19413
19911
  var codexAccountListResultSchema = external_exports.object({
@@ -20003,7 +20501,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
20003
20501
  import { spawn, spawnSync } from "node:child_process";
20004
20502
  import { readdir, readFile as readFile2 } from "node:fs/promises";
20005
20503
  import os4 from "node:os";
20006
- import path9 from "node:path";
20504
+ import path10 from "node:path";
20007
20505
  import { Readable, Writable } from "node:stream";
20008
20506
 
20009
20507
  // dist/grok-slash-commands.js
@@ -20030,8 +20528,8 @@ function parseGrokAvailableCommands(value) {
20030
20528
  });
20031
20529
  }
20032
20530
  function isGrokSkill(command) {
20033
- const path12 = command.meta?.path;
20034
- return typeof path12 === "string" && /(^|[\\/])SKILL\.md$/u.test(path12) || typeof command.meta?.qualifiedName === "string";
20531
+ const path13 = command.meta?.path;
20532
+ return typeof path13 === "string" && /(^|[\\/])SKILL\.md$/u.test(path13) || typeof command.meta?.qualifiedName === "string";
20035
20533
  }
20036
20534
  function grokLiveCommands(native) {
20037
20535
  return native.map((command) => ({
@@ -20042,234 +20540,7 @@ function grokLiveCommands(native) {
20042
20540
  }
20043
20541
 
20044
20542
  // dist/command.js
20045
- import path4 from "node:path";
20046
-
20047
- // ../../harness-discovery/dist/environment.js
20048
- import fs from "node:fs";
20049
- import path2 from "node:path";
20050
- function targetPath(platform) {
20051
- return platform === "win32" ? path2.win32 : path2.posix;
20052
- }
20053
- function environmentValue(environment, name) {
20054
- const lowered = name.toLowerCase();
20055
- for (const [key, value] of Object.entries(environment)) {
20056
- if (key.toLowerCase() === lowered)
20057
- return value;
20058
- }
20059
- return void 0;
20060
- }
20061
- function pathDelimiter(platform) {
20062
- return platform === "win32" ? ";" : ":";
20063
- }
20064
- function pathDirectories(environment, platform) {
20065
- return (environmentValue(environment, "PATH") ?? "").split(pathDelimiter(platform)).map((directory) => directory.trim().replace(/^"|"$/gu, "")).filter(Boolean);
20066
- }
20067
- function executableExtensions(command, platform, environment) {
20068
- if (platform !== "win32")
20069
- return [""];
20070
- if (targetPath(platform).extname(command) !== "")
20071
- return [""];
20072
- return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
20073
- }
20074
- function isExecutableFile(filePath, platform) {
20075
- try {
20076
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
20077
- return fs.statSync(filePath).isFile();
20078
- } catch {
20079
- return false;
20080
- }
20081
- }
20082
- function subdirectoryNames(directory) {
20083
- try {
20084
- return fs.readdirSync(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
20085
- } catch {
20086
- return [];
20087
- }
20088
- }
20089
- function newestFirst(names) {
20090
- return [...names].sort((left, right) => right.localeCompare(left, void 0, { numeric: true }));
20091
- }
20092
-
20093
- // ../../harness-discovery/dist/invocation.js
20094
- import path3 from "node:path";
20095
- function commandInvocation(command, arguments_, environment, platform = process.platform) {
20096
- const extension = path3.win32.extname(command).toLowerCase();
20097
- if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
20098
- return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
20099
- }
20100
- const quote = (value) => `"${value.replaceAll("%", "%%").replaceAll('"', '""')}"`;
20101
- const commandLine = [command, ...arguments_].map(quote).join(" ");
20102
- return {
20103
- command: environmentValue(environment, "ComSpec") ?? "cmd.exe",
20104
- arguments: ["/d", "/v:off", "/s", "/c", `"${commandLine}"`],
20105
- windowsVerbatimArguments: true
20106
- };
20107
- }
20108
-
20109
- // ../../harness-discovery/dist/resolve.js
20110
- import os2 from "node:os";
20111
-
20112
- // ../../harness-discovery/dist/version-managers.js
20113
- function versionManagerBinaryDirectories(context) {
20114
- const { platform, environment, home } = context;
20115
- const list = context.subdirectories ?? subdirectoryNames;
20116
- const pathFlavor = targetPath(platform);
20117
- const value = (name) => environmentValue(environment, name);
20118
- const directories = [];
20119
- const versioned = (root, ...tail) => {
20120
- for (const version2 of newestFirst(list(root))) {
20121
- directories.push(pathFlavor.join(root, version2, ...tail));
20122
- }
20123
- };
20124
- if (platform === "win32") {
20125
- const appData = value("APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming");
20126
- const localAppData = value("LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local");
20127
- versioned(pathFlavor.join(appData, "nvm"));
20128
- versioned(value("FNM_DIR") ?? pathFlavor.join(appData, "fnm", "node-versions"), "installation");
20129
- directories.push(pathFlavor.join(localAppData, "Volta", "bin"));
20130
- directories.push(pathFlavor.join(home, ".bun", "bin"));
20131
- const pnpmHome2 = value("PNPM_HOME");
20132
- if (pnpmHome2)
20133
- directories.push(pnpmHome2);
20134
- directories.push(pathFlavor.join(localAppData, "pnpm"));
20135
- return directories;
20136
- }
20137
- versioned(pathFlavor.join(value("NVM_DIR") ?? pathFlavor.join(home, ".nvm"), "versions", "node"), "bin");
20138
- const fnmRoots = [
20139
- value("FNM_DIR"),
20140
- pathFlavor.join(home, ".local", "share", "fnm"),
20141
- pathFlavor.join(home, "Library", "Application Support", "fnm")
20142
- ].filter((root) => root !== void 0);
20143
- for (const root of fnmRoots) {
20144
- versioned(pathFlavor.join(root, "node-versions"), "installation", "bin");
20145
- }
20146
- const voltaHome = value("VOLTA_HOME") ?? pathFlavor.join(home, ".volta");
20147
- versioned(pathFlavor.join(voltaHome, "tools", "image", "node"), "bin");
20148
- directories.push(pathFlavor.join(voltaHome, "bin"));
20149
- const asdfHome = value("ASDF_DATA_DIR") ?? pathFlavor.join(home, ".asdf");
20150
- versioned(pathFlavor.join(asdfHome, "installs", "nodejs"), "bin");
20151
- directories.push(pathFlavor.join(asdfHome, "shims"));
20152
- const nodenvHome = value("NODENV_ROOT") ?? pathFlavor.join(home, ".nodenv");
20153
- versioned(pathFlavor.join(nodenvHome, "versions"), "bin");
20154
- directories.push(pathFlavor.join(nodenvHome, "shims"));
20155
- versioned(pathFlavor.join(value("N_PREFIX") ?? "/usr/local", "n", "versions", "node"), "bin");
20156
- directories.push(pathFlavor.join(home, ".bun", "bin"));
20157
- const pnpmHome = value("PNPM_HOME");
20158
- if (pnpmHome)
20159
- directories.push(pnpmHome);
20160
- directories.push(pathFlavor.join(home, "Library", "pnpm"));
20161
- directories.push(pathFlavor.join(home, ".local", "share", "pnpm"));
20162
- for (const prefix of ["/opt/homebrew/opt", "/usr/local/opt"]) {
20163
- for (const formula of newestFirst(list(prefix).filter((name) => name.startsWith("node@")))) {
20164
- directories.push(pathFlavor.join(prefix, formula, "bin"));
20165
- }
20166
- }
20167
- return directories;
20168
- }
20169
-
20170
- // ../../harness-discovery/dist/resolve.js
20171
- var VERSION_MANAGER_ROOTS = "<version-managers>";
20172
- function installRootExtensions(platform) {
20173
- return platform === "win32" ? [".exe", ".cmd"] : [""];
20174
- }
20175
- function resolveHomeDirectory(input) {
20176
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os2.homedir();
20177
- }
20178
- function templateVariables(environment, platform, home) {
20179
- const pathFlavor = targetPath(platform);
20180
- return {
20181
- HOME: home,
20182
- USERPROFILE: home,
20183
- APPDATA: environmentValue(environment, "APPDATA") ?? pathFlavor.join(home, "AppData", "Roaming"),
20184
- LOCALAPPDATA: environmentValue(environment, "LOCALAPPDATA") ?? pathFlavor.join(home, "AppData", "Local")
20185
- };
20186
- }
20187
- function joinTemplate(platform, value) {
20188
- const pathFlavor = targetPath(platform);
20189
- const segments = value.split("/");
20190
- const head = segments[0] ?? "";
20191
- const tail = segments.slice(1);
20192
- if (head === "")
20193
- return pathFlavor.join(pathFlavor.sep, ...tail);
20194
- return tail.length === 0 ? head : pathFlavor.join(head, ...tail);
20195
- }
20196
- function expandInstallRoot(template, environment, platform, home) {
20197
- const variables = templateVariables(environment, platform, home);
20198
- let unresolved = false;
20199
- const substituted = template.replace(/^~(?=\/|$)/u, home).replace(/\$\{(\w+)\}/gu, (_match, name) => {
20200
- const value = variables[name] ?? environmentValue(environment, name);
20201
- if (value === void 0 || value === "") {
20202
- unresolved = true;
20203
- return "";
20204
- }
20205
- return value;
20206
- });
20207
- return unresolved ? void 0 : joinTemplate(platform, substituted);
20208
- }
20209
- function installRootDirectories(spec, input, dependencies, platform, home) {
20210
- const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
20211
- const directories = [];
20212
- for (const template of templates) {
20213
- if (template === VERSION_MANAGER_ROOTS) {
20214
- directories.push(...versionManagerBinaryDirectories({
20215
- platform,
20216
- environment: input.environment,
20217
- home,
20218
- ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
20219
- }));
20220
- continue;
20221
- }
20222
- const directory = expandInstallRoot(template, input.environment, platform, home);
20223
- if (directory !== void 0)
20224
- directories.push(directory);
20225
- }
20226
- return directories;
20227
- }
20228
- function harnessCandidates(spec, input, dependencies = {}) {
20229
- const platform = input.platform ?? process.platform;
20230
- const pathFlavor = targetPath(platform);
20231
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
20232
- const command = configured ?? spec.command;
20233
- if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
20234
- return [{ candidate: command, source: "configured" }];
20235
- }
20236
- const candidates = [];
20237
- const extensions = executableExtensions(command, platform, input.environment);
20238
- for (const directory of pathDirectories(input.environment, platform)) {
20239
- for (const extension of extensions) {
20240
- candidates.push({
20241
- candidate: pathFlavor.join(directory, command + extension),
20242
- source: "path"
20243
- });
20244
- }
20245
- }
20246
- if (configured !== void 0)
20247
- return candidates;
20248
- const home = resolveHomeDirectory(input);
20249
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
20250
- for (const extension of installRootExtensions(platform)) {
20251
- candidates.push({
20252
- candidate: pathFlavor.join(directory, spec.command + extension),
20253
- source: "install-root"
20254
- });
20255
- }
20256
- }
20257
- return candidates;
20258
- }
20259
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
20260
- const platform = input.platform ?? process.platform;
20261
- const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
20262
- const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
20263
- const context = { platform, isExecutable };
20264
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
20265
- const executable = runnable(candidate, context);
20266
- if (executable !== void 0 && isExecutable(executable))
20267
- return { executable, source };
20268
- }
20269
- return void 0;
20270
- }
20271
-
20272
- // dist/command.js
20543
+ import path5 from "node:path";
20273
20544
  var GrokExecutableError = class extends Error {
20274
20545
  code = "GROK_NOT_FOUND";
20275
20546
  };
@@ -20298,7 +20569,7 @@ function resolveGrokExecutable(input = {}) {
20298
20569
  });
20299
20570
  if (!resolution)
20300
20571
  throw new GrokExecutableError("Grok CLI is not installed");
20301
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path4.resolve(resolution.executable);
20572
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
20302
20573
  }
20303
20574
  function grokInvocation(command, platform = process.platform, modelId) {
20304
20575
  const arguments_ = ["agent", "--no-leader"];
@@ -20311,11 +20582,11 @@ function grokInvocation(command, platform = process.platform, modelId) {
20311
20582
 
20312
20583
  // dist/grok-fork.js
20313
20584
  import { isDeepStrictEqual } from "node:util";
20314
- import path7 from "node:path";
20585
+ import path8 from "node:path";
20315
20586
 
20316
20587
  // dist/grok-file-change.js
20317
20588
  import { Buffer as Buffer2 } from "node:buffer";
20318
- import path5 from "node:path";
20589
+ import path6 from "node:path";
20319
20590
 
20320
20591
  // ../../../node_modules/diff/libesm/diff/base.js
20321
20592
  var Diff = class {
@@ -20417,16 +20688,16 @@ var Diff = class {
20417
20688
  }
20418
20689
  }
20419
20690
  }
20420
- addToPath(path12, added, removed, oldPosInc, options) {
20421
- const last = path12.lastComponent;
20691
+ addToPath(path13, added, removed, oldPosInc, options) {
20692
+ const last = path13.lastComponent;
20422
20693
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
20423
20694
  return {
20424
- oldPos: path12.oldPos + oldPosInc,
20695
+ oldPos: path13.oldPos + oldPosInc,
20425
20696
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
20426
20697
  };
20427
20698
  } else {
20428
20699
  return {
20429
- oldPos: path12.oldPos + oldPosInc,
20700
+ oldPos: path13.oldPos + oldPosInc,
20430
20701
  lastComponent: { count: 1, added, removed, previousComponent: last }
20431
20702
  };
20432
20703
  }
@@ -20739,13 +21010,13 @@ function isRecord4(value) {
20739
21010
  return typeof value === "object" && value !== null && !Array.isArray(value);
20740
21011
  }
20741
21012
  function validAbsolutePath(value) {
20742
- return typeof value === "string" && path5.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
21013
+ return typeof value === "string" && path6.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
20743
21014
  }
20744
21015
  function displayPath(nativePath, cwd) {
20745
- const resolvedCwd = path5.resolve(cwd);
20746
- const resolvedPath = path5.resolve(nativePath);
20747
- const relative = path5.relative(resolvedCwd, resolvedPath);
20748
- const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path5.sep}`);
21016
+ const resolvedCwd = path6.resolve(cwd);
21017
+ const resolvedPath = path6.resolve(nativePath);
21018
+ const relative = path6.relative(resolvedCwd, resolvedPath);
21019
+ const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path6.sep}`);
20749
21020
  const selected = inside ? relative : resolvedPath;
20750
21021
  const normalized = selected.replaceAll("\\", "/");
20751
21022
  if (normalized.length === 0 || normalized === ".")
@@ -20808,7 +21079,7 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
20808
21079
  // dist/local-media-markdown.js
20809
21080
  import { existsSync, statSync } from "node:fs";
20810
21081
  import os3 from "node:os";
20811
- import path6 from "node:path";
21082
+ import path7 from "node:path";
20812
21083
  var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20813
21084
  ".aac",
20814
21085
  ".gif",
@@ -20827,14 +21098,14 @@ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20827
21098
  ".webp"
20828
21099
  ]);
20829
21100
  function grokMediaResolveRoots(cwd, sessionDirectory) {
20830
- const roots = [path6.resolve(cwd)];
21101
+ const roots = [path7.resolve(cwd)];
20831
21102
  if (sessionDirectory) {
20832
- const session = path6.resolve(sessionDirectory);
20833
- roots.push(session, path6.join(session, "videos"), path6.join(session, "images"));
21103
+ const session = path7.resolve(sessionDirectory);
21104
+ roots.push(session, path7.join(session, "videos"), path7.join(session, "images"));
20834
21105
  }
20835
21106
  const home = process.env.HOME ?? process.env.USERPROFILE ?? os3.homedir();
20836
21107
  if (home)
20837
- roots.push(path6.join(home, "Downloads"));
21108
+ roots.push(path7.join(home, "Downloads"));
20838
21109
  return roots;
20839
21110
  }
20840
21111
  function rewriteLocalMediaMarkdown(text, roots, options = {}) {
@@ -20935,7 +21206,7 @@ function parseInlineCode(text, start) {
20935
21206
  return { closed: false, content: text.slice(start + 1), end: text.length };
20936
21207
  }
20937
21208
  function mediaMarkdownImage(absolutePath) {
20938
- const name = path6.basename(absolutePath).replaceAll("]", "\\]");
21209
+ const name = path7.basename(absolutePath).replaceAll("]", "\\]");
20939
21210
  return `![${name}](${formatMarkdownDestination(absolutePath, false)})`;
20940
21211
  }
20941
21212
  function parseMarkdownImage(text, start) {
@@ -21060,11 +21331,11 @@ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
21060
21331
  if (!hasMediaExtension(stripped))
21061
21332
  return null;
21062
21333
  if (isAbsoluteMediaPath(stripped)) {
21063
- const absolute = path6.resolve(stripped);
21334
+ const absolute = path7.resolve(stripped);
21064
21335
  return exists(absolute) ? absolute : null;
21065
21336
  }
21066
21337
  for (const root of roots) {
21067
- const absolute = path6.resolve(root, stripped);
21338
+ const absolute = path7.resolve(root, stripped);
21068
21339
  if (exists(absolute))
21069
21340
  return absolute;
21070
21341
  }
@@ -21086,11 +21357,11 @@ function stripFileUrl(value) {
21086
21357
  }
21087
21358
  }
21088
21359
  function isAbsoluteMediaPath(value) {
21089
- return path6.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
21360
+ return path7.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
21090
21361
  }
21091
21362
  function hasMediaExtension(value) {
21092
21363
  const pathname = value.split(/[?#]/, 1)[0] ?? value;
21093
- return MEDIA_EXTENSIONS.has(path6.extname(pathname).toLowerCase());
21364
+ return MEDIA_EXTENSIONS.has(path7.extname(pathname).toLowerCase());
21094
21365
  }
21095
21366
  function mediaFileExists(absolutePath) {
21096
21367
  try {
@@ -22099,11 +22370,11 @@ function parseGrokForkResponse(value) {
22099
22370
  }
22100
22371
  function projectRelativePath(value, cwds) {
22101
22372
  const normalized = value.replaceAll("\\", "/");
22102
- if (!path7.isAbsolute(value))
22373
+ if (!path8.isAbsolute(value))
22103
22374
  return normalized;
22104
22375
  for (const cwd of cwds) {
22105
- const relative = path7.relative(path7.resolve(cwd), path7.resolve(value));
22106
- if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path7.sep}`)) {
22376
+ const relative = path8.relative(path8.resolve(cwd), path8.resolve(value));
22377
+ if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path8.sep}`)) {
22107
22378
  return relative.replaceAll("\\", "/");
22108
22379
  }
22109
22380
  }
@@ -22168,8 +22439,8 @@ async function forkGrokSession(input) {
22168
22439
  error: error51("sessionNotFound", "Grok Native Session is unavailable")
22169
22440
  };
22170
22441
  }
22171
- const sourceCwd = path7.resolve(located.cwd);
22172
- const targetCwd = path7.resolve(input.cwd);
22442
+ const sourceCwd = path8.resolve(located.cwd);
22443
+ const targetCwd = path8.resolve(input.cwd);
22173
22444
  const source = await readSnapshot({ ...input, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
22174
22445
  if (!source.ok)
22175
22446
  return source;
@@ -22351,7 +22622,7 @@ function parseGrokCompactResult(value, cancelled = false) {
22351
22622
  }
22352
22623
 
22353
22624
  // dist/grok-rewind.js
22354
- import path8 from "node:path";
22625
+ import path9 from "node:path";
22355
22626
  var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
22356
22627
  function error52(code, message, retryable = false) {
22357
22628
  return { code, message, retryable };
@@ -22424,8 +22695,8 @@ async function rewindGrokLastTurn(input) {
22424
22695
  error: error52("sessionNotFound", "Grok Native Session is unavailable")
22425
22696
  };
22426
22697
  }
22427
- const sourceCwd = path8.resolve(located.cwd);
22428
- const targetCwd = path8.resolve(input.cwd);
22698
+ const sourceCwd = path9.resolve(located.cwd);
22699
+ const targetCwd = path9.resolve(input.cwd);
22429
22700
  if (sourceCwd !== targetCwd) {
22430
22701
  return {
22431
22702
  ok: false,
@@ -22906,13 +23177,13 @@ function transportEvent(update, metadata) {
22906
23177
  function grokHomeDir(options) {
22907
23178
  const environment = { ...process.env, ...options.environment };
22908
23179
  const home = environment.HOME ?? environment.USERPROFILE ?? os4.homedir();
22909
- return environment.GROK_HOME ?? path9.join(home, ".grok");
23180
+ return environment.GROK_HOME ?? path10.join(home, ".grok");
22910
23181
  }
22911
23182
  function grokNativeSessionDirectory(options, sessionId) {
22912
- return path9.join(grokHomeDir(options), "sessions", encodeURIComponent(path9.resolve(options.cwd)), sessionId);
23183
+ return path10.join(grokHomeDir(options), "sessions", encodeURIComponent(path10.resolve(options.cwd)), sessionId);
22913
23184
  }
22914
23185
  function nativeSessionFile(options, sessionId, fileName) {
22915
- return path9.join(grokNativeSessionDirectory(options, sessionId), fileName);
23186
+ return path10.join(grokNativeSessionDirectory(options, sessionId), fileName);
22916
23187
  }
22917
23188
  function nativeHistoryPath(options, sessionId) {
22918
23189
  return nativeSessionFile(options, sessionId, "updates.jsonl");
@@ -22932,7 +23203,7 @@ async function locateGrokNativeSession(options, sessionId) {
22932
23203
  return null;
22933
23204
  let entries;
22934
23205
  try {
22935
- entries = await readdir(path9.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
23206
+ entries = await readdir(path10.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
22936
23207
  } catch (error53) {
22937
23208
  if (isMissingFile(error53))
22938
23209
  return null;
@@ -22946,7 +23217,7 @@ async function locateGrokNativeSession(options, sessionId) {
22946
23217
  continue;
22947
23218
  let summaryRaw;
22948
23219
  try {
22949
- summaryRaw = await readFile2(path9.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
23220
+ summaryRaw = await readFile2(path10.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
22950
23221
  } catch (error53) {
22951
23222
  if (isMissingFile(error53) || isRecord13(error53) && error53.code === "ENOTDIR")
22952
23223
  continue;
@@ -22963,8 +23234,8 @@ async function locateGrokNativeSession(options, sessionId) {
22963
23234
  if (!isRecord13(parsed))
22964
23235
  continue;
22965
23236
  const info = parsed.info;
22966
- const cwd = isRecord13(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path9.resolve(info.cwd) : path9.resolve(decodeURIComponent(entry.name));
22967
- const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path9.resolve(parsed.source_workspace_dir) : void 0;
23237
+ const cwd = isRecord13(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path10.resolve(info.cwd) : path10.resolve(decodeURIComponent(entry.name));
23238
+ const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path10.resolve(parsed.source_workspace_dir) : void 0;
22968
23239
  matches.push({
22969
23240
  cwd,
22970
23241
  ...sourceWorkspaceDir ? { sourceWorkspaceDir } : {}
@@ -22974,7 +23245,7 @@ async function locateGrokNativeSession(options, sessionId) {
22974
23245
  }
22975
23246
  async function readGrokNativeHistory(options, sessionId) {
22976
23247
  try {
22977
- return parseNativeHistory(await readFile2(nativeHistoryPath({ ...options, cwd: path9.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
23248
+ return parseNativeHistory(await readFile2(nativeHistoryPath({ ...options, cwd: path10.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
22978
23249
  } catch (error53) {
22979
23250
  if (isMissingFile(error53))
22980
23251
  return [];
@@ -23693,7 +23964,7 @@ function stateForGrokModel(modelState, nativeState, model = modelState.currentMo
23693
23964
  // dist/grok-credits.js
23694
23965
  import { readFile as readFile3 } from "node:fs/promises";
23695
23966
  import os5 from "node:os";
23696
- import path10 from "node:path";
23967
+ import path11 from "node:path";
23697
23968
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
23698
23969
  var REQUEST_TIMEOUT_MS = 15e3;
23699
23970
  function isRecord15(value) {
@@ -23713,7 +23984,7 @@ function nonNegativeCentValue(value) {
23713
23984
  return amount;
23714
23985
  }
23715
23986
  function grokHome(environment) {
23716
- return environment.GROK_HOME ?? path10.join(environment.HOME ?? environment.USERPROFILE ?? os5.homedir(), ".grok");
23987
+ return environment.GROK_HOME ?? path11.join(environment.HOME ?? environment.USERPROFILE ?? os5.homedir(), ".grok");
23717
23988
  }
23718
23989
  function periodTypeFrom(value) {
23719
23990
  if (typeof value !== "string")
@@ -23792,7 +24063,7 @@ async function fetchGrokAccount(input = {}) {
23792
24063
  if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((value) => value?.trim()))
23793
24064
  return null;
23794
24065
  const now = input.now ?? /* @__PURE__ */ new Date();
23795
- const authPath = path10.join(grokHome(environment), "auth.json");
24066
+ const authPath = path11.join(grokHome(environment), "auth.json");
23796
24067
  const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile3(authPath, "utf8");
23797
24068
  const token = selectAccessToken(JSON.parse(raw), now);
23798
24069
  if (!token)
@@ -23828,8 +24099,8 @@ async function fetchGrokAccount(input = {}) {
23828
24099
  }
23829
24100
  async function fetchGrokCredits(input = {}) {
23830
24101
  const account = await fetchGrokAccount(input);
23831
- const usedPercent = account?.credits.usedPercent;
23832
- if (!account || usedPercent === void 0)
24102
+ const usedPercent = account?.credits?.usedPercent;
24103
+ if (!account?.credits || usedPercent === void 0)
23833
24104
  return null;
23834
24105
  const { credits } = account;
23835
24106
  return {
@@ -25189,7 +25460,7 @@ var GrokAdapter = class {
25189
25460
  async inspect(input = {}) {
25190
25461
  if (this.#closePromise)
25191
25462
  return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
25192
- const cwd = path11.resolve(input.cwd ?? process.cwd());
25463
+ const cwd = path12.resolve(input.cwd ?? process.cwd());
25193
25464
  if (!input.refresh) {
25194
25465
  const cached2 = this.#inspectionCache.get(cwd);
25195
25466
  if (cached2)
@@ -25251,7 +25522,7 @@ var GrokAdapter = class {
25251
25522
  }
25252
25523
  };
25253
25524
  }
25254
- const cwd = path11.resolve(input.cwd);
25525
+ const cwd = path12.resolve(input.cwd);
25255
25526
  const parsedRef = input.kind === "resume" ? nativeSessionRefSchema.safeParse(input.nativeRef) : null;
25256
25527
  if (parsedRef && (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId)) {
25257
25528
  return {
@@ -25435,13 +25706,51 @@ var GrokAdapter = class {
25435
25706
  }
25436
25707
  };
25437
25708
 
25709
+ // dist/installation.js
25710
+ var GROK_NPM_PACKAGE = "@xai-official/grok";
25711
+ function createGrokInstallation(environment, command) {
25712
+ const run = (args, timeout, extra) => runInstallationCommand(resolveGrokExecutable({ environment, ...command ? { command } : {} }), args, extra ? { ...environment, ...extra } : environment, timeout);
25713
+ let installer = "";
25714
+ return createInstallationManager({
25715
+ async check() {
25716
+ const state = JSON.parse(await run(["update", "--check", "--json"]));
25717
+ if (state.error || typeof state.updateAvailable !== "boolean")
25718
+ throw new Error("Grok update check failed");
25719
+ installer = typeof state.installer === "string" ? state.installer : "";
25720
+ return {
25721
+ currentVersion: installationVersion(state.currentVersion),
25722
+ latestVersion: installationVersion(state.latestVersion),
25723
+ updateAvailable: state.updateAvailable,
25724
+ canUpdate: true
25725
+ };
25726
+ },
25727
+ async update() {
25728
+ if (installer !== "npm") {
25729
+ await run(["update"], 3e5);
25730
+ return;
25731
+ }
25732
+ const existing = environment.npm_config_allow_scripts?.trim();
25733
+ const allowed = existing ? `${existing},${GROK_NPM_PACKAGE}` : GROK_NPM_PACKAGE;
25734
+ await run(["update", "--force-reinstall"], 3e5, {
25735
+ npm_config_allow_scripts: allowed
25736
+ });
25737
+ }
25738
+ });
25739
+ }
25740
+
25438
25741
  // dist/plugin.js
25439
25742
  var GROK_COMMAND_ENV = "CODEXHOST_GROK_COMMAND";
25440
25743
  function createHarnessAdapter(context) {
25441
25744
  const environment = { ...context.environment };
25442
- return new GrokAdapter({
25745
+ return Object.assign(new GrokAdapter({
25443
25746
  ...environment[GROK_COMMAND_ENV] ? { command: environment[GROK_COMMAND_ENV] } : {},
25444
25747
  environment
25748
+ }), {
25749
+ installation: createGrokInstallation(environment, environment[GROK_COMMAND_ENV]),
25750
+ install: createHarnessInstaller(environment, {
25751
+ npm: "@xai-official/grok",
25752
+ allowScripts: "@xai-official/grok"
25753
+ })
25445
25754
  });
25446
25755
  }
25447
25756
  export {