@codexhost/cli-darwin-x64 0.9.1 → 0.10.0

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.
@@ -7,7 +7,45 @@ var __export = (target, all) => {
7
7
 
8
8
  // dist/grok-adapter.js
9
9
  import { randomUUID } from "node:crypto";
10
- import path10 from "node:path";
10
+
11
+ // dist/grok-credential-export.js
12
+ import { createHash } from "node:crypto";
13
+ import { readFile } from "node:fs/promises";
14
+ import os from "node:os";
15
+ import path from "node:path";
16
+ async function readGrokCredentials(environment) {
17
+ if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((v) => v?.trim()))
18
+ return [];
19
+ 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"));
22
+ const client2 = "b1a00492-073a-47ea-816f-4c329264a828";
23
+ const entry = auth[`https://auth.x.ai::${client2}`] ?? auth["https://auth.x.ai"];
24
+ if (!entry || entry.oidc_issuer !== "https://auth.x.ai" || entry.oidc_client_id !== client2)
25
+ return [];
26
+ if (![entry.key, entry.refresh_token, entry.user_id].every((v) => typeof v === "string" && v.length))
27
+ return [];
28
+ const expires = Date.parse(entry.expires_at);
29
+ if (!Number.isFinite(expires))
30
+ return [];
31
+ return [
32
+ {
33
+ source: {
34
+ id: `grok:${createHash("sha256").update(entry.user_id).digest("hex")}`,
35
+ harnessId: "grok",
36
+ provider: "xai",
37
+ label: typeof entry.email === "string" && entry.email ? entry.email : "Grok"
38
+ },
39
+ oauth: { access: entry.key, refresh: entry.refresh_token, expires: expires - 3e5 }
40
+ }
41
+ ];
42
+ } catch {
43
+ return [];
44
+ }
45
+ }
46
+
47
+ // dist/grok-adapter.js
48
+ import path11 from "node:path";
11
49
 
12
50
  // ../../../node_modules/zod/v4/classic/external.js
13
51
  var external_exports = {};
