@karlorz/codexhost-cli-win32-arm64 0.13.3-7 → 0.14.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +55 -4
  4. package/app/console-web.js +344 -54
  5. package/app/cpa-live-voice-hook.js +55 -4
  6. package/app/desktop-controller.mjs +69 -8
  7. package/app/host-runtime.mjs +743 -230
  8. package/app/plugins/antigravity/plugin.mjs +88 -12
  9. package/app/plugins/claude-code/plugin.mjs +397 -21
  10. package/app/plugins/codebuddy/plugin.mjs +107 -17
  11. package/app/plugins/codex-usage/plugin.mjs +67 -7
  12. package/app/plugins/copilot/assets/icon.png +0 -0
  13. package/app/plugins/copilot/manifest.json +26 -0
  14. package/app/plugins/copilot/plugin.mjs +34645 -0
  15. package/app/plugins/cursor-cli/plugin.mjs +88 -6
  16. package/app/plugins/deepseek-harness/plugin.mjs +73 -6
  17. package/app/plugins/enabled.json +1 -0
  18. package/app/plugins/grok/plugin.mjs +272 -60
  19. package/app/plugins/hermes/plugin.mjs +70 -4
  20. package/app/plugins/kimi-code/plugin.mjs +73 -6
  21. package/app/plugins/kiro-cli/plugin.mjs +73 -6
  22. package/app/plugins/omp/plugin.mjs +73 -112
  23. package/app/plugins/opencode/plugin.mjs +75 -6
  24. package/app/plugins/pi/plugin.mjs +204 -44
  25. package/app/plugins/qoder/plugin.mjs +73 -6
  26. package/app/plugins/qoder-cn/plugin.mjs +73 -6
  27. package/app/plugins/workbuddy/plugin.mjs +368 -41
  28. package/app/plugins/zcode/plugin.mjs +74 -6
  29. package/app/renderer-extension.js +749 -157
  30. package/bin/codexhost.exe +0 -0
  31. package/libexec/codexhost-node-repl.exe +0 -0
  32. package/libexec/codexhost-shim.exe +0 -0
  33. package/libexec/codexhost-updater.exe +0 -0
  34. package/package.json +1 -1
@@ -581,44 +581,8 @@ function createGrokUsageStatistics(environment) {
581
581
  // dist/grok-adapter.js
582
582
  import { randomUUID as randomUUID2 } from "node:crypto";
583
583
 
584
- // dist/grok-credential-export.js
584
+ // dist/grok-text-item-id.js
585
585
  import { createHash } from "node:crypto";
586
- import { readFile as readFile2 } from "node:fs/promises";
587
- import os3 from "node:os";
588
- import path6 from "node:path";
589
- async function readGrokCredentials(environment) {
590
- if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((v) => v?.trim()))
591
- return [];
592
- try {
593
- const home = environment.GROK_HOME ?? path6.join(environment.HOME ?? os3.homedir(), ".grok");
594
- const auth = JSON.parse(await readFile2(path6.join(home, "auth.json"), "utf8"));
595
- const client2 = "b1a00492-073a-47ea-816f-4c329264a828";
596
- const entry = auth[`https://auth.x.ai::${client2}`] ?? auth["https://auth.x.ai"];
597
- if (!entry || entry.oidc_issuer !== "https://auth.x.ai" || entry.oidc_client_id !== client2)
598
- return [];
599
- if (![entry.key, entry.refresh_token, entry.user_id].every((v) => typeof v === "string" && v.length))
600
- return [];
601
- const expires = Date.parse(entry.expires_at);
602
- if (!Number.isFinite(expires))
603
- return [];
604
- return [
605
- {
606
- source: {
607
- id: `grok:${createHash("sha256").update(entry.user_id).digest("hex")}`,
608
- harnessId: "grok",
609
- provider: "xai",
610
- label: typeof entry.email === "string" && entry.email ? entry.email : "Grok"
611
- },
612
- oauth: { access: entry.key, refresh: entry.refresh_token, expires: expires - 3e5 }
613
- }
614
- ];
615
- } catch {
616
- return [];
617
- }
618
- }
619
-
620
- // dist/grok-adapter.js
621
- import path18 from "node:path";
622
586
 
623
587
  // ../../../node_modules/zod/v4/classic/external.js
624
588
  var external_exports = {};
