@codexhost/cli-darwin-x64 0.9.1 → 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.
@@ -18223,6 +18223,61 @@ function date4(params) {
18223
18223
  // ../../../node_modules/zod/v4/classic/external.js
18224
18224
  config(en_default());
18225
18225
 
18226
+ // ../../shared-contracts/dist/credential-imports.js
18227
+ var credentialSourceSchema = external_exports.object({
18228
+ id: external_exports.string().min(1).max(256),
18229
+ harnessId: external_exports.string().min(1),
18230
+ label: external_exports.string().min(1).max(512),
18231
+ provider: external_exports.enum(["openai-codex", "xai"])
18232
+ }).strict();
18233
+ var credentialImportNameSchema = external_exports.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
18234
+ var credentialImportRecordSchema = external_exports.object({
18235
+ name: credentialImportNameSchema,
18236
+ source: credentialSourceSchema,
18237
+ importedAt: external_exports.string()
18238
+ }).strict();
18239
+ var credentialImportsRequestSchema = external_exports.discriminatedUnion("action", [
18240
+ external_exports.object({ action: external_exports.literal("list") }).strict(),
18241
+ external_exports.object({
18242
+ action: external_exports.literal("import"),
18243
+ sourceId: external_exports.string().min(1).max(256),
18244
+ name: credentialImportNameSchema,
18245
+ confirmed: external_exports.literal(true)
18246
+ }).strict(),
18247
+ external_exports.object({
18248
+ action: external_exports.literal("reimport"),
18249
+ sourceId: external_exports.string().min(1).max(256),
18250
+ name: credentialImportNameSchema,
18251
+ confirmed: external_exports.literal(true)
18252
+ }).strict(),
18253
+ external_exports.object({
18254
+ action: external_exports.literal("remove"),
18255
+ name: credentialImportNameSchema,
18256
+ confirmed: external_exports.literal(true)
18257
+ }).strict()
18258
+ ]);
18259
+ var credentialOtherLoginSchema = external_exports.object({
18260
+ provider: external_exports.string().min(1).max(128),
18261
+ type: external_exports.enum(["oauth", "api_key", "unknown"]),
18262
+ /** Best-effort account label (e.g. the email in a Codex token), derived locally when present. */
18263
+ label: external_exports.string().min(1).max(512).optional(),
18264
+ /** Recognized credential vendor, derived from the OAuth token issuer. Absent when unknown. */
18265
+ vendor: external_exports.enum(["openai-codex", "xai"]).optional()
18266
+ }).strict();
18267
+ var credentialImportsResultSchema = external_exports.object({
18268
+ sources: external_exports.array(credentialSourceSchema),
18269
+ targets: external_exports.array(external_exports.object({
18270
+ harnessId: external_exports.string(),
18271
+ providers: external_exports.array(external_exports.enum(["openai-codex", "xai"])),
18272
+ imports: external_exports.array(credentialImportRecordSchema),
18273
+ others: external_exports.array(credentialOtherLoginSchema).default([])
18274
+ }).strict())
18275
+ }).strict();
18276
+ var credentialImportsParamsSchema = external_exports.object({
18277
+ targetHarnessId: external_exports.string().min(1).max(128).optional(),
18278
+ request: credentialImportsRequestSchema
18279
+ }).strict();
18280
+
18226
18281
  // ../../shared-contracts/dist/version.js
18227
18282
  var WORKSPACE_CONTRACT_VERSION = 1;
18228
18283
 
@@ -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
 
@@ -15548,9 +15641,9 @@ function parseHostUsage(value) {
15548
15641
 
15549
15642
  // dist/acp-transport.js
15550
15643
  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";
15644
+ import { readdir, readFile as readFile2 } from "node:fs/promises";
15645
+ import os4 from "node:os";
15646
+ import path9 from "node:path";
15554
15647
  import { Readable, Writable } from "node:stream";
15555
15648
 
15556
15649
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
@@ -19715,13 +19808,13 @@ var ClientSideConnection = class {
19715
19808
  };
19716
19809
 
19717
19810
  // dist/command.js
19718
- import path3 from "node:path";
19811
+ import path4 from "node:path";
19719
19812
 
19720
19813
  // ../../harness-discovery/dist/environment.js
19721
19814
  import fs from "node:fs";
19722
- import path from "node:path";
19815
+ import path2 from "node:path";
19723
19816
  function targetPath(platform) {
19724
- return platform === "win32" ? path.win32 : path.posix;
19817
+ return platform === "win32" ? path2.win32 : path2.posix;
19725
19818
  }
19726
19819
  function environmentValue(environment, name) {
19727
19820
  const lowered = name.toLowerCase();
@@ -19764,9 +19857,9 @@ function newestFirst(names) {
19764
19857
  }
19765
19858
 
19766
19859
  // ../../harness-discovery/dist/invocation.js
19767
- import path2 from "node:path";
19860
+ import path3 from "node:path";
19768
19861
  function commandInvocation(command, arguments_, environment, platform = process.platform) {
19769
- const extension = path2.win32.extname(command).toLowerCase();
19862
+ const extension = path3.win32.extname(command).toLowerCase();
19770
19863
  if (platform !== "win32" || ![".cmd", ".bat"].includes(extension)) {
19771
19864
  return { command, arguments: [...arguments_], windowsVerbatimArguments: false };
19772
19865
  }
@@ -19780,7 +19873,7 @@ function commandInvocation(command, arguments_, environment, platform = process.
19780
19873
  }
19781
19874
 
19782
19875
  // ../../harness-discovery/dist/resolve.js
19783
- import os from "node:os";
19876
+ import os2 from "node:os";
19784
19877
 
19785
19878
  // ../../harness-discovery/dist/version-managers.js
19786
19879
  function versionManagerBinaryDirectories(context) {
@@ -19846,7 +19939,7 @@ function installRootExtensions(platform) {
19846
19939
  return platform === "win32" ? [".exe", ".cmd"] : [""];
19847
19940
  }
19848
19941
  function resolveHomeDirectory(input) {
19849
- 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();
19850
19943
  }
19851
19944
  function templateVariables(environment, platform, home) {
19852
19945
  const pathFlavor = targetPath(platform);
@@ -19971,7 +20064,7 @@ function resolveGrokExecutable(input = {}) {
19971
20064
  });
19972
20065
  if (!resolution)
19973
20066
  throw new GrokExecutableError("Grok CLI is not installed");
19974
- 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);
19975
20068
  }
19976
20069
  function grokInvocation(command, platform = process.platform, modelId) {
19977
20070
  const arguments_ = ["agent", "--no-leader"];
@@ -19984,11 +20077,11 @@ function grokInvocation(command, platform = process.platform, modelId) {
19984
20077
 
19985
20078
  // dist/grok-fork.js
19986
20079
  import { isDeepStrictEqual } from "node:util";
19987
- import path6 from "node:path";
20080
+ import path7 from "node:path";
19988
20081
 
19989
20082
  // dist/grok-file-change.js
19990
20083
  import { Buffer as Buffer2 } from "node:buffer";
19991
- import path4 from "node:path";
20084
+ import path5 from "node:path";
19992
20085
 
19993
20086
  // ../../../node_modules/diff/libesm/diff/base.js
19994
20087
  var Diff = class {
@@ -20090,16 +20183,16 @@ var Diff = class {
20090
20183
  }
20091
20184
  }
20092
20185
  }
20093
- addToPath(path11, added, removed, oldPosInc, options) {
20094
- const last = path11.lastComponent;
20186
+ addToPath(path12, added, removed, oldPosInc, options) {
20187
+ const last = path12.lastComponent;
20095
20188
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
20096
20189
  return {
20097
- oldPos: path11.oldPos + oldPosInc,
20190
+ oldPos: path12.oldPos + oldPosInc,
20098
20191
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
20099
20192
  };
20100
20193
  } else {
20101
20194
  return {
20102
- oldPos: path11.oldPos + oldPosInc,
20195
+ oldPos: path12.oldPos + oldPosInc,
20103
20196
  lastComponent: { count: 1, added, removed, previousComponent: last }
20104
20197
  };
20105
20198
  }
@@ -20412,13 +20505,13 @@ function isRecord3(value) {
20412
20505
  return typeof value === "object" && value !== null && !Array.isArray(value);
20413
20506
  }
20414
20507
  function validAbsolutePath(value) {
20415
- 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");
20416
20509
  }
20417
20510
  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}`);
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}`);
20422
20515
  const selected = inside ? relative : resolvedPath;
20423
20516
  const normalized = selected.replaceAll("\\", "/");
20424
20517
  if (normalized.length === 0 || normalized === ".")
@@ -20480,8 +20573,8 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
20480
20573
 
20481
20574
  // dist/local-media-markdown.js
20482
20575
  import { existsSync, statSync } from "node:fs";
20483
- import os2 from "node:os";
20484
- import path5 from "node:path";
20576
+ import os3 from "node:os";
20577
+ import path6 from "node:path";
20485
20578
  var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20486
20579
  ".aac",
20487
20580
  ".gif",
@@ -20500,14 +20593,14 @@ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20500
20593
  ".webp"
20501
20594
  ]);
20502
20595
  function grokMediaResolveRoots(cwd, sessionDirectory) {
20503
- const roots = [path5.resolve(cwd)];
20596
+ const roots = [path6.resolve(cwd)];
20504
20597
  if (sessionDirectory) {
20505
- const session = path5.resolve(sessionDirectory);
20506
- 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"));
20507
20600
  }
20508
- const home = process.env.HOME ?? process.env.USERPROFILE ?? os2.homedir();
20601
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? os3.homedir();
20509
20602
  if (home)
20510
- roots.push(path5.join(home, "Downloads"));
20603
+ roots.push(path6.join(home, "Downloads"));
20511
20604
  return roots;
20512
20605
  }
20513
20606
  function rewriteLocalMediaMarkdown(text, roots, options = {}) {
@@ -20608,7 +20701,7 @@ function parseInlineCode(text, start) {
20608
20701
  return { closed: false, content: text.slice(start + 1), end: text.length };
20609
20702
  }
20610
20703
  function mediaMarkdownImage(absolutePath) {
20611
- const name = path5.basename(absolutePath).replaceAll("]", "\\]");
20704
+ const name = path6.basename(absolutePath).replaceAll("]", "\\]");
20612
20705
  return `![${name}](${formatMarkdownDestination(absolutePath, false)})`;
20613
20706
  }
20614
20707
  function parseMarkdownImage(text, start) {
@@ -20733,11 +20826,11 @@ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
20733
20826
  if (!hasMediaExtension(stripped))
20734
20827
  return null;
20735
20828
  if (isAbsoluteMediaPath(stripped)) {
20736
- const absolute = path5.resolve(stripped);
20829
+ const absolute = path6.resolve(stripped);
20737
20830
  return exists(absolute) ? absolute : null;
20738
20831
  }
20739
20832
  for (const root of roots) {
20740
- const absolute = path5.resolve(root, stripped);
20833
+ const absolute = path6.resolve(root, stripped);
20741
20834
  if (exists(absolute))
20742
20835
  return absolute;
20743
20836
  }
@@ -20759,11 +20852,11 @@ function stripFileUrl(value) {
20759
20852
  }
20760
20853
  }
20761
20854
  function isAbsoluteMediaPath(value) {
20762
- return path5.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
20855
+ return path6.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
20763
20856
  }
20764
20857
  function hasMediaExtension(value) {
20765
20858
  const pathname = value.split(/[?#]/, 1)[0] ?? value;
20766
- return MEDIA_EXTENSIONS.has(path5.extname(pathname).toLowerCase());
20859
+ return MEDIA_EXTENSIONS.has(path6.extname(pathname).toLowerCase());
20767
20860
  }
20768
20861
  function mediaFileExists(absolutePath) {
20769
20862
  try {
@@ -21772,11 +21865,11 @@ function parseGrokForkResponse(value) {
21772
21865
  }
21773
21866
  function projectRelativePath(value, cwds) {
21774
21867
  const normalized = value.replaceAll("\\", "/");
21775
- if (!path6.isAbsolute(value))
21868
+ if (!path7.isAbsolute(value))
21776
21869
  return normalized;
21777
21870
  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}`)) {
21871
+ const relative = path7.relative(path7.resolve(cwd), path7.resolve(value));
21872
+ if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path7.sep}`)) {
21780
21873
  return relative.replaceAll("\\", "/");
21781
21874
  }
21782
21875
  }
@@ -21841,8 +21934,8 @@ async function forkGrokSession(input) {
21841
21934
  error: error51("sessionNotFound", "Grok Native Session is unavailable")
21842
21935
  };
21843
21936
  }
21844
- const sourceCwd = path6.resolve(located.cwd);
21845
- const targetCwd = path6.resolve(input.cwd);
21937
+ const sourceCwd = path7.resolve(located.cwd);
21938
+ const targetCwd = path7.resolve(input.cwd);
21846
21939
  const source = await readSnapshot({ ...input, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
21847
21940
  if (!source.ok)
21848
21941
  return source;
@@ -22024,7 +22117,7 @@ function parseGrokCompactResult(value, cancelled = false) {
22024
22117
  }
22025
22118
 
22026
22119
  // dist/grok-rewind.js
22027
- import path7 from "node:path";
22120
+ import path8 from "node:path";
22028
22121
  var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
22029
22122
  function error52(code, message, retryable = false) {
22030
22123
  return { code, message, retryable };
@@ -22097,8 +22190,8 @@ async function rewindGrokLastTurn(input) {
22097
22190
  error: error52("sessionNotFound", "Grok Native Session is unavailable")
22098
22191
  };
22099
22192
  }
22100
- const sourceCwd = path7.resolve(located.cwd);
22101
- const targetCwd = path7.resolve(input.cwd);
22193
+ const sourceCwd = path8.resolve(located.cwd);
22194
+ const targetCwd = path8.resolve(input.cwd);
22102
22195
  if (sourceCwd !== targetCwd) {
22103
22196
  return {
22104
22197
  ok: false,
@@ -22341,21 +22434,21 @@ function transportEvent(update, metadata) {
22341
22434
  }
22342
22435
  function grokHomeDir(options) {
22343
22436
  const environment = { ...process.env, ...options.environment };
22344
- const home = environment.HOME ?? environment.USERPROFILE ?? os3.homedir();
22345
- 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");
22346
22439
  }
22347
22440
  function grokNativeSessionDirectory(options, sessionId) {
22348
- 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);
22349
22442
  }
22350
22443
  function nativeSessionFile(options, sessionId, fileName) {
22351
- return path8.join(grokNativeSessionDirectory(options, sessionId), fileName);
22444
+ return path9.join(grokNativeSessionDirectory(options, sessionId), fileName);
22352
22445
  }
22353
22446
  function nativeHistoryPath(options, sessionId) {
22354
22447
  return nativeSessionFile(options, sessionId, "updates.jsonl");
22355
22448
  }
22356
22449
  async function readNativeSignals(options, sessionId) {
22357
22450
  try {
22358
- return JSON.parse(await readFile(nativeSessionFile(options, sessionId, "signals.json"), "utf8"));
22451
+ return JSON.parse(await readFile2(nativeSessionFile(options, sessionId, "signals.json"), "utf8"));
22359
22452
  } catch {
22360
22453
  return void 0;
22361
22454
  }
@@ -22368,7 +22461,7 @@ async function locateGrokNativeSession(options, sessionId) {
22368
22461
  return null;
22369
22462
  let entries;
22370
22463
  try {
22371
- entries = await readdir(path8.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
22464
+ entries = await readdir(path9.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
22372
22465
  } catch (error53) {
22373
22466
  if (isMissingFile(error53))
22374
22467
  return null;
@@ -22382,7 +22475,7 @@ async function locateGrokNativeSession(options, sessionId) {
22382
22475
  continue;
22383
22476
  let summaryRaw;
22384
22477
  try {
22385
- 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");
22386
22479
  } catch (error53) {
22387
22480
  if (isMissingFile(error53) || isRecord10(error53) && error53.code === "ENOTDIR")
22388
22481
  continue;
@@ -22399,8 +22492,8 @@ async function locateGrokNativeSession(options, sessionId) {
22399
22492
  if (!isRecord10(parsed))
22400
22493
  continue;
22401
22494
  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;
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;
22404
22497
  matches.push({
22405
22498
  cwd,
22406
22499
  ...sourceWorkspaceDir ? { sourceWorkspaceDir } : {}
@@ -22410,7 +22503,7 @@ async function locateGrokNativeSession(options, sessionId) {
22410
22503
  }
22411
22504
  async function readGrokNativeHistory(options, sessionId) {
22412
22505
  try {
22413
- 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);
22414
22507
  } catch (error53) {
22415
22508
  if (isMissingFile(error53))
22416
22509
  return [];
@@ -23106,9 +23199,9 @@ function stateForGrokModel(modelState, nativeState, model = modelState.currentMo
23106
23199
  }
23107
23200
 
23108
23201
  // 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";
23202
+ import { readFile as readFile3 } from "node:fs/promises";
23203
+ import os5 from "node:os";
23204
+ import path10 from "node:path";
23112
23205
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
23113
23206
  var REQUEST_TIMEOUT_MS = 15e3;
23114
23207
  function isRecord12(value) {
@@ -23128,7 +23221,7 @@ function nonNegativeCentValue(value) {
23128
23221
  return amount;
23129
23222
  }
23130
23223
  function grokHome(environment) {
23131
- 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");
23132
23225
  }
23133
23226
  function periodTypeFrom(value) {
23134
23227
  if (typeof value !== "string")
@@ -23207,8 +23300,8 @@ async function fetchGrokAccount(input = {}) {
23207
23300
  if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((value) => value?.trim()))
23208
23301
  return null;
23209
23302
  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");
23303
+ const authPath = path10.join(grokHome(environment), "auth.json");
23304
+ const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile3(authPath, "utf8");
23212
23305
  const token = selectAccessToken(JSON.parse(raw), now);
23213
23306
  if (!token)
23214
23307
  return null;
@@ -24390,6 +24483,9 @@ var GrokHarnessSession = class {
24390
24483
  }
24391
24484
  };
24392
24485
  var GrokAdapter = class {
24486
+ credentialExport = {
24487
+ read: () => this.#closePromise ? Promise.resolve([]) : readGrokCredentials(this.#environment ?? process.env)
24488
+ };
24393
24489
  commandCatalog = grokCommandCatalog;
24394
24490
  harnessId = grokHarnessId;
24395
24491
  subagents = {
@@ -24482,7 +24578,7 @@ var GrokAdapter = class {
24482
24578
  async inspect(input = {}) {
24483
24579
  if (this.#closePromise)
24484
24580
  return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
24485
- const cwd = path10.resolve(input.cwd ?? process.cwd());
24581
+ const cwd = path11.resolve(input.cwd ?? process.cwd());
24486
24582
  if (!input.refresh) {
24487
24583
  const cached2 = this.#inspectionCache.get(cwd);
24488
24584
  if (cached2)
@@ -24544,7 +24640,7 @@ var GrokAdapter = class {
24544
24640
  }
24545
24641
  };
24546
24642
  }
24547
- const cwd = path10.resolve(input.cwd);
24643
+ const cwd = path11.resolve(input.cwd);
24548
24644
  const parsedRef = input.kind === "resume" ? nativeSessionRefSchema.safeParse(input.nativeRef) : null;
24549
24645
  if (parsedRef && (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId)) {
24550
24646
  return {