@liberseek/boft-cli-win32-arm64 0.8.2 → 0.8.4

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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +58 -5
  4. package/app/console-web.js +436 -67
  5. package/app/desktop-controller.mjs +72 -9
  6. package/app/host-runtime.mjs +772 -218
  7. package/app/plugins/antigravity/plugin.mjs +91 -13
  8. package/app/plugins/claude-code/plugin.mjs +404 -26
  9. package/app/plugins/codebuddy/plugin.mjs +117 -22
  10. package/app/plugins/codex-usage/plugin.mjs +176 -74
  11. package/app/plugins/copilot/assets/icon.png +0 -0
  12. package/app/plugins/copilot/manifest.json +26 -0
  13. package/app/plugins/copilot/plugin.mjs +34601 -0
  14. package/app/plugins/cursor-cli/plugin.mjs +20794 -44912
  15. package/app/plugins/deepseek-harness/plugin.mjs +83 -11
  16. package/app/plugins/enabled.json +1 -0
  17. package/app/plugins/grok/plugin.mjs +250 -40
  18. package/app/plugins/hermes/plugin.mjs +80 -9
  19. package/app/plugins/kimi-code/plugin.mjs +76 -7
  20. package/app/plugins/kiro-cli/plugin.mjs +76 -7
  21. package/app/plugins/muse/plugin.mjs +73 -5
  22. package/app/plugins/omp/plugin.mjs +2155 -2000
  23. package/app/plugins/opencode/plugin.mjs +85 -11
  24. package/app/plugins/pi/plugin.mjs +2515 -2298
  25. package/app/plugins/qoder/plugin.mjs +83 -11
  26. package/app/plugins/qoder-cn/plugin.mjs +83 -11
  27. package/app/plugins/workbuddy/plugin.mjs +378 -46
  28. package/app/plugins/zcode/plugin.mjs +84 -11
  29. package/app/renderer-extension.js +833 -162
  30. package/bin/boft.exe +0 -0
  31. package/libexec/boft-node-repl.exe +0 -0
  32. package/libexec/boft-shim.exe +0 -0
  33. package/libexec/boft-updater.exe +0 -0
  34. package/package.json +1 -1
@@ -393,10 +393,13 @@ function usageSessionTitle(value) {
393
393
  return void 0;
394
394
  if (normalized.length <= MAX_SESSION_TITLE_LENGTH)
395
395
  return normalized;
396
- const characters = [...normalized];
397
- if (characters.length <= MAX_SESSION_TITLE_LENGTH)
398
- return normalized;
399
- return `${characters.slice(0, MAX_SESSION_TITLE_LENGTH - 1).join("").trimEnd()}…`;
396
+ let title = "";
397
+ for (const character of normalized) {
398
+ if (title.length + character.length >= MAX_SESSION_TITLE_LENGTH)
399
+ break;
400
+ title += character;
401
+ }
402
+ return `${title.trimEnd()}…`;
400
403
  }