@@ -15271,10 +15235,19 @@ var model = external_exports.string().min(1).max(512);
15271
15235
  var project = external_exports.string().min(1).max(4096);
15272
15236
  var usageStatisticsParamsSchema = external_exports.strictObject({
15273
15237
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
15238
+ /** Display timezone for ranges, dates and hourly buckets; omitted means the Host's local zone. */
15239
+ timeZone: external_exports.string().min(1).max(128).refine((value) => {
15240
+ try {
15241
+ new Intl.DateTimeFormat("en", { timeZone: value });
15242
+ return true;
15243
+ } catch {
15244
+ return false;
15245
+ }
15246
+ }, "Unsupported usage statistics timezone").optional(),
15274
15247
  harness: harness.optional(),
15275
15248
  model: model.nullable().optional(),
15276
15249
  project: project.nullable().optional(),
15277
- /** One local date inside the range. */
15250
+ /** One date in the query timezone inside the range. */
15278
15251
  date: localDate.optional()
15279
15252
  });
15280
15253
  var usageStatisticsTotalsSchema = external_exports.strictObject({
@@ -15310,7 +15283,7 @@ var usageStatisticsSessionSchema = external_exports.strictObject({
15310
15283
  });
15311
15284
  var usageStatisticsResultSchema = external_exports.strictObject({
15312
15285
  range: external_exports.enum(USAGE_STATISTICS_RANGES),
15313
- /** First local date of the range; null for all time. */
15286
+ /** First date in the query timezone (Host local when omitted); null for all time. */
15314
15287
  from: localDate.nullable(),
15315
15288
  to: localDate,
15316
15289
  /** The filters these figures apply, echoed so a late answer to older filters is recognised. */
@@ -15350,7 +15323,7 @@ var usageStatisticsResultSchema = external_exports.strictObject({
15350
15323
  totals: usageStatisticsTotalsSchema,
15351
15324
  /** Each date and Harness of the range: every filter except the day. */
15352
15325
  daily: external_exports.array(external_exports.strictObject({ date: localDate, harness, ...totals })).max(2e5),
15353
- /** Local weekday (0 = Sunday) and hour, all filters applied. */
15326
+ /** Weekday (0 = Sunday) and hour in the query timezone, all filters applied. */
15354
15327
  hourly: external_exports.array(external_exports.strictObject({
15355
15328
  weekday: external_exports.number().int().min(0).max(6),
15356
15329
  hour: external_exports.number().int().min(0).max(23),
@@ -15441,6 +15414,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
15441
15414
  "codexhost/harness/display-settings/set",
15442
15415
  "codexhost/harness/inspect",
15443
15416
  "codexhost/harness/installation",
15417
+ "codexhost/harness/installation/start",
15418
+ "codexhost/harness/installation/status",
15444
15419
  "codexhost/harness/launch-settings/get",
15445
15420
  "codexhost/harness/launch-settings/set",
15446
15421
  "codexhost/harness/grok-computer-use/get",
@@ -15518,7 +15493,18 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
15518
15493
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15519
15494
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
15520
15495
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15496
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
15497
+ var composerIndicatorsSchema = external_exports.array(external_exports.object({
15498
+ kind: external_exports.literal("countdown"),
15499
+ id: external_exports.string().min(1).max(64),
15500
+ expiresAtUnix: nonNegativeSafeIntegerSchema,
15501
+ label: indicatorTextSchema(256).optional(),
15502
+ tooltip: indicatorTextSchema(1024).optional()
15503
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
15504
+ message: "Composer indicator IDs must be unique"
15505
+ });
15521
15506
  var threadUsageSnapshotSchema = external_exports.object({
15507
+ composerIndicators: composerIndicatorsSchema.optional(),
15522
15508
  inputTokens: nonNegativeSafeIntegerSchema.optional(),
15523
15509
  cachedInputTokens: nonNegativeSafeIntegerSchema.optional(),
15524
15510
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15926,7 +15912,9 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15926
15912
  }).strict().optional(),
15927
15913
  autonomousTurns: external_exports.object({
15928
15914
  observe: external_exports.boolean()
15929
- }).strict().optional()
15915
+ }).strict().optional(),
15916
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15917
+ steer: external_exports.boolean().optional()
15930
15918
  }).strict();
15931
15919
  var harnessConfigurationStateSchema = external_exports.object({
15932
15920
  effectiveModel: harnessModelRefSchema.optional(),
@@ -16058,6 +16046,15 @@ var threadOwnershipListResultSchema = external_exports.object({
16058
16046
  seen.add(thread.threadId);
16059
16047
  }
16060
16048
  });
16049
+ var threadSteeringInspectParamsSchema = external_exports.object({
16050
+ threadId: hostThreadIdSchema,
16051
+ /** The text about to be steered; a Harness command always stops and restarts. */
16052
+ text: external_exports.string().optional()
16053
+ }).strict();
16054
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
16055
+ var threadSteeringInspectResultSchema = external_exports.object({
16056
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
16057
+ }).strict();
16061
16058
 
16062
16059
  // ../../shared-contracts/dist/harness-plugins.js
16063
16060
  var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
@@ -16179,6 +16176,10 @@ var harnessInstallationStateSchema = external_exports.object({
16179
16176
  latestVersion: external_exports.string().min(1).max(128),
16180
16177
  updateAvailable: external_exports.boolean(),
16181
16178
  canUpdate: external_exports.boolean(),
16179
+ /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
16180
+ versionKind: external_exports.enum(["cli", "application"]).optional(),
16181
+ /** Official download opened by the user; does not imply an automatic installation. */
16182
+ manualUpdateUrl: external_exports.url().max(2048).refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Manual updates require a credential-free HTTPS URL").optional(),
16182
16183
  // Adapter-owned diagnostic text; UI uses messageCode rather than displaying it verbatim.
16183
16184
  message: external_exports.string().max(2048).optional(),
16184
16185
  messageCode: external_exports.string().min(1).max(128).optional(),
@@ -16186,6 +16187,20 @@ var harnessInstallationStateSchema = external_exports.object({
16186
16187
  notice: harnessLocalizedTextSchema.optional(),
16187
16188
  latestVersionKind: external_exports.enum(["unknown", "tracking-branch"]).optional()
16188
16189
  }).strict();
16190
+ var harnessInstallationTaskParamsSchema = external_exports.object({ taskId: external_exports.string().uuid() }).strict();
16191
+ var harnessInstallationTaskSchema = external_exports.discriminatedUnion("status", [
16192
+ external_exports.object({ taskId: external_exports.string().uuid(), status: external_exports.literal("running") }).strict(),
16193
+ external_exports.object({
16194
+ taskId: external_exports.string().uuid(),
16195
+ status: external_exports.literal("succeeded"),
16196
+ result: harnessInstallationStateSchema
16197
+ }).strict(),
16198
+ external_exports.object({
16199
+ taskId: external_exports.string().uuid(),
16200
+ status: external_exports.literal("failed"),
16201
+ error: external_exports.object({ code: external_exports.number().int(), message: external_exports.string().min(1).max(2048) }).strict()
16202
+ }).strict()
16203
+ ]);
16189
16204
 
16190
16205
  // ../../shared-contracts/dist/codex-accounts.js
16191
16206
  var accountIdSchema = external_exports.string().min(1).max(256).regex(/^[A-Za-z0-9._~-]+$/u);
@@ -16615,6 +16630,51 @@ var voiceSettingsStateSchema = external_exports.strictObject({
16615
16630
  // ../../shared-contracts/dist/index.js
16616
16631
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16617
16632
 
16633
+ // dist/grok-text-item-id.js
16634
+ function grokTextItemId(sessionId, turnIndex, kind, ordinal) {
16635
+ const identity = JSON.stringify([sessionId, turnIndex, kind, ordinal]);
16636
+ return hostItemIdSchema.parse(`grok-text-${createHash("sha256").update(identity).digest("hex")}`);
16637
+ }
16638
+
16639
+ // dist/grok-credential-export.js
16640
+ import { createHash as createHash2 } from "node:crypto";
16641
+ import { readFile as readFile2 } from "node:fs/promises";
16642
+ import os3 from "node:os";
16643
+ import path6 from "node:path";
16644
+ async function readGrokCredentials(environment) {
16645
+ if ([environment.XAI_API_KEY, environment.GROK_API_KEY, environment.GROK_TOKEN].some((v) => v?.trim()))
16646
+ return [];
16647
+ try {
16648
+ const home = environment.GROK_HOME ?? path6.join(environment.HOME ?? os3.homedir(), ".grok");
16649
+ const auth = JSON.parse(await readFile2(path6.join(home, "auth.json"), "utf8"));
16650
+ const client2 = "b1a00492-073a-47ea-816f-4c329264a828";
16651
+ const entry = auth[`https://auth.x.ai::${client2}`] ?? auth["https://auth.x.ai"];
16652
+ if (!entry || entry.oidc_issuer !== "https://auth.x.ai" || entry.oidc_client_id !== client2)
16653
+ return [];
16654
+ if (![entry.key, entry.refresh_token, entry.user_id].every((v) => typeof v === "string" && v.length))
16655
+ return [];
16656
+ const expires = Date.parse(entry.expires_at);
16657
+ if (!Number.isFinite(expires))
16658
+ return [];
16659
+ return [
16660
+ {
16661
+ source: {
16662
+ id: `grok:${createHash2("sha256").update(entry.user_id).digest("hex")}`,
16663
+ harnessId: "grok",
16664
+ provider: "xai",
16665
+ label: typeof entry.email === "string" && entry.email ? entry.email : "Grok"
16666
+ },
16667
+ oauth: { access: entry.key, refresh: entry.refresh_token, expires: expires - 3e5 }
16668
+ }
16669
+ ];
16670
+ } catch {
16671
+ return [];
16672
+ }
16673
+ }
16674
+
16675
+ // dist/grok-adapter.js
16676
+ import path18 from "node:path";
16677
+
16618
16678
  // ../../harness-plugin-files/dist/grok-computer-use.js
16619
16679
  import { randomUUID } from "node:crypto";
16620
16680
  import { access, mkdir as mkdir2, readFile as readFile3, rename, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
@@ -16995,6 +17055,18 @@ function sanitizeDiagnosticTail(value) {
16995
17055
  return redacted.length <= DIAGNOSTIC_TAIL_MAX_LENGTH ? redacted : redacted.slice(-DIAGNOSTIC_TAIL_MAX_LENGTH);
16996
17056
  }
16997
17057
 
17058
+ // ../../harness-adapter/dist/steer.js
17059
+ function unsupportedSteer(harnessLabel) {
17060
+ return {
17061
+ ok: false,
17062
+ error: {
17063
+ code: "unsupported",
17064
+ message: `${harnessLabel} cannot steer an active Turn natively`,
17065
+ retryable: false
17066
+ }
17067
+ };
17068
+ }
17069
+
16998
17070
  // ../../harness-adapter/dist/usage.js
16999
17071
  var tokenFields = [
17000
17072
  "inputTokens",
@@ -17022,6 +17094,7 @@ var usageFields = /* @__PURE__ */ new Set([
17022
17094
  ...safeIntegerFields,
17023
17095
  ...percentFields,
17024
17096
  "sessionCacheUsage",
17097
+ "composerIndicators",
17025
17098
  "totalCostUsd",
17026
17099
  "totalCredits",
17027
17100
  "contextUsagePercent",
@@ -17044,6 +17117,7 @@ function parseHostUsage(value) {
17044
17117
  throw new Error(`Harness Usage contains unknown field '${key}'`);
17045
17118
  }
17046
17119
  }
17120
+ const indicators = value.composerIndicators === void 0 ? {} : { composerIndicators: composerIndicatorsSchema.parse(value.composerIndicators) };
17047
17121
  for (const field of [
17048
17122
  "totalCredits",
17049
17123
  "contextUsagePercent",
@@ -17114,9 +17188,9 @@ function parseHostUsage(value) {
17114
17188
  if (value.costSource !== "publicPrice") {
17115
17189
  throw new Error("Harness Usage 'unpricedModels' must be provided with a 'publicPrice' cost");
17116
17190
  }
17117
- return { ...value, unpricedModels: [...models] };
17191
+ return { ...value, ...indicators, unpricedModels: [...models] };
17118
17192
  }
17119
- return { ...value };
17193
+ return { ...value, ...indicators };
17120
17194
  }
17121
17195
  var requestTokenFields = [
17122
17196
  "inputTokens",
@@ -22924,7 +22998,11 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
22924
22998
  let nativePromptIndex = 0;
22925
22999
  let currentPromptIndex = null;
22926
23000
  let agent = null;
23001
+ let agentMessageId;
23002
+ let agentIndex = 0;
22927
23003
  let reasoning = null;
23004
+ let reasoningMessageId;
23005
+ let reasoningIndex = 0;
22928
23006
  const tools = /* @__PURE__ */ new Map();
22929
23007
  const generatedImages = /* @__PURE__ */ new Map();
22930
23008
  const mediaRoots = grokMediaResolveRoots(cwd, sessionDirectory);
@@ -23122,6 +23200,8 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
23122
23200
  });
23123
23201
  turnIndex += 1;
23124
23202
  messageIndex = 0;
23203
+ agentIndex = 0;
23204
+ reasoningIndex = 0;
23125
23205
  nativeTurnKey = null;
23126
23206
  currentPromptIndex = null;
23127
23207
  input = "";
@@ -23135,6 +23215,8 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
23135
23215
  });
23136
23216
  turnIndex = turns.length;
23137
23217
  messageIndex = 0;
23218
+ agentIndex = 0;
23219
+ reasoningIndex = 0;
23138
23220
  nativeTurnKey = null;
23139
23221
  nativePromptIndex = event.targetPromptIndex;
23140
23222
  currentPromptIndex = null;
@@ -23199,20 +23281,28 @@ function mapGrokReplay(replay, harnessId, sessionId, cwd, knownTurnRefs = [], to
23199
23281
  outcome
23200
23282
  });
23201
23283
  } else if (event.type === "agent.text") {
23284
+ if (agent && agentMessageId !== event.messageId)
23285
+ completeAgent();
23202
23286
  if (!agent) {
23203
23287
  completeReasoning();
23288
+ agentMessageId = event.messageId;
23289
+ ++messageIndex;
23204
23290
  agent = {
23205
23291
  type: "agentMessage",
23206
- itemId: stableId("message", turnIndex, ++messageIndex),
23292
+ itemId: grokTextItemId(sessionId, turnIndex, "agentMessage", ++agentIndex),
23207
23293
  text: ""
23208
23294
  };
23209
23295
  }
23210
23296
  agent = { ...agent, text: agent.text + event.text };
23211
23297
  } else if (event.type === "agent.thought") {
23298
+ if (reasoning && reasoningMessageId !== event.messageId)
23299
+ completeReasoning();
23212
23300
  if (!reasoning) {
23301
+ reasoningMessageId = event.messageId;
23302
+ ++messageIndex;
23213
23303
  reasoning = {
23214
23304
  type: "reasoning",
23215
- itemId: stableId("reasoning", turnIndex, ++messageIndex),
23305
+ itemId: grokTextItemId(sessionId, turnIndex, "reasoning", ++reasoningIndex),
23216
23306
  text: ""
23217
23307
  };
23218
23308
  }
@@ -24023,6 +24113,53 @@ function grokCodexhostSessionMeta(permissionMode) {
24023
24113
  };
24024
24114
  }
24025
24115
 
24116
+ // dist/permission-confirmation.js
24117
+ import { stripVTControlCharacters } from "node:util";
24118
+ var GROK_PERMISSION_MODE_METHOD = "_x.ai/yolo_mode_changed";
24119
+ var permissionManagerLog = "xai_grok_workspace::permission::manager=info";
24120
+ function grokPermissionLogFilter(existing) {
24121
+ return existing ? `${existing},${permissionManagerLog}` : permissionManagerLog;
24122
+ }
24123
+ var GrokPermissionConfirmation = class {
24124
+ #expected;
24125
+ #completion = Promise.withResolvers();
24126
+ #yolo;
24127
+ #auto;
24128
+ #buffer = "";
24129
+ constructor(mode) {
24130
+ this.#expected = grokPermissionModeSessionMeta(mode);
24131
+ }
24132
+ get completed() {
24133
+ return this.#completion.promise;
24134
+ }
24135
+ accept(chunk) {
24136
+ this.#buffer += chunk;
24137
+ let newline2;
24138
+ while ((newline2 = this.#buffer.indexOf("\n")) !== -1) {
24139
+ const line = stripVTControlCharacters(this.#buffer.slice(0, newline2)).trimEnd();
24140
+ this.#buffer = this.#buffer.slice(newline2 + 1);
24141
+ const match = /^\d{4}-\d{2}-\d{2}T\S+\s+INFO\s+(?:.*?: )?(always-approve|auto permission mode) set to: (true|false)$/.exec(line);
24142
+ if (!match)
24143
+ continue;
24144
+ const value = match[2] === "true";
24145
+ if (match[1] === "always-approve")
24146
+ this.#yolo = value;
24147
+ else
24148
+ this.#auto = value;
24149
+ if (this.#yolo !== void 0 && this.#yolo !== this.#expected.yoloMode || this.#auto !== void 0 && this.#auto !== this.#expected.autoMode) {
24150
+ this.reject(new Error("Grok did not apply the requested Permission Mode"));
24151
+ } else if (this.#yolo !== void 0 && this.#auto !== void 0) {
24152
+ this.#completion.resolve(void 0);
24153
+ }
24154
+ }
24155
+ if (this.#buffer.length > 16384)
24156
+ this.#buffer = "";
24157
+ }
24158
+ reject(error53) {
24159
+ this.#completion.reject(error53);
24160
+ }
24161
+ };
24162
+
24026
24163
  // dist/acp-transport.js
24027
24164
  var GrokTransportError = class extends Error {
24028
24165
  kind;
@@ -24307,6 +24444,8 @@ var GrokAcpTransport = class {
24307
24444
  #child = null;
24308
24445
  #closed = false;
24309
24446
  #closing = false;
24447
+ #closePromise = null;
24448
+ #permissionConfirmation = null;
24310
24449
  #connection = null;
24311
24450
  #initialize = null;
24312
24451
  #replay = null;
@@ -24507,7 +24646,11 @@ var GrokAcpTransport = class {
24507
24646
  const invocation = grokInvocation(executable, process.platform, this.#startupModelId);
24508
24647
  const child = spawn(invocation.command, invocation.arguments, {
24509
24648
  cwd: this.#options.cwd,
24510
- env: { ...process.env, ...this.#options.environment },
24649
+ env: {
24650
+ ...process.env,
24651
+ ...this.#options.environment,
24652
+ RUST_LOG: grokPermissionLogFilter(this.#options.environment?.RUST_LOG ?? process.env.RUST_LOG)
24653
+ },
24511
24654
  detached: process.platform !== "win32",
24512
24655
  stdio: ["pipe", "pipe", "pipe"],
24513
24656
  windowsHide: true,
@@ -24516,6 +24659,7 @@ var GrokAcpTransport = class {
24516
24659
  this.#child = child;
24517
24660
  child.stderr.on("data", (chunk) => {
24518
24661
  this.#stderrTail = sanitizeDiagnosticTail(`${this.#stderrTail}${chunk.toString()}`);
24662
+ this.#permissionConfirmation?.accept(chunk.toString());
24519
24663
  });
24520
24664
  await withTimeout(new Promise((resolve, reject) => {
24521
24665
  child.once("spawn", resolve);
@@ -24553,6 +24697,8 @@ var GrokAcpTransport = class {
24553
24697
  }
24554
24698
  if (this.#activePrompt)
24555
24699
  throw new Error("Grok ACP Session already has an active Prompt");
24700
+ if (this.#permissionConfirmation)
24701
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
24556
24702
  const active = { onEvent, onPermission, onElicitation };
24557
24703
  this.#activePrompt = active;
24558
24704
  try {
@@ -24571,7 +24717,7 @@ var GrokAcpTransport = class {
24571
24717
  if (!connection || !this.#sessionId || this.#closed || this.#closing) {
24572
24718
  throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
24573
24719
  }
24574
- if (this.#activePrompt || this.#activeCompact) {
24720
+ if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
24575
24721
  throw new GrokTransportError("unavailable", "Grok ACP Session already has an active operation");
24576
24722
  }
24577
24723
  const active = { onEvent, cancellationRequested: false };
@@ -24604,6 +24750,8 @@ var GrokAcpTransport = class {
24604
24750
  const connection = this.#connection;
24605
24751
  if (!connection || !this.#sessionId)
24606
24752
  throw new Error("Grok ACP Session is unavailable");
24753
+ if (this.#permissionConfirmation)
24754
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
24607
24755
  const response = await connection.request("session/set_model", {
24608
24756
  sessionId: this.#sessionId,
24609
24757
  modelId,
@@ -24631,14 +24779,57 @@ var GrokAcpTransport = class {
24631
24779
  this.#activeCompact.cancellationRequested = true;
24632
24780
  return connection.cancel({ sessionId: this.#sessionId });
24633
24781
  }
24634
- async close() {
24782
+ async setPermissionMode(permissionModeId) {
24783
+ const mode = decodeGrokPermissionModeId(permissionModeId);
24784
+ const connection = this.#connection;
24785
+ const sessionId = this.#sessionId;
24786
+ if (!connection || !sessionId || this.#closed || this.#closing) {
24787
+ throw new GrokTransportError("unavailable", "Grok ACP Session is unavailable");
24788
+ }
24789
+ if (this.#activePrompt || this.#activeCompact || this.#permissionConfirmation) {
24790
+ throw new GrokTransportError("unavailable", "Grok ACP Session has an active operation");
24791
+ }
24792
+ const confirmation = new GrokPermissionConfirmation(mode);
24793
+ this.#permissionConfirmation = confirmation;
24794
+ try {
24795
+ await withTimeout(Promise.all([
24796
+ confirmation.completed,
24797
+ (async () => {
24798
+ const flags = grokPermissionModeSessionMeta(mode);
24799
+ await connection.notify(GROK_PERMISSION_MODE_METHOD, {
24800
+ yolo_mode: flags.yoloMode,
24801
+ auto_mode: flags.autoMode,
24802
+ permission_mode: mode
24803
+ });
24804
+ const response = await connection.request("_x.ai/session/info", { sessionId });
24805
+ if (!isRecord14(response) || !isRecord14(response.result) || response.result.sessionId !== sessionId) {
24806
+ throw new Error("Grok did not confirm the target Session");
24807
+ }
24808
+ })()
24809
+ ]), this.#options.commandTimeoutMs, "Grok Permission Mode confirmation");
24810
+ if (this.#closed || this.#closing)
24811
+ throw new Error("Grok Session closed during configuration");
24812
+ } catch (cause) {
24813
+ const error53 = new GrokTransportError("protocolError", "Grok Permission Mode could not be confirmed; reopen the Session to continue", { cause });
24814
+ this.#fault(error53);
24815
+ await this.close();
24816
+ throw error53;
24817
+ } finally {
24818
+ this.#permissionConfirmation = null;
24819
+ }
24820
+ }
24821
+ close() {
24822
+ return this.#closePromise ??= this.#close();
24823
+ }
24824
+ async #close() {
24635
24825
  if (this.#closed)
24636
24826
  return;
24637
24827
  this.#closing = true;
24828
+ this.#permissionConfirmation?.reject(new Error("Grok Session closed during configuration"));
24638
24829
  const child = this.#child;
24639
24830
  const connection = this.#connection;
24640
24831
  if (connection && this.#sessionId && this.#initialize?.agentCapabilities?.sessionCapabilities?.close) {
24641
- await connection.closeSession({ sessionId: this.#sessionId }).catch(() => void 0);
24832
+ await withTimeout(connection.closeSession({ sessionId: this.#sessionId }), this.#options.closeTimeoutMs, "Grok Session close").catch(() => void 0);
24642
24833
  }
24643
24834
  if (child?.stdin.writable)
24644
24835
  child.stdin.end();
@@ -24708,6 +24899,7 @@ var GrokAcpTransport = class {
24708
24899
  return { ...await this.#activePrompt.onElicitation(parsed.request) };
24709
24900
  }
24710
24901
  #fault(error53) {
24902
+ this.#permissionConfirmation?.reject(error53);
24711
24903
  if (this.#closing || this.#closed)
24712
24904
  return;
24713
24905
  this.#options.onFault?.(error53);
@@ -25781,7 +25973,7 @@ function capabilitiesForModels(modelState) {
25781
25973
  selectModel: modelState.catalog.models.length > 0,
25782
25974
  selectThinkingOption: modelState.catalog.thinkingOptions.length > 0,
25783
25975
  selectPermissionMode: true,
25784
- permissionModeScope: "atCreate"
25976
+ permissionModeScope: "live"
25785
25977
  },
25786
25978
  history: { fork: true, forkAcrossCwd: true, rollbackLastTurn: true },
25787
25979
  subagents: { observe: true, readTranscript: true }
@@ -25935,6 +26127,8 @@ var GrokHarnessSession = class {
25935
26127
  return { ok: false, error: invalidState("Grok Session is not open") };
25936
26128
  if ("commandId" in command)
25937
26129
  return this.#executeHarnessCommand(command);
26130
+ if (command.type === "turn.steer")
26131
+ return unsupportedSteer("Grok");
25938
26132
  if (command.type === "turn.cancel")
25939
26133
  return this.#cancel(command);
25940
26134
  if (command.type === "interaction.respond")
@@ -25977,6 +26171,7 @@ var GrokHarnessSession = class {
25977
26171
  });
25978
26172
  const active = {
25979
26173
  command,
26174
+ textIdentity: { turnIndex: this.#snapshot.turns.length, agentMessage: 0, reasoning: 0 },
25980
26175
  usage: new GrokTurnUsage(this.#usage, this.#snapshot.turns.length === 0),
25981
26176
  agent: null,
25982
26177
  agentMessageId: null,
@@ -26068,6 +26263,7 @@ var GrokHarnessSession = class {
26068
26263
  });
26069
26264
  const active = {
26070
26265
  command: { type: "turn.start", turnId: command.turnId, input: [] },
26266
+ textIdentity: { turnIndex: this.#snapshot.turns.length, agentMessage: 0, reasoning: 0 },
26071
26267
  agent: null,
26072
26268
  agentMessageId: null,
26073
26269
  rawAgentText: "",
@@ -26216,14 +26412,29 @@ var GrokHarnessSession = class {
26216
26412
  }
26217
26413
  };
26218
26414
  }
26219
- return {
26220
- ok: false,
26221
- error: {
26222
- code: "invalidRequest",
26223
- message: "Grok Permission Mode is fixed at Session creation",
26224
- retryable: false
26225
- }
26226
- };
26415
+ if (this.#active || this.#configuring) {
26416
+ return {
26417
+ ok: false,
26418
+ error: {
26419
+ code: "sessionBusy",
26420
+ message: "Grok Session cannot configure permissions during another operation",
26421
+ retryable: true
26422
+ }
26423
+ };
26424
+ }
26425
+ this.#configuring = true;
26426
+ try {
26427
+ await this.#transport.setPermissionMode(command.permissionModeId);
26428
+ if (this.#phase !== "open")
26429
+ return { ok: false, error: invalidState("Grok Session is closed") };
26430
+ this.#state = { ...this.#state, effectivePermissionModeId: command.permissionModeId };
26431
+ this.#event({ type: "session.state.changed", state: this.#state });
26432
+ return { ok: true, value: { completed: true } };
26433
+ } catch (error53) {
26434
+ return { ok: false, error: normalizeError(error53, "nativeFailure") };
26435
+ } finally {
26436
+ this.#configuring = false;
26437
+ }
26227
26438
  }
26228
26439
  async #cancel(command) {
26229
26440
  const active = this.#active;
@@ -26475,7 +26686,7 @@ var GrokHarnessSession = class {
26475
26686
  if (!active.agent) {
26476
26687
  active.agent = {
26477
26688
  type: "agentMessage",
26478
- itemId: hostItemIdSchema.parse(this.#randomUUID()),
26689
+ itemId: grokTextItemId(this.#transport.sessionId, active.textIdentity.turnIndex, "agentMessage", ++active.textIdentity.agentMessage),
26479
26690
  text: ""
26480
26691
  };
26481
26692
  active.rawAgentText = "";
@@ -26507,7 +26718,7 @@ var GrokHarnessSession = class {
26507
26718
  if (!active.reasoning) {
26508
26719
  active.reasoning = {
26509
26720
  type: "reasoning",
26510
- itemId: hostItemIdSchema.parse(this.#randomUUID()),
26721
+ itemId: grokTextItemId(this.#transport.sessionId, active.textIdentity.turnIndex, "reasoning", ++active.textIdentity.reasoning),
26511
26722
  text: ""
26512
26723
  };
26513
26724
  this.#event({ type: "item.started", turnId: active.command.turnId, item: active.reasoning });
@@ -27220,6 +27431,7 @@ var GrokAdapter = class {
27220
27431
  ]);
27221
27432
  }
27222
27433
  }
27434
+ await transport.setPermissionMode(initialPermissionModeId);
27223
27435
  const history = await transport.getHistory();
27224
27436
  let initialUsage = input.kind === "resume" || input.kind === "fork" || input.kind === "rollbackLastTurn" ? combineUsage(sessionUsageFromHistory(history), usageFromSignals(opened.signals)) : null;
27225
27437
  if (contextWindow !== void 0 && initialUsage?.contextUsedTokens !== void 0) {