@liberseek/boft-cli-linux-x64 0.8.7 → 0.8.9

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 (67) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +59 -6
  4. package/app/console-web.js +1376 -1053
  5. package/app/desktop-controller.mjs +239 -57
  6. package/app/host-runtime.mjs +32921 -24901
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +9491 -4266
  9. package/app/plugins/claude-code/plugin.mjs +580 -116
  10. package/app/plugins/codebuddy/plugin.mjs +85 -8
  11. package/app/plugins/codex-usage/plugin.mjs +70 -6
  12. package/app/plugins/copilot/plugin.mjs +62 -6
  13. package/app/plugins/cursor-cli/plugin.mjs +62 -6
  14. package/app/plugins/deepseek-harness/plugin.mjs +87 -11
  15. package/app/plugins/devin/plugin.mjs +61 -6
  16. package/app/plugins/grok/plugin.mjs +320 -223
  17. package/app/plugins/hermes/plugin.mjs +61 -6
  18. package/app/plugins/kimi-code/plugin.mjs +87 -16
  19. package/app/plugins/kiro-cli/plugin.mjs +62 -6
  20. package/app/plugins/muse/plugin.mjs +61 -6
  21. package/app/plugins/omp/plugin.mjs +195 -31
  22. package/app/plugins/opencode/plugin.mjs +88 -15
  23. package/app/plugins/pi/plugin.mjs +207 -32
  24. package/app/plugins/qoder/plugin.mjs +99 -7
  25. package/app/plugins/qoder-cn/plugin.mjs +99 -7
  26. package/app/plugins/qwen-code/plugin.mjs +62 -6
  27. package/app/plugins/workbuddy/plugin.mjs +89 -11
  28. package/app/plugins/zcode/plugin.mjs +70 -6
  29. package/app/renderer-extension.js +1767 -1187
  30. package/app/web/assets/index-C2OA-eHT.js +201 -0
  31. package/app/web/assets/index-DJW4bmyx.css +1 -0
  32. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  33. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  34. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  35. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  36. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  37. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  38. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  39. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  40. package/app/web/codexhost-settings.js +1383 -1056
  41. package/app/web/index.html +4 -3
  42. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +11 -11
  45. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +3 -3
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +28 -28
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  57. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  58. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  59. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  60. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  61. package/app/web-modules/server.mjs +2458 -1615
  62. package/bin/boft +0 -0
  63. package/libexec/boft-shim +0 -0
  64. package/libexec/boft-updater +0 -0
  65. package/package.json +1 -1
  66. package/app/web/assets/index-CP6wY-1D.css +0 -1
  67. package/app/web/assets/index-Da35Phrd.js +0 -199
@@ -15023,13 +15023,25 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
15023
15023
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15024
15024
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
15025
15025
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15026
+ var usageOutputTimingSchema = external_exports.object({
15027
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
15028
+ requestId: external_exports.string().min(1),
15029
+ turnId: external_exports.string().min(1).max(1024),
15030
+ outputTokens: nonNegativeSafeIntegerSchema,
15031
+ startedAtMs: nonNegativeSafeIntegerSchema,
15032
+ completedAtMs: nonNegativeSafeIntegerSchema
15033
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
15026
15034
  var usageMeasurementSchema = external_exports.object({
15035
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
15027
15036
  value: finiteNonNegativeNumberSchema,
15028
15037
  turnId: external_exports.string().min(1).max(1024),
15029
15038
  at: nonNegativeSafeIntegerSchema
15030
15039
  }).strict();
15031
15040
  var usageMeasurementsSchema = external_exports.object({
15032
- outputTokensPerSecond: usageMeasurementSchema.optional(),
15041
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
15042
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
15043
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
15044
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
15033
15045
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
15034
15046
  }).strict();
15035
15047
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -15049,6 +15061,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15049
15061
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
15050
15062
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
15051
15063
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15064
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15052
15065
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15053
15066
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
15054
15067
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15480,11 +15493,19 @@ var threadSteeringInspectResultSchema = external_exports.object({
15480
15493
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15481
15494
  }).strict();
15482
15495
 
15496
+ // ../../shared-contracts/dist/thread-archive-confirm.js
15497
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15498
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15499
+
15483
15500
  // ../../shared-contracts/dist/client-channel.js
15484
15501
  var CLIENT_CHANNEL_VERSION = 1;
15485
15502
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15486
15503
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15487
15504
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15505
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
15506
+ var clientThreadTreeSchema = external_exports.object({
15507
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
15508
+ }).strict();
15488
15509
  var clientProjectlessWorkspaceSchema = external_exports.object({
15489
15510
  prompt: external_exports.string().max(16384).optional()
15490
15511
  }).strict();
@@ -15506,6 +15527,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15506
15527
  cursor: clientChannelCursorSchema,
15507
15528
  cwd: external_exports.string().optional()
15508
15529
  }),
