@google/gemini-cli 0.65.0-nightly.20261013.g51617c1bc → 0.65.0-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/bundle/{chunk-BXWN65YH.js → chunk-2WVLIJA5.js} +1 -1
  2. package/bundle/{chunk-5322VSKQ.js → chunk-43EXRO7A.js} +1 -1
  3. package/bundle/{chunk-3EFBILEW.js → chunk-4DCA4L53.js} +2 -2
  4. package/bundle/{chunk-NAGGT65S.js → chunk-4JGVVJGK.js} +1 -1
  5. package/bundle/{chunk-VJXI22NX.js → chunk-BFIV7GTA.js} +2 -2
  6. package/bundle/{chunk-NJIZWOAO.js → chunk-F6AJM4WN.js} +3 -3
  7. package/bundle/{chunk-EPXYFN6C.js → chunk-GSQEBEGC.js} +3 -3
  8. package/bundle/{chunk-SSAL6PAH.js → chunk-H2CZXS7F.js} +1 -1
  9. package/bundle/{chunk-76GSGGHI.js → chunk-HLOOE7YN.js} +1 -1
  10. package/bundle/{chunk-ZZJRXUDM.js → chunk-K4G5D5ZZ.js} +1 -1
  11. package/bundle/{chunk-B22AOTUS.js → chunk-K7AA35SP.js} +26 -22
  12. package/bundle/{chunk-HVVLEMLR.js → chunk-K7NOVQ6G.js} +24 -20
  13. package/bundle/{chunk-C3XVWXTB.js → chunk-LLE5Z636.js} +7 -7
  14. package/bundle/{chunk-KR7RUPIE.js → chunk-NL7ZHGCH.js} +1 -1
  15. package/bundle/{chunk-6M4QEFFF.js → chunk-QJK54DSE.js} +8 -9
  16. package/bundle/{chunk-EA2F2LNY.js → chunk-RPHDSDL6.js} +1 -1
  17. package/bundle/{chunk-LBJNFX6K.js → chunk-S7BCRBI4.js} +1 -1
  18. package/bundle/{chunk-LB7T3Q3K.js → chunk-SN7QZKXC.js} +58 -71
  19. package/bundle/{chunk-GI5HEZHG.js → chunk-TP236FKO.js} +14976 -7914
  20. package/bundle/{chunk-LJV6OKHI.js → chunk-V2R74WAG.js} +5 -7
  21. package/bundle/{chunk-VLEIPZMF.js → chunk-V72FRESD.js} +2 -2
  22. package/bundle/{chunk-N2N4FSJX.js → chunk-VF5WQSOE.js} +1 -1
  23. package/bundle/{chunk-5OZJ7SSG.js → chunk-WGL5FJOS.js} +3 -3
  24. package/bundle/{chunk-JCR3XD5H.js → chunk-WTRK3NVX.js} +7 -7
  25. package/bundle/{cleanup-C3GRMYTQ.js → cleanup-HPADDONA.js} +2 -2
  26. package/bundle/{cleanup-HHEU7BTA.js → cleanup-JOMSXKMP.js} +2 -2
  27. package/bundle/{cleanup-VCQCBVRV.js → cleanup-LYRJHMMO.js} +2 -2
  28. package/bundle/{core-EX2SPRDZ.js → core-IVQAI4S6.js} +1 -1
  29. package/bundle/{dist-GG436DD3.js → core-NCJTYARO.js} +1 -1
  30. package/bundle/{devtoolsService-OI7AEJQC.js → devtoolsService-HIZA3JGR.js} +2 -2
  31. package/bundle/{devtoolsService-E3YLHACW.js → devtoolsService-JFJBTZ4B.js} +3 -4
  32. package/bundle/{devtoolsService-CSRUFNFL.js → devtoolsService-WP2OPVPB.js} +2 -2
  33. package/bundle/{dist-MRDCUCIF.js → dist-GQKLLBDW.js} +1 -1
  34. package/bundle/{gemini-TWP2M62H.js → gemini-546WMAHG.js} +198 -214
  35. package/bundle/{gemini-W7O4SF3Y.js → gemini-5TUKZVGS.js} +14 -14
  36. package/bundle/{gemini-GG2HNQFT.js → gemini-7CHJYSHM.js} +13 -13
  37. package/bundle/gemini.js +7 -7
  38. package/bundle/{interactiveCli-3Y2RHZKF.js → interactiveCli-5XIAIY74.js} +1069 -554
  39. package/bundle/{interactiveCli-GBXKC6IY.js → interactiveCli-E3PUPYMZ.js} +1069 -554
  40. package/bundle/{interactiveCli-E5RBGMKR.js → interactiveCli-L4PK7YY3.js} +1348 -852
  41. package/bundle/{liteRtServerManager-BV7LQRJK.js → liteRtServerManager-22ISMNN2.js} +4 -4
  42. package/bundle/{liteRtServerManager-EW5TUX2V.js → liteRtServerManager-JCTYJBV5.js} +4 -4
  43. package/bundle/{liteRtServerManager-G3ETQGQD.js → liteRtServerManager-JERG6KYC.js} +4 -4
  44. package/bundle/{oauth2-provider-NVW65VJA.js → oauth2-provider-477UJQX6.js} +1 -1
  45. package/bundle/{oauth2-provider-6Z2ZXOX6.js → oauth2-provider-MKWWBW4K.js} +79 -41
  46. package/bundle/{oauth2-provider-4CXU66CN.js → oauth2-provider-XRUER2XR.js} +1 -1
  47. package/bundle/{start-AZFYLAF2.js → start-AGMBPY3O.js} +6 -6
  48. package/bundle/{start-BHB4KDHO.js → start-MVIPJNQ5.js} +6 -6
  49. package/bundle/{start-CHWZQ4ZN.js → start-RZWSVT55.js} +6 -6
  50. package/package.json +1 -1
  51. package/bundle/chunk-5YND2HLC.js +0 -1571
  52. package/bundle/chunk-IJ7X4I2Z.js +0 -425
  53. package/bundle/chunk-K6N5Z54J.js +0 -154
  54. package/bundle/chunk-LZISQJNJ.js +0 -512
  55. package/bundle/chunk-OB6IRF7N.js +0 -118
  56. package/bundle/chunk-TLYQMFOC.js +0 -17535
  57. package/bundle/chunk-UVUPZGTC.js +0 -402042
  58. package/bundle/chunk-XHQIF7OW.js +0 -103253
  59. package/bundle/cleanup-XUHY5LXE.js +0 -32
  60. package/bundle/devtoolsService-NB2AMKES.js +0 -4359
  61. package/bundle/dist-O7VOOHX4.js +0 -2268
  62. package/bundle/gemini-UZP4MEXP.js +0 -17951
  63. package/bundle/interactiveCli-R3ZT6N5Z.js +0 -35014
  64. package/bundle/liteRtServerManager-YM2L7SJG.js +0 -65
  65. package/bundle/oauth2-provider-VEKJJAQ2.js +0 -273
  66. package/bundle/start-NJW6EU4P.js +0 -18
@@ -171,10 +171,10 @@ import {
171
171
  widestLineFromStyledChars,
172
172
  wordBreakStyledChars,
173
173
  wrapStyledChars
174
- } from "./chunk-XHQIF7OW.js";
174
+ } from "./chunk-SN7QZKXC.js";
175
175
  import {
176
176
  require_source
177
- } from "./chunk-5YND2HLC.js";
177
+ } from "./chunk-K4G5D5ZZ.js";
178
178
  import {
179
179
  appEvents
180
180
  } from "./chunk-5PS3AYFU.js";
@@ -227,37 +227,33 @@ import {
227
227
  stripAnsi,
228
228
  stripUnsafeCharacters,
229
229
  toCodePoints
230
- } from "./chunk-TLYQMFOC.js";
230
+ } from "./chunk-V2R74WAG.js";
231
231
  import {
232
232
  handleAutoUpdate,
233
233
  isDevelopment,
234
234
  relaunchApp,
235
235
  setUpdateHandler
236
- } from "./chunk-VJXI22NX.js";
236
+ } from "./chunk-BFIV7GTA.js";
237
237
  import {
238
238
  isTodoList,
239
239
  mapCoreStatusToDisplayStatus,
240
240
  require_react
241
- } from "./chunk-6M4QEFFF.js";
241
+ } from "./chunk-QJK54DSE.js";
242
242
  import {
243
243
  registerCleanup,
244
244
  removeCleanup,
245
245
  runExitCleanup,
246
246
  setupTtyCheck
247
- } from "./chunk-K6N5Z54J.js";
247
+ } from "./chunk-S7BCRBI4.js";
248
248
  import {
249
249
  ACTIVATE_SKILL_TOOL_NAME,
250
250
  AGENT_TOOL_NAME,
251
251
  ApiKeyUpdatedEvent,
252
- ApprovalMode,
253
252
  AsyncFzf,
254
253
  AudioRecorder,
255
254
  AuthType,
256
255
  ChangeAuthRequestedError,
257
- CompressionStatus,
258
256
  ConversationFinishedEvent,
259
- CoreEvent,
260
- CoreToolCallStatus,
261
257
  CreditPurchaseClickEvent,
262
258
  DEFAULT_GEMINI_FLASH_LITE_MODEL,
263
259
  DEFAULT_GEMINI_FLASH_MODEL,
@@ -279,20 +275,13 @@ import {
279
275
  GEMMA_4_31B_IT_MODEL,
280
276
  GLOB_DISPLAY_NAME,
281
277
  GREP_DISPLAY_NAME,
282
- GeminiCliOperation,
283
- GeminiEventType,
284
278
  GitService,
285
279
  IdeClient,
286
- Kind,
287
280
  LS_DISPLAY_NAME,
288
281
  LegacyAgentProtocol,
289
282
  LlmRole,
290
283
  Logger,
291
284
  MAX_TOKENS_EXCEEDED_SUGGESTION,
292
- MCPDiscoveryState,
293
- MCPServerStatus,
294
- MessageBusType,
295
- MessageSenderType,
296
285
  ModelNotFoundError,
297
286
  ModelSlashCommandEvent,
298
287
  OTHER_BLOCKED_MESSAGE,
@@ -305,7 +294,6 @@ import {
305
294
  PREVIEW_GEMINI_MODEL,
306
295
  PolicyIntegrityManager,
307
296
  ProjectIdRequiredError,
308
- QuestionType,
309
297
  READ_FILE_DISPLAY_NAME,
310
298
  READ_MANY_FILES_DISPLAY_NAME,
311
299
  RECITATION_BLOCKED_MESSAGE,
@@ -314,22 +302,16 @@ import {
314
302
  SAFETY_BLOCKED_MESSAGE,
315
303
  SHELL_TOOL_NAME,
316
304
  Scheduler,
317
- SessionEndReason,
318
- SessionStartSource,
319
305
  ShellExecutionService,
320
306
  SlashCommandStatus,
321
307
  Storage,
322
- SubagentState,
323
308
  THINKING_ONLY_COMPRESS_SUGGESTION,
324
309
  TOPIC_PARAM_STRATEGIC_INTENT,
325
310
  TOPIC_PARAM_SUMMARY,
326
311
  TOPIC_PARAM_TITLE,
327
312
  TRUE_EMPTY_RESPONSE_MESSAGE,
328
313
  TerminalQuotaError,
329
- ToolConfirmationOutcome,
330
- ToolErrorType,
331
314
  TranscriptionFactory,
332
- TrustLevel,
333
315
  UPDATE_TOPIC_DISPLAY_NAME,
334
316
  UPDATE_TOPIC_TOOL_NAME,
335
317
  UnauthorizedError,
@@ -342,7 +324,6 @@ import {
342
324
  WEB_FETCH_DISPLAY_NAME,
343
325
  WEB_SEARCH_DISPLAY_NAME,
344
326
  WRITE_FILE_DISPLAY_NAME,
345
- WarningPriority,
346
327
  WhisperModelManager,
347
328
  addMCPStatusChangeListener,
348
329
  allowEditorTypeInSandbox,
@@ -450,7 +431,7 @@ import {
450
431
  validatePlanContent,
451
432
  validatePlanPath,
452
433
  writeToStdout
453
- } from "./chunk-UVUPZGTC.js";
434
+ } from "./chunk-K7NOVQ6G.js";
454
435
  import "./chunk-664ZODQF.js";
455
436
  import "./chunk-IUUIT4SU.js";
456
437
  import "./chunk-L6PII3GR.js";
@@ -5077,7 +5058,7 @@ function calculateShellMaxLines(options) {
5077
5058
  if (isAlternateBuffer && isThisShellFocused2 && !constrainHeight) {
5078
5059
  return maxLinesBasedOnHeight;
5079
5060
  }
5080
- const isExecuting = status === CoreToolCallStatus.Executing;
5061
+ const isExecuting = status === "executing" /* Executing */;
5081
5062
  const shellMaxLinesLimit = isExecuting ? ACTIVE_SHELL_MAX_LINES - SHELL_CONTENT_OVERHEAD : COMPLETED_SHELL_MAX_LINES - SHELL_CONTENT_OVERHEAD;
5082
5063
  return Math.min(maxLinesBasedOnHeight, shellMaxLinesLimit);
5083
5064
  }
@@ -5113,13 +5094,13 @@ var formatToolArgs = (args) => {
5113
5094
  var SubagentProgressDisplay = ({ progress, terminalWidth, historyOverrides }) => {
5114
5095
  let headerText;
5115
5096
  let headerColor = theme.text.secondary;
5116
- if (progress.state === SubagentState.CANCELLED) {
5097
+ if (progress.state === "cancelled" /* CANCELLED */) {
5117
5098
  headerText = `Subagent ${progress.agentName} was cancelled.`;
5118
5099
  headerColor = theme.status.warning;
5119
- } else if (progress.state === SubagentState.ERROR) {
5100
+ } else if (progress.state === "error" /* ERROR */) {
5120
5101
  headerText = `Subagent ${progress.agentName} failed.`;
5121
5102
  headerColor = theme.status.error;
5122
- } else if (progress.state === SubagentState.COMPLETED) {
5103
+ } else if (progress.state === "completed" /* COMPLETED */) {
5123
5104
  headerText = `Subagent ${progress.agentName} completed.`;
5124
5105
  headerColor = theme.status.success;
5125
5106
  } else {
@@ -5139,7 +5120,7 @@ var SubagentProgressDisplay = ({ progress, terminalWidth, historyOverrides }) =>
5139
5120
  /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Box_default, { flexGrow: 1, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { color, children: item.content }) })
5140
5121
  ] }, item.id);
5141
5122
  } else if (item.type === "tool_call") {
5142
- const statusSymbol = item.status === SubagentState.RUNNING ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(build_default, { type: "dots" }) : item.status === SubagentState.COMPLETED ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { color: theme.status.success, children: TOOL_STATUS.SUCCESS }) : item.status === SubagentState.CANCELLED ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { color: theme.status.warning, bold: true, children: TOOL_STATUS.CANCELED }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { color: theme.status.error, children: TOOL_STATUS.ERROR });
5123
+ const statusSymbol = item.status === "running" /* RUNNING */ ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(build_default, { type: "dots" }) : item.status === "completed" /* COMPLETED */ ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { color: theme.status.success, children: TOOL_STATUS.SUCCESS }) : item.status === "cancelled" /* CANCELLED */ ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { color: theme.status.warning, bold: true, children: TOOL_STATUS.CANCELED }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text, { color: theme.status.error, children: TOOL_STATUS.ERROR });
5143
5124
  const formattedArgs = item.description || formatToolArgs(item.args);
5144
5125
  const displayArgs = formattedArgs.length > 60 ? formattedArgs.slice(0, 60) + "..." : formattedArgs;
5145
5126
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Box_default, { flexDirection: "row", children: [
@@ -5150,7 +5131,7 @@ var SubagentProgressDisplay = ({ progress, terminalWidth, historyOverrides }) =>
5150
5131
  {
5151
5132
  bold: true,
5152
5133
  color: theme.text.primary,
5153
- strikethrough: item.status === SubagentState.CANCELLED,
5134
+ strikethrough: item.status === "cancelled" /* CANCELLED */,
5154
5135
  children: item.displayName || item.content
5155
5136
  }
5156
5137
  ),
@@ -5159,7 +5140,7 @@ var SubagentProgressDisplay = ({ progress, terminalWidth, historyOverrides }) =>
5159
5140
  {
5160
5141
  color: theme.text.secondary,
5161
5142
  wrap: "truncate",
5162
- strikethrough: item.status === SubagentState.CANCELLED,
5143
+ strikethrough: item.status === "cancelled" /* CANCELLED */,
5163
5144
  children: displayArgs
5164
5145
  }
5165
5146
  ) })
@@ -5179,7 +5160,7 @@ var SubagentProgressDisplay = ({ progress, terminalWidth, historyOverrides }) =>
5179
5160
  MarkdownDisplay,
5180
5161
  {
5181
5162
  text: safeJsonToMarkdown(progress.result),
5182
- isPending: progress.state !== SubagentState.COMPLETED,
5163
+ isPending: progress.state !== "completed" /* COMPLETED */,
5183
5164
  terminalWidth
5184
5165
  }
5185
5166
  )
@@ -5534,7 +5515,7 @@ var ToolActionsProvider = (props) => {
5534
5515
  }
5535
5516
  const details = tool.confirmationDetails;
