@codexhost/cli-darwin-x64 0.9.2 → 0.10.1

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.
@@ -15319,10 +15319,21 @@ var harnessCommandDescriptorSchema = external_exports.object({
15319
15319
  invocation: commandInvocationSchema,
15320
15320
  label: commandLabelSchema,
15321
15321
  description: commandDescriptionSchema.optional(),
15322
- argumentMode: external_exports.enum(["none", "text"])
15322
+ argumentMode: external_exports.enum(["none", "text"]),
15323
+ /**
15324
+ * Native distinction reported by the Harness. Omitted when the Harness does
15325
+ * not tell skills and commands apart; consumers treat that as "command".
15326
+ */
15327
+ kind: external_exports.enum(["command", "skill"]).optional()
15323
15328
  }).strict();
15324
15329
  var harnessCommandCatalogSchema = external_exports.object({
15325
- commands: external_exports.array(harnessCommandDescriptorSchema)
15330
+ commands: external_exports.array(harnessCommandDescriptorSchema),
15331
+ /**
15332
+ * `live` when the catalog includes what a native Session reports for its
15333
+ * workspace (custom commands, skills); `static` for Adapter built-ins only.
15334
+ * Omitted by Adapters; set by the Host on inspection results.
15335
+ */
15336
+ source: external_exports.enum(["live", "static"]).optional()
15326
15337
  }).strict().superRefine((catalog, context) => {
15327
15338
  const ids = /* @__PURE__ */ new Set();
15328
15339
  for (const [index, command] of catalog.commands.entries()) {
@@ -15336,7 +15347,11 @@ var harnessCommandCatalogSchema = external_exports.object({
15336
15347
  ids.add(command.id);
15337
15348
  }
15338
15349
  });
15339
- var harnessCommandsInspectParamsSchema = external_exports.object({ harnessId: harnessIdSchema }).strict();
15350
+ var harnessCommandsInspectParamsSchema = external_exports.object({
15351
+ harnessId: harnessIdSchema,
15352
+ /** Workspace of a draft without a Thread, for its live catalog when known. */
15353
+ cwd: external_exports.string().min(1).optional()
15354
+ }).strict();
15340
15355
  var threadCommandsInspectParamsSchema = external_exports.object({
15341
15356
  threadId: hostThreadIdSchema
15342
15357
  }).strict();
@@ -15639,6 +15654,124 @@ function parseHostUsage(value) {
15639
15654
  return { ...value };
15640
15655
  }
15641
15656
 
15657
+ // ../../harness-adapter/dist/live-command-catalog.js
15658
+ var COMMON_EXCLUDED_LIVE_COMMANDS = /* @__PURE__ */ new Set([
15659
+ // Session lifecycle
15660
+ "branch",
15661
+ "clear",
15662
+ "exit",
15663
+ "fork",
15664
+ "fresh",
15665
+ "new",
15666
+ "quit",
15667
+ "rename",
15668
+ "rename-chat",
15669
+ "reset",
15670
+ "resume",
15671
+ "rewind",
15672
+ "session",
15673
+ "sessions",
15674
+ // Desktop-owned configuration
15675
+ "autocompact",
15676
+ "color",
15677
+ "config",
15678
+ "effort",
15679
+ "fast",
15680
+ "keybindings",
15681
+ "model",
15682
+ "models",
15683
+ "output-style",
15684
+ "permissions",
15685
+ "settings",
15686
+ "statusline",
15687
+ "terminal-setup",
15688
+ "theme",
15689
+ "vim",
15690
+ // Trust and approval policy
15691
+ "always-approve",
15692
+ "auto-mode-setup",
15693
+ // Native login
15694
+ "login",
15695
+ "logout",
15696
+ // Work outliving the Turn
15697
+ "autopilot",
15698
+ "background",
15699
+ "bg",
15700
+ "goal",
15701
+ "jobs",
15702
+ "loop",
15703
+ "multitask",
15704
+ "queue",
15705
+ "remote-control",
15706
+ "schedule",
15707
+ "steer",
15708
+ // Native terminal UI
15709
+ "copy",
15710
+ "debug",
15711
+ "feedback",
15712
+ "heapdump",
15713
+ "share",
15714
+ "shell",
15715
+ // Plugin and MCP management
15716
+ "marketplace",
15717
+ "mcp",
15718
+ "plugins",
15719
+ "reload-plugins"
15720
+ ]);
15721
+ var COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES = ["__", "hooks-"];
15722
+ function isExcludedLiveCommand(name, kind, extra = {}) {
15723
+ const normalized = name.trim().replace(/^\//u, "");
15724
+ if (new Set(extra.names ?? []).has(normalized))
15725
+ return true;
15726
+ if (extra.prefixes?.some((prefix) => normalized.startsWith(prefix)))
15727
+ return true;
15728
+ if (kind === "skill")
15729
+ return false;
15730
+ return COMMON_EXCLUDED_LIVE_COMMANDS.has(normalized) || COMMON_EXCLUDED_LIVE_COMMAND_PREFIXES.some((prefix) => normalized.startsWith(prefix));
15731
+ }
15732
+ function liveHarnessCommandPrompt(catalog, idPrefix, commandId, argumentText) {
15733
+ if (!commandId.startsWith(idPrefix))
15734
+ return null;
15735
+ const descriptor = catalog.commands.find(({ id }) => id === commandId);
15736
+ if (!descriptor)
15737
+ return null;
15738
+ const text = typeof argumentText === "string" ? argumentText.trim() : "";
15739
+ return text ? `${descriptor.invocation} ${text}` : descriptor.invocation;
15740
+ }
15741
+ function mergeLiveHarnessCommands(builtIns, idPrefix, live, exclusions = {}) {
15742
+ if (!live)
15743
+ return builtIns;
15744
+ const invocations = new Set(builtIns.commands.map(({ invocation }) => invocation));
15745
+ const ids = new Set(builtIns.commands.map(({ id }) => id));
15746
+ const dynamic = [];
15747
+ for (const command of live) {
15748
+ const name = command.name.trim().replace(/^\//u, "");
15749
+ if (!name || /\s/u.test(name))
15750
+ continue;
15751
+ if (isExcludedLiveCommand(name, command.kind, exclusions))
15752
+ continue;
15753
+ const invocation = `/${name}`;
15754
+ const id = `${idPrefix}${name.replace(/[^A-Za-z0-9._:-]/gu, "-")}`.slice(0, 128);
15755
+ if (invocations.has(invocation) || ids.has(id))
15756
+ continue;
15757
+ const description = command.description?.trim().slice(0, 512);
15758
+ const parsed = harnessCommandDescriptorSchema.safeParse({
15759
+ id,
15760
+ invocation,
15761
+ label: name.slice(0, 128),
15762
+ ...description ? { description } : {},
15763
+ argumentMode: "text",
15764
+ kind: command.kind
15765
+ });
15766
+ if (!parsed.success)
15767
+ continue;
15768
+ invocations.add(invocation);
15769
+ ids.add(id);
15770
+ dynamic.push(parsed.data);
15771
+ }
15772
+ return harnessCommandCatalogSchema.parse({ commands: [...builtIns.commands, ...dynamic] });
15773
+ }
15774
+
15642
15775
  // dist/acp-transport.js
15643
15776
  import { spawn, spawnSync } from "node:child_process";
15644
15777
  import { readdir, readFile as readFile2 } from "node:fs/promises";
@@ -19807,6 +19940,41 @@ var ClientSideConnection = class {
19807
19940
  }
19808
19941
  };
19809
19942
 
19943
+ // dist/grok-slash-commands.js
19944
+ var GROK_LIVE_COMMAND_ID_PREFIX = "grok.slash.";
19945
+ function isRecord3(value) {
19946
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19947
+ }
19948
+ function parseGrokAvailableCommands(value) {
19949
+ if (!Array.isArray(value))
19950
+ return [];
19951
+ return value.flatMap((entry) => {
19952
+ if (!isRecord3(entry))
19953
+ return [];
19954
+ const name = typeof entry.name === "string" ? entry.name.trim().replace(/^\//u, "") : "";
19955
+ if (!name)
19956
+ return [];
19957
+ return [
19958
+ {
19959
+ name,
19960
+ description: typeof entry.description === "string" ? entry.description : "",
19961
+ meta: isRecord3(entry._meta) ? entry._meta : null
19962
+ }
19963
+ ];
19964
+ });
19965
+ }
19966
+ function isGrokSkill(command) {
19967
+ const path12 = command.meta?.path;
19968
+ return typeof path12 === "string" && /(^|[\\/])SKILL\.md$/u.test(path12) || typeof command.meta?.qualifiedName === "string";
19969
+ }
19970
+ function grokLiveCommands(native) {
19971
+ return native.map((command) => ({
19972
+ name: command.name,
19973
+ description: command.description,
19974
+ kind: isGrokSkill(command) ? "skill" : "command"
19975
+ }));
19976
+ }
19977
+
19810
19978
  // dist/command.js
19811
19979
  import path4 from "node:path";
19812
19980
 
@@ -20501,7 +20669,7 @@ function splitLines(text) {
20501
20669
  // dist/grok-file-change.js
20502
20670
  var DEFAULT_GROK_FILE_CHANGE_TEXT_LIMIT = 4 * 1024 * 1024;
20503
20671
  var MAX_GROK_FILE_CHANGES_PER_TOOL = 32;
20504
- function isRecord3(value) {
20672
+ function isRecord4(value) {
20505
20673
  return typeof value === "object" && value !== null && !Array.isArray(value);
20506
20674
  }
20507
20675
  function validAbsolutePath(value) {
@@ -20552,7 +20720,7 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
20552
20720
  return null;
20553
20721
  const candidates = [];
20554
20722
  for (const entry of content) {
20555
- if (isRecord3(entry) && entry.type === "diff")
20723
+ if (isRecord4(entry) && entry.type === "diff")
20556
20724
  candidates.push(entry);
20557
20725
  }
20558
20726
  if (candidates.length === 0 || candidates.length > MAX_GROK_FILE_CHANGES_PER_TOOL)
@@ -20869,14 +21037,14 @@ function mediaFileExists(absolutePath) {
20869
21037
  // dist/grok-tool-output.js
20870
21038
  var DEFAULT_GROK_TOOL_OUTPUT_LIMIT = 64e3;
20871
21039
  var EXECUTE_TOOL_NAMES = /* @__PURE__ */ new Set(["bash", "run_terminal_command", "shell", "cursor_shell"]);
20872
- function isRecord4(value) {
21040
+ function isRecord5(value) {
20873
21041
  return typeof value === "object" && value !== null && !Array.isArray(value);
20874
21042
  }
20875
21043
  function stringField(value, key) {
20876
- return isRecord4(value) && typeof value[key] === "string" && value[key].length > 0 ? value[key] : void 0;
21044
+ return isRecord5(value) && typeof value[key] === "string" && value[key].length > 0 ? value[key] : void 0;
20877
21045
  }
20878
21046
  function numberField(value, key) {
20879
- if (!isRecord4(value))
21047
+ if (!isRecord5(value))
20880
21048
  return void 0;
20881
21049
  const field = value[key];
20882
21050
  if (field === null)
@@ -20899,7 +21067,7 @@ function firstReadableText(...candidates) {
20899
21067
  for (const candidate of candidates) {
20900
21068
  if (typeof candidate === "string" && candidate.length > 0)
20901
21069
  return candidate;
20902
- if (isRecord4(candidate)) {
21070
+ if (isRecord5(candidate)) {
20903
21071
  const nested = stringField(candidate, "content") ?? stringField(candidate, "text") ?? stringField(candidate, "tool_result") ?? stringField(candidate, "raw_output");
20904
21072
  if (nested)
20905
21073
  return nested;
@@ -20922,7 +21090,7 @@ function grokToolArguments(rawInput) {
20922
21090
  if (!parsed.success)
20923
21091
  return {};
20924
21092
  const argumentsValue = parsed.data;
20925
- if (!isRecord4(argumentsValue) || stringField(argumentsValue, "path"))
21093
+ if (!isRecord5(argumentsValue) || stringField(argumentsValue, "path"))
20926
21094
  return argumentsValue;
20927
21095
  const targetFile = stringField(argumentsValue, "target_file");
20928
21096
  return targetFile ? { ...argumentsValue, path: targetFile } : argumentsValue;
@@ -20935,7 +21103,7 @@ function grokCommand(name, kind, rawInput) {
20935
21103
  return command;
20936
21104
  if (name && EXECUTE_TOOL_NAMES.has(name))
20937
21105
  return command;
20938
- return isRecord4(rawInput) && rawInput.variant === "Bash" ? command : void 0;
21106
+ return isRecord5(rawInput) && rawInput.variant === "Bash" ? command : void 0;
20939
21107
  }
20940
21108
  function grokCommandCwd(rawInput, fallback) {
20941
21109
  return stringField(rawInput, "cwd") ?? fallback;
@@ -20962,11 +21130,11 @@ function acpContentText(content) {
20962
21130
  if (!Array.isArray(content))
20963
21131
  return "";
20964
21132
  return content.flatMap((entry) => {
20965
- if (!isRecord4(entry))
21133
+ if (!isRecord5(entry))
20966
21134
  return [];
20967
21135
  if (entry.type === "text" && typeof entry.text === "string")
20968
21136
  return [entry.text];
20969
- if (entry.type !== "content" || !isRecord4(entry.content))
21137
+ if (entry.type !== "content" || !isRecord5(entry.content))
20970
21138
  return [];
20971
21139
  return entry.content.type === "text" && typeof entry.content.text === "string" ? [entry.content.text] : [];
20972
21140
  }).join("\n");
@@ -20977,10 +21145,10 @@ function acpContentImages(content, remainingBytes) {
20977
21145
  const images = [];
20978
21146
  let remaining = remainingBytes;
20979
21147
  for (const entry of content) {
20980
- if (!isRecord4(entry))
21148
+ if (!isRecord5(entry))
20981
21149
  continue;
20982
21150
  const image = entry.type === "image" ? entry : entry.type === "content" ? entry.content : null;
20983
- if (!isRecord4(image) || image.type !== "image")
21151
+ if (!isRecord5(image) || image.type !== "image")
20984
21152
  continue;
20985
21153
  const mimeType = stringField(image, "mimeType") ?? stringField(image, "mime_type");
20986
21154
  const data = stringField(image, "data");
@@ -21003,14 +21171,14 @@ function bashOutput(rawOutput) {
21003
21171
  function rawOutputProjection(rawOutput) {
21004
21172
  if (typeof rawOutput === "string")
21005
21173
  return rawOutput.length > 0 ? { text: rawOutput } : {};
21006
- if (!isRecord4(rawOutput))
21174
+ if (!isRecord5(rawOutput))
21007
21175
  return {};
21008
21176
  if (rawOutput.type === "Bash" || rawOutput.variant === "Bash" || numberField(rawOutput, "exit_code") !== void 0 || numberField(rawOutput, "exitCode") !== void 0) {
21009
21177
  const bash = bashOutput(rawOutput);
21010
21178
  if (bash.text !== void 0 || bash.exitCode !== void 0)
21011
21179
  return bash;
21012
21180
  }
21013
- const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord4(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord4(rawOutput.Content) ? rawOutput.Content : void 0);
21181
+ const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord5(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord5(rawOutput.Content) ? rawOutput.Content : void 0);
21014
21182
  if (text)
21015
21183
  return { text };
21016
21184
  if (typeof rawOutput.match_count === "number" && Number.isFinite(rawOutput.match_count)) {
@@ -21074,11 +21242,11 @@ var WAIT_TOOL_NAMES = /* @__PURE__ */ new Set([
21074
21242
  var KILL_TOOL_NAMES = /* @__PURE__ */ new Set(["kill_command_or_subagent", "kill_task"]);
21075
21243
  var DESCRIPTION_LIMIT = 500;
21076
21244
  var SUMMARY_LIMIT = 2e3;
21077
- function isRecord5(value) {
21245
+ function isRecord6(value) {
21078
21246
  return typeof value === "object" && value !== null && !Array.isArray(value);
21079
21247
  }
21080
21248
  function idField(value, key) {
21081
- if (!isRecord5(value))
21249
+ if (!isRecord6(value))
21082
21250
  return void 0;
21083
21251
  const field = value[key];
21084
21252
  if (typeof field === "string") {
@@ -21090,7 +21258,7 @@ function idField(value, key) {
21090
21258
  return void 0;
21091
21259
  }
21092
21260
  function stringField2(value, key) {
21093
- if (!isRecord5(value) || typeof value[key] !== "string")
21261
+ if (!isRecord6(value) || typeof value[key] !== "string")
21094
21262
  return void 0;
21095
21263
  const trimmed = value[key].trim();
21096
21264
  return trimmed.length > 0 ? trimmed : void 0;
@@ -21113,7 +21281,7 @@ function collectIds(value) {
21113
21281
  };
21114
21282
  push(idField(value, "task_id"));
21115
21283
  push(idField(value, "subagent_id"));
21116
- if (isRecord5(value)) {
21284
+ if (isRecord6(value)) {
21117
21285
  const list = value.task_ids ?? value.subagent_ids;
21118
21286
  if (Array.isArray(list)) {
21119
21287
  for (const entry of list)
@@ -21132,7 +21300,7 @@ function grokSubagentOperation(name, title, rawInput) {
21132
21300
  return "send";
21133
21301
  if (SPAWN_TOOL_NAMES.has(id))
21134
21302
  return "spawn";
21135
- if (isRecord5(rawInput) && rawInput.variant === "Task")
21303
+ if (isRecord6(rawInput) && rawInput.variant === "Task")
21136
21304
  return "spawn";
21137
21305
  return null;
21138
21306
  }
@@ -21155,7 +21323,7 @@ function grokSubagentRole(rawInput) {
21155
21323
  return bounded(stringField2(rawInput, "subagent_type") ?? stringField2(rawInput, "agent_type") ?? stringField2(rawInput, "type"), DESCRIPTION_LIMIT);
21156
21324
  }
21157
21325
  function grokSubagentBackground(rawInput) {
21158
- if (!isRecord5(rawInput))
21326
+ if (!isRecord6(rawInput))
21159
21327
  return true;
21160
21328
  if (rawInput.background === false || rawInput.run_in_background === false)
21161
21329
  return false;
@@ -21193,7 +21361,7 @@ function grokSubagentResultSummary(...candidates) {
21193
21361
  return void 0;
21194
21362
  }
21195
21363
  function grokSubagentEventFromUpdate(update) {
21196
- if (!isRecord5(update) || typeof update.sessionUpdate !== "string")
21364
+ if (!isRecord6(update) || typeof update.sessionUpdate !== "string")
21197
21365
  return null;
21198
21366
  const nativeSubagentId = idField(update, "subagent_id") ?? idField(update, "child_session_id");
21199
21367
  if (!nativeSubagentId)
@@ -21254,14 +21422,14 @@ function grokSubagentWaitSettlements(input) {
21254
21422
  return ids.map((id) => ({ id, status: overall }));
21255
21423
  }
21256
21424
  function taskOutputResults(rawOutput) {
21257
- if (!isRecord5(rawOutput))
21425
+ if (!isRecord6(rawOutput))
21258
21426
  return [];
21259
21427
  if (Array.isArray(rawOutput.results)) {
21260
- return rawOutput.results.filter(isRecord5);
21428
+ return rawOutput.results.filter(isRecord6);
21261
21429
  }
21262
21430
  const nested = firstRecord(rawOutput.MultiResult, rawOutput.multiResult, rawOutput.multi_result);
21263
21431
  if (nested && Array.isArray(nested.results)) {
21264
- return nested.results.filter(isRecord5);
21432
+ return nested.results.filter(isRecord6);
21265
21433
  }
21266
21434
  const single = firstRecord(rawOutput.Result, rawOutput.result);
21267
21435
  if (single)
@@ -21272,7 +21440,7 @@ function taskOutputResults(rawOutput) {
21272
21440
  }
21273
21441
  function firstRecord(...values) {
21274
21442
  for (const value of values) {
21275
- if (isRecord5(value))
21443
+ if (isRecord6(value))
21276
21444
  return value;
21277
21445
  }
21278
21446
  return void 0;
@@ -21295,7 +21463,7 @@ function taskOutputTextSettlements(rawOutput, content, ids) {
21295
21463
  return settled;
21296
21464
  }
21297
21465
  function taskOutputStatus(rawOutput, content) {
21298
- if (isRecord5(rawOutput) && typeof rawOutput.status === "string")
21466
+ if (isRecord6(rawOutput) && typeof rawOutput.status === "string")
21299
21467
  return rawOutput.status;
21300
21468
  const text = extractText(content) ?? extractText(rawOutput);
21301
21469
  if (!text)
@@ -21354,7 +21522,7 @@ function extractText(value, depth = 0) {
21354
21522
  const joined = parts.join("\n").trim();
21355
21523
  return joined.length > 0 ? joined : void 0;
21356
21524
  }
21357
- if (!isRecord5(value))
21525
+ if (!isRecord6(value))
21358
21526
  return void 0;
21359
21527
  if (typeof value.text === "string" && value.text.trim().length > 0)
21360
21528
  return value.text.trim();
@@ -21824,11 +21992,11 @@ var GROK_SESSION_DELETE_METHOD = "_x.ai/session/delete";
21824
21992
  function error51(code, message, retryable = false) {
21825
21993
  return { code, message, retryable };
21826
21994
  }
21827
- function isRecord6(value) {
21995
+ function isRecord7(value) {
21828
21996
  return typeof value === "object" && value !== null && !Array.isArray(value);
21829
21997
  }
21830
21998
  function isGrokMethodNotFound(error53) {
21831
- if (isRecord6(error53) && error53.code === -32601)
21999
+ if (isRecord7(error53) && error53.code === -32601)
21832
22000
  return true;
21833
22001
  const message = error53 instanceof Error ? error53.message : String(error53);
21834
22002
  return /method not found/iu.test(message);
@@ -21846,10 +22014,10 @@ function buildGrokForkParams(input) {
21846
22014
  };
21847
22015
  }
21848
22016
  function parseGrokForkResponse(value) {
21849
- if (!isRecord6(value) || value.error !== void 0)
22017
+ if (!isRecord7(value) || value.error !== void 0)
21850
22018
  return null;
21851
- const payload = typeof value.newSessionId !== "string" && isRecord6(value.result) ? value.result : value;
21852
- if (!isRecord6(payload) || payload.error !== void 0)
22019
+ const payload = typeof value.newSessionId !== "string" && isRecord7(value.result) ? value.result : value;
22020
+ if (!isRecord7(payload) || payload.error !== void 0)
21853
22021
  return null;
21854
22022
  if (typeof payload.newSessionId !== "string" || payload.newSessionId.length === 0)
21855
22023
  return null;
@@ -22012,7 +22180,7 @@ var GROK_SESSION_UPDATE_EXTENSION_METHODS = [
22012
22180
  "_x.ai/session/update",
22013
22181
  "x.ai/session_notification"
22014
22182
  ];
22015
- function isRecord7(value) {
22183
+ function isRecord8(value) {
22016
22184
  return typeof value === "object" && value !== null && !Array.isArray(value);
22017
22185
  }
22018
22186
  function optionalNonNegativeInt(value) {
@@ -22033,7 +22201,7 @@ function isGrokExtensionSessionUpdateMethod(method) {
22033
22201
  return GROK_SESSION_UPDATE_EXTENSION_METHODS.includes(method);
22034
22202
  }
22035
22203
  function grokCompactionEventFromUpdate(update) {
22036
- if (!isRecord7(update) || typeof update.sessionUpdate !== "string")
22204
+ if (!isRecord8(update) || typeof update.sessionUpdate !== "string")
22037
22205
  return null;
22038
22206
  const tokensUsed = optionalNonNegativeInt(firstPresent(update, ["tokensUsed", "tokens_used"]));
22039
22207
  const contextWindowTokens = optionalNonNegativeInt(firstPresent(update, ["contextWindowTokens", "contextWindow", "context_window"]));
@@ -22072,7 +22240,7 @@ function grokCompactionEventFromUpdate(update) {
22072
22240
  // dist/grok-manual-compaction.js
22073
22241
  var GROK_COMPACT_CONVERSATION_METHOD = "x.ai/compact_conversation";
22074
22242
  var GROK_COMPACT_CONVERSATION_FALLBACK_METHOD = "_x.ai/compact_conversation";
22075
- function isRecord8(value) {
22243
+ function isRecord9(value) {
22076
22244
  return typeof value === "object" && value !== null && !Array.isArray(value);
22077
22245
  }
22078
22246
  function optionalNonNegativeInt2(value) {
@@ -22084,7 +22252,7 @@ function optionalErrorMessage2(value) {
22084
22252
  function parseGrokCompactResult(value, cancelled = false) {
22085
22253
  if (cancelled)
22086
22254
  return { outcome: "cancelled" };
22087
- if (!isRecord8(value))
22255
+ if (!isRecord9(value))
22088
22256
  return { outcome: "succeeded" };
22089
22257
  const tokensBefore = optionalNonNegativeInt2(value.tokensBefore ?? value.tokens_before);
22090
22258
  const tokensAfter = optionalNonNegativeInt2(value.tokensAfter ?? value.tokens_after);
@@ -22122,7 +22290,7 @@ var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
22122
22290
  function error52(code, message, retryable = false) {
22123
22291
  return { code, message, retryable };
22124
22292
  }
22125
- function isRecord9(value) {
22293
+ function isRecord10(value) {
22126
22294
  return typeof value === "object" && value !== null && !Array.isArray(value);
22127
22295
  }
22128
22296
  function buildGrokRewindParams(input) {
@@ -22134,10 +22302,10 @@ function buildGrokRewindParams(input) {
22134
22302
  };
22135
22303
  }
22136
22304
  function parseGrokRewindResponse(value) {
22137
- if (!isRecord9(value))
22305
+ if (!isRecord10(value))
22138
22306
  return null;
22139
- const payload = typeof value.success !== "boolean" && isRecord9(value.result) ? value.result : value;
22140
- if (!isRecord9(payload) || typeof payload.success !== "boolean")
22307
+ const payload = typeof value.success !== "boolean" && isRecord10(value.result) ? value.result : value;
22308
+ if (!isRecord10(payload) || typeof payload.success !== "boolean")
22141
22309
  return null;
22142
22310
  return rewindPayload(payload);
22143
22311
  }
@@ -22294,16 +22462,16 @@ var GrokTransportError = class extends Error {
22294
22462
  this.name = "GrokTransportError";
22295
22463
  }
22296
22464
  };
22297
- function isRecord10(value) {
22465
+ function isRecord11(value) {
22298
22466
  return typeof value === "object" && value !== null && !Array.isArray(value);
22299
22467
  }
22300
22468
  function acpToolName(update, metadata) {
22301
- if (!isRecord10(update))
22469
+ if (!isRecord11(update))
22302
22470
  return void 0;
22303
22471
  if (typeof update.name === "string" && update.name.length > 0)
22304
22472
  return update.name;
22305
- const meta3 = isRecord10(update._meta) ? update._meta : metadata;
22306
- const tool = meta3 && isRecord10(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
22473
+ const meta3 = isRecord11(update._meta) ? update._meta : metadata;
22474
+ const tool = meta3 && isRecord11(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
22307
22475
  return tool && typeof tool.name === "string" && tool.name.length > 0 ? tool.name : void 0;
22308
22476
  }
22309
22477
  function errorText(error53) {
@@ -22359,7 +22527,7 @@ function signalProcessTree(child, signal) {
22359
22527
  try {
22360
22528
  process.kill(-child.pid, signal);
22361
22529
  } catch (error53) {
22362
- if (!isRecord10(error53) || error53.code !== "ESRCH")
22530
+ if (!isRecord11(error53) || error53.code !== "ESRCH")
22363
22531
  throw error53;
22364
22532
  }
22365
22533
  }
@@ -22454,7 +22622,7 @@ async function readNativeSignals(options, sessionId) {
22454
22622
  }
22455
22623
  }
22456
22624
  function isMissingFile(error53) {
22457
- return isRecord10(error53) && error53.code === "ENOENT";
22625
+ return isRecord11(error53) && error53.code === "ENOENT";
22458
22626
  }
22459
22627
  async function locateGrokNativeSession(options, sessionId) {
22460
22628
  if (sessionId.length === 0)
@@ -22477,7 +22645,7 @@ async function locateGrokNativeSession(options, sessionId) {
22477
22645
  try {
22478
22646
  summaryRaw = await readFile2(path9.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
22479
22647
  } catch (error53) {
22480
- if (isMissingFile(error53) || isRecord10(error53) && error53.code === "ENOTDIR")
22648
+ if (isMissingFile(error53) || isRecord11(error53) && error53.code === "ENOTDIR")
22481
22649
  continue;
22482
22650
  throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
22483
22651
  cause: error53
@@ -22489,10 +22657,10 @@ async function locateGrokNativeSession(options, sessionId) {
22489
22657
  } catch {
22490
22658
  continue;
22491
22659
  }
22492
- if (!isRecord10(parsed))
22660
+ if (!isRecord11(parsed))
22493
22661
  continue;
22494
22662
  const info = parsed.info;
22495
- const cwd = isRecord10(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path9.resolve(info.cwd) : path9.resolve(decodeURIComponent(entry.name));
22663
+ const cwd = isRecord11(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path9.resolve(info.cwd) : path9.resolve(decodeURIComponent(entry.name));
22496
22664
  const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path9.resolve(parsed.source_workspace_dir) : void 0;
22497
22665
  matches.push({
22498
22666
  cwd,
@@ -22525,12 +22693,12 @@ function parseNativeHistory(contents, sessionId) {
22525
22693
  } catch {
22526
22694
  throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
22527
22695
  }
22528
- if (!isRecord10(record2) || !isRecord10(record2.params))
22696
+ if (!isRecord11(record2) || !isRecord11(record2.params))
22529
22697
  continue;
22530
22698
  const params = record2.params;
22531
- if (params.sessionId !== sessionId || !isRecord10(params.update))
22699
+ if (params.sessionId !== sessionId || !isRecord11(params.update))
22532
22700
  continue;
22533
- const metadata = isRecord10(params._meta) ? params._meta : void 0;
22701
+ const metadata = isRecord11(params._meta) ? params._meta : void 0;
22534
22702
  const event = transportEvent(params.update, metadata);
22535
22703
  if (event)
22536
22704
  events.push(metadata ? { ...event, metadata } : event);
@@ -22548,6 +22716,7 @@ var GrokAcpTransport = class {
22548
22716
  #initialize = null;
22549
22717
  #replay = null;
22550
22718
  #sessionId = null;
22719
+ #availableCommands = null;
22551
22720
  #startupModelId;
22552
22721
  #stderrTail = "";
22553
22722
  constructor(options) {
@@ -22835,7 +23004,7 @@ var GrokAcpTransport = class {
22835
23004
  modelId,
22836
23005
  ...reasoningEffort ? { reasoningEffort } : {}
22837
23006
  });
22838
- if (!isRecord10(response) || !isRecord10(response._meta) || !isRecord10(response._meta.model)) {
23007
+ if (!isRecord11(response) || !isRecord11(response._meta) || !isRecord11(response._meta.model)) {
22839
23008
  throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
22840
23009
  }
22841
23010
  const selected = response._meta.model.Ok;
@@ -22875,10 +23044,19 @@ var GrokAcpTransport = class {
22875
23044
  this.#activePrompt = null;
22876
23045
  this.#activeCompact = null;
22877
23046
  }
23047
+ /** Latest ACP `available_commands_update` of the open Session, if any. */
23048
+ get availableCommands() {
23049
+ return this.#availableCommands;
23050
+ }
22878
23051
  #handleUpdate(notification) {
22879
23052
  if (this.#sessionId && notification.sessionId !== this.#sessionId)
22880
23053
  return;
22881
- const metadata = isRecord10(notification._meta) ? notification._meta : void 0;
23054
+ const update = notification.update;
23055
+ if (update.sessionUpdate === "available_commands_update") {
23056
+ this.#availableCommands = parseGrokAvailableCommands(update.availableCommands);
23057
+ return;
23058
+ }
23059
+ const metadata = isRecord11(notification._meta) ? notification._meta : void 0;
22882
23060
  const event = transportEvent(notification.update, metadata);
22883
23061
  if (!event)
22884
23062
  return;
@@ -22893,7 +23071,7 @@ var GrokAcpTransport = class {
22893
23071
  #handleExtensionNotification(method, params) {
22894
23072
  if (!isGrokExtensionSessionUpdateMethod(method))
22895
23073
  return;
22896
- if (typeof params.sessionId !== "string" || !isRecord10(params.update))
23074
+ if (typeof params.sessionId !== "string" || !isRecord11(params.update))
22897
23075
  return;
22898
23076
  this.#handleUpdate(params);
22899
23077
  }
@@ -23103,7 +23281,7 @@ var GrokSubagentLifecycle = class {
23103
23281
  };
23104
23282
 
23105
23283
  // dist/grok-models.js
23106
- function isRecord11(value) {
23284
+ function isRecord12(value) {
23107
23285
  return typeof value === "object" && value !== null && !Array.isArray(value);
23108
23286
  }
23109
23287
  function nonBlank(value) {
@@ -23115,7 +23293,7 @@ function thinkingOptions(value) {
23115
23293
  const seen = /* @__PURE__ */ new Set();
23116
23294
  const options = [];
23117
23295
  for (const candidate of value) {
23118
- if (!isRecord11(candidate) || !nonBlank(candidate.label))
23296
+ if (!isRecord12(candidate) || !nonBlank(candidate.label))
23119
23297
  continue;
23120
23298
  const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
23121
23299
  if (!id.success || seen.has(id.data))
@@ -23126,7 +23304,7 @@ function thinkingOptions(value) {
23126
23304
  return options;
23127
23305
  }
23128
23306
  function parseGrokModelState(value) {
23129
- if (!isRecord11(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
23307
+ if (!isRecord12(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
23130
23308
  return null;
23131
23309
  }
23132
23310
  const currentModel = harnessModelRefSchema.safeParse({ id: value.currentModelId });
@@ -23137,12 +23315,12 @@ function parseGrokModelState(value) {
23137
23315
  const models = [];
23138
23316
  let currentThinkingOptionId;
23139
23317
  for (const candidate of value.availableModels) {
23140
- if (!isRecord11(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
23318
+ if (!isRecord12(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
23141
23319
  continue;
23142
23320
  const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
23143
23321
  if (!ref.success)
23144
23322
  continue;
23145
- const metadata = isRecord11(candidate._meta) ? candidate._meta : {};
23323
+ const metadata = isRecord12(candidate._meta) ? candidate._meta : {};
23146
23324
  const options2 = thinkingOptions(metadata.reasoningEfforts);
23147
23325
  if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
23148
23326
  contextWindowTokensByModel.set(ref.data.id, metadata.totalContextTokens);
@@ -23177,10 +23355,10 @@ function parseGrokModelState(value) {
23177
23355
  };
23178
23356
  }
23179
23357
  function modelStateFromInitialize(response) {
23180
- return parseGrokModelState(isRecord11(response._meta) ? response._meta.modelState : void 0);
23358
+ return parseGrokModelState(isRecord12(response._meta) ? response._meta.modelState : void 0);
23181
23359
  }
23182
23360
  function modelStateFromSessionResponse(response) {
23183
- return parseGrokModelState(isRecord11(response) ? response.models : void 0);
23361
+ return parseGrokModelState(isRecord12(response) ? response.models : void 0);
23184
23362
  }
23185
23363
  function stateForGrokModel(modelState, nativeState, model = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
23186
23364
  const selectedModel = model;
@@ -23204,7 +23382,7 @@ import os5 from "node:os";
23204
23382
  import path10 from "node:path";
23205
23383
  var GROK_CREDITS_ENDPOINT = "https://cli-chat-proxy.grok.com/v1/billing?format=credits";
23206
23384
  var REQUEST_TIMEOUT_MS = 15e3;
23207
- function isRecord12(value) {
23385
+ function isRecord13(value) {
23208
23386
  return typeof value === "object" && value !== null && !Array.isArray(value);
23209
23387
  }
23210
23388
  function finitePercent(value) {
@@ -23213,7 +23391,7 @@ function finitePercent(value) {
23213
23391
  return Math.min(100, Math.max(0, value));
23214
23392
  }
23215
23393
  function nonNegativeCentValue(value) {
23216
- if (!isRecord12(value))
23394
+ if (!isRecord13(value))
23217
23395
  return void 0;
23218
23396
  const amount = value.val === void 0 ? 0 : value.val;
23219
23397
  if (typeof amount !== "number" || !Number.isFinite(amount) || amount < 0)
@@ -23237,7 +23415,7 @@ function productUsageFrom(value) {
23237
23415
  if (!Array.isArray(value))
23238
23416
  return void 0;
23239
23417
  const products = value.flatMap((entry) => {
23240
- if (!isRecord12(entry) || typeof entry.product !== "string")
23418
+ if (!isRecord13(entry) || typeof entry.product !== "string")
23241
23419
  return [];
23242
23420
  const usagePercent = finitePercent(entry.usagePercent);
23243
23421
  return usagePercent === void 0 ? [] : [{ product: entry.product, usagePercent }];
@@ -23245,10 +23423,10 @@ function productUsageFrom(value) {
23245
23423
  return products.length > 0 ? products : void 0;
23246
23424
  }
23247
23425
  function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()).toISOString()) {
23248
- if (!isRecord12(value) || !isRecord12(value.config))
23426
+ if (!isRecord13(value) || !isRecord13(value.config))
23249
23427
  return null;
23250
23428
  const config2 = value.config;
23251
- const period = isRecord12(config2.currentPeriod) ? config2.currentPeriod : void 0;
23429
+ const period = isRecord13(config2.currentPeriod) ? config2.currentPeriod : void 0;
23252
23430
  const periodType = periodTypeFrom(period?.type);
23253
23431
  const resetsAt = (typeof period?.end === "string" && period.end.length > 0 ? period.end : void 0) ?? (typeof config2.billingPeriodEnd === "string" && config2.billingPeriodEnd.length > 0 ? config2.billingPeriodEnd : void 0);
23254
23432
  let usedPercent = finitePercent(config2.creditUsagePercent);
@@ -23275,11 +23453,11 @@ function parseGrokCreditsResponse(value, fetchedAt = (/* @__PURE__ */ new Date()
23275
23453
  };
23276
23454
  }
23277
23455
  function selectAccessToken(auth, now) {
23278
- if (!isRecord12(auth))
23456
+ if (!isRecord13(auth))
23279
23457
  return null;
23280
- const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord12(value) && typeof value.key === "string" && value.key.length > 0).sort(([left], [right]) => Number(right.startsWith("https://auth.x.ai")) - Number(left.startsWith("https://auth.x.ai")));
23458
+ const entries = Object.entries(auth).filter(([issuer, value]) => (issuer === "https://auth.x.ai" || issuer.startsWith("https://auth.x.ai::")) && isRecord13(value) && typeof value.key === "string" && value.key.length > 0).sort(([left], [right]) => Number(right.startsWith("https://auth.x.ai")) - Number(left.startsWith("https://auth.x.ai")));
23281
23459
  for (const [, value] of entries) {
23282
- if (!isRecord12(value) || typeof value.key !== "string")
23460
+ if (!isRecord13(value) || typeof value.key !== "string")
23283
23461
  continue;
23284
23462
  if (typeof value.expires_at === "string") {
23285
23463
  const expiresAt = Date.parse(value.expires_at);
@@ -23350,7 +23528,7 @@ async function fetchGrokCredits(input = {}) {
23350
23528
 
23351
23529
  // dist/grok-usage.js
23352
23530
  var USD_TICKS_PER_DOLLAR = 1e10;
23353
- function isRecord13(value) {
23531
+ function isRecord14(value) {
23354
23532
  return typeof value === "object" && value !== null && !Array.isArray(value);
23355
23533
  }
23356
23534
  function optionalToken(value) {
@@ -23367,7 +23545,7 @@ function combineUsage(base, next) {
23367
23545
  return base === null ? next : parseHostUsage({ ...base, ...next });
23368
23546
  }
23369
23547
  function usageFromNative(value) {
23370
- if (!isRecord13(value))
23548
+ if (!isRecord14(value))
23371
23549
  return null;
23372
23550
  const inputTokens = optionalToken(value.inputTokens);
23373
23551
  const cachedRead = optionalToken(value.cachedReadTokens);
@@ -23394,7 +23572,7 @@ function usageFromPrompt(response) {
23394
23572
  return response.usage ? usageFromNative(response.usage) : null;
23395
23573
  }
23396
23574
  function usageFromSignals(value) {
23397
- if (!isRecord13(value))
23575
+ if (!isRecord14(value))
23398
23576
  return null;
23399
23577
  try {
23400
23578
  return parseHostUsage({
@@ -23414,7 +23592,7 @@ var summedUsageFields = [
23414
23592
  "totalTokens"
23415
23593
  ];
23416
23594
  function nativeCostTicks(value) {
23417
- if (!isRecord13(value))
23595
+ if (!isRecord14(value))
23418
23596
  return void 0;
23419
23597
  const ticks = value.costUsdTicks;
23420
23598
  if (typeof ticks !== "number" || !Number.isSafeInteger(ticks) || ticks < 0)
@@ -23491,7 +23669,7 @@ function usageFromCompact(tokensAfter, contextWindowTokens) {
23491
23669
  function usageFromUpdate(update, metadata, contextWindowTokens) {
23492
23670
  try {
23493
23671
  if (update?.sessionUpdate === "usage_update") {
23494
- const cost = isRecord13(update.cost) ? update.cost : null;
23672
+ const cost = isRecord14(update.cost) ? update.cost : null;
23495
23673
  return parseHostUsage({
23496
23674
  contextUsedTokens: update.used,
23497
23675
  contextWindowTokens: update.size,
@@ -23637,7 +23815,7 @@ var GrokHarnessSession = class {
23637
23815
  this.#usage = this.initialUsage;
23638
23816
  this.capabilities = capabilitiesForModels(modelState);
23639
23817
  this.commands = {
23640
- list: async () => ({ ok: true, value: grokCommandCatalog }),
23818
+ list: async () => ({ ok: true, value: this.#liveCommandCatalog() }),
23641
23819
  execute: (command) => this.#executeHarnessCommand(command)
23642
23820
  };
23643
23821
  this.#state = stateForGrokModel(modelState, { nativeRef: nativeRef(opened.sessionId) }, modelState.currentModel, modelState.currentThinkingOptionId, options.initialPermissionModeId);
@@ -23749,7 +23927,21 @@ var GrokHarnessSession = class {
23749
23927
  }));
23750
23928
  return { ok: true, value: { turnId: command.turnId } };
23751
23929
  }
23930
+ /** Built-ins plus the commands, workflows and skills the open Session advertises. */
23931
+ #liveCommandCatalog() {
23932
+ const native = this.#transport.availableCommands ?? null;
23933
+ return mergeLiveHarnessCommands(grokCommandCatalog, GROK_LIVE_COMMAND_ID_PREFIX, native ? grokLiveCommands(native) : null);
23934
+ }
23752
23935
  async #executeHarnessCommand(command) {
23936
+ const livePrompt = liveHarnessCommandPrompt(this.#liveCommandCatalog(), GROK_LIVE_COMMAND_ID_PREFIX, command.commandId, command.arguments?.text);
23937
+ if (livePrompt !== null) {
23938
+ const started = await this.execute({
23939
+ type: "turn.start",
23940
+ turnId: command.turnId,
23941
+ input: [{ type: "text", text: livePrompt }]
23942
+ });
23943
+ return started.ok ? { ok: true, value: { turnId: command.turnId } } : started;
23944
+ }
23753
23945
  if (command.commandId !== "grok.compact") {
23754
23946
  return {
23755
23947
  ok: false,
@@ -24487,6 +24679,7 @@ var GrokAdapter = class {
24487
24679
  read: () => this.#closePromise ? Promise.resolve([]) : readGrokCredentials(this.#environment ?? process.env)
24488
24680
  };
24489
24681
  commandCatalog = grokCommandCatalog;
24682
+ liveCommandCatalog = true;
24490
24683
  harnessId = grokHarnessId;
24491
24684
  subagents = {
24492
24685
  readSnapshot: async (input) => {