@karlorz/codexhost-cli-darwin-x64 0.13.3-5 → 0.13.3-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.
@@ -246,7 +246,19 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
246
246
 
247
247
  // ../../harness-discovery/dist/installation.js
248
248
  import { execFile } from "node:child_process";
249
+ import { open } from "node:fs/promises";
249
250
  import { homedir } from "node:os";
251
+ async function readLauncherScript(command) {
252
+ const file2 = await open(command, "r");
253
+ try {
254
+ const buffer = Buffer.alloc(4096);
255
+ const { bytesRead } = await file2.read(buffer, 0, buffer.length, 0);
256
+ const prefix = buffer.toString("utf8", 0, bytesRead);
257
+ return prefix.startsWith("#!") || /\.(cmd|bat|ps1)$/i.test(command) ? prefix : "";
258
+ } finally {
259
+ await file2.close();
260
+ }
261
+ }
250
262
  function runInstallationCommand(command, args, environment, timeout = 3e4) {
251
263
  const env = withNodeRuntimeOnPath(environment);
252
264
  const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
@@ -274,6 +286,9 @@ function installationVersion(value) {
274
286
  throw new Error("Harness returned an invalid version");
275
287
  return value.trim().replace(/^v/, "");
276
288
  }
289
+ function versionFromOutput(output) {
290
+ return installationVersion(output.match(/\b\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?\b/)?.[0]);
291
+ }
277
292
  function createInstallationManager(options) {
278
293
  let checking;
279
294
  let updating;
@@ -393,10 +408,13 @@ function usageSessionTitle(value) {
393
408
  return void 0;
394
409
  if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
395
410
  return normalized;
396
- const characters = [...normalized];
397
- if (characters.length <= MAX_SESSION_TITLE_LENGTH)
398
- return normalized;
399
- return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
411
+ let title = "";
412
+ for (const character of normalized) {
413
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
414
+ break;
415
+ title += character;
416
+ }
417
+ return `${title.trimEnd()}…`;
400
418
  }
401
419
  function sessionIdOk(value) {
402
420
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
@@ -561,7 +579,7 @@ function createGrokUsageStatistics(environment) {
561
579
  }
562
580
 
563
581
  // dist/grok-adapter.js
564
- import { randomUUID } from "node:crypto";
582
+ import { randomUUID as randomUUID2 } from "node:crypto";
565
583
 
566
584
  // dist/grok-credential-export.js
567
585
  import { createHash } from "node:crypto";
@@ -600,7 +618,7 @@ async function readGrokCredentials(environment) {
600
618
  }
601
619
 
602
620
  // dist/grok-adapter.js
603
- import path16 from "node:path";
621
+ import path18 from "node:path";
604
622
 
605
623
  // ../../../node_modules/zod/v4/classic/external.js
606
624
  var external_exports = {};
@@ -1368,10 +1386,10 @@ function mergeDefs(...defs) {
1368
1386
  function cloneDef(schema) {
1369
1387
  return mergeDefs(schema._zod.def);
1370
1388
  }
1371
- function getElementAtPath(obj, path17) {
1372
- if (!path17)
1389
+ function getElementAtPath(obj, path19) {
1390
+ if (!path19)
1373
1391
  return obj;
1374
- return path17.reduce((acc, key) => acc?.[key], obj);
1392
+ return path19.reduce((acc, key) => acc?.[key], obj);
1375
1393
  }
1376
1394
  function promiseAllObject(promisesObj) {
1377
1395
  const keys = Object.keys(promisesObj);
@@ -1780,11 +1798,11 @@ function explicitlyAborted(x, startIndex = 0) {
1780
1798
  }
1781
1799
  return false;
1782
1800
  }
1783
- function prefixIssues(path17, issues) {
1801
+ function prefixIssues(path19, issues) {
1784
1802
  return issues.map((iss) => {
1785
1803
  var _a3;
1786
1804
  (_a3 = iss).path ?? (_a3.path = []);
1787
- iss.path.unshift(path17);
1805
+ iss.path.unshift(path19);
1788
1806
  return iss;
1789
1807
  });
1790
1808
  }
@@ -1931,16 +1949,16 @@ function flattenError(error53, mapper = (issue2) => issue2.message) {
1931
1949
  }
1932
1950
  function formatError(error53, mapper = (issue2) => issue2.message) {
1933
1951
  const fieldErrors = { _errors: [] };
1934
- const processError = (error54, path17 = []) => {
1952
+ const processError = (error54, path19 = []) => {
1935
1953
  for (const issue2 of error54.issues) {
1936
1954
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1937
- issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
1955
+ issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
1938
1956
  } else if (issue2.code === "invalid_key") {
1939
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
1957
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
1940
1958
  } else if (issue2.code === "invalid_element") {
1941
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
1959
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
1942
1960
  } else {
1943
- const fullpath = [...path17, ...issue2.path];
1961
+ const fullpath = [...path19, ...issue2.path];
1944
1962
  if (fullpath.length === 0) {
1945
1963
  fieldErrors._errors.push(mapper(issue2));
1946
1964
  } else {
@@ -1967,17 +1985,17 @@ function formatError(error53, mapper = (issue2) => issue2.message) {
1967
1985
  }
1968
1986
  function treeifyError(error53, mapper = (issue2) => issue2.message) {
1969
1987
  const result = { errors: [] };
1970
- const processError = (error54, path17 = []) => {
1988
+ const processError = (error54, path19 = []) => {
1971
1989
  var _a3, _b;
1972
1990
  for (const issue2 of error54.issues) {
1973
1991
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1974
- issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
1992
+ issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
1975
1993
  } else if (issue2.code === "invalid_key") {
1976
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
1994
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
1977
1995
  } else if (issue2.code === "invalid_element") {
1978
- processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
1996
+ processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
1979
1997
  } else {
1980
- const fullpath = [...path17, ...issue2.path];
1998
+ const fullpath = [...path19, ...issue2.path];
1981
1999
  if (fullpath.length === 0) {
1982
2000
  result.errors.push(mapper(issue2));
1983
2001
  continue;
@@ -2009,8 +2027,8 @@ function treeifyError(error53, mapper = (issue2) => issue2.message) {
2009
2027
  }
2010
2028
  function toDotPath(_path) {
2011
2029
  const segs = [];
2012
- const path17 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2013
- for (const seg of path17) {
2030
+ const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
2031
+ for (const seg of path19) {
2014
2032
  if (typeof seg === "number")
2015
2033
  segs.push(`[${seg}]`);
2016
2034
  else if (typeof seg === "symbol")
@@ -14702,13 +14720,13 @@ function resolveRef(ref, ctx) {
14702
14720
  if (!ref.startsWith("#")) {
14703
14721
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14704
14722
  }
14705
- const path17 = ref.slice(1).split("/").filter(Boolean);
14706
- if (path17.length === 0) {
14723
+ const path19 = ref.slice(1).split("/").filter(Boolean);
14724
+ if (path19.length === 0) {
14707
14725
  return ctx.rootSchema;
14708
14726
  }
14709
14727
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14710
- if (path17[0] === defsKey) {
14711
- const key = path17[1];
14728
+ if (path19[0] === defsKey) {
14729
+ const key = path19[1];
14712
14730
  if (!key || !ctx.defs[key]) {
14713
14731
  throw new Error(`Reference not found: ${ref}`);
14714
14732
  }
@@ -15414,6 +15432,7 @@ var consoleOpenResultSchema = external_exports.strictObject({
15414
15432
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15415
15433
  });
15416
15434
  var CONSOLE_HOST_METHODS = Object.freeze([
15435
+ "codexhost/voice/gateway-status",
15417
15436
  "codexhost/console/remote-connections",
15418
15437
  "codexhost/runtime/status",
15419
15438
  "codexhost/remote/ssh-setup",
@@ -15424,6 +15443,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
15424
15443
  "codexhost/harness/installation",
15425
15444
  "codexhost/harness/launch-settings/get",
15426
15445
  "codexhost/harness/launch-settings/set",
15446
+ "codexhost/harness/grok-computer-use/get",
15447
+ "codexhost/harness/grok-computer-use/set",
15427
15448
  "codexhost/harness/web-ui/open",
15428
15449
  "codexhost/harness/accounts/sources",
15429
15450
  "codexhost/harness/accounts/list",
@@ -15952,7 +15973,9 @@ var harnessInspectionSchema = external_exports.union([
15952
15973
  var harnessInspectParamsSchema = external_exports.object({
15953
15974
  harnessId: harnessIdSchema,
15954
15975
  cwd: nonBlankTextSchema2.max(16384).optional(),
15955
- refresh: external_exports.boolean().optional()
15976
+ refresh: external_exports.boolean().optional(),
15977
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15978
+ purpose: external_exports.literal("availability").optional()
15956
15979
  }).strict();
15957
15980
  var harnessWebUiOpenParamsSchema = external_exports.object({
15958
15981
  harnessId: harnessIdSchema
@@ -16126,6 +16149,26 @@ var harnessLaunchSettingsSchema = external_exports.object({
16126
16149
  restartRequired: external_exports.boolean()
16127
16150
  }).strict();
16128
16151
 
16152
+ // ../../shared-contracts/dist/grok-computer-use.js
16153
+ var grokComputerUseGetSchema = external_exports.object({}).strict();
16154
+ var grokComputerUseSetSchema = external_exports.object({
16155
+ enabled: external_exports.boolean().optional(),
16156
+ browser: external_exports.boolean().optional()
16157
+ }).strict().refine((value) => value.enabled !== void 0 || value.browser !== void 0, {
16158
+ message: "Expected enabled or browser"
16159
+ });
16160
+ var grokComputerUseSettingsSchema = external_exports.object({
16161
+ enabled: external_exports.boolean(),
16162
+ available: external_exports.boolean(),
16163
+ unavailableReason: external_exports.string().min(1).max(500).optional(),
16164
+ browser: external_exports.boolean().optional(),
16165
+ browserFilesPresent: external_exports.boolean().optional(),
16166
+ browserAvailable: external_exports.boolean().optional(),
16167
+ browserUnavailableReason: external_exports.string().min(1).max(500).optional(),
16168
+ applyFailed: external_exports.boolean().optional(),
16169
+ applyError: external_exports.string().min(1).max(500).optional()
16170
+ }).strict();
16171
+
16129
16172
  // ../../shared-contracts/dist/harness-installation.js
16130
16173
  var harnessInstallationParamsSchema = external_exports.object({
16131
16174
  harnessId: harnessIdSchema,
@@ -16523,9 +16566,369 @@ var remoteConnectionsReplySchema = external_exports.union([
16523
16566
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16524
16567
  ]);
16525
16568
 
16569
+ // ../../shared-contracts/dist/voice-settings.js
16570
+ var voiceRoutesSchema = external_exports.strictObject({
16571
+ chatExperience: external_exports.enum(["chatgpt", "codex"]),
16572
+ chatConnection: external_exports.enum(["desktop", "gateway"]),
16573
+ workConnection: external_exports.enum(["desktop", "gateway"])
16574
+ });
16575
+ var DEFAULT_VOICE_ROUTES = Object.freeze({
16576
+ chatExperience: "chatgpt",
16577
+ chatConnection: "desktop",
16578
+ workConnection: "gateway"
16579
+ });
16580
+ var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
16581
+ var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
16582
+ external_exports.strictObject({
16583
+ operation: external_exports.literal("get"),
16584
+ runtime: external_exports.strictObject({
16585
+ id: external_exports.string().uuid(),
16586
+ revision: external_exports.string().max(64),
16587
+ activeCall: external_exports.boolean()
16588
+ }).optional()
16589
+ }),
16590
+ external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
16591
+ external_exports.strictObject({
16592
+ operation: external_exports.literal("set"),
16593
+ settings: voiceSettingsSchema,
16594
+ revision: external_exports.string().max(64)
16595
+ }),
16596
+ external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
16597
+ ]);
16598
+ var voiceSettingsStateSchema = external_exports.strictObject({
16599
+ settings: voiceSettingsSchema,
16600
+ initialized: external_exports.boolean(),
16601
+ revision: external_exports.string(),
16602
+ activeInject: external_exports.boolean().nullable(),
16603
+ envOverride: external_exports.enum(["0", "1"]).nullable(),
16604
+ activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
16605
+ routesActive: external_exports.boolean().nullable(),
16606
+ activeCall: external_exports.boolean().nullable(),
16607
+ gatewayReady: external_exports.boolean().nullable(),
16608
+ restartAvailable: external_exports.boolean(),
16609
+ restart: external_exports.strictObject({
16610
+ phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
16611
+ error: external_exports.string().nullable()
16612
+ })
16613
+ });
16614
+
16526
16615
  // ../../shared-contracts/dist/index.js
16527
16616
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16528
16617
 
16618
+ // ../../harness-plugin-files/dist/grok-computer-use.js
16619
+ import { randomUUID } from "node:crypto";
16620
+ import { access, mkdir as mkdir2, readFile as readFile3, rename, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
16621
+ import os4 from "node:os";
16622
+ import path8 from "node:path";
16623
+
16624
+ // ../../harness-plugin-files/dist/grok-computer-use-lock.js
16625
+ import { mkdir, rm as rm2 } from "node:fs/promises";
16626
+ import path7 from "node:path";
16627
+ import { setTimeout as delay } from "node:timers/promises";
16628
+ async function withGrokComputerUseLock(dataDirectory2, grokHome4, operation) {
16629
+ const locks = [
16630
+ .../* @__PURE__ */ new Set([
16631
+ path7.join(dataDirectory2, ".grok-computer-use.lock"),
16632
+ path7.join(grokHome4, ".codexhost-cua.lock")
16633
+ ])
16634
+ ].sort();
16635
+ const acquired = [];
16636
+ const deadline = Date.now() + 5e3;
16637
+ try {
16638
+ for (const lock of locks) {
16639
+ await mkdir(path7.dirname(lock), { recursive: true, mode: 448 });
16640
+ for (; ; ) {
16641
+ try {
16642
+ await mkdir(lock, { mode: 448 });
16643
+ acquired.push(lock);
16644
+ break;
16645
+ } catch (error53) {
16646
+ if (error53.code !== "EEXIST")
16647
+ throw error53;
16648
+ if (Date.now() >= deadline)
16649
+ throw new Error("Grok Computer Use settings are locked");
16650
+ await delay(25);
16651
+ }
16652
+ }
16653
+ }
16654
+ return await operation();
16655
+ } finally {
16656
+ for (const lock of acquired.reverse())
16657
+ await rm2(lock, { recursive: true });
16658
+ }
16659
+ }
16660
+
16661
+ // ../../harness-plugin-files/dist/grok-computer-use.js
16662
+ var GROK_BROWSER_BINDING_SUPPORTED = false;
16663
+ var PREFERENCE_FILE = "grok-computer-use.json";
16664
+ var TABLE = "[mcp_servers.cua_repl]";
16665
+ var ENV_TABLE = "[mcp_servers.cua_repl.env]";
16666
+ var APPLY_FAILED = "Could not apply Grok Computer Use settings to Grok config.";
16667
+ var GrokComputerUseError = class extends Error {
16668
+ constructor(message) {
16669
+ super(message);
16670
+ this.name = "GrokComputerUseError";
16671
+ }
16672
+ };
16673
+ function dataDirectory(environment) {
16674
+ return environment.CODEXHOST_DATA_DIR ? path8.resolve(environment.CODEXHOST_DATA_DIR) : path8.join(os4.homedir(), ".codexhost");
16675
+ }
16676
+ function grokHome2(environment) {
16677
+ return environment.GROK_HOME ? path8.resolve(environment.GROK_HOME) : path8.join(environment.HOME ?? os4.homedir(), ".grok");
16678
+ }
16679
+ function chatgptApp(environment, platform) {
16680
+ if (environment.CODEXHOST_CHATGPT_APP)
16681
+ return path8.resolve(environment.CODEXHOST_CHATGPT_APP);
16682
+ if (platform === "darwin")
16683
+ return "/Applications/ChatGPT.app";
16684
+ return void 0;
16685
+ }
16686
+ async function isFile(target) {
16687
+ try {
16688
+ await access(target);
16689
+ return true;
16690
+ } catch {
16691
+ return false;
16692
+ }
16693
+ }
16694
+ function isNotFound(error53) {
16695
+ return Boolean(error53 && typeof error53 === "object" && "code" in error53 && error53.code === "ENOENT");
16696
+ }
16697
+ async function writeAtomically(file2, content) {
16698
+ await mkdir2(path8.dirname(file2), { recursive: true, mode: 448 });
16699
+ const temporary = `${file2}.${randomUUID()}.tmp`;
16700
+ try {
16701
+ await writeFile2(temporary, content, { mode: 384, flag: "wx" });
16702
+ await rename(temporary, file2);
16703
+ } finally {
16704
+ await rm3(temporary, { force: true });
16705
+ }
16706
+ }
16707
+ function launchPaths(environment, platform) {
16708
+ const app = chatgptApp(environment, platform);
16709
+ if (!app)
16710
+ return void 0;
16711
+ const resources = path8.join(app, "Contents", "Resources");
16712
+ const cuaNode = path8.join(resources, "cua_node");
16713
+ return {
16714
+ node: path8.join(cuaNode, "bin", "node"),
16715
+ cuaRepl: path8.join(cuaNode, "lib", "node_modules", "@oai", "cua-repl", "bin", "cua-repl.mjs"),
16716
+ nodeRepl: path8.join(cuaNode, "bin", "node_repl"),
16717
+ nodeModules: path8.join(cuaNode, "lib", "node_modules"),
16718
+ codexCli: path8.join(resources, "codex-cli", "bin", "codex"),
16719
+ skyApp: path8.join(environment.HOME ?? os4.homedir(), ".codex", "computer-use", "Codex Computer Use.app"),
16720
+ codexHome: path8.join(environment.HOME ?? os4.homedir(), ".codex"),
16721
+ browserDesktop: path8.join(cuaNode, "lib", "node_modules", "@oai", "browser-desktop")
16722
+ };
16723
+ }
16724
+ async function sharedRuntimePresent(launch) {
16725
+ const present = await Promise.all([launch.node, launch.cuaRepl, launch.nodeRepl].map(isFile));
16726
+ return present.every(Boolean);
16727
+ }
16728
+ async function computerFilesPresent(launch) {
16729
+ const present = await Promise.all([isFile(launch.skyApp), isFile(launch.codexCli)]);
16730
+ return present.every(Boolean);
16731
+ }
16732
+ async function browserFilesPresent(launch) {
16733
+ return isFile(path8.join(launch.browserDesktop, "package.json"));
16734
+ }
16735
+ async function discoverGrokComputerUseLaunch(environment = process.env, platform = process.platform) {
16736
+ const launch = launchPaths(environment, platform);
16737
+ if (!launch || !await sharedRuntimePresent(launch))
16738
+ return void 0;
16739
+ return launch;
16740
+ }
16741
+ function tableRange(text, header) {
16742
+ const lines = text.split(/\n/);
16743
+ let start = -1;
16744
+ for (let index = 0; index < lines.length; index += 1) {
16745
+ if (lines[index] === header) {
16746
+ start = index;
16747
+ break;
16748
+ }
16749
+ }
16750
+ if (start < 0)
16751
+ return void 0;
16752
+ let end = lines.length;
16753
+ for (let index = start + 1; index < lines.length; index += 1) {
16754
+ const line = lines[index] ?? "";
16755
+ if (line.startsWith("[") && line.endsWith("]")) {
16756
+ end = index;
16757
+ break;
16758
+ }
16759
+ }
16760
+ return { start, end };
16761
+ }
16762
+ function removeTables(text, headers) {
16763
+ let current = text;
16764
+ for (const header of headers) {
16765
+ const range = tableRange(current, header);
16766
+ if (!range)
16767
+ continue;
16768
+ const lines = current.split(/\n/);
16769
+ lines.splice(range.start, range.end - range.start);
16770
+ current = lines.join("\n");
16771
+ }
16772
+ return current.replace(/\n{3,}/g, "\n\n");
16773
+ }
16774
+ function cuaReplEnabledInToml(text) {
16775
+ const range = tableRange(text, TABLE);
16776
+ if (!range)
16777
+ return false;
16778
+ const body = text.split(/\n/).slice(range.start, range.end);
16779
+ for (const line of body) {
16780
+ if (/^enabled\s*=\s*false\b/u.test(line))
16781
+ return false;
16782
+ if (/^enabled\s*=\s*true\b/u.test(line))
16783
+ return true;
16784
+ }
16785
+ return true;
16786
+ }
16787
+ function inferredSurfaces(text) {
16788
+ if (!cuaReplEnabledInToml(text))
16789
+ return { enabled: false, browser: false };
16790
+ const range = tableRange(text, ENV_TABLE);
16791
+ const body = range ? text.split(/\n/).slice(range.start, range.end).join("\n") : "";
16792
+ const literal2 = /^CUA_REPL_ENABLED_SURFACES\s*=\s*(["'])([^"']*)\1\s*(?:#.*)?$/mu.exec(body);
16793
+ if (!literal2)
16794
+ return { enabled: true, browser: false };
16795
+ const surfaces = new Set(literal2[2]?.split(",").map((surface) => surface.trim()));
16796
+ return { enabled: surfaces.has("computer"), browser: surfaces.has("browser") };
16797
+ }
16798
+ function stanza(launch, state) {
16799
+ const trusted = `${launch.codexHome}:${launch.nodeModules}`;
16800
+ const services = {};
16801
+ if (state.browser)
16802
+ services.browser = "@oai/browser-desktop/service";
16803
+ if (state.enabled)
16804
+ services.sky = "@oai/sky/service";
16805
+ const surfaces = [state.browser ? "browser" : "", state.enabled ? "computer" : ""].filter(Boolean).join(",");
16806
+ const backends = state.browser ? 'BROWSER_USE_AVAILABLE_BACKENDS = "iab"\n' : "";
16807
+ const active = state.enabled || state.browser;
16808
+ return `${TABLE}
16809
+ command = ${JSON.stringify(launch.node)}
16810
+ args = [${JSON.stringify(launch.cuaRepl)}]
16811
+ enabled = ${active ? "true" : "false"}
16812
+ startup_timeout_sec = 120
16813
+
16814
+ ${ENV_TABLE}
16815
+ NODE_REPL_TRUSTED_SERVICES = ${JSON.stringify(JSON.stringify(services))}
16816
+ NODE_REPL_TRUSTED_CODE_PATHS = ${JSON.stringify(trusted)}
16817
+ NODE_REPL_NODE_PATH = ${JSON.stringify(launch.node)}
16818
+ CODEX_HOME = ${JSON.stringify(launch.codexHome)}
16819
+ CUA_REPL_NODE_REPL_PATH = ${JSON.stringify(launch.nodeRepl)}
16820
+ NODE_REPL_NODE_MODULE_DIRS = ${JSON.stringify(launch.nodeModules)}
16821
+ NODE_REPL_NATIVE_PIPE_CONNECT_TIMEOUT_MS = "1000"
16822
+ SKY_CUA_SERVICE_PATH = ${JSON.stringify(launch.skyApp)}
16823
+ CODEX_CLI_PATH = ${JSON.stringify(launch.codexCli)}
16824
+ ${backends}CUA_REPL_ENABLED_SURFACES = ${JSON.stringify(surfaces)}
16825
+ `;
16826
+ }
16827
+ async function readPreference(environment) {
16828
+ try {
16829
+ const document = JSON.parse(await readFile3(path8.join(dataDirectory(environment), PREFERENCE_FILE), "utf8"));
16830
+ return {
16831
+ ...typeof document.enabled === "boolean" ? { enabled: document.enabled } : {},
16832
+ ...typeof document.browser === "boolean" ? { browser: document.browser } : {},
16833
+ ...typeof document.applyError === "string" && document.applyError ? { applyError: document.applyError } : {}
16834
+ };
16835
+ } catch (error53) {
16836
+ if (isNotFound(error53))
16837
+ return void 0;
16838
+ throw new GrokComputerUseError("Could not read Grok Computer Use settings");
16839
+ }
16840
+ }
16841
+ async function writePreference(environment, state) {
16842
+ const document = {
16843
+ ...typeof state.enabled === "boolean" ? { enabled: state.enabled } : {},
16844
+ ...typeof state.browser === "boolean" ? { browser: state.browser } : {},
16845
+ ...state.applyError ? { applyError: state.applyError } : {}
16846
+ };
16847
+ await writeAtomically(path8.join(dataDirectory(environment), PREFERENCE_FILE), `${JSON.stringify(document)}
16848
+ `);
16849
+ }
16850
+ async function readGrokConfig(environment) {
16851
+ try {
16852
+ return await readFile3(path8.join(grokHome2(environment), "config.toml"), "utf8");
16853
+ } catch (error53) {
16854
+ if (isNotFound(error53))
16855
+ return "";
16856
+ throw new GrokComputerUseError("Could not read Grok config");
16857
+ }
16858
+ }
16859
+ async function writeGrokConfig(environment, text) {
16860
+ await writeAtomically(path8.join(grokHome2(environment), "config.toml"), text.endsWith("\n") ? text : `${text}
16861
+ `);
16862
+ }
16863
+ async function currentState(environment, preference) {
16864
+ const resolved = preference ?? await readPreference(environment);
16865
+ const inferred = resolved?.enabled === void 0 ? inferredSurfaces(await readGrokConfig(environment)) : void 0;
16866
+ return {
16867
+ enabled: resolved?.enabled ?? inferred?.enabled ?? false,
16868
+ browser: resolved ? resolved.browser ?? false : inferred?.browser ?? false,
16869
+ ...resolved?.applyError ? { applyError: resolved.applyError } : {}
16870
+ };
16871
+ }
16872
+ async function surfaceFiles(launch) {
16873
+ if (!launch)
16874
+ return { computer: false, browser: false };
16875
+ const [computer, browser] = await Promise.all([
16876
+ computerFilesPresent(launch),
16877
+ browserFilesPresent(launch)
16878
+ ]);
16879
+ return { computer, browser };
16880
+ }
16881
+ async function writeConfigForState(state, launch, files, environment) {
16882
+ const current = await readGrokConfig(environment);
16883
+ const range = tableRange(current, TABLE);
16884
+ const effective = {
16885
+ enabled: state.enabled && files.computer,
16886
+ browser: state.browser && files.browser && GROK_BROWSER_BINDING_SUPPORTED
16887
+ };
16888
+ if (!effective.enabled && !effective.browser && !range)
16889
+ return;
16890
+ if (!launch) {
16891
+ if (!range)
16892
+ return;
16893
+ const lines = current.split(/\n/);
16894
+ const body = lines.slice(range.start, range.end);
16895
+ const replaced = body.map((line) => /^enabled\s*=/u.test(line) ? "enabled = false" : line);
16896
+ if (!replaced.some((line) => /^enabled\s*=/u.test(line))) {
16897
+ replaced.splice(1, 0, "enabled = false");
16898
+ }
16899
+ lines.splice(range.start, range.end - range.start, ...replaced);
16900
+ await writeGrokConfig(environment, lines.join("\n"));
16901
+ return;
16902
+ }
16903
+ const stripped = removeTables(current, [ENV_TABLE, TABLE]).replace(/\s+$/u, "\n");
16904
+ await writeGrokConfig(environment, `${stripped.trimEnd()}
16905
+
16906
+ ${stanza(launch, effective)}`);
16907
+ }
16908
+ async function applyGrokComputerUsePreference(environment = process.env, platform = process.platform) {
16909
+ await withGrokComputerUseLock(dataDirectory(environment), grokHome2(environment), async () => {
16910
+ const preference = await readPreference(environment);
16911
+ if (preference === void 0)
16912
+ return;
16913
+ const launch = await discoverGrokComputerUseLaunch(environment, platform);
16914
+ const files = await surfaceFiles(launch);
16915
+ const state = await currentState(environment, preference);
16916
+ try {
16917
+ await writeConfigForState(state, launch, files, environment);
16918
+ if (state.applyError)
16919
+ await writePreference(environment, { enabled: state.enabled, browser: state.browser });
16920
+ } catch (error53) {
16921
+ const applyError = error53 instanceof GrokComputerUseError ? error53.message : APPLY_FAILED;
16922
+ await writePreference(environment, {
16923
+ enabled: state.enabled,
16924
+ browser: state.browser,
16925
+ applyError
16926
+ }).catch(() => void 0);
16927
+ throw error53 instanceof GrokComputerUseError ? error53 : new GrokComputerUseError(APPLY_FAILED);
16928
+ }
16929
+ });
16930
+ }
16931
+
16529
16932
  // ../../harness-adapter/dist/approval.js
16530
16933
  function invalidRequest(message) {
16531
16934
  return { code: "invalidRequest", message, retryable: false };
@@ -16853,9 +17256,9 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
16853
17256
 
16854
17257
  // dist/acp-transport.js
16855
17258
  import { spawn, spawnSync } from "node:child_process";
16856
- import { readdir, readFile as readFile3 } from "node:fs/promises";
16857
- import os5 from "node:os";
16858
- import path13 from "node:path";
17259
+ import { readdir, readFile as readFile4 } from "node:fs/promises";
17260
+ import os6 from "node:os";
17261
+ import path15 from "node:path";
16859
17262
  import { Readable, Writable } from "node:stream";
16860
17263
 
16861
17264
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -21043,8 +21446,8 @@ function parseGrokAvailableCommands(value) {
21043
21446
  });
21044
21447
  }
21045
21448
  function isGrokSkill(command) {
21046
- const path17 = command.meta?.path;
21047
- return typeof path17 === "string" && /(^|[\\/])SKILL\.md$/u.test(path17) || typeof command.meta?.qualifiedName === "string";
21449
+ const path19 = command.meta?.path;
21450
+ return typeof path19 === "string" && /(^|[\\/])SKILL\.md$/u.test(path19) || typeof command.meta?.qualifiedName === "string";
21048
21451
  }
21049
21452
  function grokLiveCommands(native) {
21050
21453
  return native.map((command) => ({
@@ -21055,7 +21458,7 @@ function grokLiveCommands(native) {
21055
21458
  }
21056
21459
 
21057
21460
  // dist/command.js
21058
- import path7 from "node:path";
21461
+ import path9 from "node:path";
21059
21462
  var GrokExecutableError = class extends Error {
21060
21463
  code = "GROK_NOT_FOUND";
21061
21464
  };
@@ -21084,7 +21487,7 @@ function resolveGrokExecutable(input = {}) {
21084
21487
  });
21085
21488
  if (!resolution)
21086
21489
  throw new GrokExecutableError("Grok CLI is not installed");
21087
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path7.resolve(resolution.executable);
21490
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path9.resolve(resolution.executable);
21088
21491
  }
21089
21492
  function grokInvocation(command, platform = process.platform, modelId) {
21090
21493
  const arguments_ = ["agent", "--no-leader"];
@@ -21097,11 +21500,11 @@ function grokInvocation(command, platform = process.platform, modelId) {
21097
21500
 
21098
21501
  // dist/grok-fork.js
21099
21502
  import { isDeepStrictEqual } from "node:util";
21100
- import path11 from "node:path";
21503
+ import path13 from "node:path";
21101
21504
 
21102
21505
  // dist/grok-file-change.js
21103
21506
  import { Buffer as Buffer2 } from "node:buffer";
21104
- import path8 from "node:path";
21507
+ import path10 from "node:path";
21105
21508
 
21106
21509
  // ../../../node_modules/diff/libesm/diff/base.js
21107
21510
  var Diff = class {
@@ -21203,16 +21606,16 @@ var Diff = class {
21203
21606
  }
21204
21607
  }
21205
21608
  }
21206
- addToPath(path17, added, removed, oldPosInc, options) {
21207
- const last = path17.lastComponent;
21609
+ addToPath(path19, added, removed, oldPosInc, options) {
21610
+ const last = path19.lastComponent;
21208
21611
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
21209
21612
  return {
21210
- oldPos: path17.oldPos + oldPosInc,
21613
+ oldPos: path19.oldPos + oldPosInc,
21211
21614
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
21212
21615
  };
21213
21616
  } else {
21214
21617
  return {
21215
- oldPos: path17.oldPos + oldPosInc,
21618
+ oldPos: path19.oldPos + oldPosInc,
21216
21619
  lastComponent: { count: 1, added, removed, previousComponent: last }
21217
21620
  };
21218
21621
  }
@@ -21525,13 +21928,13 @@ function isRecord5(value) {
21525
21928
  return typeof value === "object" && value !== null && !Array.isArray(value);
21526
21929
  }
21527
21930
  function validAbsolutePath(value) {
21528
- return typeof value === "string" && path8.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
21931
+ return typeof value === "string" && path10.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
21529
21932
  }
21530
21933
  function displayPath(nativePath, cwd) {
21531
- const resolvedCwd = path8.resolve(cwd);
21532
- const resolvedPath = path8.resolve(nativePath);
21533
- const relative = path8.relative(resolvedCwd, resolvedPath);
21534
- const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path8.sep}`);
21934
+ const resolvedCwd = path10.resolve(cwd);
21935
+ const resolvedPath = path10.resolve(nativePath);
21936
+ const relative = path10.relative(resolvedCwd, resolvedPath);
21937
+ const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path10.sep}`);
21535
21938
  const selected = inside ? relative : resolvedPath;
21536
21939
  const normalized = selected.replaceAll("\\", "/");
21537
21940
  if (normalized.length === 0 || normalized === ".")
@@ -21592,12 +21995,12 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
21592
21995
  }
21593
21996
 
21594
21997
  // dist/grok-generated-image.js
21595
- import path10 from "node:path";
21998
+ import path12 from "node:path";
21596
21999
 
21597
22000
  // dist/local-media-markdown.js
21598
22001
  import { existsSync, statSync } from "node:fs";
21599
- import os4 from "node:os";
21600
- import path9 from "node:path";
22002
+ import os5 from "node:os";
22003
+ import path11 from "node:path";
21601
22004
  var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
21602
22005
  ".aac",
21603
22006
  ".gif",
@@ -21616,14 +22019,14 @@ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
21616
22019
  ".webp"
21617
22020
  ]);
21618
22021
  function grokMediaResolveRoots(cwd, sessionDirectory) {
21619
- const roots = [path9.resolve(cwd)];
22022
+ const roots = [path11.resolve(cwd)];
21620
22023
  if (sessionDirectory) {
21621
- const session = path9.resolve(sessionDirectory);
21622
- roots.push(session, path9.join(session, "videos"), path9.join(session, "images"));
22024
+ const session = path11.resolve(sessionDirectory);
22025
+ roots.push(session, path11.join(session, "videos"), path11.join(session, "images"));
21623
22026
  }
21624
- const home = process.env.HOME ?? process.env.USERPROFILE ?? os4.homedir();
22027
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? os5.homedir();
21625
22028
  if (home)
21626
- roots.push(path9.join(home, "Downloads"));
22029
+ roots.push(path11.join(home, "Downloads"));
21627
22030
  return roots;
21628
22031
  }
21629
22032
  function rewriteLocalMediaMarkdown(text, roots, options = {}) {
@@ -21724,7 +22127,7 @@ function parseInlineCode(text, start) {
21724
22127
  return { closed: false, content: text.slice(start + 1), end: text.length };
21725
22128
  }
21726
22129
  function mediaMarkdownImage(absolutePath) {
21727
- const name = path9.basename(absolutePath).replaceAll("]", "\\]");
22130
+ const name = path11.basename(absolutePath).replaceAll("]", "\\]");
21728
22131
  return `![${name}](${formatMarkdownDestination(absolutePath, false)})`;
21729
22132
  }
21730
22133
  function parseMarkdownImage(text, start) {
@@ -21849,11 +22252,11 @@ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
21849
22252
  if (!hasMediaExtension(stripped))
21850
22253
  return null;
21851
22254
  if (isAbsoluteMediaPath(stripped)) {
21852
- const absolute = path9.resolve(stripped);
22255
+ const absolute = path11.resolve(stripped);
21853
22256
  return exists(absolute) ? absolute : null;
21854
22257
  }
21855
22258
  for (const root of roots) {
21856
- const absolute = path9.resolve(root, stripped);
22259
+ const absolute = path11.resolve(root, stripped);
21857
22260
  if (exists(absolute))
21858
22261
  return absolute;
21859
22262
  }
@@ -21875,11 +22278,11 @@ function stripFileUrl(value) {
21875
22278
  }
21876
22279
  }
21877
22280
  function isAbsoluteMediaPath(value) {
21878
- return path9.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
22281
+ return path11.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
21879
22282
  }
21880
22283
  function hasMediaExtension(value) {
21881
22284
  const pathname = value.split(/[?#]/, 1)[0] ?? value;
21882
- return MEDIA_EXTENSIONS.has(path9.extname(pathname).toLowerCase());
22285
+ return MEDIA_EXTENSIONS.has(path11.extname(pathname).toLowerCase());
21883
22286
  }
21884
22287
  function mediaFileExists(absolutePath) {
21885
22288
  try {
@@ -21909,7 +22312,7 @@ function fromNativeRecord(value, exists) {
21909
22312
  const savedPath = stringField(value, "path");
21910
22313
  if (!validAbsolutePath(savedPath))
21911
22314
  return null;
21912
- const resolved = path10.resolve(savedPath);
22315
+ const resolved = path12.resolve(savedPath);
21913
22316
  if (!exists(resolved))
21914
22317
  return null;
21915
22318
  const filename = stringField(value, "filename");
@@ -22975,11 +23378,11 @@ function parseGrokForkResponse(value) {
22975
23378
  }
22976
23379
  function projectRelativePath(value, cwds) {
22977
23380
  const normalized = value.replaceAll("\\", "/");
22978
- if (!path11.isAbsolute(value))
23381
+ if (!path13.isAbsolute(value))
22979
23382
  return normalized;
22980
23383
  for (const cwd of cwds) {
22981
- const relative = path11.relative(path11.resolve(cwd), path11.resolve(value));
22982
- if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path11.sep}`)) {
23384
+ const relative = path13.relative(path13.resolve(cwd), path13.resolve(value));
23385
+ if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path13.sep}`)) {
22983
23386
  return relative.replaceAll("\\", "/");
22984
23387
  }
22985
23388
  }
@@ -23044,8 +23447,8 @@ async function forkGrokSession(input) {
23044
23447
  error: error51("sessionNotFound", "Grok Native Session is unavailable")
23045
23448
  };
23046
23449
  }
23047
- const sourceCwd = path11.resolve(located.cwd);
23048
- const targetCwd = path11.resolve(input.cwd);
23450
+ const sourceCwd = path13.resolve(located.cwd);
23451
+ const targetCwd = path13.resolve(input.cwd);
23049
23452
  const source = await readSnapshot({ ...input, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
23050
23453
  if (!source.ok)
23051
23454
  return source;
@@ -23228,7 +23631,7 @@ function parseGrokCompactResult(value, cancelled = false) {
23228
23631
  }
23229
23632
 
23230
23633
  // dist/grok-rewind.js
23231
- import path12 from "node:path";
23634
+ import path14 from "node:path";
23232
23635
  var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
23233
23636
  function error52(code, message, retryable = false) {
23234
23637
  return { code, message, retryable };
@@ -23301,8 +23704,8 @@ async function rewindGrokLastTurn(input) {
23301
23704
  error: error52("sessionNotFound", "Grok Native Session is unavailable")
23302
23705
  };
23303
23706
  }
23304
- const sourceCwd = path12.resolve(located.cwd);
23305
- const targetCwd = path12.resolve(input.cwd);
23707
+ const sourceCwd = path14.resolve(located.cwd);
23708
+ const targetCwd = path14.resolve(input.cwd);
23306
23709
  if (sourceCwd !== targetCwd) {
23307
23710
  return {
23308
23711
  ok: false,
@@ -23356,6 +23759,195 @@ async function rewindGrokLastTurn(input) {
23356
23759
  return { ok: true, value: { sessionId } };
23357
23760
  }
23358
23761
 
23762
+ // dist/grok-elicitation.js
23763
+ var GROK_MCP_ELICIT_METHOD = "_x.ai/mcp/elicit";
23764
+ var GROK_ELICIT_TITLE_MAX_LENGTH = 150;
23765
+ var GROK_ELICIT_DESCRIPTION_MAX_LENGTH = 500;
23766
+ var FORM_KEYS = /* @__PURE__ */ new Set([
23767
+ "sessionId",
23768
+ "toolCallId",
23769
+ "serverName",
23770
+ "message",
23771
+ "mode",
23772
+ "requestedSchema",
23773
+ "persist"
23774
+ ]);
23775
+ var URL_KEYS = /* @__PURE__ */ new Set([
23776
+ "sessionId",
23777
+ "toolCallId",
23778
+ "serverName",
23779
+ "message",
23780
+ "mode",
23781
+ "url",
23782
+ "elicitationId"
23783
+ ]);
23784
+ var SCHEMA_KEYS = /* @__PURE__ */ new Set(["type", "properties", "required"]);
23785
+ var GROK_CLOCK_ELICIT_FIXTURE = {
23786
+ sessionId: "session-1",
23787
+ toolCallId: "elicit-clock-1",
23788
+ serverName: "cua_repl",
23789
+ message: 'Allow Computer Use to use "Clock"?',
23790
+ mode: "form"
23791
+ };
23792
+ var GROK_CLOCK_ELICIT_PERSIST_FIXTURE = {
23793
+ ...GROK_CLOCK_ELICIT_FIXTURE,
23794
+ persist: ["session", "always"]
23795
+ };
23796
+ function isRecord13(value) {
23797
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23798
+ }
23799
+ function nonEmptyString(value) {
23800
+ return typeof value === "string" && value.trim().length > 0 ? value : void 0;
23801
+ }
23802
+ function hasOnlyKeys(record2, allowed) {
23803
+ return Object.keys(record2).every((key) => allowed.has(key));
23804
+ }
23805
+ function clampText(value, max) {
23806
+ return value.length <= max ? value : value.slice(0, max);
23807
+ }
23808
+ function parsePersistOffer(value) {
23809
+ if (value === void 0)
23810
+ return void 0;
23811
+ if (!Array.isArray(value) || value.length === 0)
23812
+ return "invalid";
23813
+ let session = false;
23814
+ let always = false;
23815
+ const seen = /* @__PURE__ */ new Set();
23816
+ for (const item of value) {
23817
+ if (typeof item !== "string" || item !== item.trim())
23818
+ return "invalid";
23819
+ if (seen.has(item))
23820
+ return "invalid";
23821
+ seen.add(item);
23822
+ if (item === "session")
23823
+ session = true;
23824
+ else if (item === "always")
23825
+ always = true;
23826
+ else
23827
+ return "invalid";
23828
+ }
23829
+ const out = [];
23830
+ if (session)
23831
+ out.push("session");
23832
+ if (always)
23833
+ out.push("always");
23834
+ return out.length > 0 ? out : "invalid";
23835
+ }
23836
+ function schemaIsSupportedEmptyObject(schema) {
23837
+ if (!isRecord13(schema) || !hasOnlyKeys(schema, SCHEMA_KEYS) || schema.type !== "object") {
23838
+ return false;
23839
+ }
23840
+ if (schema.properties !== void 0) {
23841
+ if (!isRecord13(schema.properties) || Object.keys(schema.properties).length !== 0)
23842
+ return false;
23843
+ }
23844
+ if (schema.required !== void 0) {
23845
+ if (!Array.isArray(schema.required) || schema.required.length !== 0)
23846
+ return false;
23847
+ }
23848
+ return true;
23849
+ }
23850
+ function parseGrokMcpElicitParams(params) {
23851
+ if (!isRecord13(params))
23852
+ return { status: "invalid", message: "elicitation params must be an object" };
23853
+ const sessionId = nonEmptyString(params.sessionId);
23854
+ const toolCallId = nonEmptyString(params.toolCallId);
23855
+ const serverName = nonEmptyString(params.serverName);
23856
+ const message = nonEmptyString(params.message);
23857
+ if (!sessionId || !toolCallId || !serverName || !message) {
23858
+ return {
23859
+ status: "invalid",
23860
+ message: "elicitation requires sessionId, toolCallId, serverName, and message"
23861
+ };
23862
+ }
23863
+ if (params.mode === "url") {
23864
+ if (!hasOnlyKeys(params, URL_KEYS)) {
23865
+ return { status: "invalid", message: "URL elicitation contains unreviewed fields" };
23866
+ }
23867
+ if (!nonEmptyString(params.url) || !nonEmptyString(params.elicitationId)) {
23868
+ return { status: "invalid", message: "URL elicitation requires url and elicitationId" };
23869
+ }
23870
+ return { status: "unsupported" };
23871
+ }
23872
+ if (params.mode !== "form") {
23873
+ return { status: "invalid", message: "elicitation mode must be form or url" };
23874
+ }
23875
+ if (!hasOnlyKeys(params, FORM_KEYS)) {
23876
+ return { status: "invalid", message: "form elicitation contains unreviewed fields" };
23877
+ }
23878
+ if (params.requestedSchema !== void 0) {
23879
+ if (!isRecord13(params.requestedSchema)) {
23880
+ return { status: "invalid", message: "requestedSchema must be an object" };
23881
+ }
23882
+ if (!schemaIsSupportedEmptyObject(params.requestedSchema))
23883
+ return { status: "unsupported" };
23884
+ }
23885
+ const persist = parsePersistOffer(params.persist);
23886
+ if (persist === "invalid") {
23887
+ return {
23888
+ status: "invalid",
23889
+ message: "persist must be a unique array of session and/or always"
23890
+ };
23891
+ }
23892
+ return {
23893
+ status: "form",
23894
+ request: {
23895
+ sessionId,
23896
+ toolCallId,
23897
+ serverName,
23898
+ message,
23899
+ mode: "form",
23900
+ ...persist ? { persist } : {}
23901
+ }
23902
+ };
23903
+ }
23904
+ function grokMcpElicitAccept(persist) {
23905
+ return { outcome: "accept", content: {}, ...persist ? { persist } : {} };
23906
+ }
23907
+ function grokMcpElicitDecline() {
23908
+ return { outcome: "decline" };
23909
+ }
23910
+ function grokMcpElicitCancel() {
23911
+ return { outcome: "cancel" };
23912
+ }
23913
+ function grokMcpElicitResponseForAction(effect) {
23914
+ if (effect === "allowOnce")
23915
+ return grokMcpElicitAccept();
23916
+ if (effect === "allowAlways")
23917
+ return grokMcpElicitAccept("always");
23918
+ if (effect === "deny")
23919
+ return grokMcpElicitDecline();
23920
+ return grokMcpElicitCancel();
23921
+ }
23922
+ function grokMcpElicitApprovalActions(persist) {
23923
+ const actions = [
23924
+ { id: "allow-once", label: "Allow once", effect: "allowOnce" }
23925
+ ];
23926
+ if (persist?.includes("always")) {
23927
+ actions.push({ id: "allow-always", label: "Always allow", effect: "allowAlways" });
23928
+ }
23929
+ actions.push({ id: "deny", label: "Deny", effect: "deny" });
23930
+ return actions;
23931
+ }
23932
+ function projectGrokMcpElicitApproval(input) {
23933
+ const title = clampText(`${input.request.serverName}: ${input.request.message}`, GROK_ELICIT_TITLE_MAX_LENGTH);
23934
+ const description = clampText(input.request.message, GROK_ELICIT_DESCRIPTION_MAX_LENGTH);
23935
+ return {
23936
+ type: "approval",
23937
+ interactionId: input.interactionId,
23938
+ turnId: input.turnId,
23939
+ title,
23940
+ description,
23941
+ subject: { type: "nativeAction" },
23942
+ actions: grokMcpElicitApprovalActions(input.request.persist)
23943
+ };
23944
+ }
23945
+ function grokElicitationResolvedToolCallId(update) {
23946
+ if (!isRecord13(update) || update.sessionUpdate !== "interaction_resolved")
23947
+ return void 0;
23948
+ return nonEmptyString(update.tool_call_id) ?? nonEmptyString(update.toolCallId);
23949
+ }
23950
+
23359
23951
  // dist/permission-modes.js
23360
23952
  var nativePermissionModes = /* @__PURE__ */ new Set(["ask", "auto", "always-approve"]);
23361
23953
  var GROK_DEFAULT_PERMISSION_MODE_ID = harnessPermissionModeIdSchema.parse("ask");
@@ -23442,16 +24034,16 @@ var GrokTransportError = class extends Error {
23442
24034
  this.name = "GrokTransportError";
23443
24035
  }
23444
24036
  };
23445
- function isRecord13(value) {
24037
+ function isRecord14(value) {
23446
24038
  return typeof value === "object" && value !== null && !Array.isArray(value);
23447
24039
  }
23448
24040
  function acpToolName(update, metadata) {
23449
- if (!isRecord13(update))
24041
+ if (!isRecord14(update))
23450
24042
  return void 0;
23451
24043
  if (typeof update.name === "string" && update.name.length > 0)
23452
24044
  return update.name;
23453
- const meta3 = isRecord13(update._meta) ? update._meta : metadata;
23454
- const tool = meta3 && isRecord13(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
24045
+ const meta3 = isRecord14(update._meta) ? update._meta : metadata;
24046
+ const tool = meta3 && isRecord14(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
23455
24047
  return tool && typeof tool.name === "string" && tool.name.length > 0 ? tool.name : void 0;
23456
24048
  }
23457
24049
  function errorText(error53) {
@@ -23507,7 +24099,7 @@ function signalProcessTree(child, signal) {
23507
24099
  try {
23508
24100
  process.kill(-child.pid, signal);
23509
24101
  } catch (error53) {
23510
- if (!isRecord13(error53) || error53.code !== "ESRCH")
24102
+ if (!isRecord14(error53) || error53.code !== "ESRCH")
23511
24103
  throw error53;
23512
24104
  }
23513
24105
  }
@@ -23550,6 +24142,14 @@ function transportEvent(update, metadata) {
23550
24142
  const subagent = grokSubagentEventFromUpdate(extension);
23551
24143
  if (subagent)
23552
24144
  return subagent;
24145
+ const resolvedToolCallId = grokElicitationResolvedToolCallId(extension);
24146
+ if (resolvedToolCallId) {
24147
+ return {
24148
+ type: "elicitation.resolved",
24149
+ toolCallId: resolvedToolCallId,
24150
+ ...metadata ? { metadata } : {}
24151
+ };
24152
+ }
23553
24153
  switch (update.sessionUpdate) {
23554
24154
  case "user_message_chunk":
23555
24155
  case "agent_message_chunk":
@@ -23597,34 +24197,34 @@ function transportEvent(update, metadata) {
23597
24197
  }
23598
24198
  function grokHomeDir(options) {
23599
24199
  const environment = { ...process.env, ...options.environment };
23600
- const home = environment.HOME ?? environment.USERPROFILE ?? os5.homedir();
23601
- return environment.GROK_HOME ?? path13.join(home, ".grok");
24200
+ const home = environment.HOME ?? environment.USERPROFILE ?? os6.homedir();
24201
+ return environment.GROK_HOME ?? path15.join(home, ".grok");
23602
24202
  }
23603
24203
  function grokNativeSessionDirectory(options, sessionId) {
23604
- return path13.join(grokHomeDir(options), "sessions", encodeURIComponent(path13.resolve(options.cwd)), sessionId);
24204
+ return path15.join(grokHomeDir(options), "sessions", encodeURIComponent(path15.resolve(options.cwd)), sessionId);
23605
24205
  }
23606
24206
  function nativeSessionFile(options, sessionId, fileName) {
23607
- return path13.join(grokNativeSessionDirectory(options, sessionId), fileName);
24207
+ return path15.join(grokNativeSessionDirectory(options, sessionId), fileName);
23608
24208
  }
23609
24209
  function nativeHistoryPath(options, sessionId) {
23610
24210
  return nativeSessionFile(options, sessionId, "updates.jsonl");
23611
24211
  }
23612
24212
  async function readNativeSignals(options, sessionId) {
23613
24213
  try {
23614
- return JSON.parse(await readFile3(nativeSessionFile(options, sessionId, "signals.json"), "utf8"));
24214
+ return JSON.parse(await readFile4(nativeSessionFile(options, sessionId, "signals.json"), "utf8"));
23615
24215
  } catch {
23616
24216
  return void 0;
23617
24217
  }
23618
24218
  }
23619
24219
  function isMissingFile(error53) {
23620
- return isRecord13(error53) && error53.code === "ENOENT";
24220
+ return isRecord14(error53) && error53.code === "ENOENT";
23621
24221
  }
23622
24222
  async function locateGrokNativeSession(options, sessionId) {
23623
24223
  if (sessionId.length === 0)
23624
24224
  return null;
23625
24225
  let entries;
23626
24226
  try {
23627
- entries = await readdir(path13.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
24227
+ entries = await readdir(path15.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
23628
24228
  } catch (error53) {
23629
24229
  if (isMissingFile(error53))
23630
24230
  return null;
@@ -23638,9 +24238,9 @@ async function locateGrokNativeSession(options, sessionId) {
23638
24238
  continue;
23639
24239
  let summaryRaw;
23640
24240
  try {
23641
- summaryRaw = await readFile3(path13.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
24241
+ summaryRaw = await readFile4(path15.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
23642
24242
  } catch (error53) {
23643
- if (isMissingFile(error53) || isRecord13(error53) && error53.code === "ENOTDIR")
24243
+ if (isMissingFile(error53) || isRecord14(error53) && error53.code === "ENOTDIR")
23644
24244
  continue;
23645
24245
  throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
23646
24246
  cause: error53
@@ -23652,11 +24252,11 @@ async function locateGrokNativeSession(options, sessionId) {
23652
24252
  } catch {
23653
24253
  continue;
23654
24254
  }
23655
- if (!isRecord13(parsed))
24255
+ if (!isRecord14(parsed))
23656
24256
  continue;
23657
24257
  const info = parsed.info;
23658
- const cwd = isRecord13(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path13.resolve(info.cwd) : path13.resolve(decodeURIComponent(entry.name));
23659
- const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path13.resolve(parsed.source_workspace_dir) : void 0;
24258
+ const cwd = isRecord14(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path15.resolve(info.cwd) : path15.resolve(decodeURIComponent(entry.name));
24259
+ const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path15.resolve(parsed.source_workspace_dir) : void 0;
23660
24260
  matches.push({
23661
24261
  cwd,
23662
24262
  ...sourceWorkspaceDir ? { sourceWorkspaceDir } : {}
@@ -23666,7 +24266,7 @@ async function locateGrokNativeSession(options, sessionId) {
23666
24266
  }
23667
24267
  async function readGrokNativeHistory(options, sessionId) {
23668
24268
  try {
23669
- return parseNativeHistory(await readFile3(nativeHistoryPath({ ...options, cwd: path13.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
24269
+ return parseNativeHistory(await readFile4(nativeHistoryPath({ ...options, cwd: path15.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
23670
24270
  } catch (error53) {
23671
24271
  if (isMissingFile(error53))
23672
24272
  return [];
@@ -23688,12 +24288,12 @@ function parseNativeHistory(contents, sessionId) {
23688
24288
  } catch {
23689
24289
  throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
23690
24290
  }
23691
- if (!isRecord13(record2) || !isRecord13(record2.params))
24291
+ if (!isRecord14(record2) || !isRecord14(record2.params))
23692
24292
  continue;
23693
24293
  const params = record2.params;
23694
- if (params.sessionId !== sessionId || !isRecord13(params.update))
24294
+ if (params.sessionId !== sessionId || !isRecord14(params.update))
23695
24295
  continue;
23696
- const metadata = isRecord13(params._meta) ? params._meta : void 0;
24296
+ const metadata = isRecord14(params._meta) ? params._meta : void 0;
23697
24297
  const event = transportEvent(params.update, metadata);
23698
24298
  if (event)
23699
24299
  events.push(metadata ? { ...event, metadata } : event);
@@ -23755,7 +24355,7 @@ var GrokAcpTransport = class {
23755
24355
  if (!this.#connection)
23756
24356
  throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
23757
24357
  const result = await withTimeout(this.#connection.request("_x.ai/session/usage", { sessionId: this.sessionId }), this.#options.commandTimeoutMs, "Grok Session usage");
23758
- return isRecord13(result) ? result.usage : void 0;
24358
+ return isRecord14(result) ? result.usage : void 0;
23759
24359
  }
23760
24360
  async readHistory(sessionId, cwd = this.#options.cwd) {
23761
24361
  return readGrokNativeHistory({ ...this.#options, cwd }, sessionId);
@@ -23925,6 +24525,7 @@ var GrokAcpTransport = class {
23925
24525
  const connection = new ClientSideConnection(() => ({
23926
24526
  sessionUpdate: (params) => this.#handleUpdate(params),
23927
24527
  requestPermission: (params) => this.#handlePermission(params),
24528
+ extMethod: (method, params) => this.#handleExtMethod(method, params),
23928
24529
  extNotification: (method, params) => this.#handleExtensionNotification(method, params)
23929
24530
  }), stream);
23930
24531
  this.#connection = connection;
@@ -23945,14 +24546,14 @@ var GrokAcpTransport = class {
23945
24546
  this.#initialize = initialize;
23946
24547
  return initialize;
23947
24548
  }
23948
- async runTurn(text, onEvent, onPermission) {
24549
+ async runTurn(text, onEvent, onPermission, onElicitation) {
23949
24550
  const connection = this.#connection;
23950
24551
  if (!connection || !this.#sessionId || this.#closed || this.#closing) {
23951
24552
  throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
23952
24553
  }
23953
24554
  if (this.#activePrompt)
23954
24555
  throw new Error("Grok ACP Session already has an active Prompt");
23955
- const active = { onEvent, onPermission };
24556
+ const active = { onEvent, onPermission, onElicitation };
23956
24557
  this.#activePrompt = active;
23957
24558
  try {
23958
24559
  return await connection.prompt({
@@ -24006,10 +24607,14 @@ var GrokAcpTransport = class {
24006
24607
  const response = await connection.request("session/set_model", {
24007
24608
  sessionId: this.#sessionId,
24008
24609
  modelId,
24009
- ...reasoningEffort ? { reasoningEffort } : {},
24010
- ...contextWindowTokens !== void 0 ? { _meta: { contextWindow: contextWindowTokens } } : {}
24610
+ ...reasoningEffort || contextWindowTokens !== void 0 ? {
24611
+ _meta: {
24612
+ ...reasoningEffort ? { reasoningEffort } : {},
24613
+ ...contextWindowTokens !== void 0 ? { contextWindow: contextWindowTokens } : {}
24614
+ }
24615
+ } : {}
24011
24616
  });
24012
- if (!isRecord13(response) || !isRecord13(response._meta) || !isRecord13(response._meta.model)) {
24617
+ if (!isRecord14(response) || !isRecord14(response._meta) || !isRecord14(response._meta.model)) {
24013
24618
  throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
24014
24619
  }
24015
24620
  const selected = response._meta.model.Ok;
@@ -24061,7 +24666,7 @@ var GrokAcpTransport = class {
24061
24666
  this.#availableCommands = parseGrokAvailableCommands(update.availableCommands);
24062
24667
  return;
24063
24668
  }
24064
- const metadata = isRecord13(notification._meta) ? notification._meta : void 0;
24669
+ const metadata = isRecord14(notification._meta) ? notification._meta : void 0;
24065
24670
  const event = transportEvent(notification.update, metadata);
24066
24671
  if (!event)
24067
24672
  return;
@@ -24076,7 +24681,7 @@ var GrokAcpTransport = class {
24076
24681
  #handleExtensionNotification(method, params) {
24077
24682
  if (!isGrokExtensionSessionUpdateMethod(method))
24078
24683
  return;
24079
- if (typeof params.sessionId !== "string" || !isRecord13(params.update))
24684
+ if (typeof params.sessionId !== "string" || !isRecord14(params.update))
24080
24685
  return;
24081
24686
  this.#handleUpdate(params);
24082
24687
  }
@@ -24086,6 +24691,22 @@ var GrokAcpTransport = class {
24086
24691
  }
24087
24692
  return this.#activePrompt.onPermission({ request: params, options: params.options });
24088
24693
  }
24694
+ async #handleExtMethod(method, params) {
24695
+ if (method !== GROK_MCP_ELICIT_METHOD) {
24696
+ throw RequestError.methodNotFound(method);
24697
+ }
24698
+ const parsed = parseGrokMcpElicitParams(params);
24699
+ if (parsed.status === "invalid") {
24700
+ throw RequestError.invalidParams(void 0, parsed.message);
24701
+ }
24702
+ if (parsed.status === "unsupported" || this.#closed || this.#closing || this.#replay !== null || this.#activeCompact !== null || !this.#activePrompt) {
24703
+ return { ...grokMcpElicitCancel() };
24704
+ }
24705
+ if (parsed.request.sessionId !== this.#sessionId) {
24706
+ return { ...grokMcpElicitCancel() };
24707
+ }
24708
+ return { ...await this.#activePrompt.onElicitation(parsed.request) };
24709
+ }
24089
24710
  #fault(error53) {
24090
24711
  if (this.#closing || this.#closed)
24091
24712
  return;
@@ -24095,8 +24716,8 @@ var GrokAcpTransport = class {
24095
24716
 
24096
24717
  // dist/session-import.js
24097
24718
  import { createReadStream as createReadStream2 } from "node:fs";
24098
- import { opendir as opendir2, readFile as readFile4, stat } from "node:fs/promises";
24099
- import path14 from "node:path";
24719
+ import { opendir as opendir2, readFile as readFile5, stat } from "node:fs/promises";
24720
+ import path16 from "node:path";
24100
24721
  import { createInterface as createInterface2 } from "node:readline";
24101
24722
 
24102
24723
  // ../../harness-adapter/dist/session-import.js
@@ -24217,11 +24838,11 @@ var SessionImportScope = class {
24217
24838
  // dist/session-import.js
24218
24839
  var MAX_METADATA_BYTES = 4 * 1024 * 1024;
24219
24840
  var SUBAGENT_SESSION_KINDS = /* @__PURE__ */ new Set(["subagent", "subagent_resume"]);
24220
- function isRecord14(value) {
24841
+ function isRecord15(value) {
24221
24842
  return typeof value === "object" && value !== null && !Array.isArray(value);
24222
24843
  }
24223
24844
  async function readJson(file2, signal) {
24224
- return JSON.parse(await readFile4(file2, { encoding: "utf8", signal }));
24845
+ return JSON.parse(await readFile5(file2, { encoding: "utf8", signal }));
24225
24846
  }
24226
24847
  function processAlive(pid) {
24227
24848
  if (typeof pid !== "number" || !Number.isSafeInteger(pid) || pid <= 0)
@@ -24230,7 +24851,7 @@ function processAlive(pid) {
24230
24851
  process.kill(pid, 0);
24231
24852
  return true;
24232
24853
  } catch (error53) {
24233
- return isRecord14(error53) && error53.code === "EPERM";
24854
+ return isRecord15(error53) && error53.code === "EPERM";
24234
24855
  }
24235
24856
  }
24236
24857
  async function firstUserText(file2, signal) {
@@ -24247,10 +24868,10 @@ async function firstUserText(file2, signal) {
24247
24868
  } catch {
24248
24869
  continue;
24249
24870
  }
24250
- const update = isRecord14(entry) && isRecord14(entry.params) ? entry.params.update : null;
24251
- if (!isRecord14(update) || update.sessionUpdate !== "user_message_chunk")
24871
+ const update = isRecord15(entry) && isRecord15(entry.params) ? entry.params.update : null;
24872
+ if (!isRecord15(update) || update.sessionUpdate !== "user_message_chunk")
24252
24873
  continue;
24253
- const text = isRecord14(update.content) ? update.content.text : null;
24874
+ const text = isRecord15(update.content) ? update.content.text : null;
24254
24875
  return typeof text === "string" ? text : "";
24255
24876
  }
24256
24877
  return null;
@@ -24317,7 +24938,7 @@ var GrokSessionImport = class {
24317
24938
  const active = /* @__PURE__ */ new Set();
24318
24939
  let entries;
24319
24940
  try {
24320
- entries = await readJson(path14.join(this.#home(), "active_sessions.json"), signal);
24941
+ entries = await readJson(path16.join(this.#home(), "active_sessions.json"), signal);
24321
24942
  } catch (error53) {
24322
24943
  signal.throwIfAborted();
24323
24944
  if (isStorageAccessError(error53))
@@ -24327,14 +24948,14 @@ var GrokSessionImport = class {
24327
24948
  if (!Array.isArray(entries))
24328
24949
  return active;
24329
24950
  for (const entry of entries) {
24330
- if (isRecord14(entry) && typeof entry.session_id === "string" && processAlive(entry.pid))
24951
+ if (isRecord15(entry) && typeof entry.session_id === "string" && processAlive(entry.pid))
24331
24952
  active.add(entry.session_id);
24332
24953
  }
24333
24954
  return active;
24334
24955
  }
24335
24956
  /** Session ID to every directory claiming it. Enumerated links are not followed. */
24336
24957
  async #sessionDirectories(signal) {
24337
- const root = path14.join(this.#home(), "sessions");
24958
+ const root = path16.join(this.#home(), "sessions");
24338
24959
  const found = /* @__PURE__ */ new Map();
24339
24960
  const info = await optionalLstat(root);
24340
24961
  if (!info)
@@ -24345,7 +24966,7 @@ var GrokSessionImport = class {
24345
24966
  signal.throwIfAborted();
24346
24967
  if (!workspace.isDirectory())
24347
24968
  continue;
24348
- const workspaceDirectory = path14.join(root, workspace.name);
24969
+ const workspaceDirectory = path16.join(root, workspace.name);
24349
24970
  const sessions = await opendir2(workspaceDirectory).catch((error53) => {
24350
24971
  if (isMissingFileError(error53))
24351
24972
  return null;
@@ -24358,7 +24979,7 @@ var GrokSessionImport = class {
24358
24979
  if (!session.isDirectory())
24359
24980
  continue;
24360
24981
  const directories = found.get(session.name) ?? [];
24361
- directories.push(path14.join(workspaceDirectory, session.name));
24982
+ directories.push(path16.join(workspaceDirectory, session.name));
24362
24983
  found.set(session.name, directories);
24363
24984
  }
24364
24985
  }
@@ -24366,25 +24987,25 @@ var GrokSessionImport = class {
24366
24987
  }
24367
24988
  async #candidate(sessionDirectory, active, signal) {
24368
24989
  signal.throwIfAborted();
24369
- const nativeSessionId = path14.basename(sessionDirectory);
24990
+ const nativeSessionId = path16.basename(sessionDirectory);
24370
24991
  const files = [
24371
- path14.join(sessionDirectory, "summary.json"),
24372
- path14.join(sessionDirectory, "updates.jsonl")
24992
+ path16.join(sessionDirectory, "summary.json"),
24993
+ path16.join(sessionDirectory, "updates.jsonl")
24373
24994
  ];
24374
24995
  return readStableFiles(files, async ([summaryInfo, updates]) => {
24375
24996
  if (!summaryInfo?.isFile() || !updates?.isFile() || summaryInfo.size > MAX_METADATA_BYTES)
24376
24997
  return null;
24377
24998
  try {
24378
24999
  const summary = await readJson(files[0], signal);
24379
- if (!isRecord14(summary) || !isRecord14(summary.info) || summary.info.id !== nativeSessionId)
25000
+ if (!isRecord15(summary) || !isRecord15(summary.info) || summary.info.id !== nativeSessionId)
24380
25001
  return null;
24381
25002
  if (typeof summary.session_kind === "string" && SUBAGENT_SESSION_KINDS.has(summary.session_kind))
24382
25003
  return null;
24383
25004
  const nativeCwd = summary.info.cwd;
24384
- if (typeof nativeCwd !== "string" || !path14.isAbsolute(nativeCwd) || nativeCwd.includes("\0"))
25005
+ if (typeof nativeCwd !== "string" || !path16.isAbsolute(nativeCwd) || nativeCwd.includes("\0"))
24385
25006
  return null;
24386
- const cwd = path14.resolve(nativeCwd);
24387
- if (encodeURIComponent(cwd) !== path14.basename(path14.dirname(sessionDirectory)))
25007
+ const cwd = path16.resolve(nativeCwd);
25008
+ if (encodeURIComponent(cwd) !== path16.basename(path16.dirname(sessionDirectory)))
24388
25009
  return null;
24389
25010
  if (!(await stat(cwd)).isDirectory())
24390
25011
  return null;
@@ -24603,7 +25224,7 @@ var GrokSubagentLifecycle = class {
24603
25224
  };
24604
25225
 
24605
25226
  // dist/grok-models.js
24606
- function isRecord15(value) {
25227
+ function isRecord16(value) {
24607
25228
  return typeof value === "object" && value !== null && !Array.isArray(value);
24608
25229
  }
24609
25230
  function nonBlank(value) {
@@ -24615,7 +25236,7 @@ function thinkingOptions(value) {
24615
25236
  const seen = /* @__PURE__ */ new Set();
24616
25237
  const options = [];
24617
25238
  for (const candidate of value) {
24618
- if (!isRecord15(candidate) || !nonBlank(candidate.label))
25239
+ if (!isRecord16(candidate) || !nonBlank(candidate.label))
24619
25240
  continue;
24620
25241
  const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
24621
25242
  if (!id.success || seen.has(id.data))
@@ -24626,7 +25247,7 @@ function thinkingOptions(value) {
24626
25247
  return options;
24627
25248
  }
24628
25249
  function parseGrokModelState(value) {
24629
- if (!isRecord15(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
25250
+ if (!isRecord16(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
24630
25251
  return null;
24631
25252
  }
24632
25253
  const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
@@ -24638,12 +25259,12 @@ function parseGrokModelState(value) {
24638
25259
  const models = [];
24639
25260
  let currentThinkingOptionId;
24640
25261
  for (const candidate of value.availableModels) {
24641
- if (!isRecord15(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
25262
+ if (!isRecord16(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
24642
25263
  continue;
24643
25264
  const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
24644
25265
  if (!ref.success)
24645
25266
  continue;
24646
- const metadata = isRecord15(candidate._meta) ? candidate._meta : {};
25267
+ const metadata = isRecord16(candidate._meta) ? candidate._meta : {};
24647
25268
  const options2 = thinkingOptions(metadata.reasoningEfforts);
24648
25269
  if (Array.isArray(metadata.contextWindows) && metadata.contextWindows.includes(5e5)) {
24649
25270
  defaultContextWindowTokensByModel.set(ref.data.id, 5e5);
@@ -24682,10 +25303,10 @@ function parseGrokModelState(value) {
24682
25303
  };
24683
25304
  }
24684
25305
  function modelStateFromInitialize(response) {
24685
- return parseGrokModelState(isRecord15(response._meta) ? response._meta.modelState : void 0);
25306
+ return parseGrokModelState(isRecord16(response._meta) ? response._meta.modelState : void 0);
24686
25307
  }
24687
25308
  function modelStateFromSessionResponse(response) {
24688
- return parseGrokModelState(isRecord15(response) ? response.models : void 0);
25309
+ return parseGrokModelState(isRecord16(response) ? response.models : void 0);
24689
25310
  }
24690
25311
  function stateForGrokModel(modelState, nativeState, model2 = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
24691
25312
  const selectedModel = model2;
@@ -24704,12 +25325,12 @@ function stateForGrokModel(modelState, nativeState, model2 = modelState.currentM
24704
25325
  }
24705
25326
 
24706
25327
  // dist/grok-credits.js
24707
- import { readFile as readFile5 } from "node:fs/promises";
24708
- import os6 from "node:os";
24709
- import path15 from "node:path";
25328
+ import { readFile as readFile6 } from "node:fs/promises";
25329
+ import os7 from "node:os";
25330
+ import path17 from "node:path";
24710
25331
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
24711
25332
  var REQUEST_TIMEOUT_MS = 15e3;
24712
- function isRecord16(value) {
25333
+ function isRecord17(value) {
24713
25334
  return typeof value === "object" && value !== null && !Array.isArray(value);
24714
25335
  }
24715
25336
  function finitePercent(value) {
@@ -24718,15 +25339,15 @@ function finitePercent(value) {
24718
25339
  return Math.min(100, Math.max(0, value));
24719
25340
  }
24720
25341
  function nonNegativeCentValue(value) {
24721
- if (!isRecord16(value))
25342
+ if (!isRecord17(value))
24722
25343
  return void 0;
24723
25344
  const amount = value.val === void 0 ? 0 : value.val;
24724
25345
  if (typeof amount !== "number" || !Number.isFinite(amount) || amount < 0)
24725
25346
  return void 0;
24726
25347
  return amount;
24727
25348
  }
24728
- function grokHome2(environment) {
24729
- return environment.GROK_HOME ?? path15.join(environment.HOME ?? environment.USERPROFILE ?? os6.homedir(), ".grok");
25349
+ function grokHome3(environment) {
25350
+ return environment.GROK_HOME ?? path17.join(environment.HOME ?? environment.USERPROFILE ?? os7.homedir(), ".grok");
24730
25351
  }
24731
25352
  function periodTypeFrom(value) {
24732
25353
  if (typeof value !== "string")
@@ -24742,7 +25363,7 @@ function productUsageFrom(value) {
24742
25363
  if (!Array.isArray(value))
24743
25364
  return void 0;
24744
25365
  const products = value.flatMap((entry) => {
24745
- if (!isRecord16(entry) || typeof entry.product !== "string")
25366
+ if (!isRecord17(entry) || typeof entry.product !== "string")
24746
25367
  return [];
24747
25368
  const usagePercent = finitePercent(entry.usagePercent);
24748
25369
  const labels = {
@@ -24763,10 +25384,10 @@ function productUsageFrom(value) {
24763
25384
  return products.length > 0 ? products : void 0;
24764
25385
  }
24765
25386
  function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
24766
- if (!isRecord16(value) || !isRecord16(value.config))
25387
+ if (!isRecord17(value) || !isRecord17(value.config))
24767
25388
  return null;
24768
25389
  const config2 = value.config;
24769
- const period = isRecord16(config2.currentPeriod) ? config2.currentPeriod : void 0;
25390
+ const period = isRecord17(config2.currentPeriod) ? config2.currentPeriod : void 0;
24770
25391
  const periodType = periodTypeFrom(period?.type);
24771
25392
  const resetsAt = (typeof period?.end === "string" && period.end.length > 0 ? period.end : void 0) ?? (typeof config2.billingPeriodEnd === "string" && config2.billingPeriodEnd.length > 0 ? config2.billingPeriodEnd : void 0);
24772
25393
  let usedPercent = finitePercent(config2.creditUsagePercent);
@@ -24793,11 +25414,11 @@ function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()
24793
25414
  };
24794
25415
  }
24795
25416
  function selectAccessToken(auth, now) {
24796
- if (!isRecord16(auth))
25417
+ if (!isRecord17(auth))
24797
25418
  return null;
24798
- const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord16(value) && typeof value.key === "string" && value.key.length > 0).sort(([left], [right]) => Number(right.startsWith("https://auth.x.ai")) - Number(left.startsWith("https://auth.x.ai")));
25419
+ const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord17(value) && typeof value.key === "string" && value.key.length > 0).sort(([left], [right]) => Number(right.startsWith("https://auth.x.ai")) - Number(left.startsWith("https://auth.x.ai")));
24799
25420
  for (const [, value] of entries) {
24800
- if (!isRecord16(value) || typeof value.key !== "string")
25421
+ if (!isRecord17(value) || typeof value.key !== "string")
24801
25422
  continue;
24802
25423
  if (typeof value.expires_at === "string") {
24803
25424
  const expiresAt = Date.parse(value.expires_at);
@@ -24818,8 +25439,8 @@ async function fetchGrokAccount(input = {}) {
24818
25439
  if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((value) => value?.trim()))
24819
25440
  return null;
24820
25441
  const now = input.now ?? /* @__PURE__ */ new Date();
24821
- const authPath = path15.join(grokHome2(environment), "auth.json");
24822
- const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile5(authPath, "utf8");
25442
+ const authPath = path17.join(grokHome3(environment), "auth.json");
25443
+ const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile6(authPath, "utf8");
24823
25444
  const token = selectAccessToken(JSON.parse(raw), now);
24824
25445
  if (!token)
24825
25446
  return null;
@@ -24868,7 +25489,7 @@ async function fetchGrokCredits(input = {}) {
24868
25489
 
24869
25490
  // dist/grok-usage.js
24870
25491
  var USD_TICKS_PER_DOLLAR = 1e10;
24871
- function isRecord17(value) {
25492
+ function isRecord18(value) {
24872
25493
  return typeof value === "object" && value !== null && !Array.isArray(value);
24873
25494
  }
24874
25495
  function optionalToken(value) {
@@ -24885,7 +25506,7 @@ function combineUsage(base, next) {
24885
25506
  return base === null ? next : parseHostUsage({ ...base, ...next });
24886
25507
  }
24887
25508
  function usageFromNative(value) {
24888
- if (!isRecord17(value))
25509
+ if (!isRecord18(value))
24889
25510
  return null;
24890
25511
  const inputTokens = optionalToken(value.inputTokens);
24891
25512
  const cachedRead = optionalToken(value.cachedReadTokens);
@@ -24909,7 +25530,7 @@ function usageFromNative(value) {
24909
25530
  }
24910
25531
  }
24911
25532
  function usageFromResponse(value) {
24912
- if (!isRecord17(value))
25533
+ if (!isRecord18(value))
24913
25534
  return null;
24914
25535
  const buckets = [
24915
25536
  value.input_tokens,
@@ -25009,7 +25630,7 @@ var GrokTurnUsage = class {
25009
25630
  }
25010
25631
  };
25011
25632
  function usageFromSignals(value) {
25012
- if (!isRecord17(value))
25633
+ if (!isRecord18(value))
25013
25634
  return null;
25014
25635
  try {
25015
25636
  return parseHostUsage({
@@ -25029,7 +25650,7 @@ var summedUsageFields = [
25029
25650
  "totalTokens"
25030
25651
  ];
25031
25652
  function nativeCostTicks(value) {
25032
- if (!isRecord17(value))
25653
+ if (!isRecord18(value))
25033
25654
  return void 0;
25034
25655
  const ticks = value.costUsdTicks;
25035
25656
  if (typeof ticks !== "number" || !Number.isSafeInteger(ticks) || ticks < 0)
@@ -25037,7 +25658,7 @@ function nativeCostTicks(value) {
25037
25658
  return ticks;
25038
25659
  }
25039
25660
  function sessionCostFromNative(value, initialCostUsd) {
25040
- if (!isRecord17(value))
25661
+ if (!isRecord18(value))
25041
25662
  return void 0;
25042
25663
  if (value.costIsPartial !== void 0 && value.costIsPartial !== false)
25043
25664
  return void 0;
@@ -25066,7 +25687,7 @@ function sessionUsageFromHistory(events) {
25066
25687
  continue;
25067
25688
  const usage = usageFromNative(event.usage);
25068
25689
  const ticks2 = nativeCostTicks(event.usage);
25069
- const complete = isRecord17(event.usage) && (event.usage.usageIsIncomplete === void 0 || event.usage.usageIsIncomplete === false) && usage?.inputTokens !== void 0 && usage.cachedInputTokens !== void 0 && usage.cachedInputTokens <= usage.inputTokens;
25690
+ const complete = isRecord18(event.usage) && (event.usage.usageIsIncomplete === void 0 || event.usage.usageIsIncomplete === false) && usage?.inputTokens !== void 0 && usage.cachedInputTokens !== void 0 && usage.cachedInputTokens <= usage.inputTokens;
25070
25691
  latestByKey.set(key, { usage, complete, ...ticks2 !== void 0 ? { ticks: ticks2 } : {} });
25071
25692
  }
25072
25693
  if (latestByKey.size === 0)
@@ -25120,7 +25741,7 @@ function usageFromCompact(tokensAfter, contextWindowTokens) {
25120
25741
  function usageFromUpdate(update, metadata, contextWindowTokens) {
25121
25742
  try {
25122
25743
  if (update?.sessionUpdate === "usage_update") {
25123
- const cost = isRecord17(update.cost) ? update.cost : null;
25744
+ const cost = isRecord18(update.cost) ? update.cost : null;
25124
25745
  return parseHostUsage({
25125
25746
  contextUsedTokens: update.used,
25126
25747
  contextWindowTokens: update.size,
@@ -25370,6 +25991,7 @@ var GrokHarnessSession = class {
25370
25991
  subagents: this.#createSubagents(),
25371
25992
  completedItems: [],
25372
25993
  approvals: /* @__PURE__ */ new Map(),
25994
+ elicitations: /* @__PURE__ */ new Map(),
25373
25995
  cancellationRequested: false,
25374
25996
  beforeNativeTurnKeys: new Set(this.#snapshot.turns.map((turn) => turn.nativeTurnRef.nativeTurnKey)),
25375
25997
  completion,
@@ -25377,7 +25999,7 @@ var GrokHarnessSession = class {
25377
25999
  };
25378
26000
  this.#active = active;
25379
26001
  this.#event({ type: "turn.started", turnId: command.turnId });
25380
- void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request)).then((response) => this.#settleFromHistory(active, terminalOutcome2(response, active.cancellationRequested), response), (error53) => this.#settleFromHistory(active, {
26002
+ void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request), (request) => this.#requestElicitation(active, request)).then((response) => this.#settleFromHistory(active, terminalOutcome2(response, active.cancellationRequested), response), (error53) => this.#settleFromHistory(active, {
25381
26003
  status: "failed",
25382
26004
  error: normalizeError(error53, "nativeFailure")
25383
26005
  }));
@@ -25459,6 +26081,7 @@ var GrokHarnessSession = class {
25459
26081
  subagents: this.#createSubagents(),
25460
26082
  completedItems: [],
25461
26083
  approvals: /* @__PURE__ */ new Map(),
26084
+ elicitations: /* @__PURE__ */ new Map(),
25462
26085
  cancellationRequested: false,
25463
26086
  beforeNativeTurnKeys: /* @__PURE__ */ new Set(),
25464
26087
  completion,
@@ -25613,6 +26236,7 @@ var GrokHarnessSession = class {
25613
26236
  for (const approval of active.approvals.values()) {
25614
26237
  approval.resolve({ outcome: { outcome: "cancelled" } });
25615
26238
  }
26239
+ this.#cancelActiveElicitations(active);
25616
26240
  try {
25617
26241
  await this.#transport.cancel();
25618
26242
  return { ok: true, value: { cancellationRequested: true } };
@@ -25622,8 +26246,9 @@ var GrokHarnessSession = class {
25622
26246
  }
25623
26247
  async #respond(command) {
25624
26248
  const active = this.#active;
25625
- const pending = active?.approvals.get(command.interactionId);
25626
- if (!active || !pending)
26249
+ const permission = active?.approvals.get(command.interactionId);
26250
+ const elicitation = active?.elicitations.get(command.interactionId);
26251
+ if (!active || !permission && !elicitation)
25627
26252
  return { ok: false, error: invalidState("Grok Approval is not pending") };
25628
26253
  if (command.response.type !== "approval") {
25629
26254
  return {
@@ -25635,10 +26260,30 @@ var GrokHarnessSession = class {
25635
26260
  }
25636
26261
  };
25637
26262
  }
25638
- const validation = validateHostApprovalResponse(pending.interaction, command.response);
26263
+ const response = command.response;
26264
+ if (elicitation) {
26265
+ const validation2 = validateHostApprovalResponse(elicitation.interaction, response);
26266
+ if (validation2)
26267
+ return { ok: false, error: validation2 };
26268
+ const action = elicitation.interaction.actions.find(({ id }) => id === response.actionId);
26269
+ if (!action)
26270
+ return {
26271
+ ok: false,
26272
+ error: {
26273
+ code: "invalidRequest",
26274
+ message: "Grok Approval action is unavailable",
26275
+ retryable: false
26276
+ }
26277
+ };
26278
+ this.#settleElicitation(active, elicitation, grokMcpElicitResponseForAction(action.effect === "allowOnce" || action.effect === "allowAlways" ? action.effect : "deny"), "responded");
26279
+ return { ok: true, value: { accepted: true } };
26280
+ }
26281
+ if (!permission)
26282
+ return { ok: false, error: invalidState("Grok Approval is not pending") };
26283
+ const validation = validateHostApprovalResponse(permission.interaction, response);
25639
26284
  if (validation)
25640
26285
  return { ok: false, error: validation };
25641
- const option = pending.options.get(command.response.actionId);
26286
+ const option = permission.options.get(response.actionId);
25642
26287
  if (!option)
25643
26288
  return {
25644
26289
  ok: false,
@@ -25649,7 +26294,7 @@ var GrokHarnessSession = class {
25649
26294
  }
25650
26295
  };
25651
26296
  active.approvals.delete(command.interactionId);
25652
- pending.resolve({ outcome: { outcome: "selected", optionId: option.optionId } });
26297
+ permission.resolve({ outcome: { outcome: "selected", optionId: option.optionId } });
25653
26298
  this.#event({
25654
26299
  type: "interaction.closed",
25655
26300
  interactionId: command.interactionId,
@@ -25678,10 +26323,57 @@ var GrokHarnessSession = class {
25678
26323
  actions
25679
26324
  };
25680
26325
  return new Promise((resolve) => {
25681
- active.approvals.set(interactionId, { interaction, options, resolve });
26326
+ active.approvals.set(interactionId, {
26327
+ kind: "permission",
26328
+ interaction,
26329
+ options,
26330
+ resolve
26331
+ });
26332
+ this.#channel.emit({ kind: "interaction", interaction });
26333
+ });
26334
+ }
26335
+ #requestElicitation(active, request) {
26336
+ if (this.#active !== active || this.#phase !== "open" || active.cancellationRequested) {
26337
+ return Promise.resolve(grokMcpElicitCancel());
26338
+ }
26339
+ for (const pending of active.elicitations.values()) {
26340
+ if (pending.nativeToolCallId === request.toolCallId) {
26341
+ return Promise.resolve(grokMcpElicitCancel());
26342
+ }
26343
+ }
26344
+ const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
26345
+ const interaction = projectGrokMcpElicitApproval({
26346
+ interactionId,
26347
+ turnId: active.command.turnId,
26348
+ request
26349
+ });
26350
+ return new Promise((resolve) => {
26351
+ active.elicitations.set(interactionId, {
26352
+ kind: "elicitation",
26353
+ nativeToolCallId: request.toolCallId,
26354
+ interaction,
26355
+ resolve
26356
+ });
25682
26357
  this.#channel.emit({ kind: "interaction", interaction });
25683
26358
  });
25684
26359
  }
26360
+ #settleElicitation(active, pending, response, reason) {
26361
+ if (!active.elicitations.has(pending.interaction.interactionId))
26362
+ return;
26363
+ active.elicitations.delete(pending.interaction.interactionId);
26364
+ pending.resolve(response);
26365
+ this.#event({
26366
+ type: "interaction.closed",
26367
+ interactionId: pending.interaction.interactionId,
26368
+ turnId: active.command.turnId,
26369
+ reason
26370
+ });
26371
+ }
26372
+ #cancelActiveElicitations(active) {
26373
+ for (const pending of [...active.elicitations.values()]) {
26374
+ this.#settleElicitation(active, pending, grokMcpElicitCancel(), "cancelled");
26375
+ }
26376
+ }
25685
26377
  #handleEvent(active, event) {
25686
26378
  if (this.#active !== active || this.#phase !== "open")
25687
26379
  return;
@@ -25710,6 +26402,12 @@ var GrokHarnessSession = class {
25710
26402
  else if (event.type === "compaction.completed") {
25711
26403
  active.compactionTerminal = event;
25712
26404
  this.#completeCompaction(active, event);
26405
+ } else if (event.type === "elicitation.resolved") {
26406
+ for (const pending of [...active.elicitations.values()]) {
26407
+ if (pending.nativeToolCallId === event.toolCallId) {
26408
+ this.#settleElicitation(active, pending, grokMcpElicitCancel(), "cancelled");
26409
+ }
26410
+ }
25713
26411
  } else if (event.type === "usage" || event.type === "turn.completed")
25714
26412
  return;
25715
26413
  }
@@ -26118,6 +26816,7 @@ var GrokHarnessSession = class {
26118
26816
  reason: "cancelled"
26119
26817
  });
26120
26818
  }
26819
+ this.#cancelActiveElicitations(active);
26121
26820
  this.#active = null;
26122
26821
  if (usage || this.#usage)
26123
26822
  this.#publishUsage({ ...usage, ...active.usage?.metrics() }, active.command.turnId, true);
@@ -26155,6 +26854,7 @@ var GrokHarnessSession = class {
26155
26854
  active.cancellationRequested = true;
26156
26855
  for (const approval of active.approvals.values())
26157
26856
  approval.resolve({ outcome: { outcome: "cancelled" } });
26857
+ this.#cancelActiveElicitations(active);
26158
26858
  await this.#transport.cancel().catch(() => void 0);
26159
26859
  await Promise.race([
26160
26860
  active.completion,
@@ -26246,7 +26946,7 @@ var GrokAdapter = class {
26246
26946
  this.usageStatistics = createGrokUsageStatistics(options.environment ?? process.env);
26247
26947
  this.#toolOutputLimit = options.toolOutputLimit ?? DEFAULT_GROK_TOOL_OUTPUT_LIMIT;
26248
26948
  this.#dependencies = dependencies ?? {
26249
- randomUUID,
26949
+ randomUUID: randomUUID2,
26250
26950
  createTransport: (transportOptions) => new GrokAcpTransport({ ...options, ...transportOptions })
26251
26951
  };
26252
26952
  this.#fetchCredits = this.#dependencies.fetchCredits ?? ((input) => fetchGrokCredits(input.environment ? { environment: input.environment } : this.#environment ? { environment: this.#environment } : {}));
@@ -26292,7 +26992,7 @@ var GrokAdapter = class {
26292
26992
  async inspect(input = {}) {
26293
26993
  if (this.#closePromise)
26294
26994
  return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
26295
- const cwd = path16.resolve(input.cwd ?? process.cwd());
26995
+ const cwd = path18.resolve(input.cwd ?? process.cwd());
26296
26996
  if (!input.refresh) {
26297
26997
  const cached2 = this.#inspectionCache.get(cwd);
26298
26998
  if (cached2)
@@ -26354,7 +27054,20 @@ var GrokAdapter = class {
26354
27054
  }
26355
27055
  };
26356
27056
  }
26357
- const cwd = path16.resolve(input.cwd);
27057
+ try {
27058
+ await applyGrokComputerUsePreference(this.#environment ?? process.env);
27059
+ } catch {
27060
+ console.warn("Could not apply Grok Computer Use settings");
27061
+ return {
27062
+ ok: false,
27063
+ error: {
27064
+ code: "unavailable",
27065
+ message: "Could not apply Grok Computer Use settings. Retry after fixing Grok config.",
27066
+ retryable: true
27067
+ }
27068
+ };
27069
+ }
27070
+ const cwd = path18.resolve(input.cwd);
26358
27071
  const parsedRef = input.kind === "resume" ? nativeSessionRefSchema.safeParse(input.nativeRef) : null;
26359
27072
  if (parsedRef && (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId)) {
26360
27073
  return {
@@ -26561,6 +27274,24 @@ function createGrokInstallation(environment, command) {
26561
27274
  let installer = "";
26562
27275
  return createInstallationManager({
26563
27276
  async check() {
27277
+ const launcher = await readLauncherScript(resolveGrokExecutable({ environment, ...command ? { command } : {} }));
27278
+ if (launcher.includes("GROKGOD_HOME=") && launcher.includes("GROKGOD_BIN=")) {
27279
+ return {
27280
+ currentVersion: versionFromOutput(await run(["--version"], void 0, {
27281
+ GROK_DISABLE_AUTOUPDATER: "1",
27282
+ GROKGOD_UPDATE_CHECK_DISABLE: "1"
27283
+ })),
27284
+ latestVersion: "Unknown",
27285
+ latestVersionKind: "unknown",
27286
+ updateAvailable: false,
27287
+ canUpdate: false,
27288
+ messageCode: "original-installer",
27289
+ notice: {
27290
+ en: "Managed by grokgod. Use grokgod's updater or installer to preserve the installed patches. The latest patched version is not checked here.",
27291
+ "zh-CN": "此安装由 grokgod 管理。请使用 grokgod 的更新程序或安装程序保留补丁;此处不检查最新补丁版本。"
27292
+ }
27293
+ };
27294
+ }
26564
27295
  const state = JSON.parse(await run(["update", "--check", "--json"]));
26565
27296
  if (state.error || typeof state.updateAvailable !== "boolean")
26566
27297
  throw new Error("Grok update check failed");