@codexhost/cli-win32-arm64 0.9.1-test.2 → 0.9.2

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
 
@@ -15051,6 +15144,8 @@ var pluginPresentationShape = {
15051
15144
  id: harnessPluginIdSchema,
15052
15145
  name: external_exports.string().trim().min(1).max(128),
15053
15146
  version: external_exports.string().min(1).max(128),
15147
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15148
+ launchCommand: external_exports.literal(true).optional(),
15054
15149
  links: external_exports.object({
15055
15150
  documentation: documentationUrlSchema.optional(),
15056
15151
  installation: documentationUrlSchema.optional()
@@ -15088,6 +15183,19 @@ var harnessPluginRouteSchema = external_exports.object({
15088
15183
  permissionModeId: harnessPermissionModeIdSchema.optional()
15089
15184
  }).strict();
15090
15185
 
15186
+ // ../../shared-contracts/dist/harness-launch-settings.js
15187
+ var harnessLaunchPathSchema = external_exports.string().trim().min(1).max(4096).refine((value) => !/[\u0000\r\n]/u.test(value), "Invalid entrypoint path");
15188
+ var harnessLaunchSettingsGetSchema = external_exports.object({
15189
+ harnessId: harnessPluginIdSchema
15190
+ }).strict();
15191
+ var harnessLaunchSettingsSetSchema = harnessLaunchSettingsGetSchema.extend({
15192
+ path: harnessLaunchPathSchema.nullable()
15193
+ });
15194
+ var harnessLaunchSettingsSchema = external_exports.object({
15195
+ path: harnessLaunchPathSchema.nullable(),
15196
+ restartRequired: external_exports.boolean()
15197
+ }).strict();
15198
+
15091
15199
  // ../../shared-contracts/dist/codex-accounts.js
15092
15200
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
15093
15201
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
@@ -15533,9 +15641,9 @@ function parseHostUsage(value) {
15533
15641
 
15534
15642
  // dist/acp-transport.js
15535
15643
  import { spawn, spawnSync } from "node:child_process";
15536
- import { readdir, readFile } from "node:fs/promises";
15537
- import os3 from "node:os";
15538
- import path8 from "node:path";
15644
+ import { readdir, readFile as readFile2 } from "node:fs/promises";
15645
+ import os4 from "node:os";
15646
+ import path9 from "node:path";
15539
15647
  import { Readable, Writable } from "node:stream";
15540
15648
 
15541
15649
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -19700,13 +19808,13 @@ var ClientSideConnection = class {
19700
19808
  };
19701
19809
 
19702
19810
  // dist/command.js
19703
- import path3 from "node:path";
19811
+ import path4 from "node:path";
19704
19812
 
19705
19813
  // ../../harness-discovery/dist/environment.js
19706
19814
  import fs from "node:fs";
19707
- import path from "node:path";
19815
+ import path2 from "node:path";
19708
19816
  function targetPath(platform) {
19709
- return platform === "win32" ? path.win32 : path.posix;
19817
+ return platform === "win32" ? path2.win32 : path2.posix;
19710
19818
  }
19711
19819
  function environmentValue(environment, name) {
19712
19820
  const lowered = name.toLowerCase();
@@ -19749,9 +19857,9 @@ function newestFirst(names) {
19749
19857
  }
19750
19858
 
19751
19859
  // ../../harness-discovery/dist/invocation.js
19752
- import path2 from "node:path";
19860
+ import path3 from "node:path";
19753
19861
  function commandInvocation(command, arguments_, environment, platform = process.platform) {
19754
- const extension = path2.win32.extname(command).toLowerCase();
19862
+ const extension = path3.win32.extname(command).toLowerCase();
19755
19863
  if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
19756
19864
  return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
19757
19865
  }
@@ -19765,7 +19873,7 @@ function commandInvocation(command, arguments_, environment, platform = process.
19765
19873
  }
19766
19874
 
19767
19875
  // ../../harness-discovery/dist/resolve.js
19768
- import os from "node:os";
19876
+ import os2 from "node:os";
19769
19877
 
19770
19878
  // ../../harness-discovery/dist/version-managers.js
19771
19879
  function versionManagerBinaryDirectories(context) {
@@ -19831,7 +19939,7 @@ function installRootExtensions(platform) {
19831
19939
  return platform === "win32" ? [".exe", ".cmd"] : [""];
19832
19940
  }
19833
19941
  function resolveHomeDirectory(input) {
19834
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
19942
+ return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os2.homedir();
19835
19943
  }
19836
19944
  function templateVariables(environment, platform, home) {
19837
19945
  const pathFlavor = targetPath(platform);
@@ -19956,7 +20064,7 @@ function resolveGrokExecutable(input = {}) {
19956
20064
  });
19957
20065
  if (!resolution)
19958
20066
  throw new GrokExecutableError("Grok CLI is not installed");
19959
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path3.resolve(resolution.executable);
20067
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path4.resolve(resolution.executable);
19960
20068
  }
19961
20069
  function grokInvocation(command, platform = process.platform, modelId) {
19962
20070
  const arguments_ = ["agent", "--no-leader"];
@@ -19969,11 +20077,11 @@ function grokInvocation(command, platform = process.platform, modelId) {
19969
20077
 
19970
20078
  // dist/grok-fork.js
19971
20079
  import { isDeepStrictEqual } from "node:util";
19972
- import path6 from "node:path";
20080
+ import path7 from "node:path";
19973
20081
 
19974
20082
  // dist/grok-file-change.js
19975
20083
  import { Buffer as Buffer2 } from "node:buffer";
19976
- import path4 from "node:path";
20084
+ import path5 from "node:path";
19977
20085
 
19978
20086
  // ../../../node_modules/diff/libesm/diff/base.js
19979
20087
  var Diff = class {
@@ -20075,16 +20183,16 @@ var Diff = class {
20075
20183
  }
20076
20184
  }
20077
20185
  }
20078
- addToPath(path11, added, removed, oldPosInc, options) {
20079
- const last = path11.lastComponent;
20186
+ addToPath(path12, added, removed, oldPosInc, options) {
20187
+ const last = path12.lastComponent;
20080
20188
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
20081
20189
  return {
20082
- oldPos: path11.oldPos + oldPosInc,
20190
+ oldPos: path12.oldPos + oldPosInc,
20083
20191
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
20084
20192
  };
20085
20193
  } else {
20086
20194
  return {
20087
- oldPos: path11.oldPos + oldPosInc,
20195
+ oldPos: path12.oldPos + oldPosInc,
20088
20196
  lastComponent: { count: 1, added, removed, previousComponent: last }
20089
20197
  };
20090
20198
  }
@@ -20397,13 +20505,13 @@ function isRecord3(value) {
20397
20505
  return typeof value === "object" && value !== null && !Array.isArray(value);
20398
20506
  }
20399
20507
  function validAbsolutePath(value) {
20400
- return typeof value === "string" && path4.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
20508
+ return typeof value === "string" && path5.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
20401
20509
  }
20402
20510
  function displayPath(nativePath, cwd) {
20403
- const resolvedCwd = path4.resolve(cwd);
20404
- const resolvedPath = path4.resolve(nativePath);
20405
- const relative = path4.relative(resolvedCwd, resolvedPath);
20406
- const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path4.sep}`);
20511
+ const resolvedCwd = path5.resolve(cwd);
20512
+ const resolvedPath = path5.resolve(nativePath);
20513
+ const relative = path5.relative(resolvedCwd, resolvedPath);
20514
+ const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path5.sep}`);
20407
20515
  const selected = inside ? relative : resolvedPath;
20408
20516
  const normalized = selected.replaceAll("\\", "/");
20409
20517
  if (normalized.length === 0 || normalized === ".")
@@ -20465,8 +20573,8 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
20465
20573
 
20466
20574
  // dist/local-media-markdown.js
20467
20575
  import { existsSync, statSync } from "node:fs";
20468
- import os2 from "node:os";
20469
- import path5 from "node:path";
20576
+ import os3 from "node:os";
20577
+ import path6 from "node:path";
20470
20578
  var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20471
20579
  ".aac",
20472
20580
  ".gif",
@@ -20485,14 +20593,14 @@ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20485
20593
  ".webp"
20486
20594
  ]);
20487
20595
  function grokMediaResolveRoots(cwd, sessionDirectory) {
20488
- const roots = [path5.resolve(cwd)];
20596
+ const roots = [path6.resolve(cwd)];
20489
20597
  if (sessionDirectory) {
20490
- const session = path5.resolve(sessionDirectory);
20491
- roots.push(session, path5.join(session, "videos"), path5.join(session, "images"));
20598
+ const session = path6.resolve(sessionDirectory);
20599
+ roots.push(session, path6.join(session, "videos"), path6.join(session, "images"));
20492
20600
  }
20493
- const home = process.env.HOME ?? process.env.USERPROFILE ?? os2.homedir();
20601
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? os3.homedir();
20494
20602
  if (home)
20495
- roots.push(path5.join(home, "Downloads"));
20603
+ roots.push(path6.join(home, "Downloads"));
20496
20604
  return roots;
20497
20605
  }
20498
20606
  function rewriteLocalMediaMarkdown(text, roots, options = {}) {
@@ -20593,7 +20701,7 @@ function parseInlineCode(text, start) {
20593
20701
  return { closed: false, content: text.slice(start + 1), end: text.length };
20594
20702
  }
20595
20703
  function mediaMarkdownImage(absolutePath) {
20596
- const name = path5.basename(absolutePath).replaceAll("]", "\\]");
20704
+ const name = path6.basename(absolutePath).replaceAll("]", "\\]");
20597
20705
  return `![${name}](${formatMarkdownDestination(absolutePath, false)})`;
20598
20706
  }
20599
20707
  function parseMarkdownImage(text, start) {
@@ -20718,11 +20826,11 @@ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
20718
20826
  if (!hasMediaExtension(stripped))
20719
20827
  return null;
20720
20828
  if (isAbsoluteMediaPath(stripped)) {
20721
- const absolute = path5.resolve(stripped);
20829
+ const absolute = path6.resolve(stripped);
20722
20830
  return exists(absolute) ? absolute : null;
20723
20831
  }
20724
20832
  for (const root of roots) {
20725
- const absolute = path5.resolve(root, stripped);
20833
+ const absolute = path6.resolve(root, stripped);
20726
20834
  if (exists(absolute))
20727
20835
  return absolute;
20728
20836
  }
@@ -20744,11 +20852,11 @@ function stripFileUrl(value) {
20744
20852
  }
20745
20853
  }
20746
20854
  function isAbsoluteMediaPath(value) {
20747
- return path5.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
20855
+ return path6.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
20748
20856
  }
20749
20857
  function hasMediaExtension(value) {
20750
20858
  const pathname = value.split(/[?#]/, 1)[0] ?? value;
20751
- return MEDIA_EXTENSIONS.has(path5.extname(pathname).toLowerCase());
20859
+ return MEDIA_EXTENSIONS.has(path6.extname(pathname).toLowerCase());
20752
20860
  }
20753
20861
  function mediaFileExists(absolutePath) {
20754
20862
  try {
@@ -21757,11 +21865,11 @@ function parseGrokForkResponse(value) {
21757
21865
  }
21758
21866
  function projectRelativePath(value, cwds) {
21759
21867
  const normalized = value.replaceAll("\\", "/");
21760
- if (!path6.isAbsolute(value))
21868
+ if (!path7.isAbsolute(value))
21761
21869
  return normalized;
21762
21870
  for (const cwd of cwds) {
21763
- const relative = path6.relative(path6.resolve(cwd), path6.resolve(value));
21764
- if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path6.sep}`)) {
21871
+ const relative = path7.relative(path7.resolve(cwd), path7.resolve(value));
21872
+ if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path7.sep}`)) {
21765
21873
  return relative.replaceAll("\\", "/");
21766
21874
  }
21767
21875
  }
@@ -21826,8 +21934,8 @@ async function forkGrokSession(input) {
21826
21934
  error: error51("sessionNotFound", "Grok Native Session is unavailable")
21827
21935
  };
21828
21936
  }
21829
- const sourceCwd = path6.resolve(located.cwd);
21830
- const targetCwd = path6.resolve(input.cwd);
21937
+ const sourceCwd = path7.resolve(located.cwd);
21938
+ const targetCwd = path7.resolve(input.cwd);
21831
21939
  const source = await readSnapshot({ ...input, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
21832
21940
  if (!source.ok)
21833
21941
  return source;
@@ -22009,7 +22117,7 @@ function parseGrokCompactResult(value, cancelled = false) {
22009
22117
  }
22010
22118
 
22011
22119
  // dist/grok-rewind.js
22012
- import path7 from "node:path";
22120
+ import path8 from "node:path";
22013
22121
  var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
22014
22122
  function error52(code, message, retryable = false) {
22015
22123
  return { code, message, retryable };
@@ -22082,8 +22190,8 @@ async function rewindGrokLastTurn(input) {
22082
22190
  error: error52("sessionNotFound", "Grok Native Session is unavailable")
22083
22191
  };
22084
22192
  }
22085
- const sourceCwd = path7.resolve(located.cwd);
22086
- const targetCwd = path7.resolve(input.cwd);
22193
+ const sourceCwd = path8.resolve(located.cwd);
22194
+ const targetCwd = path8.resolve(input.cwd);
22087
22195
  if (sourceCwd !== targetCwd) {
22088
22196
  return {
22089
22197
  ok: false,
@@ -22326,21 +22434,21 @@ function transportEvent(update, metadata) {
22326
22434
  }
22327
22435
  function grokHomeDir(options) {
22328
22436
  const environment = { ...process.env, ...options.environment };
22329
- const home = environment.HOME ?? environment.USERPROFILE ?? os3.homedir();
22330
- return environment.GROK_HOME ?? path8.join(home, ".grok");
22437
+ const home = environment.HOME ?? environment.USERPROFILE ?? os4.homedir();
22438
+ return environment.GROK_HOME ?? path9.join(home, ".grok");
22331
22439
  }
22332
22440
  function grokNativeSessionDirectory(options, sessionId) {
22333
- return path8.join(grokHomeDir(options), "sessions", encodeURIComponent(path8.resolve(options.cwd)), sessionId);
22441
+ return path9.join(grokHomeDir(options), "sessions", encodeURIComponent(path9.resolve(options.cwd)), sessionId);
22334
22442
  }
22335
22443
  function nativeSessionFile(options, sessionId, fileName) {
22336
- return path8.join(grokNativeSessionDirectory(options, sessionId), fileName);
22444
+ return path9.join(grokNativeSessionDirectory(options, sessionId), fileName);
22337
22445
  }
22338
22446
  function nativeHistoryPath(options, sessionId) {
22339
22447
  return nativeSessionFile(options, sessionId, "updates.jsonl");
22340
22448
  }
22341
22449
  async function readNativeSignals(options, sessionId) {
22342
22450
  try {
22343
- return JSON.parse(await readFile(nativeSessionFile(options, sessionId, "signals.json"), "utf8"));
22451
+ return JSON.parse(await readFile2(nativeSessionFile(options, sessionId, "signals.json"), "utf8"));
22344
22452
  } catch {
22345
22453
  return void 0;
22346
22454
  }
@@ -22353,7 +22461,7 @@ async function locateGrokNativeSession(options, sessionId) {
22353
22461
  return null;
22354
22462
  let entries;
22355
22463
  try {
22356
- entries = await readdir(path8.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
22464
+ entries = await readdir(path9.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
22357
22465
  } catch (error53) {
22358
22466
  if (isMissingFile(error53))
22359
22467
  return null;
@@ -22367,7 +22475,7 @@ async function locateGrokNativeSession(options, sessionId) {
22367
22475
  continue;
22368
22476
  let summaryRaw;
22369
22477
  try {
22370
- summaryRaw = await readFile(path8.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
22478
+ summaryRaw = await readFile2(path9.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
22371
22479
  } catch (error53) {
22372
22480
  if (isMissingFile(error53) || isRecord10(error53) && error53.code === "ENOTDIR")
22373
22481
  continue;
@@ -22384,8 +22492,8 @@ async function locateGrokNativeSession(options, sessionId) {
22384
22492
  if (!isRecord10(parsed))
22385
22493
  continue;
22386
22494
  const info = parsed.info;
22387
- const cwd = isRecord10(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path8.resolve(info.cwd) : path8.resolve(decodeURIComponent(entry.name));
22388
- const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path8.resolve(parsed.source_workspace_dir) : void 0;
22495
+ const cwd = isRecord10(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path9.resolve(info.cwd) : path9.resolve(decodeURIComponent(entry.name));
22496
+ const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path9.resolve(parsed.source_workspace_dir) : void 0;
22389
22497
  matches.push({
22390
22498
  cwd,
22391
22499
  ...sourceWorkspaceDir ? { sourceWorkspaceDir } : {}
@@ -22395,7 +22503,7 @@ async function locateGrokNativeSession(options, sessionId) {
22395
22503
  }
22396
22504
  async function readGrokNativeHistory(options, sessionId) {
22397
22505
  try {
22398
- return parseNativeHistory(await readFile(nativeHistoryPath({ ...options, cwd: path8.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
22506
+ return parseNativeHistory(await readFile2(nativeHistoryPath({ ...options, cwd: path9.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
22399
22507
  } catch (error53) {
22400
22508
  if (isMissingFile(error53))
22401
22509
  return [];
@@ -23091,9 +23199,9 @@ function stateForGrokModel(modelState, nativeState, model = modelState.currentMo
23091
23199
  }
23092
23200
 
23093
23201
  // dist/grok-credits.js
23094
- import { readFile as readFile2 } from "node:fs/promises";
23095
- import os4 from "node:os";
23096
- import path9 from "node:path";
23202
+ import { readFile as readFile3 } from "node:fs/promises";
23203
+ import os5 from "node:os";
23204
+ import path10 from "node:path";
23097
23205
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
23098
23206
  var REQUEST_TIMEOUT_MS = 15e3;
23099
23207
  function isRecord12(value) {
@@ -23113,7 +23221,7 @@ function nonNegativeCentValue(value) {
23113
23221
  return amount;
23114
23222
  }
23115
23223
  function grokHome(environment) {
23116
- return environment.GROK_HOME ?? path9.join(environment.HOME ?? environment.USERPROFILE ?? os4.homedir(), ".grok");
23224
+ return environment.GROK_HOME ?? path10.join(environment.HOME ?? environment.USERPROFILE ?? os5.homedir(), ".grok");
23117
23225
  }
23118
23226
  function periodTypeFrom(value) {
23119
23227
  if (typeof value !== "string")
@@ -23192,8 +23300,8 @@ async function fetchGrokAccount(input = {}) {
23192
23300
  if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((value) => value?.trim()))
23193
23301
  return null;
23194
23302
  const now = input.now ?? /* @__PURE__ */ new Date();
23195
- const authPath = path9.join(grokHome(environment), "auth.json");
23196
- const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile2(authPath, "utf8");
23303
+ const authPath = path10.join(grokHome(environment), "auth.json");
23304
+ const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile3(authPath, "utf8");
23197
23305
  const token = selectAccessToken(JSON.parse(raw), now);
23198
23306
  if (!token)
23199
23307
  return null;
@@ -24375,6 +24483,9 @@ var GrokHarnessSession = class {
24375
24483
  }
24376
24484
  };
24377
24485
  var GrokAdapter = class {
24486
+ credentialExport = {
24487
+ read: () => this.#closePromise ? Promise.resolve([]) : readGrokCredentials(this.#environment ?? process.env)
24488
+ };
24378
24489
  commandCatalog = grokCommandCatalog;
24379
24490
  harnessId = grokHarnessId;
24380
24491
  subagents = {
@@ -24467,7 +24578,7 @@ var GrokAdapter = class {
24467
24578
  async inspect(input = {}) {
24468
24579
  if (this.#closePromise)
24469
24580
  return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
24470
- const cwd = path10.resolve(input.cwd ?? process.cwd());
24581
+ const cwd = path11.resolve(input.cwd ?? process.cwd());
24471
24582
  if (!input.refresh) {
24472
24583
  const cached2 = this.#inspectionCache.get(cwd);
24473
24584
  if (cached2)
@@ -24529,7 +24640,7 @@ var GrokAdapter = class {
24529
24640
  }
24530
24641
  };
24531
24642
  }
24532
- const cwd = path10.resolve(input.cwd);
24643
+ const cwd = path11.resolve(input.cwd);
24533
24644
  const parsedRef = input.kind === "resume" ? nativeSessionRefSchema.safeParse(input.nativeRef) : null;
24534
24645
  if (parsedRef && (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId)) {
24535
24646
  return {