@@ -775,10 +813,10 @@ function mergeDefs(...defs) {
775
813
  function cloneDef(schema) {
776
814
  return mergeDefs(schema._zod.def);
777
815
  }
778
- function getElementAtPath(obj, path11) {
779
- if (!path11)
816
+ function getElementAtPath(obj, path12) {
817
+ if (!path12)
780
818
  return obj;
781
- return path11.reduce((acc, key) => acc?.[key], obj);
819
+ return path12.reduce((acc, key) => acc?.[key], obj);
782
820
  }
783
821
  function promiseAllObject(promisesObj) {
784
822
  const keys = Object.keys(promisesObj);
@@ -1187,11 +1225,11 @@ function explicitlyAborted(x, startIndex = 0) {
1187
1225
  }
1188
1226
  return false;
1189
1227
  }
1190
- function prefixIssues(path11, issues) {
1228
+ function prefixIssues(path12, issues) {
1191
1229
  return issues.map((iss) => {
1192
1230
  var _a3;
1193
1231
  (_a3 = iss).path ?? (_a3.path = []);
1194
- iss.path.unshift(path11);
1232
+ iss.path.unshift(path12);
1195
1233
  return iss;
1196
1234
  });
1197
1235
  }
@@ -1338,16 +1376,16 @@ function flattenError(error53, mapper = (issue2) => issue2.message) {
1338
1376
  }
1339
1377
  function formatError(error53, mapper = (issue2) => issue2.message) {
1340
1378
  const fieldErrors = { _errors: [] };
1341
- const processError = (error54, path11 = []) => {
1379
+ const processError = (error54, path12 = []) => {
1342
1380
  for (const issue2 of error54.issues) {
1343
1381
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1344
- issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
1382
+ issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1345
1383
  } else if (issue2.code === "invalid_key") {
1346
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1384
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1347
1385
  } else if (issue2.code === "invalid_element") {
1348
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1386
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1349
1387
  } else {
1350
- const fullpath = [...path11, ...issue2.path];
1388
+ const fullpath = [...path12, ...issue2.path];
1351
1389
  if (fullpath.length === 0) {
1352
1390
  fieldErrors._errors.push(mapper(issue2));
1353
1391
  } else {
@@ -1374,17 +1412,17 @@ function formatError(error53, mapper = (issue2) => issue2.message) {
1374
1412
  }
1375
1413
  function treeifyError(error53, mapper = (issue2) => issue2.message) {
1376
1414
  const result = { errors: [] };
1377
- const processError = (error54, path11 = []) => {
1415
+ const processError = (error54, path12 = []) => {
1378
1416
  var _a3, _b;
1379
1417
  for (const issue2 of error54.issues) {
1380
1418
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1381
- issue2.errors.map((issues) => processError({ issues }, [...path11, ...issue2.path]));
1419
+ issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1382
1420
  } else if (issue2.code === "invalid_key") {
1383
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1421
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1384
1422
  } else if (issue2.code === "invalid_element") {
1385
- processError({ issues: issue2.issues }, [...path11, ...issue2.path]);
1423
+ processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1386
1424
  } else {
1387
- const fullpath = [...path11, ...issue2.path];
1425
+ const fullpath = [...path12, ...issue2.path];
1388
1426
  if (fullpath.length === 0) {
1389
1427
  result.errors.push(mapper(issue2));
1390
1428
  continue;
@@ -1416,8 +1454,8 @@ function treeifyError(error53, mapper = (issue2) => issue2.message) {
1416
1454
  }
1417
1455
  function toDotPath(_path) {
1418
1456
  const segs = [];
1419
- const path11 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1420
- for (const seg of path11) {
1457
+ const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1458
+ for (const seg of path12) {
1421
1459
  if (typeof seg === "number")
1422
1460
  segs.push(`[${seg}]`);
1423
1461
  else if (typeof seg === "symbol")
@@ -14109,13 +14147,13 @@ function resolveRef(ref, ctx) {
14109
14147
  if (!ref.startsWith("#")) {
14110
14148
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14111
14149
  }
14112
- const path11 = ref.slice(1).split("/").filter(Boolean);
14113
- if (path11.length === 0) {
14150
+ const path12 = ref.slice(1).split("/").filter(Boolean);
14151
+ if (path12.length === 0) {
14114
14152
  return ctx.rootSchema;
14115
14153
  }
14116
14154
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14117
- if (path11[0] === defsKey) {
14118
- const key = path11[1];
14155
+ if (path12[0] === defsKey) {
14156
+ const key = path12[1];
14119
14157
  if (!key || !ctx.defs[key]) {
14120
14158
  throw new Error(`Reference not found: ${ref}`);
14121
14159
  }
@@ -14523,6 +14561,61 @@ function date4(params) {
14523
14561
  // ../../../node_modules/zod/v4/classic/external.js
14524
14562
  config(en_default());
14525
14563
 
14564
+ // ../../shared-contracts/dist/credential-imports.js
14565
+ var credentialSourceSchema = external_exports.object({
14566
+ id: external_exports.string().min(1).max(256),
14567
+ harnessId: external_exports.string().min(1),
14568
+ label: external_exports.string().min(1).max(512),
14569
+ provider: external_exports.enum(["openai-codex", "xai"])
14570
+ }).strict();
14571
+ var credentialImportNameSchema = external_exports.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
14572
+ var credentialImportRecordSchema = external_exports.object({
14573
+ name: credentialImportNameSchema,
14574
+ source: credentialSourceSchema,
14575
+ importedAt: external_exports.string()
14576
+ }).strict();
14577
+ var credentialImportsRequestSchema = external_exports.discriminatedUnion("action", [
14578
+ external_exports.object({ action: external_exports.literal("list") }).strict(),
14579
+ external_exports.object({
14580
+ action: external_exports.literal("import"),
14581
+ sourceId: external_exports.string().min(1).max(256),
14582
+ name: credentialImportNameSchema,
14583
+ confirmed: external_exports.literal(true)
14584
+ }).strict(),
14585
+ external_exports.object({
14586
+ action: external_exports.literal("reimport"),
14587
+ sourceId: external_exports.string().min(1).max(256),
14588
+ name: credentialImportNameSchema,
14589
+ confirmed: external_exports.literal(true)
14590
+ }).strict(),
14591
+ external_exports.object({
14592
+ action: external_exports.literal("remove"),
14593
+ name: credentialImportNameSchema,
14594
+ confirmed: external_exports.literal(true)
14595
+ }).strict()
14596
+ ]);
14597
+ var credentialOtherLoginSchema = external_exports.object({
14598
+ provider: external_exports.string().min(1).max(128),
14599
+ type: external_exports.enum(["oauth", "api_key", "unknown"]),
14600
+ /** Best-effort account label (e.g. the email in a Codex token), derived locally when present. */
14601
+ label: external_exports.string().min(1).max(512).optional(),
14602
+ /** Recognized credential vendor, derived from the OAuth token issuer. Absent when unknown. */
14603
+ vendor: external_exports.enum(["openai-codex", "xai"]).optional()
14604
+ }).strict();
14605
+ var credentialImportsResultSchema = external_exports.object({
14606
+ sources: external_exports.array(credentialSourceSchema),
14607
+ targets: external_exports.array(external_exports.object({
14608
+ harnessId: external_exports.string(),
14609
+ providers: external_exports.array(external_exports.enum(["openai-codex", "xai"])),
14610
+ imports: external_exports.array(credentialImportRecordSchema),
14611
+ others: external_exports.array(credentialOtherLoginSchema).default([])
14612
+ }).strict())
14613
+ }).strict();
14614
+ var credentialImportsParamsSchema = external_exports.object({
14615
+ targetHarnessId: external_exports.string().min(1).max(128).optional(),
14616
+ request: credentialImportsRequestSchema
14617
+ }).strict();
14618
+
14526
14619
  // ../../shared-contracts/dist/version.js
14527
14620
  var WORKSPACE_CONTRACT_VERSION = 1;
14528
14621
 
@@ -15226,10 +15319,21 @@ var harnessCommandDescriptorSchema = external_exports.object({
15226
15319
  invocation: commandInvocationSchema,
15227
15320
  label: commandLabelSchema,
15228
15321
  description: commandDescriptionSchema.optional(),
15229
- argumentMode: external_exports.enum(["none", "text"])
15322
+ argumentMode: external_exports.enum(["none", "text"]),
15323
+ /**
15324
+ * Native distinction reported by the Harness. Omitted when the Harness does
15325
+ * not tell skills and commands apart; consumers treat that as "command".
15326
+ */
15327
+ kind: external_exports.enum(["command", "skill"]).optional()
15230
15328
  }).strict();
15231
15329
  var harnessCommandCatalogSchema = external_exports.object({
15232
- commands: external_exports.array(harnessCommandDescriptorSchema)
15330
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15331
+ /**
15332
+ * `live` when the catalog includes what a native Session reports for its
15333
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15334
+ * Omitted by Adapters; set by the Host on inspection results.
15335
+ */
15336
+ source: external_exports.enum(["live", "static"]).optional()
15233
15337
  }).strict().superRefine((catalog, context) => {
15234
15338
  const ids = /* @__PURE__ */ new Set();
15235
15339
  for (const [index, command] of catalog.commands.entries()) {
@@ -15243,7 +15347,11 @@ var harnessCommandCatalogSchema = external_exports.object({
15243
15347
  ids.add(command.id);
15244
15348
  }
15245
15349
  });
15246
- var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
15350
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15351
+ harnessId: harnessIdSchema,
15352
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15353
+ cwd: external_exports.string().min(1).optional()
15354
+ }).strict();
15247
15355
  var threadCommandsInspectParamsSchema = external_exports.object({
15248
15356
  threadId: hostThreadIdSchema
15249
15357
  }).strict();
@@ -15546,11 +15654,129 @@ function parseHostUsage(value) {
15546
15654
  return { ...value };
15547
15655
  }
15548
15656
 
15657
+ // ../../harness-adapter/dist/live-command-catalog.js
15658
+ var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
15659
+ // Session lifecycle
15660
+ "branch",
15661
+ "clear",
15662
+ "exit",
15663
+ "fork",
15664
+ "fresh",
15665
+ "new",
15666
+ "quit",
15667
+ "rename",
15668
+ "rename-chat",
15669
+ "reset",
15670
+ "resume",
15671
+ "rewind",
15672
+ "session",
15673
+ "sessions",
15674
+ // Desktop-owned configuration
15675
+ "autocompact",
15676
+ "color",
15677
+ "config",
15678
+ "effort",
15679
+ "fast",
15680
+ "keybindings",
15681
+ "model",
15682
+ "models",
15683
+ "output-style",
15684
+ "permissions",
15685
+ "settings",
15686
+ "statusline",
15687
+ "terminal-setup",
15688
+ "theme",
15689
+ "vim",
15690
+ // Trust and approval policy
15691
+ "always-approve",
15692
+ "auto-mode-setup",
15693
+ // Native login
15694
+ "login",
15695
+ "logout",
15696
+ // Work outliving the Turn
15697
+ "autopilot",
15698
+ "background",
15699
+ "bg",
15700
+ "goal",
15701
+ "jobs",
15702
+ "loop",
15703
+ "multitask",
15704
+ "queue",
15705
+ "remote-control",
15706
+ "schedule",
15707
+ "steer",
15708
+ // Native terminal UI
15709
+ "copy",
15710
+ "debug",
15711
+ "feedback",
15712
+ "heapdump",
15713
+ "share",
15714
+ "shell",
15715
+ // Plugin and MCP management
15716
+ "marketplace",
15717
+ "mcp",
15718
+ "plugins",
15719
+ "reload-plugins"
15720
+ ]);
15721
+ var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
15722
+ function isExcludedLiveCommand(name, kind, extra = {}) {
15723
+ const normalized = name.trim().replace(/^\//u, "");
15724
+ if (new Set(extra.names ?? []).has(normalized))
15725
+ return true;
15726
+ if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
15727
+ return true;
15728
+ if (kind === "skill")
15729
+ return false;
15730
+ return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
15731
+ }
15732
+ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
15733
+ if (!commandId.startsWith(idPrefix))
15734
+ return null;
15735
+ const descriptor = catalog.commands.find(({ id }) => id === commandId);
15736
+ if (!descriptor)
15737
+ return null;
15738
+ const text = typeof argumentText === "string" ? argumentText.trim() : "";
15739
+ return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
15740
+ }
15741
+ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
15742
+ if (!live)
15743
+ return builtIns;
15744
+ const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
15745
+ const ids = new Set(builtIns.commands.map(({ id }) => id));
15746
+ const dynamic = [];
15747
+ for (const command of live) {
15748
+ const name = command.name.trim().replace(/^\//u, "");
15749
+ if (!name || /\s/u.test(name))
15750
+ continue;
15751
+ if (isExcludedLiveCommand(name, command.kind, exclusions))
15752
+ continue;
15753
+ const invocation = `/${name}`;
15754
+ const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
15755
+ if (invocations.has(invocation) || ids.has(id))
15756
+ continue;
15757
+ const description = command.description?.trim().slice(0, 512);
15758
+ const parsed = harnessCommandDescriptorSchema.safeParse({
15759
+ id,
15760
+ invocation,
15761
+ label: name.slice(0, 128),
15762
+ ...description ? { description } : {},
15763
+ argumentMode: "text",
15764
+ kind: command.kind
15765
+ });
15766
+ if (!parsed.success)
15767
+ continue;
15768
+ invocations.add(invocation);
15769
+ ids.add(id);
15770
+ dynamic.push(parsed.data);
15771
+ }
15772
+ return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
15773
+ }
15774
+
15549
15775
  // dist/acp-transport.js
15550
15776
  import { spawn, spawnSync } from "node:child_process";
15551
- import { readdir, readFile } from "node:fs/promises";
15552
- import os3 from "node:os";
15553
- import path8 from "node:path";
15777
+ import { readdir, readFile as readFile2 } from "node:fs/promises";
15778
+ import os4 from "node:os";
15779
+ import path9 from "node:path";
15554
15780
  import { Readable, Writable } from "node:stream";
15555
15781
 
15556
15782
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -19714,14 +19940,49 @@ var ClientSideConnection = class {
19714
19940
  }
19715
19941
  };
19716
19942
 
19943
+ // dist/grok-slash-commands.js
19944
+ var GROK_LIVE_COMMAND_ID_PREFIX = "grok.slash.";
19945
+ function isRecord3(value) {
19946
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19947
+ }
19948
+ function parseGrokAvailableCommands(value) {
19949
+ if (!Array.isArray(value))
19950
+ return [];
19951
+ return value.flatMap((entry) => {
19952
+ if (!isRecord3(entry))
19953
+ return [];
19954
+ const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
19955
+ if (!name)
19956
+ return [];
19957
+ return [
19958
+ {
19959
+ name,
19960
+ description: typeof entry.description === "string" ? entry.description : "",
19961
+ meta: isRecord3(entry._meta) ? entry._meta : null
19962
+ }
19963
+ ];
19964
+ });
19965
+ }
19966
+ function isGrokSkill(command) {
19967
+ const path12 = command.meta?.path;
19968
+ return typeof path12 === "string" && /(^|[\\/])SKILL\.md$/u.test(path12) || typeof command.meta?.qualifiedName === "string";
19969
+ }
19970
+ function grokLiveCommands(native) {
19971
+ return native.map((command) => ({
19972
+ name: command.name,
19973
+ description: command.description,
19974
+ kind: isGrokSkill(command) ? "skill" : "command"
19975
+ }));
19976
+ }
19977
+
19717
19978
  // dist/command.js
19718
- import path3 from "node:path";
19979
+ import path4 from "node:path";
19719
19980
 
19720
19981
  // ../../harness-discovery/dist/environment.js
19721
19982
  import fs from "node:fs";
19722
- import path from "node:path";
19983
+ import path2 from "node:path";
19723
19984
  function targetPath(platform) {
19724
- return platform === "win32" ? path.win32 : path.posix;
19985
+ return platform === "win32" ? path2.win32 : path2.posix;
19725
19986
  }
19726
19987
  function environmentValue(environment, name) {
19727
19988
  const lowered = name.toLowerCase();
@@ -19764,9 +20025,9 @@ function newestFirst(names) {
19764
20025
  }
19765
20026
 
19766
20027
  // ../../harness-discovery/dist/invocation.js
19767
- import path2 from "node:path";
20028
+ import path3 from "node:path";
19768
20029
  function commandInvocation(command, arguments_, environment, platform = process.platform) {
19769
- const extension = path2.win32.extname(command).toLowerCase();
20030
+ const extension = path3.win32.extname(command).toLowerCase();
19770
20031
  if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
19771
20032
  return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
19772
20033
  }
@@ -19780,7 +20041,7 @@ function commandInvocation(command, arguments_, environment, platform = process.
19780
20041
  }
19781
20042
 
19782
20043
  // ../../harness-discovery/dist/resolve.js
19783
- import os from "node:os";
20044
+ import os2 from "node:os";
19784
20045
 
19785
20046
  // ../../harness-discovery/dist/version-managers.js
19786
20047
  function versionManagerBinaryDirectories(context) {
@@ -19846,7 +20107,7 @@ function installRootExtensions(platform) {
19846
20107
  return platform === "win32" ? [".exe", ".cmd"] : [""];
19847
20108
  }
19848
20109
  function resolveHomeDirectory(input) {
19849
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
20110
+ return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os2.homedir();
19850
20111
  }
19851
20112
  function templateVariables(environment, platform, home) {
19852
20113
  const pathFlavor = targetPath(platform);
@@ -19971,7 +20232,7 @@ function resolveGrokExecutable(input = {}) {
19971
20232
  });
19972
20233
  if (!resolution)
19973
20234
  throw new GrokExecutableError("Grok CLI is not installed");
19974
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path3.resolve(resolution.executable);
20235
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path4.resolve(resolution.executable);
19975
20236
  }
19976
20237
  function grokInvocation(command, platform = process.platform, modelId) {
19977
20238
  const arguments_ = ["agent", "--no-leader"];
@@ -19984,11 +20245,11 @@ function grokInvocation(command, platform = process.platform, modelId) {
19984
20245
 
19985
20246
  // dist/grok-fork.js
19986
20247
  import { isDeepStrictEqual } from "node:util";
19987
- import path6 from "node:path";
20248
+ import path7 from "node:path";
19988
20249
 
19989
20250
  // dist/grok-file-change.js
19990
20251
  import { Buffer as Buffer2 } from "node:buffer";
19991
- import path4 from "node:path";
20252
+ import path5 from "node:path";
19992
20253
 
19993
20254
  // ../../../node_modules/diff/libesm/diff/base.js
19994
20255
  var Diff = class {
@@ -20090,16 +20351,16 @@ var Diff = class {
20090
20351
  }
20091
20352
  }
20092
20353
  }
20093
- addToPath(path11, added, removed, oldPosInc, options) {
20094
- const last = path11.lastComponent;
20354
+ addToPath(path12, added, removed, oldPosInc, options) {
20355
+ const last = path12.lastComponent;
20095
20356
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
20096
20357
  return {
20097
- oldPos: path11.oldPos + oldPosInc,
20358
+ oldPos: path12.oldPos + oldPosInc,
20098
20359
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
20099
20360
  };
20100
20361
  } else {
20101
20362
  return {
20102
- oldPos: path11.oldPos + oldPosInc,
20363
+ oldPos: path12.oldPos + oldPosInc,
20103
20364
  lastComponent: { count: 1, added, removed, previousComponent: last }
20104
20365
  };
20105
20366
  }
@@ -20408,17 +20669,17 @@ function splitLines(text) {
20408
20669
  // dist/grok-file-change.js
20409
20670
  var DEFAULT_GROK_FILE_CHANGE_TEXT_LIMIT = 4 * 1024 * 1024;
20410
20671
  var MAX_GROK_FILE_CHANGES_PER_TOOL = 32;
20411
- function isRecord3(value) {
20672
+ function isRecord4(value) {
20412
20673
  return typeof value === "object" && value !== null && !Array.isArray(value);
20413
20674
  }
20414
20675
  function validAbsolutePath(value) {
20415
- return typeof value === "string" && path4.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
20676
+ return typeof value === "string" && path5.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
20416
20677
  }
20417
20678
  function displayPath(nativePath, cwd) {
20418
- const resolvedCwd = path4.resolve(cwd);
20419
- const resolvedPath = path4.resolve(nativePath);
20420
- const relative = path4.relative(resolvedCwd, resolvedPath);
20421
- const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path4.sep}`);
20679
+ const resolvedCwd = path5.resolve(cwd);
20680
+ const resolvedPath = path5.resolve(nativePath);
20681
+ const relative = path5.relative(resolvedCwd, resolvedPath);
20682
+ const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path5.sep}`);
20422
20683
  const selected = inside ? relative : resolvedPath;
20423
20684
  const normalized = selected.replaceAll("\\", "/");
20424
20685
  if (normalized.length === 0 || normalized === ".")
@@ -20459,7 +20720,7 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
20459
20720
  return null;
20460
20721
  const candidates = [];
20461
20722
  for (const entry of content) {
20462
- if (isRecord3(entry) && entry.type === "diff")
20723
+ if (isRecord4(entry) && entry.type === "diff")
20463
20724
  candidates.push(entry);
20464
20725
  }
20465
20726
  if (candidates.length === 0 || candidates.length > MAX_GROK_FILE_CHANGES_PER_TOOL)
@@ -20480,8 +20741,8 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
20480
20741
 
20481
20742
  // dist/local-media-markdown.js
20482
20743
  import { existsSync, statSync } from "node:fs";
20483
- import os2 from "node:os";
20484
- import path5 from "node:path";
20744
+ import os3 from "node:os";
20745
+ import path6 from "node:path";
20485
20746
  var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20486
20747
  ".aac",
20487
20748
  ".gif",
@@ -20500,14 +20761,14 @@ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20500
20761
  ".webp"
20501
20762
  ]);
20502
20763
  function grokMediaResolveRoots(cwd, sessionDirectory) {
20503
- const roots = [path5.resolve(cwd)];
20764
+ const roots = [path6.resolve(cwd)];
20504
20765
  if (sessionDirectory) {
20505
- const session = path5.resolve(sessionDirectory);
20506
- roots.push(session, path5.join(session, "videos"), path5.join(session, "images"));
20766
+ const session = path6.resolve(sessionDirectory);
20767
+ roots.push(session, path6.join(session, "videos"), path6.join(session, "images"));
20507
20768
  }
20508
- const home = process.env.HOME ?? process.env.USERPROFILE ?? os2.homedir();
20769
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? os3.homedir();
20509
20770
  if (home)
20510
- roots.push(path5.join(home, "Downloads"));
20771
+ roots.push(path6.join(home, "Downloads"));
20511
20772
  return roots;
20512
20773
  }
20513
20774
  function rewriteLocalMediaMarkdown(text, roots, options = {}) {
@@ -20608,7 +20869,7 @@ function parseInlineCode(text, start) {
20608
20869
  return { closed: false, content: text.slice(start + 1), end: text.length };
20609
20870
  }
20610
20871
  function mediaMarkdownImage(absolutePath) {
20611
- const name = path5.basename(absolutePath).replaceAll("]", "\\]");
20872
+ const name = path6.basename(absolutePath).replaceAll("]", "\\]");
20612
20873
  return `![${name}](${formatMarkdownDestination(absolutePath, false)})`;
20613
20874
  }
20614
20875
  function parseMarkdownImage(text, start) {
@@ -20733,11 +20994,11 @@ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
20733
20994
  if (!hasMediaExtension(stripped))
20734
20995
  return null;
20735
20996
  if (isAbsoluteMediaPath(stripped)) {
20736
- const absolute = path5.resolve(stripped);
20997
+ const absolute = path6.resolve(stripped);
20737
20998
  return exists(absolute) ? absolute : null;
20738
20999
  }
20739
21000
  for (const root of roots) {
20740
- const absolute = path5.resolve(root, stripped);
21001
+ const absolute = path6.resolve(root, stripped);
20741
21002
  if (exists(absolute))
20742
21003
  return absolute;
20743
21004
  }
@@ -20759,11 +21020,11 @@ function stripFileUrl(value) {
20759
21020
  }
20760
21021
  }
20761
21022
  function isAbsoluteMediaPath(value) {
20762
- return path5.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
21023
+ return path6.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
20763
21024
  }
20764
21025
  function hasMediaExtension(value) {
20765
21026
  const pathname = value.split(/[?#]/, 1)[0] ?? value;
20766
- return MEDIA_EXTENSIONS.has(path5.extname(pathname).toLowerCase());
21027
+ return MEDIA_EXTENSIONS.has(path6.extname(pathname).toLowerCase());
20767
21028
  }
20768
21029
  function mediaFileExists(absolutePath) {
20769
21030
  try {
@@ -20776,14 +21037,14 @@ function mediaFileExists(absolutePath) {
20776
21037
  // dist/grok-tool-output.js
20777
21038
  var DEFAULT_GROK_TOOL_OUTPUT_LIMIT = 64e3;
20778
21039
  var EXECUTE_TOOL_NAMES = /* @__PURE__ */ new Set(["bash", "run_terminal_command", "shell", "cursor_shell"]);
20779
- function isRecord4(value) {
21040
+ function isRecord5(value) {
20780
21041
  return typeof value === "object" && value !== null && !Array.isArray(value);
20781
21042
  }
20782
21043
  function stringField(value, key) {
20783
- return isRecord4(value) && typeof value[key] === "string" && value[key].length > 0 ? value[key] : void 0;
21044
+ return isRecord5(value) && typeof value[key] === "string" && value[key].length > 0 ? value[key] : void 0;
20784
21045
  }
20785
21046
  function numberField(value, key) {
20786
- if (!isRecord4(value))
21047
+ if (!isRecord5(value))
20787
21048
  return void 0;
20788
21049
  const field = value[key];
20789
21050
  if (field === null)
@@ -20806,7 +21067,7 @@ function firstReadableText(...candidates) {
20806
21067
  for (const candidate of candidates) {
20807
21068
  if (typeof candidate === "string" && candidate.length > 0)
20808
21069
  return candidate;
20809
- if (isRecord4(candidate)) {
21070
+ if (isRecord5(candidate)) {
20810
21071
  const nested = stringField(candidate, "content") ?? stringField(candidate, "text") ?? stringField(candidate, "tool_result") ?? stringField(candidate, "raw_output");
20811
21072
  if (nested)
20812
21073
  return nested;
@@ -20829,7 +21090,7 @@ function grokToolArguments(rawInput) {
20829
21090
  if (!parsed.success)
20830
21091
  return {};
20831
21092
  const argumentsValue = parsed.data;
20832
- if (!isRecord4(argumentsValue) || stringField(argumentsValue, "path"))
21093
+ if (!isRecord5(argumentsValue) || stringField(argumentsValue, "path"))
20833
21094
  return argumentsValue;
20834
21095
  const targetFile = stringField(argumentsValue, "target_file");
20835
21096
  return targetFile ? { ...argumentsValue, path: targetFile } : argumentsValue;
@@ -20842,7 +21103,7 @@ function grokCommand(name, kind, rawInput) {
20842
21103
  return command;
20843
21104
  if (name && EXECUTE_TOOL_NAMES.has(name))
20844
21105
  return command;
20845
- return isRecord4(rawInput) && rawInput.variant === "Bash" ? command : void 0;
21106
+ return isRecord5(rawInput) && rawInput.variant === "Bash" ? command : void 0;
20846
21107
  }
20847
21108
  function grokCommandCwd(rawInput, fallback) {
20848
21109
  return stringField(rawInput, "cwd") ?? fallback;
@@ -20869,11 +21130,11 @@ function acpContentText(content) {
20869
21130
  if (!Array.isArray(content))
20870
21131
  return "";
20871
21132
  return content.flatMap((entry) => {
20872
- if (!isRecord4(entry))
21133
+ if (!isRecord5(entry))
20873
21134
  return [];
20874
21135
  if (entry.type === "text" && typeof entry.text === "string")
20875
21136
  return [entry.text];
20876
- if (entry.type !== "content" || !isRecord4(entry.content))
21137
+ if (entry.type !== "content" || !isRecord5(entry.content))
20877
21138
  return [];
20878
21139
  return entry.content.type === "text" && typeof entry.content.text === "string" ? [entry.content.text] : [];
20879
21140
  }).join("\n");
@@ -20884,10 +21145,10 @@ function acpContentImages(content, remainingBytes) {
20884
21145
  const images = [];
20885
21146
  let remaining = remainingBytes;
20886
21147
  for (const entry of content) {
20887
- if (!isRecord4(entry))
21148
+ if (!isRecord5(entry))
20888
21149
  continue;
20889
21150
  const image = entry.type === "image" ? entry : entry.type === "content" ? entry.content : null;
20890
- if (!isRecord4(image) || image.type !== "image")
21151
+ if (!isRecord5(image) || image.type !== "image")
20891
21152
  continue;
20892
21153
  const mimeType = stringField(image, "mimeType") ?? stringField(image, "mime_type");
20893
21154
  const data = stringField(image, "data");
@@ -20910,14 +21171,14 @@ function bashOutput(rawOutput) {
20910
21171
  function rawOutputProjection(rawOutput) {
20911
21172
  if (typeof rawOutput === "string")
20912
21173
  return rawOutput.length > 0 ? { text: rawOutput } : {};
20913
- if (!isRecord4(rawOutput))
21174
+ if (!isRecord5(rawOutput))
20914
21175
  return {};
20915
21176
  if (rawOutput.type === "Bash" || rawOutput.variant === "Bash" || numberField(rawOutput, "exit_code") !== void 0 || numberField(rawOutput, "exitCode") !== void 0) {
20916
21177
  const bash = bashOutput(rawOutput);
20917
21178
  if (bash.text !== void 0 || bash.exitCode !== void 0)
20918
21179
  return bash;
20919
21180
  }
20920
- const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord4(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord4(rawOutput.Content) ? rawOutput.Content : void 0);
21181
+ const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord5(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord5(rawOutput.Content) ? rawOutput.Content : void 0);
20921
21182
  if (text)
20922
21183
  return { text };
20923
21184
  if (typeof rawOutput.match_count === "number" && Number.isFinite(rawOutput.match_count)) {
@@ -20981,11 +21242,11 @@ var WAIT_TOOL_NAMES = /* @__PURE__ */ new Set([
20981
21242
  var KILL_TOOL_NAMES = /* @__PURE__ */ new Set(["kill_command_or_subagent", "kill_task"]);
20982
21243
  var DESCRIPTION_LIMIT = 500;
20983
21244
  var SUMMARY_LIMIT = 2e3;
20984
- function isRecord5(value) {
21245
+ function isRecord6(value) {
20985
21246
  return typeof value === "object" && value !== null && !Array.isArray(value);
20986
21247
  }
20987
21248
  function idField(value, key) {
20988
- if (!isRecord5(value))
21249
+ if (!isRecord6(value))
20989
21250
  return void 0;
20990
21251
  const field = value[key];
20991
21252
  if (typeof field === "string") {
@@ -20997,7 +21258,7 @@ function idField(value, key) {
20997
21258
  return void 0;
20998
21259
  }
20999
21260
  function stringField2(value, key) {
21000
- if (!isRecord5(value) || typeof value[key] !== "string")
21261
+ if (!isRecord6(value) || typeof value[key] !== "string")
21001
21262
  return void 0;
21002
21263
  const trimmed = value[key].trim();
21003
21264
  return trimmed.length > 0 ? trimmed : void 0;
@@ -21020,7 +21281,7 @@ function collectIds(value) {
21020
21281
  };
21021
21282
  push(idField(value, "task_id"));
21022
21283
  push(idField(value, "subagent_id"));
21023
- if (isRecord5(value)) {
21284
+ if (isRecord6(value)) {
21024
21285
  const list = value.task_ids ?? value.subagent_ids;
21025
21286
  if (Array.isArray(list)) {
21026
21287
  for (const entry of list)
@@ -21039,7 +21300,7 @@ function grokSubagentOperation(name, title, rawInput) {
21039
21300
  return "send";
21040
21301
  if (SPAWN_TOOL_NAMES.has(id))
21041
21302
  return "spawn";
21042
- if (isRecord5(rawInput) && rawInput.variant === "Task")
21303
+ if (isRecord6(rawInput) && rawInput.variant === "Task")
21043
21304
  return "spawn";
21044
21305
  return null;
21045
21306
  }
@@ -21062,7 +21323,7 @@ function grokSubagentRole(rawInput) {
21062
21323
  return bounded(stringField2(rawInput, "subagent_type") ?? stringField2(rawInput, "agent_type") ?? stringField2(rawInput, "type"), DESCRIPTION_LIMIT);
21063
21324
  }
21064
21325
  function grokSubagentBackground(rawInput) {
21065
- if (!isRecord5(rawInput))
21326
+ if (!isRecord6(rawInput))
21066
21327
  return true;
21067
21328
  if (rawInput.background === false || rawInput.run_in_background === false)
21068
21329
  return false;
@@ -21100,7 +21361,7 @@ function grokSubagentResultSummary(...candidates) {
21100
21361
  return void 0;
21101
21362
  }
21102
21363
  function grokSubagentEventFromUpdate(update) {
21103
- if (!isRecord5(update) || typeof update.sessionUpdate !== "string")
21364
+ if (!isRecord6(update) || typeof update.sessionUpdate !== "string")
21104
21365
  return null;
21105
21366
  const nativeSubagentId = idField(update, "subagent_id") ?? idField(update, "child_session_id");
21106
21367
  if (!nativeSubagentId)
@@ -21161,14 +21422,14 @@ function grokSubagentWaitSettlements(input) {
21161
21422
  return ids.map((id) => ({ id, status: overall }));
21162
21423
  }
21163
21424
  function taskOutputResults(rawOutput) {
21164
- if (!isRecord5(rawOutput))
21425
+ if (!isRecord6(rawOutput))
21165
21426
  return [];
21166
21427
  if (Array.isArray(rawOutput.results)) {
21167
- return rawOutput.results.filter(isRecord5);
21428
+ return rawOutput.results.filter(isRecord6);
21168
21429
  }
21169
21430
  const nested = firstRecord(rawOutput.MultiResult, rawOutput.multiResult, rawOutput.multi_result);
21170
21431
  if (nested && Array.isArray(nested.results)) {
21171
- return nested.results.filter(isRecord5);
21432
+ return nested.results.filter(isRecord6);
21172
21433
  }
21173
21434
  const single = firstRecord(rawOutput.Result, rawOutput.result);
21174
21435
  if (single)
@@ -21179,7 +21440,7 @@ function taskOutputResults(rawOutput) {
21179
21440
  }
21180
21441
  function firstRecord(...values) {
21181
21442
  for (const value of values) {
21182
- if (isRecord5(value))
21443
+ if (isRecord6(value))
21183
21444
  return value;
21184
21445
  }
21185
21446
  return void 0;
@@ -21202,7 +21463,7 @@ function taskOutputTextSettlements(rawOutput, content, ids) {
21202
21463
  return settled;
21203
21464
  }
21204
21465
  function taskOutputStatus(rawOutput, content) {
21205
- if (isRecord5(rawOutput) && typeof rawOutput.status === "string")
21466
+ if (isRecord6(rawOutput) && typeof rawOutput.status === "string")
21206
21467
  return rawOutput.status;
21207
21468
  const text = extractText(content) ?? extractText(rawOutput);
21208
21469
  if (!text)
@@ -21261,7 +21522,7 @@ function extractText(value, depth = 0) {
21261
21522
  const joined = parts.join("\n").trim();
21262
21523
  return joined.length > 0 ? joined : void 0;
21263
21524
  }
21264
- if (!isRecord5(value))
21525
+ if (!isRecord6(value))
21265
21526
  return void 0;
21266
21527
  if (typeof value.text === "string" && value.text.trim().length > 0)
21267
21528
  return value.text.trim();
@@ -21731,11 +21992,11 @@ var GROK_SESSION_DELETE_METHOD = "_x.ai/session/delete";
21731
21992
  function error51(code, message, retryable = false) {
21732
21993
  return { code, message, retryable };
21733
21994
  }
21734
- function isRecord6(value) {
21995
+ function isRecord7(value) {
21735
21996
  return typeof value === "object" && value !== null && !Array.isArray(value);
21736
21997
  }
21737
21998
  function isGrokMethodNotFound(error53) {
21738
- if (isRecord6(error53) && error53.code === -32601)
21999
+ if (isRecord7(error53) && error53.code === -32601)
21739
22000
  return true;
21740
22001
  const message = error53 instanceof Error ? error53.message : String(error53);
21741
22002
  return /method not found/iu.test(message);
@@ -21753,10 +22014,10 @@ function buildGrokForkParams(input) {
21753
22014
  };
21754
22015
  }
21755
22016
  function parseGrokForkResponse(value) {
21756
- if (!isRecord6(value) || value.error !== void 0)
22017
+ if (!isRecord7(value) || value.error !== void 0)
21757
22018
  return null;
21758
- const payload = typeof value.newSessionId !== "string" && isRecord6(value.result) ? value.result : value;
21759
- if (!isRecord6(payload) || payload.error !== void 0)
22019
+ const payload = typeof value.newSessionId !== "string" && isRecord7(value.result) ? value.result : value;
22020
+ if (!isRecord7(payload) || payload.error !== void 0)
21760
22021
  return null;
21761
22022
  if (typeof payload.newSessionId !== "string" || payload.newSessionId.length === 0)
21762
22023
  return null;
@@ -21772,11 +22033,11 @@ function parseGrokForkResponse(value) {
21772
22033
  }
21773
22034
  function projectRelativePath(value, cwds) {
21774
22035
  const normalized = value.replaceAll("\\", "/");
21775
- if (!path6.isAbsolute(value))
22036
+ if (!path7.isAbsolute(value))
21776
22037
  return normalized;
21777
22038
  for (const cwd of cwds) {
21778
- const relative = path6.relative(path6.resolve(cwd), path6.resolve(value));
21779
- if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path6.sep}`)) {
22039
+ const relative = path7.relative(path7.resolve(cwd), path7.resolve(value));
22040
+ if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path7.sep}`)) {
21780
22041
  return relative.replaceAll("\\", "/");
21781
22042
  }
21782
22043
  }
@@ -21841,8 +22102,8 @@ async function forkGrokSession(input) {
21841
22102
  error: error51("sessionNotFound", "Grok Native Session is unavailable")
21842
22103
  };
21843
22104
  }
21844
- const sourceCwd = path6.resolve(located.cwd);
21845
- const targetCwd = path6.resolve(input.cwd);
22105
+ const sourceCwd = path7.resolve(located.cwd);
22106
+ const targetCwd = path7.resolve(input.cwd);
21846
22107
  const source = await readSnapshot({ ...input, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
21847
22108
  if (!source.ok)
21848
22109
  return source;
@@ -21919,7 +22180,7 @@ var GROK_SESSION_UPDATE_EXTENSION_METHODS = [
21919
22180
  "_x.ai/session/update",
21920
22181
  "x.ai/session_notification"
21921
22182
  ];
21922
- function isRecord7(value) {
22183
+ function isRecord8(value) {
21923
22184
  return typeof value === "object" && value !== null && !Array.isArray(value);
21924
22185
  }
21925
22186
  function optionalNonNegativeInt(value) {
@@ -21940,7 +22201,7 @@ function isGrokExtensionSessionUpdateMethod(method) {
21940
22201
  return GROK_SESSION_UPDATE_EXTENSION_METHODS.includes(method);
21941
22202
  }
21942
22203
  function grokCompactionEventFromUpdate(update) {
21943
- if (!isRecord7(update) || typeof update.sessionUpdate !== "string")
22204
+ if (!isRecord8(update) || typeof update.sessionUpdate !== "string")
21944
22205
  return null;
21945
22206
  const tokensUsed = optionalNonNegativeInt(firstPresent(update, ["tokensUsed", "tokens_used"]));
21946
22207
  const contextWindowTokens = optionalNonNegativeInt(firstPresent(update, ["contextWindowTokens", "contextWindow", "context_window"]));
@@ -21979,7 +22240,7 @@ function grokCompactionEventFromUpdate(update) {
21979
22240
  // dist/grok-manual-compaction.js
21980
22241
  var GROK_COMPACT_CONVERSATION_METHOD = "x.ai/compact_conversation";
21981
22242
  var GROK_COMPACT_CONVERSATION_FALLBACK_METHOD = "_x.ai/compact_conversation";
21982
- function isRecord8(value) {
22243
+ function isRecord9(value) {
21983
22244
  return typeof value === "object" && value !== null && !Array.isArray(value);
21984
22245
  }
21985
22246
  function optionalNonNegativeInt2(value) {
@@ -21991,7 +22252,7 @@ function optionalErrorMessage2(value) {
21991
22252
  function parseGrokCompactResult(value, cancelled = false) {
21992
22253
  if (cancelled)
21993
22254
  return { outcome: "cancelled" };
21994
- if (!isRecord8(value))
22255
+ if (!isRecord9(value))
21995
22256
  return { outcome: "succeeded" };
21996
22257
  const tokensBefore = optionalNonNegativeInt2(value.tokensBefore ?? value.tokens_before);
21997
22258
  const tokensAfter = optionalNonNegativeInt2(value.tokensAfter ?? value.tokens_after);
@@ -22024,12 +22285,12 @@ function parseGrokCompactResult(value, cancelled = false) {
22024
22285
  }
22025
22286
 
22026
22287
  // dist/grok-rewind.js
22027
- import path7 from "node:path";
22288
+ import path8 from "node:path";
22028
22289
  var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
22029
22290
  function error52(code, message, retryable = false) {
22030
22291
  return { code, message, retryable };
22031
22292
  }
22032
- function isRecord9(value) {
22293
+ function isRecord10(value) {
22033
22294
  return typeof value === "object" && value !== null && !Array.isArray(value);
22034
22295
  }
22035
22296
  function buildGrokRewindParams(input) {
@@ -22041,10 +22302,10 @@ function buildGrokRewindParams(input) {
22041
22302
  };
22042
22303
  }
22043
22304
  function parseGrokRewindResponse(value) {
22044
- if (!isRecord9(value))
22305
+ if (!isRecord10(value))
22045
22306
  return null;
22046
- const payload = typeof value.success !== "boolean" && isRecord9(value.result) ? value.result : value;
22047
- if (!isRecord9(payload) || typeof payload.success !== "boolean")
22307
+ const payload = typeof value.success !== "boolean" && isRecord10(value.result) ? value.result : value;
22308
+ if (!isRecord10(payload) || typeof payload.success !== "boolean")
22048
22309
  return null;
22049
22310
  return rewindPayload(payload);
22050
22311
  }
@@ -22097,8 +22358,8 @@ async function rewindGrokLastTurn(input) {
22097
22358
  error: error52("sessionNotFound", "Grok Native Session is unavailable")
22098
22359
  };
22099
22360
  }
22100
- const sourceCwd = path7.resolve(located.cwd);
22101
- const targetCwd = path7.resolve(input.cwd);
22361
+ const sourceCwd = path8.resolve(located.cwd);
22362
+ const targetCwd = path8.resolve(input.cwd);
22102
22363
  if (sourceCwd !== targetCwd) {
22103
22364
  return {
22104
22365
  ok: false,
@@ -22201,16 +22462,16 @@ var GrokTransportError = class extends Error {
22201
22462
  this.name = "GrokTransportError";
22202
22463
  }
22203
22464
  };
22204
- function isRecord10(value) {
22465
+ function isRecord11(value) {
22205
22466
  return typeof value === "object" && value !== null && !Array.isArray(value);
22206
22467
  }
22207
22468
  function acpToolName(update, metadata) {
22208
- if (!isRecord10(update))
22469
+ if (!isRecord11(update))
22209
22470
  return void 0;
22210
22471
  if (typeof update.name === "string" && update.name.length > 0)
22211
22472
  return update.name;
22212
- const meta3 = isRecord10(update._meta) ? update._meta : metadata;
22213
- const tool = meta3 && isRecord10(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
22473
+ const meta3 = isRecord11(update._meta) ? update._meta : metadata;
22474
+ const tool = meta3 && isRecord11(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
22214
22475
  return tool && typeof tool.name === "string" && tool.name.length > 0 ? tool.name : void 0;
22215
22476
  }
22216
22477
  function errorText(error53) {
@@ -22266,7 +22527,7 @@ function signalProcessTree(child, signal) {
22266
22527
  try {
22267
22528
  process.kill(-child.pid, signal);
22268
22529
  } catch (error53) {
22269
- if (!isRecord10(error53) || error53.code !== "ESRCH")
22530
+ if (!isRecord11(error53) || error53.code !== "ESRCH")
22270
22531
  throw error53;
22271
22532
  }
22272
22533
  }
@@ -22341,34 +22602,34 @@ function transportEvent(update, metadata) {
22341
22602
  }
22342
22603
  function grokHomeDir(options) {
22343
22604
  const environment = { ...process.env, ...options.environment };
22344
- const home = environment.HOME ?? environment.USERPROFILE ?? os3.homedir();
22345
- return environment.GROK_HOME ?? path8.join(home, ".grok");
22605
+ const home = environment.HOME ?? environment.USERPROFILE ?? os4.homedir();
22606
+ return environment.GROK_HOME ?? path9.join(home, ".grok");
22346
22607
  }
22347
22608
  function grokNativeSessionDirectory(options, sessionId) {
22348
- return path8.join(grokHomeDir(options), "sessions", encodeURIComponent(path8.resolve(options.cwd)), sessionId);
22609
+ return path9.join(grokHomeDir(options), "sessions", encodeURIComponent(path9.resolve(options.cwd)), sessionId);
22349
22610
  }
22350
22611
  function nativeSessionFile(options, sessionId, fileName) {
22351
- return path8.join(grokNativeSessionDirectory(options, sessionId), fileName);
22612
+ return path9.join(grokNativeSessionDirectory(options, sessionId), fileName);
22352
22613
  }
22353
22614
  function nativeHistoryPath(options, sessionId) {
22354
22615
  return nativeSessionFile(options, sessionId, "updates.jsonl");
22355
22616
  }
22356
22617
  async function readNativeSignals(options, sessionId) {
22357
22618
  try {
22358
- return JSON.parse(await readFile(nativeSessionFile(options, sessionId, "signals.json"), "utf8"));
22619
+ return JSON.parse(await readFile2(nativeSessionFile(options, sessionId, "signals.json"), "utf8"));
22359
22620
  } catch {
22360
22621
  return void 0;
22361
22622
  }
22362
22623
  }
22363
22624
  function isMissingFile(error53) {
22364
- return isRecord10(error53) && error53.code === "ENOENT";
22625
+ return isRecord11(error53) && error53.code === "ENOENT";
22365
22626
  }
22366
22627
  async function locateGrokNativeSession(options, sessionId) {
22367
22628
  if (sessionId.length === 0)
22368
22629
  return null;
22369
22630
  let entries;
22370
22631
  try {
22371
- entries = await readdir(path8.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
22632
+ entries = await readdir(path9.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
22372
22633
  } catch (error53) {
22373
22634
  if (isMissingFile(error53))
22374
22635
  return null;
@@ -22382,9 +22643,9 @@ async function locateGrokNativeSession(options, sessionId) {
22382
22643
  continue;
22383
22644
  let summaryRaw;
22384
22645
  try {
22385
- summaryRaw = await readFile(path8.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
22646
+ summaryRaw = await readFile2(path9.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
22386
22647
  } catch (error53) {
22387
- if (isMissingFile(error53) || isRecord10(error53) && error53.code === "ENOTDIR")
22648
+ if (isMissingFile(error53) || isRecord11(error53) && error53.code === "ENOTDIR")
22388
22649
  continue;
22389
22650
  throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
22390
22651
  cause: error53
@@ -22396,11 +22657,11 @@ async function locateGrokNativeSession(options, sessionId) {
22396
22657
  } catch {
22397
22658
  continue;
22398
22659
  }
22399
- if (!isRecord10(parsed))
22660
+ if (!isRecord11(parsed))
22400
22661
  continue;
22401
22662
  const info = parsed.info;
22402
- const cwd = isRecord10(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path8.resolve(info.cwd) : path8.resolve(decodeURIComponent(entry.name));
22403
- const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path8.resolve(parsed.source_workspace_dir) : void 0;
22663
+ const cwd = isRecord11(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path9.resolve(info.cwd) : path9.resolve(decodeURIComponent(entry.name));
22664
+ const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path9.resolve(parsed.source_workspace_dir) : void 0;
22404
22665
  matches.push({
22405
22666
  cwd,
22406
22667
  ...sourceWorkspaceDir ? { sourceWorkspaceDir } : {}
@@ -22410,7 +22671,7 @@ async function locateGrokNativeSession(options, sessionId) {
22410
22671
  }
22411
22672
  async function readGrokNativeHistory(options, sessionId) {
22412
22673
  try {
22413
- return parseNativeHistory(await readFile(nativeHistoryPath({ ...options, cwd: path8.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
22674
+ return parseNativeHistory(await readFile2(nativeHistoryPath({ ...options, cwd: path9.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
22414
22675
  } catch (error53) {
22415
22676
  if (isMissingFile(error53))
22416
22677
  return [];
@@ -22432,12 +22693,12 @@ function parseNativeHistory(contents, sessionId) {
22432
22693
  } catch {
22433
22694
  throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
22434
22695
  }
22435
- if (!isRecord10(record2) || !isRecord10(record2.params))
22696
+ if (!isRecord11(record2) || !isRecord11(record2.params))
22436
22697
  continue;
22437
22698
  const params = record2.params;
22438
- if (params.sessionId !== sessionId || !isRecord10(params.update))
22699
+ if (params.sessionId !== sessionId || !isRecord11(params.update))
22439
22700
  continue;
22440
- const metadata = isRecord10(params._meta) ? params._meta : void 0;
22701
+ const metadata = isRecord11(params._meta) ? params._meta : void 0;
22441
22702
  const event = transportEvent(params.update, metadata);
22442
22703
  if (event)
22443
22704
  events.push(metadata ? { ...event, metadata } : event);
@@ -22455,6 +22716,7 @@ var GrokAcpTransport = class {
22455
22716
  #initialize = null;
22456
22717
  #replay = null;
22457
22718
  #sessionId = null;
22719
+ #availableCommands = null;
22458
22720
  #startupModelId;
22459
22721
  #stderrTail = "";
22460
22722
  constructor(options) {
@@ -22742,7 +23004,7 @@ var GrokAcpTransport = class {
22742
23004
  modelId,
22743
23005
  ...reasoningEffort ? { reasoningEffort } : {}
22744
23006
  });
22745
- if (!isRecord10(response) || !isRecord10(response._meta) || !isRecord10(response._meta.model)) {
23007
+ if (!isRecord11(response) || !isRecord11(response._meta) || !isRecord11(response._meta.model)) {
22746
23008
  throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
22747
23009
  }
22748
23010
  const selected = response._meta.model.Ok;
@@ -22782,10 +23044,19 @@ var GrokAcpTransport = class {
22782
23044
  this.#activePrompt = null;
22783
23045
  this.#activeCompact = null;
22784
23046
  }
23047
+ /** Latest ACP `available_commands_update` of the open Session, if any. */
23048
+ get availableCommands() {
23049
+ return this.#availableCommands;
23050
+ }
22785
23051
  #handleUpdate(notification) {
22786
23052
  if (this.#sessionId && notification.sessionId !== this.#sessionId)
22787
23053
  return;
22788
- const metadata = isRecord10(notification._meta) ? notification._meta : void 0;
23054
+ const update = notification.update;
23055
+ if (update.sessionUpdate === "available_commands_update") {
23056
+ this.#availableCommands = parseGrokAvailableCommands(update.availableCommands);
23057
+ return;
23058
+ }
23059
+ const metadata = isRecord11(notification._meta) ? notification._meta : void 0;
22789
23060
  const event = transportEvent(notification.update, metadata);
22790
23061
  if (!event)
22791
23062
  return;
@@ -22800,7 +23071,7 @@ var GrokAcpTransport = class {
22800
23071
  #handleExtensionNotification(method, params) {
22801
23072
  if (!isGrokExtensionSessionUpdateMethod(method))
22802
23073
  return;
22803
- if (typeof params.sessionId !== "string" || !isRecord10(params.update))
23074
+ if (typeof params.sessionId !== "string" || !isRecord11(params.update))
22804
23075
  return;
22805
23076
  this.#handleUpdate(params);
22806
23077
  }
@@ -23010,7 +23281,7 @@ var GrokSubagentLifecycle = class {
23010
23281
  };
23011
23282
 
23012
23283
  // dist/grok-models.js
23013
- function isRecord11(value) {
23284
+ function isRecord12(value) {
23014
23285
  return typeof value === "object" && value !== null && !Array.isArray(value);
23015
23286
  }
23016
23287
  function nonBlank(value) {
@@ -23022,7 +23293,7 @@ function thinkingOptions(value) {
23022
23293
  const seen = /* @__PURE__ */ new Set();
23023
23294
  const options = [];
23024
23295
  for (const candidate of value) {
23025
- if (!isRecord11(candidate) || !nonBlank(candidate.label))
23296
+ if (!isRecord12(candidate) || !nonBlank(candidate.label))
23026
23297
  continue;
23027
23298
  const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
23028
23299
  if (!id.success || seen.has(id.data))
@@ -23033,7 +23304,7 @@ function thinkingOptions(value) {
23033
23304
  return options;
23034
23305
  }
23035
23306
  function parseGrokModelState(value) {
23036
- if (!isRecord11(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
23307
+ if (!isRecord12(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
23037
23308
  return null;
23038
23309
  }
23039
23310
  const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
@@ -23044,12 +23315,12 @@ function parseGrokModelState(value) {
23044
23315
  const models = [];
23045
23316
  let currentThinkingOptionId;
23046
23317
  for (const candidate of value.availableModels) {
23047
- if (!isRecord11(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
23318
+ if (!isRecord12(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
23048
23319
  continue;
23049
23320
  const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
23050
23321
  if (!ref.success)
23051
23322
  continue;
23052
- const metadata = isRecord11(candidate._meta) ? candidate._meta : {};
23323
+ const metadata = isRecord12(candidate._meta) ? candidate._meta : {};
23053
23324
  const options2 = thinkingOptions(metadata.reasoningEfforts);
23054
23325
  if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
23055
23326
  contextWindowTokensByModel.set(ref.data.id, metadata.totalContextTokens);
@@ -23084,10 +23355,10 @@ function parseGrokModelState(value) {
23084
23355
  };
23085
23356
  }
23086
23357
  function modelStateFromInitialize(response) {
23087
- return parseGrokModelState(isRecord11(response._meta) ? response._meta.modelState : void 0);
23358
+ return parseGrokModelState(isRecord12(response._meta) ? response._meta.modelState : void 0);
23088
23359
  }
23089
23360
  function modelStateFromSessionResponse(response) {
23090
- return parseGrokModelState(isRecord11(response) ? response.models : void 0);
23361
+ return parseGrokModelState(isRecord12(response) ? response.models : void 0);
23091
23362
  }
23092
23363
  function stateForGrokModel(modelState, nativeState, model = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
23093
23364
  const selectedModel = model;
@@ -23106,12 +23377,12 @@ function stateForGrokModel(modelState, nativeState, model = modelState.currentMo
23106
23377
  }
23107
23378
 
23108
23379
  // dist/grok-credits.js
23109
- import { readFile as readFile2 } from "node:fs/promises";
23110
- import os4 from "node:os";
23111
- import path9 from "node:path";
23380
+ import { readFile as readFile3 } from "node:fs/promises";
23381
+ import os5 from "node:os";
23382
+ import path10 from "node:path";
23112
23383
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
23113
23384
  var REQUEST_TIMEOUT_MS = 15e3;
23114
- function isRecord12(value) {
23385
+ function isRecord13(value) {
23115
23386
  return typeof value === "object" && value !== null && !Array.isArray(value);
23116
23387
  }
23117
23388
  function finitePercent(value) {
@@ -23120,7 +23391,7 @@ function finitePercent(value) {
23120
23391
  return Math.min(100, Math.max(0, value));
23121
23392
  }
23122
23393
  function nonNegativeCentValue(value) {
23123
- if (!isRecord12(value))
23394
+ if (!isRecord13(value))
23124
23395
  return void 0;
23125
23396
  const amount = value.val === void 0 ? 0 : value.val;
23126
23397
  if (typeof amount !== "number" || !Number.isFinite(amount) || amount < 0)
@@ -23128,7 +23399,7 @@ function nonNegativeCentValue(value) {
23128
23399
  return amount;
23129
23400
  }
23130
23401
  function grokHome(environment) {
23131
- return environment.GROK_HOME ?? path9.join(environment.HOME ?? environment.USERPROFILE ?? os4.homedir(), ".grok");
23402
+ return environment.GROK_HOME ?? path10.join(environment.HOME ?? environment.USERPROFILE ?? os5.homedir(), ".grok");
23132
23403
  }
23133
23404
  function periodTypeFrom(value) {
23134
23405
  if (typeof value !== "string")
@@ -23144,7 +23415,7 @@ function productUsageFrom(value) {
23144
23415
  if (!Array.isArray(value))
23145
23416
  return void 0;
23146
23417
  const products = value.flatMap((entry) => {
23147
- if (!isRecord12(entry) || typeof entry.product !== "string")
23418
+ if (!isRecord13(entry) || typeof entry.product !== "string")
23148
23419
  return [];
23149
23420
  const usagePercent = finitePercent(entry.usagePercent);
23150
23421
  return usagePercent === void 0 ? [] : [{ product: entry.product, usagePercent }];
@@ -23152,10 +23423,10 @@ function productUsageFrom(value) {
23152
23423
  return products.length > 0 ? products : void 0;
23153
23424
  }
23154
23425
  function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
23155
- if (!isRecord12(value) || !isRecord12(value.config))
23426
+ if (!isRecord13(value) || !isRecord13(value.config))
23156
23427
  return null;
23157
23428
  const config2 = value.config;
23158
- const period = isRecord12(config2.currentPeriod) ? config2.currentPeriod : void 0;
23429
+ const period = isRecord13(config2.currentPeriod) ? config2.currentPeriod : void 0;
23159
23430
  const periodType = periodTypeFrom(period?.type);
23160
23431
  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);
23161
23432
  let usedPercent = finitePercent(config2.creditUsagePercent);
@@ -23182,11 +23453,11 @@ function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()
23182
23453
  };
23183
23454
  }
23184
23455
  function selectAccessToken(auth, now) {
23185
- if (!isRecord12(auth))
23456
+ if (!isRecord13(auth))
23186
23457
  return null;
23187
- const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord12(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")));
23458
+ const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord13(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")));
23188
23459
  for (const [, value] of entries) {
23189
- if (!isRecord12(value) || typeof value.key !== "string")
23460
+ if (!isRecord13(value) || typeof value.key !== "string")
23190
23461
  continue;
23191
23462
  if (typeof value.expires_at === "string") {
23192
23463
  const expiresAt = Date.parse(value.expires_at);
@@ -23207,8 +23478,8 @@ async function fetchGrokAccount(input = {}) {
23207
23478
  if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((value) => value?.trim()))
23208
23479
  return null;
23209
23480
  const now = input.now ?? /* @__PURE__ */ new Date();
23210
- const authPath = path9.join(grokHome(environment), "auth.json");
23211
- const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile2(authPath, "utf8");
23481
+ const authPath = path10.join(grokHome(environment), "auth.json");
23482
+ const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile3(authPath, "utf8");
23212
23483
  const token = selectAccessToken(JSON.parse(raw), now);
23213
23484
  if (!token)
23214
23485
  return null;
@@ -23257,7 +23528,7 @@ async function fetchGrokCredits(input = {}) {
23257
23528
 
23258
23529
  // dist/grok-usage.js
23259
23530
  var USD_TICKS_PER_DOLLAR = 1e10;
23260
- function isRecord13(value) {
23531
+ function isRecord14(value) {
23261
23532
  return typeof value === "object" && value !== null && !Array.isArray(value);
23262
23533
  }
23263
23534
  function optionalToken(value) {
@@ -23274,7 +23545,7 @@ function combineUsage(base, next) {
23274
23545
  return base === null ? next : parseHostUsage({ ...base, ...next });
23275
23546
  }
23276
23547
  function usageFromNative(value) {
23277
- if (!isRecord13(value))
23548
+ if (!isRecord14(value))
23278
23549
  return null;
23279
23550
  const inputTokens = optionalToken(value.inputTokens);
23280
23551
  const cachedRead = optionalToken(value.cachedReadTokens);
@@ -23301,7 +23572,7 @@ function usageFromPrompt(response) {
23301
23572
  return response.usage ? usageFromNative(response.usage) : null;
23302
23573
  }
23303
23574
  function usageFromSignals(value) {
23304
- if (!isRecord13(value))
23575
+ if (!isRecord14(value))
23305
23576
  return null;
23306
23577
  try {
23307
23578
  return parseHostUsage({
@@ -23321,7 +23592,7 @@ var summedUsageFields = [
23321
23592
  "totalTokens"
23322
23593
  ];
23323
23594
  function nativeCostTicks(value) {
23324
- if (!isRecord13(value))
23595
+ if (!isRecord14(value))
23325
23596
  return void 0;
23326
23597
  const ticks = value.costUsdTicks;
23327
23598
  if (typeof ticks !== "number" || !Number.isSafeInteger(ticks) || ticks < 0)
@@ -23398,7 +23669,7 @@ function usageFromCompact(tokensAfter, contextWindowTokens) {
23398
23669
  function usageFromUpdate(update, metadata, contextWindowTokens) {
23399
23670
  try {
23400
23671
  if (update?.sessionUpdate === "usage_update") {
23401
- const cost = isRecord13(update.cost) ? update.cost : null;
23672
+ const cost = isRecord14(update.cost) ? update.cost : null;
23402
23673
  return parseHostUsage({
23403
23674
  contextUsedTokens: update.used,
23404
23675
  contextWindowTokens: update.size,
@@ -23544,7 +23815,7 @@ var GrokHarnessSession = class {
23544
23815
  this.#usage = this.initialUsage;
23545
23816
  this.capabilities = capabilitiesForModels(modelState);
23546
23817
  this.commands = {
23547
- list: async () => ({ ok: true, value: grokCommandCatalog }),
23818
+ list: async () => ({ ok: true, value: this.#liveCommandCatalog() }),
23548
23819
  execute: (command) => this.#executeHarnessCommand(command)
23549
23820
  };
23550
23821
  this.#state = stateForGrokModel(modelState, { nativeRef: nativeRef(opened.sessionId) }, modelState.currentModel, modelState.currentThinkingOptionId, options.initialPermissionModeId);
@@ -23656,7 +23927,21 @@ var GrokHarnessSession = class {
23656
23927
  }));
23657
23928
  return { ok: true, value: { turnId: command.turnId } };
23658
23929
  }
23930
+ /** Built-ins plus the commands, workflows and skills the open Session advertises. */
23931
+ #liveCommandCatalog() {
23932
+ const native = this.#transport.availableCommands ?? null;
23933
+ return mergeLiveHarnessCommands(grokCommandCatalog, GROK_LIVE_COMMAND_ID_PREFIX, native ? grokLiveCommands(native) : null);
23934
+ }
23659
23935
  async #executeHarnessCommand(command) {
23936
+ const livePrompt = liveHarnessCommandPrompt(this.#liveCommandCatalog(), GROK_LIVE_COMMAND_ID_PREFIX, command.commandId, command.arguments?.text);
23937
+ if (livePrompt !== null) {
23938
+ const started = await this.execute({
23939
+ type: "turn.start",
23940
+ turnId: command.turnId,
23941
+ input: [{ type: "text", text: livePrompt }]
23942
+ });
23943
+ return started.ok ? { ok: true, value: { turnId: command.turnId } } : started;
23944
+ }
23660
23945
  if (command.commandId !== "grok.compact") {
23661
23946
  return {
23662
23947
  ok: false,
@@ -24390,7 +24675,11 @@ var GrokHarnessSession = class {
24390
24675
  }
24391
24676
  };
24392
24677
  var GrokAdapter = class {
24678
+ credentialExport = {
24679
+ read: () => this.#closePromise ? Promise.resolve([]) : readGrokCredentials(this.#environment ?? process.env)
24680
+ };
24393
24681
  commandCatalog = grokCommandCatalog;
24682
+ liveCommandCatalog = true;
24394
24683
  harnessId = grokHarnessId;
24395
24684
  subagents = {
24396
24685
  readSnapshot: async (input) => {
@@ -24482,7 +24771,7 @@ var GrokAdapter = class {
24482
24771
  async inspect(input = {}) {
24483
24772
  if (this.#closePromise)
24484
24773
  return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
24485
- const cwd = path10.resolve(input.cwd ?? process.cwd());
24774
+ const cwd = path11.resolve(input.cwd ?? process.cwd());
24486
24775
  if (!input.refresh) {
24487
24776
  const cached2 = this.#inspectionCache.get(cwd);
24488
24777
  if (cached2)
@@ -24544,7 +24833,7 @@ var GrokAdapter = class {
24544
24833
  }
24545
24834
  };
24546
24835
  }
24547
- const cwd = path10.resolve(input.cwd);
24836
+ const cwd = path11.resolve(input.cwd);
24548
24837
  const parsedRef = input.kind === "resume" ? nativeSessionRefSchema.safeParse(input.nativeRef) : null;
24549
24838
  if (parsedRef && (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId)) {
24550
24839
  return {