@liberseek/boft-cli-win32-arm64 0.7.5 → 0.7.6

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.
@@ -45,7 +45,7 @@ async function readGrokCredentials(environment) {
45
45
  }
46
46
 
47
47
  // dist/grok-adapter.js
48
- import path11 from "node:path";
48
+ import path12 from "node:path";
49
49
 
50
50
  // ../../../node_modules/@agentclientprotocol/sdk/dist/schema/index.js
51
51
  var AGENT_METHODS = {
@@ -865,10 +865,10 @@ function mergeDefs(...defs) {
865
865
  function cloneDef(schema) {
866
866
  return mergeDefs(schema._zod.def);
867
867
  }
868
- function getElementAtPath(obj, path12) {
869
- if (!path12)
868
+ function getElementAtPath(obj, path13) {
869
+ if (!path13)
870
870
  return obj;
871
- return path12.reduce((acc, key) => acc?.[key], obj);
871
+ return path13.reduce((acc, key) => acc?.[key], obj);
872
872
  }
873
873
  function promiseAllObject(promisesObj) {
874
874
  const keys = Object.keys(promisesObj);
@@ -1277,11 +1277,11 @@ function explicitlyAborted(x, startIndex = 0) {
1277
1277
  }
1278
1278
  return false;
1279
1279
  }
1280
- function prefixIssues(path12, issues) {
1280
+ function prefixIssues(path13, issues) {
1281
1281
  return issues.map((iss) => {
1282
1282
  var _a3;
1283
1283
  (_a3 = iss).path ?? (_a3.path = []);
1284
- iss.path.unshift(path12);
1284
+ iss.path.unshift(path13);
1285
1285
  return iss;
1286
1286
  });
1287
1287
  }
@@ -1428,16 +1428,16 @@ function flattenError(error53, mapper = (issue2) => issue2.message) {
1428
1428
  }
1429
1429
  function formatError(error53, mapper = (issue2) => issue2.message) {
1430
1430
  const fieldErrors = { _errors: [] };
1431
- const processError = (error54, path12 = []) => {
1431
+ const processError = (error54, path13 = []) => {
1432
1432
  for (const issue2 of error54.issues) {
1433
1433
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1434
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1434
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1435
1435
  } else if (issue2.code === "invalid_key") {
1436
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1436
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1437
1437
  } else if (issue2.code === "invalid_element") {
1438
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1438
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1439
1439
  } else {
1440
- const fullpath = [...path12, ...issue2.path];
1440
+ const fullpath = [...path13, ...issue2.path];
1441
1441
  if (fullpath.length === 0) {
1442
1442
  fieldErrors._errors.push(mapper(issue2));
1443
1443
  } else {
@@ -1464,17 +1464,17 @@ function formatError(error53, mapper = (issue2) => issue2.message) {
1464
1464
  }
1465
1465
  function treeifyError(error53, mapper = (issue2) => issue2.message) {
1466
1466
  const result = { errors: [] };
1467
- const processError = (error54, path12 = []) => {
1467
+ const processError = (error54, path13 = []) => {
1468
1468
  var _a3, _b;
1469
1469
  for (const issue2 of error54.issues) {
1470
1470
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1471
- issue2.errors.map((issues) => processError({ issues }, [...path12, ...issue2.path]));
1471
+ issue2.errors.map((issues) => processError({ issues }, [...path13, ...issue2.path]));
1472
1472
  } else if (issue2.code === "invalid_key") {
1473
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1473
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1474
1474
  } else if (issue2.code === "invalid_element") {
1475
- processError({ issues: issue2.issues }, [...path12, ...issue2.path]);
1475
+ processError({ issues: issue2.issues }, [...path13, ...issue2.path]);
1476
1476
  } else {
1477
- const fullpath = [...path12, ...issue2.path];
1477
+ const fullpath = [...path13, ...issue2.path];
1478
1478
  if (fullpath.length === 0) {
1479
1479
  result.errors.push(mapper(issue2));
1480
1480
  continue;
@@ -1506,8 +1506,8 @@ function treeifyError(error53, mapper = (issue2) => issue2.message) {
1506
1506
  }
1507
1507
  function toDotPath(_path) {
1508
1508
  const segs = [];
1509
- const path12 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1510
- for (const seg of path12) {
1509
+ const path13 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1510
+ for (const seg of path13) {
1511
1511
  if (typeof seg === "number")
1512
1512
  segs.push(`[${seg}]`);
1513
1513
  else if (typeof seg === "symbol")
@@ -14199,13 +14199,13 @@ function resolveRef(ref, ctx) {
14199
14199
  if (!ref.startsWith("#")) {
14200
14200
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14201
14201
  }
14202
- const path12 = ref.slice(1).split("/").filter(Boolean);
14203
- if (path12.length === 0) {
14202
+ const path13 = ref.slice(1).split("/").filter(Boolean);
14203
+ if (path13.length === 0) {
14204
14204
  return ctx.rootSchema;
14205
14205
  }
14206
14206
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14207
- if (path12[0] === defsKey) {
14208
- const key = path12[1];
14207
+ if (path13[0] === defsKey) {
14208
+ const key = path13[1];
14209
14209
  if (!key || !ctx.defs[key]) {
14210
14210
  throw new Error(`Reference not found: ${ref}`);
14211
14211
  }
@@ -18777,6 +18777,55 @@ var credentialImportsParamsSchema = external_exports.object({
18777
18777
  request: credentialImportsRequestSchema
18778
18778
  }).strict();
18779
18779
 
18780
+ // ../../shared-contracts/dist/harness-display-settings.js
18781
+ var harnessDisplayEntriesSchema = external_exports.array(external_exports.strictObject({
18782
+ agent: external_exports.string().min(1).max(128),
18783
+ section: external_exports.enum(["main", "more", "auto"])
18784
+ })).max(256).refine((entries) => new Set(entries.map((entry) => entry.agent)).size === entries.length, "Duplicate Harness IDs");
18785
+ var harnessDisplaySettingsSchema = external_exports.strictObject({
18786
+ entries: harnessDisplayEntriesSchema.nullable()
18787
+ });
18788
+ var harnessDisplayGetSchema = external_exports.strictObject({});
18789
+ var harnessDisplaySetSchema = external_exports.strictObject({
18790
+ entries: harnessDisplayEntriesSchema,
18791
+ /** Import legacy Desktop preferences only if no shared settings exist yet. */
18792
+ initializeOnly: external_exports.boolean().optional()
18793
+ });
18794
+
18795
+ // ../../shared-contracts/dist/console.js
18796
+ var consoleAnnouncementSchema = external_exports.strictObject({
18797
+ title: external_exports.string().trim().min(1).max(200),
18798
+ type: external_exports.enum(["info", "warning", "danger"]),
18799
+ body: external_exports.string().trim().min(1).max(16 * 1024)
18800
+ });
18801
+ var consoleOpenParamsSchema = external_exports.strictObject({});
18802
+ var consoleOpenResultSchema = external_exports.strictObject({
18803
+ /** The console address. */
18804
+ url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
18805
+ });
18806
+ var CONSOLE_HOST_METHODS = Object.freeze([
18807
+ "codexhost/harness/plugins/list",
18808
+ "codexhost/harness/display-settings/get",
18809
+ "codexhost/harness/display-settings/set",
18810
+ "codexhost/harness/inspect",
18811
+ "codexhost/harness/launch-settings/get",
18812
+ "codexhost/harness/launch-settings/set",
18813
+ "codexhost/harness/web-ui/open",
18814
+ "codexhost/harness/accounts/sources",
18815
+ "codexhost/harness/accounts/list",
18816
+ "codexhost/harness/accounts/inspect",
18817
+ "codexhost/harness/credential-imports",
18818
+ "codexhost/harness/session-import/sources",
18819
+ "codexhost/harness/session-import/list",
18820
+ "codexhost/harness/session-import/import",
18821
+ "codexhost/account/list",
18822
+ "codexhost/account/refresh",
18823
+ "codexhost/account/usage/inspect",
18824
+ "codexhost/update/check",
18825
+ "codexhost/update/start",
18826
+ "codexhost/update/status"
18827
+ ]);
18828
+
18780
18829
  // ../../shared-contracts/dist/version.js
18781
18830
  var WORKSPACE_CONTRACT_VERSION = 1;
18782
18831
 
@@ -18830,6 +18879,12 @@ var hostTurnIdSchema = opaqueIdSchema.brand();
18830
18879
  var hostItemIdSchema = opaqueIdSchema.brand();
18831
18880
  var hostInteractionIdSchema = opaqueIdSchema.brand();
18832
18881
 
18882
+ // ../../shared-contracts/dist/manual-compaction.js
18883
+ var threadManualCompactionStartedSchema = external_exports.strictObject({
18884
+ threadId: hostThreadIdSchema,
18885
+ turnId: hostTurnIdSchema
18886
+ });
18887
+
18833
18888
  // ../../shared-contracts/dist/thread-usage.js
18834
18889
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
18835
18890
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -18890,6 +18945,10 @@ var threadUsageSnapshotSchema = external_exports.object({
18890
18945
  var usagePercentSchema = external_exports.number().finite().min(0).max(100);
18891
18946
  var accountCreditsProductUsageSchema = external_exports.object({
18892
18947
  product: external_exports.string().min(1),
18948
+ used: external_exports.number().finite().nonnegative().optional(),
18949
+ // Zero is a real empty cap, not an absent field.
18950
+ limit: external_exports.number().finite().nonnegative().optional(),
18951
+ unit: external_exports.string().min(1).max(32).optional(),
18893
18952
  usagePercent: usagePercentSchema,
18894
18953
  resetsAt: external_exports.string().min(1).optional()
18895
18954
  }).strict();
@@ -18899,11 +18958,14 @@ var accountResetCreditsSchema = external_exports.object({
18899
18958
  expiresAt: external_exports.array(external_exports.string().min(1)).min(1).max(32).optional()
18900
18959
  }).strict();
18901
18960
  var accountCreditsSnapshotSchema = external_exports.object({
18961
+ used: external_exports.number().finite().nonnegative().optional(),
18962
+ // Zero is a real empty cap, not an absent field.
18963
+ limit: external_exports.number().finite().nonnegative().optional(),
18964
+ unit: external_exports.string().trim().min(1).max(32).optional(),
18902
18965
  /** Native label when the primary limit is scoped to a model or product group. */
18903
18966
  label: external_exports.string().min(1).optional(),
18904
18967
  usedPercent: usagePercentSchema.optional(),
18905
18968
  remaining: external_exports.number().finite().optional(),
18906
- unit: external_exports.string().trim().min(1).max(32).optional(),
18907
18969
  resetsAt: external_exports.string().min(1).optional(),
18908
18970
  periodType: external_exports.enum(["weekly", "monthly", "five_hour", "seven_day", "unknown"]),
18909
18971
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
@@ -18934,12 +18996,27 @@ var threadUsageInspectionSchema = external_exports.object({
18934
18996
  }).strict();
18935
18997
 
18936
18998
  // ../../shared-contracts/dist/harness-accounts.js
18937
- var harnessAccountSnapshotSchema = external_exports.object({
18999
+ var accountBalanceSnapshotSchema = external_exports.object({
19000
+ amount: external_exports.number().finite().nonnegative(),
19001
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
19002
+ currency: external_exports.string().trim().min(1).max(8),
19003
+ /** Native label when the Harness exposes several Billing Sources. */
19004
+ label: external_exports.string().trim().min(1).max(128).optional()
19005
+ }).strict();
19006
+ var harnessAccountSnapshotObject = external_exports.object({
18938
19007
  email: external_exports.string().trim().min(1).max(320).optional(),
18939
19008
  label: external_exports.string().trim().min(1).max(256).optional(),
18940
19009
  plan: external_exports.string().trim().min(1).max(128).optional(),
18941
- credits: accountCreditsSnapshotSchema
19010
+ credits: accountCreditsSnapshotSchema.optional(),
19011
+ balance: accountBalanceSnapshotSchema.optional()
18942
19012
  }).strict();
19013
+ function requireReportedQuota(schema) {
19014
+ return schema.refine((value) => {
19015
+ const reported = value;
19016
+ return reported.credits !== void 0 || reported.balance !== void 0;
19017
+ }, { message: "Account must report either credits or a balance" });
19018
+ }
19019
+ var harnessAccountSnapshotSchema = requireReportedQuota(harnessAccountSnapshotObject);
18943
19020
  var harnessAccountIdentityShape = {
18944
19021
  harnessId: harnessIdSchema,
18945
19022
  harnessName: external_exports.string().trim().min(1).max(128)
@@ -18950,11 +19027,13 @@ var harnessAccountSourceListResultSchema = external_exports.object({ sources: ex
18950
19027
  var harnessAccountInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema, refresh: external_exports.boolean().optional() }).strict();
18951
19028
  var harnessAccountInspectResultSchema = external_exports.object({
18952
19029
  ...harnessAccountIdentityShape,
18953
- account: harnessAccountSnapshotSchema.nullable()
19030
+ account: harnessAccountSnapshotSchema.nullable(),
19031
+ /** Every Billing Source from one Harness; `account` remains the first for older clients. */
19032
+ accounts: external_exports.array(harnessAccountSnapshotSchema).max(8).optional()
18954
19033
  }).strict();
18955
19034
  var harnessAccountListParamsSchema = external_exports.object({ refresh: external_exports.boolean().optional() }).strict();
18956
19035
  var harnessAccountListResultSchema = external_exports.object({
18957
- accounts: external_exports.array(harnessAccountSnapshotSchema.extend(harnessAccountIdentityShape)).max(128)
19036
+ accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
18958
19037
  }).strict();
18959
19038
 
18960
19039
  // ../../shared-contracts/dist/json-value.js
@@ -19092,6 +19171,8 @@ var harnessModelSchema = external_exports.object({
19092
19171
  ref: harnessModelRefSchema,
19093
19172
  label: nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH),
19094
19173
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19174
+ /** Optional opaque selection for this same Model with priority processing enabled. */
19175
+ fastModel: harnessModelRefSchema.optional(),
19095
19176
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
19096
19177
  }).strict();
19097
19178
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
@@ -19124,6 +19205,16 @@ var harnessModelCatalogSchema = external_exports.object({
19124
19205
  });
19125
19206
  }
19126
19207
  refs.add(model.ref.id);
19208
+ if (model.fastModel) {
19209
+ if (refs.has(model.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model.fastModel?.id)) {
19210
+ context.addIssue({
19211
+ code: "custom",
19212
+ message: "Fast Model refs must be distinct and unique",
19213
+ path: ["models", index, "fastModel"]
19214
+ });
19215
+ }
19216
+ refs.add(model.fastModel.id);
19217
+ }
19127
19218
  const supportedThinkingIds = /* @__PURE__ */ new Set();
19128
19219
  for (const [optionIndex, optionId] of (model.supportedThinkingOptionIds ?? []).entries()) {
19129
19220
  if (supportedThinkingIds.has(optionId)) {
@@ -19246,11 +19337,13 @@ var threadThinkingSelectParamsSchema = external_exports.object({
19246
19337
  thinkingOptionId: harnessThinkingOptionIdSchema
19247
19338
  }).strict();
19248
19339
  var threadInspectionParamsSchema = external_exports.object({
19249
- threadId: hostThreadIdSchema
19340
+ threadId: hostThreadIdSchema,
19341
+ includeReferenceCapability: external_exports.boolean().optional()
19250
19342
  }).strict();
19251
19343
  var codexThreadInspectionSchema = external_exports.object({
19252
19344
  owner: external_exports.literal("codex"),
19253
- locked: external_exports.literal(true)
19345
+ locked: external_exports.literal(true),
19346
+ supportsThreadReferences: external_exports.literal(true).optional()
19254
19347
  }).strict();
19255
19348
  var externalThreadInspectionSchema = external_exports.object({
19256
19349
  owner: external_exports.literal("external"),
@@ -19378,10 +19471,31 @@ var harnessLaunchSettingsSchema = external_exports.object({
19378
19471
  restartRequired: external_exports.boolean()
19379
19472
  }).strict();
19380
19473
 
19474
+ // ../../shared-contracts/dist/harness-installation.js
19475
+ var harnessInstallationParamsSchema = external_exports.object({
19476
+ harnessId: harnessIdSchema,
19477
+ action: external_exports.enum(["check", "update"])
19478
+ }).strict();
19479
+ var harnessInstallationStateSchema = external_exports.object({
19480
+ currentVersion: external_exports.string().min(1).max(128),
19481
+ latestVersion: external_exports.string().min(1).max(128),
19482
+ updateAvailable: external_exports.boolean(),
19483
+ canUpdate: external_exports.boolean(),
19484
+ message: external_exports.string().max(2048).optional()
19485
+ }).strict();
19486
+
19381
19487
  // ../../shared-contracts/dist/codex-accounts.js
19382
19488
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
19383
19489
  var nonBlankTextSchema3 = external_exports.string().trim().min(1);
19384
19490
  var codexAccountAuthKindSchema = external_exports.enum(["api", "chatgpt"]);
19491
+ var codexAccountSiteUrlPattern = /^https?:\/\/(?:\[[0-9a-fA-F:]+\]|[^/\s:@?#]+)(?::\d{1,5})?(?:[/?#][^\s]*)?$/u;
19492
+ function isCodexAccountSiteUrl(value) {
19493
+ return value.length > 0 && value.length <= 2048 && codexAccountSiteUrlPattern.test(value);
19494
+ }
19495
+ var externalUrlOpenParamsSchema = external_exports.object({
19496
+ url: external_exports.string().max(2048).refine(isCodexAccountSiteUrl, "External URL must be http(s)")
19497
+ }).strict();
19498
+ var externalUrlOpenResultSchema = external_exports.object({}).strict();
19385
19499
  var codexAccountPlanTypeSchema = external_exports.enum([
19386
19500
  "free",
19387
19501
  "go",
@@ -19407,7 +19521,8 @@ var codexAccountSchema = external_exports.object({
19407
19521
  email: external_exports.string().email().max(320).optional(),
19408
19522
  planType: codexAccountPlanTypeSchema.optional(),
19409
19523
  authKind: codexAccountAuthKindSchema.optional(),
19410
- authIdentity: nonBlankTextSchema3.max(256).optional()
19524
+ authIdentity: nonBlankTextSchema3.max(256).optional(),
19525
+ siteUrl: external_exports.string().refine(isCodexAccountSiteUrl, "Account site URL must be http(s)").optional()
19411
19526
  }).strict();
19412
19527
  var codexAccountPhaseSchema = external_exports.enum(["ready", "unavailable"]);
19413
19528
  var codexAccountListResultSchema = external_exports.object({
@@ -20003,7 +20118,7 @@ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
20003
20118
  import { spawn, spawnSync } from "node:child_process";
20004
20119
  import { readdir, readFile as readFile2 } from "node:fs/promises";
20005
20120
  import os4 from "node:os";
20006
- import path9 from "node:path";
20121
+ import path10 from "node:path";
20007
20122
  import { Readable, Writable } from "node:stream";
20008
20123
 
20009
20124
  // dist/grok-slash-commands.js
@@ -20030,8 +20145,8 @@ function parseGrokAvailableCommands(value) {
20030
20145
  });
20031
20146
  }
20032
20147
  function isGrokSkill(command) {
20033
- const path12 = command.meta?.path;
20034
- return typeof path12 === "string" && /(^|[\\/])SKILL\.md$/u.test(path12) || typeof command.meta?.qualifiedName === "string";
20148
+ const path13 = command.meta?.path;
20149
+ return typeof path13 === "string" && /(^|[\\/])SKILL\.md$/u.test(path13) || typeof command.meta?.qualifiedName === "string";
20035
20150
  }
20036
20151
  function grokLiveCommands(native) {
20037
20152
  return native.map((command) => ({
@@ -20042,7 +20157,7 @@ function grokLiveCommands(native) {
20042
20157
  }
20043
20158
 
20044
20159
  // dist/command.js
20045
- import path4 from "node:path";
20160
+ import path5 from "node:path";
20046
20161
 
20047
20162
  // ../../harness-discovery/dist/environment.js
20048
20163
  import fs from "node:fs";
@@ -20106,6 +20221,20 @@ function commandInvocation(command, arguments_, environment, platform = process.
20106
20221
  };
20107
20222
  }
20108
20223
 
20224
+ // ../../harness-discovery/dist/node-runtime.js
20225
+ import path4 from "node:path";
20226
+ function withNodeRuntimeOnPath(environment, runtimeExecutable = process.execPath, platform = process.platform) {
20227
+ const pathKey = Object.keys(environment).find((name) => name.toLowerCase() === "path") ?? "PATH";
20228
+ const delimiter = platform === "win32" ? ";" : ":";
20229
+ const runtimeDirectory = path4.dirname(runtimeExecutable);
20230
+ const directories = (environment[pathKey] ?? "").split(delimiter).filter(Boolean);
20231
+ const equal = platform === "win32" ? (value) => value.toLowerCase() : (value) => value;
20232
+ if (!directories.some((directory) => equal(directory) === equal(runtimeDirectory))) {
20233
+ directories.push(runtimeDirectory);
20234
+ }
20235
+ return { ...environment, [pathKey]: directories.join(delimiter) };
20236
+ }
20237
+
20109
20238
  // ../../harness-discovery/dist/resolve.js
20110
20239
  import os2 from "node:os";
20111
20240
 
@@ -20269,6 +20398,65 @@ function resolveHarnessExecutable(spec, input, dependencies = {}) {
20269
20398
  return void 0;
20270
20399
  }
20271
20400
 
20401
+ // ../../harness-discovery/dist/installation.js
20402
+ import { execFile } from "node:child_process";
20403
+ import { homedir } from "node:os";
20404
+ function runInstallationCommand(command, args, environment, timeout = 3e4) {
20405
+ const env = withNodeRuntimeOnPath(environment);
20406
+ const invocation = /\.[cm]?js$/i.test(command) ? commandInvocation(process.execPath, [command, ...args], env) : commandInvocation(command, args, env);
20407
+ return new Promise((resolve, reject) => {
20408
+ const child = execFile(invocation.command, invocation.arguments, {
20409
+ env,
20410
+ cwd: env.HOME ?? env.USERPROFILE ?? homedir(),
20411
+ encoding: "utf8",
20412
+ timeout,
20413
+ killSignal: "SIGKILL",
20414
+ maxBuffer: 1024 * 1024,
20415
+ windowsHide: true,
20416
+ windowsVerbatimArguments: invocation.windowsVerbatimArguments
20417
+ }, (error53, stdout, stderr) => {
20418
+ if (error53)
20419
+ reject(new Error(error53.killed ? "Harness command timed out" : "Harness command failed; check the native installation and retry"));
20420
+ else
20421
+ resolve((stdout || stderr).trim());
20422
+ });
20423
+ child.stdin?.end();
20424
+ });
20425
+ }
20426
+ function installationVersion(value) {
20427
+ if (typeof value !== "string" || !/^v?\d+(?:\.\d+){1,3}(?:-[\w.-]+)?(?:\+[\w.-]+)?$/.test(value.trim()))
20428
+ throw new Error("Harness returned an invalid version");
20429
+ return value.trim().replace(/^v/, "");
20430
+ }
20431
+ function createInstallationManager(options) {
20432
+ let checking;
20433
+ let updating;
20434
+ const check2 = () => checking ??= options.check().finally(() => {
20435
+ checking = void 0;
20436
+ });
20437
+ return (action) => {
20438
+ if (updating)
20439
+ return updating;
20440
+ if (action === "check")
20441
+ return check2();
20442
+ updating = (async () => {
20443
+ const before = await check2();
20444
+ if (!before.updateAvailable)
20445
+ return before;
20446
+ if (!before.canUpdate)
20447
+ throw new Error(before.message ?? "This installation cannot be updated automatically");
20448
+ await options.update(before);
20449
+ const after = await check2();
20450
+ if (after.currentVersion === before.currentVersion)
20451
+ throw new Error("The Harness version did not change; check the native updater and retry");
20452
+ return after;
20453
+ })().finally(() => {
20454
+ updating = void 0;
20455
+ });
20456
+ return updating;
20457
+ };
20458
+ }
20459
+
20272
20460
  // dist/command.js
20273
20461
  var GrokExecutableError = class extends Error {
20274
20462
  code = "GROK_NOT_FOUND";
@@ -20298,7 +20486,7 @@ function resolveGrokExecutable(input = {}) {
20298
20486
  });
20299
20487
  if (!resolution)
20300
20488
  throw new GrokExecutableError("Grok CLI is not installed");
20301
- return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path4.resolve(resolution.executable);
20489
+ return targetPath(platform).isAbsolute(resolution.executable) ? resolution.executable : path5.resolve(resolution.executable);
20302
20490
  }
20303
20491
  function grokInvocation(command, platform = process.platform, modelId) {
20304
20492
  const arguments_ = ["agent", "--no-leader"];
@@ -20311,11 +20499,11 @@ function grokInvocation(command, platform = process.platform, modelId) {
20311
20499
 
20312
20500
  // dist/grok-fork.js
20313
20501
  import { isDeepStrictEqual } from "node:util";
20314
- import path7 from "node:path";
20502
+ import path8 from "node:path";
20315
20503
 
20316
20504
  // dist/grok-file-change.js
20317
20505
  import { Buffer as Buffer2 } from "node:buffer";
20318
- import path5 from "node:path";
20506
+ import path6 from "node:path";
20319
20507
 
20320
20508
  // ../../../node_modules/diff/libesm/diff/base.js
20321
20509
  var Diff = class {
@@ -20417,16 +20605,16 @@ var Diff = class {
20417
20605
  }
20418
20606
  }
20419
20607
  }
20420
- addToPath(path12, added, removed, oldPosInc, options) {
20421
- const last = path12.lastComponent;
20608
+ addToPath(path13, added, removed, oldPosInc, options) {
20609
+ const last = path13.lastComponent;
20422
20610
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
20423
20611
  return {
20424
- oldPos: path12.oldPos + oldPosInc,
20612
+ oldPos: path13.oldPos + oldPosInc,
20425
20613
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
20426
20614
  };
20427
20615
  } else {
20428
20616
  return {
20429
- oldPos: path12.oldPos + oldPosInc,
20617
+ oldPos: path13.oldPos + oldPosInc,
20430
20618
  lastComponent: { count: 1, added, removed, previousComponent: last }
20431
20619
  };
20432
20620
  }
@@ -20739,13 +20927,13 @@ function isRecord4(value) {
20739
20927
  return typeof value === "object" && value !== null && !Array.isArray(value);
20740
20928
  }
20741
20929
  function validAbsolutePath(value) {
20742
- return typeof value === "string" && path5.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
20930
+ return typeof value === "string" && path6.isAbsolute(value) && value.trim().length > 0 && !value.includes("\0") && !value.includes("\n") && !value.includes("\r");
20743
20931
  }
20744
20932
  function displayPath(nativePath, cwd) {
20745
- const resolvedCwd = path5.resolve(cwd);
20746
- const resolvedPath = path5.resolve(nativePath);
20747
- const relative = path5.relative(resolvedCwd, resolvedPath);
20748
- const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path5.sep}`);
20933
+ const resolvedCwd = path6.resolve(cwd);
20934
+ const resolvedPath = path6.resolve(nativePath);
20935
+ const relative = path6.relative(resolvedCwd, resolvedPath);
20936
+ const inside = relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path6.sep}`);
20749
20937
  const selected = inside ? relative : resolvedPath;
20750
20938
  const normalized = selected.replaceAll("\\", "/");
20751
20939
  if (normalized.length === 0 || normalized === ".")
@@ -20808,7 +20996,7 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
20808
20996
  // dist/local-media-markdown.js
20809
20997
  import { existsSync, statSync } from "node:fs";
20810
20998
  import os3 from "node:os";
20811
- import path6 from "node:path";
20999
+ import path7 from "node:path";
20812
21000
  var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20813
21001
  ".aac",
20814
21002
  ".gif",
@@ -20827,14 +21015,14 @@ var MEDIA_EXTENSIONS = /* @__PURE__ */ new Set([
20827
21015
  ".webp"
20828
21016
  ]);
20829
21017
  function grokMediaResolveRoots(cwd, sessionDirectory) {
20830
- const roots = [path6.resolve(cwd)];
21018
+ const roots = [path7.resolve(cwd)];
20831
21019
  if (sessionDirectory) {
20832
- const session = path6.resolve(sessionDirectory);
20833
- roots.push(session, path6.join(session, "videos"), path6.join(session, "images"));
21020
+ const session = path7.resolve(sessionDirectory);
21021
+ roots.push(session, path7.join(session, "videos"), path7.join(session, "images"));
20834
21022
  }
20835
21023
  const home = process.env.HOME ?? process.env.USERPROFILE ?? os3.homedir();
20836
21024
  if (home)
20837
- roots.push(path6.join(home, "Downloads"));
21025
+ roots.push(path7.join(home, "Downloads"));
20838
21026
  return roots;
20839
21027
  }
20840
21028
  function rewriteLocalMediaMarkdown(text, roots, options = {}) {
@@ -20935,7 +21123,7 @@ function parseInlineCode(text, start) {
20935
21123
  return { closed: false, content: text.slice(start + 1), end: text.length };
20936
21124
  }
20937
21125
  function mediaMarkdownImage(absolutePath) {
20938
- const name = path6.basename(absolutePath).replaceAll("]", "\\]");
21126
+ const name = path7.basename(absolutePath).replaceAll("]", "\\]");
20939
21127
  return `![${name}](${formatMarkdownDestination(absolutePath, false)})`;
20940
21128
  }
20941
21129
  function parseMarkdownImage(text, start) {
@@ -21060,11 +21248,11 @@ function resolveLocalMediaPath(raw, roots, exists = mediaFileExists) {
21060
21248
  if (!hasMediaExtension(stripped))
21061
21249
  return null;
21062
21250
  if (isAbsoluteMediaPath(stripped)) {
21063
- const absolute = path6.resolve(stripped);
21251
+ const absolute = path7.resolve(stripped);
21064
21252
  return exists(absolute) ? absolute : null;
21065
21253
  }
21066
21254
  for (const root of roots) {
21067
- const absolute = path6.resolve(root, stripped);
21255
+ const absolute = path7.resolve(root, stripped);
21068
21256
  if (exists(absolute))
21069
21257
  return absolute;
21070
21258
  }
@@ -21086,11 +21274,11 @@ function stripFileUrl(value) {
21086
21274
  }
21087
21275
  }
21088
21276
  function isAbsoluteMediaPath(value) {
21089
- return path6.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
21277
+ return path7.isAbsolute(value) || /^[a-zA-Z]:[\\/]/.test(value);
21090
21278
  }
21091
21279
  function hasMediaExtension(value) {
21092
21280
  const pathname = value.split(/[?#]/, 1)[0] ?? value;
21093
- return MEDIA_EXTENSIONS.has(path6.extname(pathname).toLowerCase());
21281
+ return MEDIA_EXTENSIONS.has(path7.extname(pathname).toLowerCase());
21094
21282
  }
21095
21283
  function mediaFileExists(absolutePath) {
21096
21284
  try {
@@ -22099,11 +22287,11 @@ function parseGrokForkResponse(value) {
22099
22287
  }
22100
22288
  function projectRelativePath(value, cwds) {
22101
22289
  const normalized = value.replaceAll("\\", "/");
22102
- if (!path7.isAbsolute(value))
22290
+ if (!path8.isAbsolute(value))
22103
22291
  return normalized;
22104
22292
  for (const cwd of cwds) {
22105
- const relative = path7.relative(path7.resolve(cwd), path7.resolve(value));
22106
- if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path7.sep}`)) {
22293
+ const relative = path8.relative(path8.resolve(cwd), path8.resolve(value));
22294
+ if (relative.length > 0 && relative !== ".." && !relative.startsWith(`..${path8.sep}`)) {
22107
22295
  return relative.replaceAll("\\", "/");
22108
22296
  }
22109
22297
  }
@@ -22168,8 +22356,8 @@ async function forkGrokSession(input) {
22168
22356
  error: error51("sessionNotFound", "Grok Native Session is unavailable")
22169
22357
  };
22170
22358
  }
22171
- const sourceCwd = path7.resolve(located.cwd);
22172
- const targetCwd = path7.resolve(input.cwd);
22359
+ const sourceCwd = path8.resolve(located.cwd);
22360
+ const targetCwd = path8.resolve(input.cwd);
22173
22361
  const source = await readSnapshot({ ...input, cwd: sourceCwd }, sourceRef.data.nativeSessionId);
22174
22362
  if (!source.ok)
22175
22363
  return source;
@@ -22351,7 +22539,7 @@ function parseGrokCompactResult(value, cancelled = false) {
22351
22539
  }
22352
22540
 
22353
22541
  // dist/grok-rewind.js
22354
- import path8 from "node:path";
22542
+ import path9 from "node:path";
22355
22543
  var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
22356
22544
  function error52(code, message, retryable = false) {
22357
22545
  return { code, message, retryable };
@@ -22424,8 +22612,8 @@ async function rewindGrokLastTurn(input) {
22424
22612
  error: error52("sessionNotFound", "Grok Native Session is unavailable")
22425
22613
  };
22426
22614
  }
22427
- const sourceCwd = path8.resolve(located.cwd);
22428
- const targetCwd = path8.resolve(input.cwd);
22615
+ const sourceCwd = path9.resolve(located.cwd);
22616
+ const targetCwd = path9.resolve(input.cwd);
22429
22617
  if (sourceCwd !== targetCwd) {
22430
22618
  return {
22431
22619
  ok: false,
@@ -22906,13 +23094,13 @@ function transportEvent(update, metadata) {
22906
23094
  function grokHomeDir(options) {
22907
23095
  const environment = { ...process.env, ...options.environment };
22908
23096
  const home = environment.HOME ?? environment.USERPROFILE ?? os4.homedir();
22909
- return environment.GROK_HOME ?? path9.join(home, ".grok");
23097
+ return environment.GROK_HOME ?? path10.join(home, ".grok");
22910
23098
  }
22911
23099
  function grokNativeSessionDirectory(options, sessionId) {
22912
- return path9.join(grokHomeDir(options), "sessions", encodeURIComponent(path9.resolve(options.cwd)), sessionId);
23100
+ return path10.join(grokHomeDir(options), "sessions", encodeURIComponent(path10.resolve(options.cwd)), sessionId);
22913
23101
  }
22914
23102
  function nativeSessionFile(options, sessionId, fileName) {
22915
- return path9.join(grokNativeSessionDirectory(options, sessionId), fileName);
23103
+ return path10.join(grokNativeSessionDirectory(options, sessionId), fileName);
22916
23104
  }
22917
23105
  function nativeHistoryPath(options, sessionId) {
22918
23106
  return nativeSessionFile(options, sessionId, "updates.jsonl");
@@ -22932,7 +23120,7 @@ async function locateGrokNativeSession(options, sessionId) {
22932
23120
  return null;
22933
23121
  let entries;
22934
23122
  try {
22935
- entries = await readdir(path9.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
23123
+ entries = await readdir(path10.join(grokHomeDir(options), "sessions"), { withFileTypes: true });
22936
23124
  } catch (error53) {
22937
23125
  if (isMissingFile(error53))
22938
23126
  return null;
@@ -22946,7 +23134,7 @@ async function locateGrokNativeSession(options, sessionId) {
22946
23134
  continue;
22947
23135
  let summaryRaw;
22948
23136
  try {
22949
- summaryRaw = await readFile2(path9.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
23137
+ summaryRaw = await readFile2(path10.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
22950
23138
  } catch (error53) {
22951
23139
  if (isMissingFile(error53) || isRecord13(error53) && error53.code === "ENOTDIR")
22952
23140
  continue;
@@ -22963,8 +23151,8 @@ async function locateGrokNativeSession(options, sessionId) {
22963
23151
  if (!isRecord13(parsed))
22964
23152
  continue;
22965
23153
  const info = parsed.info;
22966
- const cwd = isRecord13(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path9.resolve(info.cwd) : path9.resolve(decodeURIComponent(entry.name));
22967
- const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path9.resolve(parsed.source_workspace_dir) : void 0;
23154
+ const cwd = isRecord13(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path10.resolve(info.cwd) : path10.resolve(decodeURIComponent(entry.name));
23155
+ const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path10.resolve(parsed.source_workspace_dir) : void 0;
22968
23156
  matches.push({
22969
23157
  cwd,
22970
23158
  ...sourceWorkspaceDir ? { sourceWorkspaceDir } : {}
@@ -22974,7 +23162,7 @@ async function locateGrokNativeSession(options, sessionId) {
22974
23162
  }
22975
23163
  async function readGrokNativeHistory(options, sessionId) {
22976
23164
  try {
22977
- return parseNativeHistory(await readFile2(nativeHistoryPath({ ...options, cwd: path9.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
23165
+ return parseNativeHistory(await readFile2(nativeHistoryPath({ ...options, cwd: path10.resolve(options.cwd) }, sessionId), "utf8"), sessionId);
22978
23166
  } catch (error53) {
22979
23167
  if (isMissingFile(error53))
22980
23168
  return [];
@@ -23693,7 +23881,7 @@ function stateForGrokModel(modelState, nativeState, model = modelState.currentMo
23693
23881
  // dist/grok-credits.js
23694
23882
  import { readFile as readFile3 } from "node:fs/promises";
23695
23883
  import os5 from "node:os";
23696
- import path10 from "node:path";
23884
+ import path11 from "node:path";
23697
23885
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
23698
23886
  var REQUEST_TIMEOUT_MS = 15e3;
23699
23887
  function isRecord15(value) {
@@ -23713,7 +23901,7 @@ function nonNegativeCentValue(value) {
23713
23901
  return amount;
23714
23902
  }
23715
23903
  function grokHome(environment) {
23716
- return environment.GROK_HOME ?? path10.join(environment.HOME ?? environment.USERPROFILE ?? os5.homedir(), ".grok");
23904
+ return environment.GROK_HOME ?? path11.join(environment.HOME ?? environment.USERPROFILE ?? os5.homedir(), ".grok");
23717
23905
  }
23718
23906
  function periodTypeFrom(value) {
23719
23907
  if (typeof value !== "string")
@@ -23792,7 +23980,7 @@ async function fetchGrokAccount(input = {}) {
23792
23980
  if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((value) => value?.trim()))
23793
23981
  return null;
23794
23982
  const now = input.now ?? /* @__PURE__ */ new Date();
23795
- const authPath = path10.join(grokHome(environment), "auth.json");
23983
+ const authPath = path11.join(grokHome(environment), "auth.json");
23796
23984
  const raw = input.readAuthFile ? await input.readAuthFile(authPath) : await readFile3(authPath, "utf8");
23797
23985
  const token = selectAccessToken(JSON.parse(raw), now);
23798
23986
  if (!token)
@@ -23828,8 +24016,8 @@ async function fetchGrokAccount(input = {}) {
23828
24016
  }
23829
24017
  async function fetchGrokCredits(input = {}) {
23830
24018
  const account = await fetchGrokAccount(input);
23831
- const usedPercent = account?.credits.usedPercent;
23832
- if (!account || usedPercent === void 0)
24019
+ const usedPercent = account?.credits?.usedPercent;
24020
+ if (!account?.credits || usedPercent === void 0)
23833
24021
  return null;
23834
24022
  const { credits } = account;
23835
24023
  return {
@@ -25189,7 +25377,7 @@ var GrokAdapter = class {
25189
25377
  async inspect(input = {}) {
25190
25378
  if (this.#closePromise)
25191
25379
  return { status: "unavailable", error: invalidState("Grok Adapter is closed") };
25192
- const cwd = path11.resolve(input.cwd ?? process.cwd());
25380
+ const cwd = path12.resolve(input.cwd ?? process.cwd());
25193
25381
  if (!input.refresh) {
25194
25382
  const cached2 = this.#inspectionCache.get(cwd);
25195
25383
  if (cached2)
@@ -25251,7 +25439,7 @@ var GrokAdapter = class {
25251
25439
  }
25252
25440
  };
25253
25441
  }
25254
- const cwd = path11.resolve(input.cwd);
25442
+ const cwd = path12.resolve(input.cwd);
25255
25443
  const parsedRef = input.kind === "resume" ? nativeSessionRefSchema.safeParse(input.nativeRef) : null;
25256
25444
  if (parsedRef && (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId)) {
25257
25445
  return {
@@ -25435,14 +25623,46 @@ var GrokAdapter = class {
25435
25623
  }
25436
25624
  };
25437
25625
 
25626
+ // dist/installation.js
25627
+ var GROK_NPM_PACKAGE = "@xai-official/grok";
25628
+ function createGrokInstallation(environment, command) {
25629
+ const run = (args, timeout, extra) => runInstallationCommand(resolveGrokExecutable({ environment, ...command ? { command } : {} }), args, extra ? { ...environment, ...extra } : environment, timeout);
25630
+ let installer = "";
25631
+ return createInstallationManager({
25632
+ async check() {
25633
+ const state = JSON.parse(await run(["update", "--check", "--json"]));
25634
+ if (state.error || typeof state.updateAvailable !== "boolean")
25635
+ throw new Error("Grok update check failed");
25636
+ installer = typeof state.installer === "string" ? state.installer : "";
25637
+ return {
25638
+ currentVersion: installationVersion(state.currentVersion),
25639
+ latestVersion: installationVersion(state.latestVersion),
25640
+ updateAvailable: state.updateAvailable,
25641
+ canUpdate: true
25642
+ };
25643
+ },
25644
+ async update() {
25645
+ if (installer !== "npm") {
25646
+ await run(["update"], 3e5);
25647
+ return;
25648
+ }
25649
+ const existing = environment.npm_config_allow_scripts?.trim();
25650
+ const allowed = existing ? `${existing},${GROK_NPM_PACKAGE}` : GROK_NPM_PACKAGE;
25651
+ await run(["update", "--force-reinstall"], 3e5, {
25652
+ npm_config_allow_scripts: allowed
25653
+ });
25654
+ }
25655
+ });
25656
+ }
25657
+
25438
25658
  // dist/plugin.js
25439
25659
  var GROK_COMMAND_ENV = "CODEXHOST_GROK_COMMAND";
25440
25660
  function createHarnessAdapter(context) {
25441
25661
  const environment = { ...context.environment };
25442
- return new GrokAdapter({
25662
+ return Object.assign(new GrokAdapter({
25443
25663
  ...environment[GROK_COMMAND_ENV] ? { command: environment[GROK_COMMAND_ENV] } : {},
25444
25664
  environment
25445
- });
25665
+ }), { installation: createGrokInstallation(environment, environment[GROK_COMMAND_ENV]) });
25446
25666
  }
25447
25667
  export {
25448
25668
  GROK_COMMAND_ENV,