5536
5517
  if (details?.type === "edit" && isDiffingEnabled && "filePath" in details) {
5537
- const cliOutcome = outcome === ToolConfirmationOutcome.Cancel ? "rejected" : "accepted";
5518
+ const cliOutcome = outcome === "cancel" /* Cancel */ ? "rejected" : "accepted";
5538
5519
  if (ideClient) {
5539
5520
  void ideClient.resolveDiffFromCli(details.filePath, cliOutcome)?.catch((error) => {
5540
5521
  debugLogger.error(
@@ -5546,9 +5527,9 @@ var ToolActionsProvider = (props) => {
5546
5527
  }
5547
5528
  if (tool.correlationId) {
5548
5529
  await config.getMessageBus().publish({
5549
- type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
5530
+ type: "tool-confirmation-response" /* TOOL_CONFIRMATION_RESPONSE */,
5550
5531
  correlationId: tool.correlationId,
5551
- confirmed: outcome !== ToolConfirmationOutcome.Cancel,
5532
+ confirmed: outcome !== "cancel" /* Cancel */,
5552
5533
  requiresUserConfirmation: false,
5553
5534
  outcome,
5554
5535
  payload
@@ -5567,7 +5548,7 @@ var ToolActionsProvider = (props) => {
5567
5548
  );
5568
5549
  const cancel = (0, import_react10.useCallback)(
5569
5550
  async (callId) => {
5570
- await confirm(callId, ToolConfirmationOutcome.Cancel);
5551
+ await confirm(callId, "cancel" /* Cancel */);
5571
5552
  },
5572
5553
  [confirm]
5573
5554
  );
@@ -5688,7 +5669,7 @@ var ToolMessage = ({
5688
5669
  paddingX: 1,
5689
5670
  flexDirection: "column",
5690
5671
  children: [
5691
- status === CoreToolCallStatus.Executing && progress !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5672
+ status === "executing" /* Executing */ && progress !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
5692
5673
  McpProgressIndicator,
5693
5674
  {
5694
5675
  progress,
@@ -5705,8 +5686,8 @@ var ToolMessage = ({
5705
5686
  terminalWidth: safeTerminalWidth,
5706
5687
  renderOutputAsMarkdown,
5707
5688
  hasFocus: isThisShellFocused2,
5708
- maxLines: kind === Kind.Agent && availableTerminalHeight !== void 0 ? SUBAGENT_MAX_LINES : void 0,
5709
- overflowDirection: kind === Kind.Agent ? "bottom" : "top"
5689
+ maxLines: kind === "agent" /* Agent */ && availableTerminalHeight !== void 0 ? SUBAGENT_MAX_LINES : void 0,
5690
+ overflowDirection: kind === "agent" /* Agent */ ? "bottom" : "top"
5710
5691
  }
5711
5692
  ),
5712
5693
  isThisShellFocused2 && config && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Box_default, { paddingLeft: STATUS_INDICATOR_WIDTH, marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -6022,7 +6003,7 @@ function getInitialTrustState(settings, cwd5, isCurrentWorkspace) {
6022
6003
  settings.merged,
6023
6004
  process3.cwd()
6024
6005
  );
6025
- const isInheritedTrust = isTrusted && (!explicitTrustLevel || explicitTrustLevel === TrustLevel.DO_NOT_TRUST);
6006
+ const isInheritedTrust = isTrusted && (!explicitTrustLevel || explicitTrustLevel === "DO_NOT_TRUST" /* DO_NOT_TRUST */);
6026
6007
  return {
6027
6008
  currentTrustLevel: explicitTrustLevel,
6028
6009
  isInheritedTrustFromParent: !!(source === "file" && isInheritedTrust),
@@ -6067,7 +6048,7 @@ var usePermissionsModifyTrust = (onExit, addItem, targetDirectory) => {
6067
6048
  process3.cwd(),
6068
6049
  newConfig
6069
6050
  );
6070
- if (trustLevel === TrustLevel.DO_NOT_TRUST && isTrusted) {
6051
+ if (trustLevel === "DO_NOT_TRUST" /* DO_NOT_TRUST */ && isTrusted) {
6071
6052
  let message = "Note: This folder is still trusted because the connected IDE workspace is trusted.";
6072
6053
  if (source === "file") {
6073
6054
  message = "Note: This folder is still trusted because a parent folder is trusted.";
@@ -6141,18 +6122,18 @@ function PermissionsModifyTrustDialog({
6141
6122
  const TRUST_LEVEL_ITEMS = [
6142
6123
  {
6143
6124
  label: `Trust this folder (${dirName})`,
6144
- value: TrustLevel.TRUST_FOLDER,
6145
- key: TrustLevel.TRUST_FOLDER
6125
+ value: "TRUST_FOLDER" /* TRUST_FOLDER */,
6126
+ key: "TRUST_FOLDER" /* TRUST_FOLDER */
6146
6127
  },
6147
6128
  {
6148
6129
  label: `Trust parent folder (${parentFolder})`,
6149
- value: TrustLevel.TRUST_PARENT,
6150
- key: TrustLevel.TRUST_PARENT
6130
+ value: "TRUST_PARENT" /* TRUST_PARENT */,
6131
+ key: "TRUST_PARENT" /* TRUST_PARENT */
6151
6132
  },
6152
6133
  {
6153
6134
  label: "Don't trust",
6154
- value: TrustLevel.DO_NOT_TRUST,
6155
- key: TrustLevel.DO_NOT_TRUST
6135
+ value: "DO_NOT_TRUST" /* DO_NOT_TRUST */,
6136
+ key: "DO_NOT_TRUST" /* DO_NOT_TRUST */
6156
6137
  }
6157
6138
  ];
6158
6139
  const {
@@ -6393,7 +6374,7 @@ var ShellToolMessage = ({
6393
6374
  maxLinesLimit: maxLines
6394
6375
  });
6395
6376
  import_react15.default.useEffect(() => {
6396
- const isExecuting = status === CoreToolCallStatus.Executing;
6377
+ const isExecuting = status === "executing" /* Executing */;
6397
6378
  if (isExecuting && ptyId) {
6398
6379
  try {
6399
6380
  const childWidth = safeTerminalWidth - 4;
@@ -6607,13 +6588,13 @@ var SubagentGroupDisplay = ({
6607
6588
  const singleAgent = toolCalls[0].resultDisplay;
6608
6589
  if (isSubagentProgress(singleAgent)) {
6609
6590
  switch (singleAgent.state) {
6610
- case SubagentState.COMPLETED:
6591
+ case "completed" /* COMPLETED */:
6611
6592
  headerText = "Agent Completed";
6612
6593
  break;
6613
- case SubagentState.CANCELLED:
6594
+ case "cancelled" /* CANCELLED */:
6614
6595
  headerText = "Agent Cancelled";
6615
6596
  break;
6616
- case SubagentState.ERROR:
6597
+ case "error" /* ERROR */:
6617
6598
  headerText = "Agent Error";
6618
6599
  break;
6619
6600
  default:
@@ -6629,8 +6610,8 @@ var SubagentGroupDisplay = ({
6629
6610
  for (const tc of toolCalls) {
6630
6611
  const progress = tc.resultDisplay;
6631
6612
  if (isSubagentProgress(progress)) {
6632
- if (progress.state === SubagentState.COMPLETED) completedCount++;
6633
- else if (progress.state === SubagentState.RUNNING) runningCount++;
6613
+ if (progress.state === "completed" /* COMPLETED */) completedCount++;
6614
+ else if (progress.state === "running" /* RUNNING */) runningCount++;
6634
6615
  } else {
6635
6616
  runningCount++;
6636
6617
  }
@@ -6709,7 +6690,7 @@ var SubagentGroupDisplay = ({
6709
6690
  if (!isExpanded) {
6710
6691
  let content = "Starting...";
6711
6692
  let formattedArgs;
6712
- if (progress.state === SubagentState.COMPLETED) {
6693
+ if (progress.state === "completed" /* COMPLETED */) {
6713
6694
  if (progress.terminateReason && progress.terminateReason !== "GOAL") {
6714
6695
  content = `Finished Early (${progress.terminateReason})`;
6715
6696
  } else {
@@ -6723,17 +6704,17 @@ var SubagentGroupDisplay = ({
6723
6704
  formattedArgs = formatToolArgs(lastActivity.args);
6724
6705
  }
6725
6706
  }
6726
- const displayArgs = progress.state === SubagentState.COMPLETED ? "" : formattedArgs;
6707
+ const displayArgs = progress.state === "completed" /* COMPLETED */ ? "" : formattedArgs;
6727
6708
  const renderStatusIcon = () => {
6728
- const state = progress.state ?? SubagentState.RUNNING;
6709
+ const state = progress.state ?? "running" /* RUNNING */;
6729
6710
  switch (state) {
6730
- case SubagentState.RUNNING:
6711
+ case "running" /* RUNNING */:
6731
6712
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text, { color: theme.text.primary, children: "!" });
6732
- case SubagentState.COMPLETED:
6713
+ case "completed" /* COMPLETED */:
6733
6714
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text, { color: theme.status.success, children: "\u2713" });
6734
- case SubagentState.CANCELLED:
6715
+ case "cancelled" /* CANCELLED */:
6735
6716
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text, { color: theme.status.warning, children: "\u2139" });
6736
- case SubagentState.ERROR:
6717
+ case "error" /* ERROR */:
6737
6718
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Text, { color: theme.status.error, children: "\u2717" });
6738
6719
  default:
6739
6720
  return checkExhaustive(state);
@@ -6786,22 +6767,22 @@ var hasPayload = (res) => {
6786
6767
  function getFileOpData(diff, status, resultDisplay, terminalWidth, availableTerminalHeight, isClickable) {
6787
6768
  const added = (diff.diffStat?.model_added_lines ?? 0) + (diff.diffStat?.user_added_lines ?? 0);
6788
6769
  const removed = (diff.diffStat?.model_removed_lines ?? 0) + (diff.diffStat?.user_removed_lines ?? 0);
6789
- const isAcceptedOrConfirming = status === CoreToolCallStatus.Success || status === CoreToolCallStatus.Executing || status === CoreToolCallStatus.AwaitingApproval;
6770
+ const isAcceptedOrConfirming = status === "success" /* Success */ || status === "executing" /* Executing */ || status === "awaiting_approval" /* AwaitingApproval */;
6790
6771
  const addColor = isAcceptedOrConfirming ? theme.status.success : theme.text.secondary;
6791
6772
  const removeColor = isAcceptedOrConfirming ? theme.status.error : theme.text.secondary;
6792
6773
  const showDiffStat = !!diff.diffStat;
6793
6774
  const description = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Box_default, { flexDirection: "row", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Text, { color: theme.text.secondary, wrap: "truncate-end", children: diff.fileName }) });
6794
6775
  let resultSummary = "";
6795
6776
  let resultColor = theme.text.secondary;
6796
- if (status === CoreToolCallStatus.AwaitingApproval) {
6777
+ if (status === "awaiting_approval" /* AwaitingApproval */) {
6797
6778
  resultSummary = "Confirming";
6798
- } else if (status === CoreToolCallStatus.Success || status === CoreToolCallStatus.Executing) {
6779
+ } else if (status === "success" /* Success */ || status === "executing" /* Executing */) {
6799
6780
  resultSummary = "Accepted";
6800
6781
  resultColor = theme.text.accent;
6801
- } else if (status === CoreToolCallStatus.Cancelled) {
6782
+ } else if (status === "cancelled" /* Cancelled */) {
6802
6783
  resultSummary = "Rejected";
6803
6784
  resultColor = theme.status.error;
6804
- } else if (status === CoreToolCallStatus.Error) {
6785
+ } else if (status === "error" /* Error */) {
6805
6786
  resultSummary = typeof resultDisplay === "string" ? resultDisplay : "Failed";
6806
6787
  resultColor = theme.status.error;
6807
6788
  }
@@ -6832,7 +6813,7 @@ function getFileOpData(diff, status, resultDisplay, terminalWidth, availableTerm
6832
6813
  filename: diff.fileName,
6833
6814
  terminalWidth: Math.max(0, (terminalWidth || 0) - PAYLOAD_MARGIN_LEFT),
6834
6815
  availableTerminalHeight,
6835
- disableColor: status === CoreToolCallStatus.Cancelled
6816
+ disableColor: status === "cancelled" /* Cancelled */
6836
6817
  }
6837
6818
  );
6838
6819
  return { description, summary, payload };
@@ -6960,10 +6941,10 @@ var DenseToolMessage = (props) => {
6960
6941
  if (isGrepResult(resultDisplay)) {
6961
6942
  return getGenericSuccessData(resultDisplay, originalDescription);
6962
6943
  }
6963
- if (status === CoreToolCallStatus.Success && resultDisplay) {
6944
+ if (status === "success" /* Success */ && resultDisplay) {
6964
6945
  return getGenericSuccessData(resultDisplay, originalDescription);
6965
6946
  }
6966
- if (status === CoreToolCallStatus.Error) {
6947
+ if (status === "error" /* Error */) {
6967
6948
  const text = typeof resultDisplay === "string" ? resultDisplay.replace(/\n/g, " ") : "Failed";
6968
6949
  const errorSummary = /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Text, { color: theme.status.error, wrap: "truncate-end", children: [
6969
6950
  "\u2192 ",
@@ -7004,7 +6985,7 @@ var DenseToolMessage = (props) => {
7004
6985
  language: fileExtension,
7005
6986
  maxWidth: Math.max(0, (terminalWidth || 0) - PAYLOAD_MARGIN_LEFT),
7006
6987
  settings,
7007
- disableColor: status === CoreToolCallStatus.Cancelled,
6988
+ disableColor: status === "cancelled" /* Cancelled */,
7008
6989
  returnLines: true
7009
6990
  });
7010
6991
  } else {
@@ -7012,7 +6993,7 @@ var DenseToolMessage = (props) => {
7012
6993
  parsedLines,
7013
6994
  filename: diff.fileName,
7014
6995
  terminalWidth: Math.max(0, (terminalWidth || 0) - PAYLOAD_MARGIN_LEFT),
7015
- disableColor: status === CoreToolCallStatus.Cancelled
6996
+ disableColor: status === "cancelled" /* Cancelled */
7016
6997
  });
7017
6998
  }
7018
6999
  }, [diff, isExpanded, isAlternateBuffer, terminalWidth, settings, status]);
@@ -7149,7 +7130,7 @@ function isToolExecuting(pendingHistoryItems) {
7149
7130
  return pendingHistoryItems.some((item) => {
7150
7131
  if (item && item.type === "tool_group") {
7151
7132
  return item.tools.some(
7152
- (tool) => CoreToolCallStatus.Executing === tool.status
7133
+ (tool) => "executing" /* Executing */ === tool.status
7153
7134
  );
7154
7135
  }
7155
7136
  return false;
@@ -7158,7 +7139,7 @@ function isToolExecuting(pendingHistoryItems) {
7158
7139
  function isToolAwaitingConfirmation(pendingHistoryItems) {
7159
7140
  return pendingHistoryItems.filter((item) => item.type === "tool_group").some(
7160
7141
  (item) => item.tools.some(
7161
- (tool) => CoreToolCallStatus.AwaitingApproval === tool.status
7142
+ (tool) => "awaiting_approval" /* AwaitingApproval */ === tool.status
7162
7143
  )
7163
7144
  );
7164
7145
  }
@@ -7246,7 +7227,7 @@ var ToolGroupMessage = ({
7246
7227
  const groupedTools = (0, import_react19.useMemo)(() => {
7247
7228
  const groups = [];
7248
7229
  for (const tool of visibleToolCalls) {
7249
- if (tool.kind === Kind.Agent) {
7230
+ if (tool.kind === "agent" /* Agent */) {
7250
7231
  const lastGroup = groups[groups.length - 1];
7251
7232
  if (Array.isArray(lastGroup)) {
7252
7233
  lastGroup.push(tool);
@@ -7301,7 +7282,7 @@ var ToolGroupMessage = ({
7301
7282
  }, [groupedTools, isCompactModeEnabled, borderTopOverride]);
7302
7283
  let countToolCallsWithResults = 0;
7303
7284
  for (const tool of visibleToolCalls) {
7304
- if (tool.kind !== Kind.Agent) {
7285
+ if (tool.kind !== "agent" /* Agent */) {
7305
7286
  if (isCompactTool(tool, isCompactModeEnabled)) {
7306
7287
  if (hasDensePayload(tool)) {
7307
7288
  countToolCallsWithResults++;
@@ -7492,7 +7473,7 @@ var ToolGroupDisplay = ({
7492
7473
  }
7493
7474
  const { tools, borderColor, borderDimColor, borderTop, borderBottom } = item;
7494
7475
  const visibleTools = tools.filter(
7495
- (t) => t.status !== CoreToolCallStatus.AwaitingApproval
7476
+ (t) => t.status !== "awaiting_approval" /* AwaitingApproval */
7496
7477
  );
7497
7478
  const noticeTools = visibleTools.filter((t) => t.format === "notice");
7498
7479
  const otherTools = visibleTools.filter(
@@ -7694,18 +7675,18 @@ function CompressionMessage({
7694
7675
  return "Compressing chat history";
7695
7676
  }
7696
7677
  switch (compressionStatus) {
7697
- case CompressionStatus.COMPRESSED:
7678
+ case 1 /* COMPRESSED */:
7698
7679
  return `Chat history compressed from ${originalTokens} to ${newTokens} tokens.`;
7699
- case CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT:
7680
+ case 2 /* COMPRESSION_FAILED_INFLATED_TOKEN_COUNT */:
7700
7681
  if (originalTokens < 5e4) {
7701
7682
  return "Compression was not beneficial for this history size.";
7702
7683
  }
7703
7684
  return "Chat history compression did not reduce size. This may indicate issues with the compression prompt.";
7704
- case CompressionStatus.COMPRESSION_FAILED_TOKEN_COUNT_ERROR:
7685
+ case 3 /* COMPRESSION_FAILED_TOKEN_COUNT_ERROR */:
7705
7686
  return "Could not compress chat history due to a token counting error.";
7706
- case CompressionStatus.COMPRESSION_FAILED_EMPTY_SUMMARY:
7687
+ case 4 /* COMPRESSION_FAILED_EMPTY_SUMMARY */:
7707
7688
  return "Chat history compression failed: the model returned an empty summary.";
7708
- case CompressionStatus.NOOP:
7689
+ case 5 /* NOOP */:
7709
7690
  return "Nothing to compress.";
7710
7691
  default:
7711
7692
  return "";
@@ -8143,8 +8124,8 @@ var ModelUsageTable = ({ models }) => {
8143
8124
  );
8144
8125
  roleEntries.sort(([a], [b]) => {
8145
8126
  if (a === b) return 0;
8146
- if (a === LlmRole.MAIN) return -1;
8147
- if (b === LlmRole.MAIN) return 1;
8127
+ if (a === "main" /* MAIN */) return -1;
8128
+ if (b === "main" /* MAIN */) return 1;
8148
8129
  return a.localeCompare(b);
8149
8130
  });
8150
8131
  roleEntries.forEach(([role, roleMetrics]) => {
@@ -8475,8 +8456,8 @@ var ModelStatsDisplay = ({
8475
8456
  return validRoles.includes(role);
8476
8457
  }).sort((a, b) => {
8477
8458
  if (a === b) return 0;
8478
- if (a === LlmRole.MAIN) return -1;
8479
- if (b === LlmRole.MAIN) return 1;
8459
+ if (a === "main" /* MAIN */) return -1;
8460
+ if (b === "main" /* MAIN */) return 1;
8480
8461
  return a.localeCompare(b);
8481
8462
  });
8482
8463
  const createRow = (metric, getValue, options = {}) => {
@@ -9267,7 +9248,7 @@ var McpStatus = ({
9267
9248
  );
9268
9249
  const originalStatus = serverStatus(serverName);
9269
9250
  const hasCachedItems = serverTools.length > 0 || serverPrompts.length > 0 || serverResources.length > 0;
9270
- const status = originalStatus === MCPServerStatus.DISCONNECTED && hasCachedItems ? MCPServerStatus.CONNECTED : originalStatus;
9251
+ const status = originalStatus === "disconnected" /* DISCONNECTED */ && hasCachedItems ? "connected" /* CONNECTED */ : originalStatus;
9271
9252
  let statusIndicator = "";
9272
9253
  let statusText = "";
9273
9254
  let statusColor = theme.text.primary;
@@ -9279,17 +9260,17 @@ var McpStatus = ({
9279
9260
  statusColor = theme.text.secondary;
9280
9261
  } else {
9281
9262
  switch (status) {
9282
- case MCPServerStatus.CONNECTED:
9263
+ case "connected" /* CONNECTED */:
9283
9264
  statusIndicator = "\u{1F7E2}";
9284
9265
  statusText = "Ready";
9285
9266
  statusColor = theme.status.success;
9286
9267
  break;
9287
- case MCPServerStatus.CONNECTING:
9268
+ case "connecting" /* CONNECTING */:
9288
9269
  statusIndicator = "\u{1F504}";
9289
9270
  statusText = "Starting... (first startup may take longer)";
9290
9271
  statusColor = theme.status.warning;
9291
9272
  break;
9292
- case MCPServerStatus.DISCONNECTED:
9273
+ case "disconnected" /* DISCONNECTED */:
9293
9274
  default:
9294
9275
  statusIndicator = "\u{1F534}";
9295
9276
  statusText = "Disconnected";
@@ -9337,12 +9318,12 @@ var McpStatus = ({
9337
9318
  /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(Text, { children: [
9338
9319
  " - ",
9339
9320
  statusText,
9340
- status === MCPServerStatus.CONNECTED && parts.length > 0 && ` (${parts.join(", ")})`
9321
+ status === "connected" /* CONNECTED */ && parts.length > 0 && ` (${parts.join(", ")})`
9341
9322
  ] }),
9342
9323
  authStatusNode
9343
9324
  ] }),
9344
- status === MCPServerStatus.CONNECTING && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Text, { children: " (tools and prompts will appear when ready)" }),
9345
- status === MCPServerStatus.DISCONNECTED && toolCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(Text, { children: [
9325
+ status === "connecting" /* CONNECTING */ && /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Text, { children: " (tools and prompts will appear when ready)" }),
9326
+ status === "disconnected" /* DISCONNECTED */ && toolCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(Text, { children: [
9346
9327
  " (",
9347
9328
  toolCount,
9348
9329
  " tools cached)"
@@ -9903,7 +9884,7 @@ var Notifications = () => {
9903
9884
  if (dismissed) return [];
9904
9885
  const counts = persistentState.get("startupWarningCounts") || {};
9905
9886
  return startupWarnings.filter((w) => {
9906
- if (w.priority === WarningPriority.Low) {
9887
+ if (w.priority === "low" /* Low */) {
9907
9888
  const count = counts[w.id] || 0;
9908
9889
  return count < MAX_STARTUP_WARNING_SHOW_COUNT;
9909
9890
  }
@@ -9916,7 +9897,7 @@ var Notifications = () => {
9916
9897
  const counts = { ...persistentState.get("startupWarningCounts") || {} };
9917
9898
  let changed = false;
9918
9899
  visibleWarnings.forEach((w) => {
9919
- if (w.priority === WarningPriority.Low) {
9900
+ if (w.priority === "low" /* Low */) {
9920
9901
  counts[w.id] = (counts[w.id] || 0) + 1;
9921
9902
  changed = true;
9922
9903
  }
@@ -10023,7 +10004,7 @@ var UserIdentity = ({ config }) => {
10023
10004
  }
10024
10005
  return /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Box_default, { flexDirection: "column", children: [
10025
10006
  /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Box_default, { children: [
10026
- /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(Text, { color: theme.text.primary, wrap: "truncate-end", children: authType === AuthType.LOGIN_WITH_GOOGLE ? /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Text, { children: [
10007
+ /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(Text, { color: theme.text.primary, wrap: "truncate-end", children: authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ ? /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Text, { children: [
10027
10008
  /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Text, { bold: true, children: [
10028
10009
  "Signed in with Google",
10029
10010
  email ? ":" : ""
@@ -10266,7 +10247,7 @@ var import_react30 = __toESM(require_react(), 1);
10266
10247
  function getConfirmingToolState(pendingHistoryItems) {
10267
10248
  const allPendingTools = getAllToolCalls(pendingHistoryItems);
10268
10249
  const confirmingTools = allPendingTools.filter(
10269
- (tool) => tool.status === CoreToolCallStatus.AwaitingApproval
10250
+ (tool) => tool.status === "awaiting_approval" /* AwaitingApproval */
10270
10251
  );
10271
10252
  if (confirmingTools.length === 0) {
10272
10253
  return null;
@@ -11576,7 +11557,7 @@ var ExitPlanModeDialog = ({
11576
11557
  {
11577
11558
  questions: [
11578
11559
  {
11579
- type: QuestionType.CHOICE,
11560
+ type: "choice" /* CHOICE */,
11580
11561
  header: "Approval",
11581
11562
  question: planContent,
11582
11563
  options: [
@@ -11597,9 +11578,9 @@ var ExitPlanModeDialog = ({
11597
11578
  onSubmit: (answers) => {
11598
11579
  const answer = answers["0"];
11599
11580
  if (answer === "Yes, automatically accept edits" /* Auto */) {
11600
- onApprove(ApprovalMode.AUTO_EDIT);
11581
+ onApprove("autoEdit" /* AUTO_EDIT */);
11601
11582
  } else if (answer === "Yes, manually accept edits" /* Manual */) {
11602
- onApprove(ApprovalMode.DEFAULT);
11583
+ onApprove("default" /* DEFAULT */);
11603
11584
  } else if (answer) {
11604
11585
  onFeedback(answer);
11605
11586
  }
@@ -11811,7 +11792,7 @@ ${deceptiveUrlWarnings.map(
11811
11792
  );
11812
11793
  (0, import_react35.useEffect)(() => {
11813
11794
  if (isCancelling) {
11814
- handleConfirm(ToolConfirmationOutcome.Cancel);
11795
+ handleConfirm("cancel" /* Cancel */);
11815
11796
  }
11816
11797
  }, [isCancelling, handleConfirm]);
11817
11798
  const handleSelect = (0, import_react35.useCallback)(
@@ -11824,19 +11805,19 @@ ${deceptiveUrlWarnings.map(
11824
11805
  if (!confirmationDetails.isModifying) {
11825
11806
  options2.push({
11826
11807
  label: "Allow once",
11827
- value: ToolConfirmationOutcome.ProceedOnce,
11808
+ value: "proceed_once" /* ProceedOnce */,
11828
11809
  key: "Allow once"
11829
11810
  });
11830
11811
  if (isTrustedFolder && !confirmationDetails.isBuildFile) {
11831
11812
  options2.push({
11832
11813
  label: "Allow for this session",
11833
- value: ToolConfirmationOutcome.ProceedAlways,
11814
+ value: "proceed_always" /* ProceedAlways */,
11834
11815
  key: "Allow for this session"
11835
11816
  });
11836
11817
  if (allowPermanentApproval) {
11837
11818
  options2.push({
11838
11819
  label: "Allow for this file in all future sessions",
11839
- value: ToolConfirmationOutcome.ProceedAlwaysAndSave,
11820
+ value: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
11840
11821
  key: "Allow for this file in all future sessions"
11841
11822
  });
11842
11823
  }
@@ -11844,45 +11825,45 @@ ${deceptiveUrlWarnings.map(
11844
11825
  if (!config.getIdeMode() || !isDiffingEnabled) {
11845
11826
  options2.push({
11846
11827
  label: "Modify with external editor",
11847
- value: ToolConfirmationOutcome.ModifyWithEditor,
11828
+ value: "modify_with_editor" /* ModifyWithEditor */,
11848
11829
  key: "Modify with external editor"
11849
11830
  });
11850
11831
  }
11851
11832
  options2.push({
11852
11833
  label: "No, suggest changes (esc)",
11853
- value: ToolConfirmationOutcome.Cancel,
11834
+ value: "cancel" /* Cancel */,
11854
11835
  key: "No, suggest changes (esc)"
11855
11836
  });
11856
11837
  }
11857
11838
  } else if (confirmationDetails.type === "sandbox_expansion") {
11858
11839
  options2.push({
11859
11840
  label: "Allow once",
11860
- value: ToolConfirmationOutcome.ProceedOnce,
11841
+ value: "proceed_once" /* ProceedOnce */,
11861
11842
  key: "Allow once"
11862
11843
  });
11863
11844
  if (isTrustedFolder) {
11864
11845
  options2.push({
11865
11846
  label: "Allow for this session",
11866
- value: ToolConfirmationOutcome.ProceedAlways,
11847
+ value: "proceed_always" /* ProceedAlways */,
11867
11848
  key: "Allow for this session"
11868
11849
  });
11869
11850
  if (allowPermanentApproval) {
11870
11851
  options2.push({
11871
11852
  label: "Allow for all future sessions",
11872
- value: ToolConfirmationOutcome.ProceedAlwaysAndSave,
11853
+ value: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
11873
11854
  key: "Allow for all future sessions"
11874
11855
  });
11875
11856
  }
11876
11857
  }
11877
11858
  options2.push({
11878
11859
  label: "No, suggest changes (esc)",
11879
- value: ToolConfirmationOutcome.Cancel,
11860
+ value: "cancel" /* Cancel */,
11880
11861
  key: "No, suggest changes (esc)"
11881
11862
  });
11882
11863
  } else if (confirmationDetails.type === "exec") {
11883
11864
  options2.push({
11884
11865
  label: "Allow once",
11885
- value: ToolConfirmationOutcome.ProceedOnce,
11866
+ value: "proceed_once" /* ProceedOnce */,
11886
11867
  key: "Allow once"
11887
11868
  });
11888
11869
  const hasUntrustedFlags = confirmationDetails.untrustedFlags && confirmationDetails.untrustedFlags.length > 0;
@@ -11890,75 +11871,75 @@ ${deceptiveUrlWarnings.map(
11890
11871
  if (isTrustedFolder && !hasUntrustedFlags && !hasModifiedBuildFiles) {
11891
11872
  options2.push({
11892
11873
  label: `Allow for this session`,
11893
- value: ToolConfirmationOutcome.ProceedAlways,
11874
+ value: "proceed_always" /* ProceedAlways */,
11894
11875
  key: `Allow for this session`
11895
11876
  });
11896
11877
  if (allowPermanentApproval) {
11897
11878
  options2.push({
11898
11879
  label: `Allow this command for all future sessions`,
11899
- value: ToolConfirmationOutcome.ProceedAlwaysAndSave,
11880
+ value: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
11900
11881
  key: `Allow for all future sessions`
11901
11882
  });
11902
11883
  }
11903
11884
  }
11904
11885
  options2.push({
11905
11886
  label: "No, suggest changes (esc)",
11906
- value: ToolConfirmationOutcome.Cancel,
11887
+ value: "cancel" /* Cancel */,
11907
11888
  key: "No, suggest changes (esc)"
11908
11889
  });
11909
11890
  } else if (confirmationDetails.type === "info") {
11910
11891
  options2.push({
11911
11892
  label: "Allow once",
11912
- value: ToolConfirmationOutcome.ProceedOnce,
11893
+ value: "proceed_once" /* ProceedOnce */,
11913
11894
  key: "Allow once"
11914
11895
  });
11915
11896
  if (isTrustedFolder) {
11916
11897
  options2.push({
11917
11898
  label: "Allow for this session",
11918
- value: ToolConfirmationOutcome.ProceedAlways,
11899
+ value: "proceed_always" /* ProceedAlways */,
11919
11900
  key: "Allow for this session"
11920
11901
  });
11921
11902
  if (allowPermanentApproval) {
11922
11903
  options2.push({
11923
11904
  label: "Allow for all future sessions",
11924
- value: ToolConfirmationOutcome.ProceedAlwaysAndSave,
11905
+ value: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
11925
11906
  key: "Allow for all future sessions"
11926
11907
  });
11927
11908
  }
11928
11909
  }
11929
11910
  options2.push({
11930
11911
  label: "No, suggest changes (esc)",
11931
- value: ToolConfirmationOutcome.Cancel,
11912
+ value: "cancel" /* Cancel */,
11932
11913
  key: "No, suggest changes (esc)"
11933
11914
  });
11934
11915
  } else if (confirmationDetails.type === "mcp") {
11935
11916
  options2.push({
11936
11917
  label: "Allow once",
11937
- value: ToolConfirmationOutcome.ProceedOnce,
11918
+ value: "proceed_once" /* ProceedOnce */,
11938
11919
  key: "Allow once"
11939
11920
  });
11940
11921
  if (isTrustedFolder) {
11941
11922
  options2.push({
11942
11923
  label: "Allow tool for this session",
11943
- value: ToolConfirmationOutcome.ProceedAlwaysTool,
11924
+ value: "proceed_always_tool" /* ProceedAlwaysTool */,
11944
11925
  key: "Allow tool for this session"
11945
11926
  });
11946
11927
  options2.push({
11947
11928
  label: "Allow all server tools for this session",
11948
- value: ToolConfirmationOutcome.ProceedAlwaysServer,
11929
+ value: "proceed_always_server" /* ProceedAlwaysServer */,
11949
11930
  key: "Allow all server tools for this session"
11950
11931
  });
11951
11932
  if (allowPermanentApproval) {
11952
11933
  options2.push({
11953
11934
  label: "Allow tool for all future sessions",
11954
- value: ToolConfirmationOutcome.ProceedAlwaysAndSave,
11935
+ value: "proceed_always_and_save" /* ProceedAlwaysAndSave */,
11955
11936
  key: "Allow tool for all future sessions"
11956
11937
  });
11957
11938
  }
11958
11939
  }
11959
11940
  options2.push({
11960
11941
  label: "No, suggest changes (esc)",
11961
- value: ToolConfirmationOutcome.Cancel,
11942
+ value: "cancel" /* Cancel */,
11962
11943
  key: "No, suggest changes (esc)"
11963
11944
  });
11964
11945
  }
@@ -11999,7 +11980,7 @@ ${deceptiveUrlWarnings.map(
11999
11980
  const containsRedirection = commandsToDisplay.some(
12000
11981
  (cmd) => hasRedirection(cmd)
12001
11982
  );
12002
- const isAutoEdit = config.getApprovalMode() === ApprovalMode.YOLO || config.getApprovalMode() === ApprovalMode.AUTO_EDIT;
11983
+ const isAutoEdit = config.getApprovalMode() === "yolo" /* YOLO */ || config.getApprovalMode() === "autoEdit" /* AUTO_EDIT */;
12003
11984
  if (containsRedirection && !isAutoEdit) {
12004
11985
  extraInfoLines = 1;
12005
11986
  }
@@ -12026,7 +12007,7 @@ ${deceptiveUrlWarnings.map(
12026
12007
  const isSafeToPersist = confirmationDetails.type === "info" || confirmationDetails.type === "edit" || confirmationDetails.type === "mcp";
12027
12008
  if (isSafeToPersist && settings.merged.security.autoAddToPolicyByDefault) {
12028
12009
  const alwaysAndSaveIndex = options2.findIndex(
12029
- (o) => o.value === ToolConfirmationOutcome.ProceedAlwaysAndSave
12010
+ (o) => o.value === "proceed_always_and_save" /* ProceedAlwaysAndSave */
12030
12011
  );
12031
12012
  if (alwaysAndSaveIndex !== -1) {
12032
12013
  initialIndex2 = alwaysAndSaveIndex;
@@ -12075,10 +12056,10 @@ Ensure you trust all modifications made to build files before approving executio
12075
12056
  {
12076
12057
  questions: confirmationDetails.questions,
12077
12058
  onSubmit: (answers) => {
12078
- handleConfirm(ToolConfirmationOutcome.ProceedOnce, { answers });
12059
+ handleConfirm("proceed_once" /* ProceedOnce */, { answers });
12079
12060
  },
12080
12061
  onCancel: () => {
12081
- handleConfirm(ToolConfirmationOutcome.Cancel);
12062
+ handleConfirm("cancel" /* Cancel */);
12082
12063
  },
12083
12064
  width: safeTerminalWidth,
12084
12065
  availableHeight: bodyHeight
@@ -12099,19 +12080,19 @@ Ensure you trust all modifications made to build files before approving executio
12099
12080
  planPath: confirmationDetails.planPath,
12100
12081
  getPreferredEditor,
12101
12082
  onApprove: (approvalMode) => {
12102
- handleConfirm(ToolConfirmationOutcome.ProceedOnce, {
12083
+ handleConfirm("proceed_once" /* ProceedOnce */, {
12103
12084
  approved: true,
12104
12085
  approvalMode
12105
12086
  });
12106
12087
  },
12107
12088
  onFeedback: (feedback) => {
12108
- handleConfirm(ToolConfirmationOutcome.ProceedOnce, {
12089
+ handleConfirm("proceed_once" /* ProceedOnce */, {
12109
12090
  approved: false,
12110
12091
  feedback
12111
12092
  });
12112
12093
  },
12113
12094
  onCancel: () => {
12114
- handleConfirm(ToolConfirmationOutcome.Cancel);
12095
+ handleConfirm("cancel" /* Cancel */);
12115
12096
  },
12116
12097
  width: safeTerminalWidth,
12117
12098
  availableHeight: bodyHeight
@@ -12221,7 +12202,7 @@ Ensure you trust all modifications made to build files before approving executio
12221
12202
  const containsRedirection = commandsToDisplay.some(
12222
12203
  (cmd) => hasRedirection(cmd)
12223
12204
  );
12224
- const isAutoEdit = config.getApprovalMode() === ApprovalMode.YOLO || config.getApprovalMode() === ApprovalMode.AUTO_EDIT;
12205
+ const isAutoEdit = config.getApprovalMode() === "yolo" /* YOLO */ || config.getApprovalMode() === "autoEdit" /* AUTO_EDIT */;
12225
12206
  let warnings = null;
12226
12207
  if (containsRedirection && !isAutoEdit) {
12227
12208
  const tipText = `To auto-accept, press ${formatCommand("app.cycleApprovalMode" /* CYCLE_APPROVAL_MODE */)}`;
@@ -12380,7 +12361,7 @@ Ensure you trust all modifications made to build files before approving executio
12380
12361
  const bodyOverflowDirection = confirmationDetails.type === "mcp" && isMcpToolDetailsExpanded ? "bottom" : "top";
12381
12362
  const renderRadioItem = (0, import_react35.useCallback)(
12382
12363
  (item, { titleColor }) => {
12383
- if (item.value === ToolConfirmationOutcome.ProceedAlwaysAndSave) {
12364
+ if (item.value === "proceed_always_and_save" /* ProceedAlwaysAndSave */) {
12384
12365
  return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Text, { color: titleColor, wrap: "truncate", children: [
12385
12366
  item.label,
12386
12367
  " ",
@@ -12769,7 +12750,7 @@ var MainContent = () => {
12769
12750
  const hasConfirmationQueue = Boolean(
12770
12751
  showConfirmationQueue && confirmingTool
12771
12752
  );
12772
- const isVisiblePendingItem = (item) => item.type !== "tool_group" || item.tools.some((t) => t.status !== CoreToolCallStatus.AwaitingApproval);
12753
+ const isVisiblePendingItem = (item) => item.type !== "tool_group" || item.tools.some((t) => t.status !== "awaiting_approval" /* AwaitingApproval */);
12773
12754
  const visiblePendingCount = pendingHistoryItems.filter(isVisiblePendingItem).length;
12774
12755
  const shouldPartitionHeight = !isAlternateBufferOrTerminalBuffer && hasConfirmationQueue && visiblePendingCount > 0;
12775
12756
  const pendingCount = Math.max(1, visiblePendingCount);
@@ -14473,7 +14454,7 @@ async function validateAuthMethodWithSettings(authType, settings) {
14473
14454
  if (settings.merged.security.auth.useExternal) {
14474
14455
  return null;
14475
14456
  }
14476
- if (authType === AuthType.USE_GEMINI) {
14457
+ if (authType === "gemini-api-key" /* USE_GEMINI */) {
14477
14458
  return null;
14478
14459
  }
14479
14460
  return validateAuthMethod(authType);
@@ -14525,7 +14506,7 @@ var useAuthCommand = (settings, config, initialAuthError = null, initialAccountS
14525
14506
  }
14526
14507
  return;
14527
14508
  }
14528
- if (authType === AuthType.USE_GEMINI) {
14509
+ if (authType === "gemini-api-key" /* USE_GEMINI */) {
14529
14510
  const key = await reloadApiKey();
14530
14511
  if (!key) {
14531
14512
  setAuthState("awaiting_api_key_input" /* AwaitingApiKeyInput */);
@@ -14608,31 +14589,31 @@ function AuthDialog({
14608
14589
  let items = [
14609
14590
  {
14610
14591
  label: "Sign in with Google",
14611
- value: AuthType.LOGIN_WITH_GOOGLE,
14612
- key: AuthType.LOGIN_WITH_GOOGLE
14592
+ value: "oauth-personal" /* LOGIN_WITH_GOOGLE */,
14593
+ key: "oauth-personal" /* LOGIN_WITH_GOOGLE */
14613
14594
  },
14614
14595
  ...process.env["CLOUD_SHELL"] === "true" ? [
14615
14596
  {
14616
14597
  label: "Use Cloud Shell user credentials",
14617
- value: AuthType.COMPUTE_ADC,
14618
- key: AuthType.COMPUTE_ADC
14598
+ value: "compute-default-credentials" /* COMPUTE_ADC */,
14599
+ key: "compute-default-credentials" /* COMPUTE_ADC */
14619
14600
  }
14620
14601
  ] : process.env["GEMINI_CLI_USE_COMPUTE_ADC"] === "true" ? [
14621
14602
  {
14622
14603
  label: "Use metadata server application default credentials",
14623
- value: AuthType.COMPUTE_ADC,
14624
- key: AuthType.COMPUTE_ADC
14604
+ value: "compute-default-credentials" /* COMPUTE_ADC */,
14605
+ key: "compute-default-credentials" /* COMPUTE_ADC */
14625
14606
  }
14626
14607
  ] : [],
14627
14608
  {
14628
14609
  label: "Use Gemini API Key",
14629
- value: AuthType.USE_GEMINI,
14630
- key: AuthType.USE_GEMINI
14610
+ value: "gemini-api-key" /* USE_GEMINI */,
14611
+ key: "gemini-api-key" /* USE_GEMINI */
14631
14612
  },
14632
14613
  {
14633
14614
  label: "Vertex AI",
14634
- value: AuthType.USE_VERTEX_AI,
14635
- key: AuthType.USE_VERTEX_AI
14615
+ value: "vertex-ai" /* USE_VERTEX_AI */,
14616
+ key: "vertex-ai" /* USE_VERTEX_AI */
14636
14617
  }
14637
14618
  ];
14638
14619
  if (settings.merged.security.auth.enforcedType) {
@@ -14654,9 +14635,9 @@ function AuthDialog({
14654
14635
  return item.value === defaultAuthType;
14655
14636
  }
14656
14637
  if (process.env["GEMINI_API_KEY"]) {
14657
- return item.value === AuthType.USE_GEMINI;
14638
+ return item.value === "gemini-api-key" /* USE_GEMINI */;
14658
14639
  }
14659
- return item.value === AuthType.LOGIN_WITH_GOOGLE;
14640
+ return item.value === "oauth-personal" /* LOGIN_WITH_GOOGLE */;
14660
14641
  });
14661
14642
  if (settings.merged.security.auth.enforcedType) {
14662
14643
  initialAuthIndex = 0;
@@ -14667,14 +14648,14 @@ function AuthDialog({
14667
14648
  return;
14668
14649
  }
14669
14650
  if (authType) {
14670
- const needsRestart = authType === AuthType.LOGIN_WITH_GOOGLE || authType === AuthType.USE_VERTEX_AI && process.env["CLOUD_SHELL"] === "true";
14651
+ const needsRestart = authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ || authType === "vertex-ai" /* USE_VERTEX_AI */ && process.env["CLOUD_SHELL"] === "true";
14671
14652
  if (needsRestart) {
14672
14653
  setAuthContext({ requiresRestart: true });
14673
14654
  } else {
14674
14655
  setAuthContext({});
14675
14656
  }
14676
14657
  const currentAuthType = settings.merged.security?.auth?.selectedType;
14677
- if (authType === AuthType.LOGIN_WITH_GOOGLE || currentAuthType === AuthType.LOGIN_WITH_GOOGLE) {
14658
+ if (authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ || currentAuthType === "oauth-personal" /* LOGIN_WITH_GOOGLE */) {
14678
14659
  try {
14679
14660
  await clearCachedCredentialFile();
14680
14661
  } catch (error) {
@@ -14682,13 +14663,13 @@ function AuthDialog({
14682
14663
  onAuthError(
14683
14664
  "Failed to clear cached credentials: " + (error instanceof Error ? error.message : String(error))
14684
14665
  );
14685
- if (authType === AuthType.LOGIN_WITH_GOOGLE) {
14666
+ if (authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */) {
14686
14667
  return;
14687
14668
  }
14688
14669
  }
14689
14670
  }
14690
14671
  settings.setValue(scope, "security.auth.selectedType", authType);
14691
- if (authType === AuthType.LOGIN_WITH_GOOGLE && config.isBrowserLaunchSuppressed()) {
14672
+ if (authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ && config.isBrowserLaunchSuppressed()) {
14692
14673
  setExiting(true);
14693
14674
  setTimeout(() => {
14694
14675
  void relaunchApp({ overrideAuthType: authType }).catch((err) => {
@@ -14698,7 +14679,7 @@ function AuthDialog({
14698
14679
  }, 100);
14699
14680
  return;
14700
14681
  }
14701
- if (authType === AuthType.USE_GEMINI) {
14682
+ if (authType === "gemini-api-key" /* USE_GEMINI */) {
14702
14683
  setAuthState("awaiting_api_key_input" /* AwaitingApiKeyInput */);
14703
14684
  return;
14704
14685
  }
@@ -15510,11 +15491,11 @@ var PrivacyNoticeText = ({
15510
15491
  }) => {
15511
15492
  const authType = config.getContentGeneratorConfig()?.authType;
15512
15493
  switch (authType) {
15513
- case AuthType.USE_GEMINI:
15494
+ case "gemini-api-key" /* USE_GEMINI */:
15514
15495
  return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(GeminiPrivacyNotice, { onExit });
15515
- case AuthType.USE_VERTEX_AI:
15496
+ case "vertex-ai" /* USE_VERTEX_AI */:
15516
15497
  return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(CloudPaidPrivacyNotice, { onExit });
15517
- case AuthType.LOGIN_WITH_GOOGLE:
15498
+ case "oauth-personal" /* LOGIN_WITH_GOOGLE */:
15518
15499
  default:
15519
15500
  return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(CloudFreePrivacyNotice, { config, onExit });
15520
15501
  }
@@ -15574,7 +15555,7 @@ function ProQuotaDialog({
15574
15555
  value: "retry_always",
15575
15556
  key: "retry_always"
15576
15557
  },
15577
- ...authType === AuthType.LOGIN_WITH_GOOGLE && !isUltra ? [
15558
+ ...authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ && !isUltra ? [
15578
15559
  {
15579
15560
  label: "Upgrade for higher limits",
15580
15561
  value: "upgrade",
@@ -16747,7 +16728,7 @@ function ModelDialog({ onClose }) {
16747
16728
  const useLatestFlash = config?.hasLatestFlashGAAccess?.() ?? false;
16748
16729
  const useLatestFlashLite = config?.hasLatestFlashLiteGAAccess?.() ?? false;
16749
16730
  const selectedAuthType = settings.merged.security.auth.selectedType;
16750
- const useCustomToolModel = useGemini31 && selectedAuthType === AuthType.USE_GEMINI;
16731
+ const useCustomToolModel = useGemini31 && selectedAuthType === "gemini-api-key" /* USE_GEMINI */;
16751
16732
  const manualModelSelected = (0, import_react53.useMemo)(() => {
16752
16733
  if (config?.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
16753
16734
  const def = config.getModelConfigService().getModelDefinition(preferredModel);
@@ -18075,10 +18056,10 @@ function initializeConsoleStore() {
18075
18056
  globalConsoleMessages = [];
18076
18057
  globalErrorCount = 0;
18077
18058
  notifyListeners();
18078
- coreEvents.off(CoreEvent.ConsoleLog, handleConsoleLog);
18079
- coreEvents.off(CoreEvent.Output, handleOutput);
18080
- coreEvents.on(CoreEvent.ConsoleLog, handleConsoleLog);
18081
- coreEvents.on(CoreEvent.Output, handleOutput);
18059
+ coreEvents.off("console-log" /* ConsoleLog */, handleConsoleLog);
18060
+ coreEvents.off("output" /* Output */, handleOutput);
18061
+ coreEvents.on("console-log" /* ConsoleLog */, handleConsoleLog);
18062
+ coreEvents.on("output" /* Output */, handleOutput);
18082
18063
  }
18083
18064
  function notifyListeners() {
18084
18065
  for (const listener of listeners) {
@@ -18733,6 +18714,9 @@ function useDebouncedValue(value, delay2 = 200) {
18733
18714
  }, [value, delay2]);
18734
18715
  return debounced;
18735
18716
  }
18717
+ function escapeRegExp(value) {
18718
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18719
+ }
18736
18720
  function useReverseSearchCompletion(buffer, history, reverseSearchActive) {
18737
18721
  const {
18738
18722
  suggestions,
@@ -18762,11 +18746,12 @@ function useReverseSearchCompletion(buffer, history, reverseSearchActive) {
18762
18746
  const searchHistory = (0, import_react63.useCallback)(
18763
18747
  (query, items) => {
18764
18748
  const out = [];
18749
+ const regex = new RegExp(escapeRegExp(query), "iu");
18765
18750
  for (let i = 0; i < items.length; i++) {
18766
18751
  const cmd = items[i];
18767
- const idx = cmd.toLowerCase().indexOf(query);
18768
- if (idx !== -1) {
18769
- out.push({ label: cmd, value: cmd, matchedIndex: idx });
18752
+ const match = regex.exec(cmd);
18753
+ if (match) {
18754
+ out.push({ label: cmd, value: cmd, matchedIndex: match.index });
18770
18755
  }
18771
18756
  }
18772
18757
  return out;
@@ -18781,10 +18766,10 @@ function useReverseSearchCompletion(buffer, history, reverseSearchActive) {
18781
18766
  value: cmd,
18782
18767
  matchedIndex: -1
18783
18768
  }));
18784
- const query = debouncedQuery.toLowerCase();
18785
- const canUseCache = prevQueryRef.current && query.startsWith(prevQueryRef.current) && prevMatchesRef.current.length > 0;
18769
+ const lowerQuery = debouncedQuery.toLowerCase();
18770
+ const canUseCache = prevQueryRef.current && lowerQuery.startsWith(prevQueryRef.current) && prevMatchesRef.current.length > 0;
18786
18771
  const source = canUseCache ? prevMatchesRef.current.map((m) => m.value) : history;
18787
- return searchHistory(query, source);
18772
+ return searchHistory(debouncedQuery, source);
18788
18773
  }, [debouncedQuery, history, reverseSearchActive, searchHistory]);
18789
18774
  (0, import_react63.useEffect)(() => {
18790
18775
  if (!reverseSearchActive) {
@@ -20215,7 +20200,7 @@ function usePromptCompletion({
20215
20200
  { model: "prompt-completion" },
20216
20201
  contents,
20217
20202
  signal,
20218
- LlmRole.UTILITY_AUTOCOMPLETE
20203
+ "utility_autocomplete" /* UTILITY_AUTOCOMPLETE */
20219
20204
  );
20220
20205
  if (signal.aborted) {
20221
20206
  return;
@@ -22294,9 +22279,9 @@ var InputPrompt = ({
22294
22279
  onSuggestionsVisibilityChange(shouldShowSuggestions);
22295
22280
  }
22296
22281
  }, [shouldShowSuggestions, onSuggestionsVisibilityChange]);
22297
- const showAutoAcceptStyling = !shellModeActive && approvalMode === ApprovalMode.AUTO_EDIT;
22298
- const showYoloStyling = !shellModeActive && approvalMode === ApprovalMode.YOLO;
22299
- const showPlanStyling = !shellModeActive && approvalMode === ApprovalMode.PLAN;
22282
+ const showAutoAcceptStyling = !shellModeActive && approvalMode === "autoEdit" /* AUTO_EDIT */;
22283
+ const showYoloStyling = !shellModeActive && approvalMode === "yolo" /* YOLO */;
22284
+ const showPlanStyling = !shellModeActive && approvalMode === "plan" /* PLAN */;
22300
22285
  let statusColor;
22301
22286
  let statusText = "";
22302
22287
  if (shellModeActive) {
@@ -23130,22 +23115,22 @@ var ApprovalModeIndicator = ({
23130
23115
  const cycleHint = formatCommand("app.cycleApprovalMode" /* CYCLE_APPROVAL_MODE */);
23131
23116
  const yoloHint = formatCommand("app.toggleYolo" /* TOGGLE_YOLO */);
23132
23117
  switch (approvalMode) {
23133
- case ApprovalMode.AUTO_EDIT:
23118
+ case "autoEdit" /* AUTO_EDIT */:
23134
23119
  textColor = theme.status.warning;
23135
23120
  textContent = "auto-accept edits";
23136
23121
  subText = allowPlanMode ? `${cycleHint} to plan` : `${cycleHint} to manual`;
23137
23122
  break;
23138
- case ApprovalMode.PLAN:
23123
+ case "plan" /* PLAN */:
23139
23124
  textColor = theme.status.success;
23140
23125
  textContent = "plan";
23141
23126
  subText = `${cycleHint} to manual`;
23142
23127
  break;
23143
- case ApprovalMode.YOLO:
23128
+ case "yolo" /* YOLO */:
23144
23129
  textColor = theme.status.error;
23145
23130
  textContent = "YOLO";
23146
23131
  subText = yoloHint;
23147
23132
  break;
23148
- case ApprovalMode.DEFAULT:
23133
+ case "default" /* DEFAULT */:
23149
23134
  default:
23150
23135
  textColor = theme.text.accent;
23151
23136
  textContent = "";
@@ -23193,7 +23178,7 @@ var useComposerStatus = () => {
23193
23178
  (item) => item.type === "tool_group"
23194
23179
  ).some(
23195
23180
  (item) => item.tools.some(
23196
- (tool) => tool.status === CoreToolCallStatus.AwaitingApproval
23181
+ (tool) => tool.status === "awaiting_approval" /* AwaitingApproval */
23197
23182
  )
23198
23183
  ),
23199
23184
  [uiState.pendingHistoryItems]
@@ -23208,13 +23193,13 @@ var useComposerStatus = () => {
23208
23193
  const hideMinimalModeHintWhileBusy = !uiState.cleanUiDetailsVisible && (showLoadingIndicator || uiState.activeHooks.length > 0);
23209
23194
  if (hideMinimalModeHintWhileBusy) return null;
23210
23195
  switch (showApprovalModeIndicator) {
23211
- case ApprovalMode.YOLO:
23196
+ case "yolo" /* YOLO */:
23212
23197
  return { text: "YOLO", color: theme.status.error };
23213
- case ApprovalMode.PLAN:
23198
+ case "plan" /* PLAN */:
23214
23199
  return { text: "plan", color: theme.status.success };
23215
- case ApprovalMode.AUTO_EDIT:
23200
+ case "autoEdit" /* AUTO_EDIT */:
23216
23201
  return { text: "auto edit", color: theme.status.warning };
23217
- case ApprovalMode.DEFAULT:
23202
+ case "default" /* DEFAULT */:
23218
23203
  default:
23219
23204
  return null;
23220
23205
  }
@@ -23576,7 +23561,7 @@ var ConfigInitDisplay = ({
23576
23561
  let connected = 0;
23577
23562
  const connecting = [];
23578
23563
  for (const [name, client] of clients.entries()) {
23579
- if (client.getStatus() === MCPServerStatus.CONNECTED) {
23564
+ if (client.getStatus() === "connected" /* CONNECTED */) {
23580
23565
  connected++;
23581
23566
  } else {
23582
23567
  connecting.push(name);
@@ -23598,9 +23583,9 @@ var ConfigInitDisplay = ({
23598
23583
  );
23599
23584
  }
23600
23585
  };
23601
- coreEvents.on(CoreEvent.McpClientUpdate, onChange);
23586
+ coreEvents.on("mcp-client-update" /* McpClientUpdate */, onChange);
23602
23587
  return () => {
23603
- coreEvents.off(CoreEvent.McpClientUpdate, onChange);
23588
+ coreEvents.off("mcp-client-update" /* McpClientUpdate */, onChange);
23604
23589
  };
23605
23590
  }, [initialMessage]);
23606
23591
  return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Box_default, { marginTop: 1, children: /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(Text, { children: [
@@ -24321,7 +24306,7 @@ var useExecutionLifecycle = (addItemToHistory, setPendingHistoryItem, onExec, on
24321
24306
  callId,
24322
24307
  name: SHELL_COMMAND_NAME,
24323
24308
  description: rawQuery,
24324
- status: CoreToolCallStatus.Executing,
24309
+ status: "executing" /* Executing */,
24325
24310
  isClientInitiated: true,
24326
24311
  resultDisplay: "",
24327
24312
  confirmationDetails: void 0
@@ -24462,7 +24447,7 @@ __code=$?; pwd > ${escapedPwdFilePath}; exit $__code`;
24462
24447
  mainContent = result.output.trim() || "(Command produced no output)";
24463
24448
  }
24464
24449
  let finalOutput = result.ansiOutput && result.ansiOutput.length > 0 ? result.ansiOutput : mainContent;
24465
- let finalStatus = CoreToolCallStatus.Success;
24450
+ let finalStatus = "success" /* Success */;
24466
24451
  const prependToAnsiOutput = (output, text) => {
24467
24452
  const newLines = text.split("\n").map((line) => [
24468
24453
  {
@@ -24481,20 +24466,20 @@ __code=$?; pwd > ${escapedPwdFilePath}; exit $__code`;
24481
24466
  };
24482
24467
  let prefix = "";
24483
24468
  if (result.error) {
24484
- finalStatus = CoreToolCallStatus.Error;
24469
+ finalStatus = "error" /* Error */;
24485
24470
  prefix = result.error.message;
24486
24471
  } else if (result.aborted) {
24487
- finalStatus = CoreToolCallStatus.Cancelled;
24472
+ finalStatus = "cancelled" /* Cancelled */;
24488
24473
  prefix = "Command was cancelled.";
24489
24474
  } else if (result.backgrounded) {
24490
- finalStatus = CoreToolCallStatus.Success;
24475
+ finalStatus = "success" /* Success */;
24491
24476
  finalOutput = `Command moved to background (PID: ${result.pid}). Output hidden. Press Ctrl+B to view.`;
24492
24477
  mainContent = finalOutput;
24493
24478
  } else if (result.signal) {
24494
- finalStatus = CoreToolCallStatus.Error;
24479
+ finalStatus = "error" /* Error */;
24495
24480
  prefix = `Command terminated by signal: ${result.signal}.`;
24496
24481
  } else if (result.exitCode !== 0) {
24497
- finalStatus = CoreToolCallStatus.Error;
24482
+ finalStatus = "error" /* Error */;
24498
24483
  prefix = `Command exited with code ${result.exitCode}.`;
24499
24484
  }
24500
24485
  if (prefix) {
@@ -24520,7 +24505,7 @@ ${mainContent}`;
24520
24505
  status: finalStatus,
24521
24506
  resultDisplay: finalOutput
24522
24507
  };
24523
- if (finalStatus !== CoreToolCallStatus.Cancelled) {
24508
+ if (finalStatus !== "cancelled" /* Cancelled */) {
24524
24509
  addItemToHistory(
24525
24510
  {
24526
24511
  type: "tool_group",
@@ -25530,13 +25515,13 @@ function useQuotaAndFallback({
25530
25515
  error.retryDelayMs ? `Access resets at ${getResetTimeMessage(error.retryDelayMs)}.` : null,
25531
25516
  `/stats model for usage details`,
25532
25517
  `/model to switch models.`,
25533
- contentGeneratorConfig?.authType === AuthType.LOGIN_WITH_GOOGLE ? `/auth to switch to API key.` : null
25518
+ contentGeneratorConfig?.authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ ? `/auth to switch to API key.` : null
25534
25519
  ].filter(Boolean);
25535
25520
  message = messageLines.join("\n");
25536
25521
  }
25537
25522
  } else if (error instanceof ModelNotFoundError) {
25538
25523
  isModelNotFoundError = true;
25539
- if (contentGeneratorConfig?.authType === AuthType.USE_VERTEX_AI && VALID_GEMINI_MODELS.has(failedModel)) {
25524
+ if (contentGeneratorConfig?.authType === "vertex-ai" /* USE_VERTEX_AI */ && VALID_GEMINI_MODELS.has(failedModel)) {
25540
25525
  const location = process.env["GOOGLE_CLOUD_LOCATION"] || "your configured region";
25541
25526
  const messageLines = [
25542
25527
  `Model "${failedModel}" is not available in region "${location}".`,
@@ -25730,7 +25715,7 @@ var useEditorSettings = (loadedSettings, setEditorError, addItem) => {
25730
25715
  );
25731
25716
  setEditorError(null);
25732
25717
  setIsEditorDialogOpen(false);
25733
- coreEvents.emit(CoreEvent.EditorSelected, { editor: editorType });
25718
+ coreEvents.emit("editor-selected" /* EditorSelected */, { editor: editorType });
25734
25719
  } catch (error) {
25735
25720
  setEditorError(`Failed to set editor preference: ${error}`);
25736
25721
  }
@@ -25739,7 +25724,7 @@ var useEditorSettings = (loadedSettings, setEditorError, addItem) => {
25739
25724
  );
25740
25725
  const exitEditorDialog = (0, import_react89.useCallback)(() => {
25741
25726
  setIsEditorDialogOpen(false);
25742
- coreEvents.emit(CoreEvent.EditorSelected, { editor: void 0 });
25727
+ coreEvents.emit("editor-selected" /* EditorSelected */, { editor: void 0 });
25743
25728
  }, []);
25744
25729
  return {
25745
25730
  isEditorDialogOpen,
@@ -26116,7 +26101,7 @@ var useSlashCommandProcessor = (config, settings, addItem, clearItems, loadHisto
26116
26101
  canonicalPath: resolvedCommandPath
26117
26102
  } = parseSlashCommand(trimmed, commands);
26118
26103
  if (!commandToExecute) {
26119
- const isMcpLoading = config?.getMcpClientManager()?.getDiscoveryState() === MCPDiscoveryState.IN_PROGRESS;
26104
+ const isMcpLoading = config?.getMcpClientManager()?.getDiscoveryState() === "in_progress" /* IN_PROGRESS */;
26120
26105
  if (isMcpLoading) {
26121
26106
  setIsProcessing(true);
26122
26107
  if (addToHistory) {
@@ -26296,7 +26281,7 @@ var useSlashCommandProcessor = (config, settings, addItem, clearItems, loadHisto
26296
26281
  onConfirm: async (resolvedOutcome) => {
26297
26282
  resolve3({
26298
26283
  outcome: resolvedOutcome,
26299
- approvedCommands: resolvedOutcome === ToolConfirmationOutcome.Cancel ? [] : result.commandsToConfirm
26284
+ approvedCommands: resolvedOutcome === "cancel" /* Cancel */ ? [] : result.commandsToConfirm
26300
26285
  });
26301
26286
  }
26302
26287
  };
@@ -26304,7 +26289,7 @@ var useSlashCommandProcessor = (config, settings, addItem, clearItems, loadHisto
26304
26289
  callId,
26305
26290
  name: "Expansion",
26306
26291
  description: "Command expansion needs shell access",
26307
- status: CoreToolCallStatus.AwaitingApproval,
26292
+ status: "awaiting_approval" /* AwaitingApproval */,
26308
26293
  isClientInitiated: true,
26309
26294
  resultDisplay: void 0,
26310
26295
  confirmationDetails
@@ -26315,7 +26300,7 @@ var useSlashCommandProcessor = (config, settings, addItem, clearItems, loadHisto
26315
26300
  });
26316
26301
  });
26317
26302
  setPendingItem(null);
26318
- if (outcome === ToolConfirmationOutcome.Cancel || !approvedCommands || approvedCommands.length === 0) {
26303
+ if (outcome === "cancel" /* Cancel */ || !approvedCommands || approvedCommands.length === 0) {
26319
26304
  addItem(
26320
26305
  {
26321
26306
  type: "info" /* INFO */,
@@ -26325,7 +26310,7 @@ var useSlashCommandProcessor = (config, settings, addItem, clearItems, loadHisto
26325
26310
  );
26326
26311
  return { type: "handled" };
26327
26312
  }
26328
- if (outcome === ToolConfirmationOutcome.ProceedAlways) {
26313
+ if (outcome === "proceed_always" /* ProceedAlways */) {
26329
26314
  setSessionShellAllowlist(
26330
26315
  (prev) => /* @__PURE__ */ new Set([...prev, ...approvedCommands])
26331
26316
  );
@@ -26709,7 +26694,7 @@ var useLogger = (config) => {
26709
26694
  };
26710
26695
 
26711
26696
  // packages/cli/src/ui/hooks/useGeminiStream.ts
26712
- var import_react97 = __toESM(require_react(), 1);
26697
+ var import_react99 = __toESM(require_react(), 1);
26713
26698
 
26714
26699
  // packages/cli/src/ui/utils/markdownUtilities.ts
26715
26700
  var isIndexInsideCodeBlock = (content, indexToTest) => {
@@ -26801,7 +26786,7 @@ function mapToDisplay(toolOrTools, options = {}) {
26801
26786
  let description;
26802
26787
  let renderOutputAsMarkdown = false;
26803
26788
  const displayName = call.tool?.displayName ?? call.request.name;
26804
- if (call.status === CoreToolCallStatus.Error) {
26789
+ if (call.status === "error" /* Error */) {
26805
26790
  description = JSON.stringify(call.request.args);
26806
26791
  } else {
26807
26792
  description = call.invocation.getDescription();
@@ -26824,27 +26809,27 @@ function mapToDisplay(toolOrTools, options = {}) {
26824
26809
  let progress = void 0;
26825
26810
  let progressTotal = void 0;
26826
26811
  switch (call.status) {
26827
- case CoreToolCallStatus.Success:
26812
+ case "success" /* Success */:
26828
26813
  resultDisplay = call.response.resultDisplay;
26829
26814
  outputFile = call.response.outputFile;
26830
26815
  break;
26831
- case CoreToolCallStatus.Error:
26832
- case CoreToolCallStatus.Cancelled:
26816
+ case "error" /* Error */:
26817
+ case "cancelled" /* Cancelled */:
26833
26818
  resultDisplay = call.response.resultDisplay;
26834
26819
  break;
26835
- case CoreToolCallStatus.AwaitingApproval:
26820
+ case "awaiting_approval" /* AwaitingApproval */:
26836
26821
  correlationId = call.correlationId;
26837
26822
  confirmationDetails = call.confirmationDetails;
26838
26823
  break;
26839
- case CoreToolCallStatus.Executing:
26824
+ case "executing" /* Executing */:
26840
26825
  resultDisplay = call.liveOutput;
26841
26826
  ptyId = call.pid;
26842
26827
  progressMessage = call.progressMessage;
26843
26828
  progress = call.progress;
26844
26829
  progressTotal = call.progressTotal;
26845
26830
  break;
26846
- case CoreToolCallStatus.Scheduled:
26847
- case CoreToolCallStatus.Validating:
26831
+ case "scheduled" /* Scheduled */:
26832
+ case "validating" /* Validating */:
26848
26833
  break;
26849
26834
  default: {
26850
26835
  const exhaustiveCheck = call;
@@ -26915,7 +26900,7 @@ function useToolScheduler(onComplete, config, getPreferredEditor) {
26915
26900
  const handler = (event) => {
26916
26901
  const isRoot = event.schedulerId === ROOT_SCHEDULER_ID;
26917
26902
  const hasExecuting = event.toolCalls.some(
26918
- (tc) => tc.status === CoreToolCallStatus.Executing || (tc.status === CoreToolCallStatus.Success || tc.status === CoreToolCallStatus.Error) && "tailToolCallRequest" in tc && tc.tailToolCallRequest != null
26903
+ (tc) => tc.status === "executing" /* Executing */ || (tc.status === "success" /* Success */ || tc.status === "error" /* Error */) && "tailToolCallRequest" in tc && tc.tailToolCallRequest != null
26919
26904
  );
26920
26905
  if (hasExecuting) {
26921
26906
  setLastToolOutputTime(Date.now());
@@ -26924,7 +26909,7 @@ function useToolScheduler(onComplete, config, getPreferredEditor) {
26924
26909
  const prevCalls = prev[event.schedulerId] ?? [];
26925
26910
  const prevCallIds = new Set(prevCalls.map((tc) => tc.request.callId));
26926
26911
  const filteredToolCalls = isRoot ? event.toolCalls : event.toolCalls.filter(
26927
- (tc) => tc.status === CoreToolCallStatus.AwaitingApproval || prevCallIds.has(tc.request.callId)
26912
+ (tc) => tc.status === "awaiting_approval" /* AwaitingApproval */ || prevCallIds.has(tc.request.callId)
26928
26913
  );
26929
26914
  if (!isRoot && filteredToolCalls.length === 0 && prevCalls.length === 0) {
26930
26915
  return prev;
@@ -26936,9 +26921,9 @@ function useToolScheduler(onComplete, config, getPreferredEditor) {
26936
26921
  };
26937
26922
  });
26938
26923
  };
26939
- messageBus.subscribe(MessageBusType.TOOL_CALLS_UPDATE, handler);
26924
+ messageBus.subscribe("tool-calls-update" /* TOOL_CALLS_UPDATE */, handler);
26940
26925
  return () => {
26941
- messageBus.unsubscribe(MessageBusType.TOOL_CALLS_UPDATE, handler);
26926
+ messageBus.unsubscribe("tool-calls-update" /* TOOL_CALLS_UPDATE */, handler);
26942
26927
  };
26943
26928
  }, [messageBus, internalAdaptToolCalls]);
26944
26929
  (0, import_react96.useEffect)(() => {
@@ -26960,9 +26945,9 @@ function useToolScheduler(onComplete, config, getPreferredEditor) {
26960
26945
  };
26961
26946
  });
26962
26947
  };
26963
- messageBus.subscribe(MessageBusType.SUBAGENT_ACTIVITY, handler);
26948
+ messageBus.subscribe("subagent-activity" /* SUBAGENT_ACTIVITY */, handler);
26964
26949
  return () => {
26965
- messageBus.unsubscribe(MessageBusType.SUBAGENT_ACTIVITY, handler);
26950
+ messageBus.unsubscribe("subagent-activity" /* SUBAGENT_ACTIVITY */, handler);
26966
26951
  };
26967
26952
  }, [messageBus]);
26968
26953
  const schedule = (0, import_react96.useCallback)(
@@ -27061,8 +27046,8 @@ function adaptToolCalls(coreCalls, prevTracked) {
27061
27046
  const prev = prevMap.get(coreCall.request.callId);
27062
27047
  const responseSubmittedToGemini = prev?.responseSubmittedToGemini ?? false;
27063
27048
  let status = coreCall.status;
27064
- if ((status === CoreToolCallStatus.Success || status === CoreToolCallStatus.Error) && "tailToolCallRequest" in coreCall && coreCall.tailToolCallRequest != null) {
27065
- status = CoreToolCallStatus.Executing;
27049
+ if ((status === "success" /* Success */ || status === "error" /* Error */) && "tailToolCallRequest" in coreCall && coreCall.tailToolCallRequest != null) {
27050
+ status = "executing" /* Executing */;
27066
27051
  }
27067
27052
  return {
27068
27053
  ...coreCall,
@@ -27075,6 +27060,638 @@ function adaptToolCalls(coreCalls, prevTracked) {
27075
27060
  // packages/cli/src/ui/hooks/useGeminiStream.ts
27076
27061
  import { promises as fs6 } from "node:fs";
27077
27062
  import path13 from "node:path";
27063
+
27064
+ // packages/cli/src/ui/hooks/useAgentStream.ts
27065
+ var import_react98 = __toESM(require_react(), 1);
27066
+
27067
+ // packages/cli/src/ui/hooks/useTurnActivityMonitor.ts
27068
+ var import_react97 = __toESM(require_react(), 1);
27069
+ var useTurnActivityMonitor = (streamingState, activePtyId, pendingToolCalls = []) => {
27070
+ const [operationStartTime, setOperationStartTime] = (0, import_react97.useState)(0);
27071
+ const prevPtyIdRef = (0, import_react97.useRef)(void 0);
27072
+ const prevStreamingStateRef = (0, import_react97.useRef)(void 0);
27073
+ (0, import_react97.useEffect)(() => {
27074
+ const isNowResponding = streamingState === "responding" /* Responding */;
27075
+ const wasResponding = prevStreamingStateRef.current === "responding" /* Responding */;
27076
+ const ptyChanged = activePtyId !== prevPtyIdRef.current;
27077
+ if (isNowResponding && (!wasResponding || ptyChanged)) {
27078
+ setOperationStartTime(Date.now());
27079
+ } else if (!isNowResponding && wasResponding) {
27080
+ setOperationStartTime(0);
27081
+ }
27082
+ prevPtyIdRef.current = activePtyId;
27083
+ prevStreamingStateRef.current = streamingState;
27084
+ }, [streamingState, activePtyId]);
27085
+ const isRedirectionActive = (0, import_react97.useMemo)(
27086
+ () => (
27087
+ // Check active tool calls for run_shell_command
27088
+ pendingToolCalls.some((tc) => {
27089
+ if (tc.request.name !== "run_shell_command") return false;
27090
+ const command = tc.request.args?.command || "";
27091
+ return hasRedirection(command);
27092
+ })
27093
+ ),
27094
+ [pendingToolCalls]
27095
+ );
27096
+ return {
27097
+ operationStartTime,
27098
+ isRedirectionActive
27099
+ };
27100
+ };
27101
+
27102
+ // packages/cli/src/ui/hooks/useAgentStream.ts
27103
+ var CANCELLED_TOOL_ERROR_MESSAGE = "[Operation Cancelled] Reason: User cancelled operation";
27104
+ function createCancelledToolCall(request, tool, invocation) {
27105
+ const fallbackToolName = request.name.trim() || "generic_tool";
27106
+ return {
27107
+ status: "cancelled" /* Cancelled */,
27108
+ request,
27109
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
27110
+ tool: tool ?? {
27111
+ name: fallbackToolName,
27112
+ displayName: fallbackToolName
27113
+ },
27114
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
27115
+ invocation: invocation ?? {
27116
+ getDescription: () => fallbackToolName
27117
+ },
27118
+ response: {
27119
+ callId: request.callId,
27120
+ responseParts: [
27121
+ {
27122
+ functionResponse: {
27123
+ id: request.callId,
27124
+ name: request.name,
27125
+ response: {
27126
+ error: CANCELLED_TOOL_ERROR_MESSAGE
27127
+ }
27128
+ }
27129
+ }
27130
+ ],
27131
+ resultDisplay: void 0,
27132
+ error: new Error(CANCELLED_TOOL_ERROR_MESSAGE),
27133
+ errorType: "unhandled_exception" /* UNHANDLED_EXCEPTION */
27134
+ }
27135
+ };
27136
+ }
27137
+ var useAgentStream = ({
27138
+ agent,
27139
+ config,
27140
+ addItem,
27141
+ onCancelSubmit,
27142
+ isShellFocused,
27143
+ logger
27144
+ }) => {
27145
+ const [initError] = (0, import_react98.useState)(null);
27146
+ const [retryStatus] = (0, import_react98.useState)(null);
27147
+ const [streamingState, setStreamingState] = (0, import_react98.useState)(
27148
+ "idle" /* Idle */
27149
+ );
27150
+ const [thought, setThought] = (0, import_react98.useState)(null);
27151
+ const [lastOutputTime, setLastOutputTime] = (0, import_react98.useState)(Date.now());
27152
+ const currentStreamIdRef = (0, import_react98.useRef)(null);
27153
+ const userMessageTimestampRef = (0, import_react98.useRef)(0);
27154
+ const geminiMessageBufferRef = (0, import_react98.useRef)("");
27155
+ const [pendingHistoryItem, pendingHistoryItemRef, setPendingHistoryItem] = useStateAndRef(null);
27156
+ const [trackedTools, trackedToolsRef, setTrackedTools] = useStateAndRef([]);
27157
+ const toolRequestArgsRef = (0, import_react98.useRef)(
27158
+ /* @__PURE__ */ new Map()
27159
+ );
27160
+ const cancellationStateRef = (0, import_react98.useRef)(
27161
+ "idle" /* Idle */
27162
+ );
27163
+ const cancelPromiseRef = (0, import_react98.useRef)(Promise.resolve());
27164
+ const [pushedToolCallIds, pushedToolCallIdsRef, setPushedToolCallIds] = useStateAndRef(/* @__PURE__ */ new Set());
27165
+ const [_isFirstToolInGroup, isFirstToolInGroupRef, setIsFirstToolInGroup] = useStateAndRef(true);
27166
+ const [_hasEmittedBoxInTurn, hasEmittedBoxInTurnRef, setHasEmittedBoxInTurn] = useStateAndRef(false);
27167
+ const { startNewPrompt } = useSessionStats();
27168
+ const activePtyId = void 0;
27169
+ const backgroundTaskCount = 0;
27170
+ const isBackgroundTaskVisible = false;
27171
+ const toggleBackgroundTasks = (0, import_react98.useCallback)(() => {
27172
+ }, []);
27173
+ const backgroundCurrentExecution = void 0;
27174
+ const backgroundTasks = (0, import_react98.useMemo)(() => /* @__PURE__ */ new Map(), []);
27175
+ const dismissBackgroundTask = (0, import_react98.useCallback)(async (_pid) => {
27176
+ }, []);
27177
+ const pendingToolCalls = (0, import_react98.useMemo)(
27178
+ () => trackedTools.map((t) => ({
27179
+ request: {
27180
+ name: t.originalRequestName || t.name,
27181
+ args: { command: t.description },
27182
+ callId: t.callId,
27183
+ isClientInitiated: t.isClientInitiated ?? false,
27184
+ prompt_id: ""
27185
+ },
27186
+ status: t.status
27187
+ })),
27188
+ [trackedTools]
27189
+ );
27190
+ const [loopDetectionConfirmationRequest] = (0, import_react98.useState)(null);
27191
+ const flushPendingText = (0, import_react98.useCallback)(() => {
27192
+ if (pendingHistoryItemRef.current) {
27193
+ addItem(pendingHistoryItemRef.current, userMessageTimestampRef.current);
27194
+ setPendingHistoryItem(null);
27195
+ geminiMessageBufferRef.current = "";
27196
+ }
27197
+ }, [addItem, pendingHistoryItemRef, setPendingHistoryItem]);
27198
+ const cancelOngoingRequest = (0, import_react98.useCallback)(
27199
+ async (clearBuffer = true) => {
27200
+ if (!agent) {
27201
+ return;
27202
+ }
27203
+ if (cancellationStateRef.current === "cancelling" /* Cancelling */) {
27204
+ if (clearBuffer) {
27205
+ onCancelSubmit(false, true);
27206
+ }
27207
+ try {
27208
+ await cancelPromiseRef.current;
27209
+ } catch (error) {
27210
+ debugLogger.warn(`Error awaiting cancelTask: ${error}`);
27211
+ }
27212
+ return;
27213
+ }
27214
+ cancellationStateRef.current = "cancelling" /* Cancelling */;
27215
+ const cancelTask = (async () => {
27216
+ try {
27217
+ let timeoutId2;
27218
+ try {
27219
+ await Promise.race([
27220
+ agent.abort(),
27221
+ new Promise((resolve3) => {
27222
+ timeoutId2 = setTimeout(resolve3, 1e3);
27223
+ })
27224
+ ]);
27225
+ } finally {
27226
+ if (timeoutId2 !== void 0) {
27227
+ clearTimeout(timeoutId2);
27228
+ }
27229
+ }
27230
+ const unpushedTools = trackedToolsRef.current.filter(
27231
+ (tc) => !pushedToolCallIdsRef.current.has(tc.callId)
27232
+ );
27233
+ if (unpushedTools.length > 0) {
27234
+ setTrackedTools(
27235
+ (prev) => prev.map((tc) => {
27236
+ if (!pushedToolCallIdsRef.current.has(tc.callId) && tc.status !== "success" /* Success */ && tc.status !== "error" /* Error */ && tc.status !== "cancelled" /* Cancelled */) {
27237
+ return {
27238
+ ...tc,
27239
+ status: "cancelled" /* Cancelled */
27240
+ };
27241
+ }
27242
+ return tc;
27243
+ })
27244
+ );
27245
+ }
27246
+ try {
27247
+ const client = config?.getGeminiClient?.();
27248
+ const chat = client?.getChat?.();
27249
+ if (chat) {
27250
+ const seenCallIds = /* @__PURE__ */ new Set();
27251
+ const synthesizedCalls = [];
27252
+ for (const tc of unpushedTools) {
27253
+ if (tc.isClientInitiated) {
27254
+ continue;
27255
+ }
27256
+ seenCallIds.add(tc.callId);
27257
+ const name = tc.originalRequestName || tc.name;
27258
+ const args = toolRequestArgsRef.current.get(tc.callId) ?? {};
27259
+ synthesizedCalls.push(
27260
+ createCancelledToolCall({
27261
+ callId: tc.callId,
27262
+ name,
27263
+ args,
27264
+ isClientInitiated: false,
27265
+ prompt_id: ""
27266
+ })
27267
+ );
27268
+ }
27269
+ const clientHistory = client?.getHistory?.() ?? [];
27270
+ const lastTurn = clientHistory.at(-1);
27271
+ if (lastTurn?.role === "model" && Array.isArray(lastTurn.parts)) {
27272
+ let index = 0;
27273
+ for (const part of lastTurn.parts) {
27274
+ const fc = part.functionCall;
27275
+ if (fc?.name) {
27276
+ const callId = fc.id ?? `${fc.name}-${Date.now()}-${index++}`;
27277
+ if (!seenCallIds.has(callId)) {
27278
+ seenCallIds.add(callId);
27279
+ synthesizedCalls.push(
27280
+ createCancelledToolCall({
27281
+ callId,
27282
+ name: fc.name,
27283
+ args: fc.args ?? {},
27284
+ isClientInitiated: false,
27285
+ prompt_id: ""
27286
+ })
27287
+ );
27288
+ }
27289
+ }
27290
+ }
27291
+ }
27292
+ if (synthesizedCalls.length > 0) {
27293
+ const currentModel = client?.getCurrentSequenceModel?.() ?? config?.getModel?.() ?? "";
27294
+ chat.recordCompletedToolCalls(currentModel, synthesizedCalls);
27295
+ }
27296
+ }
27297
+ } catch (error) {
27298
+ debugLogger.warn(
27299
+ `Error recording cancelled tool calls in agent stream: ${error}`
27300
+ );
27301
+ }
27302
+ setStreamingState("idle" /* Idle */);
27303
+ onCancelSubmit(false, clearBuffer);
27304
+ } finally {
27305
+ cancellationStateRef.current = "idle" /* Idle */;
27306
+ }
27307
+ })();
27308
+ cancelPromiseRef.current = cancelTask;
27309
+ try {
27310
+ await cancelTask;
27311
+ } catch (error) {
27312
+ debugLogger.warn(`Error awaiting cancelTask: ${error}`);
27313
+ }
27314
+ },
27315
+ [
27316
+ agent,
27317
+ config,
27318
+ onCancelSubmit,
27319
+ pushedToolCallIdsRef,
27320
+ setStreamingState,
27321
+ setTrackedTools,
27322
+ trackedToolsRef
27323
+ ]
27324
+ );
27325
+ const handleApprovalModeChange = (0, import_react98.useCallback)(
27326
+ async (newApprovalMode) => {
27327
+ debugLogger.debug(`Approval mode changed to ${newApprovalMode} (stub)`);
27328
+ },
27329
+ []
27330
+ );
27331
+ const handleEvent = (0, import_react98.useCallback)(
27332
+ (event) => {
27333
+ setLastOutputTime(Date.now());
27334
+ switch (event.type) {
27335
+ case "agent_start":
27336
+ setStreamingState("responding" /* Responding */);
27337
+ break;
27338
+ case "agent_end":
27339
+ setStreamingState("idle" /* Idle */);
27340
+ flushPendingText();
27341
+ break;
27342
+ case "message":
27343
+ if (event.role === "agent") {
27344
+ for (const part of event.content) {
27345
+ if (part.type === "text") {
27346
+ geminiMessageBufferRef.current += part.text;
27347
+ const splitPoint = findLastSafeSplitPoint(
27348
+ geminiMessageBufferRef.current
27349
+ );
27350
+ if (splitPoint === geminiMessageBufferRef.current.length) {
27351
+ setPendingHistoryItem({
27352
+ type: "gemini",
27353
+ text: geminiMessageBufferRef.current
27354
+ });
27355
+ } else {
27356
+ const before = geminiMessageBufferRef.current.substring(
27357
+ 0,
27358
+ splitPoint
27359
+ );
27360
+ const after = geminiMessageBufferRef.current.substring(splitPoint);
27361
+ addItem(
27362
+ { type: "gemini", text: before },
27363
+ userMessageTimestampRef.current
27364
+ );
27365
+ geminiMessageBufferRef.current = after;
27366
+ setPendingHistoryItem({
27367
+ type: "gemini_content",
27368
+ text: after
27369
+ });
27370
+ }
27371
+ } else if (part.type === "thought") {
27372
+ setThought(parseThought(part.thought));
27373
+ }
27374
+ }
27375
+ }
27376
+ break;
27377
+ case "tool_request": {
27378
+ flushPendingText();
27379
+ toolRequestArgsRef.current.set(event.requestId, event.args);
27380
+ const legacyState = event._meta?.legacyState;
27381
+ const displayName = legacyState?.displayName ?? event.name;
27382
+ const isOutputMarkdown = legacyState?.isOutputMarkdown ?? false;
27383
+ const desc = legacyState?.description ?? "";
27384
+ const fallbackKind = "other" /* Other */;
27385
+ const newCall = {
27386
+ callId: event.requestId,
27387
+ name: displayName,
27388
+ originalRequestName: event.name,
27389
+ description: desc,
27390
+ display: event.display,
27391
+ status: "scheduled" /* Scheduled */,
27392
+ isClientInitiated: false,
27393
+ renderOutputAsMarkdown: isOutputMarkdown,
27394
+ kind: legacyState?.kind ?? fallbackKind,
27395
+ confirmationDetails: void 0,
27396
+ resultDisplay: void 0
27397
+ };
27398
+ setTrackedTools((prev) => [...prev, newCall]);
27399
+ break;
27400
+ }
27401
+ case "tool_update": {
27402
+ setTrackedTools(
27403
+ (prev) => prev.map((tc) => {
27404
+ if (tc.callId !== event.requestId) return tc;
27405
+ const legacyState = event._meta?.legacyState;
27406
+ const evtStatus = legacyState?.status;
27407
+ let status = tc.status;
27408
+ if (evtStatus === "executing")
27409
+ status = "executing" /* Executing */;
27410
+ else if (evtStatus === "error") status = "error" /* Error */;
27411
+ else if (evtStatus === "success")
27412
+ status = "success" /* Success */;
27413
+ const display = event.display?.result;
27414
+ const liveOutput = displayContentToString(display) ?? tc.resultDisplay;
27415
+ const progressMessage = legacyState?.progressMessage ?? tc.progressMessage;
27416
+ const progress = legacyState?.progress ?? tc.progress;
27417
+ const progressTotal = legacyState?.progressTotal ?? tc.progressTotal;
27418
+ const ptyId = legacyState?.pid ?? tc.ptyId;
27419
+ const description = legacyState?.description ?? tc.description;
27420
+ return {
27421
+ ...tc,
27422
+ status,
27423
+ display: event.display ? { ...tc.display, ...event.display } : tc.display,
27424
+ resultDisplay: liveOutput,
27425
+ progressMessage,
27426
+ progress,
27427
+ progressTotal,
27428
+ ptyId,
27429
+ description
27430
+ };
27431
+ })
27432
+ );
27433
+ break;
27434
+ }
27435
+ case "tool_response": {
27436
+ setTrackedTools(
27437
+ (prev) => prev.map((tc) => {
27438
+ if (tc.callId !== event.requestId) return tc;
27439
+ const legacyState = event._meta?.legacyState;
27440
+ const outputFile = legacyState?.outputFile;
27441
+ const display = event.display?.result;
27442
+ const resultDisplay = displayContentToString(display) ?? tc.resultDisplay;
27443
+ return {
27444
+ ...tc,
27445
+ status: event.isError ? "error" /* Error */ : "success" /* Success */,
27446
+ display: event.display ? { ...tc.display, ...event.display } : tc.display,
27447
+ resultDisplay,
27448
+ outputFile
27449
+ };
27450
+ })
27451
+ );
27452
+ break;
27453
+ }
27454
+ case "error": {
27455
+ const message = event._meta?.["code"] === "AGENT_EXECUTION_BLOCKED" ? `Agent execution blocked: ${event.message}` : event.message;
27456
+ addItem(
27457
+ { type: "error" /* ERROR */, text: message },
27458
+ userMessageTimestampRef.current
27459
+ );
27460
+ break;
27461
+ }
27462
+ case "initialize":
27463
+ case "session_update":
27464
+ case "elicitation_request":
27465
+ case "elicitation_response":
27466
+ case "usage":
27467
+ case "custom":
27468
+ break;
27469
+ default:
27470
+ debugLogger.error("Unknown agent event type:", event);
27471
+ event;
27472
+ break;
27473
+ }
27474
+ },
27475
+ [
27476
+ addItem,
27477
+ flushPendingText,
27478
+ setPendingHistoryItem,
27479
+ setTrackedTools,
27480
+ setStreamingState,
27481
+ setThought,
27482
+ setLastOutputTime
27483
+ ]
27484
+ );
27485
+ (0, import_react98.useEffect)(() => {
27486
+ const unsubscribe = agent?.subscribe(handleEvent);
27487
+ return () => unsubscribe?.();
27488
+ }, [agent, handleEvent]);
27489
+ useKeypress(
27490
+ (key) => {
27491
+ if (key.name === "escape" && !isShellFocused) {
27492
+ void cancelOngoingRequest(false);
27493
+ return true;
27494
+ }
27495
+ return false;
27496
+ },
27497
+ {
27498
+ isActive: streamingState === "responding" /* Responding */ || streamingState === "waiting_for_confirmation" /* WaitingForConfirmation */
27499
+ }
27500
+ );
27501
+ const submitQuery = (0, import_react98.useCallback)(
27502
+ async (query, options, _prompt_id) => {
27503
+ if (!agent) return;
27504
+ const timestamp = Date.now();
27505
+ setLastOutputTime(timestamp);
27506
+ userMessageTimestampRef.current = timestamp;
27507
+ geminiMessageBufferRef.current = "";
27508
+ if (!options?.isContinuation) {
27509
+ toolRequestArgsRef.current.clear();
27510
+ if (typeof query === "string") {
27511
+ addItem({ type: "user" /* USER */, text: query }, timestamp);
27512
+ void logger?.logMessage("user" /* USER */, query);
27513
+ }
27514
+ startNewPrompt();
27515
+ }
27516
+ const parts = geminiPartsToContentParts(
27517
+ typeof query === "string" ? [{ text: query }] : query
27518
+ );
27519
+ try {
27520
+ const { streamId } = await agent.send({
27521
+ message: { content: parts }
27522
+ });
27523
+ currentStreamIdRef.current = streamId;
27524
+ } catch (err) {
27525
+ addItem(
27526
+ { type: "error" /* ERROR */, text: getErrorMessage(err) },
27527
+ timestamp
27528
+ );
27529
+ }
27530
+ },
27531
+ [agent, addItem, logger, startNewPrompt]
27532
+ );
27533
+ (0, import_react98.useEffect)(() => {
27534
+ if (trackedTools.length > 0) {
27535
+ const isNewBatch = !trackedTools.some(
27536
+ (tc) => pushedToolCallIdsRef.current.has(tc.callId)
27537
+ );
27538
+ if (isNewBatch) {
27539
+ setPushedToolCallIds(/* @__PURE__ */ new Set());
27540
+ setIsFirstToolInGroup(true);
27541
+ }
27542
+ } else if (streamingState === "idle" /* Idle */) {
27543
+ setPushedToolCallIds(/* @__PURE__ */ new Set());
27544
+ setIsFirstToolInGroup(true);
27545
+ }
27546
+ }, [
27547
+ trackedTools,
27548
+ pushedToolCallIdsRef,
27549
+ setPushedToolCallIds,
27550
+ setIsFirstToolInGroup,
27551
+ streamingState
27552
+ ]);
27553
+ (0, import_react98.useEffect)(() => {
27554
+ if (trackedTools.length === 0) return;
27555
+ const allTerminal = trackedTools.every(
27556
+ (tc) => tc.status === "success" || tc.status === "error" || tc.status === "cancelled"
27557
+ );
27558
+ const toolsToPush = trackedTools.filter(
27559
+ (tc) => !pushedToolCallIdsRef.current.has(tc.callId)
27560
+ );
27561
+ if (allTerminal && toolsToPush.length > 0) {
27562
+ const newPushed = new Set(pushedToolCallIdsRef.current);
27563
+ for (const tc of toolsToPush) {
27564
+ newPushed.add(tc.callId);
27565
+ }
27566
+ const appearance = getToolGroupBorderAppearance(
27567
+ { type: "tool_group", tools: trackedTools },
27568
+ activePtyId,
27569
+ !!isShellFocused,
27570
+ [],
27571
+ backgroundTasks
27572
+ );
27573
+ const hasBoxInBatch = toolsToPush.some(
27574
+ (tc) => tc.display?.format !== "notice"
27575
+ );
27576
+ const shouldStartNewBlock = isFirstToolInGroupRef.current || !hasEmittedBoxInTurnRef.current && hasBoxInBatch;
27577
+ const historyItem = {
27578
+ type: "tool_display_group",
27579
+ tools: toolsToPush.map((tc) => ({
27580
+ name: tc.name,
27581
+ description: tc.description,
27582
+ ...tc.display,
27583
+ status: tc.status,
27584
+ originalRequestName: tc.originalRequestName
27585
+ })),
27586
+ borderTop: shouldStartNewBlock,
27587
+ borderBottom: true,
27588
+ ...appearance
27589
+ };
27590
+ addItem(historyItem);
27591
+ setPushedToolCallIds(newPushed);
27592
+ if (hasBoxInBatch) {
27593
+ setHasEmittedBoxInTurn(true);
27594
+ }
27595
+ setIsFirstToolInGroup(false);
27596
+ }
27597
+ }, [
27598
+ trackedTools,
27599
+ pushedToolCallIdsRef,
27600
+ isFirstToolInGroupRef,
27601
+ hasEmittedBoxInTurnRef,
27602
+ setPushedToolCallIds,
27603
+ setIsFirstToolInGroup,
27604
+ setHasEmittedBoxInTurn,
27605
+ addItem,
27606
+ activePtyId,
27607
+ isShellFocused,
27608
+ backgroundTasks
27609
+ ]);
27610
+ const pendingToolGroupItems = (0, import_react98.useMemo)(() => {
27611
+ const remainingTools = trackedTools.filter(
27612
+ (tc) => !pushedToolCallIdsRef.current.has(tc.callId)
27613
+ );
27614
+ const items = [];
27615
+ const appearance = getToolGroupBorderAppearance(
27616
+ { type: "tool_group", tools: trackedTools },
27617
+ activePtyId,
27618
+ !!isShellFocused,
27619
+ [],
27620
+ backgroundTasks
27621
+ );
27622
+ if (remainingTools.length > 0) {
27623
+ const hasBoxInPending = remainingTools.some(
27624
+ (tc) => tc.display?.format !== "notice"
27625
+ );
27626
+ const shouldStartNewBlock = pushedToolCallIds.size === 0 || !hasEmittedBoxInTurnRef.current && hasBoxInPending;
27627
+ items.push({
27628
+ type: "tool_display_group",
27629
+ tools: remainingTools.map((tc) => ({
27630
+ name: tc.name,
27631
+ description: tc.description,
27632
+ ...tc.display,
27633
+ status: tc.status,
27634
+ originalRequestName: tc.originalRequestName
27635
+ })),
27636
+ borderTop: shouldStartNewBlock,
27637
+ borderBottom: false,
27638
+ ...appearance
27639
+ });
27640
+ }
27641
+ const allTerminal = trackedTools.length > 0 && trackedTools.every(
27642
+ (tc) => tc.status === "success" || tc.status === "error" || tc.status === "cancelled"
27643
+ );
27644
+ const allPushed = trackedTools.length > 0 && trackedTools.every((tc) => pushedToolCallIds.has(tc.callId));
27645
+ const anyVisibleInHistory = pushedToolCallIds.size > 0;
27646
+ const anyVisibleInPending = remainingTools.length > 0;
27647
+ if (trackedTools.length > 0 && !(allTerminal && allPushed) && (anyVisibleInHistory || anyVisibleInPending)) {
27648
+ items.push({
27649
+ type: "tool_display_group",
27650
+ tools: [],
27651
+ borderTop: false,
27652
+ borderBottom: true,
27653
+ ...appearance
27654
+ });
27655
+ }
27656
+ return items;
27657
+ }, [
27658
+ trackedTools,
27659
+ pushedToolCallIds,
27660
+ pushedToolCallIdsRef,
27661
+ hasEmittedBoxInTurnRef,
27662
+ activePtyId,
27663
+ isShellFocused,
27664
+ backgroundTasks
27665
+ ]);
27666
+ const pendingHistoryItems = (0, import_react98.useMemo)(
27667
+ () => [pendingHistoryItem, ...pendingToolGroupItems].filter(
27668
+ (i) => i !== void 0 && i !== null
27669
+ ),
27670
+ [pendingHistoryItem, pendingToolGroupItems]
27671
+ );
27672
+ return {
27673
+ streamingState,
27674
+ submitQuery,
27675
+ initError,
27676
+ pendingHistoryItems,
27677
+ thought,
27678
+ cancelOngoingRequest,
27679
+ pendingToolCalls,
27680
+ handleApprovalModeChange,
27681
+ activePtyId,
27682
+ loopDetectionConfirmationRequest,
27683
+ lastOutputTime,
27684
+ backgroundTaskCount,
27685
+ isBackgroundTaskVisible,
27686
+ toggleBackgroundTasks,
27687
+ backgroundCurrentExecution,
27688
+ backgroundTasks,
27689
+ retryStatus,
27690
+ dismissBackgroundTask
27691
+ };
27692
+ };
27693
+
27694
+ // packages/cli/src/ui/hooks/useGeminiStream.ts
27078
27695
  var isTopicTool2 = (name) => name === UPDATE_TOPIC_TOOL_NAME || name === UPDATE_TOPIC_DISPLAY_NAME;
27079
27696
  var SUPPRESSED_TOOL_ERRORS_NOTE = 'Some internal tool attempts failed before this final error. Press F12 for diagnostics, or run /settings and change "Error Verbosity" to full for details.';
27080
27697
  var LOW_VERBOSITY_FAILURE_NOTE = 'This request failed. Press F12 for diagnostics, or run /settings and change "Error Verbosity" to full for full details.';
@@ -27094,7 +27711,7 @@ function getBackgroundedToolInfo(toolCall) {
27094
27711
  };
27095
27712
  }
27096
27713
  function isBackgroundableExecutingToolCall(toolCall) {
27097
- return toolCall.status === CoreToolCallStatus.Executing && typeof toolCall.pid === "number";
27714
+ return toolCall.status === "executing" /* Executing */ && typeof toolCall.pid === "number";
27098
27715
  }
27099
27716
  function showCitations(settings) {
27100
27717
  const enabled = settings.merged.ui.showCitations;
@@ -27104,14 +27721,14 @@ function showCitations(settings) {
27104
27721
  return true;
27105
27722
  }
27106
27723
  function calculateStreamingState(isResponding, toolCalls) {
27107
- if (toolCalls.some((tc) => tc.status === CoreToolCallStatus.AwaitingApproval)) {
27724
+ if (toolCalls.some((tc) => tc.status === "awaiting_approval" /* AwaitingApproval */)) {
27108
27725
  return "waiting_for_confirmation" /* WaitingForConfirmation */;
27109
27726
  }
27110
27727
  const isAnyToolActive = toolCalls.some((tc) => {
27111
- if (tc.status === CoreToolCallStatus.Executing || tc.status === CoreToolCallStatus.Scheduled || tc.status === CoreToolCallStatus.Validating) {
27728
+ if (tc.status === "executing" /* Executing */ || tc.status === "scheduled" /* Scheduled */ || tc.status === "validating" /* Validating */) {
27112
27729
  return true;
27113
27730
  }
27114
- if (tc.status === CoreToolCallStatus.Success || tc.status === CoreToolCallStatus.Error || tc.status === CoreToolCallStatus.Cancelled) {
27731
+ if (tc.status === "success" /* Success */ || tc.status === "error" /* Error */ || tc.status === "cancelled" /* Cancelled */) {
27115
27732
  return !tc.responseSubmittedToGemini;
27116
27733
  }
27117
27734
  return false;
@@ -27122,44 +27739,50 @@ function calculateStreamingState(isResponding, toolCalls) {
27122
27739
  return "idle" /* Idle */;
27123
27740
  }
27124
27741
  var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebugMessage, handleSlashCommand, shellModeActive, getPreferredEditor, onAuthError, _performMemoryRefresh, modelSwitchedFromQuotaError, setModelSwitchedFromQuotaError, onCancelSubmit, setShellInputFocused, terminalWidth, terminalHeight, isShellFocused, consumeUserHint) => {
27125
- const [initError, setInitError] = (0, import_react97.useState)(null);
27126
- const [retryStatus, setRetryStatus] = (0, import_react97.useState)(
27742
+ const [initError, setInitError] = (0, import_react99.useState)(null);
27743
+ const [retryStatus, setRetryStatus] = (0, import_react99.useState)(
27127
27744
  null
27128
27745
  );
27129
27746
  const isLowErrorVerbosity = settings.merged.ui?.errorVerbosity !== "full";
27130
- const suppressedToolErrorCountRef = (0, import_react97.useRef)(0);
27131
- const suppressedToolErrorNoteShownRef = (0, import_react97.useRef)(false);
27132
- const lowVerbosityFailureNoteShownRef = (0, import_react97.useRef)(false);
27133
- const abortControllerRef = (0, import_react97.useRef)(null);
27134
- const turnCancelledRef = (0, import_react97.useRef)(false);
27135
- const activeQueryIdRef = (0, import_react97.useRef)(null);
27136
- const previousApprovalModeRef = (0, import_react97.useRef)(
27747
+ const suppressedToolErrorCountRef = (0, import_react99.useRef)(0);
27748
+ const suppressedToolErrorNoteShownRef = (0, import_react99.useRef)(false);
27749
+ const lowVerbosityFailureNoteShownRef = (0, import_react99.useRef)(false);
27750
+ const abortControllerRef = (0, import_react99.useRef)(null);
27751
+ const turnCancelledRef = (0, import_react99.useRef)(false);
27752
+ const pendingToolCallRequestsRef = (0, import_react99.useRef)([]);
27753
+ const activeSchedulePromiseRef = (0, import_react99.useRef)(null);
27754
+ const cancellationStateRef = (0, import_react99.useRef)(
27755
+ "idle" /* Idle */
27756
+ );
27757
+ const cancelPromiseRef = (0, import_react99.useRef)(Promise.resolve());
27758
+ const activeQueryIdRef = (0, import_react99.useRef)(null);
27759
+ const previousApprovalModeRef = (0, import_react99.useRef)(
27137
27760
  config.getApprovalMode()
27138
27761
  );
27139
27762
  const [isResponding, isRespondingRef, setIsResponding] = useStateAndRef(false);
27140
27763
  const [thought, thoughtRef, setThought] = useStateAndRef(null);
27141
27764
  const [pendingHistoryItem, pendingHistoryItemRef, setPendingHistoryItem] = useStateAndRef(null);
27142
- const [lastGeminiActivityTime, setLastGeminiActivityTime] = (0, import_react97.useState)(0);
27765
+ const [lastGeminiActivityTime, setLastGeminiActivityTime] = (0, import_react99.useState)(0);
27143
27766
  const [pushedToolCallIds, pushedToolCallIdsRef, setPushedToolCallIds] = useStateAndRef(/* @__PURE__ */ new Set());
27144
27767
  const [_isFirstToolInGroup, isFirstToolInGroupRef, setIsFirstToolInGroup] = useStateAndRef(true);
27145
27768
  const { startNewPrompt, getPromptCount } = useSessionStats();
27146
27769
  const logger = useLogger(config);
27147
- const gitService = (0, import_react97.useMemo)(() => {
27770
+ const gitService = (0, import_react99.useMemo)(() => {
27148
27771
  if (!config.getProjectRoot()) {
27149
27772
  return;
27150
27773
  }
27151
27774
  return new GitService(config.getProjectRoot(), config.storage);
27152
27775
  }, [config]);
27153
- (0, import_react97.useEffect)(() => {
27776
+ (0, import_react99.useEffect)(() => {
27154
27777
  const handleRetryAttempt = (payload) => {
27155
27778
  if (turnCancelledRef.current || !isRespondingRef.current) {
27156
27779
  return;
27157
27780
  }
27158
27781
  setRetryStatus(payload);
27159
27782
  };
27160
- coreEvents.on(CoreEvent.RetryAttempt, handleRetryAttempt);
27783
+ coreEvents.on("retry-attempt" /* RetryAttempt */, handleRetryAttempt);
27161
27784
  return () => {
27162
- coreEvents.off(CoreEvent.RetryAttempt, handleRetryAttempt);
27785
+ coreEvents.off("retry-attempt" /* RetryAttempt */, handleRetryAttempt);
27163
27786
  };
27164
27787
  }, [isRespondingRef]);
27165
27788
  const [
@@ -27171,6 +27794,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27171
27794
  lastToolOutputTime
27172
27795
  ] = useToolScheduler(
27173
27796
  async (completedToolCallsFromScheduler) => {
27797
+ pendingToolCallRequestsRef.current = [];
27174
27798
  if (completedToolCallsFromScheduler.length > 0) {
27175
27799
  const toolsToPush = completedToolCallsFromScheduler.filter(
27176
27800
  (tc) => !pushedToolCallIdsRef.current.has(tc.request.callId)
@@ -27205,15 +27829,25 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27205
27829
  }
27206
27830
  setToolCallsForDisplay([]);
27207
27831
  try {
27208
- const currentModel = config.getGeminiClient().getCurrentSequenceModel() ?? config.getModel();
27209
- config.getGeminiClient().getChat().recordCompletedToolCalls(
27210
- currentModel,
27211
- completedToolCallsFromScheduler
27212
- );
27213
- await recordToolCallInteractions(
27214
- config,
27215
- completedToolCallsFromScheduler
27832
+ const client = geminiClient ?? config.getGeminiClient();
27833
+ const currentModel = client?.getCurrentSequenceModel?.() ?? config.getModel();
27834
+ const normalizedCompletedCalls = completedToolCallsFromScheduler.map(
27835
+ (tc) => {
27836
+ if (tc.status === "cancelled" /* Cancelled */ && (!tc.response?.responseParts || tc.response.responseParts.length === 0)) {
27837
+ return {
27838
+ ...tc,
27839
+ response: createCancelledToolCall(
27840
+ tc.request,
27841
+ tc.tool,
27842
+ tc.invocation
27843
+ ).response
27844
+ };
27845
+ }
27846
+ return tc;
27847
+ }
27216
27848
  );
27849
+ client?.getChat?.()?.recordCompletedToolCalls(currentModel, normalizedCompletedCalls);
27850
+ await recordToolCallInteractions(config, normalizedCompletedCalls);
27217
27851
  } catch (error) {
27218
27852
  debugLogger.warn(
27219
27853
  `Error recording completed tool call information: ${error}`
@@ -27225,13 +27859,13 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27225
27859
  config,
27226
27860
  getPreferredEditor
27227
27861
  );
27228
- const activeBackgroundExecutionId = (0, import_react97.useMemo)(() => {
27862
+ const activeBackgroundExecutionId = (0, import_react99.useMemo)(() => {
27229
27863
  const executingBackgroundableTool = toolCalls.find(
27230
27864
  isBackgroundableExecutingToolCall
27231
27865
  );
27232
27866
  return executingBackgroundableTool?.pid;
27233
27867
  }, [toolCalls]);
27234
- const onExec = (0, import_react97.useCallback)(
27868
+ const onExec = (0, import_react99.useCallback)(
27235
27869
  async (done) => {
27236
27870
  setIsResponding(true);
27237
27871
  await done;
@@ -27262,11 +27896,11 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27262
27896
  terminalHeight,
27263
27897
  activeBackgroundExecutionId
27264
27898
  );
27265
- const streamingState = (0, import_react97.useMemo)(
27899
+ const streamingState = (0, import_react99.useMemo)(
27266
27900
  () => calculateStreamingState(isResponding, toolCalls),
27267
27901
  [isResponding, toolCalls]
27268
27902
  );
27269
- (0, import_react97.useEffect)(() => {
27903
+ (0, import_react99.useEffect)(() => {
27270
27904
  if (toolCalls.length > 0) {
27271
27905
  const isNewBatch = !toolCalls.some(
27272
27906
  (tc) => pushedToolCallIdsRef.current.has(tc.request.callId)
@@ -27286,18 +27920,18 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27286
27920
  setIsFirstToolInGroup,
27287
27921
  streamingState
27288
27922
  ]);
27289
- (0, import_react97.useEffect)(() => {
27923
+ (0, import_react99.useEffect)(() => {
27290
27924
  const toolsToPush = [];
27291
27925
  for (let i = 0; i < toolCalls.length; i++) {
27292
27926
  const tc = toolCalls[i];
27293
27927
  if (pushedToolCallIdsRef.current.has(tc.request.callId)) continue;
27294
27928
  if (tc.status === "success" || tc.status === "error" || tc.status === "cancelled") {
27295
- const isAgent = tc.tool?.kind === Kind.Agent;
27929
+ const isAgent = tc.tool?.kind === "agent" /* Agent */;
27296
27930
  if (isAgent) {
27297
27931
  let contigAgentsComplete = true;
27298
27932
  for (let j = i + 1; j < toolCalls.length; j++) {
27299
27933
  const nextTc = toolCalls[j];
27300
- if (nextTc.tool?.kind === Kind.Agent) {
27934
+ if (nextTc.tool?.kind === "agent" /* Agent */) {
27301
27935
  if (nextTc.status !== "success" && nextTc.status !== "error" && nextTc.status !== "cancelled") {
27302
27936
  contigAgentsComplete = false;
27303
27937
  break;
@@ -27323,7 +27957,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27323
27957
  let currentGroup = [];
27324
27958
  for (const tc of toolsToPush) {
27325
27959
  newPushed.add(tc.request.callId);
27326
- if (tc.tool?.kind === Kind.Agent) {
27960
+ if (tc.tool?.kind === "agent" /* Agent */) {
27327
27961
  currentGroup.push(tc);
27328
27962
  } else {
27329
27963
  if (currentGroup.length > 0) {
@@ -27386,7 +28020,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27386
28020
  backgroundTasks,
27387
28021
  settings.merged.ui?.compactToolOutput
27388
28022
  ]);
27389
- const pendingToolGroupItems = (0, import_react97.useMemo)(() => {
28023
+ const pendingToolGroupItems = (0, import_react99.useMemo)(() => {
27390
28024
  const remainingTools = toolCalls.filter(
27391
28025
  (tc) => !pushedToolCallIds.has(tc.request.callId)
27392
28026
  );
@@ -27456,27 +28090,27 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27456
28090
  backgroundTasks,
27457
28091
  settings.merged.ui?.compactToolOutput
27458
28092
  ]);
27459
- const lastQueryRef = (0, import_react97.useRef)(null);
27460
- const lastPromptIdRef = (0, import_react97.useRef)(null);
27461
- const loopDetectedRef = (0, import_react97.useRef)(false);
27462
- const autoNudgeAttemptCountRef = (0, import_react97.useRef)(0);
28093
+ const lastQueryRef = (0, import_react99.useRef)(null);
28094
+ const lastPromptIdRef = (0, import_react99.useRef)(null);
28095
+ const loopDetectedRef = (0, import_react99.useRef)(false);
28096
+ const autoNudgeAttemptCountRef = (0, import_react99.useRef)(0);
27463
28097
  const MAX_AUTO_NUDGE_ATTEMPTS = 2;
27464
- const submitQueryRef = (0, import_react97.useRef)(null);
28098
+ const submitQueryRef = (0, import_react99.useRef)(null);
27465
28099
  const [
27466
28100
  loopDetectionConfirmationRequest,
27467
28101
  setLoopDetectionConfirmationRequest
27468
- ] = (0, import_react97.useState)(null);
28102
+ ] = (0, import_react99.useState)(null);
27469
28103
  const activePtyId = activeShellPtyId ?? activeBackgroundExecutionId ?? void 0;
27470
- const prevActiveShellPtyIdRef = (0, import_react97.useRef)(null);
27471
- (0, import_react97.useEffect)(() => {
28104
+ const prevActiveShellPtyIdRef = (0, import_react99.useRef)(null);
28105
+ (0, import_react99.useEffect)(() => {
27472
28106
  if (turnCancelledRef.current && prevActiveShellPtyIdRef.current !== null && activeShellPtyId === null) {
27473
28107
  addItem({ type: "info" /* INFO */, text: "Request cancelled." });
27474
28108
  setIsResponding(false);
27475
28109
  }
27476
28110
  prevActiveShellPtyIdRef.current = activeShellPtyId;
27477
28111
  }, [activeShellPtyId, addItem, setIsResponding]);
27478
- (0, import_react97.useEffect)(() => {
27479
- if (config.getApprovalMode() === ApprovalMode.YOLO && streamingState === "idle" /* Idle */) {
28112
+ (0, import_react99.useEffect)(() => {
28113
+ if (config.getApprovalMode() === "yolo" /* YOLO */ && streamingState === "idle" /* Idle */) {
27480
28114
  const lastUserMessageIndex = history.findLastIndex(
27481
28115
  (item) => item.type === "user" /* USER */
27482
28116
  );
@@ -27489,12 +28123,12 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27489
28123
  }
27490
28124
  }
27491
28125
  }, [streamingState, config, history]);
27492
- (0, import_react97.useEffect)(() => {
28126
+ (0, import_react99.useEffect)(() => {
27493
28127
  if (!isResponding) {
27494
28128
  setRetryStatus(null);
27495
28129
  }
27496
28130
  }, [isResponding]);
27497
- const maybeAddSuppressedToolErrorNote = (0, import_react97.useCallback)(
28131
+ const maybeAddSuppressedToolErrorNote = (0, import_react99.useCallback)(
27498
28132
  (userMessageTimestamp) => {
27499
28133
  if (!isLowErrorVerbosity) {
27500
28134
  return;
@@ -27516,7 +28150,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27516
28150
  },
27517
28151
  [addItem, isLowErrorVerbosity]
27518
28152
  );
27519
- const maybeAddLowVerbosityFailureNote = (0, import_react97.useCallback)(
28153
+ const maybeAddLowVerbosityFailureNote = (0, import_react99.useCallback)(
27520
28154
  (userMessageTimestamp) => {
27521
28155
  if (!isLowErrorVerbosity || config.getDebugMode()) {
27522
28156
  return;
@@ -27535,16 +28169,25 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27535
28169
  },
27536
28170
  [addItem, config, isLowErrorVerbosity]
27537
28171
  );
27538
- const cancelOngoingRequest = (0, import_react97.useCallback)(
27539
- (clearBuffer = true) => {
28172
+ const cancelOngoingRequest = (0, import_react99.useCallback)(
28173
+ async (clearBuffer = true) => {
27540
28174
  if (turnCancelledRef.current) {
27541
28175
  if (clearBuffer) {
27542
28176
  onCancelSubmit(false, true);
27543
28177
  }
28178
+ if (cancellationStateRef.current === "cancelling" /* Cancelling */) {
28179
+ try {
28180
+ await cancelPromiseRef.current;
28181
+ } catch (error) {
28182
+ debugLogger.warn(
28183
+ `Error awaiting schedulePromise on cancel: ${error}`
28184
+ );
28185
+ }
28186
+ }
27544
28187
  return;
27545
28188
  }
27546
- const hasActiveTools = toolCalls.some(
27547
- (tc) => tc.status === CoreToolCallStatus.Executing || tc.status === CoreToolCallStatus.Scheduled || tc.status === CoreToolCallStatus.Validating
28189
+ const hasActiveTools = pendingToolCallRequestsRef.current.length > 0 || toolCalls.some(
28190
+ (tc) => tc.status === "executing" /* Executing */ || tc.status === "scheduled" /* Scheduled */ || tc.status === "validating" /* Validating */ || tc.status === "awaiting_approval" /* AwaitingApproval */
27548
28191
  );
27549
28192
  if (streamingState === "idle" /* Idle */ && !isRespondingRef.current && !hasActiveTools) {
27550
28193
  if (clearBuffer) {
@@ -27562,6 +28205,74 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27562
28205
  }
27563
28206
  abortControllerRef.current.abort();
27564
28207
  cancelAllToolCalls(abortControllerRef.current.signal);
28208
+ try {
28209
+ const client = geminiClient ?? config.getGeminiClient?.();
28210
+ const chat = client?.getChat?.();
28211
+ if (chat) {
28212
+ const seenCallIds = /* @__PURE__ */ new Set();
28213
+ const synthesizedCalls = [];
28214
+ for (const tc of toolCalls) {
28215
+ if (tc.request.isClientInitiated) {
28216
+ continue;
28217
+ }
28218
+ const isAlreadySubmitted = (tc.status === "success" /* Success */ || tc.status === "error" /* Error */ || tc.status === "cancelled" /* Cancelled */) && tc.responseSubmittedToGemini;
28219
+ if (isAlreadySubmitted) {
28220
+ seenCallIds.add(tc.request.callId);
28221
+ continue;
28222
+ }
28223
+ seenCallIds.add(tc.request.callId);
28224
+ if ((tc.status === "success" /* Success */ || tc.status === "error" /* Error */ || tc.status === "cancelled" /* Cancelled */) && (tc.response?.responseParts?.length ?? 0) > 0) {
28225
+ synthesizedCalls.push(tc);
28226
+ } else {
28227
+ synthesizedCalls.push(
28228
+ createCancelledToolCall(
28229
+ tc.request,
28230
+ tc.tool,
28231
+ "invocation" in tc ? tc.invocation : void 0
28232
+ )
28233
+ );
28234
+ }
28235
+ }
28236
+ for (const req of pendingToolCallRequestsRef.current) {
28237
+ if (req.isClientInitiated || seenCallIds.has(req.callId)) {
28238
+ continue;
28239
+ }
28240
+ seenCallIds.add(req.callId);
28241
+ synthesizedCalls.push(createCancelledToolCall(req));
28242
+ }
28243
+ const clientHistory = client?.getHistory?.() ?? [];
28244
+ const lastTurn = clientHistory.at(-1);
28245
+ if (lastTurn?.role === "model" && Array.isArray(lastTurn.parts)) {
28246
+ let index = 0;
28247
+ for (const part of lastTurn.parts) {
28248
+ const fc = part.functionCall;
28249
+ if (fc?.name) {
28250
+ const callId = fc.id ?? `${fc.name}-${Date.now()}-${index++}`;
28251
+ if (!seenCallIds.has(callId)) {
28252
+ seenCallIds.add(callId);
28253
+ synthesizedCalls.push(
28254
+ createCancelledToolCall({
28255
+ callId,
28256
+ name: fc.name,
28257
+ args: fc.args ?? {},
28258
+ isClientInitiated: false,
28259
+ prompt_id: lastPromptIdRef.current ?? ""
28260
+ })
28261
+ );
28262
+ }
28263
+ }
28264
+ }
28265
+ }
28266
+ if (synthesizedCalls.length > 0) {
28267
+ const currentModel = client?.getCurrentSequenceModel?.() ?? config.getModel?.() ?? "";
28268
+ chat.recordCompletedToolCalls(currentModel, synthesizedCalls);
28269
+ }
28270
+ }
28271
+ } catch (error) {
28272
+ debugLogger.warn(
28273
+ `Error recording cancelled tool calls on abort: ${error}`
28274
+ );
28275
+ }
27565
28276
  if (pendingHistoryItemRef.current) {
27566
28277
  if (pendingHistoryItemRef.current.type === "tool_group" && pendingHistoryItemRef.current.tools.some(
27567
28278
  (t) => t.name === SHELL_COMMAND_NAME
@@ -27571,7 +28282,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27571
28282
  if (tool.name === SHELL_COMMAND_NAME) {
27572
28283
  return {
27573
28284
  ...tool,
27574
- status: CoreToolCallStatus.Cancelled,
28285
+ status: "cancelled" /* Cancelled */,
27575
28286
  resultDisplay: tool.resultDisplay
27576
28287
  };
27577
28288
  }
@@ -27598,6 +28309,35 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27598
28309
  }
27599
28310
  onCancelSubmit(false, clearBuffer);
27600
28311
  setShellInputFocused(false);
28312
+ const schedulePromise = activeSchedulePromiseRef.current;
28313
+ if (schedulePromise) {
28314
+ cancellationStateRef.current = "cancelling" /* Cancelling */;
28315
+ const cancelTask = (async () => {
28316
+ let timeoutId2;
28317
+ try {
28318
+ await Promise.race([
28319
+ Promise.resolve(schedulePromise).catch(() => {
28320
+ }),
28321
+ new Promise((resolve3) => {
28322
+ timeoutId2 = setTimeout(resolve3, 1e3);
28323
+ })
28324
+ ]);
28325
+ } finally {
28326
+ if (timeoutId2 !== void 0) {
28327
+ clearTimeout(timeoutId2);
28328
+ }
28329
+ cancellationStateRef.current = "idle" /* Idle */;
28330
+ }
28331
+ })();
28332
+ cancelPromiseRef.current = cancelTask;
28333
+ try {
28334
+ await cancelTask;
28335
+ } catch (error) {
28336
+ debugLogger.warn(
28337
+ `Error awaiting schedulePromise on cancel: ${error}`
28338
+ );
28339
+ }
28340
+ }
27601
28341
  },
27602
28342
  [
27603
28343
  streamingState,
@@ -27610,13 +28350,15 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27610
28350
  cancelAllToolCalls,
27611
28351
  toolCalls,
27612
28352
  activeShellPtyId,
27613
- setIsResponding
28353
+ setIsResponding,
28354
+ geminiClient,
28355
+ config
27614
28356
  ]
27615
28357
  );
27616
28358
  useKeypress(
27617
28359
  (key) => {
27618
28360
  if (key.name === "escape" && !isShellFocused) {
27619
- cancelOngoingRequest(false);
28361
+ void cancelOngoingRequest(false);
27620
28362
  return true;
27621
28363
  }
27622
28364
  return false;
@@ -27625,7 +28367,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27625
28367
  isActive: streamingState === "responding" /* Responding */ || streamingState === "waiting_for_confirmation" /* WaitingForConfirmation */
27626
28368
  }
27627
28369
  );
27628
- const prepareQueryForGemini = (0, import_react97.useCallback)(
28370
+ const prepareQueryForGemini = (0, import_react99.useCallback)(
27629
28371
  async (query, userMessageTimestamp, abortSignal, prompt_id) => {
27630
28372
  if (turnCancelledRef.current) {
27631
28373
  return { queryToSend: null, shouldProceed: false };
@@ -27636,7 +28378,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27636
28378
  let localQueryToSendToGemini = null;
27637
28379
  if (typeof query === "string") {
27638
28380
  const trimmedQuery = query.trim();
27639
- await logger?.logMessage(MessageSenderType.USER, trimmedQuery);
28381
+ await logger?.logMessage("user" /* USER */, trimmedQuery);
27640
28382
  if (!shellModeActive) {
27641
28383
  const slashCommandResult = isSlashCommand(trimmedQuery) ? await handleSlashCommand(trimmedQuery) : false;
27642
28384
  if (slashCommandResult) {
@@ -27731,7 +28473,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27731
28473
  settings
27732
28474
  ]
27733
28475
  );
27734
- const handleContentEvent = (0, import_react97.useCallback)(
28476
+ const handleContentEvent = (0, import_react99.useCallback)(
27735
28477
  (eventValue, currentGeminiMessageBuffer, userMessageTimestamp) => {
27736
28478
  setRetryStatus(null);
27737
28479
  if (turnCancelledRef.current) {
@@ -27772,7 +28514,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27772
28514
  },
27773
28515
  [addItem, pendingHistoryItemRef, setPendingHistoryItem]
27774
28516
  );
27775
- const handleThoughtEvent = (0, import_react97.useCallback)(
28517
+ const handleThoughtEvent = (0, import_react99.useCallback)(
27776
28518
  (eventValue, _userMessageTimestamp) => {
27777
28519
  setThought(eventValue);
27778
28520
  if (getInlineThinkingMode(settings) === "full") {
@@ -27784,7 +28526,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27784
28526
  },
27785
28527
  [addItem, settings, setThought]
27786
28528
  );
27787
- const handleUserCancelledEvent = (0, import_react97.useCallback)(
28529
+ const handleUserCancelledEvent = (0, import_react99.useCallback)(
27788
28530
  (userMessageTimestamp) => {
27789
28531
  if (turnCancelledRef.current) {
27790
28532
  return;
@@ -27792,7 +28534,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27792
28534
  if (pendingHistoryItemRef.current) {
27793
28535
  if (pendingHistoryItemRef.current.type === "tool_group") {
27794
28536
  const updatedTools = pendingHistoryItemRef.current.tools.map(
27795
- (tool) => tool.status === CoreToolCallStatus.Validating || tool.status === CoreToolCallStatus.Scheduled || tool.status === CoreToolCallStatus.AwaitingApproval || tool.status === CoreToolCallStatus.Executing ? { ...tool, status: CoreToolCallStatus.Cancelled } : tool
28537
+ (tool) => tool.status === "validating" /* Validating */ || tool.status === "scheduled" /* Scheduled */ || tool.status === "awaiting_approval" /* AwaitingApproval */ || tool.status === "executing" /* Executing */ ? { ...tool, status: "cancelled" /* Cancelled */ } : tool
27796
28538
  );
27797
28539
  const pendingItem = {
27798
28540
  ...pendingHistoryItemRef.current,
@@ -27819,7 +28561,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27819
28561
  setIsResponding
27820
28562
  ]
27821
28563
  );
27822
- const handleErrorEvent = (0, import_react97.useCallback)(
28564
+ const handleErrorEvent = (0, import_react99.useCallback)(
27823
28565
  (eventValue, userMessageTimestamp) => {
27824
28566
  if (pendingHistoryItemRef.current) {
27825
28567
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
@@ -27852,7 +28594,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27852
28594
  maybeAddLowVerbosityFailureNote
27853
28595
  ]
27854
28596
  );
27855
- const handleInvalidStreamEvent = (0, import_react97.useCallback)(
28597
+ const handleInvalidStreamEvent = (0, import_react99.useCallback)(
27856
28598
  (eventValue, userMessageTimestamp) => {
27857
28599
  if (pendingHistoryItemRef.current) {
27858
28600
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
@@ -27898,7 +28640,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27898
28640
  geminiClient
27899
28641
  ]
27900
28642
  );
27901
- const handleCitationEvent = (0, import_react97.useCallback)(
28643
+ const handleCitationEvent = (0, import_react99.useCallback)(
27902
28644
  (text, userMessageTimestamp) => {
27903
28645
  if (!showCitations(settings)) {
27904
28646
  return;
@@ -27911,7 +28653,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27911
28653
  },
27912
28654
  [addItem, pendingHistoryItemRef, setPendingHistoryItem, settings]
27913
28655
  );
27914
- const handleFinishedEvent = (0, import_react97.useCallback)(
28656
+ const handleFinishedEvent = (0, import_react99.useCallback)(
27915
28657
  (event, userMessageTimestamp) => {
27916
28658
  const finishReason = event.value.reason;
27917
28659
  if (!finishReason) {
@@ -27947,7 +28689,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27947
28689
  },
27948
28690
  [addItem]
27949
28691
  );
27950
- const handleChatCompressionEvent = (0, import_react97.useCallback)(
28692
+ const handleChatCompressionEvent = (0, import_react99.useCallback)(
27951
28693
  (eventValue, userMessageTimestamp) => {
27952
28694
  if (pendingHistoryItemRef.current) {
27953
28695
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
@@ -27973,14 +28715,14 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27973
28715
  },
27974
28716
  [addItem, pendingHistoryItemRef, setPendingHistoryItem, config]
27975
28717
  );
27976
- const handleMaxSessionTurnsEvent = (0, import_react97.useCallback)(
28718
+ const handleMaxSessionTurnsEvent = (0, import_react99.useCallback)(
27977
28719
  () => addItem({
27978
28720
  type: "info",
27979
28721
  text: `The session has reached the maximum number of turns: ${config.getMaxSessionTurns()}. Please update this limit in your setting.json file.`
27980
28722
  }),
27981
28723
  [addItem, config]
27982
28724
  );
27983
- const handleContextWindowWillOverflowEvent = (0, import_react97.useCallback)(
28725
+ const handleContextWindowWillOverflowEvent = (0, import_react99.useCallback)(
27984
28726
  (estimatedRequestTokenCount, remainingTokenCount) => {
27985
28727
  onCancelSubmit(true);
27986
28728
  const limit = tokenLimit(config.getModel());
@@ -27996,7 +28738,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27996
28738
  },
27997
28739
  [addItem, onCancelSubmit, config]
27998
28740
  );
27999
- const handleChatModelEvent = (0, import_react97.useCallback)(
28741
+ const handleChatModelEvent = (0, import_react99.useCallback)(
28000
28742
  (eventValue, userMessageTimestamp) => {
28001
28743
  if (!settings.merged.ui.showModelInfoInChat) {
28002
28744
  return;
@@ -28015,7 +28757,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28015
28757
  },
28016
28758
  [addItem, pendingHistoryItemRef, setPendingHistoryItem, settings]
28017
28759
  );
28018
- const handleAgentExecutionStoppedEvent = (0, import_react97.useCallback)(
28760
+ const handleAgentExecutionStoppedEvent = (0, import_react99.useCallback)(
28019
28761
  (reason, userMessageTimestamp, systemMessage, contextCleared) => {
28020
28762
  if (pendingHistoryItemRef.current) {
28021
28763
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
@@ -28048,7 +28790,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28048
28790
  maybeAddLowVerbosityFailureNote
28049
28791
  ]
28050
28792
  );
28051
- const handleAgentExecutionBlockedEvent = (0, import_react97.useCallback)(
28793
+ const handleAgentExecutionBlockedEvent = (0, import_react99.useCallback)(
28052
28794
  (reason, userMessageTimestamp, systemMessage, contextCleared) => {
28053
28795
  if (pendingHistoryItemRef.current) {
28054
28796
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
@@ -28079,20 +28821,20 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28079
28821
  maybeAddLowVerbosityFailureNote
28080
28822
  ]
28081
28823
  );
28082
- const processGeminiStreamEvents = (0, import_react97.useCallback)(
28824
+ const processGeminiStreamEvents = (0, import_react99.useCallback)(
28083
28825
  async (stream, userMessageTimestamp, signal, isContinuation, prompt_id) => {
28084
28826
  let geminiMessageBuffer = "";
28085
28827
  const toolCallRequests = [];
28086
28828
  for await (const event of stream) {
28087
- if (event.type !== GeminiEventType.Thought && thoughtRef.current !== null) {
28829
+ if (event.type !== "thought" /* Thought */ && thoughtRef.current !== null) {
28088
28830
  setThought(null);
28089
28831
  }
28090
28832
  switch (event.type) {
28091
- case GeminiEventType.Thought:
28833
+ case "thought" /* Thought */:
28092
28834
  setLastGeminiActivityTime(Date.now());
28093
28835
  handleThoughtEvent(event.value, userMessageTimestamp);
28094
28836
  break;
28095
- case GeminiEventType.Content:
28837
+ case "content" /* Content */:
28096
28838
  setLastGeminiActivityTime(Date.now());
28097
28839
  geminiMessageBuffer = handleContentEvent(
28098
28840
  event.value,
@@ -28100,16 +28842,17 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28100
28842
  userMessageTimestamp
28101
28843
  );
28102
28844
  break;
28103
- case GeminiEventType.ToolCallRequest:
28845
+ case "tool_call_request" /* ToolCallRequest */:
28104
28846
  toolCallRequests.push(event.value);
28847
+ pendingToolCallRequestsRef.current.push(event.value);
28105
28848
  break;
28106
- case GeminiEventType.UserCancelled:
28849
+ case "user_cancelled" /* UserCancelled */:
28107
28850
  handleUserCancelledEvent(userMessageTimestamp);
28108
28851
  break;
28109
- case GeminiEventType.Error:
28852
+ case "error" /* Error */:
28110
28853
  handleErrorEvent(event.value, userMessageTimestamp);
28111
28854
  break;
28112
- case GeminiEventType.AgentExecutionStopped:
28855
+ case "agent_execution_stopped" /* AgentExecutionStopped */:
28113
28856
  handleAgentExecutionStoppedEvent(
28114
28857
  event.value.reason,
28115
28858
  userMessageTimestamp,
@@ -28117,7 +28860,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28117
28860
  event.value.contextCleared
28118
28861
  );
28119
28862
  break;
28120
- case GeminiEventType.AgentExecutionBlocked:
28863
+ case "agent_execution_blocked" /* AgentExecutionBlocked */:
28121
28864
  handleAgentExecutionBlockedEvent(
28122
28865
  event.value.reason,
28123
28866
  userMessageTimestamp,
@@ -28125,36 +28868,36 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28125
28868
  event.value.contextCleared
28126
28869
  );
28127
28870
  break;
28128
- case GeminiEventType.ChatCompressed:
28871
+ case "chat_compressed" /* ChatCompressed */:
28129
28872
  handleChatCompressionEvent(event.value, userMessageTimestamp);
28130
28873
  break;
28131
- case GeminiEventType.ToolCallConfirmation:
28132
- case GeminiEventType.ToolCallResponse:
28874
+ case "tool_call_confirmation" /* ToolCallConfirmation */:
28875
+ case "tool_call_response" /* ToolCallResponse */:
28133
28876
  break;
28134
- case GeminiEventType.MaxSessionTurns:
28877
+ case "max_session_turns" /* MaxSessionTurns */:
28135
28878
  handleMaxSessionTurnsEvent();
28136
28879
  break;
28137
- case GeminiEventType.ContextWindowWillOverflow:
28880
+ case "context_window_will_overflow" /* ContextWindowWillOverflow */:
28138
28881
  handleContextWindowWillOverflowEvent(
28139
28882
  event.value.estimatedRequestTokenCount,
28140
28883
  event.value.remainingTokenCount
28141
28884
  );
28142
28885
  break;
28143
- case GeminiEventType.Finished:
28886
+ case "finished" /* Finished */:
28144
28887
  handleFinishedEvent(event, userMessageTimestamp);
28145
28888
  break;
28146
- case GeminiEventType.Citation:
28889
+ case "citation" /* Citation */:
28147
28890
  handleCitationEvent(event.value, userMessageTimestamp);
28148
28891
  break;
28149
- case GeminiEventType.ModelInfo:
28892
+ case "model_info" /* ModelInfo */:
28150
28893
  handleChatModelEvent(event.value, userMessageTimestamp);
28151
28894
  break;
28152
- case GeminiEventType.LoopDetected:
28895
+ case "loop_detected" /* LoopDetected */:
28153
28896
  loopDetectedRef.current = true;
28154
28897
  break;
28155
- case GeminiEventType.Retry:
28898
+ case "retry" /* Retry */:
28156
28899
  break;
28157
- case GeminiEventType.InvalidStream:
28900
+ case "invalid_stream" /* InvalidStream */:
28158
28901
  handleInvalidStreamEvent(event.value, userMessageTimestamp);
28159
28902
  break;
28160
28903
  default: {
@@ -28168,7 +28911,18 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28168
28911
  addItem(pendingHistoryItemRef.current, userMessageTimestamp);
28169
28912
  setPendingHistoryItem(null);
28170
28913
  }
28171
- await scheduleToolCalls(toolCallRequests, signal);
28914
+ const schedulePromise = Promise.resolve(
28915
+ scheduleToolCalls(toolCallRequests, signal)
28916
+ );
28917
+ activeSchedulePromiseRef.current = schedulePromise;
28918
+ try {
28919
+ await schedulePromise;
28920
+ } finally {
28921
+ if (activeSchedulePromiseRef.current === schedulePromise) {
28922
+ activeSchedulePromiseRef.current = null;
28923
+ }
28924
+ pendingToolCallRequestsRef.current = [];
28925
+ }
28172
28926
  } else {
28173
28927
  const hasVisibleText = geminiMessageBuffer.trim().length > 0;
28174
28928
  if (isContinuation && !hasVisibleText && autoNudgeAttemptCountRef.current < MAX_AUTO_NUDGE_ATTEMPTS) {
@@ -28205,10 +28959,10 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28205
28959
  setThought
28206
28960
  ]
28207
28961
  );
28208
- const submitQuery = (0, import_react97.useCallback)(
28962
+ const submitQuery = (0, import_react99.useCallback)(
28209
28963
  async (query, options, prompt_id) => runInDevTraceSpan(
28210
28964
  {
28211
- operation: options?.isContinuation ? GeminiCliOperation.SystemPrompt : GeminiCliOperation.UserPrompt,
28965
+ operation: options?.isContinuation ? "system_prompt" /* SystemPrompt */ : "user_prompt" /* UserPrompt */,
28212
28966
  sessionId: config.getSessionId()
28213
28967
  },
28214
28968
  async ({ metadata: spanMetadata }) => {
@@ -28219,6 +28973,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28219
28973
  activeQueryIdRef.current = queryId;
28220
28974
  const userMessageTimestamp = Date.now();
28221
28975
  if (!options?.isContinuation) {
28976
+ pendingToolCallRequestsRef.current = [];
28222
28977
  autoNudgeAttemptCountRef.current = 0;
28223
28978
  setModelSwitchedFromQuotaError(false);
28224
28979
  config.setQuotaErrorOccurred(false);
@@ -28370,9 +29125,9 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28370
29125
  ]
28371
29126
  );
28372
29127
  submitQueryRef.current = submitQuery;
28373
- const handleApprovalModeChange = (0, import_react97.useCallback)(
29128
+ const handleApprovalModeChange = (0, import_react99.useCallback)(
28374
29129
  async (newApprovalMode) => {
28375
- if (previousApprovalModeRef.current === ApprovalMode.PLAN && newApprovalMode !== ApprovalMode.PLAN && streamingState === "idle" /* Idle */) {
29130
+ if (previousApprovalModeRef.current === "plan" /* PLAN */ && newApprovalMode !== "plan" /* PLAN */ && streamingState === "idle" /* Idle */) {
28376
29131
  if (geminiClient) {
28377
29132
  try {
28378
29133
  await geminiClient.addHistory({
@@ -28395,11 +29150,11 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28395
29150
  }
28396
29151
  }
28397
29152
  previousApprovalModeRef.current = newApprovalMode;
28398
- if (newApprovalMode === ApprovalMode.YOLO || newApprovalMode === ApprovalMode.AUTO_EDIT) {
29153
+ if (newApprovalMode === "yolo" /* YOLO */ || newApprovalMode === "autoEdit" /* AUTO_EDIT */) {
28399
29154
  let awaitingApprovalCalls = toolCalls.filter(
28400
29155
  (call) => call.status === "awaiting_approval" && !call.request.forcedAsk
28401
29156
  );
28402
- if (newApprovalMode === ApprovalMode.AUTO_EDIT) {
29157
+ if (newApprovalMode === "autoEdit" /* AUTO_EDIT */) {
28403
29158
  awaitingApprovalCalls = awaitingApprovalCalls.filter((call) => {
28404
29159
  if (EDIT_TOOL_NAMES.has(call.request.name)) {
28405
29160
  return true;
@@ -28415,11 +29170,11 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28415
29170
  if (call.correlationId) {
28416
29171
  try {
28417
29172
  await config.getMessageBus().publish({
28418
- type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
29173
+ type: "tool-confirmation-response" /* TOOL_CONFIRMATION_RESPONSE */,
28419
29174
  correlationId: call.correlationId,
28420
29175
  confirmed: true,
28421
29176
  requiresUserConfirmation: false,
28422
- outcome: ToolConfirmationOutcome.ProceedOnce
29177
+ outcome: "proceed_once" /* ProceedOnce */
28423
29178
  });
28424
29179
  } catch (error) {
28425
29180
  debugLogger.warn(
@@ -28433,7 +29188,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28433
29188
  },
28434
29189
  [config, toolCalls, geminiClient, streamingState, addItem, onDebugMessage]
28435
29190
  );
28436
- const handleCompletedTools = (0, import_react97.useCallback)(
29191
+ const handleCompletedTools = (0, import_react99.useCallback)(
28437
29192
  async (completedToolCallsFromScheduler) => {
28438
29193
  const completedAndReadyToSubmitTools = completedToolCallsFromScheduler.filter(
28439
29194
  (tc) => {
@@ -28510,14 +29265,14 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28510
29265
  );
28511
29266
  if (isLowErrorVerbosity) {
28512
29267
  suppressedToolErrorCountRef.current += geminiTools.filter(
28513
- (tc) => tc.status === CoreToolCallStatus.Error
29268
+ (tc) => tc.status === "error" /* Error */
28514
29269
  ).length;
28515
29270
  }
28516
29271
  if (geminiTools.length === 0) {
28517
29272
  return;
28518
29273
  }
28519
29274
  const stopExecutionTool = geminiTools.find(
28520
- (tc) => tc.response.errorType === ToolErrorType.STOP_EXECUTION
29275
+ (tc) => tc.response.errorType === "stop_execution" /* STOP_EXECUTION */
28521
29276
  );
28522
29277
  if (stopExecutionTool && stopExecutionTool.response.error) {
28523
29278
  maybeAddSuppressedToolErrorNote();
@@ -28537,9 +29292,9 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28537
29292
  (tc) => !isTopicTool2(tc.request.name)
28538
29293
  );
28539
29294
  const allDeclinableToolsCancelled = declinableTools.length > 0 && declinableTools.every(
28540
- (tc) => tc.status === CoreToolCallStatus.Cancelled
29295
+ (tc) => tc.status === "cancelled" /* Cancelled */
28541
29296
  );
28542
- const allToolsCancelled = geminiTools.length > 0 && geminiTools.every((tc) => tc.status === CoreToolCallStatus.Cancelled);
29297
+ const allToolsCancelled = geminiTools.length > 0 && geminiTools.every((tc) => tc.status === "cancelled" /* Cancelled */);
28543
29298
  if (allDeclinableToolsCancelled || allToolsCancelled) {
28544
29299
  if (!turnCancelledRef.current) {
28545
29300
  addItem({
@@ -28606,19 +29361,19 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28606
29361
  toolCalls
28607
29362
  ]
28608
29363
  );
28609
- const pendingHistoryItems = (0, import_react97.useMemo)(
29364
+ const pendingHistoryItems = (0, import_react99.useMemo)(
28610
29365
  () => [pendingHistoryItem, ...pendingToolGroupItems].filter(
28611
29366
  (i) => i !== void 0 && i !== null
28612
29367
  ),
28613
29368
  [pendingHistoryItem, pendingToolGroupItems]
28614
29369
  );
28615
- (0, import_react97.useEffect)(() => {
29370
+ (0, import_react99.useEffect)(() => {
28616
29371
  const saveRestorableToolCalls = async () => {
28617
29372
  if (!config.getCheckpointingEnabled()) {
28618
29373
  return;
28619
29374
  }
28620
29375
  const restorableToolCalls = toolCalls.filter(
28621
- (toolCall) => EDIT_TOOL_NAMES.has(toolCall.request.name) && toolCall.status === CoreToolCallStatus.AwaitingApproval
29376
+ (toolCall) => EDIT_TOOL_NAMES.has(toolCall.request.name) && toolCall.status === "awaiting_approval" /* AwaitingApproval */
28622
29377
  );
28623
29378
  if (restorableToolCalls.length > 0) {
28624
29379
  if (!gitService) {
@@ -28681,475 +29436,6 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28681
29436
  };
28682
29437
  };
28683
29438
 
28684
- // packages/cli/src/ui/hooks/useAgentStream.ts
28685
- var import_react99 = __toESM(require_react(), 1);
28686
-
28687
- // packages/cli/src/ui/hooks/useTurnActivityMonitor.ts
28688
- var import_react98 = __toESM(require_react(), 1);
28689
- var useTurnActivityMonitor = (streamingState, activePtyId, pendingToolCalls = []) => {
28690
- const [operationStartTime, setOperationStartTime] = (0, import_react98.useState)(0);
28691
- const prevPtyIdRef = (0, import_react98.useRef)(void 0);
28692
- const prevStreamingStateRef = (0, import_react98.useRef)(void 0);
28693
- (0, import_react98.useEffect)(() => {
28694
- const isNowResponding = streamingState === "responding" /* Responding */;
28695
- const wasResponding = prevStreamingStateRef.current === "responding" /* Responding */;
28696
- const ptyChanged = activePtyId !== prevPtyIdRef.current;
28697
- if (isNowResponding && (!wasResponding || ptyChanged)) {
28698
- setOperationStartTime(Date.now());
28699
- } else if (!isNowResponding && wasResponding) {
28700
- setOperationStartTime(0);
28701
- }
28702
- prevPtyIdRef.current = activePtyId;
28703
- prevStreamingStateRef.current = streamingState;
28704
- }, [streamingState, activePtyId]);
28705
- const isRedirectionActive = (0, import_react98.useMemo)(
28706
- () => (
28707
- // Check active tool calls for run_shell_command
28708
- pendingToolCalls.some((tc) => {
28709
- if (tc.request.name !== "run_shell_command") return false;
28710
- const command = tc.request.args?.command || "";
28711
- return hasRedirection(command);
28712
- })
28713
- ),
28714
- [pendingToolCalls]
28715
- );
28716
- return {
28717
- operationStartTime,
28718
- isRedirectionActive
28719
- };
28720
- };
28721
-
28722
- // packages/cli/src/ui/hooks/useAgentStream.ts
28723
- var useAgentStream = ({
28724
- agent,
28725
- addItem,
28726
- onCancelSubmit,
28727
- isShellFocused,
28728
- logger
28729
- }) => {
28730
- const [initError] = (0, import_react99.useState)(null);
28731
- const [retryStatus] = (0, import_react99.useState)(null);
28732
- const [streamingState, setStreamingState] = (0, import_react99.useState)(
28733
- "idle" /* Idle */
28734
- );
28735
- const [thought, setThought] = (0, import_react99.useState)(null);
28736
- const [lastOutputTime, setLastOutputTime] = (0, import_react99.useState)(Date.now());
28737
- const currentStreamIdRef = (0, import_react99.useRef)(null);
28738
- const userMessageTimestampRef = (0, import_react99.useRef)(0);
28739
- const geminiMessageBufferRef = (0, import_react99.useRef)("");
28740
- const [pendingHistoryItem, pendingHistoryItemRef, setPendingHistoryItem] = useStateAndRef(null);
28741
- const [trackedTools, , setTrackedTools] = useStateAndRef([]);
28742
- const [pushedToolCallIds, pushedToolCallIdsRef, setPushedToolCallIds] = useStateAndRef(/* @__PURE__ */ new Set());
28743
- const [_isFirstToolInGroup, isFirstToolInGroupRef, setIsFirstToolInGroup] = useStateAndRef(true);
28744
- const [_hasEmittedBoxInTurn, hasEmittedBoxInTurnRef, setHasEmittedBoxInTurn] = useStateAndRef(false);
28745
- const { startNewPrompt } = useSessionStats();
28746
- const activePtyId = void 0;
28747
- const backgroundTaskCount = 0;
28748
- const isBackgroundTaskVisible = false;
28749
- const toggleBackgroundTasks = (0, import_react99.useCallback)(() => {
28750
- }, []);
28751
- const backgroundCurrentExecution = void 0;
28752
- const backgroundTasks = (0, import_react99.useMemo)(() => /* @__PURE__ */ new Map(), []);
28753
- const dismissBackgroundTask = (0, import_react99.useCallback)(async (_pid) => {
28754
- }, []);
28755
- const pendingToolCalls = (0, import_react99.useMemo)(
28756
- () => trackedTools.map((t) => ({
28757
- request: {
28758
- name: t.originalRequestName || t.name,
28759
- args: { command: t.description },
28760
- callId: t.callId,
28761
- isClientInitiated: t.isClientInitiated ?? false,
28762
- prompt_id: ""
28763
- },
28764
- status: t.status
28765
- })),
28766
- [trackedTools]
28767
- );
28768
- const [loopDetectionConfirmationRequest] = (0, import_react99.useState)(null);
28769
- const flushPendingText = (0, import_react99.useCallback)(() => {
28770
- if (pendingHistoryItemRef.current) {
28771
- addItem(pendingHistoryItemRef.current, userMessageTimestampRef.current);
28772
- setPendingHistoryItem(null);
28773
- geminiMessageBufferRef.current = "";
28774
- }
28775
- }, [addItem, pendingHistoryItemRef, setPendingHistoryItem]);
28776
- const cancelOngoingRequest = (0, import_react99.useCallback)(
28777
- async (clearBuffer = true) => {
28778
- if (agent) {
28779
- await agent.abort();
28780
- setStreamingState("idle" /* Idle */);
28781
- onCancelSubmit(false, clearBuffer);
28782
- }
28783
- },
28784
- [agent, onCancelSubmit]
28785
- );
28786
- const handleApprovalModeChange = (0, import_react99.useCallback)(
28787
- async (newApprovalMode) => {
28788
- debugLogger.debug(`Approval mode changed to ${newApprovalMode} (stub)`);
28789
- },
28790
- []
28791
- );
28792
- const handleEvent = (0, import_react99.useCallback)(
28793
- (event) => {
28794
- setLastOutputTime(Date.now());
28795
- switch (event.type) {
28796
- case "agent_start":
28797
- setStreamingState("responding" /* Responding */);
28798
- break;
28799
- case "agent_end":
28800
- setStreamingState("idle" /* Idle */);
28801
- flushPendingText();
28802
- break;
28803
- case "message":
28804
- if (event.role === "agent") {
28805
- for (const part of event.content) {
28806
- if (part.type === "text") {
28807
- geminiMessageBufferRef.current += part.text;
28808
- const splitPoint = findLastSafeSplitPoint(
28809
- geminiMessageBufferRef.current
28810
- );
28811
- if (splitPoint === geminiMessageBufferRef.current.length) {
28812
- setPendingHistoryItem({
28813
- type: "gemini",
28814
- text: geminiMessageBufferRef.current
28815
- });
28816
- } else {
28817
- const before = geminiMessageBufferRef.current.substring(
28818
- 0,
28819
- splitPoint
28820
- );
28821
- const after = geminiMessageBufferRef.current.substring(splitPoint);
28822
- addItem(
28823
- { type: "gemini", text: before },
28824
- userMessageTimestampRef.current
28825
- );
28826
- geminiMessageBufferRef.current = after;
28827
- setPendingHistoryItem({
28828
- type: "gemini_content",
28829
- text: after
28830
- });
28831
- }
28832
- } else if (part.type === "thought") {
28833
- setThought(parseThought(part.thought));
28834
- }
28835
- }
28836
- }
28837
- break;
28838
- case "tool_request": {
28839
- flushPendingText();
28840
- const legacyState = event._meta?.legacyState;
28841
- const displayName = legacyState?.displayName ?? event.name;
28842
- const isOutputMarkdown = legacyState?.isOutputMarkdown ?? false;
28843
- const desc = legacyState?.description ?? "";
28844
- const fallbackKind = Kind.Other;
28845
- const newCall = {
28846
- callId: event.requestId,
28847
- name: displayName,
28848
- originalRequestName: event.name,
28849
- description: desc,
28850
- display: event.display,
28851
- status: CoreToolCallStatus.Scheduled,
28852
- isClientInitiated: false,
28853
- renderOutputAsMarkdown: isOutputMarkdown,
28854
- kind: legacyState?.kind ?? fallbackKind,
28855
- confirmationDetails: void 0,
28856
- resultDisplay: void 0
28857
- };
28858
- setTrackedTools((prev) => [...prev, newCall]);
28859
- break;
28860
- }
28861
- case "tool_update": {
28862
- setTrackedTools(
28863
- (prev) => prev.map((tc) => {
28864
- if (tc.callId !== event.requestId) return tc;
28865
- const legacyState = event._meta?.legacyState;
28866
- const evtStatus = legacyState?.status;
28867
- let status = tc.status;
28868
- if (evtStatus === "executing")
28869
- status = CoreToolCallStatus.Executing;
28870
- else if (evtStatus === "error") status = CoreToolCallStatus.Error;
28871
- else if (evtStatus === "success")
28872
- status = CoreToolCallStatus.Success;
28873
- const display = event.display?.result;
28874
- const liveOutput = displayContentToString(display) ?? tc.resultDisplay;
28875
- const progressMessage = legacyState?.progressMessage ?? tc.progressMessage;
28876
- const progress = legacyState?.progress ?? tc.progress;
28877
- const progressTotal = legacyState?.progressTotal ?? tc.progressTotal;
28878
- const ptyId = legacyState?.pid ?? tc.ptyId;
28879
- const description = legacyState?.description ?? tc.description;
28880
- return {
28881
- ...tc,
28882
- status,
28883
- display: event.display ? { ...tc.display, ...event.display } : tc.display,
28884
- resultDisplay: liveOutput,
28885
- progressMessage,
28886
- progress,
28887
- progressTotal,
28888
- ptyId,
28889
- description
28890
- };
28891
- })
28892
- );
28893
- break;
28894
- }
28895
- case "tool_response": {
28896
- setTrackedTools(
28897
- (prev) => prev.map((tc) => {
28898
- if (tc.callId !== event.requestId) return tc;
28899
- const legacyState = event._meta?.legacyState;
28900
- const outputFile = legacyState?.outputFile;
28901
- const display = event.display?.result;
28902
- const resultDisplay = displayContentToString(display) ?? tc.resultDisplay;
28903
- return {
28904
- ...tc,
28905
- status: event.isError ? CoreToolCallStatus.Error : CoreToolCallStatus.Success,
28906
- display: event.display ? { ...tc.display, ...event.display } : tc.display,
28907
- resultDisplay,
28908
- outputFile
28909
- };
28910
- })
28911
- );
28912
- break;
28913
- }
28914
- case "error": {
28915
- const message = event._meta?.["code"] === "AGENT_EXECUTION_BLOCKED" ? `Agent execution blocked: ${event.message}` : event.message;
28916
- addItem(
28917
- { type: "error" /* ERROR */, text: message },
28918
- userMessageTimestampRef.current
28919
- );
28920
- break;
28921
- }
28922
- case "initialize":
28923
- case "session_update":
28924
- case "elicitation_request":
28925
- case "elicitation_response":
28926
- case "usage":
28927
- case "custom":
28928
- break;
28929
- default:
28930
- debugLogger.error("Unknown agent event type:", event);
28931
- event;
28932
- break;
28933
- }
28934
- },
28935
- [
28936
- addItem,
28937
- flushPendingText,
28938
- setPendingHistoryItem,
28939
- setTrackedTools,
28940
- setStreamingState,
28941
- setThought,
28942
- setLastOutputTime
28943
- ]
28944
- );
28945
- (0, import_react99.useEffect)(() => {
28946
- const unsubscribe = agent?.subscribe(handleEvent);
28947
- return () => unsubscribe?.();
28948
- }, [agent, handleEvent]);
28949
- useKeypress(
28950
- (key) => {
28951
- if (key.name === "escape" && !isShellFocused) {
28952
- void cancelOngoingRequest(false);
28953
- return true;
28954
- }
28955
- return false;
28956
- },
28957
- {
28958
- isActive: streamingState === "responding" /* Responding */ || streamingState === "waiting_for_confirmation" /* WaitingForConfirmation */
28959
- }
28960
- );
28961
- const submitQuery = (0, import_react99.useCallback)(
28962
- async (query, options, _prompt_id) => {
28963
- if (!agent) return;
28964
- const timestamp = Date.now();
28965
- setLastOutputTime(timestamp);
28966
- userMessageTimestampRef.current = timestamp;
28967
- geminiMessageBufferRef.current = "";
28968
- if (!options?.isContinuation) {
28969
- if (typeof query === "string") {
28970
- addItem({ type: "user" /* USER */, text: query }, timestamp);
28971
- void logger?.logMessage(MessageSenderType.USER, query);
28972
- }
28973
- startNewPrompt();
28974
- }
28975
- const parts = geminiPartsToContentParts(
28976
- typeof query === "string" ? [{ text: query }] : query
28977
- );
28978
- try {
28979
- const { streamId } = await agent.send({
28980
- message: { content: parts }
28981
- });
28982
- currentStreamIdRef.current = streamId;
28983
- } catch (err) {
28984
- addItem(
28985
- { type: "error" /* ERROR */, text: getErrorMessage(err) },
28986
- timestamp
28987
- );
28988
- }
28989
- },
28990
- [agent, addItem, logger, startNewPrompt]
28991
- );
28992
- (0, import_react99.useEffect)(() => {
28993
- if (trackedTools.length > 0) {
28994
- const isNewBatch = !trackedTools.some(
28995
- (tc) => pushedToolCallIdsRef.current.has(tc.callId)
28996
- );
28997
- if (isNewBatch) {
28998
- setPushedToolCallIds(/* @__PURE__ */ new Set());
28999
- setIsFirstToolInGroup(true);
29000
- }
29001
- } else if (streamingState === "idle" /* Idle */) {
29002
- setPushedToolCallIds(/* @__PURE__ */ new Set());
29003
- setIsFirstToolInGroup(true);
29004
- }
29005
- }, [
29006
- trackedTools,
29007
- pushedToolCallIdsRef,
29008
- setPushedToolCallIds,
29009
- setIsFirstToolInGroup,
29010
- streamingState
29011
- ]);
29012
- (0, import_react99.useEffect)(() => {
29013
- if (trackedTools.length === 0) return;
29014
- const allTerminal = trackedTools.every(
29015
- (tc) => tc.status === "success" || tc.status === "error" || tc.status === "cancelled"
29016
- );
29017
- const toolsToPush = trackedTools.filter(
29018
- (tc) => !pushedToolCallIdsRef.current.has(tc.callId)
29019
- );
29020
- if (allTerminal && toolsToPush.length > 0) {
29021
- const newPushed = new Set(pushedToolCallIdsRef.current);
29022
- for (const tc of toolsToPush) {
29023
- newPushed.add(tc.callId);
29024
- }
29025
- const appearance = getToolGroupBorderAppearance(
29026
- { type: "tool_group", tools: trackedTools },
29027
- activePtyId,
29028
- !!isShellFocused,
29029
- [],
29030
- backgroundTasks
29031
- );
29032
- const hasBoxInBatch = toolsToPush.some(
29033
- (tc) => tc.display?.format !== "notice"
29034
- );
29035
- const shouldStartNewBlock = isFirstToolInGroupRef.current || !hasEmittedBoxInTurnRef.current && hasBoxInBatch;
29036
- const historyItem = {
29037
- type: "tool_display_group",
29038
- tools: toolsToPush.map((tc) => ({
29039
- name: tc.name,
29040
- description: tc.description,
29041
- ...tc.display,
29042
- status: tc.status,
29043
- originalRequestName: tc.originalRequestName
29044
- })),
29045
- borderTop: shouldStartNewBlock,
29046
- borderBottom: true,
29047
- ...appearance
29048
- };
29049
- addItem(historyItem);
29050
- setPushedToolCallIds(newPushed);
29051
- if (hasBoxInBatch) {
29052
- setHasEmittedBoxInTurn(true);
29053
- }
29054
- setIsFirstToolInGroup(false);
29055
- }
29056
- }, [
29057
- trackedTools,
29058
- pushedToolCallIdsRef,
29059
- isFirstToolInGroupRef,
29060
- hasEmittedBoxInTurnRef,
29061
- setPushedToolCallIds,
29062
- setIsFirstToolInGroup,
29063
- setHasEmittedBoxInTurn,
29064
- addItem,
29065
- activePtyId,
29066
- isShellFocused,
29067
- backgroundTasks
29068
- ]);
29069
- const pendingToolGroupItems = (0, import_react99.useMemo)(() => {
29070
- const remainingTools = trackedTools.filter(
29071
- (tc) => !pushedToolCallIdsRef.current.has(tc.callId)
29072
- );
29073
- const items = [];
29074
- const appearance = getToolGroupBorderAppearance(
29075
- { type: "tool_group", tools: trackedTools },
29076
- activePtyId,
29077
- !!isShellFocused,
29078
- [],
29079
- backgroundTasks
29080
- );
29081
- if (remainingTools.length > 0) {
29082
- const hasBoxInPending = remainingTools.some(
29083
- (tc) => tc.display?.format !== "notice"
29084
- );
29085
- const shouldStartNewBlock = pushedToolCallIds.size === 0 || !hasEmittedBoxInTurnRef.current && hasBoxInPending;
29086
- items.push({
29087
- type: "tool_display_group",
29088
- tools: remainingTools.map((tc) => ({
29089
- name: tc.name,
29090
- description: tc.description,
29091
- ...tc.display,
29092
- status: tc.status,
29093
- originalRequestName: tc.originalRequestName
29094
- })),
29095
- borderTop: shouldStartNewBlock,
29096
- borderBottom: false,
29097
- ...appearance
29098
- });
29099
- }
29100
- const allTerminal = trackedTools.length > 0 && trackedTools.every(
29101
- (tc) => tc.status === "success" || tc.status === "error" || tc.status === "cancelled"
29102
- );
29103
- const allPushed = trackedTools.length > 0 && trackedTools.every((tc) => pushedToolCallIds.has(tc.callId));
29104
- const anyVisibleInHistory = pushedToolCallIds.size > 0;
29105
- const anyVisibleInPending = remainingTools.length > 0;
29106
- if (trackedTools.length > 0 && !(allTerminal && allPushed) && (anyVisibleInHistory || anyVisibleInPending)) {
29107
- items.push({
29108
- type: "tool_display_group",
29109
- tools: [],
29110
- borderTop: false,
29111
- borderBottom: true,
29112
- ...appearance
29113
- });
29114
- }
29115
- return items;
29116
- }, [
29117
- trackedTools,
29118
- pushedToolCallIds,
29119
- pushedToolCallIdsRef,
29120
- hasEmittedBoxInTurnRef,
29121
- activePtyId,
29122
- isShellFocused,
29123
- backgroundTasks
29124
- ]);
29125
- const pendingHistoryItems = (0, import_react99.useMemo)(
29126
- () => [pendingHistoryItem, ...pendingToolGroupItems].filter(
29127
- (i) => i !== void 0 && i !== null
29128
- ),
29129
- [pendingHistoryItem, pendingToolGroupItems]
29130
- );
29131
- return {
29132
- streamingState,
29133
- submitQuery,
29134
- initError,
29135
- pendingHistoryItems,
29136
- thought,
29137
- cancelOngoingRequest,
29138
- pendingToolCalls,
29139
- handleApprovalModeChange,
29140
- activePtyId,
29141
- loopDetectionConfirmationRequest,
29142
- lastOutputTime,
29143
- backgroundTaskCount,
29144
- isBackgroundTaskVisible,
29145
- toggleBackgroundTasks,
29146
- backgroundCurrentExecution,
29147
- backgroundTasks,
29148
- retryStatus,
29149
- dismissBackgroundTask
29150
- };
29151
- };
29152
-
29153
29439
  // packages/cli/src/ui/hooks/vim.ts
29154
29440
  var import_react100 = __toESM(require_react(), 1);
29155
29441
  var DIGIT_MULTIPLIER = 10;
@@ -30500,9 +30786,9 @@ var useFolderTrust = (settings, onTrustChange, addItem) => {
30500
30786
  const handleFolderTrustSelect = (0, import_react103.useCallback)(
30501
30787
  async (choice) => {
30502
30788
  const trustLevelMap = {
30503
- ["trust_folder" /* TRUST_FOLDER */]: TrustLevel.TRUST_FOLDER,
30504
- ["trust_parent" /* TRUST_PARENT */]: TrustLevel.TRUST_PARENT,
30505
- ["do_not_trust" /* DO_NOT_TRUST */]: TrustLevel.DO_NOT_TRUST
30789
+ ["trust_folder" /* TRUST_FOLDER */]: "TRUST_FOLDER" /* TRUST_FOLDER */,
30790
+ ["trust_parent" /* TRUST_PARENT */]: "TRUST_PARENT" /* TRUST_PARENT */,
30791
+ ["do_not_trust" /* DO_NOT_TRUST */]: "DO_NOT_TRUST" /* DO_NOT_TRUST */
30506
30792
  };
30507
30793
  const trustLevel = trustLevelMap[choice];
30508
30794
  if (!trustLevel) return;
@@ -30521,7 +30807,7 @@ var useFolderTrust = (settings, onTrustChange, addItem) => {
30521
30807
  }, 100);
30522
30808
  return;
30523
30809
  }
30524
- const currentIsTrusted = trustLevel === TrustLevel.TRUST_FOLDER || trustLevel === TrustLevel.TRUST_PARENT;
30810
+ const currentIsTrusted = trustLevel === "TRUST_FOLDER" /* TRUST_FOLDER */ || trustLevel === "TRUST_PARENT" /* TRUST_PARENT */;
30525
30811
  onTrustChangeRef.current(currentIsTrusted);
30526
30812
  setIsTrusted(currentIsTrusted);
30527
30813
  const wasTrusted = isTrusted ?? false;
@@ -31529,7 +31815,7 @@ function useMessageQueue({
31529
31815
  var import_react105 = __toESM(require_react(), 1);
31530
31816
  function useMcpStatus(config) {
31531
31817
  const [discoveryState, setDiscoveryState] = (0, import_react105.useState)(
31532
- () => config.getMcpClientManager()?.getDiscoveryState() ?? MCPDiscoveryState.NOT_STARTED
31818
+ () => config.getMcpClientManager()?.getDiscoveryState() ?? "not_started" /* NOT_STARTED */
31533
31819
  );
31534
31820
  const [mcpServerCount, setMcpServerCount] = (0, import_react105.useState)(
31535
31821
  () => config.getMcpClientManager()?.getMcpServerCount() ?? 0
@@ -31542,12 +31828,12 @@ function useMcpStatus(config) {
31542
31828
  setMcpServerCount(manager.getMcpServerCount());
31543
31829
  }
31544
31830
  };
31545
- coreEvents.on(CoreEvent.McpClientUpdate, onChange);
31831
+ coreEvents.on("mcp-client-update" /* McpClientUpdate */, onChange);
31546
31832
  return () => {
31547
- coreEvents.off(CoreEvent.McpClientUpdate, onChange);
31833
+ coreEvents.off("mcp-client-update" /* McpClientUpdate */, onChange);
31548
31834
  };
31549
31835
  }, [config]);
31550
- const isMcpReady = discoveryState === MCPDiscoveryState.COMPLETED || discoveryState === MCPDiscoveryState.NOT_STARTED && mcpServerCount === 0;
31836
+ const isMcpReady = discoveryState === "completed" /* COMPLETED */ || discoveryState === "not_started" /* NOT_STARTED */ && mcpServerCount === 0;
31551
31837
  return {
31552
31838
  discoveryState,
31553
31839
  mcpServerCount,
@@ -31574,7 +31860,7 @@ function useApprovalModeIndicator({
31574
31860
  (key) => {
31575
31861
  let nextApprovalMode;
31576
31862
  if (keyMatchers["app.toggleYolo" /* TOGGLE_YOLO */](key)) {
31577
- if (config.isYoloModeDisabled() && config.getApprovalMode() !== ApprovalMode.YOLO) {
31863
+ if (config.isYoloModeDisabled() && config.getApprovalMode() !== "yolo" /* YOLO */) {
31578
31864
  if (addItem) {
31579
31865
  let text = "You cannot enter YOLO mode since it is disabled in your settings.";
31580
31866
  const adminSettings = config.getRemoteAdminSettings();
@@ -31592,21 +31878,21 @@ function useApprovalModeIndicator({
31592
31878
  }
31593
31879
  return;
31594
31880
  }
31595
- nextApprovalMode = config.getApprovalMode() === ApprovalMode.YOLO ? ApprovalMode.DEFAULT : ApprovalMode.YOLO;
31881
+ nextApprovalMode = config.getApprovalMode() === "yolo" /* YOLO */ ? "default" /* DEFAULT */ : "yolo" /* YOLO */;
31596
31882
  } else if (keyMatchers["app.cycleApprovalMode" /* CYCLE_APPROVAL_MODE */](key)) {
31597
31883
  const currentMode = config.getApprovalMode();
31598
31884
  switch (currentMode) {
31599
- case ApprovalMode.DEFAULT:
31600
- nextApprovalMode = ApprovalMode.AUTO_EDIT;
31885
+ case "default" /* DEFAULT */:
31886
+ nextApprovalMode = "autoEdit" /* AUTO_EDIT */;
31601
31887
  break;
31602
- case ApprovalMode.AUTO_EDIT:
31603
- nextApprovalMode = allowPlanMode ? ApprovalMode.PLAN : ApprovalMode.DEFAULT;
31888
+ case "autoEdit" /* AUTO_EDIT */:
31889
+ nextApprovalMode = allowPlanMode ? "plan" /* PLAN */ : "default" /* DEFAULT */;
31604
31890
  break;
31605
- case ApprovalMode.PLAN:
31606
- nextApprovalMode = ApprovalMode.DEFAULT;
31891
+ case "plan" /* PLAN */:
31892
+ nextApprovalMode = "default" /* DEFAULT */;
31607
31893
  break;
31608
- case ApprovalMode.YOLO:
31609
- nextApprovalMode = ApprovalMode.AUTO_EDIT;
31894
+ case "yolo" /* YOLO */:
31895
+ nextApprovalMode = "autoEdit" /* AUTO_EDIT */;
31610
31896
  break;
31611
31897
  default:
31612
31898
  }
@@ -32016,11 +32302,11 @@ var useHookDisplayState = () => {
32016
32302
  removeHook();
32017
32303
  }
32018
32304
  };
32019
- coreEvents.on(CoreEvent.HookStart, handleHookStart);
32020
- coreEvents.on(CoreEvent.HookEnd, handleHookEnd);
32305
+ coreEvents.on("hook-start" /* HookStart */, handleHookStart);
32306
+ coreEvents.on("hook-end" /* HookEnd */, handleHookEnd);
32021
32307
  return () => {
32022
- coreEvents.off(CoreEvent.HookStart, handleHookStart);
32023
- coreEvents.off(CoreEvent.HookEnd, handleHookEnd);
32308
+ coreEvents.off("hook-start" /* HookStart */, handleHookStart);
32309
+ coreEvents.off("hook-end" /* HookEnd */, handleHookEnd);
32024
32310
  activeTimeouts.forEach(clearTimeout);
32025
32311
  activeTimeouts.clear();
32026
32312
  };
@@ -32663,6 +32949,49 @@ function useVisibilityToggle() {
32663
32949
  var import_jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
32664
32950
  var SHELL_WIDTH_FRACTION = 0.89;
32665
32951
  var SHELL_HEIGHT_PADDING = 10;
32952
+ var ENTER_SYNCHRONIZED_OUTPUT = "\x1B[?2026h";
32953
+ var EXIT_SYNCHRONIZED_OUTPUT = "\x1B[?2026l";
32954
+ var RESIZE_DEBOUNCE_MS = 100;
32955
+ var RESIZE_CORK_SAFETY_TIMEOUT_MS = 1e3;
32956
+ function discardCorkedStdoutBuffer(stream) {
32957
+ try {
32958
+ const state = stream._writableState;
32959
+ if (state && (state.corked ?? 0) > 0 && Array.isArray(state.buffered)) {
32960
+ const startIndex = state.bufferedIndex ?? 0;
32961
+ const entries = state.buffered.slice(startIndex);
32962
+ let discardedLength = 0;
32963
+ for (const entry of entries) {
32964
+ if (entry?.chunk) {
32965
+ if (typeof entry.chunk === "string") {
32966
+ discardedLength += Buffer.byteLength(
32967
+ entry.chunk,
32968
+ entry.encoding ?? "utf8"
32969
+ );
32970
+ } else if ("length" in entry.chunk && typeof entry.chunk.length === "number") {
32971
+ discardedLength += entry.chunk.length;
32972
+ }
32973
+ }
32974
+ }
32975
+ state.buffered.length = startIndex;
32976
+ state.length = Math.max(0, (state.length ?? 0) - discardedLength);
32977
+ if ("allBuffers" in state) state.allBuffers = true;
32978
+ if ("allNoop" in state) state.allNoop = true;
32979
+ for (const entry of entries) {
32980
+ if (entry && typeof entry.callback === "function") {
32981
+ entry.callback(null);
32982
+ }
32983
+ }
32984
+ }
32985
+ } catch (error) {
32986
+ debugLogger.warn("Failed to discard corked stdout buffer safely:", error);
32987
+ }
32988
+ }
32989
+ function refreshStdoutSize(stream) {
32990
+ const resizableStream = stream;
32991
+ if (typeof resizableStream._refreshSize === "function") {
32992
+ resizableStream._refreshSize();
32993
+ }
32994
+ }
32666
32995
  var AppContainer = (props) => {
32667
32996
  const isHelpDismissKey = useIsHelpDismissKey();
32668
32997
  const keyMatchers = useKeyMatchers();
@@ -32861,7 +33190,7 @@ var AppContainer = (props) => {
32861
33190
  setConfigInitialized(true);
32862
33191
  startupProfiler.flush(config);
32863
33192
  startAutoMemoryIfEnabled(config);
32864
- const sessionStartSource = resumedSessionData ? SessionStartSource.Resume : SessionStartSource.Startup;
33193
+ const sessionStartSource = resumedSessionData ? "resume" /* Resume */ : "startup" /* Startup */;
32865
33194
  const result = await config.getHookSystem()?.fireSessionStartEvent(sessionStartSource);
32866
33195
  if (result) {
32867
33196
  const additionalContext = result.getAdditionalContext();
@@ -32888,7 +33217,7 @@ var AppContainer = (props) => {
32888
33217
  );
32889
33218
  const ideClient = await IdeClient.getInstance();
32890
33219
  await ideClient.disconnect();
32891
- await config?.getHookSystem()?.fireSessionEndEvent(SessionEndReason.Exit);
33220
+ await config?.getHookSystem()?.fireSessionEndEvent("exit" /* Exit */);
32892
33221
  };
32893
33222
  registerCleanup(cleanupFn);
32894
33223
  return () => {
@@ -32913,11 +33242,11 @@ var AppContainer = (props) => {
32913
33242
  resetTime: payload.resetTime
32914
33243
  });
32915
33244
  };
32916
- coreEvents.on(CoreEvent.ModelChanged, handleModelChanged);
32917
- coreEvents.on(CoreEvent.QuotaChanged, handleQuotaChanged);
33245
+ coreEvents.on("model-changed" /* ModelChanged */, handleModelChanged);
33246
+ coreEvents.on("quota-changed" /* QuotaChanged */, handleQuotaChanged);
32918
33247
  return () => {
32919
- coreEvents.off(CoreEvent.ModelChanged, handleModelChanged);
32920
- coreEvents.off(CoreEvent.QuotaChanged, handleQuotaChanged);
33248
+ coreEvents.off("model-changed" /* ModelChanged */, handleModelChanged);
33249
+ coreEvents.off("quota-changed" /* QuotaChanged */, handleQuotaChanged);
32921
33250
  };
32922
33251
  }, [config]);
32923
33252
  (0, import_react119.useEffect)(() => {
@@ -32930,16 +33259,16 @@ var AppContainer = (props) => {
32930
33259
  const handleAgentsDiscovered = (payload) => {
32931
33260
  setNewAgents(payload.agents);
32932
33261
  };
32933
- coreEvents.on(CoreEvent.SettingsChanged, handleSettingsChanged);
32934
- coreEvents.on(CoreEvent.AdminSettingsChanged, handleAdminSettingsChanged);
32935
- coreEvents.on(CoreEvent.AgentsDiscovered, handleAgentsDiscovered);
33262
+ coreEvents.on("settings-changed" /* SettingsChanged */, handleSettingsChanged);
33263
+ coreEvents.on("admin-settings-changed" /* AdminSettingsChanged */, handleAdminSettingsChanged);
33264
+ coreEvents.on("agents-discovered" /* AgentsDiscovered */, handleAgentsDiscovered);
32936
33265
  return () => {
32937
- coreEvents.off(CoreEvent.SettingsChanged, handleSettingsChanged);
33266
+ coreEvents.off("settings-changed" /* SettingsChanged */, handleSettingsChanged);
32938
33267
  coreEvents.off(
32939
- CoreEvent.AdminSettingsChanged,
33268
+ "admin-settings-changed" /* AdminSettingsChanged */,
32940
33269
  handleAdminSettingsChanged
32941
33270
  );
32942
- coreEvents.off(CoreEvent.AgentsDiscovered, handleAgentsDiscovered);
33271
+ coreEvents.off("agents-discovered" /* AgentsDiscovered */, handleAgentsDiscovered);
32943
33272
  };
32944
33273
  }, [settings]);
32945
33274
  const { errorCount, clearErrorCount } = useErrorCount();
@@ -32976,12 +33305,89 @@ var AppContainer = (props) => {
32976
33305
  addConfirmUpdateExtensionRequest,
32977
33306
  addItem: historyManager.addItem
32978
33307
  });
33308
+ const isStdoutCorkedRef = (0, import_react119.useRef)(false);
33309
+ const isRefreshingStaticRef = (0, import_react119.useRef)(false);
33310
+ const resizeCorkSafetyTimerRef = (0, import_react119.useRef)(null);
33311
+ const resizeDebounceTimerRef = (0, import_react119.useRef)(null);
33312
+ const lastStdoutColumnsRef = (0, import_react119.useRef)(
33313
+ stdout.columns ?? process12.stdout.columns ?? terminalWidth
33314
+ );
33315
+ const lastRefreshedColumnsRef = (0, import_react119.useRef)(terminalWidth);
33316
+ const terminalWidthRef = (0, import_react119.useRef)(terminalWidth);
33317
+ terminalWidthRef.current = terminalWidth;
33318
+ const clearResizeCorkSafetyTimer = (0, import_react119.useCallback)(() => {
33319
+ if (resizeCorkSafetyTimerRef.current) {
33320
+ clearTimeout(resizeCorkSafetyTimerRef.current);
33321
+ resizeCorkSafetyTimerRef.current = null;
33322
+ }
33323
+ }, []);
33324
+ const clearResizeDebounceTimer = (0, import_react119.useCallback)(() => {
33325
+ if (resizeDebounceTimerRef.current) {
33326
+ clearTimeout(resizeDebounceTimerRef.current);
33327
+ resizeDebounceTimerRef.current = null;
33328
+ }
33329
+ }, []);
33330
+ const corkStdout = (0, import_react119.useCallback)(() => {
33331
+ if (!isStdoutCorkedRef.current && typeof stdout.cork === "function") {
33332
+ stdout.cork();
33333
+ isStdoutCorkedRef.current = true;
33334
+ }
33335
+ }, [stdout]);
33336
+ const uncorkStdout = (0, import_react119.useCallback)(() => {
33337
+ clearResizeCorkSafetyTimer();
33338
+ if (isStdoutCorkedRef.current && typeof stdout.uncork === "function") {
33339
+ isStdoutCorkedRef.current = false;
33340
+ stdout.uncork();
33341
+ }
33342
+ }, [stdout, clearResizeCorkSafetyTimer]);
32979
33343
  const refreshStatic = (0, import_react119.useCallback)(() => {
32980
33344
  if (!isAlternateBuffer && !config.getUseTerminalBuffer()) {
33345
+ clearResizeDebounceTimer();
33346
+ refreshStdoutSize(stdout);
33347
+ if (typeof stdout.prependListener === "function" && stdout.columns !== void 0 && stdout.columns !== terminalWidthRef.current) {
33348
+ corkStdout();
33349
+ clearResizeCorkSafetyTimer();
33350
+ resizeCorkSafetyTimerRef.current = setTimeout(() => {
33351
+ discardCorkedStdoutBuffer(stdout);
33352
+ uncorkStdout();
33353
+ }, RESIZE_CORK_SAFETY_TIMEOUT_MS);
33354
+ return;
33355
+ }
33356
+ clearResizeCorkSafetyTimer();
33357
+ lastRefreshedColumnsRef.current = terminalWidthRef.current;
33358
+ if (typeof stdout.cork === "function") {
33359
+ corkStdout();
33360
+ discardCorkedStdoutBuffer(stdout);
33361
+ isRefreshingStaticRef.current = true;
33362
+ stdout.write(ENTER_SYNCHRONIZED_OUTPUT);
33363
+ }
32981
33364
  stdout.write(base_exports.clearTerminal);
32982
33365
  setHistoryRemountKey((prev) => prev + 1);
32983
33366
  }
32984
- }, [setHistoryRemountKey, isAlternateBuffer, stdout, config]);
33367
+ }, [
33368
+ setHistoryRemountKey,
33369
+ isAlternateBuffer,
33370
+ stdout,
33371
+ config,
33372
+ clearResizeDebounceTimer,
33373
+ clearResizeCorkSafetyTimer,
33374
+ corkStdout,
33375
+ uncorkStdout
33376
+ ]);
33377
+ (0, import_react119.useLayoutEffect)(() => {
33378
+ if (isRefreshingStaticRef.current) {
33379
+ isRefreshingStaticRef.current = false;
33380
+ refreshStdoutSize(stdout);
33381
+ if (stdout.columns !== void 0 && stdout.columns !== lastRefreshedColumnsRef.current) {
33382
+ discardCorkedStdoutBuffer(stdout);
33383
+ stdout.write(EXIT_SYNCHRONIZED_OUTPUT);
33384
+ uncorkStdout();
33385
+ return;
33386
+ }
33387
+ stdout.write(EXIT_SYNCHRONIZED_OUTPUT);
33388
+ uncorkStdout();
33389
+ }
33390
+ }, [historyRemountKey, stdout, uncorkStdout]);
32985
33391
  const shouldUseAlternateScreen = shouldEnterAlternateScreen(
32986
33392
  isAlternateBuffer,
32987
33393
  config.getScreenReader()
@@ -33006,11 +33412,11 @@ var AppContainer = (props) => {
33006
33412
  exitEditorDialog
33007
33413
  } = useEditorSettings(settings, setEditorError, historyManager.addItem);
33008
33414
  (0, import_react119.useEffect)(() => {
33009
- coreEvents.on(CoreEvent.ExternalEditorClosed, handleEditorClose);
33010
- coreEvents.on(CoreEvent.RequestEditorSelection, openEditorDialog);
33415
+ coreEvents.on("external-editor-closed" /* ExternalEditorClosed */, handleEditorClose);
33416
+ coreEvents.on("request-editor-selection" /* RequestEditorSelection */, openEditorDialog);
33011
33417
  return () => {
33012
- coreEvents.off(CoreEvent.ExternalEditorClosed, handleEditorClose);
33013
- coreEvents.off(CoreEvent.RequestEditorSelection, openEditorDialog);
33418
+ coreEvents.off("external-editor-closed" /* ExternalEditorClosed */, handleEditorClose);
33419
+ coreEvents.off("request-editor-selection" /* RequestEditorSelection */, openEditorDialog);
33014
33420
  };
33015
33421
  }, [handleEditorClose, openEditorDialog]);
33016
33422
  (0, import_react119.useEffect)(() => {
@@ -33081,7 +33487,7 @@ var AppContainer = (props) => {
33081
33487
  errorVerbosity: settings.merged.ui.errorVerbosity
33082
33488
  });
33083
33489
  const isAuthDialogOpen = authState === "updating" /* Updating */;
33084
- const isAuthenticating = authState === "unauthenticated" /* Unauthenticated */ && settings.merged.security.auth.selectedType !== AuthType.USE_GEMINI;
33490
+ const isAuthenticating = authState === "unauthenticated" /* Unauthenticated */ && settings.merged.security.auth.selectedType !== "gemini-api-key" /* USE_GEMINI */;
33085
33491
  const isGeminiClientInitialized = config.getGeminiClient()?.isInitialized();
33086
33492
  const { loadHistoryForResume, isResuming } = useSessionResume({
33087
33493
  config,
@@ -33109,7 +33515,7 @@ var AppContainer = (props) => {
33109
33515
  async (authType, scope) => {
33110
33516
  if (authType) {
33111
33517
  const previousAuthType = config.getContentGeneratorConfig()?.authType ?? "unknown";
33112
- if (authType === AuthType.LOGIN_WITH_GOOGLE) {
33518
+ if (authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */) {
33113
33519
  setAuthContext({ requiresRestart: true });
33114
33520
  } else {
33115
33521
  setAuthContext({});
@@ -33137,7 +33543,7 @@ var AppContainer = (props) => {
33137
33543
  );
33138
33544
  return;
33139
33545
  }
33140
- if (authType === AuthType.LOGIN_WITH_GOOGLE && config.isBrowserLaunchSuppressed()) {
33546
+ if (authType === "oauth-personal" /* LOGIN_WITH_GOOGLE */ && config.isBrowserLaunchSuppressed()) {
33141
33547
  writeToStdout(`
33142
33548
  ----------------------------------------------------------------
33143
33549
  Logging in with Google... Restarting Gemini CLI to continue.
@@ -33160,7 +33566,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
33160
33566
  }
33161
33567
  await saveApiKey(apiKey);
33162
33568
  await reloadApiKey();
33163
- await config.refreshAuth(AuthType.USE_GEMINI);
33569
+ await config.refreshAuth("gemini-api-key" /* USE_GEMINI */);
33164
33570
  setAuthState("authenticated" /* Authenticated */);
33165
33571
  } catch (e) {
33166
33572
  onAuthError(
@@ -33185,7 +33591,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
33185
33591
  `Authentication is enforced to be ${settings.merged.security.auth.enforcedType}, but you are currently using ${settings.merged.security.auth.selectedType}.`
33186
33592
  );
33187
33593
  } else if (settings.merged.security.auth.selectedType && !settings.merged.security.auth.useExternal) {
33188
- if (settings.merged.security.auth.selectedType === AuthType.USE_GEMINI) {
33594
+ if (settings.merged.security.auth.selectedType === "gemini-api-key" /* USE_GEMINI */) {
33189
33595
  return;
33190
33596
  }
33191
33597
  const authMethod = settings.merged.security.auth.selectedType;
@@ -33226,6 +33632,28 @@ Logging in with Google... Restarting Gemini CLI to continue.
33226
33632
  toggleCleanUiDetailsVisible,
33227
33633
  revealCleanUiDetailsTemporarily
33228
33634
  } = useVisibilityToggle();
33635
+ const cancelPromiseRef = (0, import_react119.useRef)(null);
33636
+ const awaitCancelPromise = (0, import_react119.useCallback)(async () => {
33637
+ if (!cancelPromiseRef.current) {
33638
+ return;
33639
+ }
33640
+ let timeoutId2;
33641
+ try {
33642
+ await Promise.race([
33643
+ cancelPromiseRef.current,
33644
+ new Promise((resolve3) => {
33645
+ timeoutId2 = setTimeout(resolve3, 1e3);
33646
+ })
33647
+ ]);
33648
+ } catch (error) {
33649
+ debugLogger.warn(`Error awaiting cancellation: ${error}`);
33650
+ } finally {
33651
+ if (timeoutId2 !== void 0) {
33652
+ clearTimeout(timeoutId2);
33653
+ }
33654
+ cancelPromiseRef.current = null;
33655
+ }
33656
+ }, []);
33229
33657
  const slashCommandActions = (0, import_react119.useMemo)(
33230
33658
  () => ({
33231
33659
  openAuthDialog: () => setAuthState("updating" /* Updating */),
@@ -33242,6 +33670,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
33242
33670
  closeThemeDialog();
33243
33671
  setQuittingMessages(messages);
33244
33672
  setTimeout(async () => {
33673
+ await awaitCancelPromise();
33245
33674
  await runExitCleanup();
33246
33675
  process12.exit(0);
33247
33676
  }, 100);
@@ -33277,6 +33706,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
33277
33706
  openVoiceModelDialog,
33278
33707
  openAgentConfigDialog,
33279
33708
  setQuittingMessages,
33709
+ awaitCancelPromise,
33280
33710
  setDebugMessage,
33281
33711
  setShowPrivacyNotice,
33282
33712
  setCorgiMode,
@@ -33321,9 +33751,9 @@ Logging in with Google... Restarting Gemini CLI to continue.
33321
33751
  }
33322
33752
  });
33323
33753
  };
33324
- coreEvents.on(CoreEvent.ConsentRequest, handleConsentRequest);
33754
+ coreEvents.on("consent-request" /* ConsentRequest */, handleConsentRequest);
33325
33755
  return () => {
33326
- coreEvents.off(CoreEvent.ConsentRequest, handleConsentRequest);
33756
+ coreEvents.off("consent-request" /* ConsentRequest */, handleConsentRequest);
33327
33757
  };
33328
33758
  }, []);
33329
33759
  const performMemoryRefresh = (0, import_react119.useCallback)(async () => {
@@ -33423,6 +33853,7 @@ Logging in with Google... Restarting Gemini CLI to continue.
33423
33853
  // eslint-disable-next-line react-hooks/rules-of-hooks
33424
33854
  useAgentStream({
33425
33855
  agent: streamAgent,
33856
+ config,
33426
33857
  addItem: historyManager.addItem,
33427
33858
  onCancelSubmit,
33428
33859
  isShellFocused: embeddedShellFocused,
@@ -33777,15 +34208,18 @@ ${queuedText}` : queuedText;
33777
34208
  const [showFullTodos, setShowFullTodos] = (0, import_react119.useState)(false);
33778
34209
  const [renderMarkdown, setRenderMarkdown] = (0, import_react119.useState)(true);
33779
34210
  const handleExitRepeat = (0, import_react119.useCallback)(
33780
- (count) => {
34211
+ async (count) => {
33781
34212
  if (count > 2) {
33782
34213
  recordExitFail(config);
33783
34214
  }
33784
34215
  if (count > 1) {
33785
- void handleSlashCommand("/quit", void 0, void 0, false);
34216
+ if (cancelPromiseRef.current) {
34217
+ await awaitCancelPromise();
34218
+ }
34219
+ await handleSlashCommand("/quit", void 0, void 0, false);
33786
34220
  }
33787
34221
  },
33788
- [config, handleSlashCommand]
34222
+ [config, handleSlashCommand, awaitCancelPromise]
33789
34223
  );
33790
34224
  const { pressCount: ctrlCPressCount, handlePress: handleCtrlCPress } = useRepeatedKeyPress({
33791
34225
  windowMs: WARNING_PROMPT_DURATION_MS,
@@ -33813,6 +34247,7 @@ ${queuedText}` : queuedText;
33813
34247
  needsRestart: ideNeedsRestart,
33814
34248
  restartReason: ideTrustRestartReason
33815
34249
  } = useIdeTrustListener();
34250
+ const prevWidthRef = (0, import_react119.useRef)(terminalWidth);
33816
34251
  useIncludeDirsTrust(config, isTrustedFolder, historyManager, setCustomDialog);
33817
34252
  const tabFocusTimeoutRef = (0, import_react119.useRef)(null);
33818
34253
  (0, import_react119.useEffect)(() => {
@@ -33862,6 +34297,64 @@ ${queuedText}` : queuedText;
33862
34297
  setShowIdeRestartPrompt(true);
33863
34298
  }
33864
34299
  }, [ideNeedsRestart]);
34300
+ (0, import_react119.useEffect)(() => {
34301
+ if (isAlternateBuffer || config.getUseTerminalBuffer() || typeof stdout.prependListener !== "function") {
34302
+ return;
34303
+ }
34304
+ const handleResizeStart = () => {
34305
+ const currentColumns = stdout.columns ?? process12.stdout.columns;
34306
+ if (currentColumns !== void 0 && currentColumns !== lastStdoutColumnsRef.current) {
34307
+ lastStdoutColumnsRef.current = currentColumns;
34308
+ corkStdout();
34309
+ clearResizeCorkSafetyTimer();
34310
+ resizeCorkSafetyTimerRef.current = setTimeout(() => {
34311
+ discardCorkedStdoutBuffer(stdout);
34312
+ uncorkStdout();
34313
+ }, RESIZE_CORK_SAFETY_TIMEOUT_MS);
34314
+ }
34315
+ };
34316
+ stdout.prependListener("resize", handleResizeStart);
34317
+ return () => {
34318
+ stdout.off("resize", handleResizeStart);
34319
+ clearResizeDebounceTimer();
34320
+ if (isRefreshingStaticRef.current) {
34321
+ isRefreshingStaticRef.current = false;
34322
+ stdout.write(EXIT_SYNCHRONIZED_OUTPUT);
34323
+ }
34324
+ uncorkStdout();
34325
+ };
34326
+ }, [
34327
+ stdout,
34328
+ isAlternateBuffer,
34329
+ config,
34330
+ corkStdout,
34331
+ uncorkStdout,
34332
+ clearResizeDebounceTimer,
34333
+ clearResizeCorkSafetyTimer
34334
+ ]);
34335
+ (0, import_react119.useEffect)(() => {
34336
+ if (prevWidthRef.current === terminalWidth) {
34337
+ return;
34338
+ }
34339
+ prevWidthRef.current = terminalWidth;
34340
+ if (isAlternateBuffer || config.getUseTerminalBuffer()) {
34341
+ clearResizeDebounceTimer();
34342
+ return;
34343
+ }
34344
+ clearResizeDebounceTimer();
34345
+ resizeDebounceTimerRef.current = setTimeout(() => {
34346
+ refreshStatic();
34347
+ }, RESIZE_DEBOUNCE_MS);
34348
+ return () => {
34349
+ clearResizeDebounceTimer();
34350
+ };
34351
+ }, [
34352
+ terminalWidth,
34353
+ refreshStatic,
34354
+ clearResizeDebounceTimer,
34355
+ isAlternateBuffer,
34356
+ config
34357
+ ]);
33865
34358
  (0, import_react119.useEffect)(() => {
33866
34359
  const unsubscribe = ideContextStore.subscribe(setIdeContextState);
33867
34360
  setIdeContextState(ideContextStore.get());
@@ -33893,7 +34386,7 @@ ${queuedText}` : queuedText;
33893
34386
  [handleSlashCommand, settings]
33894
34387
  );
33895
34388
  const isAwaitingLoginRestart = authState === "awaiting_login_restart" /* AwaitingLoginRestart */;
33896
- const loginRestartMessage = settings.merged.security.auth.selectedType === AuthType.USE_VERTEX_AI ? "Authenticating to Vertex AI in Cloud Shell requires a restart to apply project settings." : void 0;
34389
+ const loginRestartMessage = settings.merged.security.auth.selectedType === "vertex-ai" /* USE_VERTEX_AI */ ? "Authenticating to Vertex AI in Cloud Shell requires a restart to apply project settings." : void 0;
33897
34390
  const dialogsVisible = shouldShowIdePrompt || isFolderTrustDialogOpen || isPolicyUpdateDialogOpen || adminSettingsChanged || !!commandConfirmationRequest || !!authConsentRequest || !!permissionConfirmationRequest || !!customDialog || confirmUpdateExtensionRequests.length > 0 || !!loopDetectionConfirmationRequest || isThemeDialogOpen || isSettingsDialogOpen || isModelDialogOpen || isVoiceModelDialogOpen || isAgentConfigDialogOpen || isPermissionsDialogOpen || isAuthenticating || isAuthDialogOpen || isEditorDialogOpen || showPrivacyNotice || showIdeRestartPrompt || !!proQuotaRequest || !!validationRequest || !!overageMenuRequest || !!emptyWalletRequest || isSessionBrowserOpen || authState === "awaiting_api_key_input" /* AwaitingApiKeyInput */ || isAwaitingLoginRestart || !!newAgents;
33898
34391
  const handleGlobalKeypress = (0, import_react119.useCallback)(
33899
34392
  (key) => {
@@ -33916,7 +34409,10 @@ ${queuedText}` : queuedText;
33916
34409
  return true;
33917
34410
  }
33918
34411
  if (keyMatchers["basic.quit" /* QUIT */](key)) {
33919
- void cancelOngoingRequest?.();
34412
+ const cancelPromise = cancelOngoingRequest?.();
34413
+ if (cancelPromise) {
34414
+ cancelPromiseRef.current = cancelPromise;
34415
+ }
33920
34416
  handleCtrlCPress();
33921
34417
  return true;
33922
34418
  } else if (keyMatchers["basic.exit" /* EXIT */](key)) {
@@ -33983,7 +34479,7 @@ ${queuedText}` : queuedText;
33983
34479
  if (keyMatchers["app.showErrorDetails" /* SHOW_ERROR_DETAILS */](key)) {
33984
34480
  if (settings.merged.general.devtools) {
33985
34481
  void (async () => {
33986
- const { toggleDevToolsPanel } = await import("./devtoolsService-CSRUFNFL.js");
34482
+ const { toggleDevToolsPanel } = await import("./devtoolsService-HIZA3JGR.js");
33987
34483
  await toggleDevToolsPanel(
33988
34484
  config,
33989
34485
  showErrorDetails,
@@ -34204,12 +34700,12 @@ ${queuedText}` : queuedText;
34204
34700
  Date.now()
34205
34701
  );
34206
34702
  };
34207
- coreEvents.on(CoreEvent.UserFeedback, handleUserFeedback);
34208
- coreEvents.on(CoreEvent.HookSystemMessage, handleHookSystemMessage);
34703
+ coreEvents.on("user-feedback" /* UserFeedback */, handleUserFeedback);
34704
+ coreEvents.on("hook-system-message" /* HookSystemMessage */, handleHookSystemMessage);
34209
34705
  coreEvents.drainBacklogs();
34210
34706
  return () => {
34211
- coreEvents.off(CoreEvent.UserFeedback, handleUserFeedback);
34212
- coreEvents.off(CoreEvent.HookSystemMessage, handleHookSystemMessage);
34707
+ coreEvents.off("user-feedback" /* UserFeedback */, handleUserFeedback);
34708
+ coreEvents.off("hook-system-message" /* HookSystemMessage */, handleHookSystemMessage);
34213
34709
  };
34214
34710
  }, [historyManager]);
34215
34711
  const nightly = props.version.includes("nightly");
@@ -34318,9 +34814,9 @@ ${queuedText}` : queuedText;
34318
34814
  const handleMemoryChanged = (result) => {
34319
34815
  setGeminiMdFileCount(result.fileCount);
34320
34816
  };
34321
- coreEvents.on(CoreEvent.MemoryChanged, handleMemoryChanged);
34817
+ coreEvents.on("memory-changed" /* MemoryChanged */, handleMemoryChanged);
34322
34818
  return () => {
34323
- coreEvents.off(CoreEvent.MemoryChanged, handleMemoryChanged);
34819
+ coreEvents.off("memory-changed" /* MemoryChanged */, handleMemoryChanged);
34324
34820
  };
34325
34821
  }, []);
34326
34822
  (0, import_react119.useEffect)(() => {