15530
+ external_exports.object({
15531
+ type: external_exports.literal("harness-inspection-changed"),
15532
+ cursor: clientChannelCursorSchema,
15533
+ harnessId: external_exports.string().min(1)
15534
+ }),
15509
15535
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15510
15536
  external_exports.object({
15511
15537
  type: external_exports.literal("preferences-changed"),
@@ -15577,6 +15603,8 @@ var clientItemTruncationSchema = external_exports.object({
15577
15603
  var clientTurnSchema = external_exports.object({
15578
15604
  id: external_exports.string().min(1),
15579
15605
  status: external_exports.string().min(1),
15606
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15607
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15580
15608
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15581
15609
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15582
15610
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -15615,7 +15643,12 @@ var clientThreadSnapshotSchema = external_exports.object({
15615
15643
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15616
15644
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15617
15645
  /** Most recent explicit command in this Host process; not native conversation history. */
15618
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15646
+ command: external_exports.object({
15647
+ name: external_exports.string().min(1),
15648
+ turn: clientTurnSchema,
15649
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15650
+ subsequentTurnId: external_exports.string().min(1).optional()
15651
+ }).optional(),
15619
15652
  thread: external_exports.object({
15620
15653
  id: external_exports.string().min(1),
15621
15654
  cwd: external_exports.string(),
@@ -15823,15 +15856,14 @@ var webAccessStateSchema = external_exports.object({
15823
15856
  quotaUntil: external_exports.string().optional()
15824
15857
  }).strict().optional()
15825
15858
  }).strict();
15826
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
15827
15859
 
15828
15860
  // ../../shared-contracts/dist/delegation-read.js
15829
15861
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
15830
15862
  var delegationReadParamsSchema = external_exports.strictObject({
15831
15863
  threadId: external_exports.string().min(1).max(1024),
15832
15864
  view: external_exports.enum(["result", "messages"]),
15833
- cursor: external_exports.string().min(1).max(8192).optional(),
15834
- limit: external_exports.number().int().min(1).max(100).optional()
15865
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
15866
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
15835
15867
  });
15836
15868
 
15837
15869
  // ../../shared-contracts/dist/credential-imports.js
@@ -16816,6 +16848,7 @@ var THREAD_WATCH_NOTICE_OUTCOMES = [
16816
16848
  "completed",
16817
16849
  "failed",
16818
16850
  "interrupted",
16851
+ "needsInput",
16819
16852
  "timedOut",
16820
16853
  "unreadable",
16821
16854
  "notFound"
@@ -16862,13 +16895,26 @@ var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
16862
16895
  var thread = { ...target, threadId: identity };
16863
16896
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16864
16897
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
16898
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
16865
16899
  external_exports.strictObject({
16866
16900
  kind: external_exports.literal("list"),
16867
16901
  ...target,
16868
16902
  cursor: external_exports.string().nullable(),
16869
16903
  archived: external_exports.boolean()
16870
16904
  }),
16871
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16905
+ external_exports.strictObject({
16906
+ kind: external_exports.literal("read"),
16907
+ ...thread,
16908
+ page: external_exports.strictObject({
16909
+ cursor: external_exports.string().min(1).max(8192).nullable(),
16910
+ epoch: identity.optional(),
16911
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
16912
+ limit: external_exports.number().int().min(1).max(20).optional()
16913
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
16914
+ message: "A history continuation requires its connection epoch"
16915
+ }).optional()
16916
+ }),
16917
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
16872
16918
  external_exports.strictObject({
16873
16919
  kind: external_exports.literal("configure"),
16874
16920
  ...thread,
@@ -16949,6 +16995,13 @@ var remoteConnectionsReplySchema = external_exports.union([
16949
16995
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16950
16996
  ]);
16951
16997
 
16998
+ // ../../shared-contracts/dist/thread-title.js
16999
+ var threadTitleInputSchema = external_exports.strictObject({
17000
+ prompt: external_exports.string().trim().min(1).max(2e3),
17001
+ cwd: external_exports.string().max(4096).nullable()
17002
+ });
17003
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
17004
+
16952
17005
  // ../../shared-contracts/dist/web-ui-extensions.js
16953
17006
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
16954
17007
  var localizedTextSchema2 = external_exports.union([
@@ -17138,6 +17191,7 @@ var usageFields = /* @__PURE__ */ new Set([
17138
17191
  "totalCredits",
17139
17192
  "contextUsagePercent",
17140
17193
  "outputTokensPerSecond",
17194
+ "sessionOutputTokensPerSecond",
17141
17195
  "apiOutputTokensPerSecond",
17142
17196
  "costSource",
17143
17197
  "unpricedModels"
@@ -17160,6 +17214,7 @@ function parseHostUsage(value) {
17160
17214
  for (const field2 of [
17161
17215
  "totalCredits",
17162
17216
  "contextUsagePercent",
17217
+ "sessionOutputTokensPerSecond",
17163
17218
  "apiOutputTokensPerSecond"
17164
17219
  ]) {
17165
17220
  const candidate = value[field2];
@@ -17244,6 +17299,7 @@ var requestTokenFields = [
17244
17299
  "cacheWrite1hInputTokens",
17245
17300
  "outputTokens",
17246
17301
  "reasoningOutputTokens",
17302
+ "timedOutputTokens",
17247
17303
  "startedAtMs",
17248
17304
  "completedAtMs"
17249
17305
  ];
@@ -22218,6 +22274,128 @@ function grokLiveCommands(native) {
22218
22274
  }));
22219
22275
  }
22220
22276
 
22277
+ // dist/grok-models.js
22278
+ function isRecord5(value) {
22279
+ return typeof value === "object" && value !== null && !Array.isArray(value);
22280
+ }
22281
+ function nonBlank(value) {
22282
+ return typeof value === "string" && value.trim().length > 0;
22283
+ }
22284
+ var ENCODED_MODEL_REF_PREFIX = "grok-model~";
22285
+ function encodeGrokModelRef(modelId2) {
22286
+ if (!nonBlank(modelId2) || modelId2.length > HARNESS_MODEL_REF_MAX_LENGTH || new RegExp("\\p{Cc}", "u").test(modelId2))
22287
+ return null;
22288
+ const direct = harnessModelRefSchema.safeParse({ id: modelId2 });
22289
+ if (direct.success && !modelId2.startsWith(ENCODED_MODEL_REF_PREFIX))
22290
+ return direct.data;
22291
+ const encoded = harnessModelRefSchema.safeParse({
22292
+ id: `${ENCODED_MODEL_REF_PREFIX}${Buffer.from(modelId2, "utf8").toString("base64url")}`
22293
+ });
22294
+ return encoded.success ? encoded.data : null;
22295
+ }
22296
+ function decodeGrokModelRef(ref) {
22297
+ const { id } = harnessModelRefSchema.parse(ref);
22298
+ if (!id.startsWith(ENCODED_MODEL_REF_PREFIX))
22299
+ return id;
22300
+ const modelId2 = Buffer.from(id.slice(ENCODED_MODEL_REF_PREFIX.length), "base64url").toString("utf8");
22301
+ if (encodeGrokModelRef(modelId2)?.id !== id)
22302
+ throw new Error("Invalid Grok Model Ref");
22303
+ return modelId2;
22304
+ }
22305
+ function thinkingOptions(value) {
22306
+ if (!Array.isArray(value))
22307
+ return [];
22308
+ const seen = /* @__PURE__ */ new Set();
22309
+ const options = [];
22310
+ for (const candidate of value) {
22311
+ if (!isRecord5(candidate) || !nonBlank(candidate.label))
22312
+ continue;
22313
+ const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
22314
+ if (!id.success || seen.has(id.data))
22315
+ continue;
22316
+ seen.add(id.data);
22317
+ options.push({ id: id.data, label: candidate.label });
22318
+ }
22319
+ return options;
22320
+ }
22321
+ function parseGrokModelState(value) {
22322
+ if (!isRecord5(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
22323
+ return null;
22324
+ }
22325
+ const currentModel = encodeGrokModelRef(value.currentModelId);
22326
+ if (!currentModel)
22327
+ return null;
22328
+ const allThinking = /* @__PURE__ */ new Map();
22329
+ const contextWindowTokensByModel = /* @__PURE__ */ new Map();
22330
+ const defaultContextWindowTokensByModel = /* @__PURE__ */ new Map();
22331
+ const models = [];
22332
+ let currentThinkingOptionId;
22333
+ for (const candidate of value.availableModels) {
22334
+ if (!isRecord5(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
22335
+ continue;
22336
+ const ref = encodeGrokModelRef(candidate.modelId);
22337
+ if (!ref)
22338
+ continue;
22339
+ const metadata = isRecord5(candidate._meta) ? candidate._meta : {};
22340
+ const options2 = thinkingOptions(metadata.reasoningEfforts);
22341
+ if (Array.isArray(metadata.contextWindows) && metadata.contextWindows.includes(5e5)) {
22342
+ defaultContextWindowTokensByModel.set(ref.id, 5e5);
22343
+ }
22344
+ if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
22345
+ contextWindowTokensByModel.set(ref.id, metadata.totalContextTokens);
22346
+ }
22347
+ for (const option of options2)
22348
+ allThinking.set(option.id, option);
22349
+ if (candidate.modelId === value.currentModelId && nonBlank(metadata.reasoningEffort)) {
22350
+ const parsed = harnessThinkingOptionIdSchema.safeParse(metadata.reasoningEffort);
22351
+ if (parsed.success && options2.some(({ id }) => id === parsed.data)) {
22352
+ currentThinkingOptionId = parsed.data;
22353
+ }
22354
+ }
22355
+ models.push({
22356
+ ref,
22357
+ label: candidate.name,
22358
+ ...options2.length > 0 ? { supportedThinkingOptionIds: options2.map(({ id }) => id) } : {}
22359
+ });
22360
+ }
22361
+ if (!models.some(({ ref }) => ref.id === currentModel.id))
22362
+ return null;
22363
+ const options = [...allThinking.values()];
22364
+ return {
22365
+ currentModel,
22366
+ contextWindowTokensByModel,
22367
+ defaultContextWindowTokensByModel,
22368
+ ...currentThinkingOptionId ? { currentThinkingOptionId } : {},
22369
+ catalog: {
22370
+ models,
22371
+ defaultModel: currentModel,
22372
+ thinkingOptions: options,
22373
+ ...currentThinkingOptionId ? { defaultThinkingOptionId: currentThinkingOptionId } : {}
22374
+ }
22375
+ };
22376
+ }
22377
+ function modelStateFromInitialize(response) {
22378
+ return parseGrokModelState(isRecord5(response._meta) ? response._meta.modelState : void 0);
22379
+ }
22380
+ function modelStateFromSessionResponse(response) {
22381
+ return parseGrokModelState(isRecord5(response) ? response.models : void 0);
22382
+ }
22383
+ function stateForGrokModel(modelState, nativeState, model2 = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
22384
+ const selectedModel = model2;
22385
+ const catalogModel = modelState.catalog.models.find(({ ref }) => ref.id === selectedModel.id);
22386
+ const availableThinkingOptions = catalogModel?.supportedThinkingOptionIds?.flatMap((id) => {
22387
+ const option = modelState.catalog.thinkingOptions.find((candidate) => candidate.id === id);
22388
+ return option ? [option] : [];
22389
+ });
22390
+ return {
22391
+ ...nativeState,
22392
+ effectiveModel: selectedModel,
22393
+ ...thinkingOptionId ? { effectiveThinkingOptionId: thinkingOptionId } : {},
22394
+ ...permissionModeId ? { effectivePermissionModeId: permissionModeId } : {},
22395
+ ...availableThinkingOptions ? { availableThinkingOptions } : {}
22396
+ };
22397
+ }
22398
+
22221
22399
  // dist/command.js
22222
22400
  import path8 from "node:path";
22223
22401
  var GrokExecutableError = class extends Error {
@@ -22684,7 +22862,7 @@ function splitLines(text) {
22684
22862
  // dist/grok-file-change.js
22685
22863
  var DEFAULT_GROK_FILE_CHANGE_TEXT_LIMIT = 4 * 1024 * 1024;
22686
22864
  var MAX_GROK_FILE_CHANGES_PER_TOOL = 32;
22687
- function isRecord5(value) {
22865
+ function isRecord6(value) {
22688
22866
  return typeof value === "object" && value !== null && !Array.isArray(value);
22689
22867
  }
22690
22868
  function validAbsolutePath(value) {
@@ -22735,7 +22913,7 @@ function projectGrokFileChanges(content, cwd, textLimit = DEFAULT_GROK_FILE_CHAN
22735
22913
  return null;
22736
22914
  const candidates = [];
22737
22915
  for (const entry of content) {
22738
- if (isRecord5(entry) && entry.type === "diff")
22916
+ if (isRecord6(entry) && entry.type === "diff")
22739
22917
  candidates.push(entry);
22740
22918
  }
22741
22919
  if (candidates.length === 0 || candidates.length > MAX_GROK_FILE_CHANGES_PER_TOOL)
@@ -22772,14 +22950,14 @@ function grokMediaResolveRoots(cwd, sessionDirectory) {
22772
22950
  // dist/grok-tool-output.js
22773
22951
  var DEFAULT_GROK_TOOL_OUTPUT_LIMIT = 64e3;
22774
22952
  var EXECUTE_TOOL_NAMES = /* @__PURE__ */ new Set(["bash", "run_terminal_command", "shell", "cursor_shell"]);
22775
- function isRecord6(value) {
22953
+ function isRecord7(value) {
22776
22954
  return typeof value === "object" && value !== null && !Array.isArray(value);
22777
22955
  }
22778
22956
  function stringField(value, key) {
22779
- return isRecord6(value) && typeof value[key] === "string" && value[key].length > 0 ? value[key] : void 0;
22957
+ return isRecord7(value) && typeof value[key] === "string" && value[key].length > 0 ? value[key] : void 0;
22780
22958
  }
22781
22959
  function numberField(value, key) {
22782
- if (!isRecord6(value))
22960
+ if (!isRecord7(value))
22783
22961
  return void 0;
22784
22962
  const field2 = value[key];
22785
22963
  if (field2 === null)
@@ -22802,7 +22980,7 @@ function firstReadableText(...candidates) {
22802
22980
  for (const candidate of candidates) {
22803
22981
  if (typeof candidate === "string" && candidate.length > 0)
22804
22982
  return candidate;
22805
- if (isRecord6(candidate)) {
22983
+ if (isRecord7(candidate)) {
22806
22984
  const nested = stringField(candidate, "content") ?? stringField(candidate, "text") ?? stringField(candidate, "tool_result") ?? stringField(candidate, "raw_output");
22807
22985
  if (nested)
22808
22986
  return nested;
@@ -22825,7 +23003,7 @@ function grokToolArguments(rawInput) {
22825
23003
  if (!parsed.success)
22826
23004
  return {};
22827
23005
  const argumentsValue = parsed.data;
22828
- if (!isRecord6(argumentsValue) || stringField(argumentsValue, "path"))
23006
+ if (!isRecord7(argumentsValue) || stringField(argumentsValue, "path"))
22829
23007
  return argumentsValue;
22830
23008
  const targetFile = stringField(argumentsValue, "target_file");
22831
23009
  return targetFile ? { ...argumentsValue, path: targetFile } : argumentsValue;
@@ -22838,7 +23016,7 @@ function grokCommand(name, kind, rawInput) {
22838
23016
  return command;
22839
23017
  if (name && EXECUTE_TOOL_NAMES.has(name))
22840
23018
  return command;
22841
- return isRecord6(rawInput) && rawInput.variant === "Bash" ? command : void 0;
23019
+ return isRecord7(rawInput) && rawInput.variant === "Bash" ? command : void 0;
22842
23020
  }
22843
23021
  function grokCommandCwd(rawInput, fallback) {
22844
23022
  return stringField(rawInput, "cwd") ?? fallback;
@@ -22865,11 +23043,11 @@ function acpContentText(content) {
22865
23043
  if (!Array.isArray(content))
22866
23044
  return "";
22867
23045
  return content.flatMap((entry) => {
22868
- if (!isRecord6(entry))
23046
+ if (!isRecord7(entry))
22869
23047
  return [];
22870
23048
  if (entry.type === "text" && typeof entry.text === "string")
22871
23049
  return [entry.text];
22872
- if (entry.type !== "content" || !isRecord6(entry.content))
23050
+ if (entry.type !== "content" || !isRecord7(entry.content))
22873
23051
  return [];
22874
23052
  return entry.content.type === "text" && typeof entry.content.text === "string" ? [entry.content.text] : [];
22875
23053
  }).join("\n");
@@ -22880,10 +23058,10 @@ function acpContentImages(content, remainingBytes) {
22880
23058
  const images = [];
22881
23059
  let remaining = remainingBytes;
22882
23060
  for (const entry of content) {
22883
- if (!isRecord6(entry))
23061
+ if (!isRecord7(entry))
22884
23062
  continue;
22885
23063
  const image = entry.type === "image" ? entry : entry.type === "content" ? entry.content : null;
22886
- if (!isRecord6(image) || image.type !== "image")
23064
+ if (!isRecord7(image) || image.type !== "image")
22887
23065
  continue;
22888
23066
  const mimeType = stringField(image, "mimeType") ?? stringField(image, "mime_type");
22889
23067
  const data = stringField(image, "data");
@@ -22906,14 +23084,14 @@ function bashOutput(rawOutput) {
22906
23084
  function rawOutputProjection(rawOutput) {
22907
23085
  if (typeof rawOutput === "string")
22908
23086
  return rawOutput.length > 0 ? { text: rawOutput } : {};
22909
- if (!isRecord6(rawOutput))
23087
+ if (!isRecord7(rawOutput))
22910
23088
  return {};
22911
23089
  if (rawOutput.type === "Bash" || rawOutput.variant === "Bash" || numberField(rawOutput, "exit_code") !== void 0 || numberField(rawOutput, "exitCode") !== void 0) {
22912
23090
  const bash = bashOutput(rawOutput);
22913
23091
  if (bash.text !== void 0 || bash.exitCode !== void 0)
22914
23092
  return bash;
22915
23093
  }
22916
- const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord6(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord6(rawOutput.Content) ? rawOutput.Content : void 0);
23094
+ const text = firstReadableText(rawOutput.content, rawOutput.text, rawOutput.tool_result, rawOutput.raw_output, isRecord7(rawOutput.FileContent) ? rawOutput.FileContent : void 0, isRecord7(rawOutput.Content) ? rawOutput.Content : void 0);
22917
23095
  if (text)
22918
23096
  return { text };
22919
23097
  if (typeof rawOutput.match_count === "number" && Number.isFinite(rawOutput.match_count)) {
@@ -22977,11 +23155,11 @@ var WAIT_TOOL_NAMES = /* @__PURE__ */ new Set([
22977
23155
  var KILL_TOOL_NAMES = /* @__PURE__ */ new Set(["kill_command_or_subagent", "kill_task"]);
22978
23156
  var DESCRIPTION_LIMIT = 500;
22979
23157
  var SUMMARY_LIMIT = 2e3;
22980
- function isRecord7(value) {
23158
+ function isRecord8(value) {
22981
23159
  return typeof value === "object" && value !== null && !Array.isArray(value);
22982
23160
  }
22983
23161
  function idField(value, key) {
22984
- if (!isRecord7(value))
23162
+ if (!isRecord8(value))
22985
23163
  return void 0;
22986
23164
  const field2 = value[key];
22987
23165
  if (typeof field2 === "string") {
@@ -22993,7 +23171,7 @@ function idField(value, key) {
22993
23171
  return void 0;
22994
23172
  }
22995
23173
  function stringField2(value, key) {
22996
- if (!isRecord7(value) || typeof value[key] !== "string")
23174
+ if (!isRecord8(value) || typeof value[key] !== "string")
22997
23175
  return void 0;
22998
23176
  const trimmed = value[key].trim();
22999
23177
  return trimmed.length > 0 ? trimmed : void 0;
@@ -23016,7 +23194,7 @@ function collectIds(value) {
23016
23194
  };
23017
23195
  push(idField(value, "task_id"));
23018
23196
  push(idField(value, "subagent_id"));
23019
- if (isRecord7(value)) {
23197
+ if (isRecord8(value)) {
23020
23198
  const list = value.task_ids ?? value.subagent_ids;
23021
23199
  if (Array.isArray(list)) {
23022
23200
  for (const entry of list)
@@ -23035,7 +23213,7 @@ function grokSubagentOperation(name, title, rawInput) {
23035
23213
  return "send";
23036
23214
  if (SPAWN_TOOL_NAMES.has(id))
23037
23215
  return "spawn";
23038
- if (isRecord7(rawInput) && rawInput.variant === "Task")
23216
+ if (isRecord8(rawInput) && rawInput.variant === "Task")
23039
23217
  return "spawn";
23040
23218
  return null;
23041
23219
  }
@@ -23058,7 +23236,7 @@ function grokSubagentRole(rawInput) {
23058
23236
  return bounded(stringField2(rawInput, "subagent_type") ?? stringField2(rawInput, "agent_type") ?? stringField2(rawInput, "type"), DESCRIPTION_LIMIT);
23059
23237
  }
23060
23238
  function grokSubagentBackground(rawInput) {
23061
- if (!isRecord7(rawInput))
23239
+ if (!isRecord8(rawInput))
23062
23240
  return true;
23063
23241
  if (rawInput.background === false || rawInput.run_in_background === false)
23064
23242
  return false;
@@ -23096,7 +23274,7 @@ function grokSubagentResultSummary(...candidates) {
23096
23274
  return void 0;
23097
23275
  }
23098
23276
  function grokSubagentEventFromUpdate(update) {
23099
- if (!isRecord7(update) || typeof update.sessionUpdate !== "string")
23277
+ if (!isRecord8(update) || typeof update.sessionUpdate !== "string")
23100
23278
  return null;
23101
23279
  const nativeSubagentId = idField(update, "subagent_id") ?? idField(update, "child_session_id");
23102
23280
  if (!nativeSubagentId)
@@ -23157,14 +23335,14 @@ function grokSubagentWaitSettlements(input) {
23157
23335
  return ids.map((id) => ({ id, status: overall }));
23158
23336
  }
23159
23337
  function taskOutputResults(rawOutput) {
23160
- if (!isRecord7(rawOutput))
23338
+ if (!isRecord8(rawOutput))
23161
23339
  return [];
23162
23340
  if (Array.isArray(rawOutput.results)) {
23163
- return rawOutput.results.filter(isRecord7);
23341
+ return rawOutput.results.filter(isRecord8);
23164
23342
  }
23165
23343
  const nested = firstRecord(rawOutput.MultiResult, rawOutput.multiResult, rawOutput.multi_result);
23166
23344
  if (nested && Array.isArray(nested.results)) {
23167
- return nested.results.filter(isRecord7);
23345
+ return nested.results.filter(isRecord8);
23168
23346
  }
23169
23347
  const single = firstRecord(rawOutput.Result, rawOutput.result);
23170
23348
  if (single)
@@ -23175,7 +23353,7 @@ function taskOutputResults(rawOutput) {
23175
23353
  }
23176
23354
  function firstRecord(...values) {
23177
23355
  for (const value of values) {
23178
- if (isRecord7(value))
23356
+ if (isRecord8(value))
23179
23357
  return value;
23180
23358
  }
23181
23359
  return void 0;
@@ -23198,7 +23376,7 @@ function taskOutputTextSettlements(rawOutput, content, ids) {
23198
23376
  return settled;
23199
23377
  }
23200
23378
  function taskOutputStatus(rawOutput, content) {
23201
- if (isRecord7(rawOutput) && typeof rawOutput.status === "string")
23379
+ if (isRecord8(rawOutput) && typeof rawOutput.status === "string")
23202
23380
  return rawOutput.status;
23203
23381
  const text = extractText(content) ?? extractText(rawOutput);
23204
23382
  if (!text)
@@ -23257,7 +23435,7 @@ function extractText(value, depth = 0) {
23257
23435
  const joined = parts.join("\n").trim();
23258
23436
  return joined.length > 0 ? joined : void 0;
23259
23437
  }
23260
- if (!isRecord7(value))
23438
+ if (!isRecord8(value))
23261
23439
  return void 0;
23262
23440
  if (typeof value.text === "string" && value.text.trim().length > 0)
23263
23441
  return value.text.trim();
@@ -23728,11 +23906,11 @@ var GROK_SESSION_DELETE_METHOD = "_x.ai/session/delete";
23728
23906
  function error51(code, message, retryable = false) {
23729
23907
  return { code, message, retryable };
23730
23908
  }
23731
- function isRecord8(value) {
23909
+ function isRecord9(value) {
23732
23910
  return typeof value === "object" && value !== null && !Array.isArray(value);
23733
23911
  }
23734
23912
  function isGrokMethodNotFound(error53) {
23735
- if (isRecord8(error53) && error53.code === -32601)
23913
+ if (isRecord9(error53) && error53.code === -32601)
23736
23914
  return true;
23737
23915
  const message = error53 instanceof Error ? error53.message : String(error53);
23738
23916
  return /method not found/iu.test(message);
@@ -23750,10 +23928,10 @@ function buildGrokForkParams(input) {
23750
23928
  };
23751
23929
  }
23752
23930
  function parseGrokForkResponse(value) {
23753
- if (!isRecord8(value) || value.error !== void 0)
23931
+ if (!isRecord9(value) || value.error !== void 0)
23754
23932
  return null;
23755
- const payload = typeof value.newSessionId !== "string" && isRecord8(value.result) ? value.result : value;
23756
- if (!isRecord8(payload) || payload.error !== void 0)
23933
+ const payload = typeof value.newSessionId !== "string" && isRecord9(value.result) ? value.result : value;
23934
+ if (!isRecord9(payload) || payload.error !== void 0)
23757
23935
  return null;
23758
23936
  if (typeof payload.newSessionId !== "string" || payload.newSessionId.length === 0)
23759
23937
  return null;
@@ -23917,7 +24095,7 @@ var GROK_SESSION_UPDATE_EXTENSION_METHODS = [
23917
24095
  "x.ai/session_notification",
23918
24096
  "_x.ai/session_notification"
23919
24097
  ];
23920
- function isRecord9(value) {
24098
+ function isRecord10(value) {
23921
24099
  return typeof value === "object" && value !== null && !Array.isArray(value);
23922
24100
  }
23923
24101
  function optionalNonNegativeInt(value) {
@@ -23938,7 +24116,7 @@ function isGrokExtensionSessionUpdateMethod(method) {
23938
24116
  return GROK_SESSION_UPDATE_EXTENSION_METHODS.includes(method);
23939
24117
  }
23940
24118
  function grokCompactionEventFromUpdate(update) {
23941
- if (!isRecord9(update) || typeof update.sessionUpdate !== "string")
24119
+ if (!isRecord10(update) || typeof update.sessionUpdate !== "string")
23942
24120
  return null;
23943
24121
  const tokensUsed = optionalNonNegativeInt(firstPresent(update, ["tokensUsed", "tokens_used"]));
23944
24122
  const contextWindowTokens = optionalNonNegativeInt(firstPresent(update, ["contextWindowTokens", "contextWindow", "context_window"]));
@@ -23977,7 +24155,7 @@ function grokCompactionEventFromUpdate(update) {
23977
24155
  // dist/grok-manual-compaction.js
23978
24156
  var GROK_COMPACT_CONVERSATION_METHOD = "x.ai/compact_conversation";
23979
24157
  var GROK_COMPACT_CONVERSATION_FALLBACK_METHOD = "_x.ai/compact_conversation";
23980
- function isRecord10(value) {
24158
+ function isRecord11(value) {
23981
24159
  return typeof value === "object" && value !== null && !Array.isArray(value);
23982
24160
  }
23983
24161
  function optionalNonNegativeInt2(value) {
@@ -23989,7 +24167,7 @@ function optionalErrorMessage2(value) {
23989
24167
  function parseGrokCompactResult(value, cancelled = false) {
23990
24168
  if (cancelled)
23991
24169
  return { outcome: "cancelled" };
23992
- if (!isRecord10(value))
24170
+ if (!isRecord11(value))
23993
24171
  return { outcome: "succeeded" };
23994
24172
  const tokensBefore = optionalNonNegativeInt2(value.tokensBefore ?? value.tokens_before);
23995
24173
  const tokensAfter = optionalNonNegativeInt2(value.tokensAfter ?? value.tokens_after);
@@ -24027,7 +24205,7 @@ var GROK_REWIND_EXECUTE_METHOD = "_x.ai/rewind/execute";
24027
24205
  function error52(code, message, retryable = false) {
24028
24206
  return { code, message, retryable };
24029
24207
  }
24030
- function isRecord11(value) {
24208
+ function isRecord12(value) {
24031
24209
  return typeof value === "object" && value !== null && !Array.isArray(value);
24032
24210
  }
24033
24211
  function buildGrokRewindParams(input) {
@@ -24039,10 +24217,10 @@ function buildGrokRewindParams(input) {
24039
24217
  };
24040
24218
  }
24041
24219
  function parseGrokRewindResponse(value) {
24042
- if (!isRecord11(value))
24220
+ if (!isRecord12(value))
24043
24221
  return null;
24044
- const payload = typeof value.success !== "boolean" && isRecord11(value.result) ? value.result : value;
24045
- if (!isRecord11(payload) || typeof payload.success !== "boolean")
24222
+ const payload = typeof value.success !== "boolean" && isRecord12(value.result) ? value.result : value;
24223
+ if (!isRecord12(payload) || typeof payload.success !== "boolean")
24046
24224
  return null;
24047
24225
  return rewindPayload(payload);
24048
24226
  }
@@ -24158,7 +24336,7 @@ var GROK_PLAN_STAY_VALUE = "stay";
24158
24336
  var GROK_PLAN_STAY_LABEL = "Stay in plan mode";
24159
24337
  var GROK_PLAN_OUTCOME_APPROVED = "approved";
24160
24338
  var GROK_PLAN_OUTCOME_CANCELLED = "cancelled";
24161
- function isRecord12(value) {
24339
+ function isRecord13(value) {
24162
24340
  return typeof value === "object" && value !== null && !Array.isArray(value);
24163
24341
  }
24164
24342
  function stringField3(value, ...keys) {
@@ -24170,9 +24348,9 @@ function stringField3(value, ...keys) {
24170
24348
  return void 0;
24171
24349
  }
24172
24350
  function parseGrokExitPlanModeParams(params) {
24173
- if (!isRecord12(params))
24351
+ if (!isRecord13(params))
24174
24352
  return null;
24175
- const nested = isRecord12(params.input) ? params.input : params;
24353
+ const nested = isRecord13(params.input) ? params.input : params;
24176
24354
  const plan = stringField3(nested, "planContent", "plan_content", "plan") ?? stringField3(params, "planContent", "plan_content", "plan") ?? null;
24177
24355
  const planFilePath = stringField3(nested, "planFilePath", "plan_file_path") ?? stringField3(params, "planFilePath", "plan_file_path");
24178
24356
  const sessionId = stringField3(params, "sessionId", "session_id");
@@ -24244,7 +24422,7 @@ var GROK_ACP_CLIENT_CAPABILITIES = {
24244
24422
  "x.ai/exit_plan_mode": true
24245
24423
  }
24246
24424
  };
24247
- function isRecord13(value) {
24425
+ function isRecord14(value) {
24248
24426
  return typeof value === "object" && value !== null && !Array.isArray(value);
24249
24427
  }
24250
24428
  function stringField4(value, ...keys) {
@@ -24273,15 +24451,15 @@ function isGrokExitPlanModeMethod(method) {
24273
24451
  function questionsPayload(params) {
24274
24452
  if (Array.isArray(params.questions))
24275
24453
  return params.questions;
24276
- if (isRecord13(params.input) && Array.isArray(params.input.questions))
24454
+ if (isRecord14(params.input) && Array.isArray(params.input.questions))
24277
24455
  return params.input.questions;
24278
- if (isRecord13(params.askUserQuestion) && Array.isArray(params.askUserQuestion.questions)) {
24456
+ if (isRecord14(params.askUserQuestion) && Array.isArray(params.askUserQuestion.questions)) {
24279
24457
  return params.askUserQuestion.questions;
24280
24458
  }
24281
24459
  return void 0;
24282
24460
  }
24283
24461
  function parseOption(value, labels) {
24284
- if (!isRecord13(value))
24462
+ if (!isRecord14(value))
24285
24463
  return null;
24286
24464
  const label = stringField4(value, "label");
24287
24465
  if (!label || labels.has(label))
@@ -24296,7 +24474,7 @@ function parseOption(value, labels) {
24296
24474
  };
24297
24475
  }
24298
24476
  function parseQuestion(value, questions) {
24299
- if (!isRecord13(value))
24477
+ if (!isRecord14(value))
24300
24478
  return null;
24301
24479
  const question = stringField4(value, "question");
24302
24480
  if (!question || questions.has(question))
@@ -24321,7 +24499,7 @@ function parseQuestion(value, questions) {
24321
24499
  };
24322
24500
  }
24323
24501
  function parseGrokAskUserQuestionParams(params) {
24324
- if (!isRecord13(params))
24502
+ if (!isRecord14(params))
24325
24503
  return null;
24326
24504
  const rawQuestions = questionsPayload(params);
24327
24505
  if (!Array.isArray(rawQuestions) || rawQuestions.length === 0)
@@ -24481,25 +24659,25 @@ var GrokPermissionConfirmation = class {
24481
24659
 
24482
24660
  // dist/grok-questions.js
24483
24661
  var GROK_ASK_USER_QUESTION_METHOD = "_x.ai/ask_user_question";
24484
- function isRecord14(value) {
24662
+ function isRecord15(value) {
24485
24663
  return typeof value === "object" && value !== null && !Array.isArray(value);
24486
24664
  }
24487
24665
  function nonEmptyString(value) {
24488
24666
  return typeof value === "string" && value.trim().length > 0;
24489
24667
  }
24490
24668
  function parseGrokQuestionRequest(value) {
24491
- if (!isRecord14(value) || !nonEmptyString(value.sessionId) || !nonEmptyString(value.toolCallId) || value.mode !== "default" && value.mode !== "plan" || !Array.isArray(value.questions) || value.questions.length === 0)
24669
+ if (!isRecord15(value) || !nonEmptyString(value.sessionId) || !nonEmptyString(value.toolCallId) || value.mode !== "default" && value.mode !== "plan" || !Array.isArray(value.questions) || value.questions.length === 0)
24492
24670
  throw new Error("Grok question requires sessionId, toolCallId, mode and nonempty questions");
24493
24671
  const seen = /* @__PURE__ */ new Set();
24494
24672
  const questions = value.questions.map((question) => {
24495
- if (!isRecord14(question) || !nonEmptyString(question.question) || seen.has(question.question) || !Array.isArray(question.options) || question.multiSelect != null && typeof question.multiSelect !== "boolean" || question.multi_select != null && typeof question.multi_select !== "boolean")
24673
+ if (!isRecord15(question) || !nonEmptyString(question.question) || seen.has(question.question) || !Array.isArray(question.options) || question.multiSelect != null && typeof question.multiSelect !== "boolean" || question.multi_select != null && typeof question.multi_select !== "boolean")
24496
24674
  throw new Error("Grok question text must be unique and options/multiSelect must be valid");
24497
24675
  if (question.multiSelect != null && question.multi_select != null && question.multiSelect !== question.multi_select)
24498
24676
  throw new Error("Grok question contains conflicting multi-select flags");
24499
24677
  seen.add(question.question);
24500
24678
  const labels = /* @__PURE__ */ new Set();
24501
24679
  const options = question.options.map((option) => {
24502
- if (!isRecord14(option) || !nonEmptyString(option.label) || labels.has(option.label) || typeof option.description !== "string" || option.preview != null && typeof option.preview !== "string")
24680
+ if (!isRecord15(option) || !nonEmptyString(option.label) || labels.has(option.label) || typeof option.description !== "string" || option.preview != null && typeof option.preview !== "string")
24503
24681
  throw new Error("Grok question options require unique labels and text descriptions/previews");
24504
24682
  labels.add(option.label);
24505
24683
  return {
@@ -24647,16 +24825,16 @@ var GrokTransportError = class extends Error {
24647
24825
  this.name = "GrokTransportError";
24648
24826
  }
24649
24827
  };
24650
- function isRecord15(value) {
24828
+ function isRecord16(value) {
24651
24829
  return typeof value === "object" && value !== null && !Array.isArray(value);
24652
24830
  }
24653
24831
  function acpToolName(update, metadata) {
24654
- if (!isRecord15(update))
24832
+ if (!isRecord16(update))
24655
24833
  return void 0;
24656
24834
  if (typeof update.name === "string" && update.name.length > 0)
24657
24835
  return update.name;
24658
- const meta3 = isRecord15(update._meta) ? update._meta : metadata;
24659
- const tool = meta3 && isRecord15(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
24836
+ const meta3 = isRecord16(update._meta) ? update._meta : metadata;
24837
+ const tool = meta3 && isRecord16(meta3["x.ai/tool"]) ? meta3["x.ai/tool"] : void 0;
24660
24838
  return tool && typeof tool.name === "string" && tool.name.length > 0 ? tool.name : void 0;
24661
24839
  }
24662
24840
  function errorText(error53) {
@@ -24712,12 +24890,12 @@ function signalProcessTree(child, signal) {
24712
24890
  try {
24713
24891
  process.kill(-child.pid, signal);
24714
24892
  } catch (error53) {
24715
- if (!isRecord15(error53) || error53.code === "ESRCH")
24893
+ if (!isRecord16(error53) || error53.code === "ESRCH")
24716
24894
  return;
24717
24895
  try {
24718
24896
  child.kill(signal);
24719
24897
  } catch (fallback) {
24720
- if (!isRecord15(fallback) || fallback.code !== "ESRCH")
24898
+ if (!isRecord16(fallback) || fallback.code !== "ESRCH")
24721
24899
  throw fallback;
24722
24900
  }
24723
24901
  }
@@ -24832,7 +25010,7 @@ async function readNativeSignals(options, sessionId) {
24832
25010
  }
24833
25011
  }
24834
25012
  function isMissingFile(error53) {
24835
- return isRecord15(error53) && error53.code === "ENOENT";
25013
+ return isRecord16(error53) && error53.code === "ENOENT";
24836
25014
  }
24837
25015
  async function locateGrokNativeSession(options, sessionId) {
24838
25016
  if (sessionId.length === 0)
@@ -24855,7 +25033,7 @@ async function locateGrokNativeSession(options, sessionId) {
24855
25033
  try {
24856
25034
  summaryRaw = await readFile3(path13.join(grokHomeDir(options), "sessions", entry.name, sessionId, "summary.json"), "utf8");
24857
25035
  } catch (error53) {
24858
- if (isMissingFile(error53) || isRecord15(error53) && error53.code === "ENOTDIR")
25036
+ if (isMissingFile(error53) || isRecord16(error53) && error53.code === "ENOTDIR")
24859
25037
  continue;
24860
25038
  throw new GrokTransportError("unavailable", "Grok Native Session metadata could not be read", {
24861
25039
  cause: error53
@@ -24867,10 +25045,10 @@ async function locateGrokNativeSession(options, sessionId) {
24867
25045
  } catch {
24868
25046
  continue;
24869
25047
  }
24870
- if (!isRecord15(parsed))
25048
+ if (!isRecord16(parsed))
24871
25049
  continue;
24872
25050
  const info = parsed.info;
24873
- const cwd = isRecord15(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path13.resolve(info.cwd) : path13.resolve(decodeURIComponent(entry.name));
25051
+ const cwd = isRecord16(info) && typeof info.cwd === "string" && info.cwd.length > 0 ? path13.resolve(info.cwd) : path13.resolve(decodeURIComponent(entry.name));
24874
25052
  const sourceWorkspaceDir = typeof parsed.source_workspace_dir === "string" && parsed.source_workspace_dir.length > 0 ? path13.resolve(parsed.source_workspace_dir) : void 0;
24875
25053
  matches.push({
24876
25054
  cwd,
@@ -24903,12 +25081,12 @@ function parseNativeHistory(contents, sessionId) {
24903
25081
  } catch {
24904
25082
  throw new GrokTransportError("protocolError", "Grok Native history contains invalid JSON");
24905
25083
  }
24906
- if (!isRecord15(record3) || !isRecord15(record3.params))
25084
+ if (!isRecord16(record3) || !isRecord16(record3.params))
24907
25085
  continue;
24908
25086
  const params = record3.params;
24909
- if (params.sessionId !== sessionId || !isRecord15(params.update))
25087
+ if (params.sessionId !== sessionId || !isRecord16(params.update))
24910
25088
  continue;
24911
- const metadata = isRecord15(params._meta) ? params._meta : void 0;
25089
+ const metadata = isRecord16(params._meta) ? params._meta : void 0;
24912
25090
  const event = transportEvent(params.update, metadata);
24913
25091
  if (event)
24914
25092
  events.push(metadata ? { ...event, metadata } : event);
@@ -24951,13 +25129,23 @@ var GrokAcpTransport = class {
24951
25129
  throw new Error("Grok ACP inspection cannot reuse an open Session");
24952
25130
  try {
24953
25131
  const initialize = await this.#ensureInitialized();
25132
+ const connection = this.#connection;
25133
+ if (!connection)
25134
+ throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
24954
25135
  if (initialize.agentCapabilities?.sessionCapabilities?.list) {
24955
- const connection = this.#connection;
24956
- if (!connection)
24957
- throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
24958
25136
  await withTimeout(connection.listSessions({ cwd: this.#options.cwd }), this.#options.commandTimeoutMs, "Grok Session inspection");
24959
25137
  }
24960
- return initialize;
25138
+ try {
25139
+ const response = await withTimeout(connection.request("_x.ai/models/list", {}), this.#options.commandTimeoutMs, "Grok Model inspection");
25140
+ const modelState = isRecord16(response) ? response.result : void 0;
25141
+ if (!parseGrokModelState(modelState))
25142
+ throw new GrokTransportError("protocolError", "Grok returned an invalid Model catalog");
25143
+ return { ...initialize, _meta: { ...initialize._meta, modelState } };
25144
+ } catch (error53) {
25145
+ if (isGrokMethodNotFound(error53))
25146
+ return initialize;
25147
+ throw error53;
25148
+ }
24961
25149
  } catch (error53) {
24962
25150
  const classified = classifyStartupError(error53);
24963
25151
  await this.close().catch(() => void 0);
@@ -24972,7 +25160,7 @@ var GrokAcpTransport = class {
24972
25160
  if (!this.#connection)
24973
25161
  throw new GrokTransportError("unavailable", "Grok ACP is unavailable");
24974
25162
  const result = await withTimeout(this.#connection.request("_x.ai/session/usage", { sessionId: this.sessionId }), this.#options.commandTimeoutMs, "Grok Session usage");
24975
- return isRecord15(result) ? result.usage : void 0;
25163
+ return isRecord16(result) ? result.usage : void 0;
24976
25164
  }
24977
25165
  async readHistory(sessionId, cwd = this.#options.cwd) {
24978
25166
  return readGrokNativeHistory({ ...this.#options, cwd }, sessionId);
@@ -25235,7 +25423,7 @@ var GrokAcpTransport = class {
25235
25423
  ...reasoningEffort ? { reasoningEffort } : {},
25236
25424
  ...contextWindowTokens !== void 0 ? { _meta: { contextWindow: contextWindowTokens } } : {}
25237
25425
  });
25238
- if (!isRecord15(response) || !isRecord15(response._meta) || !isRecord15(response._meta.model)) {
25426
+ if (!isRecord16(response) || !isRecord16(response._meta) || !isRecord16(response._meta.model)) {
25239
25427
  throw new GrokTransportError("protocolError", "Grok rejected Model configuration");
25240
25428
  }
25241
25429
  const selected = response._meta.model.Ok;
@@ -25275,7 +25463,7 @@ var GrokAcpTransport = class {
25275
25463
  permission_mode: mode
25276
25464
  });
25277
25465
  const response = await connection.request("_x.ai/session/info", { sessionId });
25278
- if (!isRecord15(response) || !isRecord15(response.result) || response.result.sessionId !== sessionId) {
25466
+ if (!isRecord16(response) || !isRecord16(response.result) || response.result.sessionId !== sessionId) {
25279
25467
  throw new Error("Grok did not confirm the target Session");
25280
25468
  }
25281
25469
  })()
@@ -25330,7 +25518,7 @@ var GrokAcpTransport = class {
25330
25518
  this.#availableCommands = parseGrokAvailableCommands(update.availableCommands);
25331
25519
  return;
25332
25520
  }
25333
- const metadata = isRecord15(notification._meta) ? notification._meta : void 0;
25521
+ const metadata = isRecord16(notification._meta) ? notification._meta : void 0;
25334
25522
  const event = transportEvent(notification.update, metadata);
25335
25523
  if (!event)
25336
25524
  return;
@@ -25345,7 +25533,7 @@ var GrokAcpTransport = class {
25345
25533
  #handleExtensionNotification(method, params) {
25346
25534
  if (!isGrokExtensionSessionUpdateMethod(method))
25347
25535
  return;
25348
- if (typeof params.sessionId !== "string" || !isRecord15(params.update))
25536
+ if (typeof params.sessionId !== "string" || !isRecord16(params.update))
25349
25537
  return;
25350
25538
  this.#handleUpdate(params);
25351
25539
  }
@@ -25370,7 +25558,7 @@ var GrokAcpTransport = class {
25370
25558
  return { outcome: "cancelled" };
25371
25559
  return { ...await active.onQuestion(request) };
25372
25560
  }
25373
- if (!isRecord15(params) || "toolCallId" in params && "mode" in params) {
25561
+ if (!isRecord16(params) || "toolCallId" in params && "mode" in params) {
25374
25562
  throw RequestError.invalidParams(void 0, errorText(parseError));
25375
25563
  }
25376
25564
  const legacy = parseGrokAskUserQuestionParams(params);
@@ -25523,7 +25711,7 @@ var SessionImportScope = class {
25523
25711
  // dist/session-import.js
25524
25712
  var MAX_METADATA_BYTES = 4 * 1024 * 1024;
25525
25713
  var SUBAGENT_SESSION_KINDS = /* @__PURE__ */ new Set(["subagent", "subagent_resume"]);
25526
- function isRecord16(value) {
25714
+ function isRecord17(value) {
25527
25715
  return typeof value === "object" && value !== null && !Array.isArray(value);
25528
25716
  }
25529
25717
  async function readJson(file2, signal) {
@@ -25536,7 +25724,7 @@ function processAlive(pid) {
25536
25724
  process.kill(pid, 0);
25537
25725
  return true;
25538
25726
  } catch (error53) {
25539
- return isRecord16(error53) && error53.code === "EPERM";
25727
+ return isRecord17(error53) && error53.code === "EPERM";
25540
25728
  }
25541
25729
  }
25542
25730
  async function firstUserText(file2, signal) {
@@ -25553,10 +25741,10 @@ async function firstUserText(file2, signal) {
25553
25741
  } catch {
25554
25742
  continue;
25555
25743
  }
25556
- const update = isRecord16(entry) && isRecord16(entry.params) ? entry.params.update : null;
25557
- if (!isRecord16(update) || update.sessionUpdate !== "user_message_chunk")
25744
+ const update = isRecord17(entry) && isRecord17(entry.params) ? entry.params.update : null;
25745
+ if (!isRecord17(update) || update.sessionUpdate !== "user_message_chunk")
25558
25746
  continue;
25559
- const text = isRecord16(update.content) ? update.content.text : null;
25747
+ const text = isRecord17(update.content) ? update.content.text : null;
25560
25748
  return typeof text === "string" ? text : "";
25561
25749
  }
25562
25750
  return null;
@@ -25633,7 +25821,7 @@ var GrokSessionImport = class {
25633
25821
  if (!Array.isArray(entries))
25634
25822
  return active;
25635
25823
  for (const entry of entries) {
25636
- if (isRecord16(entry) && typeof entry.session_id === "string" && processAlive(entry.pid))
25824
+ if (isRecord17(entry) && typeof entry.session_id === "string" && processAlive(entry.pid))
25637
25825
  active.add(entry.session_id);
25638
25826
  }
25639
25827
  return active;
@@ -25682,7 +25870,7 @@ var GrokSessionImport = class {
25682
25870
  return null;
25683
25871
  try {
25684
25872
  const summary = await readJson(files[0], signal);
25685
- if (!isRecord16(summary) || !isRecord16(summary.info) || summary.info.id !== nativeSessionId)
25873
+ if (!isRecord17(summary) || !isRecord17(summary.info) || summary.info.id !== nativeSessionId)
25686
25874
  return null;
25687
25875
  if (typeof summary.session_kind === "string" && SUBAGENT_SESSION_KINDS.has(summary.session_kind))
25688
25876
  return null;
@@ -25908,128 +26096,6 @@ var GrokSubagentLifecycle = class {
25908
26096
  }
25909
26097
  };
25910
26098
 
25911
- // dist/grok-models.js
25912
- function isRecord17(value) {
25913
- return typeof value === "object" && value !== null && !Array.isArray(value);
25914
- }
25915
- function nonBlank(value) {
25916
- return typeof value === "string" && value.trim().length > 0;
25917
- }
25918
- var ENCODED_MODEL_REF_PREFIX = "grok-model~";
25919
- function encodeGrokModelRef(modelId2) {
25920
- if (!nonBlank(modelId2) || modelId2.length > HARNESS_MODEL_REF_MAX_LENGTH || new RegExp("\\p{Cc}", "u").test(modelId2))
25921
- return null;
25922
- const direct = harnessModelRefSchema.safeParse({ id: modelId2 });
25923
- if (direct.success && !modelId2.startsWith(ENCODED_MODEL_REF_PREFIX))
25924
- return direct.data;
25925
- const encoded = harnessModelRefSchema.safeParse({
25926
- id: `${ENCODED_MODEL_REF_PREFIX}${Buffer.from(modelId2, "utf8").toString("base64url")}`
25927
- });
25928
- return encoded.success ? encoded.data : null;
25929
- }
25930
- function decodeGrokModelRef(ref) {
25931
- const { id } = harnessModelRefSchema.parse(ref);
25932
- if (!id.startsWith(ENCODED_MODEL_REF_PREFIX))
25933
- return id;
25934
- const modelId2 = Buffer.from(id.slice(ENCODED_MODEL_REF_PREFIX.length), "base64url").toString("utf8");
25935
- if (encodeGrokModelRef(modelId2)?.id !== id)
25936
- throw new Error("Invalid Grok Model Ref");
25937
- return modelId2;
25938
- }
25939
- function thinkingOptions(value) {
25940
- if (!Array.isArray(value))
25941
- return [];
25942
- const seen = /* @__PURE__ */ new Set();
25943
- const options = [];
25944
- for (const candidate of value) {
25945
- if (!isRecord17(candidate) || !nonBlank(candidate.label))
25946
- continue;
25947
- const id = harnessThinkingOptionIdSchema.safeParse(candidate.id ?? candidate.value);
25948
- if (!id.success || seen.has(id.data))
25949
- continue;
25950
- seen.add(id.data);
25951
- options.push({ id: id.data, label: candidate.label });
25952
- }
25953
- return options;
25954
- }
25955
- function parseGrokModelState(value) {
25956
- if (!isRecord17(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
25957
- return null;
25958
- }
25959
- const currentModel = encodeGrokModelRef(value.currentModelId);
25960
- if (!currentModel)
25961
- return null;
25962
- const allThinking = /* @__PURE__ */ new Map();
25963
- const contextWindowTokensByModel = /* @__PURE__ */ new Map();
25964
- const defaultContextWindowTokensByModel = /* @__PURE__ */ new Map();
25965
- const models = [];
25966
- let currentThinkingOptionId;
25967
- for (const candidate of value.availableModels) {
25968
- if (!isRecord17(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
25969
- continue;
25970
- const ref = encodeGrokModelRef(candidate.modelId);
25971
- if (!ref)
25972
- continue;
25973
- const metadata = isRecord17(candidate._meta) ? candidate._meta : {};
25974
- const options2 = thinkingOptions(metadata.reasoningEfforts);
25975
- if (Array.isArray(metadata.contextWindows) && metadata.contextWindows.includes(5e5)) {
25976
- defaultContextWindowTokensByModel.set(ref.id, 5e5);
25977
- }
25978
- if (typeof metadata.totalContextTokens === "number" && Number.isSafeInteger(metadata.totalContextTokens) && metadata.totalContextTokens > 0) {
25979
- contextWindowTokensByModel.set(ref.id, metadata.totalContextTokens);
25980
- }
25981
- for (const option of options2)
25982
- allThinking.set(option.id, option);
25983
- if (candidate.modelId === value.currentModelId && nonBlank(metadata.reasoningEffort)) {
25984
- const parsed = harnessThinkingOptionIdSchema.safeParse(metadata.reasoningEffort);
25985
- if (parsed.success && options2.some(({ id }) => id === parsed.data)) {
25986
- currentThinkingOptionId = parsed.data;
25987
- }
25988
- }
25989
- models.push({
25990
- ref,
25991
- label: candidate.name,
25992
- ...options2.length > 0 ? { supportedThinkingOptionIds: options2.map(({ id }) => id) } : {}
25993
- });
25994
- }
25995
- if (!models.some(({ ref }) => ref.id === currentModel.id))
25996
- return null;
25997
- const options = [...allThinking.values()];
25998
- return {
25999
- currentModel,
26000
- contextWindowTokensByModel,
26001
- defaultContextWindowTokensByModel,
26002
- ...currentThinkingOptionId ? { currentThinkingOptionId } : {},
26003
- catalog: {
26004
- models,
26005
- defaultModel: currentModel,
26006
- thinkingOptions: options,
26007
- ...currentThinkingOptionId ? { defaultThinkingOptionId: currentThinkingOptionId } : {}
26008
- }
26009
- };
26010
- }
26011
- function modelStateFromInitialize(response) {
26012
- return parseGrokModelState(isRecord17(response._meta) ? response._meta.modelState : void 0);
26013
- }
26014
- function modelStateFromSessionResponse(response) {
26015
- return parseGrokModelState(isRecord17(response) ? response.models : void 0);
26016
- }
26017
- function stateForGrokModel(modelState, nativeState, model2 = modelState.currentModel, thinkingOptionId = modelState.currentThinkingOptionId, permissionModeId) {
26018
- const selectedModel = model2;
26019
- const catalogModel = modelState.catalog.models.find(({ ref }) => ref.id === selectedModel.id);
26020
- const availableThinkingOptions = catalogModel?.supportedThinkingOptionIds?.flatMap((id) => {
26021
- const option = modelState.catalog.thinkingOptions.find((candidate) => candidate.id === id);
26022
- return option ? [option] : [];
26023
- });
26024
- return {
26025
- ...nativeState,
26026
- effectiveModel: selectedModel,
26027
- ...thinkingOptionId ? { effectiveThinkingOptionId: thinkingOptionId } : {},
26028
- ...permissionModeId ? { effectivePermissionModeId: permissionModeId } : {},
26029
- ...availableThinkingOptions ? { availableThinkingOptions } : {}
26030
- };
26031
- }
26032
-
26033
26099
  // dist/grok-credits.js
26034
26100
  import { readFile as readFile5 } from "node:fs/promises";
26035
26101
  import os6 from "node:os";
@@ -26277,6 +26343,9 @@ var GrokTurnUsage = class {
26277
26343
  #compacting = false;
26278
26344
  #startedAtMs;
26279
26345
  #streamKey;
26346
+ #reasoningObserved = false;
26347
+ #textStartedOutput = false;
26348
+ #bufferedToolInput = false;
26280
26349
  #outputTokens = 0;
26281
26350
  #durationMs = 0;
26282
26351
  #latestCacheHit;
@@ -26292,8 +26361,7 @@ var GrokTurnUsage = class {
26292
26361
  }
26293
26362
  observe(event) {
26294
26363
  if (event.type === "compaction.started" || event.type === "compaction.completed") {
26295
- this.#startedAtMs = void 0;
26296
- this.#streamKey = void 0;
26364
+ this.#resetResponse();
26297
26365
  this.#compacting = event.type === "compaction.started";
26298
26366
  }
26299
26367
  if (this.#compacting)
@@ -26301,14 +26369,29 @@ var GrokTurnUsage = class {
26301
26369
  if (event.type === "subagent.spawned")
26302
26370
  this.#cacheComplete = false;
26303
26371
  if (event.type === "agent.text" || event.type === "agent.thought" || event.type === "tool.input.delta") {
26304
- if (!event.text)
26372
+ if (!event.text || event.type === "tool.input.delta" && !event.text.trim())
26305
26373
  return null;
26306
26374
  const key = event.metadata?.streamStartMs;
26307
26375
  if (key !== void 0 && this.#streamKey !== void 0 && key !== this.#streamKey)
26308
- this.#startedAtMs = void 0;
26376
+ this.#resetResponse();
26309
26377
  if (key !== void 0)
26310
26378
  this.#streamKey = key;
26311
- this.#startedAtMs ??= Date.now();
26379
+ if (this.#bufferedToolInput)
26380
+ return null;
26381
+ if (event.type === "tool.input.delta" && this.#startedAtMs === void 0) {
26382
+ try {
26383
+ JSON.parse(event.text);
26384
+ this.#bufferedToolInput = true;
26385
+ return null;
26386
+ } catch {
26387
+ }
26388
+ }
26389
+ if (event.type === "agent.thought")
26390
+ this.#reasoningObserved = true;
26391
+ if (this.#startedAtMs === void 0) {
26392
+ this.#startedAtMs = Date.now();
26393
+ this.#textStartedOutput = event.type === "agent.text";
26394
+ }
26312
26395
  }
26313
26396
  if (event.type !== "response.completed")
26314
26397
  return null;
@@ -26318,9 +26401,12 @@ var GrokTurnUsage = class {
26318
26401
  this.#seen.add(event.messageId);
26319
26402
  }
26320
26403
  const duration3 = this.#startedAtMs === void 0 ? 0 : Date.now() - this.#startedAtMs;
26321
- this.#startedAtMs = void 0;
26322
- this.#streamKey = void 0;
26323
26404
  const usage = usageFromResponse(event.usage);
26405
+ const outputTokens = usage?.outputTokens;
26406
+ const reasoningOutputTokens = usage?.reasoningOutputTokens;
26407
+ const completeOutputBoundary = this.#reasoningObserved || reasoningOutputTokens === 0;
26408
+ const timedOutputTokens = completeOutputBoundary ? outputTokens : this.#textStartedOutput && outputTokens !== void 0 && reasoningOutputTokens !== void 0 && reasoningOutputTokens > 0 && reasoningOutputTokens < outputTokens ? outputTokens - reasoningOutputTokens : void 0;
26409
+ this.#resetResponse();
26324
26410
  this.#latestCacheHit = usage?.cacheHitRatePercent;
26325
26411
  if (usage?.inputTokens === void 0 || usage.cachedInputTokens === void 0)
26326
26412
  this.#cacheComplete = false;
@@ -26331,13 +26417,20 @@ var GrokTurnUsage = class {
26331
26417
  if (value !== void 0)
26332
26418
  this.#totals[field2] = (this.#totals[field2] ?? 0) + value;
26333
26419
  }
26334
- if (duration3 > 0 && usage.outputTokens !== void 0) {
26335
- this.#outputTokens += usage.outputTokens;
26420
+ if (duration3 > 0 && timedOutputTokens !== void 0) {
26421
+ this.#outputTokens += timedOutputTokens;
26336
26422
  this.#durationMs += duration3;
26337
26423
  }
26338
26424
  }
26339
26425
  return this.snapshot();
26340
26426
  }
26427
+ #resetResponse() {
26428
+ this.#startedAtMs = void 0;
26429
+ this.#streamKey = void 0;
26430
+ this.#reasoningObserved = false;
26431
+ this.#textStartedOutput = false;
26432
+ this.#bufferedToolInput = false;
26433
+ }
26341
26434
  metrics() {
26342
26435
  return {
26343
26436
  ...this.#durationMs > 0 ? { outputTokensPerSecond: this.#outputTokens * 1e3 / this.#durationMs } : {},
@@ -26515,6 +26608,7 @@ function capabilitiesForModels(modelState) {
26515
26608
  };
26516
26609
  }
26517
26610
  var DEFAULT_CLOSE_TIMEOUT_MS = 2e3;
26611
+ var INSPECTION_CACHE_TTL_MS = 3e4;
26518
26612
  var GROK_CREDITS_TTL_MS = 6e4;
26519
26613
  function invalidState(message) {
26520
26614
  return { code: "invalidState", message, retryable: false };
@@ -27752,8 +27846,8 @@ var GrokAdapter = class {
27752
27846
  const cwd = path16.resolve(input.cwd ?? process.cwd());
27753
27847
  if (!input.refresh) {
27754
27848
  const cached2 = this.#inspectionCache.get(cwd);
27755
- if (cached2)
27756
- return cached2;
27849
+ if (cached2 && Date.now() < cached2.expiresAt)
27850
+ return cached2.inspection;
27757
27851
  }
27758
27852
  let transport = null;
27759
27853
  const startedAt = Date.now();
@@ -27773,7 +27867,10 @@ var GrokAdapter = class {
27773
27867
  permissionModes: GROK_PERMISSION_MODE_CATALOG,
27774
27868
  capabilities: capabilitiesForModels(modelState)
27775
27869
  };
27776
- this.#inspectionCache.set(cwd, ready);
27870
+ this.#inspectionCache.set(cwd, {
27871
+ inspection: ready,
27872
+ expiresAt: Date.now() + INSPECTION_CACHE_TTL_MS
27873
+ });
27777
27874
  this.#scheduleCreditsRefresh();
27778
27875
  return ready;
27779
27876
  } catch (error53) {