401
404
  function sessionIdOk(value) {
402
405
  return typeof value === "string" && value.length > 0 && value.length <= MAX_SESSION_ID_LENGTH;
@@ -19414,10 +19417,19 @@ var model = external_exports.string().min(1).max(512);
19414
19417
  var project = external_exports.string().min(1).max(4096);
19415
19418
  var usageStatisticsParamsSchema = external_exports.strictObject({
19416
19419
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
19420
+ /** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
19421
+ timeZone: external_exports.string().min(1).max(128).refine((value) => {
19422
+ try {
19423
+ new Intl.DateTimeFormat("en", { timeZone: value });
19424
+ return true;
19425
+ } catch {
19426
+ return false;
19427
+ }
19428
+ }, "Unsupported usage statistics timezone").optional(),
19417
19429
  harness: harness.optional(),
19418
19430
  model: model.nullable().optional(),
19419
19431
  project: project.nullable().optional(),
19420
- /** One local date inside the range. */
19432
+ /** One date in the query timezone inside the range. */
19421
19433
  date: localDate.optional()
19422
19434
  });
19423
19435
  var usageStatisticsTotalsSchema = external_exports.strictObject({
@@ -19453,7 +19465,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
19453
19465
  });
19454
19466
  var usageStatisticsResultSchema = external_exports.strictObject({
19455
19467
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
19456
- /** First local date of the range; null for all time. */
19468
+ /** First date in the query timezone (Host local when omitted); null for all time. */
19457
19469
  from: localDate.nullable(),
19458
19470
  to: localDate,
19459
19471
  /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
@@ -19493,7 +19505,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
19493
19505
  totals: usageStatisticsTotalsSchema,
19494
19506
  /** Each date and Harness of the range: every filter except the day. */
19495
19507
  daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
19496
- /** Local weekday (0 = Sunday) and hour, all filters applied. */
19508
+ /** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
19497
19509
  hourly: external_exports.array(external_exports.strictObject({
19498
19510
  weekday: external_exports.number().int().min(0).max(6),
19499
19511
  hour: external_exports.number().int().min(0).max(23),
@@ -19635,6 +19647,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
19635
19647
  "codexhost/harness/display-settings/set",
19636
19648
  "codexhost/harness/inspect",
19637
19649
  "codexhost/harness/installation",
19650
+ "codexhost/harness/installation/start",
19651
+ "codexhost/harness/installation/status",
19638
19652
  "codexhost/harness/launch-settings/get",
19639
19653
  "codexhost/harness/launch-settings/set",
19640
19654
  HARNESS_LONG_CONTEXT_GET_METHOD,
@@ -19712,7 +19726,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
19712
19726
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
19713
19727
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
19714
19728
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
19729
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
19730
+ var composerIndicatorsSchema = external_exports.array(external_exports.object({
19731
+ kind: external_exports.literal("countdown"),
19732
+ id: external_exports.string().min(1).max(64),
19733
+ expiresAtUnix: nonNegativeSafeIntegerSchema,
19734
+ label: indicatorTextSchema(256).optional(),
19735
+ tooltip: indicatorTextSchema(1024).optional()
19736
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
19737
+ message: "Composer indicator IDs must be unique"
19738
+ });
19715
19739
  var threadUsageSnapshotSchema = external_exports.object({
19740
+ composerIndicators: composerIndicatorsSchema.optional(),
19716
19741
  inputTokens: nonNegativeSafeIntegerSchema.optional(),
19717
19742
  cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
19718
19743
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -20138,7 +20163,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
20138
20163
  }).strict().optional(),
20139
20164
  input: external_exports.object({
20140
20165
  image: external_exports.boolean()
20141
- }).strict().optional()
20166
+ }).strict().optional(),
20167
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
20168
+ steer: external_exports.boolean().optional()
20142
20169
  }).strict();
20143
20170
  var harnessConfigurationStateSchema = external_exports.object({
20144
20171
  effectiveModel: harnessModelRefSchema.optional(),
@@ -20185,7 +20212,9 @@ var harnessInspectionSchema = external_exports.union([
20185
20212
  var harnessInspectParamsSchema = external_exports.object({
20186
20213
  harnessId: harnessIdSchema,
20187
20214
  cwd: nonBlankTextSchema2.max(16384).optional(),
20188
- refresh: external_exports.boolean().optional()
20215
+ refresh: external_exports.boolean().optional(),
20216
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
20217
+ purpose: external_exports.literal("availability").optional()
20189
20218
  }).strict();
20190
20219
  var harnessWebUiOpenParamsSchema = external_exports.object({
20191
20220
  harnessId: harnessIdSchema
@@ -20270,6 +20299,15 @@ var threadOwnershipListResultSchema = external_exports.object({
20270
20299
  seen.add(thread.threadId);
20271
20300
  }
20272
20301
  });
20302
+ var threadSteeringInspectParamsSchema = external_exports.object({
20303
+ threadId: hostThreadIdSchema,
20304
+ /** The text about to be steered; a Harness command always stops and restarts. */
20305
+ text: external_exports.string().optional()
20306
+ }).strict();
20307
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
20308
+ var threadSteeringInspectResultSchema = external_exports.object({
20309
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
20310
+ }).strict();
20273
20311
 
20274
20312
  // ../../shared-contracts/dist/harness-route.js
20275
20313
  var harnessPluginRouteSchema = external_exports.object({
@@ -20302,6 +20340,10 @@ var harnessInstallationStateSchema = external_exports.object({
20302
20340
  latestVersion: external_exports.string().min(1).max(128),
20303
20341
  updateAvailable: external_exports.boolean(),
20304
20342
  canUpdate: external_exports.boolean(),
20343
+ /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
20344
+ versionKind: external_exports.enum(["cli", "application"]).optional(),
20345
+ /** Official download opened by the user; does not imply an automatic installation. */
20346
+ manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
20305
20347
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
20306
20348
  message: external_exports.string().max(2048).optional(),
20307
20349
  messageCode: external_exports.string().min(1).max(128).optional(),
@@ -20309,6 +20351,20 @@ var harnessInstallationStateSchema = external_exports.object({
20309
20351
  notice: harnessLocalizedTextSchema.optional(),
20310
20352
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
20311
20353
  }).strict();
20354
+ var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
20355
+ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
20356
+ external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
20357
+ external_exports.object({
20358
+ taskId: external_exports.string().uuid(),
20359
+ status: external_exports.literal("succeeded"),
20360
+ result: harnessInstallationStateSchema
20361
+ }).strict(),
20362
+ external_exports.object({
20363
+ taskId: external_exports.string().uuid(),
20364
+ status: external_exports.literal("failed"),
20365
+ error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
20366
+ }).strict()
20367
+ ]);
20312
20368
 
20313
20369
  // ../../shared-contracts/dist/codex-accounts.js
20314
20370
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
@@ -20806,6 +20862,18 @@ function sanitizeDiagnosticTail(value) {
20806
20862
  return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
20807
20863
  }
20808
20864
 
20865
+ // ../../harness-adapter/dist/steer.js
20866
+ function unsupportedSteer(harnessLabel) {
20867
+ return {
20868
+ ok: false,
20869
+ error: {
20870
+ code: "unsupported",
20871
+ message: `${harnessLabel} cannot steer an active Turn natively`,
20872
+ retryable: false
20873
+ }
20874
+ };
20875
+ }
20876
+
20809
20877
  // ../../harness-adapter/dist/usage.js
20810
20878
  var tokenFields = [
20811
20879
  "inputTokens",
@@ -20833,6 +20901,7 @@ var usageFields = /* @__PURE__ */ new Set([
20833
20901
  ...safeIntegerFields,
20834
20902
  ...percentFields,
20835
20903
  "sessionCacheUsage",
20904
+ "composerIndicators",
20836
20905
  "totalCostUsd",
20837
20906
  "totalCredits",
20838
20907
  "contextUsagePercent",
@@ -20855,6 +20924,7 @@ function parseHostUsage(value) {
20855
20924
  throw new Error(`Harness Usage contains unknown field '${key}'`);
20856
20925
  }
20857
20926
  }
20927
+ const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
20858
20928
  for (const field of [
20859
20929
  "totalCredits",
20860
20930
  "contextUsagePercent",
@@ -20931,9 +21001,9 @@ function parseHostUsage(value) {
20931
21001
  if (value.costSource !== "publicPrice") {
20932
21002
  throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
20933
21003
  }
20934
- return { ...value, unpricedModels: [...models] };
21004
+ return { ...value, ...indicators, unpricedModels: [...models] };
20935
21005
  }
20936
- return { ...value };
21006
+ return { ...value, ...indicators };
20937
21007
  }
20938
21008
  var requestTokenFields = [
20939
21009
  "inputTokens",
@@ -21147,9 +21217,8 @@ function resolveGrokExecutable(input = {}) {
21147
21217
  }
21148
21218
  function grokInvocation(command, platform = process.platform, modelId) {
21149
21219
  const arguments_ = ["agent", "--no-leader"];
21150
- const trimmed = modelId?.trim();
21151
- if (trimmed)
21152
- arguments_.push("--model", trimmed);
21220
+ if (modelId?.trim())
21221
+ arguments_.push("--model", modelId);
21153
21222
  arguments_.push("stdio");
21154
21223
  return commandInvocation(command, arguments_, process.env, platform);
21155
21224
  }
@@ -23607,6 +23676,53 @@ function grokPermissionModeSessionMeta(permissionMode) {
23607
23676
  };
23608
23677
  }
23609
23678
 
23679
+ // dist/permission-confirmation.js
23680
+ import { stripVTControlCharacters } from "node:util";
23681
+ var GROK_PERMISSION_MODE_METHOD = "_x.ai/yolo_mode_changed";
23682
+ var permissionManagerLog = "xai_grok_workspace::permission::manager=info";
23683
+ function grokPermissionLogFilter(existing) {
23684
+ return existing ? `${existing},${permissionManagerLog}` : permissionManagerLog;
23685
+ }
23686
+ var GrokPermissionConfirmation = class {
23687
+ #expected;
23688
+ #completion = Promise.withResolvers();
23689
+ #yolo;
23690
+ #auto;
23691
+ #buffer = "";
23692
+ constructor(mode) {
23693
+ this.#expected = grokPermissionModeSessionMeta(mode);
23694
+ }
23695
+ get completed() {
23696
+ return this.#completion.promise;
23697
+ }
23698
+ accept(chunk) {
23699
+ this.#buffer += chunk;
23700
+ let newline2;
23701
+ while ((newline2 = this.#buffer.indexOf("\n")) !== -1) {
23702
+ const line = stripVTControlCharacters(this.#buffer.slice(0, newline2)).trimEnd();
23703
+ this.#buffer = this.#buffer.slice(newline2 + 1);
23704
+ const match = /^\d{4}-\d{2}-\d{2}T\S+\s+INFO\s+(?:.*?: )?(always-approve|auto permission mode) set to: (true|false)$/.exec(line);
23705
+ if (!match)
23706
+ continue;
23707
+ const value = match[2] === "true";
23708
+ if (match[1] === "always-approve")
23709
+ this.#yolo = value;
23710
+ else
23711
+ this.#auto = value;
23712
+ if (this.#yolo !== void 0 && this.#yolo !== this.#expected.yoloMode || this.#auto !== void 0 && this.#auto !== this.#expected.autoMode) {
23713
+ this.reject(new Error("Grok did not apply the requested Permission Mode"));
23714
+ } else if (this.#yolo !== void 0 && this.#auto !== void 0) {
23715
+ this.#completion.resolve(void 0);
23716
+ }
23717
+ }
23718
+ if (this.#buffer.length > 16384)
23719
+ this.#buffer = "";
23720
+ }
23721
+ reject(error53) {
23722
+ this.#completion.reject(error53);
23723
+ }
23724
+ };
23725
+
23610
23726
  // dist/acp-transport.js
23611
23727
  var GrokTransportError = class extends Error {
23612
23728
  kind;
@@ -23883,6 +23999,8 @@ var GrokAcpTransport = class {
23883
23999
  #child = null;
23884
24000
  #closed = false;
23885
24001
  #closing = false;
24002
+ #closePromise = null;
24003
+ #permissionConfirmation = null;
23886
24004
  #connection = null;
23887
24005
  #initialize = null;
23888
24006
  #replay = null;
@@ -24082,7 +24200,11 @@ var GrokAcpTransport = class {
24082
24200
  const invocation = grokInvocation(executable, process.platform, this.#startupModelId);
24083
24201
  const child = spawn(invocation.command, invocation.arguments, {
24084
24202
  cwd: this.#options.cwd,
24085
- env: { ...process.env, ...this.#options.environment },
24203
+ env: {
24204
+ ...process.env,
24205
+ ...this.#options.environment,
24206
+ RUST_LOG: grokPermissionLogFilter(this.#options.environment?.RUST_LOG ?? process.env.RUST_LOG)
24207
+ },
24086
24208
  detached: process.platform !== "win32",
24087
24209
  stdio: ["pipe", "pipe", "pipe"],
24088
24210
  windowsHide: true,
@@ -24091,6 +24213,7 @@ var GrokAcpTransport = class {
24091
24213
  this.#child = child;
24092
24214
  child.stderr.on("data", (chunk) => {
24093
24215
  this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
24216
+ this.#permissionConfirmation?.accept(chunk.toString());
24094
24217
  });
24095
24218
  await withTimeout(new Promise((resolve, reject) => {
24096
24219
  child.once("spawn", resolve);
@@ -24128,6 +24251,8 @@ var GrokAcpTransport = class {
24128
24251
  }
24129
24252
  if (this.#activePrompt)
24130
24253
  throw new Error("Grok ACP Session already has an active Prompt");
24254
+ if (this.#permissionConfirmation)
24255
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
24131
24256
  const active = { onEvent, onPermission, onExtension };
24132
24257
  this.#activePrompt = active;
24133
24258
  try {
@@ -24146,7 +24271,7 @@ var GrokAcpTransport = class {
24146
24271
  if (!connection || !this.#sessionId || this.#closed || this.#closing) {
24147
24272
  throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
24148
24273
  }
24149
- if (this.#activePrompt || this.#activeCompact) {
24274
+ if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
24150
24275
  throw new GrokTransportError("unavailable", "Grok ACP Session already has an active operation");
24151
24276
  }
24152
24277
  const active = { onEvent, cancellationRequested: false };
@@ -24179,6 +24304,8 @@ var GrokAcpTransport = class {
24179
24304
  const connection = this.#connection;
24180
24305
  if (!connection || !this.#sessionId)
24181
24306
  throw new Error("Grok ACP Session is unavailable");
24307
+ if (this.#permissionConfirmation)
24308
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
24182
24309
  const response = await connection.request("session/set_model", {
24183
24310
  sessionId: this.#sessionId,
24184
24311
  modelId,
@@ -24202,14 +24329,57 @@ var GrokAcpTransport = class {
24202
24329
  this.#activeCompact.cancellationRequested = true;
24203
24330
  return connection.cancel({ sessionId: this.#sessionId });
24204
24331
  }
24205
- async close() {
24332
+ async setPermissionMode(permissionModeId) {
24333
+ const mode = decodeGrokPermissionModeId(permissionModeId);
24334
+ const connection = this.#connection;
24335
+ const sessionId = this.#sessionId;
24336
+ if (!connection || !sessionId || this.#closed || this.#closing) {
24337
+ throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
24338
+ }
24339
+ if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
24340
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
24341
+ }
24342
+ const confirmation = new GrokPermissionConfirmation(mode);
24343
+ this.#permissionConfirmation = confirmation;
24344
+ try {
24345
+ await withTimeout(Promise.all([
24346
+ confirmation.completed,
24347
+ (async () => {
24348
+ const flags = grokPermissionModeSessionMeta(mode);
24349
+ await connection.notify(GROK_PERMISSION_MODE_METHOD, {
24350
+ yolo_mode: flags.yoloMode,
24351
+ auto_mode: flags.autoMode,
24352
+ permission_mode: mode
24353
+ });
24354
+ const response = await connection.request("_x.ai/session/info", { sessionId });
24355
+ if (!isRecord14(response) || !isRecord14(response.result) || response.result.sessionId !== sessionId) {
24356
+ throw new Error("Grok did not confirm the target Session");
24357
+ }
24358
+ })()
24359
+ ]), this.#options.commandTimeoutMs, "Grok Permission Mode confirmation");
24360
+ if (this.#closed || this.#closing)
24361
+ throw new Error("Grok Session closed during configuration");
24362
+ } catch (cause) {
24363
+ const error53 = new GrokTransportError("protocolError", "Grok Permission Mode could not be confirmed; reopen the Session to continue", { cause });
24364
+ this.#fault(error53);
24365
+ await this.close();
24366
+ throw error53;
24367
+ } finally {
24368
+ this.#permissionConfirmation = null;
24369
+ }
24370
+ }
24371
+ close() {
24372
+ return this.#closePromise ??= this.#close();
24373
+ }
24374
+ async #close() {
24206
24375
  if (this.#closed)
24207
24376
  return;
24208
24377
  this.#closing = true;
24378
+ this.#permissionConfirmation?.reject(new Error("Grok Session closed during configuration"));
24209
24379
  const child = this.#child;
24210
24380
  const connection = this.#connection;
24211
24381
  if (connection && this.#sessionId && this.#initialize?.agentCapabilities?.sessionCapabilities?.close) {
24212
- await connection.closeSession({ sessionId: this.#sessionId }).catch(() => void 0);
24382
+ await withTimeout(connection.closeSession({ sessionId: this.#sessionId }), this.#options.closeTimeoutMs, "Grok Session close").catch(() => void 0);
24213
24383
  }
24214
24384
  if (child?.stdin.writable)
24215
24385
  child.stdin.end();
@@ -24273,6 +24443,7 @@ var GrokAcpTransport = class {
24273
24443
  throw RequestError.methodNotFound(method);
24274
24444
  }
24275
24445
  #fault(error53) {
24446
+ this.#permissionConfirmation?.reject(error53);
24276
24447
  if (this.#closing || this.#closed)
24277
24448
  return;
24278
24449
  this.#options.onFault?.(error53);
@@ -24795,6 +24966,27 @@ function isRecord16(value) {
24795
24966
  function nonBlank(value) {
24796
24967
  return typeof value === "string" && value.trim().length > 0;
24797
24968
  }
24969
+ var ENCODED_MODEL_REF_PREFIX = "grok-model~";
24970
+ function encodeGrokModelRef(modelId) {
24971
+ if (!nonBlank(modelId) || modelId.length > HARNESS_MODEL_REF_MAX_LENGTH || new RegExp("\\p{Cc}", "u").test(modelId))
24972
+ return null;
24973
+ const direct = harnessModelRefSchema.safeParse({ id: modelId });
24974
+ if (direct.success && !modelId.startsWith(ENCODED_MODEL_REF_PREFIX))
24975
+ return direct.data;
24976
+ const encoded = harnessModelRefSchema.safeParse({
24977
+ id: `${ENCODED_MODEL_REF_PREFIX}${Buffer.from(modelId, "utf8").toString("base64url")}`
24978
+ });
24979
+ return encoded.success ? encoded.data : null;
24980
+ }
24981
+ function decodeGrokModelRef(ref) {
24982
+ const { id } = harnessModelRefSchema.parse(ref);
24983
+ if (!id.startsWith(ENCODED_MODEL_REF_PREFIX))
24984
+ return id;
24985
+ const modelId = Buffer.from(id.slice(ENCODED_MODEL_REF_PREFIX.length), "base64url").toString("utf8");
24986
+ if (encodeGrokModelRef(modelId)?.id !== id)
24987
+ throw new Error("Invalid Grok Model Ref");
24988
+ return modelId;
24989
+ }
24798
24990
  function thinkingOptions(value) {
24799
24991
  if (!Array.isArray(value))
24800
24992
  return [];
@@ -24815,8 +25007,8 @@ function parseGrokModelState(value) {
24815
25007
  if (!isRecord16(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
24816
25008
  return null;
24817
25009
  }
24818
- const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
24819
- if (!currentModel.success)
25010
+ const currentModel = encodeGrokModelRef(value.currentModelId);
25011
+ if (!currentModel)
24820
25012
  return null;
24821
25013
  const allThinking = /* @__PURE__ */ new Map();
24822
25014
  const contextWindowTokensByModel = /* @__PURE__ */ new Map();
@@ -24826,16 +25018,16 @@ function parseGrokModelState(value) {
24826
25018
  for (const candidate of value.availableModels) {
24827
25019
  if (!isRecord16(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
24828
25020
  continue;
24829
- const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
24830
- if (!ref.success)
25021
+ const ref = encodeGrokModelRef(candidate.modelId);
25022
+ if (!ref)
24831
25023
  continue;
24832
25024
  const metadata = isRecord16(candidate._meta) ? candidate._meta : {};
24833
25025
  const options2 = thinkingOptions(metadata.reasoningEfforts);
24834
25026
  if (Array.isArray(metadata.contextWindows) && metadata.contextWindows.includes(5e5)) {
24835
- defaultContextWindowTokensByModel.set(ref.data.id, 5e5);
25027
+ defaultContextWindowTokensByModel.set(ref.id, 5e5);
24836
25028
  }
24837
25029
  if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
24838
- contextWindowTokensByModel.set(ref.data.id, metadata.totalContextTokens);
25030
+ contextWindowTokensByModel.set(ref.id, metadata.totalContextTokens);
24839
25031
  }
24840
25032
  for (const option of options2)
24841
25033
  allThinking.set(option.id, option);
@@ -24846,22 +25038,22 @@ function parseGrokModelState(value) {
24846
25038
  }
24847
25039
  }
24848
25040
  models.push({
24849
- ref: ref.data,
25041
+ ref,
24850
25042
  label: candidate.name,
24851
25043
  ...options2.length > 0 ? { supportedThinkingOptionIds: options2.map(({ id }) => id) } : {}
24852
25044
  });
24853
25045
  }
24854
- if (!models.some(({ ref }) => ref.id === currentModel.data.id))
25046
+ if (!models.some(({ ref }) => ref.id === currentModel.id))
24855
25047
  return null;
24856
25048
  const options = [...allThinking.values()];
24857
25049
  return {
24858
- currentModel: currentModel.data,
25050
+ currentModel,
24859
25051
  contextWindowTokensByModel,
24860
25052
  defaultContextWindowTokensByModel,
24861
25053
  ...currentThinkingOptionId ? { currentThinkingOptionId } : {},
24862
25054
  catalog: {
24863
25055
  models,
24864
- defaultModel: currentModel.data,
25056
+ defaultModel: currentModel,
24865
25057
  thinkingOptions: options,
24866
25058
  ...currentThinkingOptionId ? { defaultThinkingOptionId: currentThinkingOptionId } : {}
24867
25059
  }
@@ -25354,7 +25546,7 @@ function capabilitiesForModels(modelState) {
25354
25546
  selectModel: modelState.catalog.models.length > 0,
25355
25547
  selectThinkingOption: modelState.catalog.thinkingOptions.length > 0,
25356
25548
  selectPermissionMode: true,
25357
- permissionModeScope: "atCreate"
25549
+ permissionModeScope: "live"
25358
25550
  },
25359
25551
  history: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true },
25360
25552
  subagents: { observe: true, readTranscript: true }
@@ -25509,6 +25701,8 @@ var GrokHarnessSession = class {
25509
25701
  return { ok: false, error: invalidState("Grok Session is not open") };
25510
25702
  if ("commandId" in command)
25511
25703
  return this.#executeHarnessCommand(command);
25704
+ if (command.type === "turn.steer")
25705
+ return unsupportedSteer("Grok");
25512
25706
  if (command.type === "turn.cancel")
25513
25707
  return this.#cancel(command);
25514
25708
  if (command.type === "interaction.respond")
@@ -25757,7 +25951,7 @@ var GrokHarnessSession = class {
25757
25951
  this.#configuring = true;
25758
25952
  try {
25759
25953
  const contextWindow = this.#modelState.defaultContextWindowTokensByModel.get(model2.id);
25760
- await this.#transport.setModel(model2.id, thinkingOptionId, contextWindow);
25954
+ await this.#transport.setModel(decodeGrokModelRef(model2), thinkingOptionId, contextWindow);
25761
25955
  if (contextWindow !== void 0) {
25762
25956
  this.#modelState.contextWindowTokensByModel = new Map([
25763
25957
  ...this.#modelState.contextWindowTokensByModel,
@@ -25790,14 +25984,29 @@ var GrokHarnessSession = class {
25790
25984
  }
25791
25985
  };
25792
25986
  }
25793
- return {
25794
- ok: false,
25795
- error: {
25796
- code: "invalidRequest",
25797
- message: "Grok Permission Mode is fixed at Session creation",
25798
- retryable: false
25799
- }
25800
- };
25987
+ if (this.#active || this.#configuring) {
25988
+ return {
25989
+ ok: false,
25990
+ error: {
25991
+ code: "sessionBusy",
25992
+ message: "Grok Session cannot configure permissions during another operation",
25993
+ retryable: true
25994
+ }
25995
+ };
25996
+ }
25997
+ this.#configuring = true;
25998
+ try {
25999
+ await this.#transport.setPermissionMode(command.permissionModeId);
26000
+ if (this.#phase !== "open")
26001
+ return { ok: false, error: invalidState("Grok Session is closed") };
26002
+ this.#state = { ...this.#state, effectivePermissionModeId: command.permissionModeId };
26003
+ this.#event({ type: "session.state.changed", state: this.#state });
26004
+ return { ok: true, value: { completed: true } };
26005
+ } catch (error53) {
26006
+ return { ok: false, error: normalizeError(error53, "nativeFailure") };
26007
+ } finally {
26008
+ this.#configuring = false;
26009
+ }
25801
26010
  }
25802
26011
  async #cancel(command) {
25803
26012
  const active = this.#active;
@@ -26723,7 +26932,7 @@ var GrokAdapter = class {
26723
26932
  } : {
26724
26933
  kind: "create",
26725
26934
  permissionModeId: requestedPermissionModeId,
26726
- ...input.kind === "create" && input.model ? { modelId: input.model.id } : {}
26935
+ ...input.kind === "create" && input.model ? { modelId: decodeGrokModelRef(input.model) } : {}
26727
26936
  });
26728
26937
  }
26729
26938
  if (!opened) {
@@ -26781,7 +26990,7 @@ var GrokAdapter = class {
26781
26990
  }
26782
26991
  const contextWindow = modelState.defaultContextWindowTokensByModel.get(modelState.currentModel.id);
26783
26992
  if (modelState.currentModel.id !== nativeModelId || modelState.currentThinkingOptionId !== nativeThinkingOptionId || contextWindow !== void 0 && modelState.contextWindowTokensByModel.get(modelState.currentModel.id) !== contextWindow) {
26784
- await transport.setModel(modelState.currentModel.id, modelState.currentThinkingOptionId, contextWindow);
26993
+ await transport.setModel(decodeGrokModelRef(modelState.currentModel), modelState.currentThinkingOptionId, contextWindow);
26785
26994
  if (contextWindow !== void 0) {
26786
26995
  modelState.contextWindowTokensByModel = new Map([
26787
26996
  ...modelState.contextWindowTokensByModel,
@@ -26789,6 +26998,7 @@ var GrokAdapter = class {
26789
26998
  ]);
26790
26999
  }
26791
27000
  }
27001
+ await transport.setPermissionMode(initialPermissionModeId);
26792
27002
  const history = await transport.getHistory();
26793
27003
  let initialUsage = input.kind === "resume" || input.kind === "fork" || input.kind === "rollbackLastTurn" ? combineUsage(sessionUsageFromHistory(history), usageFromSignals(opened.signals)) : null;
26794
27004
  if (contextWindow !== void 0 && initialUsage?.contextUsedTokens !== void 0) {